aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Schwarz2012-05-03 02:37:52 (EDT)
committerUwe Stieber2012-05-03 02:37:52 (EDT)
commit1e5af2f860f17aaa7e1b5ceba3f8dc11fe0915fe (patch)
treef772ab7c1594e2a1f4a70fc6f6838f7a0e5ee344
parentba219fcdd2984d592bc180dad18776f95bab1a37 (diff)
downloadorg.eclipse.tcf-1e5af2f860f17aaa7e1b5ceba3f8dc11fe0915fe.zip
org.eclipse.tcf-1e5af2f860f17aaa7e1b5ceba3f8dc11fe0915fe.tar.gz
org.eclipse.tcf-1e5af2f860f17aaa7e1b5ceba3f8dc11fe0915fe.tar.bz2
Target Explorer: REPLACE delete and refresh handler delegate
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/plugin.xml100
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/LaunchNodePropertyTester.java95
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/adapters/AdapterFactory.java101
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/adapters/RefreshHandlerDelegate.java53
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/handler/DeleteHandler.java79
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/handler/RefreshHandler.java102
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/LaunchNavigatorContentProvider.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/plugin.xml12
8 files changed, 298 insertions, 246 deletions
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 adc78ef..5c61d38 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.IRefreshHandlerDelegate"/>
</factory>
</extension>
@@ -18,7 +17,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,canDelete"
+ properties="isLaunchConfig,isLaunchConfigType,canDelete,canRefresh"
type="org.eclipse.tcf.te.launch.ui.model.LaunchNode">
</propertyTester>
</extension>
@@ -243,7 +242,7 @@
<iterate
ifEmpty="false"
operator="and">
- <test property="org.eclipse.tcf.te.ui.views.isRefreshableElement"/>
+ <instanceof value="org.eclipse.tcf.te.launch.ui.model.LaunchNode"/>
</iterate>
</with>
</visibleWhen>
@@ -336,7 +335,7 @@
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"
+ mnemonic="%Delete.menu.mnemonic"
style="push"
tooltip="%command.delete.description">
<visibleWhen checkEnabled="false">
@@ -349,6 +348,25 @@
</visibleWhen>
</command>
</menuContribution>
+ <menuContribution locationURI="popup:org.eclipse.tcf.te.ui.views.View#Popup?after=group.refresh">
+ <command
+ commandId="org.eclipse.tcf.te.ui.command.refresh"
+ id="org.eclipse.tcf.te.launch.ui.views.project.commands.refresh"
+ label="%Refresh.menu.name"
+ mnemonic="%Refresh.menu.mnemonic"
+ style="push">
+ <visibleWhen checkEnabled="false">
+ <with variable="selection">
+ <count value="1"/>
+ <iterate
+ ifEmpty="false"
+ operator="and">
+ <instanceof value="org.eclipse.tcf.te.launch.ui.model.LaunchNode"/>
+ </iterate>
+ </with>
+ </visibleWhen>
+ </command>
+ </menuContribution>
<!-- Launches editor page menu contributions -->
<menuContribution locationURI="popup:org.eclipse.tcf.te.launch.ui.editor.menu.launches">
@@ -498,7 +516,7 @@
<iterate
ifEmpty="false"
operator="and">
- <test property="org.eclipse.tcf.te.ui.views.isRefreshableElement"/>
+ <instanceof value="org.eclipse.tcf.te.launch.ui.model.LaunchNode"/>
</iterate>
</with>
</visibleWhen>
@@ -548,56 +566,45 @@
<handler
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>
<with variable="activePartId">
- <equals value="org.eclipse.ui.navigator.ProjectExplorer"/>
+ <or>
+ <equals value="org.eclipse.tcf.te.ui.views.View"/>
+ <equals value="org.eclipse.tcf.te.ui.views.Editor"/>
+ <equals value="org.eclipse.ui.navigator.ProjectExplorer"/>
+ </or>
</with>
<with variable="selection">
- <count value="1"/>
- <iterate
- ifEmpty="false"
- operator="and">
+ <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"/>
+ </iterate>
+ </with>
+ </enabledWhen>
</handler>
<handler
- class="org.eclipse.tcf.te.ui.views.handler.RefreshHandler"
- commandId="org.eclipse.tcf.te.ui.command.refresh">
+ commandId="org.eclipse.tcf.te.ui.command.refresh"
+ class="org.eclipse.tcf.te.launch.ui.internal.handler.RefreshHandler">
<activeWhen>
<and>
<with variable="activePartId">
- <equals value="org.eclipse.ui.navigator.ProjectExplorer"/>
+ <or>
+ <equals value="org.eclipse.tcf.te.ui.views.View"/>
+ <equals value="org.eclipse.tcf.te.ui.views.Editor"/>
+ <equals value="org.eclipse.ui.navigator.ProjectExplorer"/>
+ </or>
</with>
<with variable="selection">
<count value="1"/>
@@ -609,10 +616,19 @@
</with>
</and>
</activeWhen>
+ <enabledWhen>
+ <with variable="selection">
+ <iterate
+ operator="and"
+ ifEmpty="false">
+ <test property="org.eclipse.tcf.te.launch.ui.model.canRefresh"/>
+ </iterate>
+ </with>
+ </enabledWhen>
</handler>
<handler
- class="org.eclipse.tcf.te.ui.views.handler.ShowInPropertiesHandler"
- commandId="org.eclipse.tcf.te.ui.views.command.ShowInProperties">
+ commandId="org.eclipse.tcf.te.ui.views.command.ShowInProperties"
+ class="org.eclipse.tcf.te.ui.views.handler.ShowInPropertiesHandler">
<activeWhen>
<and>
<with variable="activePartId">
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 6d7eb18..78210ad 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
@@ -1,45 +1,50 @@
-/*******************************************************************************
- * 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;
-
-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)
- * @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 LaunchNode) {
- LaunchNode node = (LaunchNode)receiver;
- if (property.equals("isLaunchConfigType")) { //$NON-NLS-1$
- if (LaunchNode.TYPE_LAUNCH_CONFIG_TYPE.equals(node.getType())) {
- boolean isValue = expectedValue == null || expectedValue.equals(node.getLaunchConfigurationType().getIdentifier());
- return isValue;
- }
- }
- 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;
- }
-}
+/*******************************************************************************
+ * 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;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.tcf.te.launch.ui.internal.handler.DeleteHandler;
+import org.eclipse.tcf.te.launch.ui.internal.handler.RefreshHandler;
+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();
+ private final RefreshHandler refreshHandler = new RefreshHandler();
+
+ /*
+ * (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 LaunchNode) {
+ LaunchNode node = (LaunchNode)receiver;
+ if (property.equals("isLaunchConfigType")) { //$NON-NLS-1$
+ if (LaunchNode.TYPE_LAUNCH_CONFIG_TYPE.equals(node.getType())) {
+ boolean isValue = expectedValue == null || expectedValue.equals(node.getLaunchConfigurationType().getIdentifier());
+ return isValue;
+ }
+ }
+ 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);
+ }
+ else if (property.equals("canRefresh")) { //$NON-NLS-1$
+ return refreshHandler.canRefresh(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 78a1476..d98bc6b 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
@@ -1,54 +1,47 @@
-/*******************************************************************************
- * 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.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.IRefreshHandlerDelegate;
-
-/**
- * Adapter factory implementation.
- */
-public class AdapterFactory implements IAdapterFactory {
- // The adapter for ILabelProvider.class
- private ILabelProvider labelProvider = new LaunchTreeLabelProvider();
- // The refresh handler delegate adapter
- private IRefreshHandlerDelegate refreshDelegate = new RefreshHandlerDelegate();
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
- */
- @Override
- public Object getAdapter(Object adaptableObject, Class adapterType) {
- if (adaptableObject instanceof LaunchNode) {
- if (ILabelProvider.class.equals(adapterType)) {
- return labelProvider;
- }
- if (IRefreshHandlerDelegate.class.equals(adapterType)) {
- return refreshDelegate;
- }
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
- */
- @Override
- public Class[] getAdapterList() {
- return new Class<?>[] {
- ILabelProvider.class,
- IRefreshHandlerDelegate.class
- };
- }
-
-}
+/*******************************************************************************
+ * 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.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;
+
+/**
+ * Adapter factory implementation.
+ */
+public class AdapterFactory implements IAdapterFactory {
+ // The adapter for ILabelProvider.class
+ private ILabelProvider labelProvider = new LaunchTreeLabelProvider();
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
+ */
+ @Override
+ public Object getAdapter(Object adaptableObject, Class adapterType) {
+ if (adaptableObject instanceof LaunchNode) {
+ if (ILabelProvider.class.equals(adapterType)) {
+ return labelProvider;
+ }
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
+ */
+ @Override
+ public Class[] getAdapterList() {
+ return new Class<?>[] {
+ ILabelProvider.class
+ };
+ }
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/adapters/RefreshHandlerDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/adapters/RefreshHandlerDelegate.java
deleted file mode 100644
index 7807a58..0000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/adapters/RefreshHandlerDelegate.java
+++ /dev/null
@@ -1,53 +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.tcf.te.launch.ui.model.LaunchModel;
-import org.eclipse.tcf.te.launch.ui.model.LaunchNode;
-import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
-import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
-import org.eclipse.tcf.te.ui.views.interfaces.handler.IRefreshHandlerDelegate;
-
-/**
- * Launch tree node refresh handler delegate implementation.
- */
-public class RefreshHandlerDelegate implements IRefreshHandlerDelegate {
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.views.interfaces.handler.IRefreshHandlerDelegate#canRefresh(java.lang.Object)
- */
- @Override
- public boolean canRefresh(Object element) {
- if (element instanceof LaunchNode) {
- return true;
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.views.interfaces.handler.IRefreshHandlerDelegate#refresh(java.lang.Object, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback)
- */
- @Override
- public void refresh(Object element, IPropertiesContainer state, ICallback callback) {
- Assert.isNotNull(element);
- Assert.isNotNull(state);
-
- if (canRefresh(element)) {
- LaunchNode node = (LaunchNode) element;
- LaunchModel model = node.getModel();
- model.refresh();
- }
- if (callback != null) {
- callback.done(this, Status.OK_STATUS);
- }
- }
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/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 fa9f382..1ead882 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/handler/DeleteHandler.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/handler/DeleteHandler.java
@@ -15,8 +15,6 @@ 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;
@@ -25,11 +23,6 @@ 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.runtime.utils.StatusHelper;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.handlers.HandlerUtil;
@@ -50,12 +43,8 @@ public class DeleteHandler extends AbstractHandler {
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
+ // Loop over the selection and delete the elements providing
Iterator<?> iterator = ((IStructuredSelection)selection).iterator();
while (iterator.hasNext()) {
final Object element = iterator.next();
@@ -71,25 +60,22 @@ public class DeleteHandler extends AbstractHandler {
}
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);
- }
+ // Delete the element and refresh the tree
+ if (delete(element)) {
+ 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);
}
}
- });
- }
- });
+ }
+ });
+ }
}
}
}
@@ -97,9 +83,11 @@ public class DeleteHandler extends AbstractHandler {
return null;
}
- // ***** DeleteHandlerDelegate content. Clean up. *****
-
- @Deprecated
+ /**
+ * Check if an element can be deleted.
+ * @param element The element to check.
+ * @return
+ */
public boolean canDelete(Object element) {
if (element instanceof LaunchNode) {
LaunchNode node = (LaunchNode)element;
@@ -108,33 +96,22 @@ public class DeleteHandler extends AbstractHandler {
return false;
}
- @Deprecated
- public void delete(Object element, IPropertiesContainer state, final ICallback callback) {
+ private boolean delete(Object element) {
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()))) {
+ if (MessageDialog.openQuestion(
+ UIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(),
+ Messages.DeleteHandlerDelegate_question_title, NLS.bind(Messages.DeleteHandlerDelegate_question_message, node.getLaunchConfiguration().getName()))) {
+ try {
node.getLaunchConfiguration().delete();
- if (callback != null) {
- callback.done(this, Status.OK_STATUS);
- }
+ return true;
}
- else {
- if (callback != null) {
- callback.done(this, Status.CANCEL_STATUS);
- }
- }
- }
- catch (Exception e) {
- if (callback != null) {
- callback.done(this, StatusHelper.getStatus(e));
+ catch (Exception e) {
}
}
}
+ return false;
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/handler/RefreshHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/handler/RefreshHandler.java
new file mode 100644
index 0000000..e09c474
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/handler/RefreshHandler.java
@@ -0,0 +1,102 @@
+/*******************************************************************************
+ * 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.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.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.tcf.te.launch.ui.model.LaunchModel;
+import org.eclipse.tcf.te.launch.ui.model.LaunchNode;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.ui.navigator.CommonViewer;
+
+/**
+ * Refresh handler implementation.
+ */
+public class RefreshHandler 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);
+
+ // Loop over the selection and refresh the elements
+ Iterator<?> iterator = ((IStructuredSelection)selection).iterator();
+ while (iterator.hasNext()) {
+ final Object element = iterator.next();
+
+ // Refresh the element if there is a valid delegate
+ if (canRefresh(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;
+
+ // Refresh the element and the tree
+ if (refresh(element)) {
+ 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;
+ }
+
+ /**
+ * Check if an element can be refreshed.
+ * @param element The element to check.
+ * @return
+ */
+ public boolean canRefresh(Object element) {
+ if (element instanceof LaunchNode) {
+ return true;
+ }
+ return false;
+ }
+
+ private boolean refresh(Object element) {
+ Assert.isNotNull(element);
+
+ LaunchNode node = (LaunchNode) element;
+ LaunchModel model = node.getModel();
+ return model.refresh();
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/LaunchNavigatorContentProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/LaunchNavigatorContentProvider.java
index 1774177..2892baf 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/LaunchNavigatorContentProvider.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/viewer/LaunchNavigatorContentProvider.java
@@ -85,7 +85,7 @@ public class LaunchNavigatorContentProvider extends TreeContentProvider implemen
LaunchModel model = LaunchModel.getLaunchModel(element);
if (model != null) {
- if (isRootNodeVisible()) {
+ if (isRootNodeVisible() && model.getRootNode().hasChildren()) {
return new Object[]{model.getRootNode()};
}
return model.getRootNode().getChildren();
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/plugin.xml
index d56ca45..01bf04f 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/plugin.xml
@@ -140,4 +140,16 @@
</propertySections>
</extension>
+ <extension point="org.eclipse.ui.views.properties.tabbed.propertySections">
+ <propertySections contributorId="org.eclipse.ui.navigator.ProjectExplorer">
+ <propertySection
+ id="org.eclipse.tcf.te.tcf.launch.ui.project.propertytab.remote.app"
+ class="org.eclipse.tcf.te.tcf.launch.ui.remote.app.RemoteAppPropertiesSection"
+ enablesFor="1"
+ afterSection="org.eclipse.tcf.te.launch.ui.project.launchcontext"
+ filter="org.eclipse.tcf.te.tcf.launch.ui.remote.app.RemoteAppFilter"
+ tab="org.eclipse.tcf.te.launch.ui.project.propertytab.general">
+ </propertySection>
+ </propertySections>
+ </extension>
</plugin>