Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2004-04-29 11:27:09 -0400
committerMichael Valenta2004-04-29 11:27:09 -0400
commitd6fd0a4035d7473ddc086abea8f51be7dd6a97f8 (patch)
treeedf554d200be86139de698b778f759c75fc20106
parent56e057770d5f13f3f9e46633bdd7be33eb39f319 (diff)
downloadeclipse.platform.team-d6fd0a4035d7473ddc086abea8f51be7dd6a97f8.tar.gz
eclipse.platform.team-d6fd0a4035d7473ddc086abea8f51be7dd6a97f8.tar.xz
eclipse.platform.team-d6fd0a4035d7473ddc086abea8f51be7dd6a97f8.zip
Fixed delete behavior of repositories view
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoveDateTagAction.java4
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoveRootAction.java5
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoriesView.java46
3 files changed, 33 insertions, 22 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoveDateTagAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoveDateTagAction.java
index 0982635d9..b0e46ee6d 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoveDateTagAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoveDateTagAction.java
@@ -33,7 +33,9 @@ public class RemoveDateTagAction extends SelectionListenerAction {
protected boolean updateSelection(IStructuredSelection selection) {
this.selection = selection;
- return containsDataTag();
+ boolean b = containsDataTag();
+ setEnabled(b);
+ return b;
}
private boolean containsDataTag(){
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoveRootAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoveRootAction.java
index 0742d9d03..83e6a137d 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoveRootAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RemoveRootAction.java
@@ -143,9 +143,10 @@ public class RemoveRootAction extends SelectionListenerAction {
protected boolean updateSelection(IStructuredSelection selection) {
this.selection = selection;
-
ICVSRepositoryLocation[] roots = getSelectedRemoteRoots();
- return roots.length > 0;
+ boolean b = roots.length > 0;
+ setEnabled(b);
+ return b;
}
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoriesView.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoriesView.java
index a64aa51a8..be55b5fdf 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoriesView.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/repo/RepositoriesView.java
@@ -15,6 +15,7 @@ import java.util.Properties;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
@@ -27,7 +28,6 @@ import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
@@ -66,6 +66,7 @@ public class RepositoriesView extends RemoteViewPart {
private AllRootsElement root;
// Actions
+ private IAction removeAction;
private Action newAction;
private Action newAnonAction;
private PropertyDialogAction propertiesAction;
@@ -102,7 +103,7 @@ public class RepositoriesView extends RemoteViewPart {
* @param partName
*/
public RepositoriesView() {
- super(VIEW_ID);
+ super(VIEW_ID);
}
/**
@@ -160,12 +161,23 @@ public class RepositoriesView extends RemoteViewPart {
removeRootAction.selectionChanged((IStructuredSelection)null);
removeDateTagAction = new RemoveDateTagAction();
removeDateTagAction.selectionChanged( (IStructuredSelection)null);
+ removeAction = new Action(){
+ public void run(){
+ if(removeRootAction.isEnabled()){
+ removeRootAction.run();
+ }
+ if(removeDateTagAction.isEnabled()){
+ removeDateTagAction.run();
+ }
+ }
+ };
WorkbenchHelp.setHelp(removeRootAction, IHelpContextIds.REMOVE_REPOSITORY_LOCATION_ACTION);
IActionBars bars = getViewSite().getActionBars();
- bars.setGlobalActionHandler(ActionFactory.DELETE.getId(), removeRootAction);
+ bars.setGlobalActionHandler(ActionFactory.DELETE.getId(), removeAction);
+
super.contributeActions();
}
-
+
/**
* Method includeEclipseConnection.
* @return boolean
@@ -229,23 +241,13 @@ public class RepositoriesView extends RemoteViewPart {
super.initializeListeners();
viewer.addSelectionChangedListener(removeRootAction);
viewer.addSelectionChangedListener(removeDateTagAction);
- viewer.getControl().addKeyListener(new KeyListener() {
- public void keyPressed(KeyEvent event) {
- handleKeyPressed(event);
- }
- public void keyReleased(KeyEvent event) {
- handleKeyReleased(event);
- }
+ viewer.addSelectionChangedListener(new ISelectionChangedListener(){
+ public void selectionChanged(SelectionChangedEvent event) {
+ IStructuredSelection selection = (IStructuredSelection)event.getSelection();
+ handleChange(selection);
+ }
});
}
- public void handleKeyPressed(KeyEvent event) {
- if (event.character == SWT.DEL && event.stateMask == 0) {
- removeRootAction.run();
- removeDateTagAction.run();
- }
- }
- protected void handleKeyReleased(KeyEvent event) {
- }
/**
* @see org.eclipse.team.internal.ccvs.ui.repo.RemoteViewPart#getTreeInput()
@@ -316,4 +318,10 @@ public class RepositoriesView extends RemoteViewPart {
}
};
}
+
+ private void handleChange(IStructuredSelection selection){
+ removeRootAction.updateSelection(selection);
+ removeDateTagAction.updateSelection(selection);
+ removeAction.setEnabled(removeRootAction.isEnabled() || removeDateTagAction.isEnabled());
+ }
}

Back to the top