Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Fedorenko2011-08-04 11:24:23 -0400
committerIgor Fedorenko2011-08-04 11:24:23 -0400
commit093352787bc8b48dfebd094d2967760491550e3e (patch)
treeb850877905e0c25f594a43ef8bdcdfcb395a4b7d /org.eclipse.m2e.refactoring
parentc47e215285d7c562d2e8c98c52a80349abe070b6 (diff)
parent55bb6dd084da70138e6fd4800a514ee94abdb743 (diff)
downloadm2e-core-093352787bc8b48dfebd094d2967760491550e3e.tar.gz
m2e-core-093352787bc8b48dfebd094d2967760491550e3e.tar.xz
m2e-core-093352787bc8b48dfebd094d2967760491550e3e.zip
Merge remote-tracking branch 'origin/master' into m2e-self-hosting
Conflicts: com.ning.async-http-client/pom.xml org.eclipse.m2e.archetype.common/META-INF/MANIFEST.MF org.eclipse.m2e.archetype.common/pom.xml org.eclipse.m2e.core.ui/pom.xml org.eclipse.m2e.core/pom.xml org.eclipse.m2e.discovery/pom.xml org.eclipse.m2e.editor.xml/pom.xml org.eclipse.m2e.editor/pom.xml org.eclipse.m2e.feature/pom.xml org.eclipse.m2e.integration.tests.common/pom.xml org.eclipse.m2e.jdt/pom.xml org.eclipse.m2e.launching/pom.xml org.eclipse.m2e.lifecyclemapping.defaults/pom.xml org.eclipse.m2e.logback.appender/pom.xml org.eclipse.m2e.logback.configuration/pom.xml org.eclipse.m2e.logback.feature/pom.xml org.eclipse.m2e.maven.indexer/META-INF/MANIFEST.MF org.eclipse.m2e.maven.indexer/pom.xml org.eclipse.m2e.maven.runtime/META-INF/MANIFEST.MF org.eclipse.m2e.maven.runtime/pom.xml org.eclipse.m2e.model.edit/pom.xml org.eclipse.m2e.refactoring/pom.xml org.eclipse.m2e.scm/pom.xml org.eclipse.m2e.sdk.feature/pom.xml org.eclipse.m2e.site/pom.xml org.eclipse.m2e.tests.common/pom.xml org.eclipse.m2e.usagedata/pom.xml org.jboss.netty/pom.xml pom.xml target-platform/pom.xml
Diffstat (limited to 'org.eclipse.m2e.refactoring')
-rw-r--r--org.eclipse.m2e.refactoring/META-INF/MANIFEST.MF2
-rw-r--r--org.eclipse.m2e.refactoring/OSGI-INF/l10n/bundle.properties3
-rw-r--r--org.eclipse.m2e.refactoring/plugin.xml62
-rw-r--r--org.eclipse.m2e.refactoring/pom.xml2
-rw-r--r--org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/rename/RenameArtifactHandler.java (renamed from org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/rename/RenameArtifactAction.java)66
5 files changed, 73 insertions, 62 deletions
diff --git a/org.eclipse.m2e.refactoring/META-INF/MANIFEST.MF b/org.eclipse.m2e.refactoring/META-INF/MANIFEST.MF
index 9937625a..a155c47c 100644
--- a/org.eclipse.m2e.refactoring/META-INF/MANIFEST.MF
+++ b/org.eclipse.m2e.refactoring/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: %Bundle-Name
Bundle-Vendor: %Bundle-Vendor
Bundle-SymbolicName: org.eclipse.m2e.refactoring;singleton:=true
-Bundle-Version: 1.0.100.qualifier
+Bundle-Version: 1.0.200.qualifier
Bundle-Activator: org.eclipse.m2e.refactoring.internal.Activator
Require-Bundle: org.eclipse.m2e.core;bundle-version="[1.0.0,1.1.0)",
org.eclipse.m2e.model.edit;bundle-version="[1.0.0,1.1.0)",
diff --git a/org.eclipse.m2e.refactoring/OSGI-INF/l10n/bundle.properties b/org.eclipse.m2e.refactoring/OSGI-INF/l10n/bundle.properties
index 6f565cae..8edf851f 100644
--- a/org.eclipse.m2e.refactoring/OSGI-INF/l10n/bundle.properties
+++ b/org.eclipse.m2e.refactoring/OSGI-INF/l10n/bundle.properties
@@ -1,8 +1,7 @@
#Properties file for org.eclipse.m2e.refactoring
Bundle-Vendor = Eclipse.org - m2e
Bundle-Name = Maven Integration for Eclipse Refactoring
-action.rename1.label = Rename Maven Artifact...
-action.rename2.label = Rename Maven Artifact...
+action.rename.label = Rename Maven Artifact...
action.exclude1.label = Exclude Maven Artifact...
action.exclude2.label = Exclude Maven Artifact...
action.exclude3.label = Exclude Maven Artifact... \ No newline at end of file
diff --git a/org.eclipse.m2e.refactoring/plugin.xml b/org.eclipse.m2e.refactoring/plugin.xml
index 64f1fa54..61f75bec 100644
--- a/org.eclipse.m2e.refactoring/plugin.xml
+++ b/org.eclipse.m2e.refactoring/plugin.xml
@@ -9,33 +9,43 @@
<?eclipse version="3.2"?>
<plugin>
+ <extension point="org.eclipse.ui.menus">
+ <menuContribution
+ locationURI="popup:org.eclipse.jdt.ui.refactoring.menu?after=additions">
+ <command
+ commandId="org.eclipse.m2e.editor.RenameArtifactAction"
+ icon="$nl$/icons/m2.gif"
+ label="%action.rename.label"
+ id="org.eclipse.m2e.editor.RenameArtifactAction">
+ <visibleWhen
+ checkEnabled="false">
+ <with variable="selection">
+ <count value="1"/>
+ <iterate>
+ <or>
+ <adapt type="org.eclipse.core.resources.IProject">
+ <test property="org.eclipse.core.resources.projectNature" value="org.eclipse.m2e.core.maven2Nature"/>
+ </adapt>
+ <adapt type="org.eclipse.core.resources.IResource">
+ <test property="org.eclipse.core.resources.name" value="pom.xml"/>
+ </adapt>
+ </or>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.commands">
+ <command
+ id="org.eclipse.m2e.editor.RenameArtifactAction"
+ name="%action.rename.label"
+ defaultHandler="org.eclipse.m2e.refactoring.rename.RenameArtifactHandler"/>
+ </extension>
+
<extension point="org.eclipse.ui.popupMenus">
- <objectContribution
- id="org.eclipse.m2e.refactoring.rename.pomContributor"
- objectClass="org.eclipse.core.resources.IFile"
- nameFilter="pom.xml" adaptable="true">
- <action id="org.eclipse.m2e.editor.RenamePomAction"
- class="org.eclipse.m2e.refactoring.rename.RenameArtifactAction"
- enablesFor="1"
- label="%action.rename1.label"
- menubarPath="group.edit"/>
- <!-- add visibility condition for managed poms -->
- </objectContribution>
- <objectContribution id="org.eclipse.m2e.refactoring.rename.projectContributor"
- objectClass="org.eclipse.core.resources.IProject"
- adaptable="true">
- <action id="org.eclipse.m2e.editor.RenameProjectAction"
- class="org.eclipse.m2e.refactoring.rename.RenameArtifactAction"
- enablesFor="1"
- label="%action.rename2.label"
- menubarPath="org.eclipse.jdt.ui.refactoring.menu/MavenRefactoring"/>
- <visibility>
- <and>
- <objectState name="open" value="true"/>
- <objectState name="nature" value="org.eclipse.m2e.core.maven2Nature"/>
- </and>
- </visibility>
- </objectContribution>
<!-- actions in pom editor -->
<objectContribution
diff --git a/org.eclipse.m2e.refactoring/pom.xml b/org.eclipse.m2e.refactoring/pom.xml
index ea914088..3a70a347 100644
--- a/org.eclipse.m2e.refactoring/pom.xml
+++ b/org.eclipse.m2e.refactoring/pom.xml
@@ -13,7 +13,7 @@
<parent>
<groupId>org.eclipse.m2e</groupId>
<artifactId>m2e-core</artifactId>
- <version>1.0.100-SNAPSHOT</version>
+ <version>1.0.200-SNAPSHOT</version>
</parent>
<artifactId>org.eclipse.m2e.refactoring</artifactId>
diff --git a/org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/rename/RenameArtifactAction.java b/org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/rename/RenameArtifactHandler.java
index 3ded0280..c0afda28 100644
--- a/org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/rename/RenameArtifactAction.java
+++ b/org.eclipse.m2e.refactoring/src/org/eclipse/m2e/refactoring/rename/RenameArtifactHandler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008-2010 Sonatype, Inc.
+ * Copyright (c) 2011 Sonatype, Inc.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,48 +8,35 @@
* Contributors:
* Sonatype, Inc. - initial API and implementation
*******************************************************************************/
-
package org.eclipse.m2e.refactoring.rename;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
-import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation;
import org.eclipse.m2e.refactoring.internal.SaveDirtyFilesDialog;
-import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.ActionDelegate;
-import org.eclipse.ui.internal.ObjectPluginAction;
+import org.eclipse.ui.handlers.HandlerUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+public class RenameArtifactHandler extends AbstractHandler {
+ private static final Logger log = LoggerFactory.getLogger(RenameArtifactHandler.class);
-/**
- * @author Anton Kraev
- */
-@SuppressWarnings("restriction")
-public class RenameArtifactAction extends ActionDelegate {
- private static final Logger log = LoggerFactory.getLogger(RenameArtifactAction.class);
-
- @Override
- public void init(IAction action) {
- super.init(action);
- }
-
- @Override
- public void run(IAction action) {
- doRun(action);
- }
-
- @Override
- public void runWithEvent(IAction action, Event event) {
- doRun(action);
- }
-
- public void doRun(IAction action) {
- Object element = ((IStructuredSelection) ((ObjectPluginAction) action).getSelection()).getFirstElement();
+ /* (non-Javadoc)
+ * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ ISelection selection = computeSelection(event);
+ if (! (selection instanceof IStructuredSelection)) {
+ return null;
+ }
+ Object element = ((IStructuredSelection) selection).getFirstElement();
if(element instanceof IFile) {
rename((IFile) element);
} else if (element instanceof IProject) {
@@ -59,8 +46,9 @@ public class RenameArtifactAction extends ActionDelegate {
rename(file);
}
}
+ return null;
}
-
+
private void rename(IFile file) {
try {
// get the model from existing file
@@ -76,5 +64,19 @@ public class RenameArtifactAction extends ActionDelegate {
log.error("Unable to rename " + file, e);
}
}
-}
+
+ protected ISelection computeSelection(ExecutionEvent event) {
+ ISelection selection = HandlerUtil.getActiveMenuSelection(event);
+ if (!(selection instanceof IStructuredSelection)) {
+ selection = HandlerUtil.getActiveMenuEditorInput(event);
+ }
+ if (!(selection instanceof IStructuredSelection)) {
+ selection = HandlerUtil.getCurrentSelection(event);
+ }
+ if (!(selection instanceof IStructuredSelection)) {
+ selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getSelection();
+ }
+ return selection;
+ }
+}

Back to the top