diff options
author | Tobias Schwarz | 2013-12-12 06:48:34 +0000 |
---|---|---|
committer | Tobias Schwarz | 2013-12-12 06:48:34 +0000 |
commit | 27e9596b045ba44cd4f5db7d4b310b9272135288 (patch) | |
tree | 38c00afca949d9fbff0b5d1d682604ad9e972ca4 /target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org | |
parent | fcc67d234b1665c188a07c53c2aa3779a76a95db (diff) | |
download | org.eclipse.tcf-27e9596b045ba44cd4f5db7d4b310b9272135288.tar.gz org.eclipse.tcf-27e9596b045ba44cd4f5db7d4b310b9272135288.tar.xz org.eclipse.tcf-27e9596b045ba44cd4f5db7d4b310b9272135288.zip |
Target Explorer: connect and model rework
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org')
17 files changed, 245 insertions, 507 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/activator/UIPlugin.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/activator/UIPlugin.java index 6e3894574..128fd7397 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/activator/UIPlugin.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/activator/UIPlugin.java @@ -17,7 +17,6 @@ import org.eclipse.core.runtime.Platform; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageRegistry; import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Display; import org.eclipse.tcf.protocol.Protocol; import org.eclipse.tcf.te.runtime.callback.AsyncCallbackCollector; import org.eclipse.tcf.te.runtime.concurrent.util.ExecutorsUtil; @@ -35,12 +34,9 @@ import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; import org.eclipse.tcf.te.tcf.locator.interfaces.services.IStepperServiceOperations; import org.eclipse.tcf.te.tcf.locator.model.Model; import org.eclipse.tcf.te.tcf.ui.internal.ImageConsts; -import org.eclipse.tcf.te.tcf.ui.listeners.WorkbenchWindowListener; import org.eclipse.tcf.te.ui.jface.images.AbstractImageDescriptor; -import org.eclipse.ui.IWindowListener; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchListener; -import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; @@ -57,10 +53,6 @@ public class UIPlugin extends AbstractUIPlugin { // Reference to the workbench listener /* default */ final ListenerList listeners = new ListenerList(); - - // The global window listener instance - private IWindowListener windowListener; - /** * Constructor. */ @@ -158,6 +150,7 @@ public class UIPlugin extends AbstractUIPlugin { data, stepGroupId, IStepperServiceOperations.DISCONNECT, + false, false); ICallback callback = new AsyncCallbackCollector.SimpleCollectorCallback(collector); @@ -201,38 +194,14 @@ public class UIPlugin extends AbstractUIPlugin { } }; PlatformUI.getWorkbench().addWorkbenchListener(listener); - - if (windowListener == null && PlatformUI.getWorkbench() != null) { - windowListener = new WorkbenchWindowListener(); - PlatformUI.getWorkbench().addWindowListener(windowListener); - activateContexts(); - } } - void activateContexts() { - if (Display.getCurrent() != null) { - IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (window != null && windowListener != null) windowListener.windowOpened(window); - } - else { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable(){ - @Override - public void run() { - activateContexts(); - }}); - } - } - /* (non-Javadoc) * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) */ @Override public void stop(BundleContext context) throws Exception { if (listener != null) { PlatformUI.getWorkbench().removeWorkbenchListener(listener); listener = null; } - if (windowListener != null && PlatformUI.getWorkbench() != null) { - PlatformUI.getWorkbench().removeWindowListener(windowListener); - windowListener = null; - } plugin = null; super.stop(context); @@ -277,6 +246,8 @@ public class UIPlugin extends AbstractUIPlugin { url = UIPlugin.getDefault().getBundle().getEntry(ImageConsts.IMAGE_DIR_ROOT + ImageConsts.IMAGE_DIR_ELCL + "newTarget_wiz.gif"); //$NON-NLS-1$ registry.put(ImageConsts.NEW_PEER, ImageDescriptor.createFromURL(url)); + url = UIPlugin.getDefault().getBundle().getEntry(ImageConsts.IMAGE_DIR_ROOT + ImageConsts.IMAGE_DIR_OVR + "busy.gif"); //$NON-NLS-1$ + registry.put(ImageConsts.BUSY_OVR, ImageDescriptor.createFromURL(url)); url = UIPlugin.getDefault().getBundle().getEntry(ImageConsts.IMAGE_DIR_ROOT + ImageConsts.IMAGE_DIR_OVR + "gold_ovr.gif"); //$NON-NLS-1$ registry.put(ImageConsts.GOLD_OVR, ImageDescriptor.createFromURL(url)); url = UIPlugin.getDefault().getBundle().getEntry(ImageConsts.IMAGE_DIR_ROOT + ImageConsts.IMAGE_DIR_OVR + "green_ovr.gif"); //$NON-NLS-1$ diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/PipeTransportPanel.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/PipeTransportPanel.java index a418c5438..25e97afdb 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/PipeTransportPanel.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/PipeTransportPanel.java @@ -32,7 +32,7 @@ import org.eclipse.tcf.te.ui.swt.SWTControlUtil; import org.eclipse.ui.forms.widgets.FormToolkit; /** - * Pipe transport type panel implementation. + * Pipe transport simulator panel implementation. */ public class PipeTransportPanel extends AbstractWizardConfigurationPanel implements IDataExchangeNode3 { diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/TransportTypePanelControl.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/TransportTypePanelControl.java index 4f9e41ebf..5bb42b1af 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/TransportTypePanelControl.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/TransportTypePanelControl.java @@ -13,7 +13,7 @@ import org.eclipse.jface.dialogs.IDialogPage; import org.eclipse.tcf.te.ui.controls.BaseWizardConfigurationPanelControl;
/**
- * Transport type wizard panel control.
+ * Transport simulator wizard panel control.
*/
public class TransportTypePanelControl extends BaseWizardConfigurationPanelControl {
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/controls/TransportSectionTypePanelControl.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/controls/TransportSectionTypePanelControl.java index c070c85ef..28ddb73e7 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/controls/TransportSectionTypePanelControl.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/controls/TransportSectionTypePanelControl.java @@ -18,7 +18,7 @@ import org.eclipse.tcf.te.ui.controls.interfaces.IWizardConfigurationPanel; import org.eclipse.tcf.te.ui.jface.interfaces.IValidatingContainer;
/**
- * Transport section transport type panel control implementation.
+ * Transport section transport simulator panel control implementation.
*/
public class TransportSectionTypePanelControl extends TransportTypePanelControl implements ModifyListener {
// Reference to the parent transport section
@@ -46,10 +46,10 @@ public class TransportSectionTypePanelControl extends TransportTypePanelControl TransportSectionTypeControl transportTypeControl = (TransportSectionTypeControl)transportSection.getAdapter(TransportSectionTypeControl.class);
if (transportTypeControl != null) {
- // Get the currently selected transport type
+ // Get the currently selected transport simulator
String transportType = transportTypeControl.getSelectedTransportType();
if (transportType != null) {
- // get the panel for the transport type and validate the panel
+ // get the panel for the transport simulator and validate the panel
IWizardConfigurationPanel panel = getConfigurationPanel(transportType);
if (panel != null) {
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/filter/UnreachablePeersFilter.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/filter/UnreachablePeersFilter.java index a11b7cb3c..fe6708ab3 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/filter/UnreachablePeersFilter.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/filter/UnreachablePeersFilter.java @@ -26,11 +26,11 @@ public class UnreachablePeersFilter extends ViewerFilter { @Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
- // Filter only elements of type IPeerModel
+ // Filter only elements of simulator IPeerModel
if (element instanceof IPeerModel) {
final IPeerModel peerModel = (IPeerModel)element;
- // Determine the current state of the peer model
+ // Determine the current action of the peer model
final int[] state = new int[1];
if (Protocol.isDispatchThread()) {
state[0] = peerModel.getIntProperty(IPeerModelProperties.PROP_STATE);
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/OfflineCommandHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/OfflineCommandHandler.java deleted file mode 100644 index 3baf14819..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/OfflineCommandHandler.java +++ /dev/null @@ -1,209 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2012, 2013 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.ui.handler; - -import java.io.IOException; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.concurrent.atomic.AtomicBoolean; - -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.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.osgi.util.NLS; -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.persistence.interfaces.IURIPersistenceService; -import org.eclipse.tcf.te.runtime.services.ServiceManager; -import org.eclipse.tcf.te.runtime.statushandler.StatusHandlerUtil; -import org.eclipse.tcf.te.tcf.core.peers.Peer; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelRefreshService; -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.Managers; -import org.eclipse.tcf.te.ui.views.interfaces.IUIConstants; -import org.eclipse.tcf.te.ui.views.interfaces.categories.ICategorizable; -import org.eclipse.ui.handlers.HandlerUtil; - -/** - * "Always available offline" command handler implementation. - */ -public class OfflineCommandHandler 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 - final ISelection selection = HandlerUtil.getCurrentSelection(event); - // Make the selection available offline - if (selection != null) makeAvailableOffline(selection, new Callback() { - @Override - protected void internalDone(Object caller, IStatus status) { - if (status.getSeverity() == IStatus.ERROR) { - StatusHandlerUtil.handleStatus(status, selection, null, - Messages.OfflineCommandHandler_error_title, IContextHelpIds.MESSAGE_MAKEOFFLINE_FAILED, OfflineCommandHandler.this, null); - } - - // Trigger a refresh of the model - Protocol.invokeLater(new Runnable() { - @Override - public void run() { - ILocatorModelRefreshService service = Model.getModel().getService(ILocatorModelRefreshService.class); - // Refresh the model now (must be executed within the TCF dispatch thread) - if (service != null) service.refresh(null); - } - }); - } - }); - - return null; - } - - /** - * Tests if the elements of the given selection can be made - * available offline. - * - * @param selection The selection. Must not be <code>null</code>. - * @return <code>True</code> if the elements can be made available offline, <code>false</code> otherwise. - */ - public boolean canMakeAvailableOffline(ISelection selection) { - Assert.isNotNull(selection); - - boolean enabled = false; - - // The selection must be a structured selection and must not be empty - if (selection instanceof IStructuredSelection && !selection.isEmpty()) { - // Assume the selection to be deletable - enabled = true; - // Iterate the selection. All elements must be of type IPeerModel - Iterator<?> iterator = ((IStructuredSelection)selection).iterator(); - while (iterator.hasNext()) { - Object element = iterator.next(); - if (!(element instanceof IPeerModel)) { - enabled = false; - break; - } - - // Determine if the selected peer model is static - boolean isStatic = isStatic((IPeerModel)element); - if (isStatic) enabled = false; - - if (!enabled) break; - } - } - - return enabled; - } - - /** - * Determines if the given peer model node is a static node. - * - * @param node The peer model node. Must not be <code>null</code>. - * @return <code>True</code> if the node is static, <code>false</code> otherwise. - */ - private boolean isStatic(final IPeerModel node) { - Assert.isNotNull(node); - - final AtomicBoolean isStatic = new AtomicBoolean(); - - Runnable runnable = new Runnable() { - @Override - public void run() { - isStatic.set(node.isStatic()); - } - }; - - if (Protocol.isDispatchThread()) runnable.run(); - else Protocol.invokeAndWait(runnable); - - return isStatic.get(); - } - - /** - * Creates an offline copy of the peer attributes. - * - * @param selection The selection. Must not be <code>null</code>. - * @param callback The callback. Must not be <code>null</code>. - */ - public void makeAvailableOffline(final ISelection selection, final ICallback callback) { - Assert.isNotNull(selection); - Assert.isNotNull(callback); - - Runnable runnable = new Runnable() { - @Override - public void run() { - // The status to report back - IStatus status = Status.OK_STATUS; - // The selection must be a structured selection and must not be empty - if (selection instanceof IStructuredSelection && !selection.isEmpty()) { - // Iterate the selection. All elements must be of type IPeerModel - Iterator<?> iterator = ((IStructuredSelection)selection).iterator(); - while (iterator.hasNext()) { - Object element = iterator.next(); - Assert.isTrue(element instanceof IPeerModel); - IPeerModel node = (IPeerModel)element; - - // Copy the peer attributes - Map<String, String> attrs = new HashMap<String, String>(); - attrs.putAll(node.getPeer().getAttributes()); - - // Remove attributes filled in by the discovery - attrs.remove(IPeer.ATTR_AGENT_ID); - attrs.remove(IPeer.ATTR_SERVICE_MANGER_ID); - attrs.remove("ServerManagerID"); //$NON-NLS-1$ - attrs.remove(IPeer.ATTR_USER_NAME); - attrs.remove(IPeer.ATTR_OS_NAME); - - // Persist the attributes - try { - IURIPersistenceService service = ServiceManager.getInstance().getService(IURIPersistenceService.class); - if (service == null) { - throw new IOException("Persistence service instance unavailable."); //$NON-NLS-1$ - } - service.write(new Peer(attrs), null); - - // Remove the node from the "Neighborhood" category - ICategorizable categorizable = (ICategorizable)node.getAdapter(ICategorizable.class); - if (categorizable == null) categorizable = (ICategorizable)Platform.getAdapterManager().getAdapter(node, ICategorizable.class); - Assert.isNotNull(categorizable); - - Managers.getCategoryManager().remove(IUIConstants.ID_CAT_NEIGHBORHOOD, categorizable.getId()); - } catch (IOException e) { - status = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(), - NLS.bind(Messages.OfflineCommandHandler_error_makeOffline_failed, node.getName(), e.getLocalizedMessage()), e); - } - - if (status != null) break; - } - } - - // Invoke the callback - callback.done(OfflineCommandHandler.this, status); - } - }; - - Protocol.invokeLater(runnable); - } -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/ImageConsts.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/ImageConsts.java index d5a2972bd..f54e992ec 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/ImageConsts.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/ImageConsts.java @@ -81,6 +81,11 @@ public interface ImageConsts { public static final String NEW_PEER = "NewPeerObject"; //$NON-NLS-1$ /** + * The key to access the peer object busy overlay image. + */ + public static final String BUSY_OVR = "BusyOverlay"; //$NON-NLS-1$ + + /** * The key to access the peer object gold overlay image. */ public static final String GOLD_OVR = "GoldOverlay"; //$NON-NLS-1$ diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/PropertyTester.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/PropertyTester.java index 627c79560..072d2142f 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/PropertyTester.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/PropertyTester.java @@ -14,7 +14,6 @@ import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; import org.eclipse.tcf.te.tcf.locator.utils.SimulatorUtils; import org.eclipse.tcf.te.tcf.ui.handler.DeleteHandler; -import org.eclipse.tcf.te.tcf.ui.handler.OfflineCommandHandler; import org.eclipse.tcf.te.ui.views.navigator.nodes.NewWizardNode; @@ -25,8 +24,6 @@ import org.eclipse.tcf.te.ui.views.navigator.nodes.NewWizardNode; public class PropertyTester extends org.eclipse.core.expressions.PropertyTester { // Reference to the peer model delete handler (to determine "canDelete") private final DeleteHandler deleteHandler = new DeleteHandler(); - // Reference to the peer model offline handler (to determine "canMakeAvailableOffline") - private final OfflineCommandHandler offlineHandler = new OfflineCommandHandler(); /* (non-Javadoc) * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object) @@ -69,10 +66,6 @@ public class PropertyTester extends org.eclipse.core.expressions.PropertyTester return deleteHandler.canDelete(selection); } - if ("canMakeAvailableOffline".equals(property)) { //$NON-NLS-1$ - return offlineHandler.canMakeAvailableOffline(selection); - } - return false; } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/listeners/WorkbenchPartListener.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/listeners/WorkbenchPartListener.java deleted file mode 100644 index 6348635ae..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/listeners/WorkbenchPartListener.java +++ /dev/null @@ -1,96 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011, 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.ui.listeners; - -import org.eclipse.core.runtime.Platform; -import org.eclipse.tcf.te.runtime.services.ServiceManager; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.services.IDefaultContextService; -import org.eclipse.tcf.te.ui.views.interfaces.IUIConstants; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IEditorReference; -import org.eclipse.ui.IPartListener2; -import org.eclipse.ui.IWorkbenchPartReference; - -/** - * The part listener implementation. Takes care of - * activation and deactivation of key binding contexts. - */ -public class WorkbenchPartListener implements IPartListener2 { - - /* (non-Javadoc) - * @see org.eclipse.ui.IPartListener2#partBroughtToTop(org.eclipse.ui.IWorkbenchPartReference) - */ - @Override - public void partBroughtToTop(IWorkbenchPartReference partRef) { - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IPartListener2#partOpened(org.eclipse.ui.IWorkbenchPartReference) - */ - @Override - public void partOpened(IWorkbenchPartReference partRef) { - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IPartListener2#partClosed(org.eclipse.ui.IWorkbenchPartReference) - */ - @Override - public void partClosed(IWorkbenchPartReference partRef) { - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IPartListener2#partVisible(org.eclipse.ui.IWorkbenchPartReference) - */ - @Override - public void partVisible(IWorkbenchPartReference partRef) { - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IPartListener2#partHidden(org.eclipse.ui.IWorkbenchPartReference) - */ - @Override - public void partHidden(IWorkbenchPartReference partRef) { - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IPartListener2#partActivated(org.eclipse.ui.IWorkbenchPartReference) - */ - @Override - public void partActivated(IWorkbenchPartReference partRef) { - if (IUIConstants.ID_EDITOR.equals(partRef.getId())) { - if (partRef instanceof IEditorReference) { - IEditorPart part = (IEditorPart)partRef.getPart(false); - if (part != null) { - IPeerModel peerModel = (IPeerModel)Platform.getAdapterManager().getAdapter(part.getEditorInput(), IPeerModel.class); - if (peerModel != null) { - IDefaultContextService service = ServiceManager.getInstance().getService(IDefaultContextService.class); - if (service != null) service.setDefaultContext(peerModel); - } - } - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IPartListener2#partDeactivated(org.eclipse.ui.IWorkbenchPartReference) - */ - @Override - public void partDeactivated(IWorkbenchPartReference partRef) { - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IPartListener2#partInputChanged(org.eclipse.ui.IWorkbenchPartReference) - */ - @Override - public void partInputChanged(IWorkbenchPartReference partRef) { - } - -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/listeners/WorkbenchWindowListener.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/listeners/WorkbenchWindowListener.java deleted file mode 100644 index 06d8b97d4..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/listeners/WorkbenchWindowListener.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2011, 2013 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.ui.listeners; - -import org.eclipse.tcf.te.ui.views.listeners.AbstractWindowListener; -import org.eclipse.ui.IPartListener2; - -/** - * The window listener implementation. Takes care of the - * management of the global listeners per workbench window. - */ -public class WorkbenchWindowListener extends AbstractWindowListener { - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.ui.views.listeners.AbstractWindowListener#createPartListener() - */ - @Override - protected IPartListener2 createPartListener() { - return new WorkbenchPartListener(); - } -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/PeerLabelProviderDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/PeerLabelProviderDelegate.java index ad8643c6a..8ca09120c 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/PeerLabelProviderDelegate.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/PeerLabelProviderDelegate.java @@ -23,7 +23,6 @@ import org.eclipse.tcf.protocol.Protocol; import org.eclipse.tcf.te.runtime.services.interfaces.delegates.ILabelProviderDelegate; import org.eclipse.tcf.te.runtime.utils.net.IPAddressUtil; import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties; import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelLookupService; import org.eclipse.tcf.te.tcf.locator.model.Model; import org.eclipse.tcf.te.tcf.ui.activator.UIPlugin; @@ -181,7 +180,7 @@ public class PeerLabelProviderDelegate extends LabelProvider implements ILabelDe public Image decorateImage(Image image, Object element) { Image decoratedImage = image; - if (image != null && element instanceof IPeerModel && !((IPeerModel)element).isStatic()) { + if (image != null && element instanceof IPeerModel) { AbstractImageDescriptor descriptor = new PeerImageDescriptor( UIPlugin.getDefault().getImageRegistry(), image, @@ -197,38 +196,21 @@ public class PeerLabelProviderDelegate extends LabelProvider implements ILabelDe */ @Override public String decorateText(final String text, final Object element) { - String label = text; - - if (element instanceof IPeerModel) { - final StringBuilder builder = new StringBuilder(label != null && !"".equals(label.trim()) ? label.trim() : "<noname>"); //$NON-NLS-1$ //$NON-NLS-2$ - - Runnable runnable = new Runnable() { - @Override - public void run() { - boolean isStatic = ((IPeerModel)element).isStatic(); - - int state = ((IPeerModel)element).getIntProperty(IPeerModelProperties.PROP_STATE); - if (state > IPeerModelProperties.STATE_UNKNOWN - && (!isStatic - || state == IPeerModelProperties.STATE_REACHABLE - || state == IPeerModelProperties.STATE_CONNECTED - || state == IPeerModelProperties.STATE_WAITING_FOR_READY)) { - builder.append(" ["); //$NON-NLS-1$ - builder.append(Messages.getString("LabelProviderDelegate_state_" + state)); //$NON-NLS-1$ - builder.append("]"); //$NON-NLS-1$ - } - } - }; - - if (Protocol.isDispatchThread()) runnable.run(); - else Protocol.invokeAndWait(runnable); - - label = builder.toString(); - - if (!"".equals(label.trim()) && !"<noname>".equals(label.trim())) { //$NON-NLS-1$ //$NON-NLS-2$ - return label; - } - } +// String label = text; +// +// if (element instanceof IConnectable) { +// final StringBuilder builder = new StringBuilder(label != null && !"".equals(label.trim()) ? label.trim() : "<noname>"); //$NON-NLS-1$ //$NON-NLS-2$ +// +// builder.append(" ["); //$NON-NLS-1$ +// builder.append(ConnectStateHelper.getConnectState(((IConnectable)element).getConnectState())); +// builder.append("]"); //$NON-NLS-1$ +// +// label = builder.toString(); +// +// if (!"".equals(label.trim()) && !"<noname>".equals(label.trim())) { //$NON-NLS-1$ //$NON-NLS-2$ +// return label; +// } +// } return null; } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/images/PeerImageDescriptor.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/images/PeerImageDescriptor.java index b9762a4e8..9264647d0 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/images/PeerImageDescriptor.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/navigator/images/PeerImageDescriptor.java @@ -14,8 +14,8 @@ import org.eclipse.jface.resource.ImageRegistry; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Point; import org.eclipse.tcf.protocol.Protocol; +import org.eclipse.tcf.te.core.interfaces.IConnectable; import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties; import org.eclipse.tcf.te.tcf.ui.internal.ImageConsts; import org.eclipse.tcf.te.ui.jface.images.AbstractImageDescriptor; @@ -29,8 +29,8 @@ public class PeerImageDescriptor extends AbstractImageDescriptor { // the image size private Point imageSize; - // Flags representing the object states to decorate - private int state; + // Flags representing the connect states to decorate + private int connectState; /** * Constructor. @@ -66,7 +66,7 @@ public class PeerImageDescriptor extends AbstractImageDescriptor { Assert.isNotNull(node); Assert.isTrue(Protocol.isDispatchThread()); - state = node.getIntProperty(IPeerModelProperties.PROP_STATE); + connectState = node instanceof IConnectable ? ((IConnectable)node).getConnectState() : IConnectable.STATE_UNKNOWN; } /** @@ -77,7 +77,7 @@ public class PeerImageDescriptor extends AbstractImageDescriptor { protected void defineKey(int hashCode) { String key = "PMID:" + //$NON-NLS-1$ hashCode + ":" + //$NON-NLS-1$ - state; + connectState; setDecriptorKey(key); } @@ -89,11 +89,15 @@ public class PeerImageDescriptor extends AbstractImageDescriptor { protected void drawCompositeImage(int width, int height) { drawCentered(baseImage, width, height); - if (state == IPeerModelProperties.STATE_NOT_REACHABLE) { /* not connected, not reachable */ - drawBottomRight(ImageConsts.RED_OVR); + if (connectState < 0) { + drawTopRight(ImageConsts.BUSY_OVR); } - else if (state == IPeerModelProperties.STATE_ERROR) { /* not connected, error */ - drawBottomRight(ImageConsts.RED_X_OVR); + + if (connectState == IConnectable.STATE_CONNECTED) { + drawBottomRight(ImageConsts.GREEN_OVR); + } + else if (connectState == IConnectable.STATE_CONNECTING || connectState == IConnectable.STATE_DISCONNECTING) { + drawBottomRight(ImageConsts.GREY_OVR); } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.java index 714dc533c..d473cfca1 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.java @@ -192,8 +192,8 @@ public class Messages extends NLS { public static String AbstractConfigWizardPage_configName_infoMissingValue; public static String AbstractConfigWizardPage_configName_nameInUse; public static String AbstractConfigWizardPage_launchDbg_label; + public static String AbstractConfigWizardPage_connect_label; public static String AbstractConfigWizardPage_advancedButton_label; - public static String AbstractConfigWizardPage_connectJob_label; public static String ToolbarAction_selectPeer; public static String ToolbarAction_selectionDialog_title; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.properties index 2687838d5..1b96b383f 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.properties +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.properties @@ -135,7 +135,7 @@ RenameHandler_dialog_error_nameExist=A target with the name you specified alread RenameHandler_dialog_promptNewName=New Name: TargetSelectorSection_title=Target -TargetSelectorSection_button_enableReal=Use running Target +TargetSelectorSection_button_enableReal=Use running Target: TargetSelectorSection_button_enableSimulator=Start local Simulator: SimulatorTypeSelectionControl_label=Simulator Type: @@ -143,14 +143,14 @@ SimulatorTypeSelectionControl_button_configure=Configure... SimulatorTypeSelectionControl_error_invalidConfiguration=The simulator configuration is not valid. Please click on ''Configure...'' to configure the simulator. AbstractConfigurationEditorPage_error_possibleCause=Possible Cause:\n{0} -AbstractConfigurationEditorPage_error_save=Failed to save connection: {0}.\n\n{1} +AbstractConfigurationEditorPage_error_save=Failed to save configuration: {0}.\n\n{1} -AbstractConfigWizardPage_configName_label=Connection Name: -AbstractConfigWizardPage_configName_infoMissingValue=Please enter a connection name. -AbstractConfigWizardPage_configName_nameInUse=This connection name is already used. Please choose a unique name. -AbstractConfigWizardPage_launchDbg_label=Start debugger after connection has been established +AbstractConfigWizardPage_configName_label=Configuration Name: +AbstractConfigWizardPage_configName_infoMissingValue=Please enter a configuration name. +AbstractConfigWizardPage_configName_nameInUse=This configuration name is already used. Please choose a unique name. +AbstractConfigWizardPage_connect_label=Connect configuration on finish +AbstractConfigWizardPage_launchDbg_label=Start debugger after configuration has been established AbstractConfigWizardPage_advancedButton_label=Advanced... -AbstractConfigWizardPage_connectJob_label=Connect ''{0}'' ToolbarAction_selectPeer=Select Existing Target... ToolbarAction_selectionDialog_title=Select Existing Target diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/sections/SimulatorTypeSelectionSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/sections/SimulatorTypeSelectionSection.java index bc9229bb0..44e43bc68 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/sections/SimulatorTypeSelectionSection.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/sections/SimulatorTypeSelectionSection.java @@ -11,34 +11,41 @@ package org.eclipse.tcf.te.tcf.ui.sections; import java.util.HashMap; import java.util.Map; +import java.util.concurrent.atomic.AtomicBoolean; import org.eclipse.core.runtime.Assert; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerFilter; +import org.eclipse.jface.window.Window; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.TypedEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.tcf.core.TransientPeer; import org.eclipse.tcf.protocol.IPeer; import org.eclipse.tcf.protocol.Protocol; +import org.eclipse.tcf.te.core.interfaces.IConnectable; import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; import org.eclipse.tcf.te.runtime.properties.PropertiesContainer; -import org.eclipse.tcf.te.runtime.services.interfaces.ISimulatorService; import org.eclipse.tcf.te.tcf.core.peers.Peer; import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties; import org.eclipse.tcf.te.tcf.locator.nodes.PeerRedirector; -import org.eclipse.tcf.te.tcf.locator.utils.SimulatorUtils; import org.eclipse.tcf.te.tcf.ui.controls.SimulatorTypeSelectionControl; +import org.eclipse.tcf.te.tcf.ui.dialogs.AgentSelectionDialog; import org.eclipse.tcf.te.tcf.ui.nls.Messages; +import org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl; import org.eclipse.tcf.te.ui.forms.parts.AbstractSection; import org.eclipse.tcf.te.ui.interfaces.data.IDataExchangeNode; import org.eclipse.tcf.te.ui.jface.interfaces.IValidatingContainer; import org.eclipse.tcf.te.ui.swt.SWTControlUtil; import org.eclipse.tcf.te.ui.views.editor.pages.AbstractEditorPage; +import org.eclipse.tcf.te.ui.views.navigator.ViewerSorter; import org.eclipse.ui.forms.IManagedForm; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.Section; @@ -48,8 +55,8 @@ import org.eclipse.ui.forms.widgets.Section; */ public class SimulatorTypeSelectionSection extends AbstractSection implements IDataExchangeNode { // The section sub controls - /* default */ Button real; - /* default */ SimulatorTypeSelectionControl type; + /* default */ BaseEditBrowseTextControl target; + /* default */ SimulatorTypeSelectionControl simulator; // Reference to the original data object /* default */ IPeerModel od; @@ -61,6 +68,8 @@ public class SimulatorTypeSelectionSection extends AbstractSection implements ID protected static final int SELECTION_REAL = 0; protected static final int SELECTION_SIM = 1; + protected IPeerModel selectedTarget = null; + /** * Constructor. * @@ -97,7 +106,7 @@ public class SimulatorTypeSelectionSection extends AbstractSection implements ID */ @Override public void dispose() { - if (type != null) { type.dispose(); type = null; } + if (simulator != null) { simulator.dispose(); simulator = null; } super.dispose(); } @@ -129,30 +138,91 @@ public class SimulatorTypeSelectionSection extends AbstractSection implements ID Assert.isNotNull(client); section.setClient(client); - real = toolkit.createButton(client, Messages.TargetSelectorSection_button_enableReal, SWT.RADIO); - GridData gd = new GridData(SWT.BEGINNING, SWT.CENTER, false, false); - gd.horizontalSpan = 3; - real.setSelection(true); - real.setLayoutData(gd); - real.setBackground(client.getBackground()); - real.addSelectionListener(new SelectionAdapter() { + target = new BaseEditBrowseTextControl(null) { + /* (non-Javadoc) + * @see org.eclipse.tcf.te.ui.controls.BaseDialogPageControl#getValidatingContainer() + */ @Override - public void widgetSelected(SelectionEvent e) { - if (real.getSelection()) { + public IValidatingContainer getValidatingContainer() { + return SimulatorTypeSelectionSection.this.getValidatingContainer(); + } + @SuppressWarnings("synthetic-access") + @Override + protected void onLabelControlSelectedChanged() { + super.onLabelControlSelectedChanged(); + if (target.isLabelControlSelected()) { onSelectionChanged(SELECTION_REAL); + if (!isUpdating()) { + onTargetChanged(false, true, selectedTarget, selectedTarget); + } } - // validate the page - getValidatingContainer().validate(); - dataChanged(null); } - }); + @Override + protected void onButtonControlSelected() { + AgentSelectionDialog dialog = new AgentSelectionDialog(null) { + @Override + protected boolean supportsMultiSelection() { + return false; + } + @Override + protected void configureTableViewer(TableViewer viewer) { + viewer.addFilter(new ViewerFilter() { + @Override + public boolean select(Viewer viewer, Object parentElement, final Object element) { + if (element instanceof IPeerModel && !(element instanceof IConnectable)) { + final IPeer peer = ((IPeerModel)element).getPeer(); + final AtomicBoolean isValueAdd = new AtomicBoolean(); + final AtomicBoolean isCLI = new AtomicBoolean(); + Protocol.invokeAndWait(new Runnable() { + @Override + public void run() { + String value = peer.getAttributes().get("ValueAdd"); //$NON-NLS-1$ + isValueAdd.set(value != null && ("1".equals(value.trim()) || Boolean.parseBoolean(value.trim()))); //$NON-NLS-1$ + isCLI.set(peer.getName() != null + && (peer.getName().startsWith("Eclipse CLI") //$NON-NLS-1$ + || peer.getName().startsWith("Eclipse Command Server") //$NON-NLS-1$ + || peer.getName().endsWith("CLI Server") //$NON-NLS-1$ + || peer.getName().endsWith("CLI Client"))); //$NON-NLS-1$ + } + }); + return !isValueAdd.get() && !isCLI.get(); + } + return false; + } + }); + viewer.setSorter(new ViewerSorter()); + } + }; + + // Open the dialog + if (dialog.open() == Window.OK) { + // Get the selected proxy from the dialog + ISelection selection = dialog.getSelection(); + if (selection instanceof IStructuredSelection && !selection.isEmpty() && ((IStructuredSelection)selection).getFirstElement() instanceof IPeerModel) { + IPeerModel oldPeerModel = selectedTarget; + selectedTarget = (IPeerModel)((IStructuredSelection)selection).getFirstElement(); + setEditFieldControlText(selectedTarget.getName()); + onTargetChanged(isLabelControlSelected(), isLabelControlSelected(), oldPeerModel, selectedTarget); + } + } - type = new SimulatorTypeSelectionControl(this) { + } + }; + target.setLabelIsButton(true); + target.setLabelButtonStyle(SWT.RADIO); + target.setParentControlIsInnerPanel(true); + target.setEditFieldLabel(Messages.TargetSelectorSection_button_enableReal); + target.setHasHistory(false); + target.setHideEditFieldControl(true); + target.setReadOnly(true); + target.setupPanel(client); + + simulator = new SimulatorTypeSelectionControl(this) { @SuppressWarnings("synthetic-access") @Override protected void onLabelControlSelectedChanged() { super.onLabelControlSelectedChanged(); - if (type.isLabelControlSelected()) { + if (simulator.isLabelControlSelected()) { onSelectionChanged(SELECTION_SIM); if (!isUpdating()) { onSimulatorChanged(false, true, getSelectedSimulatorId(), getSelectedSimulatorId(), getSimulatorConfig(), getSimulatorConfig()); @@ -175,11 +245,11 @@ public class SimulatorTypeSelectionSection extends AbstractSection implements ID } } }; - type.setLabelIsButton(true); - type.setLabelButtonStyle(SWT.RADIO); - type.setEditFieldLabel(Messages.TargetSelectorSection_button_enableSimulator); - type.setParentControlIsInnerPanel(true); - type.setupPanel(client); + simulator.setLabelIsButton(true); + simulator.setLabelButtonStyle(SWT.RADIO); + simulator.setEditFieldLabel(Messages.TargetSelectorSection_button_enableSimulator); + simulator.setParentControlIsInnerPanel(true); + simulator.setupPanel(client); // Adjust the control enablement updateEnablement(); @@ -190,18 +260,18 @@ public class SimulatorTypeSelectionSection extends AbstractSection implements ID /** * Called on radio button selection changed. - * @param selectionType The new selected type. + * @param selectionType The new selected simulator. */ protected void onSelectionChanged(int selectionType) { } /** - * Called on simulator enabled, simulator type or simulator configuration changed. + * Called on simulator enabled, simulator simulator or simulator configuration changed. * - * @param oldEnabled The old simulator enabled state. - * @param newEnabled The simulator enabled state. - * @param oldType The old selected simulator type. - * @param newType The selected simulator type. + * @param oldEnabled The old simulator enabled action. + * @param newEnabled The new simulator enabled action. + * @param oldType The old selected simulator simulator. + * @param newType The selected simulator simulator. * @param oldConfig The old simulator configuration. * @param newConfig The new simulator configuration. */ @@ -209,6 +279,17 @@ public class SimulatorTypeSelectionSection extends AbstractSection implements ID } /** + * Called on target enabled and selected peer model changed. + * + * @param oldEnabled The old target enabled action. + * @param newEnabled The new target enabled action. + * @param oldPeerModel The new selected peer model. + * @param newPeerModel The old selected peer model. + */ + protected void onTargetChanged(boolean oldEnabled, boolean newEnabled, IPeerModel oldPeerModel, IPeerModel newPeerModel) { + } + + /** * Indicates whether the sections parent page has become the active in the editor. * * @param active <code>True</code> if the parent page should be visible, <code>false</code> otherwise. @@ -217,7 +298,7 @@ public class SimulatorTypeSelectionSection extends AbstractSection implements ID // If the parent page has become the active and it does not contain // unsaved data, than fill in the data from the selected node if (active) { - // Leave everything unchanged if the page is in dirty state + // Leave everything unchanged if the page is in dirty action if (getManagedForm().getContainer() instanceof AbstractEditorPage && !((AbstractEditorPage)getManagedForm().getContainer()).isDirty()) { Object node = ((AbstractEditorPage)getManagedForm().getContainer()).getEditorInputNode(); @@ -226,7 +307,7 @@ public class SimulatorTypeSelectionSection extends AbstractSection implements ID } } } else { - // Evaluate the dirty state even if going inactive + // Evaluate the dirty action even if going inactive dataChanged(null); } } @@ -239,21 +320,23 @@ public class SimulatorTypeSelectionSection extends AbstractSection implements ID // Mark the control update as in-progress now setIsUpdating(true); - // Initialize the simulator type selection control - if (type != null) { - type.initialize(od); - type.setSelectedSimulatorId(data.getStringProperty(IPeerModelProperties.PROP_SIM_TYPE)); - type.setSimulatorConfig(data.getStringProperty(IPeerModelProperties.PROP_SIM_PROPERTIES)); - type.setLabelControlSelection(data.getBooleanProperty(IPeerModelProperties.PROP_SIM_ENABLED)); + // Initialize the simulator simulator selection control + if (simulator != null) { + simulator.initialize(od); + simulator.setSelectedSimulatorId(data.getStringProperty(IPeerModelProperties.PROP_SIM_TYPE)); + simulator.setSimulatorConfig(data.getStringProperty(IPeerModelProperties.PROP_SIM_PROPERTIES)); + simulator.setLabelControlSelection(data.getBooleanProperty(IPeerModelProperties.PROP_SIM_ENABLED)); } - SWTControlUtil.setSelection(real, !data.getBooleanProperty(IPeerModelProperties.PROP_SIM_ENABLED)); + if (target != null) { + target.setLabelControlSelection(!data.getBooleanProperty(IPeerModelProperties.PROP_SIM_ENABLED)); + } onSelectionChanged(data.getBooleanProperty(IPeerModelProperties.PROP_SIM_ENABLED) ? SELECTION_SIM : SELECTION_REAL); // Mark the control update as completed now setIsUpdating(false); - // Re-evaluate the dirty state + // Re-evaluate the dirty action dataChanged(null); } @@ -325,7 +408,7 @@ public class SimulatorTypeSelectionSection extends AbstractSection implements ID setupData(wc); } else { - // Re-evaluate the dirty state + // Re-evaluate the dirty action dataChanged(null); } } @@ -338,10 +421,15 @@ public class SimulatorTypeSelectionSection extends AbstractSection implements ID Assert.isNotNull(data); // Extract the widget data into the working copy - if (type != null) { - data.setProperty(IPeerModelProperties.PROP_SIM_ENABLED, type.isLabelControlSelected()); - data.setProperty(IPeerModelProperties.PROP_SIM_TYPE, type.getSelectedSimulatorId()); - data.setProperty(IPeerModelProperties.PROP_SIM_PROPERTIES, type.getSimulatorConfig()); + if (target != null) { + data.setProperty(IPeerModelProperties.PROP_SIM_ENABLED, false); + data.setProperty(IPeerModelProperties.PROP_TARGET, target.getEditFieldControlText()); + } + + if (simulator != null) { + data.setProperty(IPeerModelProperties.PROP_SIM_ENABLED, simulator.isLabelControlSelected()); + data.setProperty(IPeerModelProperties.PROP_SIM_TYPE, simulator.getSelectedSimulatorId()); + data.setProperty(IPeerModelProperties.PROP_SIM_PROPERTIES, simulator.getSimulatorConfig()); } } @@ -425,10 +513,10 @@ public class SimulatorTypeSelectionSection extends AbstractSection implements ID boolean valid = super.isValid(); - if (type != null && type.isLabelControlSelected()) { - valid &= type.isValid(); - if (type.getMessageType() > getMessageType()) { - setMessage(type.getMessage(), type.getMessageType()); + if (simulator != null && simulator.isLabelControlSelected()) { + valid &= simulator.isValid(); + if (simulator.getMessageType() > getMessageType()) { + setMessage(simulator.getMessage(), simulator.getMessageType()); } } @@ -440,9 +528,9 @@ public class SimulatorTypeSelectionSection extends AbstractSection implements ID */ @Override public void commit(boolean onSave) { - // Remember the current dirty state + // Remember the current dirty action boolean needsSaving = isDirty(); - // Call the super implementation (resets the dirty state) + // Call the super implementation (resets the dirty action) super.commit(onSave); // Nothing to do if not on save or saving is not needed @@ -468,12 +556,12 @@ public class SimulatorTypeSelectionSection extends AbstractSection implements ID boolean isDirty = false; // Compare the data - if (type != null) { + if (simulator != null) { boolean oldEnabled = odc.getBooleanProperty(IPeerModelProperties.PROP_SIM_ENABLED); - isDirty |= (oldEnabled != type.isLabelControlSelected()); + isDirty |= (oldEnabled != simulator.isLabelControlSelected()); - if (type.isLabelControlSelected()) { - String newType = type.getSelectedSimulatorId(); + if (simulator.isLabelControlSelected()) { + String newType = simulator.getSelectedSimulatorId(); String oldType = odc.getStringProperty(IPeerModelProperties.PROP_SIM_TYPE); if (newType == null || "".equals(newType)) { //$NON-NLS-1$ isDirty |= oldType != null && !"".equals(oldType); //$NON-NLS-1$ @@ -481,7 +569,7 @@ public class SimulatorTypeSelectionSection extends AbstractSection implements ID isDirty |= !newType.equals(oldType); } - String newConfig = type.getSimulatorConfig(); + String newConfig = simulator.getSimulatorConfig(); String oldConfig = odc.getStringProperty(IPeerModelProperties.PROP_SIM_PROPERTIES); if (newConfig == null || "".equals(newConfig)) { //$NON-NLS-1$ isDirty |= oldConfig != null && !"".equals(oldConfig); //$NON-NLS-1$ @@ -507,7 +595,7 @@ public class SimulatorTypeSelectionSection extends AbstractSection implements ID @Override public Object getAdapter(Class adapter) { if (SimulatorTypeSelectionControl.class.equals(adapter)) { - return type; + return simulator; } return super.getAdapter(adapter); } @@ -516,13 +604,14 @@ public class SimulatorTypeSelectionSection extends AbstractSection implements ID * Updates the control enablement. */ protected void updateEnablement() { - SimulatorUtils.Result simulator = od != null ? SimulatorUtils.getSimulatorService(od) : null; - - boolean enabled = simulator == null || simulator.service.getState(od, simulator.settings) == ISimulatorService.State.Stopped; - SWTControlUtil.setEnabled(real, enabled); + boolean enabled = od instanceof IConnectable && ((IConnectable)od).getConnectState() == IConnectable.STATE_DISCONNECTED; - if (type != null) { - SWTControlUtil.setEnabled(type.getEditFieldControl(), type.isLabelControlSelected() && enabled); + if (target != null) { + SWTControlUtil.setEnabled(target.getEditFieldControl(), target.isLabelControlSelected() && enabled); + SWTControlUtil.setEnabled(target.getButtonControl(), target.isLabelControlSelected() && enabled); + } + if (simulator != null) { + SWTControlUtil.setEnabled(simulator.getEditFieldControl(), simulator.isLabelControlSelected() && enabled); } } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/AbstractConfigWizard.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/AbstractConfigWizard.java index 42ed0dac5..4d4fd155f 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/AbstractConfigWizard.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/AbstractConfigWizard.java @@ -79,30 +79,30 @@ public abstract class AbstractConfigWizard extends NewTargetWizard { // If auto-connect is switched off, we are done here. if (!autoConnect) return; - // Attach the debugger - final AtomicBoolean attachDebugger = new AtomicBoolean(); + // Connect and Attach the debugger + final AtomicBoolean connect = new AtomicBoolean(); Protocol.invokeAndWait(new Runnable() { @Override public void run() { - attachDebugger.set(Boolean.parseBoolean(peerModel.getPeer().getAttributes().get(IPeerModelProperties.PROP_AUTO_START_DEBUGGER))); + connect.set(Boolean.parseBoolean(peerModel.getPeer().getAttributes().get(IPeerModelProperties.PROP_AUTO_CONNECT))); } }); - if (attachDebugger.get()) { + if (connect.get()) { IService[] services = ServiceManager.getInstance().getServices(peerModel, IStepperOperationService.class, false); IStepperOperationService stepperOperationService = null; for (IService service : services) { - if (service instanceof IStepperOperationService && ((IStepperOperationService)service).isHandledOperation(peerModel, IStepperServiceOperations.ATTACH_DEBUGGER)) { + if (service instanceof IStepperOperationService && ((IStepperOperationService)service).isHandledOperation(peerModel, IStepperServiceOperations.CONNECT)) { stepperOperationService = (IStepperOperationService)service; break; } } if (stepperOperationService != null) { - String stepGroupId = stepperOperationService.getStepGroupId(peerModel, IStepperServiceOperations.ATTACH_DEBUGGER); - IStepContext stepContext = stepperOperationService.getStepContext(peerModel, IStepperServiceOperations.ATTACH_DEBUGGER); - String name = stepperOperationService.getStepGroupName(peerModel, IStepperServiceOperations.ATTACH_DEBUGGER); - IPropertiesContainer data = stepperOperationService.getStepData(peerModel, IStepperServiceOperations.ATTACH_DEBUGGER); - boolean enabled = stepperOperationService.isEnabled(peerModel, IStepperServiceOperations.ATTACH_DEBUGGER); + String stepGroupId = stepperOperationService.getStepGroupId(peerModel, IStepperServiceOperations.CONNECT); + IStepContext stepContext = stepperOperationService.getStepContext(peerModel, IStepperServiceOperations.CONNECT); + String name = stepperOperationService.getStepGroupName(peerModel, IStepperServiceOperations.CONNECT); + IPropertiesContainer data = stepperOperationService.getStepData(peerModel, IStepperServiceOperations.CONNECT); + boolean enabled = stepperOperationService.isEnabled(peerModel, IStepperServiceOperations.CONNECT); if (enabled && stepGroupId != null && stepContext != null) { try { @@ -110,7 +110,8 @@ public abstract class AbstractConfigWizard extends NewTargetWizard { stepContext, data, stepGroupId, - IStepperServiceOperations.ATTACH_DEBUGGER, + IStepperServiceOperations.CONNECT, + true, true); job.schedule(); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/AbstractConfigWizardPage.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/AbstractConfigWizardPage.java index b201c8ee6..4a5bf06cb 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/AbstractConfigWizardPage.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/AbstractConfigWizardPage.java @@ -48,8 +48,10 @@ public abstract class AbstractConfigWizardPage extends AbstractFormsWizardPage i private AbstractSection selectorSection = null; private AbstractSection detailsSection = null; /* default */ Button launchDbg = null; + /* default */ Button connect = null; private Button advancedButton = null; + /* default */ boolean autoConnect = false; /* default */ boolean autoLaunchDbg = false; // The list of existing configuration names. Used to generate a unique name @@ -178,6 +180,17 @@ public abstract class AbstractConfigWizardPage extends AbstractFormsWizardPage i detailsSection.getSection().setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false)); } + connect = new Button(parent, SWT.CHECK); + connect.setText(Messages.AbstractConfigWizardPage_connect_label); + connect.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); + connect.setSelection(autoConnect); + connect.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + autoConnect = SWTControlUtil.getSelection(connect); + } + }); + launchDbg = new Button(parent, SWT.CHECK); launchDbg.setText(Messages.AbstractConfigWizardPage_launchDbg_label); launchDbg.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); @@ -349,6 +362,15 @@ public abstract class AbstractConfigWizardPage extends AbstractFormsWizardPage i } /** + * Returns if or if not to connect after the configuration got created. + * + * @return <code>True</code> to connect, <code>false</code> if not. + */ + public final boolean isAutoConnect() { + return autoConnect; + } + + /** * Returns if or if not to auto-start the debugger after the configuration got created. * * @return <code>True</code> to auto-start the debugger, <code>false</code> if not. @@ -415,6 +437,10 @@ public abstract class AbstractConfigWizardPage extends AbstractFormsWizardPage i peerAttributes.setProperty(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties.PROP_AUTO_START_DEBUGGER, true); } + if (isAutoConnect()) { + peerAttributes.setProperty(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties.PROP_AUTO_CONNECT, true); + } + if (selectorSection != null) { updateAttribute(selectorSection, peerAttributes); } |