diff options
author | Tobias Schwarz | 2013-07-04 09:25:48 +0000 |
---|---|---|
committer | Tobias Schwarz | 2013-07-04 09:25:48 +0000 |
commit | 410ba38cbca8edea5a734ff86bca80239fd980b2 (patch) | |
tree | cce186c619dcf2c042fbb4263a48fe354165b322 /target_explorer | |
parent | 02629e28cb4af2650160ee0d3699ed880ba372a7 (diff) | |
download | org.eclipse.tcf-410ba38cbca8edea5a734ff86bca80239fd980b2.tar.gz org.eclipse.tcf-410ba38cbca8edea5a734ff86bca80239fd980b2.tar.xz org.eclipse.tcf-410ba38cbca8edea5a734ff86bca80239fd980b2.zip |
Target Explorer: move context selector out of launch plugins
Diffstat (limited to 'target_explorer')
31 files changed, 802 insertions, 532 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/activator/UIPlugin.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/activator/UIPlugin.java index 800cd1a75..fff0ec216 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/activator/UIPlugin.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/activator/UIPlugin.java @@ -1,151 +1,142 @@ -/*******************************************************************************
- * 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.launch.ui.activator;
-
-import java.net.URL;
-
-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.tcf.te.launch.ui.internal.ImageConsts;
-import org.eclipse.tcf.te.runtime.tracing.TraceHandler;
-import org.eclipse.tcf.te.ui.jface.images.AbstractImageDescriptor;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class UIPlugin extends AbstractUIPlugin {
- // The shared instance
- private static UIPlugin plugin;
- // The trace handler instance
- private static volatile TraceHandler traceHandler;
-
- /**
- * The constructor
- */
- public UIPlugin() {
- }
-
- /**
- * Returns the shared instance
- *
- * @return the shared instance
- */
- public static UIPlugin getDefault() {
- return plugin;
- }
-
- /**
- * Convenience method which returns the unique identifier of this plugin.
- */
- public static String getUniqueIdentifier() {
- if (getDefault() != null && getDefault().getBundle() != null) {
- return getDefault().getBundle().getSymbolicName();
- }
- return "org.eclipse.tcf.te.launch.ui"; //$NON-NLS-1$
- }
-
- /**
- * Returns the bundles trace handler.
- *
- * @return The bundles trace handler.
- */
- public static TraceHandler getTraceHandler() {
- if (traceHandler == null) {
- traceHandler = new TraceHandler(getUniqueIdentifier());
- }
- return traceHandler;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- */
- @Override
- public void start(BundleContext context) throws Exception {
- super.start(context);
- plugin = this;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- */
- @Override
- public void stop(BundleContext context) throws Exception {
- plugin = null;
- traceHandler = null;
- super.stop(context);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#initializeImageRegistry(org.eclipse.jface.resource.ImageRegistry)
- */
- @Override
- protected void initializeImageRegistry(ImageRegistry registry) {
- Bundle bundle = Platform.getBundle("org.eclipse.ui"); //$NON-NLS-1$
- if (bundle != null) {
- URL url = bundle.getEntry(ImageConsts.IMAGE_DIR_ROOT + "full/" + ImageConsts.IMAGE_DIR_ELCL + "refresh_nav.gif"); //$NON-NLS-1$ //$NON-NLS-2$
- registry.put(ImageConsts.ACTION_Refresh_Enabled, ImageDescriptor.createFromURL(url));
- url = bundle.getEntry(ImageConsts.IMAGE_DIR_ROOT + "full/" + ImageConsts.IMAGE_DIR_DLCL + "refresh_nav.gif"); //$NON-NLS-1$ //$NON-NLS-2$
- registry.put(ImageConsts.ACTION_Refresh_Disabled, ImageDescriptor.createFromURL(url));
- }
- URL url = getBundle().getEntry(ImageConsts.IMAGE_DIR_ROOT + ImageConsts.IMAGE_DIR_OBJ + "launches_root.gif"); //$NON-NLS-1$
- registry.put(ImageConsts.OBJ_Launches_Root, ImageDescriptor.createFromURL(url));
- url = getBundle().getEntry(ImageConsts.IMAGE_DIR_ROOT + ImageConsts.IMAGE_DIR_OVR + "redX_ovr.gif"); //$NON-NLS-1$
- registry.put(ImageConsts.RED_X_OVR, ImageDescriptor.createFromURL(url));
- }
-
- /**
- * Loads the image registered under the specified key from the image
- * registry and returns the <code>Image</code> object instance.
- *
- * @param key The key the image is registered with.
- * @return The <code>Image</code> object instance or <code>null</code>.
- */
- public static Image getImage(String key) {
- return getDefault().getImageRegistry().get(key);
- }
-
- /**
- * Loads the image registered under the specified key from the image
- * registry and returns the <code>ImageDescriptor</code> object instance.
- *
- * @param key The key the image is registered with.
- * @return The <code>ImageDescriptor</code> object instance or <code>null</code>.
- */
- public static ImageDescriptor getImageDescriptor(String key) {
- return getDefault().getImageRegistry().getDescriptor(key);
- }
-
- /**
- * Loads the image given by the specified image descriptor from the image
- * registry. If the image has been loaded ones before already, the cached
- * <code>Image</code> object instance is returned. Otherwise, the <code>
- * Image</code> object instance will be created and cached before returned.
- *
- * @param descriptor The image descriptor.
- * @return The corresponding <code>Image</code> object instance or <code>null</code>.
- */
- public static Image getSharedImage(AbstractImageDescriptor descriptor) {
- ImageRegistry registry = getDefault().getImageRegistry();
-
- String imageKey = descriptor.getDecriptorKey();
- Image image = registry.get(imageKey);
- if (image == null) {
- registry.put(imageKey, descriptor);
- image = registry.get(imageKey);
- }
-
- return image;
- }
-}
+/******************************************************************************* + * 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.launch.ui.activator; + +import java.net.URL; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.resource.ImageRegistry; +import org.eclipse.swt.graphics.Image; +import org.eclipse.tcf.te.launch.ui.internal.ImageConsts; +import org.eclipse.tcf.te.runtime.tracing.TraceHandler; +import org.eclipse.tcf.te.ui.jface.images.AbstractImageDescriptor; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class UIPlugin extends AbstractUIPlugin { + // The shared instance + private static UIPlugin plugin; + // The trace handler instance + private static volatile TraceHandler traceHandler; + + /** + * The constructor + */ + public UIPlugin() { + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static UIPlugin getDefault() { + return plugin; + } + + /** + * Convenience method which returns the unique identifier of this plugin. + */ + public static String getUniqueIdentifier() { + if (getDefault() != null && getDefault().getBundle() != null) { + return getDefault().getBundle().getSymbolicName(); + } + return "org.eclipse.tcf.te.launch.ui"; //$NON-NLS-1$ + } + + /** + * Returns the bundles trace handler. + * + * @return The bundles trace handler. + */ + public static TraceHandler getTraceHandler() { + if (traceHandler == null) { + traceHandler = new TraceHandler(getUniqueIdentifier()); + } + return traceHandler; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + @Override + public void stop(BundleContext context) throws Exception { + plugin = null; + traceHandler = null; + super.stop(context); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#initializeImageRegistry(org.eclipse.jface.resource.ImageRegistry) + */ + @Override + protected void initializeImageRegistry(ImageRegistry registry) { + URL url = getBundle().getEntry(ImageConsts.IMAGE_DIR_ROOT + ImageConsts.IMAGE_DIR_OBJ + "launches_root.gif"); //$NON-NLS-1$ + registry.put(ImageConsts.OBJ_Launches_Root, ImageDescriptor.createFromURL(url)); + url = getBundle().getEntry(ImageConsts.IMAGE_DIR_ROOT + ImageConsts.IMAGE_DIR_OVR + "redX_ovr.gif"); //$NON-NLS-1$ + registry.put(ImageConsts.RED_X_OVR, ImageDescriptor.createFromURL(url)); + } + + /** + * Loads the image registered under the specified key from the image + * registry and returns the <code>Image</code> object instance. + * + * @param key The key the image is registered with. + * @return The <code>Image</code> object instance or <code>null</code>. + */ + public static Image getImage(String key) { + return getDefault().getImageRegistry().get(key); + } + + /** + * Loads the image registered under the specified key from the image + * registry and returns the <code>ImageDescriptor</code> object instance. + * + * @param key The key the image is registered with. + * @return The <code>ImageDescriptor</code> object instance or <code>null</code>. + */ + public static ImageDescriptor getImageDescriptor(String key) { + return getDefault().getImageRegistry().getDescriptor(key); + } + + /** + * Loads the image given by the specified image descriptor from the image + * registry. If the image has been loaded ones before already, the cached + * <code>Image</code> object instance is returned. Otherwise, the <code> + * Image</code> object instance will be created and cached before returned. + * + * @param descriptor The image descriptor. + * @return The corresponding <code>Image</code> object instance or <code>null</code>. + */ + public static Image getSharedImage(AbstractImageDescriptor descriptor) { + ImageRegistry registry = getDefault().getImageRegistry(); + + String imageKey = descriptor.getDecriptorKey(); + Image image = registry.get(imageKey); + if (image == null) { + registry.put(imageKey, descriptor); + image = registry.get(imageKey); + } + + return image; + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/ImageConsts.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/ImageConsts.java index 4e49d0f15..71a0b3fef 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/ImageConsts.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/internal/ImageConsts.java @@ -55,16 +55,6 @@ public interface ImageConsts { // ***** The image constants ***** /** - * The key to access the refresh action image (enabled). - */ - public static final String ACTION_Refresh_Enabled = "RefreshAction_enabled"; //$NON-NLS-1$ - - /** - * The key to access the refresh action image (disabled). - */ - public static final String ACTION_Refresh_Disabled = "RefreshAction_disabled"; //$NON-NLS-1$ - - /** * The key to access the launches tree root image. */ public static final String OBJ_Launches_Root = "OBJ_Launches_Root"; //$NON-NLS-1$ diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/nls/Messages.java index d5d799e38..cd5dc5338 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/nls/Messages.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/nls/Messages.java @@ -69,8 +69,6 @@ public class Messages extends NLS { public static String LaunchSelectionManager_error_failedToDetermineElfType; - public static String ContextSelectorControl_toolbar_refresh_tooltip; - public static String LaunchConfigType_title; public static String LaunchConfigType_label; @@ -79,9 +77,6 @@ public class Messages extends NLS { public static String ContextSelectorSection_title; public static String ContextSelectorSection_label; - public static String RemoteContextSelectorControl_error_noContextSelected_single; - public static String RemoteContextSelectorControl_error_noContextSelected_multi; - public static String ReferencedProjectsTab_name; public static String ReferencedProjectsSection_title; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/nls/Messages.properties index 76727d698..2cd4dffb3 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/nls/Messages.properties +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/nls/Messages.properties @@ -1,67 +1,62 @@ -###############################################################################
-# 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
-###############################################################################
-
-LaunchSelectionManager_error_failedToDetermineElfType=Failed to determine ELF type of file ''{0}''.
-
-LaunchContextSelectorTab_name=Main
-
-ContextSelectorControl_toolbar_refresh_tooltip=Refresh
-
-LaunchConfigType_title=Launch Configuration Type
-LaunchConfigType_label=Name:
-
-ContextSelectorSection_title=Remote Context
-ContextSelectorSection_label=Name:
-
-RemoteContextSelectorControl_error_noContextSelected_single=Please select a remote context.
-RemoteContextSelectorControl_error_noContextSelected_multi=Please select one or more remote contexts.
-
-ReferencedProjectsTab_name = Referenced Projects
-
-ReferencedProjectsSection_title = Referenced Projects
-ReferencedProjectsSection_description = Referenced Projects
-ReferencedProjectsSection_name_column = Name
-ReferencedProjectsSection_add_button = Add
-ReferencedProjectsSection_delete_button = Delete
-ReferencedProjectsSection_up_button = Up
-ReferencedProjectsSection_down_button = Down
-ReferencedProjectsSection_addDialog_message = Select projects that should be built before launch.
-
-FileTransferTab_name = File Transfers
-
-FileTransferSection_title = File Transfers
-FileTransferSection_description = File Transfers
-FileTransferSection_host_column = Host
-FileTransferSection_target_column = Target
-FileTransferSection_options_column = Options
-FileTransferSection_add_button = Add
-FileTransferSection_edit_button = Edit
-FileTransferSection_delete_button = Delete
-FileTransferSection_up_button = Up
-FileTransferSection_down_button = Down
-FileTransferSection_toHost_tooltip = Transfer from Target to Host
-FileTransferSection_toTarget_tooltip = Transfer from Host to Target
-FileTransferSection_toHost_text = <<
-FileTransferSection_toTarget_text = >>
-
-LaunchEditorPage_title = Launches
-LaunchExplorerEditorPage_PageTitle=Launches
-
-DeleteHandlerDelegate_question_title = Question
-DeleteHandlerDelegate_question_message = Are you sure you want to delete ''{0}''?
-
-LaunchDialogHandler_dialog_title = Choose launch mode
-LaunchDialogHandler_dialog_message = Please choose a launch mode for {0} launch ''{1}''.
-
-CommonDnD_launchMode_dialog_title = Choose launch mode
-CommonDnD_launchMode_dialog_message = Please choose a launch mode for {0} launch.
-
-CommonDnD_launchType_dialog_title = Choose launch configuration type
-CommonDnD_launchType_dialog_message = Please choose a launch configuration type.
+############################################################################### +# 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 +############################################################################### + +LaunchSelectionManager_error_failedToDetermineElfType=Failed to determine ELF type of file ''{0}''. + +LaunchContextSelectorTab_name=Main + +LaunchConfigType_title=Launch Configuration Type +LaunchConfigType_label=Name: + +ContextSelectorSection_title=Remote Context +ContextSelectorSection_label=Name: + +ReferencedProjectsTab_name = Referenced Projects + +ReferencedProjectsSection_title = Referenced Projects +ReferencedProjectsSection_description = Referenced Projects +ReferencedProjectsSection_name_column = Name +ReferencedProjectsSection_add_button = Add +ReferencedProjectsSection_delete_button = Delete +ReferencedProjectsSection_up_button = Up +ReferencedProjectsSection_down_button = Down +ReferencedProjectsSection_addDialog_message = Select projects that should be built before launch. + +FileTransferTab_name = File Transfers + +FileTransferSection_title = File Transfers +FileTransferSection_description = File Transfers +FileTransferSection_host_column = Host +FileTransferSection_target_column = Target +FileTransferSection_options_column = Options +FileTransferSection_add_button = Add +FileTransferSection_edit_button = Edit +FileTransferSection_delete_button = Delete +FileTransferSection_up_button = Up +FileTransferSection_down_button = Down +FileTransferSection_toHost_tooltip = Transfer from Target to Host +FileTransferSection_toTarget_tooltip = Transfer from Host to Target +FileTransferSection_toHost_text = << +FileTransferSection_toTarget_text = >> + +LaunchEditorPage_title = Launches +LaunchExplorerEditorPage_PageTitle=Launches + +DeleteHandlerDelegate_question_title = Question +DeleteHandlerDelegate_question_message = Are you sure you want to delete ''{0}''? + +LaunchDialogHandler_dialog_title = Choose launch mode +LaunchDialogHandler_dialog_message = Please choose a launch mode for {0} launch ''{1}''. + +CommonDnD_launchMode_dialog_title = Choose launch mode +CommonDnD_launchMode_dialog_message = Please choose a launch mode for {0} launch. + +CommonDnD_launchType_dialog_title = Choose launch configuration type +CommonDnD_launchType_dialog_message = Please choose a launch configuration type. diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/launchcontext/AbstractContextSelectorTab.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/launchcontext/AbstractContextSelectorTab.java index 2cdfd6325..68eda0b6b 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/launchcontext/AbstractContextSelectorTab.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/launchcontext/AbstractContextSelectorTab.java @@ -16,6 +16,7 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.tcf.te.launch.ui.nls.Messages; import org.eclipse.tcf.te.launch.ui.tabs.AbstractFormsLaunchConfigurationTab; import org.eclipse.tcf.te.ui.forms.CustomFormToolkit; +import org.eclipse.tcf.te.ui.views.sections.AbstractContextSelectorSection; import org.eclipse.ui.forms.IManagedForm; import org.eclipse.ui.forms.widgets.TableWrapData; import org.eclipse.ui.forms.widgets.TableWrapLayout; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/delegates/GsonMapPersistenceDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/delegates/GsonMapPersistenceDelegate.java index 62720121b..ac94f1a8d 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/delegates/GsonMapPersistenceDelegate.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.persistence/src/org/eclipse/tcf/te/runtime/persistence/delegates/GsonMapPersistenceDelegate.java @@ -245,7 +245,8 @@ public class GsonMapPersistenceDelegate extends ExecutableExtension implements I Reader reader = new InputStreamReader(new FileInputStream(file), "UTF-8"); //$NON-NLS-1$ if (!isList) { try { - data.add(gson.fromJson(reader, Map.class)); + Map<String,Object> read = gson.fromJson(reader, Map.class); + data.add(read); } finally { reader.close(); @@ -255,7 +256,8 @@ public class GsonMapPersistenceDelegate extends ExecutableExtension implements I try { List<String> strings = gson.fromJson(reader, List.class); for (String string : strings) { - data.add(gson.fromJson(string, Map.class)); + Map<String,Object> read = gson.fromJson(string, Map.class); + data.add(read); } } finally { @@ -276,19 +278,20 @@ public class GsonMapPersistenceDelegate extends ExecutableExtension implements I } for (Map<String, Object> entry : data) { - Map<String, String> variables = new HashMap<String, String>(); - if (entry.containsKey(VARIABLES)) { - variables = (Map<String, String>) entry.remove(VARIABLES); - } - IVariableDelegate[] delegates = PersistenceManager.getInstance() - .getVariableDelegates(this); - for (IVariableDelegate delegate : delegates) { - entry = delegate.putVariables(entry, variables); + if (entry != null) { + Map<String, String> variables = new HashMap<String, String>(); + if (entry.containsKey(VARIABLES)) { + variables = (Map<String, String>) entry.remove(VARIABLES); + } + IVariableDelegate[] delegates = PersistenceManager.getInstance().getVariableDelegates(this); + for (IVariableDelegate delegate : delegates) { + entry = delegate.putVariables(entry, variables); + } } } if (!isList) { - return !data.isEmpty() ? fromMap(data.get(0), context) : context; + return !data.isEmpty() && data.get(0) != null ? fromMap(data.get(0), context) : context; } List<Object> list = new ArrayList<Object>(); @@ -391,7 +394,7 @@ public class GsonMapPersistenceDelegate extends ExecutableExtension implements I newMap.putAll(map); return newMap; } - else if (IPropertiesContainer.class.equals(context.getClass())) { + else if (IPropertiesContainer.class.equals(context)) { IPropertiesContainer container = new PropertiesContainer(); container.setProperties(map); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/filetransfer/FileTransferItem.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/filetransfer/FileTransferItem.java index 51ef796e7..a4880a209 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/filetransfer/FileTransferItem.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/filetransfer/FileTransferItem.java @@ -28,10 +28,19 @@ public class FileTransferItem extends PropertiesContainer implements IFileTransf setProperty(PROPERTY_DIRECTION, HOST_TO_TARGET); } + public FileTransferItem(IPath fromHost, boolean enabled) { + this(); + if (fromHost != null) + setProperty(PROPERTY_HOST, fromHost.toPortableString()); + setProperty(PROPERTY_ENABLED, enabled); + } + public FileTransferItem(IPath fromHost, IPath toTarget) { this(); - setProperty(PROPERTY_HOST, fromHost.toPortableString()); - setProperty(PROPERTY_TARGET, toTarget.toPortableString()); + if (fromHost != null) + setProperty(PROPERTY_HOST, fromHost.toPortableString()); + if (toTarget != null) + setProperty(PROPERTY_TARGET, toTarget.toPortableString()); } /* (non-Javadoc) diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/interfaces/IStepperService.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/interfaces/IStepperService.java index 186ae3f4e..e33c4d547 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/interfaces/IStepperService.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/interfaces/IStepperService.java @@ -9,6 +9,7 @@ *******************************************************************************/ package org.eclipse.tcf.te.runtime.stepper.interfaces; +import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; import org.eclipse.tcf.te.runtime.services.interfaces.IService; /** @@ -17,6 +18,14 @@ import org.eclipse.tcf.te.runtime.services.interfaces.IService; public interface IStepperService extends IService { /** + * Checks if this service can handle the given operation. + * @param context The context. Must not be <code>null</code>. + * @param operation The operation. Must not be <code>null</code>. + * @return <code>true</code> if this service handles the given operation. + */ + public boolean isHandledOperation(Object context, String operation); + + /** * Get the step group id for the given context and operation * or <code>null</code> if this operation is not available. * @@ -48,6 +57,15 @@ public interface IStepperService extends IService { public IStepContext getStepContext(Object context, String operation); /** + * Get the step data for the given context and operation. + * + * @param context The context. Must not be <code>null</code>. + * @param operation The operation. Must not be <code>null</code>. + * @return The step data or an empty properties container. + */ + public IPropertiesContainer getStepData(Object context, String operation); + + /** * Get the enabled state for the given operation. * * @param context The context. Must not be <code>null</code>. diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/internal/PropertyTester.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/internal/PropertyTester.java index 642911a56..a0d5fbefd 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/internal/PropertyTester.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/internal/PropertyTester.java @@ -12,6 +12,7 @@ package org.eclipse.tcf.te.runtime.stepper.internal; import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; import org.eclipse.tcf.te.runtime.services.ServiceManager; import org.eclipse.tcf.te.runtime.services.interfaces.IPropertiesAccessService; +import org.eclipse.tcf.te.runtime.services.interfaces.IService; import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepperService; import org.eclipse.tcf.te.runtime.stepper.job.StepperJob; @@ -52,9 +53,15 @@ public class PropertyTester extends org.eclipse.core.expressions.PropertyTester if ("isEnabled".equals(property)) { //$NON-NLS-1$ if (operation != null) { - IStepperService service = ServiceManager.getInstance().getService(receiver, IStepperService.class); - if (service != null) { - return service.isEnabled(receiver, operation); + IService[] services = ServiceManager.getInstance().getServices(receiver, IStepperService.class, false); + IStepperService stepperService = null; + for (IService service : services) { + if (service instanceof IStepperService && ((IStepperService)service).isHandledOperation(receiver, operation)) { + stepperService = (IStepperService)service; + } + } + if (stepperService != null) { + return stepperService.isEnabled(receiver, operation); } } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/services/AbstractStepperService.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/services/AbstractStepperService.java index dcb677795..9be29cba2 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/services/AbstractStepperService.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/services/AbstractStepperService.java @@ -10,7 +10,12 @@ package org.eclipse.tcf.te.runtime.stepper.services; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.Platform; +import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; +import org.eclipse.tcf.te.runtime.properties.PropertiesContainer; import org.eclipse.tcf.te.runtime.services.AbstractService; +import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext; import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepperService; /** @@ -18,4 +23,30 @@ import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepperService; */ public abstract class AbstractStepperService extends AbstractService implements IStepperService { + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepperService#getStepContext(java.lang.Object, java.lang.String) + */ + @Override + public IStepContext getStepContext(Object context, String operation) { + IStepContext stepContext = null; + + if (isHandledOperation(context, operation)) { + if (context instanceof IAdaptable) { + stepContext = (IStepContext)((IAdaptable)context).getAdapter(IStepContext.class); + } + if (stepContext == null && context != null) { + stepContext = (IStepContext)Platform.getAdapterManager().getAdapter(context, IStepContext.class); + } + } + + return stepContext; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepperService#getStepData(java.lang.Object, java.lang.String) + */ + @Override + public IPropertiesContainer getStepData(Object context, String operation) { + return new PropertiesContainer(); + } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/META-INF/MANIFEST.MF index 4a973bc9b..63e80a8bc 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/META-INF/MANIFEST.MF +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/META-INF/MANIFEST.MF @@ -33,7 +33,8 @@ Require-Bundle: org.eclipse.core.expressions;bundle-version="3.4.400", org.eclipse.ui;bundle-version="3.8.0", org.eclipse.ui.forms;bundle-version="3.5.200", org.eclipse.ui.navigator;bundle-version="3.5.200", - org.eclipse.ui.views.properties.tabbed;bundle-version="3.5.300" + org.eclipse.ui.views.properties.tabbed;bundle-version="3.5.300", + org.eclipse.tcf.te.ui;bundle-version="1.1.0" Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ActivationPolicy: lazy Bundle-Localization: plugin diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/launchcontext/AbstractLaunchContextMainTab.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/launchcontext/AbstractLaunchContextMainTab.java index 04a8aff36..41e638cb0 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/launchcontext/AbstractLaunchContextMainTab.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/launchcontext/AbstractLaunchContextMainTab.java @@ -21,10 +21,10 @@ import org.eclipse.jface.viewers.ViewerFilter; import org.eclipse.swt.widgets.Composite; import org.eclipse.tcf.te.launch.core.bindings.LaunchConfigTypeBindingsManager; import org.eclipse.tcf.te.launch.core.selection.RemoteSelectionContext; -import org.eclipse.tcf.te.launch.ui.tabs.launchcontext.AbstractContextSelectorControl; import org.eclipse.tcf.te.launch.ui.tabs.launchcontext.AbstractContextSelectorTab; -import org.eclipse.tcf.te.tcf.launch.ui.launchcontext.ContextSelectorSection.ContextSelectorSectionSelectorControl; import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.ui.controls.ContextSelectorSectionControl; +import org.eclipse.tcf.te.ui.views.controls.AbstractContextSelectorControl; import org.eclipse.ui.forms.IManagedForm; /** @@ -66,7 +66,7 @@ public abstract class AbstractLaunchContextMainTab extends AbstractContextSelect /** * Launch configuration main tab context selector control implementation. */ - protected class MainTabContextSelectorControl extends ContextSelectorSectionSelectorControl { + protected class MainTabContextSelectorControl extends ContextSelectorSectionControl { /** * Constructor. @@ -75,7 +75,7 @@ public abstract class AbstractLaunchContextMainTab extends AbstractContextSelect * @param parentPage The parent target connection page this control is embedded in. Might be * <code>null</code> if the control is not associated with a page. */ - public MainTabContextSelectorControl(ContextSelectorSection section, IDialogPage parentPage) { + public MainTabContextSelectorControl(MainTabContextSelectorSection section, IDialogPage parentPage) { super(section, parentPage); } @@ -110,11 +110,11 @@ public abstract class AbstractLaunchContextMainTab extends AbstractContextSelect * @see org.eclipse.tcf.te.launch.ui.tabs.launchcontext.AbstractContextSelectorTab#doCreateContextSelectorSection(org.eclipse.ui.forms.IManagedForm, org.eclipse.swt.widgets.Composite) */ @Override - protected ContextSelectorSection doCreateContextSelectorSection(IManagedForm form, Composite panel) { - return new ContextSelectorSection(form, panel) { + protected MainTabContextSelectorSection doCreateContextSelectorSection(IManagedForm form, Composite panel) { + return new MainTabContextSelectorSection(form, panel) { /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.launch.ui.launchcontext.ContextSelectorSection#doCreateContextSelector() + * @see org.eclipse.tcf.te.tcf.launch.ui.launchcontext.MainTabContextSelectorSection#doCreateContextSelector() */ @Override protected AbstractContextSelectorControl doCreateContextSelector() { diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/launchcontext/ContextSelectorSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/launchcontext/ContextSelectorSection.java deleted file mode 100644 index 0bc08787a..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/launchcontext/ContextSelectorSection.java +++ /dev/null @@ -1,69 +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.tcf.launch.ui.launchcontext; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.jface.dialogs.IDialogPage; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.tcf.te.launch.ui.tabs.launchcontext.AbstractContextSelectorControl; -import org.eclipse.tcf.te.launch.ui.tabs.launchcontext.AbstractContextSelectorSection; -import org.eclipse.ui.forms.IManagedForm; - -/** - * Locator model context selector section implementation. - */ -public class ContextSelectorSection extends AbstractContextSelectorSection { - - /** - * Context selector section selector control implementation. - */ - public static class ContextSelectorSectionSelectorControl extends ContextSelectorControl { - private final ContextSelectorSection section; - - /** - * Constructor. - * - * @param section The parent context selector section. Must not be <code>null</code>. - * @param parentPage The parent target connection page this control is embedded in. Might be - * <code>null</code> if the control is not associated with a page. - */ - public ContextSelectorSectionSelectorControl(ContextSelectorSection section, IDialogPage parentPage) { - super(parentPage); - Assert.isNotNull(section); - this.section = section; - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.launch.ui.tabs.launchcontext.AbstractContextSelectorControl#onCheckStateChanged(java.lang.Object, boolean) - */ - @Override - protected void onCheckStateChanged(Object element, boolean checked) { - super.onCheckStateChanged(element, checked); - section.getManagedForm().dirtyStateChanged(); - } - } - - /** - * Constructor. - * @param form The managed form. - * @param parent The parent composite. - */ - public ContextSelectorSection(IManagedForm form, Composite parent) { - super(form, parent); - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.launch.ui.tabs.launchcontext.AbstractContextSelectorSection#doCreateContextSelector() - */ - @Override - protected AbstractContextSelectorControl doCreateContextSelector() { - return new ContextSelectorSectionSelectorControl(this, null); - } -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/launchcontext/MainTabContextSelectorSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/launchcontext/MainTabContextSelectorSection.java new file mode 100644 index 000000000..7f3dd792f --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/launchcontext/MainTabContextSelectorSection.java @@ -0,0 +1,100 @@ +/******************************************************************************* + * 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.launch.ui.launchcontext; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchContextLaunchAttributes; +import org.eclipse.tcf.te.launch.core.persistence.launchcontext.LaunchContextsPersistenceDelegate; +import org.eclipse.tcf.te.launch.ui.interfaces.ILaunchConfigurationTabFormPart; +import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode; +import org.eclipse.tcf.te.tcf.ui.sections.ContextSelectorSection; +import org.eclipse.ui.forms.IManagedForm; + +/** + * Locator model context selector section implementation. + */ +public class MainTabContextSelectorSection extends ContextSelectorSection implements ILaunchConfigurationTabFormPart { + + /** + * Constructor. + * @param form The managed form. + * @param parent The parent composite. + */ + public MainTabContextSelectorSection(IManagedForm form, Composite parent) { + super(form, parent); + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.tcf.ui.sections.ContextSelectorSection#getContextListDataKey() + */ + @Override + protected String getContextListDataKey() { + return ILaunchContextLaunchAttributes.ATTR_LAUNCH_CONTEXTS; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.launch.ui.interfaces.ILaunchConfigurationTabFormPart#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration) + */ + @Override + public void initializeFrom(ILaunchConfiguration configuration) { + Assert.isNotNull(configuration); + + if (selector != null) { + IModelNode[] contexts = LaunchContextsPersistenceDelegate.getLaunchContexts(configuration); + if (contexts != null && contexts.length > 0) { + // Loop the contexts and create a list of nodes + List<IModelNode> nodes = new ArrayList<IModelNode>(); + for (IModelNode node : contexts) { + if (node != null && !nodes.contains(node)) { + nodes.add(node); + } + } + if (!nodes.isEmpty()) { + selector.setCheckedModelContexts(nodes.toArray(new IModelNode[nodes.size()])); + } + } + } + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.launch.ui.interfaces.ILaunchConfigurationTabFormPart#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) + */ + @Override + public void performApply(ILaunchConfigurationWorkingCopy configuration) { + Assert.isNotNull(configuration); + + if (selector != null) { + IModelNode[] nodes = selector.getCheckedModelContexts(); + + // Write the selected contexts to the launch configuration + if (nodes != null && nodes.length > 0) { + LaunchContextsPersistenceDelegate.setLaunchContexts(configuration, nodes); + } else { + LaunchContextsPersistenceDelegate.setLaunchContexts(configuration, null); + } + } else { + LaunchContextsPersistenceDelegate.setLaunchContexts(configuration, null); + } + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.launch.ui.interfaces.ILaunchConfigurationTabFormPart#isValid(org.eclipse.debug.core.ILaunchConfiguration) + */ + @Override + public boolean isValid(ILaunchConfiguration configuration) { + return isValid(); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/persistence/GsonPeerPersistenceDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/persistence/GsonPeerPersistenceDelegate.java index 246ff5658..ce3aad621 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/persistence/GsonPeerPersistenceDelegate.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/persistence/GsonPeerPersistenceDelegate.java @@ -66,7 +66,8 @@ public class GsonPeerPersistenceDelegate extends GsonMapPersistenceDelegate { protected Object fromMap(Map<String, Object> map, Object context) throws IOException { Map<String,String> attrs = new HashMap<String,String>(); for (Entry<String, Object> entry : map.entrySet()) { - attrs.put(entry.getKey(), entry.getValue().toString()); + if (entry != null) + attrs.put(entry.getKey(), entry.getValue().toString()); } final IPeer peer = new Peer(attrs); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/AbstractStepperService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/AbstractStepperService.java index 8130f2a6a..97b911ed2 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/AbstractStepperService.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/AbstractStepperService.java @@ -11,9 +11,6 @@ package org.eclipse.tcf.te.tcf.locator.services; import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.Platform; -import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext; import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; import org.eclipse.tcf.te.tcf.locator.interfaces.services.IStepperServiceOperations; @@ -29,6 +26,15 @@ public abstract class AbstractStepperService extends org.eclipse.tcf.te.runtime. } /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepperService#isHandledOperation(java.lang.Object, java.lang.String) + */ + @Override + public boolean isHandledOperation(Object context, String operation) { + return IStepperServiceOperations.CONNECT.equals(operation) || + IStepperServiceOperations.DISCONNECT.equals(operation); + } + + /* (non-Javadoc) * @see org.eclipse.tcf.te.runtime.services.interfaces.IStepperService#getStepGroupId(java.lang.Object, java.lang.String) */ @Override @@ -63,25 +69,6 @@ public abstract class AbstractStepperService extends org.eclipse.tcf.te.runtime. } /* (non-Javadoc) - * @see org.eclipse.tcf.te.runtime.services.interfaces.IStepperService#getStepContext(java.lang.Object, java.lang.String) - */ - @Override - public IStepContext getStepContext(Object context, String operation) { - IStepContext stepContext = null; - - if (IStepperServiceOperations.CONNECT.equals(operation) || IStepperServiceOperations.DISCONNECT.equals(operation)) { - if (context instanceof IAdaptable) { - stepContext = (IStepContext)((IAdaptable)context).getAdapter(IStepContext.class); - } - if (stepContext == null) { - stepContext = (IStepContext)Platform.getAdapterManager().getAdapter(context, IStepContext.class); - } - } - - return stepContext; - } - - /* (non-Javadoc) * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStepperService#isCancelable(java.lang.Object, java.lang.String) */ @Override 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 22df90325..4521dac4d 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 @@ -21,8 +21,8 @@ import org.eclipse.tcf.te.core.async.AsyncCallbackCollector; import org.eclipse.tcf.te.runtime.concurrent.util.ExecutorsUtil; 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.services.ServiceManager; +import org.eclipse.tcf.te.runtime.services.interfaces.IService; import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext; import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepperService; import org.eclipse.tcf.te.runtime.stepper.job.StepperJob; @@ -126,15 +126,21 @@ public class UIPlugin extends AbstractUIPlugin { IPeerModel[] peers = model.getPeers(); // Loop them and check if disconnect is available for (IPeerModel peerModel : peers) { - IStepperService service = ServiceManager.getInstance().getService(peerModel, IStepperService.class); - if (service != null) { - String stepGroupId = service.getStepGroupId(peerModel, IStepperServiceOperations.DISCONNECT); - IStepContext stepContext = service.getStepContext(peerModel, IStepperServiceOperations.DISCONNECT); - String name = service.getStepGroupName(peerModel, IStepperServiceOperations.DISCONNECT); - boolean isEnabled = service.isEnabled(peerModel, IStepperServiceOperations.DISCONNECT); + IService[] services = ServiceManager.getInstance().getServices(peerModel, IStepperService.class, false); + IStepperService stepperService = null; + for (IService service : services) { + if (service instanceof IStepperService && ((IStepperService)service).isHandledOperation(peerModel, IStepperServiceOperations.DISCONNECT)) { + stepperService = (IStepperService)service; + } + } + if (stepperService != null) { + String stepGroupId = stepperService.getStepGroupId(peerModel, IStepperServiceOperations.DISCONNECT); + IStepContext stepContext = stepperService.getStepContext(peerModel, IStepperServiceOperations.DISCONNECT); + String name = stepperService.getStepGroupName(peerModel, IStepperServiceOperations.DISCONNECT); + boolean isEnabled = stepperService.isEnabled(peerModel, IStepperServiceOperations.DISCONNECT); + IPropertiesContainer data = stepperService.getStepData(peerModel, IStepperServiceOperations.DISCONNECT); if (isEnabled && stepGroupId != null && stepContext != null) { - IPropertiesContainer data = new PropertiesContainer(); StepperJob job = new StepperJob(name != null ? name : "", //$NON-NLS-1$ stepContext, data, diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/launchcontext/ContextSelectorControl.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/ContextSelectorSectionControl.java index 19cfe7b7a..86ac93640 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/launchcontext/ContextSelectorControl.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/ContextSelectorSectionControl.java @@ -8,28 +8,45 @@ * Wind River Systems - initial API and implementation *******************************************************************************/ -package org.eclipse.tcf.te.tcf.launch.ui.launchcontext; +package org.eclipse.tcf.te.tcf.ui.controls; +import org.eclipse.core.runtime.Assert; import org.eclipse.jface.dialogs.IDialogPage; import org.eclipse.jface.viewers.DecoratingLabelProvider; import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.tcf.te.launch.ui.tabs.launchcontext.AbstractContextSelectorControl; import org.eclipse.tcf.te.tcf.locator.model.Model; import org.eclipse.tcf.te.tcf.ui.navigator.ContentProviderDelegate; import org.eclipse.tcf.te.tcf.ui.navigator.DelegatingLabelProvider; +import org.eclipse.tcf.te.ui.views.controls.AbstractContextSelectorControl; +import org.eclipse.tcf.te.ui.views.sections.AbstractContextSelectorSection; /** * Locator model launch context selector control. */ -public class ContextSelectorControl extends AbstractContextSelectorControl { +public class ContextSelectorSectionControl extends AbstractContextSelectorControl { + private final AbstractContextSelectorSection section; /** * Constructor. - * @param parentPage + * + * @param section The parent context selector section. Must not be <code>null</code>. + * @param parentPage The parent target connection page this control is embedded in. Might be + * <code>null</code> if the control is not associated with a page. */ - public ContextSelectorControl(IDialogPage parentPage) { - super(parentPage); + public ContextSelectorSectionControl(AbstractContextSelectorSection section, IDialogPage parentPage) { + super(parentPage); + Assert.isNotNull(section); + this.section = section; + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.launch.ui.tabs.launchcontext.AbstractContextSelectorControl#onCheckStateChanged(java.lang.Object, boolean) + */ + @Override + protected void onCheckStateChanged(Object element, boolean checked) { + super.onCheckStateChanged(element, checked); + section.getManagedForm().dirtyStateChanged(); } /* (non-Javadoc) 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 08084ef8f..eb97503c4 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 @@ -239,5 +239,4 @@ public class Messages extends NLS { public static String PeerImportWizardPage_overwrite_button; public static String PeerImportWizardPage_overwriteDialog_message; public static String PeerImportWizardPage_overwriteDialogToggle_message; - } 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 794adabc6..e8594fb52 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 @@ -198,4 +198,3 @@ PeerImportWizardPage_locationIsFile_error=Please enter or select a valid directo PeerImportWizardPage_overwrite_button=Overwrite existing configuration(s) without warning PeerImportWizardPage_overwriteDialog_message=The configuration ''{0}'' already exists. Do you want to overwrite it? PeerImportWizardPage_overwriteDialogToggle_message=Remember my decision - diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/sections/ContextSelectorSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/sections/ContextSelectorSection.java new file mode 100644 index 000000000..0a34a497a --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/sections/ContextSelectorSection.java @@ -0,0 +1,113 @@ +/******************************************************************************* + * 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.ui.sections; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.swt.widgets.Composite; +import org.eclipse.tcf.protocol.IPeer; +import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; +import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode; +import org.eclipse.tcf.te.runtime.persistence.PersistenceManager; +import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistenceDelegate; +import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tcf.te.tcf.ui.controls.ContextSelectorSectionControl; +import org.eclipse.tcf.te.ui.views.controls.AbstractContextSelectorControl; +import org.eclipse.tcf.te.ui.views.sections.AbstractContextSelectorSection; +import org.eclipse.ui.forms.IManagedForm; + +/** + * Locator model context selector section implementation. + */ +public abstract class ContextSelectorSection extends AbstractContextSelectorSection { + + /** + * Constructor. + * @param form The managed form. + * @param parent The parent composite. + */ + public ContextSelectorSection(IManagedForm form, Composite parent) { + super(form, parent); + } + + /** + * Constructor. + * @param form The managed form. + * @param parent The parent composite. + * @param style + */ + public ContextSelectorSection(IManagedForm form, Composite parent, int style) { + super(form, parent, style); + } + + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.launch.ui.tabs.launchcontext.AbstractContextSelectorSection#doCreateContextSelector() + */ + @Override + protected AbstractContextSelectorControl doCreateContextSelector() { + return new ContextSelectorSectionControl(this, null); + } + + public static final String encode(IModelNode[] contexts) { + try { + if (contexts != null && contexts.length > 0) { + IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(IPeer.class, String.class); + return (String)delegate.writeList(contexts, String.class); + } + } + catch (Exception e) { + } + return null; + } + + public static final IModelNode[] decode (String encoded) { + try { + if (encoded != null && encoded.trim().length() > 0) { + IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(IPeer.class, String.class); + Object[] input = delegate.readList(IPeerModel.class, encoded); + List<IModelNode> peers = new ArrayList<IModelNode>(); + for (Object object : input) { + if (object instanceof IModelNode) { + peers.add((IModelNode)object); + } + } + return peers.toArray(new IPeerModel[peers.size()]); + } + } + catch (Exception e) { + } + return new IModelNode[0]; + } + + protected abstract String getContextListDataKey(); + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.ui.interfaces.data.IDataExchangeNode#setupData(org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer) + */ + @Override + public void setupData(IPropertiesContainer data) { + String encoded = data.getStringProperty(getContextListDataKey()); + IModelNode[] list = decode(encoded); + selector.setCheckedModelContexts(list); + if (selector != null && selector.getViewer() != null) { + selector.getViewer().refresh(); + } + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.ui.interfaces.data.IDataExchangeNode#extractData(org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer) + */ + @Override + public void extractData(IPropertiesContainer data) { + data.setProperty(getContextListDataKey(), encode(selector.getCheckedModelContexts())); + } +} 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 63dca42bb..ea8a1c17a 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 @@ -12,8 +12,8 @@ package org.eclipse.tcf.te.tcf.ui.wizards; import org.eclipse.core.runtime.Assert; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; -import org.eclipse.tcf.te.runtime.properties.PropertiesContainer; import org.eclipse.tcf.te.runtime.services.ServiceManager; +import org.eclipse.tcf.te.runtime.services.interfaces.IService; import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext; import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepperService; import org.eclipse.tcf.te.runtime.stepper.job.StepperJob; @@ -74,14 +74,20 @@ public abstract class AbstractConfigWizard extends NewTargetWizard { if (!autoConnect) return; // Connect the connection - IStepperService service = ServiceManager.getInstance().getService(peerModel, IStepperService.class); - if (service != null) { - String stepGroupId = service.getStepGroupId(peerModel, IStepperServiceOperations.CONNECT); - IStepContext stepContext = service.getStepContext(peerModel, IStepperServiceOperations.CONNECT); - String name = service.getStepGroupName(peerModel, IStepperServiceOperations.CONNECT); + IService[] services = ServiceManager.getInstance().getServices(peerModel, IStepperService.class, false); + IStepperService stepperService = null; + for (IService service : services) { + if (service instanceof IStepperService && ((IStepperService)service).isHandledOperation(peerModel, IStepperServiceOperations.CONNECT)) { + stepperService = (IStepperService)service; + } + } + if (stepperService != null) { + String stepGroupId = stepperService.getStepGroupId(peerModel, IStepperServiceOperations.CONNECT); + IStepContext stepContext = stepperService.getStepContext(peerModel, IStepperServiceOperations.CONNECT); + String name = stepperService.getStepGroupName(peerModel, IStepperServiceOperations.CONNECT); + IPropertiesContainer data = stepperService.getStepData(peerModel, IStepperServiceOperations.CONNECT); if (stepGroupId != null && stepContext != null) { - IPropertiesContainer data = new PropertiesContainer(); StepperJob job = new StepperJob(name != null ? name : "", //$NON-NLS-1$ stepContext, data, diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/META-INF/MANIFEST.MF index f74f9902f..b96691163 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/META-INF/MANIFEST.MF +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/META-INF/MANIFEST.MF @@ -1,53 +1,55 @@ -Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-SymbolicName: org.eclipse.tcf.te.ui.views;singleton:=true
-Bundle-Version: 1.1.0.qualifier
-Bundle-Activator: org.eclipse.tcf.te.ui.views.activator.UIPlugin
-Bundle-Vendor: %providerName
-Require-Bundle: com.google.gson;bundle-version="2.1.0",
- org.eclipse.core.runtime;bundle-version="3.8.0",
- org.eclipse.core.expressions;bundle-version="3.4.400",
- org.eclipse.help;bundle-version="3.6.0",
- org.eclipse.tcf.te.core;bundle-version="1.1.0",
- org.eclipse.tcf.te.runtime;bundle-version="1.1.0",
- org.eclipse.tcf.te.runtime.model;bundle-version="1.1.0",
- org.eclipse.tcf.te.runtime.persistence;bundle-version="1.1.0",
- org.eclipse.tcf.te.runtime.services;bundle-version="1.1.0",
- org.eclipse.tcf.te.ui;bundle-version="1.1.0",
- org.eclipse.tcf.te.ui.controls;bundle-version="1.1.0",
- org.eclipse.tcf.te.ui.forms;bundle-version="1.1.0",
- org.eclipse.tcf.te.ui.swt;bundle-version="1.1.0",
- org.eclipse.ui;bundle-version="3.8.0",
- org.eclipse.ui.forms;bundle-version="3.5.200",
- org.eclipse.ui.navigator;bundle-version="3.5.200",
- org.eclipse.ui.views.properties.tabbed;bundle-version="3.5.300"
-Bundle-RequiredExecutionEnvironment: JavaSE-1.6
-Bundle-ActivationPolicy: lazy
-Bundle-Localization: plugin
-Export-Package: org.eclipse.tcf.te.ui.views,
- org.eclipse.tcf.te.ui.views.actions,
- org.eclipse.tcf.te.ui.views.activator;x-internal:=true,
- org.eclipse.tcf.te.ui.views.categories,
- org.eclipse.tcf.te.ui.views.editor,
- org.eclipse.tcf.te.ui.views.editor.controls,
- org.eclipse.tcf.te.ui.views.editor.pages,
- org.eclipse.tcf.te.ui.views.events,
- org.eclipse.tcf.te.ui.views.expressions,
- org.eclipse.tcf.te.ui.views.extensions,
- org.eclipse.tcf.te.ui.views.handler,
- org.eclipse.tcf.te.ui.views.interfaces,
- org.eclipse.tcf.te.ui.views.interfaces.categories,
- org.eclipse.tcf.te.ui.views.interfaces.tracing;x-internal:=true,
- org.eclipse.tcf.te.ui.views.internal;x-friends:="org.eclipse.tcf.te.launch.ui",
- org.eclipse.tcf.te.ui.views.internal.adapters;x-internal:=true,
- org.eclipse.tcf.te.ui.views.internal.categories;x-internal:=true,
- org.eclipse.tcf.te.ui.views.internal.extensions,
- org.eclipse.tcf.te.ui.views.internal.preferences;x-internal:=true,
- org.eclipse.tcf.te.ui.views.internal.quickfilter;x-internal:=true,
- org.eclipse.tcf.te.ui.views.internal.services;x-internal:=true,
- org.eclipse.tcf.te.ui.views.listeners,
- org.eclipse.tcf.te.ui.views.navigator,
- org.eclipse.tcf.te.ui.views.navigator.nodes,
- org.eclipse.tcf.te.ui.views.nls;x-internal:=true,
- org.eclipse.tcf.te.ui.views.perspective
+Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %pluginName +Bundle-SymbolicName: org.eclipse.tcf.te.ui.views;singleton:=true +Bundle-Version: 1.1.0.qualifier +Bundle-Activator: org.eclipse.tcf.te.ui.views.activator.UIPlugin +Bundle-Vendor: %providerName +Require-Bundle: com.google.gson;bundle-version="2.1.0", + org.eclipse.core.runtime;bundle-version="3.8.0", + org.eclipse.core.expressions;bundle-version="3.4.400", + org.eclipse.help;bundle-version="3.6.0", + org.eclipse.tcf.te.core;bundle-version="1.1.0", + org.eclipse.tcf.te.runtime;bundle-version="1.1.0", + org.eclipse.tcf.te.runtime.model;bundle-version="1.1.0", + org.eclipse.tcf.te.runtime.persistence;bundle-version="1.1.0", + org.eclipse.tcf.te.runtime.services;bundle-version="1.1.0", + org.eclipse.tcf.te.ui;bundle-version="1.1.0", + org.eclipse.tcf.te.ui.controls;bundle-version="1.1.0", + org.eclipse.tcf.te.ui.forms;bundle-version="1.1.0", + org.eclipse.tcf.te.ui.swt;bundle-version="1.1.0", + org.eclipse.ui;bundle-version="3.8.0", + org.eclipse.ui.forms;bundle-version="3.5.200", + org.eclipse.ui.navigator;bundle-version="3.5.200", + org.eclipse.ui.views.properties.tabbed;bundle-version="3.5.300" +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-ActivationPolicy: lazy +Bundle-Localization: plugin +Export-Package: org.eclipse.tcf.te.ui.views, + org.eclipse.tcf.te.ui.views.actions, + org.eclipse.tcf.te.ui.views.activator;x-internal:=true, + org.eclipse.tcf.te.ui.views.categories, + org.eclipse.tcf.te.ui.views.controls, + org.eclipse.tcf.te.ui.views.editor, + org.eclipse.tcf.te.ui.views.editor.controls, + org.eclipse.tcf.te.ui.views.editor.pages, + org.eclipse.tcf.te.ui.views.events, + org.eclipse.tcf.te.ui.views.expressions, + org.eclipse.tcf.te.ui.views.extensions, + org.eclipse.tcf.te.ui.views.handler, + org.eclipse.tcf.te.ui.views.interfaces, + org.eclipse.tcf.te.ui.views.interfaces.categories, + org.eclipse.tcf.te.ui.views.interfaces.tracing;x-internal:=true, + org.eclipse.tcf.te.ui.views.internal;x-friends:="org.eclipse.tcf.te.launch.ui", + org.eclipse.tcf.te.ui.views.internal.adapters;x-internal:=true, + org.eclipse.tcf.te.ui.views.internal.categories;x-internal:=true, + org.eclipse.tcf.te.ui.views.internal.extensions, + org.eclipse.tcf.te.ui.views.internal.preferences;x-internal:=true, + org.eclipse.tcf.te.ui.views.internal.quickfilter;x-internal:=true, + org.eclipse.tcf.te.ui.views.internal.services;x-internal:=true, + org.eclipse.tcf.te.ui.views.listeners, + org.eclipse.tcf.te.ui.views.navigator, + org.eclipse.tcf.te.ui.views.navigator.nodes, + org.eclipse.tcf.te.ui.views.nls;x-internal:=true, + org.eclipse.tcf.te.ui.views.perspective, + org.eclipse.tcf.te.ui.views.sections diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/activator/UIPlugin.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/activator/UIPlugin.java index 533665e09..fecdd412f 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/activator/UIPlugin.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/activator/UIPlugin.java @@ -11,6 +11,7 @@ package org.eclipse.tcf.te.ui.views.activator; import java.net.URL; +import org.eclipse.core.runtime.Platform; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.resource.ImageRegistry; import org.eclipse.swt.graphics.Image; @@ -24,6 +25,7 @@ import org.eclipse.ui.IWindowListener; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; @@ -140,6 +142,11 @@ public class UIPlugin extends AbstractUIPlugin { */ @Override protected void initializeImageRegistry(ImageRegistry registry) { + Bundle bundle = Platform.getBundle("org.eclipse.ui"); //$NON-NLS-1$ + if (bundle != null) { + URL url = bundle.getEntry(ImageConsts.IMAGE_DIR_ROOT + "full/" + ImageConsts.IMAGE_DIR_ELCL + "refresh_nav.gif"); //$NON-NLS-1$ //$NON-NLS-2$ + registry.put(ImageConsts.ACTION_Refresh_Enabled, ImageDescriptor.createFromURL(url)); + } URL url = UIPlugin.getDefault().getBundle().getEntry(ImageConsts.IMAGE_DIR_ROOT + ImageConsts.IMAGE_DIR_EVIEW + "prop_ps.gif"); //$NON-NLS-1$ registry.put(ImageConsts.EDITOR, ImageDescriptor.createFromURL(url)); url = UIPlugin.getDefault().getBundle().getEntry(ImageConsts.IMAGE_DIR_ROOT + ImageConsts.IMAGE_DIR_EVIEW + "targets_view.gif"); //$NON-NLS-1$ diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/launchcontext/AbstractContextSelectorControl.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/controls/AbstractContextSelectorControl.java index 5ab4b01ab..c2a1bacb0 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/launchcontext/AbstractContextSelectorControl.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/controls/AbstractContextSelectorControl.java @@ -7,7 +7,7 @@ * Contributors: * Wind River Systems - initial API and implementation *******************************************************************************/ -package org.eclipse.tcf.te.launch.ui.tabs.launchcontext; +package org.eclipse.tcf.te.ui.views.controls; import java.util.ArrayList; import java.util.Arrays; @@ -38,7 +38,6 @@ import org.eclipse.swt.widgets.Item; import org.eclipse.swt.widgets.Tree; import org.eclipse.swt.widgets.TreeItem; import org.eclipse.swt.widgets.Widget; -import org.eclipse.tcf.te.launch.ui.nls.Messages; import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode; import org.eclipse.tcf.te.runtime.properties.PropertiesContainer; @@ -48,6 +47,7 @@ import org.eclipse.tcf.te.ui.controls.AbstractDecoratedDialogPageControl; import org.eclipse.tcf.te.ui.jface.interfaces.IValidatingContainer; import org.eclipse.tcf.te.ui.swt.SWTControlUtil; import org.eclipse.tcf.te.ui.views.interfaces.ICategory; +import org.eclipse.tcf.te.ui.views.nls.Messages; import org.eclipse.ui.dialogs.ContainerCheckedTreeViewer; import org.eclipse.ui.navigator.CommonViewerSorter; @@ -835,7 +835,7 @@ public abstract class AbstractContextSelectorControl extends AbstractDecoratedDi // if we are not valid here, it can only mean, that there is // no connectable checked. if (!valid) { - String messageId = "RemoteContextSelectorControl_error_noContextSelected"; //$NON-NLS-1$ + String messageId = "AbstractContextSelectorControl_error_noContextSelected"; //$NON-NLS-1$ if (getPropertiesContainer().isProperty(PROPERTY_MULTI_CONTEXT_SELECTOR, true)) { messageId += "_multi"; //$NON-NLS-1$ } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/interfaces/ImageConsts.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/interfaces/ImageConsts.java index c54db9908..3e8aa4fa5 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/interfaces/ImageConsts.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/interfaces/ImageConsts.java @@ -23,6 +23,12 @@ public interface ImageConsts { public final static String IMAGE_DIR_ROOT = "icons/"; //$NON-NLS-1$ /** + * The directory where to load enabled local toolbar images from, + * relative to the image root directory. + */ + public final static String IMAGE_DIR_ELCL = "elcl16/"; //$NON-NLS-1$ + + /** * The directory where to load view related images from, relative to * the image root directory. */ @@ -48,7 +54,12 @@ public interface ImageConsts { // ***** The image constants ***** - /** + /** + * The key to access the refresh action image (enabled). + */ + public static final String ACTION_Refresh_Enabled = "RefreshAction_enabled"; //$NON-NLS-1$ + + /** * The key to access the editor image. */ public static final String EDITOR = "Editor"; //$NON-NLS-1$ diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/nls/Messages.java index a6cb81811..799b05446 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/nls/Messages.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/nls/Messages.java @@ -9,6 +9,8 @@ *******************************************************************************/ package org.eclipse.tcf.te.ui.views.nls; +import java.lang.reflect.Field; + import org.eclipse.osgi.util.NLS; /** @@ -27,6 +29,42 @@ public class Messages extends NLS { NLS.initializeMessages(BUNDLE_NAME, Messages.class); } + /** + * Returns the corresponding string for the given externalized strings + * key or <code>null</code> if the key does not exist. + * + * @param key The externalized strings key or <code>null</code>. + * @return The corresponding string or <code>null</code>. + */ + public static String getString(String key) { + if (key != null) { + try { + Field field = Messages.class.getDeclaredField(key); + return (String)field.get(null); + } catch (Exception e) { /* ignored on purpose */ } + } + + return null; + } + + /** + * Returns if or if not this NLS manager contains a constant for + * the given externalized strings key. + * + * @param key The externalized strings key or <code>null</code>. + * @return <code>True</code> if a constant for the given key exists, <code>false</code> otherwise. + */ + public static boolean hasString(String key) { + if (key != null) { + try { + Field field = Messages.class.getDeclaredField(key); + return field != null; + } catch (NoSuchFieldException e) { /* ignored on purpose */ } + } + + return false; + } + // **** Declare externalized string id's down here ***** public static String NewActionProvider_NewMenu_label; @@ -66,4 +104,11 @@ public class Messages extends NLS { public static String UpdateActiveFiltersOperation_OperationName; public static String ViewsUtil_reopen_error; + + public static String AbstractContextSelectorControl_error_noContextSelected_single; + public static String AbstractContextSelectorControl_error_noContextSelected_multi; + + public static String AbstractContextSelectorSection_toolbar_refresh_tooltip; + public static String AbstractContextSelectorSection_title; + } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/nls/Messages.properties index f39f0ecd9..7d3e01360 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/nls/Messages.properties +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/nls/Messages.properties @@ -49,5 +49,10 @@ ConfigFiltersHandler_PromptMessage=Select the filters to apply (matching items w UpdateActiveExtensionsOperation_OperationName=Update CommonViewer Extensions UpdateActiveFiltersOperation_OperationName=Update CommonViewer Filters - ViewsUtil_reopen_error=Failed to reopen editor. + +AbstractContextSelectorControl_error_noContextSelected_single=Please select a remote context. +AbstractContextSelectorControl_error_noContextSelected_multi=Please select one or more remote contexts. + +AbstractContextSelectorSection_toolbar_refresh_tooltip=Refresh +AbstractContextSelectorSection_title=Remote Context diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/launchcontext/AbstractContextSelectorSection.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/sections/AbstractContextSelectorSection.java index c2c75cd83..891f883c0 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/tabs/launchcontext/AbstractContextSelectorSection.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/sections/AbstractContextSelectorSection.java @@ -7,14 +7,9 @@ * Contributors: * Wind River Systems - initial API and implementation *******************************************************************************/ -package org.eclipse.tcf.te.launch.ui.tabs.launchcontext; - -import java.util.ArrayList; -import java.util.List; +package org.eclipse.tcf.te.ui.views.sections; import org.eclipse.core.runtime.Assert; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.ToolBarManager; @@ -22,24 +17,24 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; -import org.eclipse.tcf.te.launch.core.persistence.launchcontext.LaunchContextsPersistenceDelegate; -import org.eclipse.tcf.te.launch.ui.activator.UIPlugin; -import org.eclipse.tcf.te.launch.ui.interfaces.ILaunchConfigurationTabFormPart; -import org.eclipse.tcf.te.launch.ui.internal.ImageConsts; -import org.eclipse.tcf.te.launch.ui.nls.Messages; -import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode; import org.eclipse.tcf.te.ui.forms.parts.AbstractSection; +import org.eclipse.tcf.te.ui.interfaces.data.IDataExchangeNode; +import org.eclipse.tcf.te.ui.views.activator.UIPlugin; +import org.eclipse.tcf.te.ui.views.controls.AbstractContextSelectorControl; +import org.eclipse.tcf.te.ui.views.interfaces.ImageConsts; +import org.eclipse.tcf.te.ui.views.nls.Messages; import org.eclipse.ui.forms.IManagedForm; import org.eclipse.ui.forms.widgets.ExpandableComposite; import org.eclipse.ui.forms.widgets.FormToolkit; import org.eclipse.ui.forms.widgets.Section; /** - * Abstract context selector section implementation. + * Context selector section implementation. */ -public abstract class AbstractContextSelectorSection extends AbstractSection implements ILaunchConfigurationTabFormPart { +public abstract class AbstractContextSelectorSection extends AbstractSection implements IDataExchangeNode { + // Reference to the section sub controls - /* default */ AbstractContextSelectorControl selector; + protected AbstractContextSelectorControl selector; /** * Context selector control refresh action implementation. @@ -52,7 +47,7 @@ public abstract class AbstractContextSelectorSection extends AbstractSection imp public RefreshAction() { super(null, IAction.AS_PUSH_BUTTON); setImageDescriptor(UIPlugin.getImageDescriptor(ImageConsts.ACTION_Refresh_Enabled)); - setToolTipText(Messages.ContextSelectorControl_toolbar_refresh_tooltip); + setToolTipText(Messages.AbstractContextSelectorSection_toolbar_refresh_tooltip); } /* (non-Javadoc) @@ -71,13 +66,24 @@ public abstract class AbstractContextSelectorSection extends AbstractSection imp * * @param form The parent managed form. Must not be <code>null</code>. * @param parent The parent composite. Must not be <code>null</code>. + * @param */ - public AbstractContextSelectorSection(IManagedForm form, Composite parent) { - super(form, parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); + public AbstractContextSelectorSection(IManagedForm form, Composite parent, int style) { + super(form, parent, style); getSection().setBackground(parent.getBackground()); createClient(getSection(), form.getToolkit()); } + /** + * Constructor. + * + * @param form The parent managed form. Must not be <code>null</code>. + * @param parent The parent composite. Must not be <code>null</code>. + */ + public AbstractContextSelectorSection(IManagedForm form, Composite parent) { + this(form, parent, ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED); + } + /* (non-Javadoc) * @see org.eclipse.tcf.te.ui.forms.parts.AbstractSection#createClient(org.eclipse.ui.forms.widgets.Section, org.eclipse.ui.forms.widgets.FormToolkit) */ @@ -87,7 +93,7 @@ public abstract class AbstractContextSelectorSection extends AbstractSection imp Assert.isNotNull(toolkit); // Configure the section - section.setText(Messages.ContextSelectorSection_title); + section.setText(Messages.AbstractContextSelectorSection_title); if (section.getParent().getLayout() instanceof GridLayout) { section.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); } @@ -146,55 +152,10 @@ public abstract class AbstractContextSelectorSection extends AbstractSection imp } /* (non-Javadoc) - * @see org.eclipse.tcf.te.launch.ui.interfaces.ILaunchConfigurationTabFormPart#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration) - */ - @Override - public void initializeFrom(ILaunchConfiguration configuration) { - Assert.isNotNull(configuration); - - if (selector != null) { - IModelNode[] contexts = LaunchContextsPersistenceDelegate.getLaunchContexts(configuration); - if (contexts != null && contexts.length > 0) { - // Loop the contexts and create a list of nodes - List<IModelNode> nodes = new ArrayList<IModelNode>(); - for (IModelNode node : contexts) { - if (node != null && !nodes.contains(node)) { - nodes.add(node); - } - } - if (!nodes.isEmpty()) { - selector.setCheckedModelContexts(nodes.toArray(new IModelNode[nodes.size()])); - } - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.launch.ui.interfaces.ILaunchConfigurationTabFormPart#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) - */ - @Override - public void performApply(ILaunchConfigurationWorkingCopy configuration) { - Assert.isNotNull(configuration); - - if (selector != null) { - IModelNode[] nodes = selector.getCheckedModelContexts(); - - // Write the selected contexts to the launch configuration - if (nodes != null && nodes.length > 0) { - LaunchContextsPersistenceDelegate.setLaunchContexts(configuration, nodes); - } else { - LaunchContextsPersistenceDelegate.setLaunchContexts(configuration, null); - } - } else { - LaunchContextsPersistenceDelegate.setLaunchContexts(configuration, null); - } - } - - /* (non-Javadoc) - * @see org.eclipse.tcf.te.launch.ui.interfaces.ILaunchConfigurationTabFormPart#isValid(org.eclipse.debug.core.ILaunchConfiguration) + * @see org.eclipse.tcf.te.ui.forms.parts.AbstractSection#isValid() */ @Override - public boolean isValid(ILaunchConfiguration configuration) { + public boolean isValid() { boolean valid = super.isValid(); if (valid) { diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/dialogs/AbstractSectionDialog.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/dialogs/AbstractSectionDialog.java index 1a6ab0b67..35e07c34a 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/dialogs/AbstractSectionDialog.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/dialogs/AbstractSectionDialog.java @@ -281,10 +281,12 @@ public abstract class AbstractSectionDialog extends CustomTitleAreaDialog implem public void validate() { boolean valid = true; if (sections != null) { + ValidationResult result = new ValidationResult(); for (AbstractSection section : sections) { valid &= section.isValid(); - setMessage(section.getMessage(), section.getMessageType()); + result.setResult(section); } + setMessage(result.getMessage(), result.getMessageType()); if (!isMessageSet()) { setMessage(message); } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/handler/StepperCommandHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/handler/StepperCommandHandler.java index 688912c2f..dae892fde 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/handler/StepperCommandHandler.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/handler/StepperCommandHandler.java @@ -24,8 +24,8 @@ import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; -import org.eclipse.tcf.te.runtime.properties.PropertiesContainer; import org.eclipse.tcf.te.runtime.services.ServiceManager; +import org.eclipse.tcf.te.runtime.services.interfaces.IService; import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext; import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepperService; import org.eclipse.tcf.te.runtime.stepper.job.StepperJob; @@ -39,8 +39,8 @@ import org.eclipse.ui.part.EditorPart; */ public class StepperCommandHandler extends AbstractHandler implements IExecutableExtension { - private String operation = null; - private String adaptTo = null; + protected String operation = null; + protected String adaptTo = null; /* (non-Javadoc) * @see com.windriver.te.tcf.ui.handler.AbstractAgentCommandHandler#execute(org.eclipse.core.commands.ExecutionEvent) @@ -49,6 +49,56 @@ public class StepperCommandHandler extends AbstractHandler implements IExecutabl public Object execute(ExecutionEvent event) throws ExecutionException { Assert.isNotNull(operation); + IStructuredSelection selection = getSelection(event); + + Iterator<?> iterator = selection.iterator(); + while (iterator.hasNext()) { + Object element = iterator.next(); + Object adapted = element; + if (adaptTo != null) { + Object adapter = Platform.getAdapterManager().getAdapter(element, adaptTo); + if (adapter != null) adapted = adapter; + } + IStepperService stepperService = getStepperService(adapted, operation); + if (stepperService != null) { + IStepContext stepContext = stepperService.getStepContext(adapted, operation); + String stepGroupId = stepperService.getStepGroupId(adapted, operation); + String name = stepperService.getStepGroupName(adapted, operation); + boolean isCancelable = stepperService.isCancelable(adapted, operation); + IPropertiesContainer data = stepperService.getStepData(adapted, operation); + + if (stepGroupId != null && stepContext != null) { + scheduleStepperJob(stepContext, data, stepGroupId, name, isCancelable); + } + } + } + + return null; + } + + /** + * Get the stepper service for the goven context and operation. + * @param context The context. + * @param operation The operation. + * @return The stepper service or <code>null</code>. + */ + protected IStepperService getStepperService(Object context, String operation) { + IService[] services = ServiceManager.getInstance().getServices(context, IStepperService.class, false); + IStepperService stepperService = null; + for (IService service : services) { + if (service instanceof IStepperService && ((IStepperService)service).isHandledOperation(context, operation)) { + stepperService = (IStepperService)service; + } + } + return stepperService; + } + + /** + * Get the selection for the handler execution. + * @param event The event. + * @return The selection. + */ + protected IStructuredSelection getSelection(ExecutionEvent event) { // Get the active part IWorkbenchPart part = HandlerUtil.getActivePart(event); // Get the current selection @@ -64,38 +114,25 @@ public class StepperCommandHandler extends AbstractHandler implements IExecutabl } } - // If the selection is not empty, iterate over the selection and execute - // the operation for each peer model node in the selection. - if (selection instanceof IStructuredSelection && !selection.isEmpty()) { - Iterator<?> iterator = ((IStructuredSelection)selection).iterator(); - while (iterator.hasNext()) { - Object element = iterator.next(); - Object adapted = element; - if (adaptTo != null) { - Object adapter = Platform.getAdapterManager().getAdapter(element, adaptTo); - if (adapter != null) adapted = adapter; - } - IStepperService service = ServiceManager.getInstance().getService(adapted, IStepperService.class); - if (service != null) { - String stepGroupId = service.getStepGroupId(adapted, operation); - IStepContext stepContext = service.getStepContext(adapted, operation); - String name = service.getStepGroupName(adapted, operation); - - if (stepGroupId != null && stepContext != null) { - IPropertiesContainer data = new PropertiesContainer(); - StepperJob job = new StepperJob(name != null ? name : "", //$NON-NLS-1$ - stepContext, - data, - stepGroupId, - operation, - service.isCancelable(adapted, operation)); - job.schedule(); - } - } - } - } + return (selection instanceof IStructuredSelection && !selection.isEmpty()) ? (IStructuredSelection)selection : new StructuredSelection(); + } - return null; + /** + * Schedule the stepper job. + * @param stepContext The step context. + * @param data The execution data. + * @param stepGroupId The step group id to execute. + * @param name The job name. + * @param isCancelable <code>true</code> if the job should be cancelable. + */ + protected void scheduleStepperJob(IStepContext stepContext, IPropertiesContainer data, String stepGroupId, String name, boolean isCancelable) { + StepperJob job = new StepperJob(name != null ? name : "", //$NON-NLS-1$ + stepContext, + data, + stepGroupId, + operation, + isCancelable); + job.schedule(); } /* (non-Javadoc) |