Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Fedorenko2011-04-15 18:50:19 -0400
committerIgor Fedorenko2011-04-15 18:50:19 -0400
commitf3738a023734dc6375a03ec10933ea6c08cbdb7b (patch)
treed555cdc0d853b79f555b5cd293048ab53af7a080
parent89d9c968706b8d982fbd9b8379fcf3e00993a0f2 (diff)
downloadm2e-core-f3738a023734dc6375a03ec10933ea6c08cbdb7b.tar.gz
m2e-core-f3738a023734dc6375a03ec10933ea6c08cbdb7b.tar.xz
m2e-core-f3738a023734dc6375a03ec10933ea6c08cbdb7b.zip
342910 hooked the new UpdateDepenciesDialog to right-click actions
Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
-rw-r--r--org.eclipse.m2e.core.ui/plugin.properties3
-rw-r--r--org.eclipse.m2e.core.ui/plugin.xml18
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/UpdateDependenciesAction.java (renamed from org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/RefreshMavenModelsAction.java)53
-rw-r--r--org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/UpdateDepenciesDialog.java42
4 files changed, 49 insertions, 67 deletions
diff --git a/org.eclipse.m2e.core.ui/plugin.properties b/org.eclipse.m2e.core.ui/plugin.properties
index 6fcd4bbf..84f283b9 100644
--- a/org.eclipse.m2e.core.ui/plugin.properties
+++ b/org.eclipse.m2e.core.ui/plugin.properties
@@ -27,8 +27,7 @@ m2.popup.ModuleProjectWizardAction=New Maven Module Project
m2.popup.AddPluginAction=Add Plugin
m2.popup.AddDependencyAction=Add Dependency
m2.popup.UpdateConfigurationAction=Update Project Configuration
-m2.popup.RefreshMavenModelsAction=Update Dependencies
-m2.popup.RefreshMavenModelsAction.snapshots=Update Snapshots
+m2.popup.RefreshMavenModelsAction=Update Dependencies...
m2.popup.OpenUrlAction.openCiPage=Open Continuous Integration
m2.popup.OpenUrlAction.openScmPage=Open Source Control
m2.popup.OpenUrlAction.openIssuesPage=Open Issue Tracker
diff --git a/org.eclipse.m2e.core.ui/plugin.xml b/org.eclipse.m2e.core.ui/plugin.xml
index 373503f5..ba1fa6b9 100644
--- a/org.eclipse.m2e.core.ui/plugin.xml
+++ b/org.eclipse.m2e.core.ui/plugin.xml
@@ -141,18 +141,11 @@
objectClass="org.eclipse.core.resources.IProject"
adaptable="true">
<action id="org.eclipse.m2e.refreshMavenModelsAction"
- class="org.eclipse.m2e.core.ui.internal.actions.RefreshMavenModelsAction"
+ class="org.eclipse.m2e.core.ui.internal.actions.UpdateDependenciesAction"
label="%m2.popup.RefreshMavenModelsAction"
style="push"
menubarPath="org.eclipse.m2e.core.mavenMenu/update"
enablesFor="+"/>
- <action id="org.eclipse.m2e.refreshMavenSnapshotsAction"
- class="org.eclipse.m2e.core.ui.internal.actions.RefreshMavenModelsAction:snapshots"
- label="%m2.popup.RefreshMavenModelsAction.snapshots"
- style="push"
- menubarPath="org.eclipse.m2e.core.mavenMenu/update"
- enablesFor="+">
- </action>
<visibility>
<and>
<objectState name="open" value="true"/>
@@ -446,18 +439,11 @@
adaptable="true"
objectClass="org.eclipse.ui.IWorkingSet">
<action id="org.eclipse.m2e.refreshMavenModelsAction"
- class="org.eclipse.m2e.core.ui.internal.actions.RefreshMavenModelsAction"
+ class="org.eclipse.m2e.core.ui.internal.actions.UpdateDependenciesAction"
label="%m2.popup.RefreshMavenModelsAction"
style="push"
menubarPath="org.eclipse.m2e.core.workingSetMenu/update"
enablesFor="+"/>
- <action id="org.eclipse.m2e.refreshMavenSnapshotsAction"
- class="org.eclipse.m2e.core.ui.internal.actions.RefreshMavenModelsAction:snapshots"
- label="%m2.popup.RefreshMavenModelsAction.snapshots"
- style="push"
- menubarPath="org.eclipse.m2e.core.workingSetMenu/update"
- enablesFor="+">
- </action>
</objectContribution>
<objectContribution id="org.eclipse.m2e.core.openPomArtifact"
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/RefreshMavenModelsAction.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/UpdateDependenciesAction.java
index a7fadbb6..6a89b50c 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/RefreshMavenModelsAction.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/actions/UpdateDependenciesAction.java
@@ -14,6 +14,9 @@ package org.eclipse.m2e.core.ui.internal.actions;
import java.util.ArrayList;
import java.util.Iterator;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
@@ -23,50 +26,43 @@ import org.eclipse.core.runtime.IExecutableExtension;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowActionDelegate;
+import org.eclipse.ui.IWorkingSet;
+
import org.eclipse.m2e.core.MavenPlugin;
import org.eclipse.m2e.core.core.IMavenConstants;
import org.eclipse.m2e.core.project.IMavenProjectRegistry;
import org.eclipse.m2e.core.project.MavenUpdateRequest;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-import org.eclipse.ui.IWorkingSet;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.eclipse.m2e.core.ui.internal.dialogs.UpdateDepenciesDialog;
-public class RefreshMavenModelsAction implements IWorkbenchWindowActionDelegate, IExecutableExtension {
- private static final Logger log = LoggerFactory.getLogger(RefreshMavenModelsAction.class);
+public class UpdateDependenciesAction extends MavenActionSupport implements IWorkbenchWindowActionDelegate,
+ IExecutableExtension {
+ private static final Logger log = LoggerFactory.getLogger(UpdateDependenciesAction.class);
public static final String ID = "org.eclipse.m2e.refreshMavenModelsAction"; //$NON-NLS-1$
- public static final String ID_SNAPSHOTS = "org.eclipse.m2e.refreshMavenSnapshotsAction"; //$NON-NLS-1$
-
- private boolean updateSnapshots = false;
-
- private boolean offline = false; // should respect global settings
-
private IStructuredSelection selection;
- public RefreshMavenModelsAction() {
- }
-
- public RefreshMavenModelsAction(boolean updateSnapshots) {
- this.updateSnapshots = updateSnapshots;
+ public UpdateDependenciesAction() {
}
-
+
// IExecutableExtension
-
+
public void setInitializationData(IConfigurationElement config, String propertyName, Object data) {
- if("snapshots".equals(data)) { //$NON-NLS-1$
- this.updateSnapshots = true;
- }
}
-
+
// IWorkbenchWindowActionDelegate
-
+
public void run(IAction action) {
- IMavenProjectRegistry projectManager = MavenPlugin.getMavenProjectRegistry();
- projectManager.refresh(new MavenUpdateRequest(getProjects(), offline, updateSnapshots));
+ UpdateDepenciesDialog dialog = new UpdateDepenciesDialog(getShell(), getProjects());
+ if(dialog.open() == Window.OK) {
+ IMavenProjectRegistry projectManager = MavenPlugin.getMavenProjectRegistry();
+ projectManager.refresh(new MavenUpdateRequest(dialog.getSelectedProjects(), //
+ dialog.isOffline(), dialog.isForceUpdate()));
+ }
}
public void selectionChanged(IAction action, ISelection selection) {
@@ -110,6 +106,5 @@ public class RefreshMavenModelsAction implements IWorkbenchWindowActionDelegate,
}
return projectList.toArray(new IProject[projectList.size()]);
}
-
-}
+}
diff --git a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/UpdateDepenciesDialog.java b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/UpdateDepenciesDialog.java
index 855f9d44..a55ad2fa 100644
--- a/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/UpdateDepenciesDialog.java
+++ b/org.eclipse.m2e.core.ui/src/org/eclipse/m2e/core/ui/internal/dialogs/UpdateDepenciesDialog.java
@@ -65,28 +65,28 @@ public class UpdateDepenciesDialog extends TitleAreaDialog {
private Collection<IProject> projects;
- private Button checkSnapshots;
+ private Button offline;
- private Button updateRemote;
+ private Button forceUpdate;
private IProject[] selectedProjects;
- private boolean isCheckSnapshots = false;
+ private boolean isOffline;
- private boolean isUpdateRemote = false;
+ private boolean isForceUpdate;
private List<String> projectPaths;
private static final String SEPARATOR = System.getProperty("file.separator"); //$NON-NLS-1$
private final IProject[] initialSelection;
- /**
- * Create the dialog.
- * @param parentShell
- */
+
public UpdateDepenciesDialog(Shell parentShell, IProject[] initialSelection) {
super(parentShell);
this.initialSelection = initialSelection;
+
+ isOffline = MavenPlugin.getMavenConfiguration().isOffline();
+ isForceUpdate = !isOffline;
}
@Override
@@ -222,13 +222,15 @@ public class UpdateDepenciesDialog extends TitleAreaDialog {
}
});
- checkSnapshots = new Button(container, SWT.CHECK);
- checkSnapshots.setText("Forces a check for updated releases and snapshots on remote");
- checkSnapshots.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 2, 1));
+ offline = new Button(container, SWT.CHECK);
+ offline.setText("Offline");
+ offline.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 2, 1));
+ offline.setSelection(isOffline);
- updateRemote = new Button(container, SWT.CHECK);
- updateRemote.setText("Do not automatically update dependencies from remote");
- updateRemote.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 2, 1));
+ forceUpdate = new Button(container, SWT.CHECK);
+ forceUpdate.setText("Forces a check for updated releases and snapshots\non remote repositories");
+ forceUpdate.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 2, 1));
+ forceUpdate.setSelection(isForceUpdate);
setTitle("Update Maven Dependencies");
setMessage("Select Maven codebases to update dependencies");
@@ -256,8 +258,8 @@ public class UpdateDepenciesDialog extends TitleAreaDialog {
}
selectedProjects = projects;
}
- isCheckSnapshots = checkSnapshots.getSelection();
- isUpdateRemote = updateRemote.getSelection();
+ isOffline = offline.getSelection();
+ isForceUpdate = forceUpdate.getSelection();
super.okPressed();
}
@@ -289,12 +291,12 @@ public class UpdateDepenciesDialog extends TitleAreaDialog {
return selectedProjects;
}
- public boolean isCheckSnapshots() {
- return isCheckSnapshots;
+ public boolean isOffline() {
+ return isOffline;
}
- public boolean isUpdateRemote() {
- return isUpdateRemote;
+ public boolean isForceUpdate() {
+ return isForceUpdate;
}
private IProject getProject(String path) {

Back to the top