Author: dazarov
Date: 2008-02-12 08:21:15 -0500 (Tue, 12 Feb 2008)
New Revision: 6259
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui/icons/open_seam_project.gif
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/actions/OpenSeamComponentAction.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/OpenSeamComponentDialog.java
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/OpenSeamComponentDialogTest.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties
Log:
http://jira.jboss.com/jira/browse/JBIDE-518
Added: trunk/seam/plugins/org.jboss.tools.seam.ui/icons/open_seam_project.gif
===================================================================
(Binary files differ)
Property changes on:
trunk/seam/plugins/org.jboss.tools.seam.ui/icons/open_seam_project.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml 2008-02-12 13:14:09 UTC (rev
6258)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml 2008-02-12 13:21:15 UTC (rev
6259)
@@ -418,4 +418,41 @@
name="Seam">
</perspective>
</extension>
+ <extension
+ point="org.eclipse.ui.actionSets">
+ <actionSet
+ label="Seam Navigation"
+ description="Seam Navigation Action Set"
+ visible="true"
+ id="org.jboss.tools.seam.ui.SeamActionSet">
+ <action
+ class="org.jboss.tools.seam.ui.actions.OpenSeamComponentAction"
+ definitionId="org.jboss.tools.seam.ui.open.component"
+ helpContextId="org.eclipse.jdt.ui.open_type_action"
+ icon="icons/open_seam_project.gif"
+ id="openComponent"
+ label="Open Seam Component"
+ menubarPath="navigate/open.ext2"
+ toolbarPath="org.eclipse.search.searchActionSet/Search"
+ tooltip="Open Seam Component">
+ </action>
+ </actionSet>
+ </extension>
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+ categoryId="org.eclipse.ui.category.navigate"
+ description="Open Seam Component"
+ id="org.jboss.tools.seam.ui.open.component"
+ name="Open Seam Component">
+ </command>
+ </extension>
+ <extension
+ point="org.eclipse.ui.bindings">
+ <key
+ commandId="org.jboss.tools.seam.ui.open.component"
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+ sequence="M1+M2+Y">
+ </key>
+ </extension>
</plugin>
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java 2008-02-12
13:14:09 UTC (rev 6258)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java 2008-02-12
13:21:15 UTC (rev 6259)
@@ -45,6 +45,18 @@
public static String GENERATE_SEAM_ENTITIES_WIZARD_REVERSE_ENGINEER_LABEL;
public static String GENERATE_SEAM_ENTITIES_WIZARD_EXISTING_ENTITIES_LABEL;
+ public static String OPEN_SEAM_COMPONENT_ACTION_ACTION_NAME;
+
+ public static String OPEN_SEAM_COMPONENT_ACTION_DESCRIPTION;
+
+ public static String OPEN_SEAM_COMPONENT_ACTION_MESSAGE;
+
+ public static String OPEN_SEAM_COMPONENT_ACTION_TOOL_TIP;
+
+ public static String OPEN_SEAM_COMPONENT_DIALOG_LOADING;
+
+ public static String OPEN_SEAM_COMPONENT_DIALOG_NAME;
+
public static String SEAM_ACTION_WIZARD_ACTION_CREATING_OPERATION;
public static String SEAM_ACTION_WIZARD_NEW_SEAM_ACTION;
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/actions/OpenSeamComponentAction.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/actions/OpenSeamComponentAction.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/actions/OpenSeamComponentAction.java 2008-02-12
13:21:15 UTC (rev 6259)
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.seam.ui.actions;
+
+
+import java.util.Set;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IActionDelegate2;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.SelectionDialog;
+import org.jboss.tools.seam.core.ISeamComponent;
+import org.jboss.tools.seam.core.ISeamComponentDeclaration;
+import org.jboss.tools.seam.internal.core.SeamComponentDeclaration;
+import org.jboss.tools.seam.internal.core.SeamJavaComponentDeclaration;
+import org.jboss.tools.seam.ui.SeamUIMessages;
+import org.jboss.tools.seam.ui.wizard.OpenSeamComponentDialog;
+
+/**
+ * @author Daniel Azarov
+ *
+ */
+public class OpenSeamComponentAction extends Action implements
IWorkbenchWindowActionDelegate, IActionDelegate2 {
+
+ public OpenSeamComponentAction() {
+ super();
+ setText(SeamUIMessages.OPEN_SEAM_COMPONENT_ACTION_ACTION_NAME);
+ setDescription(SeamUIMessages.OPEN_SEAM_COMPONENT_ACTION_DESCRIPTION);
+ setToolTipText(SeamUIMessages.OPEN_SEAM_COMPONENT_ACTION_TOOL_TIP);
+ }
+
+ public void run() {
+ runWithEvent(null);
+ }
+
+ public void runWithEvent(Event e) {
+ Shell parent= PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
+ SelectionDialog dialog;
+
+ dialog= new OpenSeamComponentDialog(parent);
+
+ dialog.setTitle(SeamUIMessages.OPEN_SEAM_COMPONENT_ACTION_ACTION_NAME);
+ dialog.setMessage(SeamUIMessages.OPEN_SEAM_COMPONENT_ACTION_MESSAGE);
+
+ int result= dialog.open();
+ if (result != IDialogConstants.OK_ID)
+ return;
+
+ Object[] components= dialog.getResult();
+ if (components != null && components.length > 0) {
+ ISeamComponent component= null;
+ for (int i= 0; i < components.length; i++) {
+ component= (ISeamComponent) components[i];
+ SeamJavaComponentDeclaration javaDeclaration =
(SeamJavaComponentDeclaration)component.getJavaDeclaration();
+ if(javaDeclaration != null){
+ javaDeclaration.open();
+ }else{
+ Set<ISeamComponentDeclaration> declarations = component.getAllDeclarations();
+ if(declarations.iterator().hasNext()){
+ ((SeamComponentDeclaration)declarations.iterator().next()).open();
+ }
+ }
+ }
+ }
+ }
+
+
+ // ---- IWorkbenchWindowActionDelegate
+ // ------------------------------------------------
+
+ public void run(IAction action) {
+ run();
+ }
+
+ public void dispose() {
+ // do nothing.
+ }
+
+ public void init(IWorkbenchWindow window) {
+ // do nothing.
+ }
+
+ public void selectionChanged(IAction action, ISelection selection) {
+ // do nothing. Action doesn't depend on selection.
+ }
+
+ // ---- IActionDelegate2
+ // ------------------------------------------------
+
+ public void runWithEvent(IAction action, Event event) {
+ runWithEvent(event);
+ }
+
+ public void init(IAction action) {
+ // do nothing.
+ }
+}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties 2008-02-12
13:14:09 UTC (rev 6258)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties 2008-02-12
13:21:15 UTC (rev 6259)
@@ -195,4 +195,10 @@
SEAM_TARGET_SERVER=Target Server
RUNTIME_DELETE_CONFIRM_TITLE=Confirm Runtime Delete
RUNTIME_DELETE_NOT_USED_CONFIRM=Are you sure you want to delete runtime
''{0}''?
-RUNTIME_DELETE_USED_CONFIRM=Runtime ''{0}'' is used by seam projects. Are
you sure you want to delete it?
\ No newline at end of file
+RUNTIME_DELETE_USED_CONFIRM=Runtime ''{0}'' is used by seam projects. Are
you sure you want to delete it?
+OPEN_SEAM_COMPONENT_ACTION_ACTION_NAME=Open Seam Component
+OPEN_SEAM_COMPONENT_ACTION_DESCRIPTION=Open Seam Component
+OPEN_SEAM_COMPONENT_ACTION_TOOL_TIP=Open Seam Component
+OPEN_SEAM_COMPONENT_ACTION_MESSAGE=&Choose a name of the seam component (? = any
character, * = any string):
+OPEN_SEAM_COMPONENT_DIALOG_LOADING=Seam components loading
+OPEN_SEAM_COMPONENT_DIALOG_NAME=OpenSeamComponentDialog
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/OpenSeamComponentDialog.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/OpenSeamComponentDialog.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/OpenSeamComponentDialog.java 2008-02-12
13:21:15 UTC (rev 6259)
@@ -0,0 +1,210 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.seam.ui.wizard;
+
+import java.util.Comparator;
+import java.util.Iterator;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.DialogSettings;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.dialogs.FilteredItemsSelectionDialog;
+import org.jboss.tools.seam.core.ISeamComponent;
+import org.jboss.tools.seam.core.ISeamProject;
+import org.jboss.tools.seam.core.SeamCorePlugin;
+import org.jboss.tools.seam.internal.core.SeamComponent;
+import org.jboss.tools.seam.ui.SeamUIMessages;
+import org.jboss.tools.seam.ui.SeamUiImages;
+import org.jboss.tools.seam.ui.views.SeamReferencedFilter;
+
+/**
+ * @author Daniel Azarov
+ *
+ */
+public class OpenSeamComponentDialog extends FilteredItemsSelectionDialog {
+
+ public OpenSeamComponentDialog(Shell shell) {
+ super(shell);
+ setListLabelProvider(new SeamComponentLabelProvider());
+ setDetailsLabelProvider(new SeamComponentLabelProvider());
+ setSelectionHistory(new SeamComponentSelectionHistory());
+ }
+
+ protected void computeResult() {
+ super.computeResult();
+ }
+
+ protected Control createExtendedContentArea(Composite parent) {
+ return null;
+ }
+
+ protected ItemsFilter createFilter() {
+ return new SeamComponentFilter();
+ }
+
+ protected void fillContentProvider(AbstractContentProvider contentProvider,
+ ItemsFilter itemsFilter, IProgressMonitor progressMonitor)
+ throws CoreException {
+
+ IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+
+ progressMonitor.beginTask(SeamUIMessages.OPEN_SEAM_COMPONENT_DIALOG_LOADING,
projects.length);
+
+ for(int i = 0; i < projects.length; i++){
+ IProject project = projects[i];
+ progressMonitor.subTask(project.getName());
+ progressMonitor.worked(1);
+ ISeamProject seamProject = SeamCorePlugin.getSeamProject(project, true);
+ if(seamProject != null){
+ Iterator<ISeamComponent> iter = seamProject.getComponents().iterator();
+ while(iter.hasNext()){
+ ISeamComponent component = iter.next();
+
+ if(SeamReferencedFilter.isComponentDeclaredInThisProject(component))
+ contentProvider.add(component, itemsFilter);
+ }
+ }
+ }
+ progressMonitor.done();
+ }
+
+ protected IDialogSettings getDialogSettings() {
+ return new DialogSettings(SeamUIMessages.OPEN_SEAM_COMPONENT_DIALOG_NAME);
+ }
+
+ public String getElementName(Object item) {
+ if(item instanceof ISeamComponent){
+ ISeamComponent component = (ISeamComponent)item;
+ return component.getName();
+ }
+ return null;
+ }
+
+ protected Comparator<SeamComponent> getItemsComparator() {
+ return new SeamComponentComparator();
+ }
+
+ protected IStatus validateItem(Object item) {
+ return new SeamComponentStatus();
+ }
+
+ public class SeamComponentComparator implements Comparator<SeamComponent>{
+ public int compare(SeamComponent left, SeamComponent right) {
+ return left.getName().compareTo(right.getName());
+ }
+
+ }
+
+ public class SeamComponentFilter extends ItemsFilter{
+ public boolean isConsistentItem(Object item) {
+ return true;
+ }
+
+ public boolean matchItem(Object item) {
+ if(item instanceof ISeamComponent){
+ ISeamComponent component = (ISeamComponent)item;
+ return patternMatcher.matches(component.getName());
+ }
+ return false;
+ }
+ }
+
+ public class SeamComponentStatus implements IStatus{
+ public IStatus[] getChildren() {
+ return null;
+ }
+
+ public int getCode() {
+ return 0;
+ }
+
+ public Throwable getException() {
+ return null;
+ }
+
+ public String getMessage() {
+ return ""; //$NON-NLS-1$
+ }
+
+ public String getPlugin() {
+ return ""; //$NON-NLS-1$
+ }
+
+ public int getSeverity() {
+ return 0;
+ }
+
+ public boolean isMultiStatus() {
+ return false;
+ }
+
+ public boolean isOK() {
+ return true;
+ }
+
+ public boolean matches(int severityMask) {
+ return false;
+ }
+
+ }
+
+ public class SeamComponentSelectionHistory extends SelectionHistory{
+ protected Object restoreItemFromMemento(IMemento memento) {
+ return null;
+ }
+
+ @Override
+ protected void storeItemToMemento(Object item, IMemento memento) {
+ }
+
+ }
+
+ public class SeamComponentLabelProvider implements ILabelProvider{
+
+ public Image getImage(Object element) {
+ return SeamUiImages.COMPONENT_IMAGE;
+ }
+
+ public String getText(Object element) {
+ if(element instanceof ISeamComponent){
+ ISeamComponent component = (ISeamComponent)element;
+ return component.getName()+" -
"+component.getSeamProject().getProject().getName(); //$NON-NLS-1$
+ }
+ return null;
+ }
+
+ public void addListener(ILabelProviderListener listener) {
+ }
+
+ public void dispose() {
+ }
+
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+
+ public void removeListener(ILabelProviderListener listener) {
+ }
+
+ }
+}
Added:
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/OpenSeamComponentDialogTest.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/OpenSeamComponentDialogTest.java
(rev 0)
+++
trunk/seam/tests/org.jboss.tools.seam.ui.test/src/org/jboss/tools/seam/ui/test/wizard/OpenSeamComponentDialogTest.java 2008-02-12
13:21:15 UTC (rev 6259)
@@ -0,0 +1,19 @@
+package org.jboss.tools.seam.ui.test.wizard;
+
+import junit.framework.TestCase;
+
+import org.eclipse.ui.PlatformUI;
+import org.jboss.tools.seam.ui.wizard.OpenSeamComponentDialog;
+
+/**
+ * @author Daniel Azarov
+ *
+ */
+public class OpenSeamComponentDialogTest extends TestCase{
+
+ public void testOpenSeamComponentDialogIsCreated() {
+ OpenSeamComponentDialog dialog = new OpenSeamComponentDialog(
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell());
+ dialog.open();
+ }
+}