Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2012-05-02 11:20:56 +0000
committerUwe Stieber2012-05-02 11:37:35 +0000
commit82dba9bf83929c40e1a11b3453fdb630c248a630 (patch)
tree1bf4a875214f5575c759028c5c4b14291d6cc221
parent86e0ea52f2f9bf83b690371b8b68f64594b38208 (diff)
downloadorg.eclipse.tcf-82dba9bf83929c40e1a11b3453fdb630c248a630.tar.gz
org.eclipse.tcf-82dba9bf83929c40e1a11b3453fdb630c248a630.tar.xz
org.eclipse.tcf-82dba9bf83929c40e1a11b3453fdb630c248a630.zip
Target Explorer: Rework delete handler contributions
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/plugin.properties3
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/plugin.xml57
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/LaunchNodePropertyTester.java5
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/adapters/AdapterFactory.java7
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/adapters/DeleteHandlerDelegate.java75
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/handler/DeleteHandler.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/DeleteHandler.java)62
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/plugin.properties3
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/plugin.xml70
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSTreeNodeAdapterFactory.java7
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/handlers/DeleteHandler.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/DeleteHandlerDelegate.java)118
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/testers/TreeNodePropertyTester.java34
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.properties3
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml55
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/DeleteHandler.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/DeleteHandlerDelegate.java)92
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/AdapterFactory.java7
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/adapters/DeleteHandlerDelegateTest.java10
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/adapters/FSTreeNodeAdapterFactoryTest.java11
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/plugin.properties3
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/plugin.xml58
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/expressions/PropertyTester.java31
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/interfaces/handler/IDeleteHandlerDelegate.java49
21 files changed, 444 insertions, 316 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/plugin.properties b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/plugin.properties
index ab398181e..346688111 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/plugin.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/plugin.properties
@@ -47,5 +47,8 @@ Refresh.menu.mnemonic=f
ShowIn.menu.name=Show In
Properties.menu.name=Properties
+command.delete.label=Delete
+command.delete.description=Delete the selected node
+
LauchTree.name=Launches
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/plugin.xml
index 084737668..adc78ef08 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/plugin.xml
@@ -8,7 +8,6 @@
adaptableType="org.eclipse.tcf.te.launch.ui.model.LaunchNode"
class="org.eclipse.tcf.te.launch.ui.internal.adapters.AdapterFactory">
<adapter type="org.eclipse.jface.viewers.ILabelProvider"/>
- <adapter type="org.eclipse.tcf.te.ui.views.interfaces.handler.IDeleteHandlerDelegate"/>
<adapter type="org.eclipse.tcf.te.ui.views.interfaces.handler.IRefreshHandlerDelegate"/>
</factory>
</extension>
@@ -19,7 +18,7 @@
class="org.eclipse.tcf.te.launch.ui.internal.LaunchNodePropertyTester"
id="org.eclipse.tcf.te.launch.ui.propertytester.launchNode"
namespace="org.eclipse.tcf.te.launch.ui.model"
- properties="isLaunchConfig, isLaunchConfigType"
+ properties="isLaunchConfig,isLaunchConfigType,canDelete"
type="org.eclipse.tcf.te.launch.ui.model.LaunchNode">
</propertyTester>
</extension>
@@ -223,7 +222,7 @@
<iterate
ifEmpty="false"
operator="and">
- <test property="org.eclipse.tcf.te.ui.views.isDeletableElement"/>
+ <test property="org.eclipse.tcf.te.launch.ui.model.isLaunchConfig"/>
</iterate>
</with>
</visibleWhen>
@@ -329,6 +328,27 @@
</visibleWhen>
</menu>
</menuContribution>
+ <menuContribution locationURI="popup:org.eclipse.tcf.te.ui.views.View#Popup?after=group.delete">
+ <command
+ commandId="org.eclipse.ui.edit.delete"
+ disabledIcon="platform:/plugin/org.eclipse.ui/icons/full/dtool16/delete.gif"
+ helpContextId="org.eclipse.tcf.te.ui.command_Delete"
+ icon="platform:/plugin/org.eclipse.ui/icons/full/etool16/delete.gif"
+ id="org.eclipse.tcf.te.ui.commands.delete"
+ label="%command.delete.label"
+ mnemonic="D"
+ style="push"
+ tooltip="%command.delete.description">
+ <visibleWhen checkEnabled="false">
+ <with variable="selection">
+ <count value="+"/>
+ <iterate operator="and" ifEmpty="false">
+ <test property="org.eclipse.tcf.te.launch.ui.model.isLaunchConfig"/>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+ </menuContribution>
<!-- Launches editor page menu contributions -->
<menuContribution locationURI="popup:org.eclipse.tcf.te.launch.ui.editor.menu.launches">
@@ -457,7 +477,7 @@
<iterate
ifEmpty="false"
operator="and">
- <test property="org.eclipse.tcf.te.ui.views.isDeletableElement"/>
+ <test property="org.eclipse.tcf.te.launch.ui.model.isLaunchConfig"/>
</iterate>
</with>
</visibleWhen>
@@ -526,7 +546,34 @@
<!-- Handler contributions -->
<extension point="org.eclipse.ui.handlers">
<handler
- class="org.eclipse.tcf.te.ui.views.handler.DeleteHandler"
+ commandId="org.eclipse.ui.edit.delete"
+ class="org.eclipse.tcf.te.launch.ui.internal.handler.DeleteHandler">
+ <activeWhen>
+ <and>
+ <with variable="activePartId">
+ <or>
+ <equals value="org.eclipse.tcf.te.ui.views.View"/>
+ <equals value="org.eclipse.tcf.te.ui.views.Editor"/>
+ </or>
+ </with>
+ <with variable="selection">
+ <iterate operator="and" ifEmpty="false">
+ <test property="org.eclipse.tcf.te.launch.ui.model.isLaunchConfig"/>
+ </iterate>
+ </with>
+ </and>
+ </activeWhen>
+ <enabledWhen>
+ <with variable="selection">
+ <iterate operator="and" ifEmpty="false">
+ <test property="org.eclipse.tcf.te.launch.ui.model.canDelete" value="true"/>
+ </iterate>
+ </with>
+ </enabledWhen>
+ </handler>
+
+ <handler
+ class="org.eclipse.tcf.te.launch.ui.internal.handler.DeleteHandler"
commandId="org.eclipse.ui.edit.delete">
<activeWhen>
<and>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/LaunchNodePropertyTester.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/LaunchNodePropertyTester.java
index 05a63065d..6d7eb18f2 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/LaunchNodePropertyTester.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/LaunchNodePropertyTester.java
@@ -10,12 +10,14 @@
package org.eclipse.tcf.te.launch.ui.internal;
import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.tcf.te.launch.ui.internal.handler.DeleteHandler;
import org.eclipse.tcf.te.launch.ui.model.LaunchNode;
/**
* The property tester for a launch tree node.
*/
public class LaunchNodePropertyTester extends PropertyTester {
+ private final DeleteHandler deleteHandler = new DeleteHandler();
/*
* (non-Javadoc)
@@ -34,6 +36,9 @@ public class LaunchNodePropertyTester extends PropertyTester {
else if (property.equals("isLaunchConfig")) { //$NON-NLS-1$
return LaunchNode.TYPE_LAUNCH_CONFIG.equals(node.getType());
}
+ else if (property.equals("canDelete")) { //$NON-NLS-1$
+ return deleteHandler.canDelete(receiver);
+ }
}
return false;
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/adapters/AdapterFactory.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/adapters/AdapterFactory.java
index dee7dcabe..78a1476ba 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/adapters/AdapterFactory.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/adapters/AdapterFactory.java
@@ -13,7 +13,6 @@ import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.tcf.te.launch.ui.internal.viewer.LaunchTreeLabelProvider;
import org.eclipse.tcf.te.launch.ui.model.LaunchNode;
-import org.eclipse.tcf.te.ui.views.interfaces.handler.IDeleteHandlerDelegate;
import org.eclipse.tcf.te.ui.views.interfaces.handler.IRefreshHandlerDelegate;
/**
@@ -24,8 +23,6 @@ public class AdapterFactory implements IAdapterFactory {
private ILabelProvider labelProvider = new LaunchTreeLabelProvider();
// The refresh handler delegate adapter
private IRefreshHandlerDelegate refreshDelegate = new RefreshHandlerDelegate();
- // The delete handler delegate adapter
- private static IDeleteHandlerDelegate deleteDelegate = new DeleteHandlerDelegate();
/* (non-Javadoc)
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
@@ -36,9 +33,6 @@ public class AdapterFactory implements IAdapterFactory {
if (ILabelProvider.class.equals(adapterType)) {
return labelProvider;
}
- if (IDeleteHandlerDelegate.class.equals(adapterType) && LaunchNode.TYPE_LAUNCH_CONFIG.equals(((LaunchNode)adaptableObject).getType())) {
- return deleteDelegate;
- }
if (IRefreshHandlerDelegate.class.equals(adapterType)) {
return refreshDelegate;
}
@@ -53,7 +47,6 @@ public class AdapterFactory implements IAdapterFactory {
public Class[] getAdapterList() {
return new Class<?>[] {
ILabelProvider.class,
- IDeleteHandlerDelegate.class,
IRefreshHandlerDelegate.class
};
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/adapters/DeleteHandlerDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/adapters/DeleteHandlerDelegate.java
deleted file mode 100644
index 0526616ea..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/adapters/DeleteHandlerDelegate.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. 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 http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.launch.ui.internal.adapters;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.tcf.te.launch.ui.activator.UIPlugin;
-import org.eclipse.tcf.te.launch.ui.model.LaunchNode;
-import org.eclipse.tcf.te.launch.ui.nls.Messages;
-import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
-import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
-import org.eclipse.tcf.te.runtime.utils.StatusHelper;
-import org.eclipse.tcf.te.ui.views.interfaces.handler.IDeleteHandlerDelegate;
-
-/**
- * File System tree node delete handler delegate implementation.
- */
-public class DeleteHandlerDelegate implements IDeleteHandlerDelegate {
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.views.interfaces.handler.IDeleteHandlerDelegate#canDelete(java.lang.Object)
- */
- @Override
- public boolean canDelete(Object element) {
- if (element instanceof LaunchNode) {
- LaunchNode node = (LaunchNode)element;
- return LaunchNode.TYPE_LAUNCH_CONFIG.equals(node.getType()) && !node.getLaunchConfiguration().isReadOnly();
- }
- return false;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.views.interfaces.handler.IDeleteHandlerDelegate#delete(java.lang.Object, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback)
- */
- @Override
- public void delete(Object element, IPropertiesContainer state, final ICallback callback) {
- Assert.isNotNull(element);
- Assert.isNotNull(state);
-
- if (element instanceof LaunchNode) {
- final LaunchNode node = (LaunchNode)element;
- try {
- if (MessageDialog.openQuestion(
- UIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(),
- Messages.DeleteHandlerDelegate_question_title, NLS.bind(Messages.DeleteHandlerDelegate_question_message, node.getLaunchConfiguration().getName()))) {
- node.getLaunchConfiguration().delete();
- if (callback != null) {
- callback.done(this, Status.OK_STATUS);
- }
- }
- else {
- if (callback != null) {
- callback.done(this, Status.CANCEL_STATUS);
- }
- }
- }
- catch (Exception e) {
- if (callback != null) {
- callback.done(this, StatusHelper.getStatus(e));
- }
- }
- }
- }
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/DeleteHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/handler/DeleteHandler.java
index a9fe2907c..fa9f382f1 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/DeleteHandler.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/handler/DeleteHandler.java
@@ -7,22 +7,29 @@
* Contributors:
* Wind River Systems - initial API and implementation
*******************************************************************************/
-package org.eclipse.tcf.te.ui.views.handler;
+package org.eclipse.tcf.te.launch.ui.internal.handler;
import java.util.Iterator;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.tcf.te.launch.ui.activator.UIPlugin;
+import org.eclipse.tcf.te.launch.ui.model.LaunchNode;
+import org.eclipse.tcf.te.launch.ui.nls.Messages;
import org.eclipse.tcf.te.runtime.callback.Callback;
+import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
import org.eclipse.tcf.te.runtime.properties.PropertiesContainer;
-import org.eclipse.tcf.te.ui.views.interfaces.handler.IDeleteHandlerDelegate;
+import org.eclipse.tcf.te.runtime.utils.StatusHelper;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.handlers.HandlerUtil;
@@ -53,12 +60,8 @@ public class DeleteHandler extends AbstractHandler {
while (iterator.hasNext()) {
final Object element = iterator.next();
- // Determine the delete handler delegate for the selected element
- IDeleteHandlerDelegate delegate = element instanceof IDeleteHandlerDelegate ? (IDeleteHandlerDelegate)element : null;
- if (delegate == null) delegate = (IDeleteHandlerDelegate)Platform.getAdapterManager().loadAdapter(element, IDeleteHandlerDelegate.class.getName());
-
// Delete the element if there is a valid delegate
- if (delegate != null && delegate.canDelete(element)) {
+ if (canDelete(element)) {
// Determine the elements parent element
Object parentElement = null;
CommonViewer viewer = (CommonViewer)part.getAdapter(CommonViewer.class);
@@ -69,7 +72,7 @@ public class DeleteHandler extends AbstractHandler {
final Object finParentElement = parentElement;
// Delete the element and refresh the parent element
- delegate.delete(element, state, new Callback() {
+ delete(element, state, new Callback() {
@Override
protected void internalDone(Object caller, IStatus status) {
PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
@@ -93,4 +96,45 @@ public class DeleteHandler extends AbstractHandler {
return null;
}
+
+ // ***** DeleteHandlerDelegate content. Clean up. *****
+
+ @Deprecated
+ public boolean canDelete(Object element) {
+ if (element instanceof LaunchNode) {
+ LaunchNode node = (LaunchNode)element;
+ return LaunchNode.TYPE_LAUNCH_CONFIG.equals(node.getType()) && !node.getLaunchConfiguration().isReadOnly();
+ }
+ return false;
+ }
+
+ @Deprecated
+ public void delete(Object element, IPropertiesContainer state, final ICallback callback) {
+ Assert.isNotNull(element);
+ Assert.isNotNull(state);
+
+ if (element instanceof LaunchNode) {
+ final LaunchNode node = (LaunchNode)element;
+ try {
+ if (MessageDialog.openQuestion(
+ UIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(),
+ Messages.DeleteHandlerDelegate_question_title, NLS.bind(Messages.DeleteHandlerDelegate_question_message, node.getLaunchConfiguration().getName()))) {
+ node.getLaunchConfiguration().delete();
+ if (callback != null) {
+ callback.done(this, Status.OK_STATUS);
+ }
+ }
+ else {
+ if (callback != null) {
+ callback.done(this, Status.CANCEL_STATUS);
+ }
+ }
+ }
+ catch (Exception e) {
+ if (callback != null) {
+ callback.done(this, StatusHelper.getStatus(e));
+ }
+ }
+ }
+ }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/plugin.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/plugin.properties
index 7ea30d154..98877889f 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/plugin.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/plugin.properties
@@ -62,6 +62,9 @@ command.commit.name = Commit File
command.merge.name = Merge File
command.revert.name = Revert File
+command.delete.label=Delete
+command.delete.description=Delete the selected node
+
decorator.modified.label = Modified Cache
decorator.outdated.label = Outdated Cache
decorator.conflict.label = Conflicting Cache
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/plugin.xml
index 6346cb378..82e3fa2e1 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/plugin.xml
@@ -362,10 +362,9 @@
<iterate
ifEmpty="false"
operator="and">
- <test
- property="org.eclipse.tcf.te.ui.views.isDeletableElement"
- value="true">
- </test>
+ <instanceof
+ value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode">
+ </instanceof>
</iterate>
</with>
</visibleWhen>
@@ -549,6 +548,28 @@
</visibleWhen>
</command>
</menuContribution>
+ <menuContribution locationURI="popup:org.eclipse.tcf.te.ui.views.View#Popup?after=group.delete">
+ <command
+ commandId="org.eclipse.ui.edit.delete"
+ disabledIcon="platform:/plugin/org.eclipse.ui/icons/full/dtool16/delete.gif"
+ helpContextId="org.eclipse.tcf.te.ui.command_Delete"
+ icon="platform:/plugin/org.eclipse.ui/icons/full/etool16/delete.gif"
+ id="org.eclipse.tcf.te.ui.commands.delete"
+ label="%command.delete.label"
+ mnemonic="D"
+ style="push"
+ tooltip="%command.delete.description">
+ <visibleWhen checkEnabled="false">
+ <with variable="selection">
+ <count value="+"/>
+ <iterate operator="and" ifEmpty="false">
+ <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode"/>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+
<menuContribution locationURI="popup:org.eclipse.tcf.te.ui.views.View#Popup?after=group.properties">
<command
commandId="org.eclipse.ui.file.properties"
@@ -936,6 +957,13 @@
properties="isEditorActivation"
type="org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent">
</propertyTester>
+ <propertyTester
+ id="org.eclipse.tcf.te.tcf.filesystem.propertytester.treenode"
+ class="org.eclipse.tcf.te.tcf.filesystem.ui.internal.testers.TreeNodePropertyTester"
+ namespace="org.eclipse.tcf.te.tcf.filesystem"
+ properties="canDelete"
+ type="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode">
+ </propertyTester>
</extension>
<!-- Command contributions -->
@@ -1565,6 +1593,37 @@
class="org.eclipse.tcf.te.tcf.filesystem.ui.internal.handlers.RefreshViewerHandler"
commandId="org.eclipse.tcf.te.tcf.filesystem.commands.refreshViewer">
</handler>
+
+ <handler
+ commandId="org.eclipse.ui.edit.delete"
+ class="org.eclipse.tcf.te.tcf.ui.handler.DeleteHandler">
+ <activeWhen>
+ <and>
+ <with variable="activePartId">
+ <or>
+ <equals value="org.eclipse.tcf.te.ui.views.View"/>
+ <equals value="org.eclipse.tcf.te.ui.views.Editor"/>
+ </or>
+ </with>
+ <with variable="selection">
+ <iterate operator="and" ifEmpty="false">
+ <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode"/>
+ </iterate>
+ </with>
+ </and>
+ </activeWhen>
+ <enabledWhen>
+ <with variable="selection">
+ <iterate operator="and" ifEmpty="false">
+ <test
+ property="org.eclipse.tcf.te.tcf.filesystem.canDelete"
+ value="true">
+ </test>
+ </iterate>
+ </with>
+ </enabledWhen>
+ </handler>
+
</extension>
<!-- Decorator contributions -->
@@ -1667,9 +1726,6 @@
type="org.eclipse.tcf.te.ui.views.interfaces.handler.IRefreshHandlerDelegate">
</adapter>
<adapter
- type="org.eclipse.tcf.te.ui.views.interfaces.handler.IDeleteHandlerDelegate">
- </adapter>
- <adapter
type="org.eclipse.ui.IPersistableElement">
</adapter>
</factory>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSTreeNodeAdapterFactory.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSTreeNodeAdapterFactory.java
index 7b53d0681..c1fe7d5b4 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSTreeNodeAdapterFactory.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/FSTreeNodeAdapterFactory.java
@@ -19,7 +19,6 @@ import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
import org.eclipse.tcf.te.tcf.filesystem.ui.activator.UIPlugin;
import org.eclipse.tcf.te.tcf.filesystem.ui.internal.columns.FSTreeElementLabelProvider;
-import org.eclipse.tcf.te.ui.views.interfaces.handler.IDeleteHandlerDelegate;
import org.eclipse.tcf.te.ui.views.interfaces.handler.IRefreshHandlerDelegate;
import org.eclipse.ui.IActionFilter;
import org.eclipse.ui.IPersistableElement;
@@ -29,7 +28,6 @@ import org.eclipse.ui.IPersistableElement;
*/
public class FSTreeNodeAdapterFactory implements IAdapterFactory {
private static ILabelProvider nodeLabelProvider = new FSTreeElementLabelProvider();
- private static IDeleteHandlerDelegate deleteDelegate = new DeleteHandlerDelegate();
private static IRefreshHandlerDelegate refreshDelegate = new RefreshHandlerDelegate();
// The fFilters map caching fFilters for FS nodes.
private Map<FSTreeNode, NodeStateFilter> filters;
@@ -62,9 +60,6 @@ public class FSTreeNodeAdapterFactory implements IAdapterFactory {
else if(adapterType == IRefreshHandlerDelegate.class) {
return refreshDelegate;
}
- else if(adapterType == IDeleteHandlerDelegate.class) {
- return deleteDelegate;
- }
else if(adapterType == IPersistableElement.class && UIPlugin.isExpandedPersisted()) {
return new PersistableNode(node);
}
@@ -77,6 +72,6 @@ public class FSTreeNodeAdapterFactory implements IAdapterFactory {
*/
@Override
public Class[] getAdapterList() {
- return new Class[] { IActionFilter.class, ILabelProvider.class, IRefreshHandlerDelegate.class, IDeleteHandlerDelegate.class, IPersistableElement.class };
+ return new Class[] { IActionFilter.class, ILabelProvider.class, IRefreshHandlerDelegate.class, IPersistableElement.class };
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/DeleteHandlerDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/handlers/DeleteHandler.java
index 4f0ef3aa3..da7622570 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/adapters/DeleteHandlerDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/handlers/DeleteHandler.java
@@ -7,20 +7,29 @@
* Contributors:
* Wind River Systems - initial API and implementation
*******************************************************************************/
-package org.eclipse.tcf.te.tcf.filesystem.ui.internal.adapters;
+package org.eclipse.tcf.te.tcf.filesystem.ui.internal.handlers;
+import java.util.Iterator;
import java.util.List;
import java.util.UUID;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.tcf.te.runtime.callback.Callback;
import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.runtime.properties.PropertiesContainer;
import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IConfirmCallback;
import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.IOpExecutor;
import org.eclipse.tcf.te.tcf.filesystem.core.internal.operations.OpDelete;
@@ -29,61 +38,106 @@ import org.eclipse.tcf.te.tcf.filesystem.ui.activator.UIPlugin;
import org.eclipse.tcf.te.tcf.filesystem.ui.internal.ImageConsts;
import org.eclipse.tcf.te.tcf.filesystem.ui.internal.operations.UiExecutor;
import org.eclipse.tcf.te.tcf.filesystem.ui.nls.Messages;
-import org.eclipse.tcf.te.ui.views.interfaces.handler.IDeleteHandlerDelegate;
+import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.ui.navigator.CommonViewer;
/**
- * File System tree node delete handler delegate implementation.
+ * Delete handler implementation.
*/
-public class DeleteHandlerDelegate implements IDeleteHandlerDelegate {
+public class DeleteHandler extends AbstractHandler {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ // Get the current selection
+ ISelection selection = HandlerUtil.getCurrentSelection(event);
+ if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
+ // Determine the active part
+ final IWorkbenchPart part = HandlerUtil.getActivePart(event);
+ // Create the delete state properties container
+ final IPropertiesContainer state = new PropertiesContainer();
+ // Store the selection to the state as reference
+ state.setProperty("selection", selection); //$NON-NLS-1$
+
+ // Loop over the selection and delete the elements providing an IDeleteHandlerDelegate
+ Iterator<?> iterator = ((IStructuredSelection)selection).iterator();
+ while (iterator.hasNext()) {
+ final Object element = iterator.next();
+
+ // Delete the element if there is a valid delegate
+ if (canDelete(element)) {
+ // Determine the elements parent element
+ Object parentElement = null;
+ CommonViewer viewer = (CommonViewer)part.getAdapter(CommonViewer.class);
+ if (viewer != null && viewer.getContentProvider() instanceof ITreeContentProvider) {
+ ITreeContentProvider cp = (ITreeContentProvider)viewer.getContentProvider();
+ parentElement = cp.getParent(element);
+ }
+ final Object finParentElement = parentElement;
+
+ // Delete the element and refresh the parent element
+ delete(element, state, new Callback() {
+ @Override
+ protected void internalDone(Object caller, IStatus status) {
+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ CommonViewer viewer = (CommonViewer)part.getAdapter(CommonViewer.class);
+ if (viewer != null) {
+ if (finParentElement != null) {
+ viewer.refresh(finParentElement, true);
+ } else {
+ viewer.refresh(true);
+ }
+ }
+ }
+ });
+ }
+ });
+ }
+ }
+ }
+
+ return null;
+ }
+
+ // ***** DeleteHandlerDelegate content. Clean up. *****
// The key to access the selection in the state.
private static final String KEY_SELECTION = "selection"; //$NON-NLS-1$
// The key to access the processed state in the state.
private static final String KEY_PROCESSED = "processed"; //$NON-NLS-1$
// The deletion confirmation callback
- private IConfirmCallback confirmCallback;
+ private IConfirmCallback confirmCallback = new DeletionConfirmCallback();
// The confirmation call for read only files.
- private IConfirmCallback readonlyCallback;
-
- /**
- * Constructor
- */
- public DeleteHandlerDelegate() {
- confirmCallback = new DeletionConfirmCallback();
- readonlyCallback = new ReadOnlyConfirmCallback();
- }
-
+ private IConfirmCallback readonlyCallback = new ReadOnlyConfirmCallback();
+
/**
* Set the confirmation callback
- *
+ *
* @param confirmCallback The confirmation callback
*/
public void setConfirmCallback(IConfirmCallback confirmCallback) {
this.confirmCallback = confirmCallback;
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.views.interfaces.handler.IDeleteHandlerDelegate#canDelete(java.lang.Object)
- */
- @Override
+ @Deprecated
public boolean canDelete(Object element) {
if (element instanceof FSTreeNode) {
FSTreeNode node = (FSTreeNode) element;
if (!node.isSystemRoot() && !node.isRoot()) {
- return node.isWindowsNode() && !node.isReadOnly()
+ return node.isWindowsNode() && !node.isReadOnly()
|| !node.isWindowsNode() && node.isWritable();
}
}
return false;
}
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.views.interfaces.handler.IDeleteHandlerDelegate#delete(java.lang.Object, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback)
- */
- @Override
+ @Deprecated
public void delete(Object element, IPropertiesContainer state, ICallback callback) {
Assert.isNotNull(element);
Assert.isNotNull(state);
@@ -143,9 +197,9 @@ public class DeleteHandlerDelegate implements IDeleteHandlerDelegate {
});
return results[0];
}
-
+
}
-
+
static class DeletionConfirmCallback implements IConfirmCallback {
/*
* (non-Javadoc)
@@ -155,7 +209,7 @@ public class DeleteHandlerDelegate implements IDeleteHandlerDelegate {
public boolean requires(Object object) {
return true;
}
-
+
/*
* (non-Javadoc)
* @see org.eclipse.tcf.te.tcf.filesystem.interfaces.IConfirmCallback#confirms(java.lang.Object)
@@ -163,7 +217,7 @@ public class DeleteHandlerDelegate implements IDeleteHandlerDelegate {
@Override
public int confirms(Object object) {
IStructuredSelection selection = (IStructuredSelection) object;
- List<FSTreeNode> nodes = selection.toList();
+ List<FSTreeNode> nodes = selection.toList();
String question;
if (nodes.size() == 1) {
FSTreeNode node = nodes.get(0);
@@ -173,7 +227,7 @@ public class DeleteHandlerDelegate implements IDeleteHandlerDelegate {
question = NLS.bind(Messages.DeleteFilesHandler_DeleteMultipleFilesConfirmation, Integer.valueOf(nodes.size()));
}
Shell parent = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
- if (MessageDialog.openQuestion(parent, Messages.DeleteFilesHandler_ConfirmDialogTitle, question)) {
+ if (MessageDialog.openQuestion(parent, Messages.DeleteFilesHandler_ConfirmDialogTitle, question)) {
return IConfirmCallback.YES;
}
return IConfirmCallback.NO;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/testers/TreeNodePropertyTester.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/testers/TreeNodePropertyTester.java
new file mode 100644
index 000000000..4e43d4b75
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/testers/TreeNodePropertyTester.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems, Inc. and others. 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 http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.filesystem.ui.internal.testers;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.ui.internal.handlers.DeleteHandler;
+
+/**
+ * Tree node property tester.
+ */
+public class TreeNodePropertyTester extends PropertyTester {
+ private final DeleteHandler deleteHandler = new DeleteHandler();
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
+ */
+ @Override
+ public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
+ if (receiver instanceof FSTreeNode && "canDelete".equals(property)) { //$NON-NLS-1$
+ return deleteHandler.canDelete(receiver);
+ }
+ return false;
+ }
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.properties
index fbc3693d2..5969e1fa6 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.properties
@@ -45,6 +45,9 @@ preference.page.name = Logging
# ***** Command Contributions *****
+command.delete.label=Delete
+command.delete.description=Delete the selected node
+
command.redirect.name=Redirect Command
command.redirect.label=Redirect...
command.redirect.tooltip=Redirect communication to this node through a proxy
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml
index aaabfedba..dd16b6d92 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml
@@ -9,7 +9,6 @@
class="org.eclipse.tcf.te.tcf.ui.internal.adapters.AdapterFactory">
<adapter type="org.eclipse.jface.viewers.ILabelProvider"/>
<adapter type="org.eclipse.tcf.te.ui.views.interfaces.handler.IRefreshHandlerDelegate"/>
- <adapter type="org.eclipse.tcf.te.ui.views.interfaces.handler.IDeleteHandlerDelegate"/>
<adapter type="org.eclipse.ui.IPersistableElement"/>
<adapter type="org.eclipse.tcf.te.ui.views.interfaces.categories.ICategorizable"/>
</factory>
@@ -233,6 +232,29 @@
</visibleWhen>
</command>
</menuContribution>
+
+ <menuContribution locationURI="popup:org.eclipse.tcf.te.ui.views.View#Popup?after=group.delete">
+ <command
+ commandId="org.eclipse.ui.edit.delete"
+ disabledIcon="platform:/plugin/org.eclipse.ui/icons/full/dtool16/delete.gif"
+ helpContextId="org.eclipse.tcf.te.ui.command_Delete"
+ icon="platform:/plugin/org.eclipse.ui/icons/full/etool16/delete.gif"
+ id="org.eclipse.tcf.te.ui.commands.delete"
+ label="%command.delete.label"
+ mnemonic="D"
+ style="push"
+ tooltip="%command.delete.description">
+ <visibleWhen checkEnabled="false">
+ <with variable="selection">
+ <count value="+"/>
+ <iterate operator="and" ifEmpty="false">
+ <instanceof value="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel"/>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+ </menuContribution>
+
</extension>
<!-- Command contributions -->
@@ -294,6 +316,37 @@
</with>
</enabledWhen>
</handler>
+
+ <handler
+ commandId="org.eclipse.ui.edit.delete"
+ class="org.eclipse.tcf.te.tcf.ui.handler.DeleteHandler">
+ <activeWhen>
+ <and>
+ <with variable="activePartId">
+ <or>
+ <equals value="org.eclipse.tcf.te.ui.views.View"/>
+ <equals value="org.eclipse.tcf.te.ui.views.Editor"/>
+ </or>
+ </with>
+ <with variable="selection">
+ <iterate operator="and" ifEmpty="false">
+ <instanceof value="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel"/>
+ </iterate>
+ </with>
+ </and>
+ </activeWhen>
+ <enabledWhen>
+ <with variable="selection">
+ <iterate operator="and" ifEmpty="false">
+ <and>
+ <instanceof value="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel"/>
+ <test property="org.eclipse.tcf.te.tcf.locator.isStaticPeer" value="true"/>
+ </and>
+ </iterate>
+ </with>
+ </enabledWhen>
+ </handler>
+
</extension>
<!-- Tabbed properties view contributions -->
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/DeleteHandlerDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/DeleteHandler.java
index c18d3981f..2c22033a0 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/DeleteHandlerDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/DeleteHandler.java
@@ -7,22 +7,29 @@
* Contributors:
* Wind River Systems - initial API and implementation
*******************************************************************************/
-package org.eclipse.tcf.te.tcf.ui.internal.adapters;
+package org.eclipse.tcf.te.tcf.ui.handler;
import java.io.IOException;
+import java.util.Iterator;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.tcf.protocol.IPeer;
import org.eclipse.tcf.protocol.Protocol;
+import org.eclipse.tcf.te.runtime.callback.Callback;
import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
import org.eclipse.tcf.te.runtime.persistence.interfaces.IURIPersistenceService;
@@ -38,22 +45,80 @@ import org.eclipse.tcf.te.tcf.locator.model.Model;
import org.eclipse.tcf.te.tcf.ui.activator.UIPlugin;
import org.eclipse.tcf.te.tcf.ui.help.IContextHelpIds;
import org.eclipse.tcf.te.tcf.ui.nls.Messages;
-import org.eclipse.tcf.te.ui.views.interfaces.handler.IDeleteHandlerDelegate;
+import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.ui.navigator.CommonViewer;
/**
- * Peer model node delete handler delegate implementation.
+ * Delete handler implementation.
*/
-public class DeleteHandlerDelegate implements IDeleteHandlerDelegate {
+public class DeleteHandler extends AbstractHandler {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ // Get the current selection
+ ISelection selection = HandlerUtil.getCurrentSelection(event);
+ if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
+ // Determine the active part
+ final IWorkbenchPart part = HandlerUtil.getActivePart(event);
+ // Create the delete state properties container
+ final IPropertiesContainer state = new PropertiesContainer();
+ // Store the selection to the state as reference
+ state.setProperty("selection", selection); //$NON-NLS-1$
+
+ // Loop over the selection and delete the elements providing an IDeleteHandlerDelegate
+ Iterator<?> iterator = ((IStructuredSelection)selection).iterator();
+ while (iterator.hasNext()) {
+ final Object element = iterator.next();
+
+ // Delete the element if there is a valid delegate
+ if (canDelete(element)) {
+ // Determine the elements parent element
+ Object parentElement = null;
+ CommonViewer viewer = (CommonViewer)part.getAdapter(CommonViewer.class);
+ if (viewer != null && viewer.getContentProvider() instanceof ITreeContentProvider) {
+ ITreeContentProvider cp = (ITreeContentProvider)viewer.getContentProvider();
+ parentElement = cp.getParent(element);
+ }
+ final Object finParentElement = parentElement;
+
+ // Delete the element and refresh the parent element
+ delete(element, state, new Callback() {
+ @Override
+ protected void internalDone(Object caller, IStatus status) {
+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ CommonViewer viewer = (CommonViewer)part.getAdapter(CommonViewer.class);
+ if (viewer != null) {
+ if (finParentElement != null) {
+ viewer.refresh(finParentElement, true);
+ } else {
+ viewer.refresh(true);
+ }
+ }
+ }
+ });
+ }
+ });
+ }
+ }
+ }
+
+ return null;
+ }
+
+ // ***** DeleteHandlerDelegate content. Clean up. *****
private static final String KEY_CONFIRMED = "confirmed"; //$NON-NLS-1$
private static final String KEY_SELECTION = "selection"; //$NON-NLS-1$
private static final String KEY_PROCESSED = "processed"; //$NON-NLS-1$
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.views.interfaces.handler.IDeleteHandlerDelegate#canDelete(java.lang.Object)
- */
- @Override
+ @Deprecated
public boolean canDelete(final Object element) {
if (element instanceof IPeerModel) {
final AtomicBoolean canDelete = new AtomicBoolean();
@@ -78,10 +143,7 @@ public class DeleteHandlerDelegate implements IDeleteHandlerDelegate {
return false;
}
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.views.interfaces.handler.IDeleteHandlerDelegate#delete(java.lang.Object, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback)
- */
- @Override
+ @Deprecated
public void delete(Object element, IPropertiesContainer state, ICallback callback) {
Assert.isNotNull(element);
Assert.isNotNull(state);
@@ -142,7 +204,7 @@ public class DeleteHandlerDelegate implements IDeleteHandlerDelegate {
/**
* Confirm the deletion with the user.
- *
+ *
* @param state The state of delegation handler.
* @return true if the user agrees to delete or it has confirmed previously.
*/
@@ -165,7 +227,7 @@ public class DeleteHandlerDelegate implements IDeleteHandlerDelegate {
/**
* Get confirmation question displayed in the confirmation dialog.
- *
+ *
* @param selection The current selection selected to delete.
* @return The question to ask the user.
*/
@@ -196,4 +258,6 @@ public class DeleteHandlerDelegate implements IDeleteHandlerDelegate {
}
return question;
}
+
+
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/AdapterFactory.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/AdapterFactory.java
index 2fbce6218..d87e9b134 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/AdapterFactory.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/adapters/AdapterFactory.java
@@ -14,7 +14,6 @@ import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
import org.eclipse.tcf.te.tcf.ui.navigator.LabelProviderDelegate;
import org.eclipse.tcf.te.ui.views.interfaces.categories.ICategorizable;
-import org.eclipse.tcf.te.ui.views.interfaces.handler.IDeleteHandlerDelegate;
import org.eclipse.tcf.te.ui.views.interfaces.handler.IRefreshHandlerDelegate;
import org.eclipse.ui.IPersistableElement;
@@ -26,14 +25,11 @@ public class AdapterFactory implements IAdapterFactory {
private final LabelProviderDelegate labelProvider = new LabelProviderDelegate();
// The refresh handler delegate adapter
private final IRefreshHandlerDelegate refreshDelegate = new RefreshHandlerDelegate();
- // The delete handler delegate adapter
- private final IDeleteHandlerDelegate deleteDelegate = new DeleteHandlerDelegate();
// The adapter class.
private Class<?>[] adapters = {
ILabelProvider.class,
IRefreshHandlerDelegate.class,
- IDeleteHandlerDelegate.class,
IPersistableElement.class,
ICategorizable.class
};
@@ -50,9 +46,6 @@ public class AdapterFactory implements IAdapterFactory {
if (IRefreshHandlerDelegate.class.equals(adapterType)) {
return refreshDelegate;
}
- if (IDeleteHandlerDelegate.class.equals(adapterType)) {
- return deleteDelegate;
- }
if (IPersistableElement.class.equals(adapterType)) {
return new PersistablePeerModel((IPeerModel)adaptableObject);
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/adapters/DeleteHandlerDelegateTest.java b/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/adapters/DeleteHandlerDelegateTest.java
index 0c4aa5104..247185454 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/adapters/DeleteHandlerDelegateTest.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/adapters/DeleteHandlerDelegateTest.java
@@ -9,20 +9,18 @@
*******************************************************************************/
package org.eclipse.tcf.te.tests.tcf.filesystem.adapters;
-import org.eclipse.core.runtime.Platform;
import org.eclipse.tcf.te.tcf.filesystem.core.interfaces.IConfirmCallback;
-import org.eclipse.tcf.te.tcf.filesystem.ui.internal.adapters.DeleteHandlerDelegate;
+import org.eclipse.tcf.te.tcf.filesystem.ui.internal.handlers.DeleteHandler;
import org.eclipse.tcf.te.tests.tcf.filesystem.FSPeerTestCase;
-import org.eclipse.tcf.te.ui.views.interfaces.handler.IDeleteHandlerDelegate;
@SuppressWarnings("restriction")
public class DeleteHandlerDelegateTest extends FSPeerTestCase {
- private IDeleteHandlerDelegate delegate;
+ private DeleteHandler delegate;
@Override
protected void setUp() throws Exception {
super.setUp();
- delegate = (IDeleteHandlerDelegate) Platform.getAdapterManager().getAdapter(test11File, IDeleteHandlerDelegate.class);
+ delegate = new DeleteHandler();
assertNotNull(delegate);
IConfirmCallback confirmCallback = new IConfirmCallback() {
@Override
@@ -36,7 +34,7 @@ public class DeleteHandlerDelegateTest extends FSPeerTestCase {
return 0;
}
};
- ((DeleteHandlerDelegate) delegate).setConfirmCallback(confirmCallback);
+ delegate.setConfirmCallback(confirmCallback);
}
public void testCanDelete() {
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/adapters/FSTreeNodeAdapterFactoryTest.java b/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/adapters/FSTreeNodeAdapterFactoryTest.java
index 597f35ba4..271add67c 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/adapters/FSTreeNodeAdapterFactoryTest.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/filesystem/adapters/FSTreeNodeAdapterFactoryTest.java
@@ -12,7 +12,6 @@ package org.eclipse.tcf.te.tests.tcf.filesystem.adapters;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.tcf.te.tests.tcf.filesystem.FSPeerTestCase;
-import org.eclipse.tcf.te.ui.views.interfaces.handler.IDeleteHandlerDelegate;
import org.eclipse.tcf.te.ui.views.interfaces.handler.IRefreshHandlerDelegate;
import org.eclipse.ui.IActionFilter;
@@ -21,19 +20,15 @@ public class FSTreeNodeAdapterFactoryTest extends FSPeerTestCase {
IActionFilter filter = (IActionFilter) Platform.getAdapterManager().getAdapter(testFile, IActionFilter.class);
assertNotNull(filter);
}
-
+
public void testLabelProviderAdapter() {
ILabelProvider labelProvider = (ILabelProvider) Platform.getAdapterManager().getAdapter(testFile, ILabelProvider.class);
assertNotNull(labelProvider);
}
-
+
public void testRefreshHandlerDelegateAdapter() {
IRefreshHandlerDelegate delegate = (IRefreshHandlerDelegate) Platform.getAdapterManager().getAdapter(testFolder, IRefreshHandlerDelegate.class);
assertNotNull(delegate);
}
-
- public void testDeleteHandlerDelegateAdapter() {
- IDeleteHandlerDelegate delegate = (IDeleteHandlerDelegate) Platform.getAdapterManager().getAdapter(testFolder, IDeleteHandlerDelegate.class);
- assertNotNull(delegate);
- }
+
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/plugin.properties b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/plugin.properties
index 9d27d630e..6a0dc62f7 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/plugin.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/plugin.properties
@@ -54,9 +54,6 @@ command.showInProperties.label = Show In Properties
command.refresh.label=Refresh
command.refresh.description=Refresh the selected node
-command.delete.label=Delete
-command.delete.description=Delete the selected node
-
command.filters.label = Filters...
command.content.label = Content...
command.filters.name = Filters
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/plugin.xml
index eeea0553f..df07fe45e 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/plugin.xml
@@ -229,31 +229,7 @@
</visibleWhen>
</command>
</menuContribution>
-
- <menuContribution locationURI="popup:org.eclipse.tcf.te.ui.views.View#Popup?after=group.delete">
- <command
- commandId="org.eclipse.ui.edit.delete"
- disabledIcon="platform:/plugin/org.eclipse.ui/icons/full/dtool16/delete.gif"
- helpContextId="org.eclipse.tcf.te.ui.command_Delete"
- icon="platform:/plugin/org.eclipse.ui/icons/full/etool16/delete.gif"
- id="org.eclipse.tcf.te.ui.commands.delete"
- label="%command.delete.label"
- mnemonic="D"
- style="push"
- tooltip="%command.delete.description">
- <visibleWhen checkEnabled="false">
- <with variable="selection">
- <count value="+"/>
- <iterate operator="and" ifEmpty="false">
- <test
- property="org.eclipse.tcf.te.ui.views.isDeletableElement"
- value="true"/>
- </iterate>
- </with>
- </visibleWhen>
- </command>
- </menuContribution>
-
+
<menuContribution locationURI="popup:org.eclipse.tcf.te.ui.views.View#Popup?after=group.properties">
<command
commandId="org.eclipse.ui.file.properties"
@@ -468,36 +444,6 @@
</handler>
<handler
- commandId="org.eclipse.ui.edit.delete"
- class="org.eclipse.tcf.te.ui.views.handler.DeleteHandler">
- <activeWhen>
- <and>
- <with variable="activePartId">
- <or>
- <equals value="org.eclipse.tcf.te.ui.views.View"/>
- <equals value="org.eclipse.tcf.te.ui.views.Editor"/>
- </or>
- </with>
- <with variable="selection">
- <iterate operator="and" ifEmpty="false">
- <test
- property="org.eclipse.tcf.te.ui.views.isDeletableElement"
- value="true"/>
- </iterate>
- </with>
- </and>
- </activeWhen>
- <enabledWhen>
- <with variable="selection">
- <iterate operator="and" ifEmpty="false">
- <test
- property="org.eclipse.tcf.te.ui.views.canDelete"
- value="true"/>
- </iterate>
- </with>
- </enabledWhen>
- </handler>
- <handler
class="org.eclipse.tcf.te.ui.views.handler.ConfigFiltersHandler"
commandId="org.eclipse.tcf.te.ui.views.command.filters">
<activeWhen>
@@ -529,7 +475,7 @@
class="org.eclipse.tcf.te.ui.views.expressions.PropertyTester"
id="org.eclipse.tcf.te.ui.views.PropertyTester"
namespace="org.eclipse.tcf.te.ui.views"
- properties="hasApplicableEditorBindings,isRefreshableElement,canRefresh,isDeletableElement,canDelete"
+ properties="hasApplicableEditorBindings,isRefreshableElement,canRefresh"
type="java.lang.Object">
</propertyTester>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/expressions/PropertyTester.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/expressions/PropertyTester.java
index f54351139..5f0c8ac6d 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/expressions/PropertyTester.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/expressions/PropertyTester.java
@@ -12,7 +12,6 @@ package org.eclipse.tcf.te.ui.views.expressions;
import org.eclipse.core.runtime.Platform;
import org.eclipse.tcf.te.ui.views.editor.EditorInput;
import org.eclipse.tcf.te.ui.views.extensions.EditorPageBindingExtensionPointManager;
-import org.eclipse.tcf.te.ui.views.interfaces.handler.IDeleteHandlerDelegate;
import org.eclipse.tcf.te.ui.views.interfaces.handler.IRefreshHandlerDelegate;
import org.eclipse.ui.IEditorInput;
@@ -63,36 +62,6 @@ public class PropertyTester extends org.eclipse.core.expressions.PropertyTester
return (expectedValue != null ? expectedValue : Boolean.TRUE).equals(Boolean.valueOf(canRefresh));
}
-
- if ("isDeletableElement".equals(property)) { //$NON-NLS-1$
- // An element is deletable if it implements or adapt to IDeleteHandlerDelegate
- //
- // Note: This test will force the load of the adapter.
-
- boolean deletable = receiver instanceof IDeleteHandlerDelegate;
- if (!deletable) {
- IDeleteHandlerDelegate delegate = (IDeleteHandlerDelegate)Platform.getAdapterManager().loadAdapter(receiver, IDeleteHandlerDelegate.class.getName());
- deletable = delegate != null;
- }
-
- return (expectedValue != null ? expectedValue : Boolean.TRUE).equals(Boolean.valueOf(deletable));
- }
-
- if ("canDelete".equals(property)) { //$NON-NLS-1$
- // Test if the receiver can be deleted
- IDeleteHandlerDelegate delegate = receiver instanceof IDeleteHandlerDelegate ? (IDeleteHandlerDelegate)receiver : null;
- if (delegate == null) {
- delegate = (IDeleteHandlerDelegate)Platform.getAdapterManager().loadAdapter(receiver, IDeleteHandlerDelegate.class.getName());
- }
-
- boolean canDelete = false;
- if (delegate != null) {
- canDelete = delegate.canDelete(receiver);
- }
-
- return (expectedValue != null ? expectedValue : Boolean.TRUE).equals(Boolean.valueOf(canDelete));
- }
-
return false;
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/interfaces/handler/IDeleteHandlerDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/interfaces/handler/IDeleteHandlerDelegate.java
deleted file mode 100644
index acd5c56de..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/interfaces/handler/IDeleteHandlerDelegate.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. 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 http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.ui.views.interfaces.handler;
-
-import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
-import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
-
-/**
- * Interface to be implemented by deletable nodes.
- * <p>
- * The interface can be implemented directly or provided as adapter.
- */
-public interface IDeleteHandlerDelegate {
-
- /**
- * Determines if the given element can be deleted or not. If the
- * method returns <code>false</code>, the delete action will be still
- * visible for such an element, but disabled.
- *
- * @param element The element. Must not be <code>null</code>.
- * @return <code>True</code> if the element can be refreshed, <code>false</code> otherwise.
- */
- public boolean canDelete(Object element);
-
- /**
- * Deletes the given element.
- * <p>
- * <b>Note:</b> The delete method will be called for each element of the current selection.
- * This might not be very practicable in all situations where the delete needs optimize the
- * deleted elements of a given selection. Clients can use the state properties container
- * to store delete operation wide status information and/or identify a delete operation
- * via the state properties container unique id.
- * <p>
- * The default delete handler implementation stores the current selection to the state properties
- * container using the key &quot;selection&quot;.
- *
- * @param element The element. Must not be <code>null</code>.
- * @param state The delete operation state. Must not be <code>null</code>.
- * @param callback The callback to invoke once the operation finished, or <code>null</code>.
- */
- public void delete(Object element, IPropertiesContainer state, ICallback callback);
-}

Back to the top