Author: scabanovich
Date: 2009-04-23 09:13:04 -0400 (Thu, 23 Apr 2009)
New Revision: 14871
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/actions/RenameComponentAction.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
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/refactoring/SeamComponentRenameHandler.java
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/actions/SeamActionProvider.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-1077
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml 2009-04-23 13:12:04 UTC (rev
14870)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui/plugin.xml 2009-04-23 13:13:04 UTC (rev
14871)
@@ -661,5 +661,9 @@
</handler>
</extension>
+ <extension point="org.jboss.tools.common.model.classes">
+ <xclass
id="org.jboss.tools.seam.ui.views.actions.RenameComponentAction"
+
class="org.jboss.tools.seam.ui.views.actions.RenameComponentAction"/>
+ </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 2009-04-23
13:12:04 UTC (rev 14870)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/SeamUIMessages.java 2009-04-23
13:13:04 UTC (rev 14871)
@@ -381,6 +381,8 @@
public static String SeamRuntimeListFieldEditor_ActionEdit;
public static String SeamRuntimeListFieldEditor_ActionRemove;
+
+ public static String RENAME_SEAM_COMPONENT;
static {
// load message values from bundle file
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 2009-04-23
13:12:04 UTC (rev 14870)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/messages.properties 2009-04-23
13:13:04 UTC (rev 14871)
@@ -199,4 +199,5 @@
POJO_CLASS_ALREADY_EXISTS=Such POJO class already exists!
ENTITY_CLASS_ALREADY_EXISTS=Such entity class already exists!
PAGE_ALREADY_EXISTS=Such page already exists!
-MASTER_PAGE_ALREADY_EXISTS=Such master page already exists!
\ No newline at end of file
+MASTER_PAGE_ALREADY_EXISTS=Such master page already exists!
+RENAME_SEAM_COMPONENT = Rename Seam Component
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/refactoring/SeamComponentRenameHandler.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/refactoring/SeamComponentRenameHandler.java 2009-04-23
13:12:04 UTC (rev 14870)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/refactoring/SeamComponentRenameHandler.java 2009-04-23
13:13:04 UTC (rev 14871)
@@ -60,18 +60,23 @@
component = components.iterator().next();
}
}
- RenameComponentProcessor processor = new RenameComponentProcessor(component);
- RenameComponentRefactoring refactoring = new RenameComponentRefactoring(processor);
- RenameComponentWizard wizard = new RenameComponentWizard(refactoring, component);
- RefactoringWizardOpenOperation op = new RefactoringWizardOpenOperation(wizard);
- try {
- String titleForFailedChecks = "TestTestTest"; //$NON-NLS-1$
- op.run(activeShell, titleForFailedChecks);
- } catch (final InterruptedException irex) {
- // operation was canceled
- }
+
+ invokeRenameWizard(component, activeShell);
}
return null;
}
-}
\ No newline at end of file
+
+ public static void invokeRenameWizard(ISeamComponent component, Shell activeShell) {
+ RenameComponentProcessor processor = new RenameComponentProcessor(component);
+ RenameComponentRefactoring refactoring = new RenameComponentRefactoring(processor);
+ RenameComponentWizard wizard = new RenameComponentWizard(refactoring, component);
+ RefactoringWizardOpenOperation op = new RefactoringWizardOpenOperation(wizard);
+ try {
+ String titleForFailedChecks = "TestTestTest"; //$NON-NLS-1$
+ op.run(activeShell, titleForFailedChecks);
+ } catch (final InterruptedException irex) {
+ // operation was canceled
+ }
+ }
+}
Added:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/actions/RenameComponentAction.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/actions/RenameComponentAction.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/actions/RenameComponentAction.java 2009-04-23
13:13:04 UTC (rev 14871)
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * 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.views.actions;
+
+import java.util.Set;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jface.action.Action;
+import org.eclipse.swt.widgets.Shell;
+import org.jboss.tools.common.meta.action.SpecialWizard;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.seam.core.ISeamComponent;
+import org.jboss.tools.seam.core.ISeamProject;
+import org.jboss.tools.seam.core.ISeamXmlComponentDeclaration;
+import org.jboss.tools.seam.core.SeamCorePlugin;
+import org.jboss.tools.seam.internal.core.SeamObject;
+import org.jboss.tools.seam.ui.SeamGuiPlugin;
+import org.jboss.tools.seam.ui.SeamUIMessages;
+import org.jboss.tools.seam.ui.refactoring.SeamComponentRenameHandler;
+
+/**
+ * Rename component action for Seam Components view.
+ * @author Viacheslav Kabanovich
+ */
+public class RenameComponentAction extends Action implements SpecialWizard {
+ ISeamComponent component;
+
+ public RenameComponentAction() {
+ }
+
+ public RenameComponentAction(ISeamComponent component) {
+ setText(SeamUIMessages.RENAME_SEAM_COMPONENT);
+ this.component = component;
+ }
+
+ @Override
+ public void run() {
+ if(component != null) {
+ Shell activeShell =
SeamGuiPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell();
+ SeamComponentRenameHandler.invokeRenameWizard(component, activeShell);
+ }
+ }
+
+ public int execute() {
+ run();
+ return 0;
+ }
+
+ public void setObject(Object object) {
+ if(object instanceof XModelObject) {
+ XModelObject o = (XModelObject)object;
+ IProject project = EclipseResourceUtil.getProject(o);
+ if(project == null) return;
+ ISeamProject seamProject = SeamCorePlugin.getSeamProject(project, true);
+ if(seamProject == null) return;
+ ISeamComponent[] cs = seamProject.getComponents();
+ for (ISeamComponent c: cs) {
+ Set<ISeamXmlComponentDeclaration> ds = c.getXmlDeclarations();
+ if(ds == null || ds.size() == 0) continue;
+ ISeamXmlComponentDeclaration d = ds.iterator().next();
+ Object id = ((SeamObject)d).getId();
+ if(id == o) {
+ component = c;
+ break;
+ }
+ }
+ if(component == null) {
+ String name = o.getAttributeValue("name");
+ if(name != null && name.length() > 0) {
+ component = seamProject.getComponent(name);
+ }
+ }
+ }
+
+ }
+
+}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/actions/SeamActionProvider.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/actions/SeamActionProvider.java 2009-04-23
13:12:04 UTC (rev 14870)
+++
trunk/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/views/actions/SeamActionProvider.java 2009-04-23
13:13:04 UTC (rev 14871)
@@ -21,6 +21,7 @@
import org.eclipse.ui.navigator.CommonActionProvider;
import org.eclipse.ui.navigator.ICommonActionConstants;
import org.jboss.tools.seam.core.IOpenableElement;
+import org.jboss.tools.seam.core.ISeamComponent;
import org.jboss.tools.seam.core.ISeamElement;
/**
@@ -46,6 +47,11 @@
}
}
+ if(e instanceof ISeamComponent) {
+ ISeamComponent component = (ISeamComponent)e;
+ RenameComponentAction action = new RenameComponentAction(component);
+ menu.add(action);
+ }
}
@Override