Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/actions/NewActionProvider.java318
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/activator/UIPlugin.java352
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/categories/Category.java418
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/Editor.java1060
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/EditorEventListener.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/EditorInput.java388
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/controls/ButtonPanelControl.java398
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/AbstractCustomFormToolkitEditorPage.java682
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/AbstractEditorPage.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/TreeViewerExplorerEditorPage.java1014
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/events/AbstractEventListener.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/events/ViewerContentChangeEvent.java168
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/expressions/PropertyTester.java96
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/expressions/SelectionSourceProvider.java414
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/extensions/EditorPageBindingExtensionPointManager.java388
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/extensions/EditorPageExtensionPointManager.java204
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/extensions/LabelProviderDelegateExtensionPointManager.java262
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/FilterMRUContribution.java216
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/NewWizardHandler.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/OpenEditorHandler.java226
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/ShowInSystemManagementHandler.java230
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/interfaces/ICategory.java112
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/interfaces/IEditorPage.java40
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/interfaces/IEditorSaveAsAdapter.java68
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/interfaces/IRoot.java38
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/interfaces/IUIConstants.java120
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/interfaces/ImageConsts.java140
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/interfaces/categories/ICategoryManager.java180
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/View.java510
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/ViewViewer.java306
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/adapters/EditorAdapterFactory.java114
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/categories/AbstractCategoryContributionItem.java610
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/categories/CategoryFactory.java98
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/categories/CategoryManager.java728
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/categories/CategoryPropertyTester.java352
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/preferences/IPreferenceKeys.java100
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/preferences/PreferencesInitializer.java92
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/quickfilter/EditorQuickFilterTester.java128
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/services/MenuService.java78
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/listeners/WorkbenchWindowListener.java72
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/navigator/LabelProviderDelegate.java100
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/navigator/ViewerContentProvider.java252
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/navigator/nodes/NewWizardNode.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/nls/Messages.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/nls/Messages.properties2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/perspective/PerspectiveFactory.java154
46 files changed, 5620 insertions, 5620 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/actions/NewActionProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/actions/NewActionProvider.java
index d39068801..526961cb0 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/actions/NewActionProvider.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/actions/NewActionProvider.java
@@ -1,159 +1,159 @@
-/*******************************************************************************
- * 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
- * Tobias Schwarz (Wind River) - [368243] [UI] Allow dynamic new wizard contributions
- *******************************************************************************/
-package org.eclipse.tcf.te.ui.views.actions;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.tcf.te.ui.help.IContextHelpIds;
-import org.eclipse.tcf.te.ui.interfaces.ImageConsts;
-import org.eclipse.tcf.te.ui.views.interfaces.IUIConstants;
-import org.eclipse.tcf.te.ui.views.nls.Messages;
-import org.eclipse.tcf.te.ui.wizards.newWizard.NewWizardRegistry;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.internal.actions.CommandAction;
-import org.eclipse.ui.internal.navigator.wizards.WizardShortcutAction;
-import org.eclipse.ui.navigator.CommonActionProvider;
-import org.eclipse.ui.navigator.ICommonActionExtensionSite;
-import org.eclipse.ui.navigator.ICommonMenuConstants;
-import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
-import org.eclipse.ui.navigator.WizardActionGroup;
-import org.eclipse.ui.wizards.IWizardDescriptor;
-
-/**
- * Action provider implementation providing the "New >" content menu
- * content.
- */
-@SuppressWarnings("restriction")
-public class NewActionProvider extends CommonActionProvider {
- // Reference to the action showing the "Other..." dialog (context menu)
- private CommandAction newWizardCommandAction = null;
- // Reference to the action showing the "Other..." dialog (toolbar)
- private CommandAction newWizardCommandActionToolbar = null;
- // Reference to the action group managing the context sensitive new wizards
- private WizardActionGroup newWizardActionGroup = null;
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.navigator.CommonActionProvider#init(org.eclipse.ui.navigator.ICommonActionExtensionSite)
- */
- @Override
- public void init(ICommonActionExtensionSite site) {
- super.init(site);
-
- if (site.getViewSite() instanceof ICommonViewerWorkbenchSite) {
- // To initialize the actions, the workbench window instance is required
- IWorkbenchWindow window = ((ICommonViewerWorkbenchSite)site.getViewSite()).getWorkbenchWindow();
- // Initialize the actions
- newWizardCommandAction = new CommandAction(window, "org.eclipse.tcf.te.ui.command.newWizards"); //$NON-NLS-1$
- newWizardCommandAction.setImageDescriptor(null);
- newWizardCommandAction.setDisabledImageDescriptor(null);
- newWizardCommandAction.setText(Messages.NewActionProvider_NewWizardCommandAction_label);
- newWizardCommandAction.setToolTipText(Messages.NewActionProvider_NewWizardCommandAction_tooltip);
- window.getWorkbench().getHelpSystem().setHelp(newWizardCommandAction, IContextHelpIds.NEW_TARGET_WIZARD);
-
- newWizardCommandActionToolbar = new CommandAction(window, "org.eclipse.tcf.te.ui.command.newWizards"); //$NON-NLS-1$
- newWizardCommandActionToolbar.setImageDescriptor(org.eclipse.tcf.te.ui.activator.UIPlugin.getImageDescriptor(ImageConsts.NEW_TARGET_WIZARD_ENABLED));
- newWizardCommandActionToolbar.setDisabledImageDescriptor(org.eclipse.tcf.te.ui.activator.UIPlugin.getImageDescriptor(ImageConsts.NEW_TARGET_WIZARD_DISABLED));
- newWizardCommandActionToolbar.setText(Messages.NewActionProvider_NewWizardCommandAction_label);
- newWizardCommandActionToolbar.setToolTipText(Messages.NewActionProvider_NewWizardCommandAction_tooltip);
- window.getWorkbench().getHelpSystem().setHelp(newWizardCommandActionToolbar, IContextHelpIds.NEW_TARGET_WIZARD);
-
- newWizardActionGroup = new WizardActionGroup(window,
- NewWizardRegistry.getInstance(),
- WizardActionGroup.TYPE_NEW,
- site.getContentService());
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.actions.ActionGroup#dispose()
- */
- @Override
- public void dispose() {
- if (newWizardCommandAction != null) {
- newWizardCommandAction.dispose();
- newWizardCommandAction = null;
- }
- if (newWizardActionGroup != null) {
- newWizardActionGroup.dispose();
- newWizardActionGroup = null;
- }
- super.dispose();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.actions.ActionGroup#fillContextMenu(org.eclipse.jface.action.IMenuManager)
- */
- @Override
- public void fillContextMenu(IMenuManager menu) {
- // If none of the actions got created, there is nothing to do here
- if (newWizardCommandAction == null && newWizardActionGroup == null) {
- return;
- }
-
- // Create the new sub menu
- IMenuManager newMenu = new MenuManager(Messages.NewActionProvider_NewMenu_label,
- org.eclipse.tcf.te.ui.activator.UIPlugin.getImageDescriptor(ImageConsts.NEW_TARGET_WIZARD_ENABLED),
- IUIConstants.ID_EXPLORER + ".menu.new"); //$NON-NLS-1$
-
- // Add the context sensitive wizards (commonWizard element)
- if (newWizardActionGroup != null) {
- newWizardActionGroup.setContext(getContext());
- newWizardActionGroup.fillContextMenu(newMenu);
- }
-
-
- IWorkbenchWindow window = ((ICommonViewerWorkbenchSite)getActionSite().getViewSite()).getWorkbenchWindow();
- for (IWizardDescriptor wizard : NewWizardRegistry.getInstance().getCommonWizards(getContext().getSelection())) {
- IAction action = new WizardShortcutAction(window, wizard);
- newMenu.add(action);
- }
-
- // Add the standard additions marker
- newMenu.add(new Separator(ICommonMenuConstants.GROUP_ADDITIONS));
-
- // Add the "Other..." dialog action
- if (newWizardCommandAction != null) {
- newMenu.add(new Separator());
- newMenu.add(newWizardCommandAction);
- }
-
- // The menu will be appended after the GROUP_NEW group.
- menu.insertAfter(ICommonMenuConstants.GROUP_NEW, newMenu);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.actions.ActionGroup#fillActionBars(org.eclipse.ui.IActionBars)
- */
- @Override
- public void fillActionBars(IActionBars actionBars) {
- // If none of the actions got created, there is nothing to do here
- if (newWizardCommandActionToolbar == null) {
- return;
- }
-
- // Get the toolbar manager
- IToolBarManager toolbar = actionBars.getToolBarManager();
-
- // Check for the newWizard action in the toolbar. If found,
- // drop out immediately to avoid adding the items to the toolbar
- // again and again
- if (toolbar.find("org.eclipse.tcf.te.ui.command.newWizards") != null) { //$NON-NLS-1$
- return;
- }
-
- // Add the items to the toolbar
- toolbar.insertAfter(ICommonMenuConstants.GROUP_NEW, newWizardCommandActionToolbar);
- }
-}
+/*******************************************************************************
+ * 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
+ * Tobias Schwarz (Wind River) - [368243] [UI] Allow dynamic new wizard contributions
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.views.actions;
+
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.tcf.te.ui.help.IContextHelpIds;
+import org.eclipse.tcf.te.ui.interfaces.ImageConsts;
+import org.eclipse.tcf.te.ui.views.interfaces.IUIConstants;
+import org.eclipse.tcf.te.ui.views.nls.Messages;
+import org.eclipse.tcf.te.ui.wizards.newWizard.NewWizardRegistry;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.internal.actions.CommandAction;
+import org.eclipse.ui.internal.navigator.wizards.WizardShortcutAction;
+import org.eclipse.ui.navigator.CommonActionProvider;
+import org.eclipse.ui.navigator.ICommonActionExtensionSite;
+import org.eclipse.ui.navigator.ICommonMenuConstants;
+import org.eclipse.ui.navigator.ICommonViewerWorkbenchSite;
+import org.eclipse.ui.navigator.WizardActionGroup;
+import org.eclipse.ui.wizards.IWizardDescriptor;
+
+/**
+ * Action provider implementation providing the "New >" content menu
+ * content.
+ */
+@SuppressWarnings("restriction")
+public class NewActionProvider extends CommonActionProvider {
+ // Reference to the action showing the "Other..." dialog (context menu)
+ private CommandAction newWizardCommandAction = null;
+ // Reference to the action showing the "Other..." dialog (toolbar)
+ private CommandAction newWizardCommandActionToolbar = null;
+ // Reference to the action group managing the context sensitive new wizards
+ private WizardActionGroup newWizardActionGroup = null;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.CommonActionProvider#init(org.eclipse.ui.navigator.ICommonActionExtensionSite)
+ */
+ @Override
+ public void init(ICommonActionExtensionSite site) {
+ super.init(site);
+
+ if (site.getViewSite() instanceof ICommonViewerWorkbenchSite) {
+ // To initialize the actions, the workbench window instance is required
+ IWorkbenchWindow window = ((ICommonViewerWorkbenchSite)site.getViewSite()).getWorkbenchWindow();
+ // Initialize the actions
+ newWizardCommandAction = new CommandAction(window, "org.eclipse.tcf.te.ui.command.newWizards"); //$NON-NLS-1$
+ newWizardCommandAction.setImageDescriptor(null);
+ newWizardCommandAction.setDisabledImageDescriptor(null);
+ newWizardCommandAction.setText(Messages.NewActionProvider_NewWizardCommandAction_label);
+ newWizardCommandAction.setToolTipText(Messages.NewActionProvider_NewWizardCommandAction_tooltip);
+ window.getWorkbench().getHelpSystem().setHelp(newWizardCommandAction, IContextHelpIds.NEW_TARGET_WIZARD);
+
+ newWizardCommandActionToolbar = new CommandAction(window, "org.eclipse.tcf.te.ui.command.newWizards"); //$NON-NLS-1$
+ newWizardCommandActionToolbar.setImageDescriptor(org.eclipse.tcf.te.ui.activator.UIPlugin.getImageDescriptor(ImageConsts.NEW_TARGET_WIZARD_ENABLED));
+ newWizardCommandActionToolbar.setDisabledImageDescriptor(org.eclipse.tcf.te.ui.activator.UIPlugin.getImageDescriptor(ImageConsts.NEW_TARGET_WIZARD_DISABLED));
+ newWizardCommandActionToolbar.setText(Messages.NewActionProvider_NewWizardCommandAction_label);
+ newWizardCommandActionToolbar.setToolTipText(Messages.NewActionProvider_NewWizardCommandAction_tooltip);
+ window.getWorkbench().getHelpSystem().setHelp(newWizardCommandActionToolbar, IContextHelpIds.NEW_TARGET_WIZARD);
+
+ newWizardActionGroup = new WizardActionGroup(window,
+ NewWizardRegistry.getInstance(),
+ WizardActionGroup.TYPE_NEW,
+ site.getContentService());
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.actions.ActionGroup#dispose()
+ */
+ @Override
+ public void dispose() {
+ if (newWizardCommandAction != null) {
+ newWizardCommandAction.dispose();
+ newWizardCommandAction = null;
+ }
+ if (newWizardActionGroup != null) {
+ newWizardActionGroup.dispose();
+ newWizardActionGroup = null;
+ }
+ super.dispose();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.actions.ActionGroup#fillContextMenu(org.eclipse.jface.action.IMenuManager)
+ */
+ @Override
+ public void fillContextMenu(IMenuManager menu) {
+ // If none of the actions got created, there is nothing to do here
+ if (newWizardCommandAction == null && newWizardActionGroup == null) {
+ return;
+ }
+
+ // Create the new sub menu
+ IMenuManager newMenu = new MenuManager(Messages.NewActionProvider_NewMenu_label,
+ org.eclipse.tcf.te.ui.activator.UIPlugin.getImageDescriptor(ImageConsts.NEW_TARGET_WIZARD_ENABLED),
+ IUIConstants.ID_EXPLORER + ".menu.new"); //$NON-NLS-1$
+
+ // Add the context sensitive wizards (commonWizard element)
+ if (newWizardActionGroup != null) {
+ newWizardActionGroup.setContext(getContext());
+ newWizardActionGroup.fillContextMenu(newMenu);
+ }
+
+
+ IWorkbenchWindow window = ((ICommonViewerWorkbenchSite)getActionSite().getViewSite()).getWorkbenchWindow();
+ for (IWizardDescriptor wizard : NewWizardRegistry.getInstance().getCommonWizards(getContext().getSelection())) {
+ IAction action = new WizardShortcutAction(window, wizard);
+ newMenu.add(action);
+ }
+
+ // Add the standard additions marker
+ newMenu.add(new Separator(ICommonMenuConstants.GROUP_ADDITIONS));
+
+ // Add the "Other..." dialog action
+ if (newWizardCommandAction != null) {
+ newMenu.add(new Separator());
+ newMenu.add(newWizardCommandAction);
+ }
+
+ // The menu will be appended after the GROUP_NEW group.
+ menu.insertAfter(ICommonMenuConstants.GROUP_NEW, newMenu);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.actions.ActionGroup#fillActionBars(org.eclipse.ui.IActionBars)
+ */
+ @Override
+ public void fillActionBars(IActionBars actionBars) {
+ // If none of the actions got created, there is nothing to do here
+ if (newWizardCommandActionToolbar == null) {
+ return;
+ }
+
+ // Get the toolbar manager
+ IToolBarManager toolbar = actionBars.getToolBarManager();
+
+ // Check for the newWizard action in the toolbar. If found,
+ // drop out immediately to avoid adding the items to the toolbar
+ // again and again
+ if (toolbar.find("org.eclipse.tcf.te.ui.command.newWizards") != null) { //$NON-NLS-1$
+ return;
+ }
+
+ // Add the items to the toolbar
+ toolbar.insertAfter(ICommonMenuConstants.GROUP_NEW, newWizardCommandActionToolbar);
+ }
+}
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 f04a85f86..533665e09 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
@@ -1,176 +1,176 @@
-/*******************************************************************************
- * 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.ui.views.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.swt.widgets.Display;
-import org.eclipse.tcf.te.runtime.preferences.ScopedEclipsePreferences;
-import org.eclipse.tcf.te.runtime.tracing.TraceHandler;
-import org.eclipse.tcf.te.ui.views.Managers;
-import org.eclipse.tcf.te.ui.views.interfaces.ImageConsts;
-import org.eclipse.tcf.te.ui.views.listeners.WorkbenchWindowListener;
-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.BundleContext;
-
-
-/**
- * The activator class controls the plug-in life cycle
- */
-public class UIPlugin extends AbstractUIPlugin {
- // The shared instance
- private static UIPlugin plugin;
- // The scoped preferences instance
- private static volatile ScopedEclipsePreferences scopedPreferences;
- // The trace handler instance
- private static volatile TraceHandler traceHandler;
-
- // The global window listener instance
- private IWindowListener windowListener;
-
- /**
- * 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.ui.views"; //$NON-NLS-1$
- }
-
- /**
- * Return the scoped preferences for this plugin.
- */
- public static ScopedEclipsePreferences getScopedPreferences() {
- if (scopedPreferences == null) {
- scopedPreferences = new ScopedEclipsePreferences(getUniqueIdentifier());
- }
- return scopedPreferences;
- }
-
- /**
- * 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;
-
- 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 (windowListener != null && PlatformUI.getWorkbench() != null) {
- PlatformUI.getWorkbench().removeWindowListener(windowListener);
- windowListener = null;
- }
-
- Managers.dispose();
-
- plugin = null;
- scopedPreferences = 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 = 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$
- registry.put(ImageConsts.VIEW, ImageDescriptor.createFromURL(url));
-
- url = UIPlugin.getDefault().getBundle().getEntry(ImageConsts.IMAGE_DIR_ROOT + ImageConsts.IMAGE_DIR_ETOOL + "help.gif"); //$NON-NLS-1$
- registry.put(ImageConsts.HELP, ImageDescriptor.createFromURL(url));
-
- url = UIPlugin.getDefault().getBundle().getEntry(ImageConsts.IMAGE_DIR_ROOT + ImageConsts.IMAGE_DIR_OBJ + "favorites.gif"); //$NON-NLS-1$
- registry.put(ImageConsts.FAVORITES, 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);
- }
-}
+/*******************************************************************************
+ * 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.ui.views.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.swt.widgets.Display;
+import org.eclipse.tcf.te.runtime.preferences.ScopedEclipsePreferences;
+import org.eclipse.tcf.te.runtime.tracing.TraceHandler;
+import org.eclipse.tcf.te.ui.views.Managers;
+import org.eclipse.tcf.te.ui.views.interfaces.ImageConsts;
+import org.eclipse.tcf.te.ui.views.listeners.WorkbenchWindowListener;
+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.BundleContext;
+
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class UIPlugin extends AbstractUIPlugin {
+ // The shared instance
+ private static UIPlugin plugin;
+ // The scoped preferences instance
+ private static volatile ScopedEclipsePreferences scopedPreferences;
+ // The trace handler instance
+ private static volatile TraceHandler traceHandler;
+
+ // The global window listener instance
+ private IWindowListener windowListener;
+
+ /**
+ * 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.ui.views"; //$NON-NLS-1$
+ }
+
+ /**
+ * Return the scoped preferences for this plugin.
+ */
+ public static ScopedEclipsePreferences getScopedPreferences() {
+ if (scopedPreferences == null) {
+ scopedPreferences = new ScopedEclipsePreferences(getUniqueIdentifier());
+ }
+ return scopedPreferences;
+ }
+
+ /**
+ * 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;
+
+ 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 (windowListener != null && PlatformUI.getWorkbench() != null) {
+ PlatformUI.getWorkbench().removeWindowListener(windowListener);
+ windowListener = null;
+ }
+
+ Managers.dispose();
+
+ plugin = null;
+ scopedPreferences = 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 = 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$
+ registry.put(ImageConsts.VIEW, ImageDescriptor.createFromURL(url));
+
+ url = UIPlugin.getDefault().getBundle().getEntry(ImageConsts.IMAGE_DIR_ROOT + ImageConsts.IMAGE_DIR_ETOOL + "help.gif"); //$NON-NLS-1$
+ registry.put(ImageConsts.HELP, ImageDescriptor.createFromURL(url));
+
+ url = UIPlugin.getDefault().getBundle().getEntry(ImageConsts.IMAGE_DIR_ROOT + ImageConsts.IMAGE_DIR_OBJ + "favorites.gif"); //$NON-NLS-1$
+ registry.put(ImageConsts.FAVORITES, 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);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/categories/Category.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/categories/Category.java
index 4961e5da1..740b50410 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/categories/Category.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/categories/Category.java
@@ -1,209 +1,209 @@
-/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.ui.views.categories;
-
-import org.eclipse.core.expressions.EvaluationContext;
-import org.eclipse.core.expressions.EvaluationResult;
-import org.eclipse.core.expressions.Expression;
-import org.eclipse.core.expressions.ExpressionConverter;
-import org.eclipse.core.expressions.IEvaluationContext;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.tcf.te.runtime.extensions.ExecutableExtension;
-import org.eclipse.tcf.te.runtime.interfaces.IDisposable;
-import org.eclipse.tcf.te.ui.views.Managers;
-import org.eclipse.tcf.te.ui.views.activator.UIPlugin;
-import org.eclipse.tcf.te.ui.views.interfaces.ICategory;
-import org.eclipse.tcf.te.ui.views.interfaces.categories.ICategorizable;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IPersistableElement;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.handlers.IHandlerService;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-
-/**
- * Default category implementation.
- */
-public class Category extends ExecutableExtension implements ICategory, IDisposable, IPersistableElement {
- // The category image / image descriptor
- private ImageDescriptor descriptor = null;
- private Image image = null;
- // The sorting rank
- private int rank = -1;
- // The converted expression
- private Expression expression;
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.extensions.ExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement, java.lang.String, java.lang.Object)
- */
- @Override
- public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
- super.setInitializationData(config, propertyName, data);
-
- // Read the icon attribute and create the image
- String attrIcon = config.getAttribute("icon");//$NON-NLS-1$
- if (attrIcon != null) {
- descriptor = AbstractUIPlugin.imageDescriptorFromPlugin(config.getNamespaceIdentifier(), attrIcon);
- if (descriptor != null) {
- image = JFaceResources.getResources().createImageWithDefault(descriptor);
- }
- }
-
- // Read the rank attribute
- String attrRank = config.getAttribute("rank"); //$NON-NLS-1$
- if (attrRank != null) {
- try {
- rank = Integer.valueOf(attrRank).intValue();
- } catch (NumberFormatException e) { /* ignored on purpose */ }
- }
-
- // Read the "enablement" sub element of the extension
- IConfigurationElement[] children = config.getChildren("enablement"); //$NON-NLS-1$
- // Only one "enablement" element is expected
- if (children != null && children.length > 0) {
- expression = ExpressionConverter.getDefault().perform(children[0]);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class)
- */
- @Override
- public Object getAdapter(Class adapter) {
- if(adapter == IPersistableElement.class) {
- return this;
- }
- return super.getAdapter(adapter);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.IPersistable#saveState(org.eclipse.ui.IMemento)
- */
- @Override
- public void saveState(IMemento memento) {
- memento.putString("id", this.getId()); //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.IPersistableElement#getFactoryId()
- */
- @Override
- public String getFactoryId() {
- return "org.eclipse.tcf.te.ui.views.categoryFactory"; //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.interfaces.IDisposable#dispose()
- */
- @Override
- public void dispose() {
- if (descriptor != null) {
- JFaceResources.getResources().destroyImage(descriptor);
- descriptor = null;
- }
- image = null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.views.interfaces.ICategory#getImage()
- */
- @Override
- public Image getImage() {
- return image;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.views.interfaces.ICategory#getChildren()
- */
- @Override
- public Object[] getChildren() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.views.interfaces.ICategory#getRank()
- */
- @Override
- public int getRank() {
- return rank;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.views.interfaces.ICategory#belongsTo(java.lang.Object)
- */
- @Override
- public boolean belongsTo(Object element) {
- ICategorizable categorizable = null;
- if (element instanceof IAdaptable) {
- categorizable = (ICategorizable)((IAdaptable)element).getAdapter(ICategorizable.class);
- }
- if (categorizable == null) {
- categorizable = (ICategorizable)Platform.getAdapterManager().getAdapter(element, ICategorizable.class);
- }
- return categorizable != null ? Managers.getCategoryManager().belongsTo(getId(), categorizable.getId()) : false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.views.interfaces.ICategory#isEnabled()
- */
- @Override
- public boolean isEnabled() {
- // The category is enabled if no "enablement" expression is found
- boolean enabled = true;
-
- if (expression != null) {
- // Get the handler service
- IHandlerService handlerSvc = (IHandlerService)PlatformUI.getWorkbench().getService(IHandlerService.class);
- Assert.isNotNull(handlerSvc);
-
- // Get the current state
- IEvaluationContext currentState = handlerSvc.getCurrentState();
-
- // Construct the evaluation context to pass to the expression
- // The expressions default variable is the category itself.
- IEvaluationContext ctx = new EvaluationContext(currentState, this);
- try {
- enabled = expression.evaluate(ctx).equals(EvaluationResult.TRUE);
- } catch (CoreException e) {
- IStatus status = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(), e.getLocalizedMessage(), e);
- UIPlugin.getDefault().getLog().log(status);
- }
- }
-
- return enabled;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- @Override
- public String toString() {
- StringBuffer buffer = new StringBuffer(getLabel());
- buffer.append(" ["); //$NON-NLS-1$
- buffer.append(getId());
- buffer.append("] {rank="); //$NON-NLS-1$
- buffer.append(getRank());
- buffer.append(", enabled="); //$NON-NLS-1$
- buffer.append(isEnabled());
- buffer.append("}"); //$NON-NLS-1$
- return buffer.toString();
- }
-}
+/*******************************************************************************
+ * 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.ui.views.categories;
+
+import org.eclipse.core.expressions.EvaluationContext;
+import org.eclipse.core.expressions.EvaluationResult;
+import org.eclipse.core.expressions.Expression;
+import org.eclipse.core.expressions.ExpressionConverter;
+import org.eclipse.core.expressions.IEvaluationContext;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.tcf.te.runtime.extensions.ExecutableExtension;
+import org.eclipse.tcf.te.runtime.interfaces.IDisposable;
+import org.eclipse.tcf.te.ui.views.Managers;
+import org.eclipse.tcf.te.ui.views.activator.UIPlugin;
+import org.eclipse.tcf.te.ui.views.interfaces.ICategory;
+import org.eclipse.tcf.te.ui.views.interfaces.categories.ICategorizable;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IPersistableElement;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.handlers.IHandlerService;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+
+/**
+ * Default category implementation.
+ */
+public class Category extends ExecutableExtension implements ICategory, IDisposable, IPersistableElement {
+ // The category image / image descriptor
+ private ImageDescriptor descriptor = null;
+ private Image image = null;
+ // The sorting rank
+ private int rank = -1;
+ // The converted expression
+ private Expression expression;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.extensions.ExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement, java.lang.String, java.lang.Object)
+ */
+ @Override
+ public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
+ super.setInitializationData(config, propertyName, data);
+
+ // Read the icon attribute and create the image
+ String attrIcon = config.getAttribute("icon");//$NON-NLS-1$
+ if (attrIcon != null) {
+ descriptor = AbstractUIPlugin.imageDescriptorFromPlugin(config.getNamespaceIdentifier(), attrIcon);
+ if (descriptor != null) {
+ image = JFaceResources.getResources().createImageWithDefault(descriptor);
+ }
+ }
+
+ // Read the rank attribute
+ String attrRank = config.getAttribute("rank"); //$NON-NLS-1$
+ if (attrRank != null) {
+ try {
+ rank = Integer.valueOf(attrRank).intValue();
+ } catch (NumberFormatException e) { /* ignored on purpose */ }
+ }
+
+ // Read the "enablement" sub element of the extension
+ IConfigurationElement[] children = config.getChildren("enablement"); //$NON-NLS-1$
+ // Only one "enablement" element is expected
+ if (children != null && children.length > 0) {
+ expression = ExpressionConverter.getDefault().perform(children[0]);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.PlatformObject#getAdapter(java.lang.Class)
+ */
+ @Override
+ public Object getAdapter(Class adapter) {
+ if(adapter == IPersistableElement.class) {
+ return this;
+ }
+ return super.getAdapter(adapter);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.IPersistable#saveState(org.eclipse.ui.IMemento)
+ */
+ @Override
+ public void saveState(IMemento memento) {
+ memento.putString("id", this.getId()); //$NON-NLS-1$
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.IPersistableElement#getFactoryId()
+ */
+ @Override
+ public String getFactoryId() {
+ return "org.eclipse.tcf.te.ui.views.categoryFactory"; //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.interfaces.IDisposable#dispose()
+ */
+ @Override
+ public void dispose() {
+ if (descriptor != null) {
+ JFaceResources.getResources().destroyImage(descriptor);
+ descriptor = null;
+ }
+ image = null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.views.interfaces.ICategory#getImage()
+ */
+ @Override
+ public Image getImage() {
+ return image;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.views.interfaces.ICategory#getChildren()
+ */
+ @Override
+ public Object[] getChildren() {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.views.interfaces.ICategory#getRank()
+ */
+ @Override
+ public int getRank() {
+ return rank;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.views.interfaces.ICategory#belongsTo(java.lang.Object)
+ */
+ @Override
+ public boolean belongsTo(Object element) {
+ ICategorizable categorizable = null;
+ if (element instanceof IAdaptable) {
+ categorizable = (ICategorizable)((IAdaptable)element).getAdapter(ICategorizable.class);
+ }
+ if (categorizable == null) {
+ categorizable = (ICategorizable)Platform.getAdapterManager().getAdapter(element, ICategorizable.class);
+ }
+ return categorizable != null ? Managers.getCategoryManager().belongsTo(getId(), categorizable.getId()) : false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.views.interfaces.ICategory#isEnabled()
+ */
+ @Override
+ public boolean isEnabled() {
+ // The category is enabled if no "enablement" expression is found
+ boolean enabled = true;
+
+ if (expression != null) {
+ // Get the handler service
+ IHandlerService handlerSvc = (IHandlerService)PlatformUI.getWorkbench().getService(IHandlerService.class);
+ Assert.isNotNull(handlerSvc);
+
+ // Get the current state
+ IEvaluationContext currentState = handlerSvc.getCurrentState();
+
+ // Construct the evaluation context to pass to the expression
+ // The expressions default variable is the category itself.
+ IEvaluationContext ctx = new EvaluationContext(currentState, this);
+ try {
+ enabled = expression.evaluate(ctx).equals(EvaluationResult.TRUE);
+ } catch (CoreException e) {
+ IStatus status = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(), e.getLocalizedMessage(), e);
+ UIPlugin.getDefault().getLog().log(status);
+ }
+ }
+
+ return enabled;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ @Override
+ public String toString() {
+ StringBuffer buffer = new StringBuffer(getLabel());
+ buffer.append(" ["); //$NON-NLS-1$
+ buffer.append(getId());
+ buffer.append("] {rank="); //$NON-NLS-1$
+ buffer.append(getRank());
+ buffer.append(", enabled="); //$NON-NLS-1$
+ buffer.append(isEnabled());
+ buffer.append("}"); //$NON-NLS-1$
+ return buffer.toString();
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/Editor.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/Editor.java
index d86ab77cd..1c7922127 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/Editor.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/Editor.java
@@ -1,530 +1,530 @@
-/*******************************************************************************
- * 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.ui.views.editor;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.tcf.te.ui.views.editor.pages.AbstractEditorPage;
-import org.eclipse.tcf.te.ui.views.extensions.EditorPageBinding;
-import org.eclipse.tcf.te.ui.views.extensions.EditorPageBindingExtensionPointManager;
-import org.eclipse.tcf.te.ui.views.extensions.EditorPageExtensionPointManager;
-import org.eclipse.tcf.te.ui.views.interfaces.IEditorPage;
-import org.eclipse.tcf.te.ui.views.interfaces.IEditorSaveAsAdapter;
-import org.eclipse.tcf.te.ui.views.interfaces.IUIConstants;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IPersistable;
-import org.eclipse.ui.IPersistableEditor;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.XMLMemento;
-import org.eclipse.ui.forms.editor.FormEditor;
-import org.eclipse.ui.forms.editor.IFormPage;
-import org.eclipse.ui.internal.part.NullEditorInput;
-import org.eclipse.ui.views.properties.IPropertySheetPage;
-import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;
-import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
-
-
-/**
- * Editor implementation.
- */
-@SuppressWarnings("restriction")
-public final class Editor extends FormEditor implements IPersistableEditor, ITabbedPropertySheetPageContributor {
-
- // The reference to an memento to restore once the editor got activated
- private IMemento mementoToRestore;
-
- // The editor event listener instance
- private EditorEventListener listener;
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.forms.editor.FormEditor#addPages()
- */
- @Override
- protected void addPages() {
- // Read extension point and add the contributed pages.
- IEditorInput input = getEditorInput();
- // Get all applicable editor page bindings
- EditorPageBinding[] bindings = EditorPageBindingExtensionPointManager.getInstance().getApplicableEditorPageBindings(input);
- for (EditorPageBinding binding : bindings) {
- processPageBinding(binding);
- }
-
- if (mementoToRestore != null) {
- // Loop over all registered pages and pass on the editor specific memento
- // to the pages which implements IPersistableEditor as well
- for (Object page : pages) {
- if (page instanceof IPersistableEditor) {
- ((IPersistableEditor)page).restoreState(mementoToRestore);
- }
- }
- mementoToRestore = null;
- }
- }
-
- /**
- * Override this method to delegate the setFocus to
- * the active form page.
- */
- @Override
- public void setFocus() {
- IFormPage fpage = getActivePageInstance();
- if(fpage != null) {
- fpage.setFocus();
- }
- else {
- super.setFocus();
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.forms.editor.FormEditor#getActivePageInstance()
- */
- @Override
- public IFormPage getActivePageInstance() {
- int index = getActivePage();
- if (index != -1) {
- return getPage(index);
- }
- return super.getActivePageInstance();
- }
-
- /**
- * Returns the page which has the specified index.
- *
- * @param index The page's index.
- * @return The page object or null if it does not exists.
- */
- private IFormPage getPage(int index) {
- for (int i = 0; i < pages.size(); i++) {
- Object page = pages.get(i);
- if (page instanceof IFormPage) {
- IFormPage fpage = (IFormPage) page;
- if (fpage.getIndex() == index) {
- return fpage;
- }
- }
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.forms.editor.FormEditor#setActivePage(int)
- */
- @Override
- public void setActivePage(int pageIndex) {
- if (getPage(pageIndex) != null) {
- super.setActivePage(pageIndex);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.part.MultiPageEditorPart#getEditor(int)
- */
- @Override
- protected IEditorPart getEditor(int pageIndex) {
- return getPage(pageIndex) != null ? super.getEditor(pageIndex) : null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.forms.editor.FormEditor#createPageContainer(org.eclipse.swt.widgets.Composite)
- */
- @Override
- protected Composite createPageContainer(Composite parent) {
- // Create page container is the first method called by the final
- // MultiPageEditorPart#createPartControl. Use it as hook to close
- // editors with a NullEditorInput.
- if (getEditorInput() instanceof NullEditorInput) {
-// DisplayUtil.safeAsyncExec(new Runnable() {
-// @Override
-// public void run() {
-// close(false);
-// }
-// });
- close(false);
- }
-
- return super.createPageContainer(parent);
- }
-
- /**
- * Update the editor page list. Pages which are not longer valid
- * will be removed and pages now being valid gets added.
- */
- public void updatePageList() {
- // Remember the currently active page
- String activePageId = getActivePageInstance() != null ? getActivePageInstance().getId() : null;
- String activePageTitle = getActivePageInstance() != null ? getActivePageInstance().getTitle() : null;
- // Get the editor input object
- IEditorInput input = getEditorInput();
- // Get all applicable editor page bindings
- List<EditorPageBinding> bindings = new ArrayList<EditorPageBinding>(Arrays.asList(EditorPageBindingExtensionPointManager.getInstance().getApplicableEditorPageBindings(input)));
- // Get a copy of the currently added pages
- List<Object> oldPages = pages != null ? new ArrayList<Object>(Arrays.asList(pages.toArray())) : new ArrayList<Object>();
- // Loop through the old pages and determine if the page is still applicable
- Iterator<Object> iterator = oldPages.iterator();
- while (iterator.hasNext()) {
- Object element = iterator.next();
- // Skip over pages not being a form page.
- if (!(element instanceof IFormPage)) {
- continue;
- }
- IFormPage page = (IFormPage)element;
- // Find the corresponding page binding
- EditorPageBinding binding = null;
- for (EditorPageBinding candidate : bindings) {
- if (candidate.getPageId().equals(page.getId())) {
- binding = candidate;
- break;
- }
- }
- if (binding != null) {
- // Found binding -> page is still applicable
- bindings.remove(binding);
- } else {
- // No binding found -> page is not longer applicable
- removePage(pages.indexOf(page));
- }
- }
- // If the are remaining bindings left, this are new pages.
- // --> Process them now
- for (EditorPageBinding binding : bindings) {
- processPageBinding(binding);
- }
- // If possible, restore the active page
- if (activePageId != null) {
- int index = getIndexOf(activePageId);
- if (index == -1 && activePageTitle != null) {
- index = getIndexOfByTitle(activePageTitle);
- }
- if (index != -1) setActivePage(index);
- }
- }
-
- /**
- * Process the given editor page binding.
- *
- * @param binding The editor page binding. Must not be <code>null</code>.
- */
- protected void processPageBinding(EditorPageBinding binding) {
- Assert.isNotNull(binding);
-
- String pageId = binding.getPageId();
- if (pageId != null) {
- // Get the corresponding editor page instance
- IEditorPage page = EditorPageExtensionPointManager.getInstance().getEditorPage(pageId, true);
- if (page != null) {
- try {
- // Associate this editor with the page instance.
- // This is typically done in the constructor, but we are
- // utilizing a default constructor to instantiate the page.
- page.initialize(this);
-
- // Read in the "insertBefore" and "insertAfter" properties of the binding
- String insertBefore = binding.getInsertBefore().trim();
- String insertAfter = binding.getInsertAfter().trim();
-
- boolean pageAdded = false;
-
- // insertBefore will be processed before insertAfter.
- if (!"".equals(insertBefore)) { //$NON-NLS-1$
- String[] pageIds = insertBefore.split(","); //$NON-NLS-1$
- for (String insertBeforePageId : pageIds) {
- // If it is "first", we insert the page at index 0
- if ("first".equalsIgnoreCase(insertBeforePageId)) { //$NON-NLS-1$
- if (getIndexOf(page.getId()) == -1) {
- addPage(0, page);
- }
- pageAdded = true;
- break;
- }
-
- // Find the index of the page we shall insert this page before
- int index = getIndexOf(insertBeforePageId);
- if (index != -1) {
- if (getIndexOf(page.getId()) == -1) {
- addPage(index, page);
- }
- pageAdded = true;
- break;
- }
- }
- }
-
- // If the page hasn't been added till now, process insertAfter
- if (!pageAdded && !"".equals(insertAfter)) { //$NON-NLS-1$
- String[] pageIds = insertAfter.split(","); //$NON-NLS-1$
- for (String insertAfterPageId : pageIds) {
- // If it is "last", we insert the page at the end
- if ("last".equalsIgnoreCase(insertAfterPageId)) { //$NON-NLS-1$
- if (getIndexOf(page.getId()) == -1) {
- addPage(page);
- }
- pageAdded = true;
- break;
- }
-
- // Find the index of the page we shall insert this page after
- int index = getIndexOf(insertAfterPageId);
- if (index != -1 && index + 1 < pages.size()) {
- if (getIndexOf(page.getId()) == -1) {
- addPage(index + 1, page);
- }
- pageAdded = true;
- break;
- }
- }
- }
-
- // Add the page to the end if not added otherwise
- if (!pageAdded && getIndexOf(page.getId()) == -1) {
- addPage(page);
- }
-
- } catch (PartInitException e) { /* ignored on purpose */ }
- }
- }
- }
-
- /**
- * Returns the index of the page with the given id.
- *
- * @param pageId The page id. Must not be <code>null</code>.
- * @return The page index or <code>-1</code> if not found.
- */
- private int getIndexOf(String pageId) {
- Assert.isNotNull(pageId);
- for (int i = 0; i < pages.size(); i++) {
- Object page = pages.get(i);
- if (page instanceof IFormPage) {
- IFormPage fpage = (IFormPage)page;
- if (fpage.getId().equals(pageId)) {
- return i;
- }
- }
- }
- return -1;
- }
-
- /**
- * Returns the index of the page with the given title.
- *
- * @param pageTitle The page title. Must not be <code>null</code>.
- * @return The page index or <code>-1</code> if not found.
- */
- private int getIndexOfByTitle(String pageTitle) {
- Assert.isNotNull(pageTitle);
- for (int i = 0; i < pages.size(); i++) {
- Object page = pages.get(i);
- if (page instanceof IFormPage) {
- IFormPage fpage = (IFormPage)page;
- if (fpage.getTitle().equals(pageTitle)) {
- return i;
- }
- }
- }
- return -1;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.forms.editor.FormPage#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)
- */
- @Override
- public void init(IEditorSite site, IEditorInput input) throws PartInitException {
- super.init(site, input);
-
- // Update the part name
- if (!"".equals(input.getName())) { //$NON-NLS-1$
- setPartName(input.getName());
- }
-
- // Dispose an existing event listener instance
- if (listener != null) { listener.dispose(); listener = null; }
- // Create the event listener. The event listener does register itself.
- listener = new EditorEventListener(this);
- }
-
- /**
- * Update the editor part name based on the current editor input.
- */
- public void updatePartName() {
- IEditorInput input = getEditorInput();
- String oldPartName = getPartName();
-
- if (input instanceof EditorInput) {
- // Reset the editor input name to trigger recalculation
- ((EditorInput)input).name = null;
- // If the name changed, apply the new name
- if (!oldPartName.equals(input.getName())) {
- setPartName(input.getName());
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.forms.editor.FormEditor#dispose()
- */
- @Override
- public void dispose() {
- // Dispose an existing event listener instance
- if (listener != null) { listener.dispose(); listener = null; }
-
- super.dispose();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void doSave(IProgressMonitor monitor) {
- // The pages may require some save pre processing
- for (Object page : pages) {
- if (page instanceof AbstractEditorPage) {
- ((AbstractEditorPage)page).preDoSave(monitor);
- }
- }
- // Commit the page changes
- commitPages(true);
- // The pages may require some save post processing
- for (Object page : pages) {
- if (page instanceof AbstractEditorPage) {
- ((AbstractEditorPage)page).postDoSave(monitor);
- }
- }
- editorDirtyStateChanged();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.part.EditorPart#doSaveAs()
- */
- @Override
- public void doSaveAs() {
- IEditorSaveAsAdapter adapter = getEditorInput() != null ? (IEditorSaveAsAdapter)Platform.getAdapterManager().getAdapter(getEditorInput(), IEditorSaveAsAdapter.class) : null;
- if (adapter != null) {
- Object newNode = adapter.doSaveAs(getEditorInput());
- if (newNode != null) {
- setInput(new EditorInput(newNode));
- updatePartName();
- updatePageList();
- for (Object page : pages) {
- if (page instanceof AbstractEditorPage) {
- ((AbstractEditorPage) page).init(getEditorSite(), getEditorInput());
- }
- }
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
- */
- @Override
- public boolean isSaveAsAllowed() {
- IEditorSaveAsAdapter adapter = getEditorInput() != null ? (IEditorSaveAsAdapter)Platform.getAdapterManager().getAdapter(getEditorInput(), IEditorSaveAsAdapter.class) : null;
- if (adapter != null) {
- return adapter.isSaveAsAllowed(getEditorInput());
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPersistableEditor#restoreState(org.eclipse.ui.IMemento)
- */
- @Override
- public void restoreState(IMemento memento) {
- // Get the editor specific memento
- mementoToRestore = internalGetMemento(memento);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPersistable#saveState(org.eclipse.ui.IMemento)
- */
- @Override
- public void saveState(IMemento memento) {
- // Get the editor specific memento
- memento = internalGetMemento(memento);
- // Loop over all registered pages and pass on the editor specific memento
- // to the pages which implements IPersistable as well
- for (Object page : pages) {
- if (page instanceof IPersistable) {
- ((IPersistable)page).saveState(memento);
- }
- }
- }
-
- /**
- * Internal helper method accessing our editor local child memento
- * from the given parent memento.
- */
- private IMemento internalGetMemento(IMemento memento) {
- // Assume the editor memento to be the same as the parent memento
- IMemento editorMemento = memento;
-
- // If the parent memento is not null, create a child within the parent
- if (memento != null) {
- editorMemento = memento.getChild(Editor.class.getName());
- if (editorMemento == null) {
- editorMemento = memento.createChild(Editor.class.getName());
- }
- } else {
- // The parent memento is null. Create a new internal instance
- // of a XMLMemento. This case is happening if the user switches
- // to another perspective an the view becomes visible by this switch.
- editorMemento = XMLMemento.createWriteRoot(Editor.class.getName());
- }
-
- return editorMemento;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.part.MultiPageEditorPart#getAdapter(java.lang.Class)
- */
- @Override
- public Object getAdapter(Class adapter) {
- if (adapter == IPropertySheetPage.class) {
- return new TabbedPropertySheetPage(this);
- }
- // We pass on the adapt request to the currently active page
- Object adapterInstance = getActivePageInstance() != null ? getActivePageInstance().getAdapter(adapter) : null;
- if (adapterInstance == null) {
- // If failed to adapt via the currently active page, pass on to the super implementation
- adapterInstance = super.getAdapter(adapter);
- }
- return adapterInstance;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor#getContributorId()
- */
- @Override
- public String getContributorId() {
- return IUIConstants.TABBED_PROPERTIES_CONTRIBUTOR_ID;
- }
-
- /**
- * Fires a property changed event.
- *
- * @param propertyId the id of the property that changed
- */
- @Override
- public final void firePropertyChange(final int propertyId) {
- super.firePropertyChange(propertyId);
- }
-}
+/*******************************************************************************
+ * 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.ui.views.editor;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.tcf.te.ui.views.editor.pages.AbstractEditorPage;
+import org.eclipse.tcf.te.ui.views.extensions.EditorPageBinding;
+import org.eclipse.tcf.te.ui.views.extensions.EditorPageBindingExtensionPointManager;
+import org.eclipse.tcf.te.ui.views.extensions.EditorPageExtensionPointManager;
+import org.eclipse.tcf.te.ui.views.interfaces.IEditorPage;
+import org.eclipse.tcf.te.ui.views.interfaces.IEditorSaveAsAdapter;
+import org.eclipse.tcf.te.ui.views.interfaces.IUIConstants;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IPersistable;
+import org.eclipse.ui.IPersistableEditor;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.XMLMemento;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.IFormPage;
+import org.eclipse.ui.internal.part.NullEditorInput;
+import org.eclipse.ui.views.properties.IPropertySheetPage;
+import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
+
+
+/**
+ * Editor implementation.
+ */
+@SuppressWarnings("restriction")
+public final class Editor extends FormEditor implements IPersistableEditor, ITabbedPropertySheetPageContributor {
+
+ // The reference to an memento to restore once the editor got activated
+ private IMemento mementoToRestore;
+
+ // The editor event listener instance
+ private EditorEventListener listener;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.forms.editor.FormEditor#addPages()
+ */
+ @Override
+ protected void addPages() {
+ // Read extension point and add the contributed pages.
+ IEditorInput input = getEditorInput();
+ // Get all applicable editor page bindings
+ EditorPageBinding[] bindings = EditorPageBindingExtensionPointManager.getInstance().getApplicableEditorPageBindings(input);
+ for (EditorPageBinding binding : bindings) {
+ processPageBinding(binding);
+ }
+
+ if (mementoToRestore != null) {
+ // Loop over all registered pages and pass on the editor specific memento
+ // to the pages which implements IPersistableEditor as well
+ for (Object page : pages) {
+ if (page instanceof IPersistableEditor) {
+ ((IPersistableEditor)page).restoreState(mementoToRestore);
+ }
+ }
+ mementoToRestore = null;
+ }
+ }
+
+ /**
+ * Override this method to delegate the setFocus to
+ * the active form page.
+ */
+ @Override
+ public void setFocus() {
+ IFormPage fpage = getActivePageInstance();
+ if(fpage != null) {
+ fpage.setFocus();
+ }
+ else {
+ super.setFocus();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.forms.editor.FormEditor#getActivePageInstance()
+ */
+ @Override
+ public IFormPage getActivePageInstance() {
+ int index = getActivePage();
+ if (index != -1) {
+ return getPage(index);
+ }
+ return super.getActivePageInstance();
+ }
+
+ /**
+ * Returns the page which has the specified index.
+ *
+ * @param index The page's index.
+ * @return The page object or null if it does not exists.
+ */
+ private IFormPage getPage(int index) {
+ for (int i = 0; i < pages.size(); i++) {
+ Object page = pages.get(i);
+ if (page instanceof IFormPage) {
+ IFormPage fpage = (IFormPage) page;
+ if (fpage.getIndex() == index) {
+ return fpage;
+ }
+ }
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.forms.editor.FormEditor#setActivePage(int)
+ */
+ @Override
+ public void setActivePage(int pageIndex) {
+ if (getPage(pageIndex) != null) {
+ super.setActivePage(pageIndex);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.MultiPageEditorPart#getEditor(int)
+ */
+ @Override
+ protected IEditorPart getEditor(int pageIndex) {
+ return getPage(pageIndex) != null ? super.getEditor(pageIndex) : null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.forms.editor.FormEditor#createPageContainer(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Composite createPageContainer(Composite parent) {
+ // Create page container is the first method called by the final
+ // MultiPageEditorPart#createPartControl. Use it as hook to close
+ // editors with a NullEditorInput.
+ if (getEditorInput() instanceof NullEditorInput) {
+// DisplayUtil.safeAsyncExec(new Runnable() {
+// @Override
+// public void run() {
+// close(false);
+// }
+// });
+ close(false);
+ }
+
+ return super.createPageContainer(parent);
+ }
+
+ /**
+ * Update the editor page list. Pages which are not longer valid
+ * will be removed and pages now being valid gets added.
+ */
+ public void updatePageList() {
+ // Remember the currently active page
+ String activePageId = getActivePageInstance() != null ? getActivePageInstance().getId() : null;
+ String activePageTitle = getActivePageInstance() != null ? getActivePageInstance().getTitle() : null;
+ // Get the editor input object
+ IEditorInput input = getEditorInput();
+ // Get all applicable editor page bindings
+ List<EditorPageBinding> bindings = new ArrayList<EditorPageBinding>(Arrays.asList(EditorPageBindingExtensionPointManager.getInstance().getApplicableEditorPageBindings(input)));
+ // Get a copy of the currently added pages
+ List<Object> oldPages = pages != null ? new ArrayList<Object>(Arrays.asList(pages.toArray())) : new ArrayList<Object>();
+ // Loop through the old pages and determine if the page is still applicable
+ Iterator<Object> iterator = oldPages.iterator();
+ while (iterator.hasNext()) {
+ Object element = iterator.next();
+ // Skip over pages not being a form page.
+ if (!(element instanceof IFormPage)) {
+ continue;
+ }
+ IFormPage page = (IFormPage)element;
+ // Find the corresponding page binding
+ EditorPageBinding binding = null;
+ for (EditorPageBinding candidate : bindings) {
+ if (candidate.getPageId().equals(page.getId())) {
+ binding = candidate;
+ break;
+ }
+ }
+ if (binding != null) {
+ // Found binding -> page is still applicable
+ bindings.remove(binding);
+ } else {
+ // No binding found -> page is not longer applicable
+ removePage(pages.indexOf(page));
+ }
+ }
+ // If the are remaining bindings left, this are new pages.
+ // --> Process them now
+ for (EditorPageBinding binding : bindings) {
+ processPageBinding(binding);
+ }
+ // If possible, restore the active page
+ if (activePageId != null) {
+ int index = getIndexOf(activePageId);
+ if (index == -1 && activePageTitle != null) {
+ index = getIndexOfByTitle(activePageTitle);
+ }
+ if (index != -1) setActivePage(index);
+ }
+ }
+
+ /**
+ * Process the given editor page binding.
+ *
+ * @param binding The editor page binding. Must not be <code>null</code>.
+ */
+ protected void processPageBinding(EditorPageBinding binding) {
+ Assert.isNotNull(binding);
+
+ String pageId = binding.getPageId();
+ if (pageId != null) {
+ // Get the corresponding editor page instance
+ IEditorPage page = EditorPageExtensionPointManager.getInstance().getEditorPage(pageId, true);
+ if (page != null) {
+ try {
+ // Associate this editor with the page instance.
+ // This is typically done in the constructor, but we are
+ // utilizing a default constructor to instantiate the page.
+ page.initialize(this);
+
+ // Read in the "insertBefore" and "insertAfter" properties of the binding
+ String insertBefore = binding.getInsertBefore().trim();
+ String insertAfter = binding.getInsertAfter().trim();
+
+ boolean pageAdded = false;
+
+ // insertBefore will be processed before insertAfter.
+ if (!"".equals(insertBefore)) { //$NON-NLS-1$
+ String[] pageIds = insertBefore.split(","); //$NON-NLS-1$
+ for (String insertBeforePageId : pageIds) {
+ // If it is "first", we insert the page at index 0
+ if ("first".equalsIgnoreCase(insertBeforePageId)) { //$NON-NLS-1$
+ if (getIndexOf(page.getId()) == -1) {
+ addPage(0, page);
+ }
+ pageAdded = true;
+ break;
+ }
+
+ // Find the index of the page we shall insert this page before
+ int index = getIndexOf(insertBeforePageId);
+ if (index != -1) {
+ if (getIndexOf(page.getId()) == -1) {
+ addPage(index, page);
+ }
+ pageAdded = true;
+ break;
+ }
+ }
+ }
+
+ // If the page hasn't been added till now, process insertAfter
+ if (!pageAdded && !"".equals(insertAfter)) { //$NON-NLS-1$
+ String[] pageIds = insertAfter.split(","); //$NON-NLS-1$
+ for (String insertAfterPageId : pageIds) {
+ // If it is "last", we insert the page at the end
+ if ("last".equalsIgnoreCase(insertAfterPageId)) { //$NON-NLS-1$
+ if (getIndexOf(page.getId()) == -1) {
+ addPage(page);
+ }
+ pageAdded = true;
+ break;
+ }
+
+ // Find the index of the page we shall insert this page after
+ int index = getIndexOf(insertAfterPageId);
+ if (index != -1 && index + 1 < pages.size()) {
+ if (getIndexOf(page.getId()) == -1) {
+ addPage(index + 1, page);
+ }
+ pageAdded = true;
+ break;
+ }
+ }
+ }
+
+ // Add the page to the end if not added otherwise
+ if (!pageAdded && getIndexOf(page.getId()) == -1) {
+ addPage(page);
+ }
+
+ } catch (PartInitException e) { /* ignored on purpose */ }
+ }
+ }
+ }
+
+ /**
+ * Returns the index of the page with the given id.
+ *
+ * @param pageId The page id. Must not be <code>null</code>.
+ * @return The page index or <code>-1</code> if not found.
+ */
+ private int getIndexOf(String pageId) {
+ Assert.isNotNull(pageId);
+ for (int i = 0; i < pages.size(); i++) {
+ Object page = pages.get(i);
+ if (page instanceof IFormPage) {
+ IFormPage fpage = (IFormPage)page;
+ if (fpage.getId().equals(pageId)) {
+ return i;
+ }
+ }
+ }
+ return -1;
+ }
+
+ /**
+ * Returns the index of the page with the given title.
+ *
+ * @param pageTitle The page title. Must not be <code>null</code>.
+ * @return The page index or <code>-1</code> if not found.
+ */
+ private int getIndexOfByTitle(String pageTitle) {
+ Assert.isNotNull(pageTitle);
+ for (int i = 0; i < pages.size(); i++) {
+ Object page = pages.get(i);
+ if (page instanceof IFormPage) {
+ IFormPage fpage = (IFormPage)page;
+ if (fpage.getTitle().equals(pageTitle)) {
+ return i;
+ }
+ }
+ }
+ return -1;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.forms.editor.FormPage#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)
+ */
+ @Override
+ public void init(IEditorSite site, IEditorInput input) throws PartInitException {
+ super.init(site, input);
+
+ // Update the part name
+ if (!"".equals(input.getName())) { //$NON-NLS-1$
+ setPartName(input.getName());
+ }
+
+ // Dispose an existing event listener instance
+ if (listener != null) { listener.dispose(); listener = null; }
+ // Create the event listener. The event listener does register itself.
+ listener = new EditorEventListener(this);
+ }
+
+ /**
+ * Update the editor part name based on the current editor input.
+ */
+ public void updatePartName() {
+ IEditorInput input = getEditorInput();
+ String oldPartName = getPartName();
+
+ if (input instanceof EditorInput) {
+ // Reset the editor input name to trigger recalculation
+ ((EditorInput)input).name = null;
+ // If the name changed, apply the new name
+ if (!oldPartName.equals(input.getName())) {
+ setPartName(input.getName());
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.forms.editor.FormEditor#dispose()
+ */
+ @Override
+ public void dispose() {
+ // Dispose an existing event listener instance
+ if (listener != null) { listener.dispose(); listener = null; }
+
+ super.dispose();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void doSave(IProgressMonitor monitor) {
+ // The pages may require some save pre processing
+ for (Object page : pages) {
+ if (page instanceof AbstractEditorPage) {
+ ((AbstractEditorPage)page).preDoSave(monitor);
+ }
+ }
+ // Commit the page changes
+ commitPages(true);
+ // The pages may require some save post processing
+ for (Object page : pages) {
+ if (page instanceof AbstractEditorPage) {
+ ((AbstractEditorPage)page).postDoSave(monitor);
+ }
+ }
+ editorDirtyStateChanged();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.EditorPart#doSaveAs()
+ */
+ @Override
+ public void doSaveAs() {
+ IEditorSaveAsAdapter adapter = getEditorInput() != null ? (IEditorSaveAsAdapter)Platform.getAdapterManager().getAdapter(getEditorInput(), IEditorSaveAsAdapter.class) : null;
+ if (adapter != null) {
+ Object newNode = adapter.doSaveAs(getEditorInput());
+ if (newNode != null) {
+ setInput(new EditorInput(newNode));
+ updatePartName();
+ updatePageList();
+ for (Object page : pages) {
+ if (page instanceof AbstractEditorPage) {
+ ((AbstractEditorPage) page).init(getEditorSite(), getEditorInput());
+ }
+ }
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
+ */
+ @Override
+ public boolean isSaveAsAllowed() {
+ IEditorSaveAsAdapter adapter = getEditorInput() != null ? (IEditorSaveAsAdapter)Platform.getAdapterManager().getAdapter(getEditorInput(), IEditorSaveAsAdapter.class) : null;
+ if (adapter != null) {
+ return adapter.isSaveAsAllowed(getEditorInput());
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IPersistableEditor#restoreState(org.eclipse.ui.IMemento)
+ */
+ @Override
+ public void restoreState(IMemento memento) {
+ // Get the editor specific memento
+ mementoToRestore = internalGetMemento(memento);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IPersistable#saveState(org.eclipse.ui.IMemento)
+ */
+ @Override
+ public void saveState(IMemento memento) {
+ // Get the editor specific memento
+ memento = internalGetMemento(memento);
+ // Loop over all registered pages and pass on the editor specific memento
+ // to the pages which implements IPersistable as well
+ for (Object page : pages) {
+ if (page instanceof IPersistable) {
+ ((IPersistable)page).saveState(memento);
+ }
+ }
+ }
+
+ /**
+ * Internal helper method accessing our editor local child memento
+ * from the given parent memento.
+ */
+ private IMemento internalGetMemento(IMemento memento) {
+ // Assume the editor memento to be the same as the parent memento
+ IMemento editorMemento = memento;
+
+ // If the parent memento is not null, create a child within the parent
+ if (memento != null) {
+ editorMemento = memento.getChild(Editor.class.getName());
+ if (editorMemento == null) {
+ editorMemento = memento.createChild(Editor.class.getName());
+ }
+ } else {
+ // The parent memento is null. Create a new internal instance
+ // of a XMLMemento. This case is happening if the user switches
+ // to another perspective an the view becomes visible by this switch.
+ editorMemento = XMLMemento.createWriteRoot(Editor.class.getName());
+ }
+
+ return editorMemento;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.part.MultiPageEditorPart#getAdapter(java.lang.Class)
+ */
+ @Override
+ public Object getAdapter(Class adapter) {
+ if (adapter == IPropertySheetPage.class) {
+ return new TabbedPropertySheetPage(this);
+ }
+ // We pass on the adapt request to the currently active page
+ Object adapterInstance = getActivePageInstance() != null ? getActivePageInstance().getAdapter(adapter) : null;
+ if (adapterInstance == null) {
+ // If failed to adapt via the currently active page, pass on to the super implementation
+ adapterInstance = super.getAdapter(adapter);
+ }
+ return adapterInstance;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor#getContributorId()
+ */
+ @Override
+ public String getContributorId() {
+ return IUIConstants.TABBED_PROPERTIES_CONTRIBUTOR_ID;
+ }
+
+ /**
+ * Fires a property changed event.
+ *
+ * @param propertyId the id of the property that changed
+ */
+ @Override
+ public final void firePropertyChange(final int propertyId) {
+ super.firePropertyChange(propertyId);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/EditorEventListener.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/EditorEventListener.java
index 2ab7f98b9..8efa40eb2 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/EditorEventListener.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/EditorEventListener.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * 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
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/EditorInput.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/EditorInput.java
index dc4e0a1de..fd7e2eb72 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/EditorInput.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/EditorInput.java
@@ -1,194 +1,194 @@
-/*******************************************************************************
- * 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.ui.views.editor;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.tcf.te.runtime.preferences.ScopedEclipsePreferences;
-import org.eclipse.tcf.te.ui.interfaces.IPreferenceKeys;
-import org.eclipse.tcf.te.ui.views.activator.UIPlugin;
-import org.eclipse.tcf.te.ui.views.interfaces.IUIConstants;
-import org.eclipse.tcf.te.ui.views.interfaces.ImageConsts;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.IPersistableElement;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.navigator.CommonNavigator;
-import org.eclipse.ui.navigator.CommonViewer;
-
-
-/**
- * Editor input implementation.
- */
-public final class EditorInput implements IEditorInput, IPersistableElement {
- // The parent editor id
- private final String id;
- // The editor input name, once determined
- /* default */ String name;
- // The node (selection) the editor is showing
- private final Object node;
-
- /**
- * Constructor.
- *
- * @param node The node (selection) the editor is showing. Must not be <code>null</code>.
- */
- public EditorInput(Object node) {
- this(node, IUIConstants.ID_EDITOR);
- }
-
- /**
- * Constructor.
- *
- * @param node The node (selection) the editor is showing. Must not be <code>null</code>.
- * @param id The parent editor id or <code>null</code>
- */
- public EditorInput(Object node, String id) {
- super();
- this.id = id;
- Assert.isNotNull(node);
- this.node = node;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (node != null && obj instanceof EditorInput) {
- return node.equals(((EditorInput)obj).node)
- && (id != null ? id.equals(((EditorInput)obj).id) : ((EditorInput)obj).id == null);
- }
- return super.equals(obj);
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- return node != null ? node.hashCode() << 16 + (id != null ? id.hashCode() : 0) : super.hashCode();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IEditorInput#exists()
- */
- @Override
- public boolean exists() {
- return node != null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
- */
- @Override
- public ImageDescriptor getImageDescriptor() {
- return UIPlugin.getImageDescriptor(ImageConsts.EDITOR);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IEditorInput#getName()
- */
- @Override
- public String getName() {
- if (name == null && node != null) {
- ILabelProvider provider = node instanceof IAdaptable ? (ILabelProvider)((IAdaptable)node).getAdapter(ILabelProvider.class) : null;
- if (provider == null) {
- provider = (ILabelProvider)Platform.getAdapterManager().getAdapter(node, ILabelProvider.class);
- }
- name = provider != null ? provider.getText(node) : node.toString();
- }
-
- return name != null ? name : ""; //$NON-NLS-1$
- }
-
- /**
- * Get the common viewer used by the main view instance.
- *
- * @return The common viewer or <code>null</code>
- */
- protected CommonViewer getViewer() {
- if (PlatformUI.getWorkbench() != null && PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null
- && PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() != null) {
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- IViewPart part = page.findView(IUIConstants.ID_EXPLORER);
- if (part instanceof CommonNavigator) {
- return ((CommonNavigator)part).getCommonViewer();
- }
- }
-
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IEditorInput#getPersistable()
- */
- @Override
- public IPersistableElement getPersistable() {
- ScopedEclipsePreferences store = org.eclipse.tcf.te.ui.activator.UIPlugin.getScopedPreferences();
- if (getFactoryId() != null && store != null && store.getBoolean(IPreferenceKeys.PREF_PERSIST_EDITORS)) {
- return this;
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPersistableElement#getFactoryId()
- */
- @Override
- public String getFactoryId() {
- IPersistableElement adapter = (IPersistableElement)Platform.getAdapterManager().getAdapter(node, IPersistableElement.class);
- if (adapter != null) {
- return adapter.getFactoryId();
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPersistable#saveState(org.eclipse.ui.IMemento)
- */
- @Override
- public void saveState(IMemento memento) {
- IPersistableElement adapter = (IPersistableElement)Platform.getAdapterManager().getAdapter(node, IPersistableElement.class);
- if (adapter != null) {
- adapter.saveState(memento);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IEditorInput#getToolTipText()
- */
- @Override
- public String getToolTipText() {
- return getName();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
- */
- @Override
- public Object getAdapter(Class adapter) {
- if (IPersistableElement.class.isAssignableFrom(adapter)) {
- return getPersistable();
- }
-
- // If the adapter can be applied to the node instance, return the adapted node
- Object adapted = Platform.getAdapterManager().getAdapter(node, adapter);
- if (adapted != null) return adapted;
-
- return null;
- }
-
-}
+/*******************************************************************************
+ * 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.ui.views.editor;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.tcf.te.runtime.preferences.ScopedEclipsePreferences;
+import org.eclipse.tcf.te.ui.interfaces.IPreferenceKeys;
+import org.eclipse.tcf.te.ui.views.activator.UIPlugin;
+import org.eclipse.tcf.te.ui.views.interfaces.IUIConstants;
+import org.eclipse.tcf.te.ui.views.interfaces.ImageConsts;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IPersistableElement;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.navigator.CommonNavigator;
+import org.eclipse.ui.navigator.CommonViewer;
+
+
+/**
+ * Editor input implementation.
+ */
+public final class EditorInput implements IEditorInput, IPersistableElement {
+ // The parent editor id
+ private final String id;
+ // The editor input name, once determined
+ /* default */ String name;
+ // The node (selection) the editor is showing
+ private final Object node;
+
+ /**
+ * Constructor.
+ *
+ * @param node The node (selection) the editor is showing. Must not be <code>null</code>.
+ */
+ public EditorInput(Object node) {
+ this(node, IUIConstants.ID_EDITOR);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param node The node (selection) the editor is showing. Must not be <code>null</code>.
+ * @param id The parent editor id or <code>null</code>
+ */
+ public EditorInput(Object node, String id) {
+ super();
+ this.id = id;
+ Assert.isNotNull(node);
+ this.node = node;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (node != null && obj instanceof EditorInput) {
+ return node.equals(((EditorInput)obj).node)
+ && (id != null ? id.equals(((EditorInput)obj).id) : ((EditorInput)obj).id == null);
+ }
+ return super.equals(obj);
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ return node != null ? node.hashCode() << 16 + (id != null ? id.hashCode() : 0) : super.hashCode();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IEditorInput#exists()
+ */
+ @Override
+ public boolean exists() {
+ return node != null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
+ */
+ @Override
+ public ImageDescriptor getImageDescriptor() {
+ return UIPlugin.getImageDescriptor(ImageConsts.EDITOR);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IEditorInput#getName()
+ */
+ @Override
+ public String getName() {
+ if (name == null && node != null) {
+ ILabelProvider provider = node instanceof IAdaptable ? (ILabelProvider)((IAdaptable)node).getAdapter(ILabelProvider.class) : null;
+ if (provider == null) {
+ provider = (ILabelProvider)Platform.getAdapterManager().getAdapter(node, ILabelProvider.class);
+ }
+ name = provider != null ? provider.getText(node) : node.toString();
+ }
+
+ return name != null ? name : ""; //$NON-NLS-1$
+ }
+
+ /**
+ * Get the common viewer used by the main view instance.
+ *
+ * @return The common viewer or <code>null</code>
+ */
+ protected CommonViewer getViewer() {
+ if (PlatformUI.getWorkbench() != null && PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null
+ && PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() != null) {
+ IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ IViewPart part = page.findView(IUIConstants.ID_EXPLORER);
+ if (part instanceof CommonNavigator) {
+ return ((CommonNavigator)part).getCommonViewer();
+ }
+ }
+
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IEditorInput#getPersistable()
+ */
+ @Override
+ public IPersistableElement getPersistable() {
+ ScopedEclipsePreferences store = org.eclipse.tcf.te.ui.activator.UIPlugin.getScopedPreferences();
+ if (getFactoryId() != null && store != null && store.getBoolean(IPreferenceKeys.PREF_PERSIST_EDITORS)) {
+ return this;
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IPersistableElement#getFactoryId()
+ */
+ @Override
+ public String getFactoryId() {
+ IPersistableElement adapter = (IPersistableElement)Platform.getAdapterManager().getAdapter(node, IPersistableElement.class);
+ if (adapter != null) {
+ return adapter.getFactoryId();
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IPersistable#saveState(org.eclipse.ui.IMemento)
+ */
+ @Override
+ public void saveState(IMemento memento) {
+ IPersistableElement adapter = (IPersistableElement)Platform.getAdapterManager().getAdapter(node, IPersistableElement.class);
+ if (adapter != null) {
+ adapter.saveState(memento);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IEditorInput#getToolTipText()
+ */
+ @Override
+ public String getToolTipText() {
+ return getName();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+ */
+ @Override
+ public Object getAdapter(Class adapter) {
+ if (IPersistableElement.class.isAssignableFrom(adapter)) {
+ return getPersistable();
+ }
+
+ // If the adapter can be applied to the node instance, return the adapted node
+ Object adapted = Platform.getAdapterManager().getAdapter(node, adapter);
+ if (adapted != null) return adapted;
+
+ return null;
+ }
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/controls/ButtonPanelControl.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/controls/ButtonPanelControl.java
index 430183dab..74d73563a 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/controls/ButtonPanelControl.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/controls/ButtonPanelControl.java
@@ -1,199 +1,199 @@
-/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.ui.views.editor.controls;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-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.te.ui.controls.BaseControl;
-import org.eclipse.tcf.te.ui.swt.SWTControlUtil;
-import org.eclipse.tcf.te.ui.views.nls.Messages;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IPropertyListener;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.editor.FormEditor;
-import org.eclipse.ui.forms.editor.FormPage;
-
-/**
- * A panel control holding a set of buttons.
- * <p>
- * The panel control is associated with a managed form. If the managed form is the
- * embedded within a form editor or a form page, <code>getEditor()</code> will return
- * the parent form editor instance.
- * <p>
- * If the panel control has the default "Apply" button, the apply button will be
- * enabled once the parent form editor is marked dirty. If the "Apply" button is
- * clicked the form editor will be saved.
- */
-public class ButtonPanelControl extends BaseControl {
- // Reference to the parent managed form
- private final IManagedForm form;
-
- // The control sub-control
- private Composite panel;
- /* default */ Button applyButton;
-
- // Reference to the dirty state listener
- private IPropertyListener dirtyListener = null;
-
- /**
- * Constructor
- *
- * @param form The parent managed form. Must not be <code>null</code>.
- */
- public ButtonPanelControl(IManagedForm form) {
- super();
-
- Assert.isNotNull(form);
- this.form = form;
- }
-
- /**
- * Returns the parent managed form instance.
- *
- * @return The parent managed form instance.
- */
- protected final IManagedForm getManagedForm() {
- return form;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.forms.AbstractFormPart#dispose()
- */
- @Override
- public void dispose() {
- // Dispose the dirty state listener
- if (dirtyListener != null && getEditor() != null) {
- getEditor().removePropertyListener(dirtyListener);
- dirtyListener = null;
- }
-
- super.dispose();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.controls.BaseControl#setupPanel(org.eclipse.swt.widgets.Composite)
- */
- @Override
- public void setupPanel(Composite parent) {
- super.setupPanel(parent);
-
- // Create the buttons panel
- panel = doCreatePanel(parent);
- Assert.isNotNull(panel);
-
- // Create the buttons within the buttons panel
- doCreateButtons(panel);
- }
-
- /**
- * Create the panel that holds the buttons.
- *
- * @param parent The parent composite. Must not be <code>null</code>.
- * @return The panel.
- */
- protected Composite doCreatePanel(Composite parent) {
- Assert.isNotNull(parent);
-
- Composite panel = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.marginHeight = 0; layout.marginWidth = 0;
- panel.setLayout(layout);
- GridData layoutData = new GridData(SWT.TRAIL, SWT.BEGINNING, true, false);
- if (parent.getLayout() instanceof GridLayout) layoutData.horizontalSpan = ((GridLayout)parent.getLayout()).numColumns;
- panel.setLayoutData(layoutData);
- panel.setBackground(parent.getBackground());
-
- return panel;
- }
-
- /**
- * Returns if or of not the control has an apply button added to the buttons
- * panel by default.
- * <p>
- * <b>Note:</b> The default return by this method is <code>true</code>.
- *
- * @return <code>true</code> if there should be an apply button.
- */
- protected boolean hasApplyButton() {
- return true;
- }
-
- /**
- * Creates the buttons within the given parent composite.
- *
- * @param parent The parent composite. Must not be <code>null</code>.
- */
- protected void doCreateButtons(Composite parent) {
- Assert.isNotNull(parent);
-
- // Create a "Apply" button if requested
- if (hasApplyButton() && getEditor() != null) {
- applyButton = new Button(parent, SWT.PUSH);
- applyButton.setText(Messages.ButtonPanelControl_applyButton_label);
- applyButton.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ETOOL_SAVE_EDIT));
- applyButton.setBackground(parent.getBackground());
-
- GridData layoutData = new GridData(SWT.TRAIL, SWT.CENTER, false, false);
- layoutData.widthHint = SWTControlUtil.convertWidthInCharsToPixels(applyButton, 15);
- applyButton.setLayoutData(layoutData);
-
- applyButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- FormEditor editor = getEditor();
- Assert.isNotNull(editor);
- if (editor.isDirty()) {
- editor.doSave(new NullProgressMonitor());
- }
- }
- });
-
- dirtyListener = new IPropertyListener() {
- @Override
- public void propertyChanged(Object source, int propId) {
- if (propId == IEditorPart.PROP_DIRTY) {
- boolean dirty = getEditor().isDirty();
- applyButton.setEnabled(dirty);
- }
- }
- };
- getEditor().addPropertyListener(dirtyListener);
- applyButton.setEnabled(getEditor().isDirty());
- }
- }
-
- /**
- * Returns the parent form editor if the managed form is embedded
- * in such an editor.
- *
- * @return The parent form editor or <code>null</code>.
- */
- protected final FormEditor getEditor() {
- FormEditor editor = null;
-
- Object container = getManagedForm() != null ? getManagedForm().getContainer() : null;
- if (container instanceof FormEditor) {
- editor = (FormEditor)container;
- } else if (container instanceof FormPage) {
- editor = ((FormPage)container).getEditor();
- }
-
- return editor;
- }
-}
+/*******************************************************************************
+ * 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.ui.views.editor.controls;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+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.te.ui.controls.BaseControl;
+import org.eclipse.tcf.te.ui.swt.SWTControlUtil;
+import org.eclipse.tcf.te.ui.views.nls.Messages;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IPropertyListener;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.FormPage;
+
+/**
+ * A panel control holding a set of buttons.
+ * <p>
+ * The panel control is associated with a managed form. If the managed form is the
+ * embedded within a form editor or a form page, <code>getEditor()</code> will return
+ * the parent form editor instance.
+ * <p>
+ * If the panel control has the default "Apply" button, the apply button will be
+ * enabled once the parent form editor is marked dirty. If the "Apply" button is
+ * clicked the form editor will be saved.
+ */
+public class ButtonPanelControl extends BaseControl {
+ // Reference to the parent managed form
+ private final IManagedForm form;
+
+ // The control sub-control
+ private Composite panel;
+ /* default */ Button applyButton;
+
+ // Reference to the dirty state listener
+ private IPropertyListener dirtyListener = null;
+
+ /**
+ * Constructor
+ *
+ * @param form The parent managed form. Must not be <code>null</code>.
+ */
+ public ButtonPanelControl(IManagedForm form) {
+ super();
+
+ Assert.isNotNull(form);
+ this.form = form;
+ }
+
+ /**
+ * Returns the parent managed form instance.
+ *
+ * @return The parent managed form instance.
+ */
+ protected final IManagedForm getManagedForm() {
+ return form;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.forms.AbstractFormPart#dispose()
+ */
+ @Override
+ public void dispose() {
+ // Dispose the dirty state listener
+ if (dirtyListener != null && getEditor() != null) {
+ getEditor().removePropertyListener(dirtyListener);
+ dirtyListener = null;
+ }
+
+ super.dispose();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.BaseControl#setupPanel(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ public void setupPanel(Composite parent) {
+ super.setupPanel(parent);
+
+ // Create the buttons panel
+ panel = doCreatePanel(parent);
+ Assert.isNotNull(panel);
+
+ // Create the buttons within the buttons panel
+ doCreateButtons(panel);
+ }
+
+ /**
+ * Create the panel that holds the buttons.
+ *
+ * @param parent The parent composite. Must not be <code>null</code>.
+ * @return The panel.
+ */
+ protected Composite doCreatePanel(Composite parent) {
+ Assert.isNotNull(parent);
+
+ Composite panel = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.marginHeight = 0; layout.marginWidth = 0;
+ panel.setLayout(layout);
+ GridData layoutData = new GridData(SWT.TRAIL, SWT.BEGINNING, true, false);
+ if (parent.getLayout() instanceof GridLayout) layoutData.horizontalSpan = ((GridLayout)parent.getLayout()).numColumns;
+ panel.setLayoutData(layoutData);
+ panel.setBackground(parent.getBackground());
+
+ return panel;
+ }
+
+ /**
+ * Returns if or of not the control has an apply button added to the buttons
+ * panel by default.
+ * <p>
+ * <b>Note:</b> The default return by this method is <code>true</code>.
+ *
+ * @return <code>true</code> if there should be an apply button.
+ */
+ protected boolean hasApplyButton() {
+ return true;
+ }
+
+ /**
+ * Creates the buttons within the given parent composite.
+ *
+ * @param parent The parent composite. Must not be <code>null</code>.
+ */
+ protected void doCreateButtons(Composite parent) {
+ Assert.isNotNull(parent);
+
+ // Create a "Apply" button if requested
+ if (hasApplyButton() && getEditor() != null) {
+ applyButton = new Button(parent, SWT.PUSH);
+ applyButton.setText(Messages.ButtonPanelControl_applyButton_label);
+ applyButton.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ETOOL_SAVE_EDIT));
+ applyButton.setBackground(parent.getBackground());
+
+ GridData layoutData = new GridData(SWT.TRAIL, SWT.CENTER, false, false);
+ layoutData.widthHint = SWTControlUtil.convertWidthInCharsToPixels(applyButton, 15);
+ applyButton.setLayoutData(layoutData);
+
+ applyButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ FormEditor editor = getEditor();
+ Assert.isNotNull(editor);
+ if (editor.isDirty()) {
+ editor.doSave(new NullProgressMonitor());
+ }
+ }
+ });
+
+ dirtyListener = new IPropertyListener() {
+ @Override
+ public void propertyChanged(Object source, int propId) {
+ if (propId == IEditorPart.PROP_DIRTY) {
+ boolean dirty = getEditor().isDirty();
+ applyButton.setEnabled(dirty);
+ }
+ }
+ };
+ getEditor().addPropertyListener(dirtyListener);
+ applyButton.setEnabled(getEditor().isDirty());
+ }
+ }
+
+ /**
+ * Returns the parent form editor if the managed form is embedded
+ * in such an editor.
+ *
+ * @return The parent form editor or <code>null</code>.
+ */
+ protected final FormEditor getEditor() {
+ FormEditor editor = null;
+
+ Object container = getManagedForm() != null ? getManagedForm().getContainer() : null;
+ if (container instanceof FormEditor) {
+ editor = (FormEditor)container;
+ } else if (container instanceof FormPage) {
+ editor = ((FormPage)container).getEditor();
+ }
+
+ return editor;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/AbstractCustomFormToolkitEditorPage.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/AbstractCustomFormToolkitEditorPage.java
index 678c234dc..70eb2529f 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/AbstractCustomFormToolkitEditorPage.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/AbstractCustomFormToolkitEditorPage.java
@@ -1,341 +1,341 @@
-/*******************************************************************************
- * 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.ui.views.editor.pages;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ContributionManager;
-import org.eclipse.jface.action.GroupMarker;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.tcf.te.runtime.interfaces.IDisposable;
-import org.eclipse.tcf.te.ui.forms.CustomFormToolkit;
-import org.eclipse.tcf.te.ui.forms.FormLayoutFactory;
-import org.eclipse.tcf.te.ui.views.activator.UIPlugin;
-import org.eclipse.tcf.te.ui.views.interfaces.ImageConsts;
-import org.eclipse.tcf.te.ui.views.nls.Messages;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IPropertyListener;
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.menus.CommandContributionItem;
-import org.eclipse.ui.menus.CommandContributionItemParameter;
-import org.eclipse.ui.menus.IMenuService;
-
-/**
- * Abstract details editor page implementation managing
- * an custom form toolkit instance.
- */
-public abstract class AbstractCustomFormToolkitEditorPage extends AbstractEditorPage {
- // Reference to the form toolkit instance
- private CustomFormToolkit toolkit = null;
- // Reference to the toolbar manager to release menu contributions for
- private IToolBarManager manager = null;
-
- // The default help action class definition
- static protected class HelpAction extends Action {
- /* default */ final String helpID;
-
- /**
- * Constructor.
- *
- * @param helpID The context help id. Must not be <code>null</code>.
- */
- public HelpAction(String helpID) {
- super(Messages.AbstractCustomFormToolkitEditorPage_HelpAction_label, IAction.AS_PUSH_BUTTON);
- Assert.isNotNull(helpID);
- this.helpID = helpID;
- setToolTipText(Messages.AbstractCustomFormToolkitEditorPage_HelpAction_tooltip);
- setImageDescriptor(UIPlugin.getImageDescriptor(ImageConsts.HELP));
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.Action#run()
- */
- @Override
- public void run() {
- PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- PlatformUI.getWorkbench().getHelpSystem().displayHelp(helpID);
- }
- });
- }
- }
-
- // The default apply changes action class definition
- static protected class ApplyAction extends Action implements IPropertyListener, IDisposable {
- private final IEditorPart part;
-
- /**
- * Constructor
- */
- public ApplyAction(IEditorPart part) {
- super(Messages.AbstractCustomFormToolkitEditorPage_ApplyAction_label, IAction.AS_PUSH_BUTTON);
- Assert.isNotNull(part);
- this.part = part;
- setToolTipText(Messages.AbstractCustomFormToolkitEditorPage_ApplyAction_tooltip);
- setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_ETOOL_SAVE_EDIT));
- setDisabledImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_ETOOL_SAVE_EDIT_DISABLED));
-
- part.addPropertyListener(this);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.interfaces.IDisposable#dispose()
- */
- @Override
- public void dispose() {
- if (part != null) part.dispose();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.Action#run()
- */
- @Override
- public void run() {
- if (part != null && part.isDirty()) {
- part.doSave(new NullProgressMonitor());
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPropertyListener#propertyChanged(java.lang.Object, int)
- */
- @Override
- public void propertyChanged(Object source, int propId) {
- if (propId == IEditorPart.PROP_DIRTY) {
- boolean dirty = part != null && part.isDirty();
- setEnabled(dirty);
- }
- }
- }
-
- /**
- * Returns the custom form toolkit instance.
- *
- * @return The custom form toolkit instance or <code>null</code>.
- */
- protected final CustomFormToolkit getFormToolkit() {
- return toolkit;
- }
-
- /**
- * Sets the custom form toolkit instance.
- *
- * @param toolkit The custom form toolkit instance or <code>null</code>.
- */
- protected final void setFormToolkit(CustomFormToolkit toolkit) {
- this.toolkit = toolkit;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.forms.editor.FormPage#dispose()
- */
- @Override
- public void dispose() {
- // Get the menu service and release the toolbar manager
- if (manager instanceof ContributionManager) {
- IMenuService service = (IMenuService) getSite().getService(IMenuService.class);
- if (service != null) {
- service.releaseContributions((ContributionManager)manager);
- }
- }
- // Dispose the custom form toolkit
- if (toolkit != null) { toolkit.dispose(); toolkit = null; }
- // Dispose all the rest
- super.dispose();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.forms.editor.FormPage#createFormContent(org.eclipse.ui.forms.IManagedForm)
- */
- @Override
- protected void createFormContent(IManagedForm managedForm) {
- super.createFormContent(managedForm);
-
- Assert.isNotNull(managedForm);
-
- // Create the toolkit instance
- toolkit = new CustomFormToolkit(managedForm.getToolkit());
-
- // Configure the managed form
- configureManagedForm(managedForm);
-
- // Do create the content of the form now
- doCreateFormContent(managedForm.getForm().getBody(), getFormToolkit());
-
- // Re-arrange the controls
- managedForm.reflow(true);
- }
-
- /**
- * Configure the managed form to be ready for usage.
- *
- * @param managedForm The managed form. Must not be <code>null</code>.
- */
- protected void configureManagedForm(IManagedForm managedForm) {
- Assert.isNotNull(managedForm);
-
- // Configure main layout
- Composite body = managedForm.getForm().getBody();
- body.setLayout(FormLayoutFactory.createFormGridLayout(false, 1));
-
- // Set context help id
- if (getContextHelpId() != null) {
- PlatformUI.getWorkbench().getHelpSystem().setHelp(managedForm.getForm(), getContextHelpId());
- }
-
- // Decorate the form header
- getFormToolkit().getFormToolkit().decorateFormHeading(managedForm.getForm().getForm());
- // And set the header text and image
- if (getFormTitle() != null) managedForm.getForm().getForm().setText(getFormTitle());
- managedForm.getForm().getForm().setImage(getFormImage());
-
- // Add the toolbar items which will appear in the form header
- manager = managedForm.getForm().getForm().getToolBarManager();
- // Add the default "additions" separator
- manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
- // Create fixed toolbar contribution items
- createToolbarContributionItems(manager);
- // Get the menu service and populate contributed toolbar actions
- IMenuService service = (IMenuService) getSite().getService(IMenuService.class);
- if (service != null && manager instanceof ContributionManager) {
- service.populateContributionManager((ContributionManager)manager, "toolbar:" + getId()); //$NON-NLS-1$
- }
- // Trigger an update of the toolbar widget
- manager.update(true);
- }
-
- /**
- * Returns the context help id to associate with the page form.
- *
- * @return The context help id.
- */
- protected String getContextHelpId() {
- return null;
- }
-
- /**
- * Returns the form title to set to the top form header.
- *
- * @return The form title.
- */
- protected String getFormTitle() {
- return null;
- }
-
- /**
- * Returns the image to be set to the top form header.
- *
- * @return The image or <code>null</code> to use no image.
- */
- protected Image getFormImage() {
- return null;
- }
-
- /**
- * Create the toolbar contribution items.
- *
- * @param manager The toolbar manager. Must not be <code>null</code>.
- */
- protected void createToolbarContributionItems(IToolBarManager manager) {
- Assert.isNotNull(manager);
-
- manager.add(new Separator("group.connect")); //$NON-NLS-1$
- manager.add(new Separator("group.launch")); //$NON-NLS-1$
- manager.add(new GroupMarker("group.launch.rundebug")); //$NON-NLS-1$
- manager.add(new GroupMarker("group.launch.modes")); //$NON-NLS-1$
- manager.add(new GroupMarker("group.launch.additions")); //$NON-NLS-1$
-
- manager.add(new Separator("group.showIn")); //$NON-NLS-1$
- if (hasShowInSystemManagementAction()) {
- manager.add(new CommandContributionItem(new CommandContributionItemParameter(PlatformUI.getWorkbench(),
- "org.eclipse.tcf.te.ui.views.command.showIn.systemManagement", //$NON-NLS-1$
- "org.eclipse.tcf.te.ui.command.showIn.systemManagement", //$NON-NLS-1$
- CommandContributionItem.STYLE_PUSH)));
- }
-
- manager.add(new Separator("group.save")); //$NON-NLS-1$
- // If the page should have an apply button, add one to the toolbar
- if (hasApplyAction()) {
- Action applyAction = doCreateApplyAction(getEditor());
- if (applyAction != null) manager.add(applyAction);
- }
-
- manager.add(new Separator("group.help")); //$NON-NLS-1$
- // If the page is associated with a context help id, add a default
- // help action button into the toolbar
- if (getContextHelpId() != null) {
- Action helpAction = doCreateHelpAction(getContextHelpId());
- if (helpAction != null) manager.add(helpAction);
- }
- }
-
- /**
- * Create the help action.
- *
- * @param contextHelpId The context help id. Must not be <code>null</code>.
- * @return The help action or <code>null</code>.
- */
- protected Action doCreateHelpAction(String contextHelpId) {
- Assert.isNotNull(contextHelpId);
- return new HelpAction(contextHelpId);
- }
-
- /**
- * Creates the apply action.
- *
- * @param part The editor part. Must not be <code>null</code>.
- * @return The apply action or <code>null</code>.
- */
- protected Action doCreateApplyAction(IEditorPart part) {
- Assert.isNotNull(part);
- return new ApplyAction(part);
- }
-
- /**
- * Returns if or if not the page should have an
- * ShowInSystemManagementView button in the toolbar.
- * <p>
- * The default implementation returns <code>true</code>.
- *
- * @return <code>True</code> if the page does have an ShowInSystemManagementView button, <code>false</code> otherwise.
- */
- protected boolean hasShowInSystemManagementAction() {
- return true;
- }
-
- /**
- * Returns if or if not the page should have an apply button in
- * the toolbar.
- * <p>
- * The default implementation returns <code>false</code>.
- *
- * @return <code>True</code> if the page does have an apply button, <code>false</code> otherwise.
- */
- protected boolean hasApplyAction() {
- return false;
- }
-
- /**
- * Do create the managed form content.
- *
- * @param parent The parent composite. Must not be <code>null</code>
- * @param toolkit The {@link CustomFormToolkit} instance. Must not be <code>null</code>.
- */
- protected abstract void doCreateFormContent(Composite parent, CustomFormToolkit toolkit);
-}
+/*******************************************************************************
+ * 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.ui.views.editor.pages;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ContributionManager;
+import org.eclipse.jface.action.GroupMarker;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.tcf.te.runtime.interfaces.IDisposable;
+import org.eclipse.tcf.te.ui.forms.CustomFormToolkit;
+import org.eclipse.tcf.te.ui.forms.FormLayoutFactory;
+import org.eclipse.tcf.te.ui.views.activator.UIPlugin;
+import org.eclipse.tcf.te.ui.views.interfaces.ImageConsts;
+import org.eclipse.tcf.te.ui.views.nls.Messages;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IPropertyListener;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.menus.CommandContributionItem;
+import org.eclipse.ui.menus.CommandContributionItemParameter;
+import org.eclipse.ui.menus.IMenuService;
+
+/**
+ * Abstract details editor page implementation managing
+ * an custom form toolkit instance.
+ */
+public abstract class AbstractCustomFormToolkitEditorPage extends AbstractEditorPage {
+ // Reference to the form toolkit instance
+ private CustomFormToolkit toolkit = null;
+ // Reference to the toolbar manager to release menu contributions for
+ private IToolBarManager manager = null;
+
+ // The default help action class definition
+ static protected class HelpAction extends Action {
+ /* default */ final String helpID;
+
+ /**
+ * Constructor.
+ *
+ * @param helpID The context help id. Must not be <code>null</code>.
+ */
+ public HelpAction(String helpID) {
+ super(Messages.AbstractCustomFormToolkitEditorPage_HelpAction_label, IAction.AS_PUSH_BUTTON);
+ Assert.isNotNull(helpID);
+ this.helpID = helpID;
+ setToolTipText(Messages.AbstractCustomFormToolkitEditorPage_HelpAction_tooltip);
+ setImageDescriptor(UIPlugin.getImageDescriptor(ImageConsts.HELP));
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ PlatformUI.getWorkbench().getHelpSystem().displayHelp(helpID);
+ }
+ });
+ }
+ }
+
+ // The default apply changes action class definition
+ static protected class ApplyAction extends Action implements IPropertyListener, IDisposable {
+ private final IEditorPart part;
+
+ /**
+ * Constructor
+ */
+ public ApplyAction(IEditorPart part) {
+ super(Messages.AbstractCustomFormToolkitEditorPage_ApplyAction_label, IAction.AS_PUSH_BUTTON);
+ Assert.isNotNull(part);
+ this.part = part;
+ setToolTipText(Messages.AbstractCustomFormToolkitEditorPage_ApplyAction_tooltip);
+ setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_ETOOL_SAVE_EDIT));
+ setDisabledImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_ETOOL_SAVE_EDIT_DISABLED));
+
+ part.addPropertyListener(this);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.interfaces.IDisposable#dispose()
+ */
+ @Override
+ public void dispose() {
+ if (part != null) part.dispose();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ if (part != null && part.isDirty()) {
+ part.doSave(new NullProgressMonitor());
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IPropertyListener#propertyChanged(java.lang.Object, int)
+ */
+ @Override
+ public void propertyChanged(Object source, int propId) {
+ if (propId == IEditorPart.PROP_DIRTY) {
+ boolean dirty = part != null && part.isDirty();
+ setEnabled(dirty);
+ }
+ }
+ }
+
+ /**
+ * Returns the custom form toolkit instance.
+ *
+ * @return The custom form toolkit instance or <code>null</code>.
+ */
+ protected final CustomFormToolkit getFormToolkit() {
+ return toolkit;
+ }
+
+ /**
+ * Sets the custom form toolkit instance.
+ *
+ * @param toolkit The custom form toolkit instance or <code>null</code>.
+ */
+ protected final void setFormToolkit(CustomFormToolkit toolkit) {
+ this.toolkit = toolkit;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.forms.editor.FormPage#dispose()
+ */
+ @Override
+ public void dispose() {
+ // Get the menu service and release the toolbar manager
+ if (manager instanceof ContributionManager) {
+ IMenuService service = (IMenuService) getSite().getService(IMenuService.class);
+ if (service != null) {
+ service.releaseContributions((ContributionManager)manager);
+ }
+ }
+ // Dispose the custom form toolkit
+ if (toolkit != null) { toolkit.dispose(); toolkit = null; }
+ // Dispose all the rest
+ super.dispose();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.forms.editor.FormPage#createFormContent(org.eclipse.ui.forms.IManagedForm)
+ */
+ @Override
+ protected void createFormContent(IManagedForm managedForm) {
+ super.createFormContent(managedForm);
+
+ Assert.isNotNull(managedForm);
+
+ // Create the toolkit instance
+ toolkit = new CustomFormToolkit(managedForm.getToolkit());
+
+ // Configure the managed form
+ configureManagedForm(managedForm);
+
+ // Do create the content of the form now
+ doCreateFormContent(managedForm.getForm().getBody(), getFormToolkit());
+
+ // Re-arrange the controls
+ managedForm.reflow(true);
+ }
+
+ /**
+ * Configure the managed form to be ready for usage.
+ *
+ * @param managedForm The managed form. Must not be <code>null</code>.
+ */
+ protected void configureManagedForm(IManagedForm managedForm) {
+ Assert.isNotNull(managedForm);
+
+ // Configure main layout
+ Composite body = managedForm.getForm().getBody();
+ body.setLayout(FormLayoutFactory.createFormGridLayout(false, 1));
+
+ // Set context help id
+ if (getContextHelpId() != null) {
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(managedForm.getForm(), getContextHelpId());
+ }
+
+ // Decorate the form header
+ getFormToolkit().getFormToolkit().decorateFormHeading(managedForm.getForm().getForm());
+ // And set the header text and image
+ if (getFormTitle() != null) managedForm.getForm().getForm().setText(getFormTitle());
+ managedForm.getForm().getForm().setImage(getFormImage());
+
+ // Add the toolbar items which will appear in the form header
+ manager = managedForm.getForm().getForm().getToolBarManager();
+ // Add the default "additions" separator
+ manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
+ // Create fixed toolbar contribution items
+ createToolbarContributionItems(manager);
+ // Get the menu service and populate contributed toolbar actions
+ IMenuService service = (IMenuService) getSite().getService(IMenuService.class);
+ if (service != null && manager instanceof ContributionManager) {
+ service.populateContributionManager((ContributionManager)manager, "toolbar:" + getId()); //$NON-NLS-1$
+ }
+ // Trigger an update of the toolbar widget
+ manager.update(true);
+ }
+
+ /**
+ * Returns the context help id to associate with the page form.
+ *
+ * @return The context help id.
+ */
+ protected String getContextHelpId() {
+ return null;
+ }
+
+ /**
+ * Returns the form title to set to the top form header.
+ *
+ * @return The form title.
+ */
+ protected String getFormTitle() {
+ return null;
+ }
+
+ /**
+ * Returns the image to be set to the top form header.
+ *
+ * @return The image or <code>null</code> to use no image.
+ */
+ protected Image getFormImage() {
+ return null;
+ }
+
+ /**
+ * Create the toolbar contribution items.
+ *
+ * @param manager The toolbar manager. Must not be <code>null</code>.
+ */
+ protected void createToolbarContributionItems(IToolBarManager manager) {
+ Assert.isNotNull(manager);
+
+ manager.add(new Separator("group.connect")); //$NON-NLS-1$
+ manager.add(new Separator("group.launch")); //$NON-NLS-1$
+ manager.add(new GroupMarker("group.launch.rundebug")); //$NON-NLS-1$
+ manager.add(new GroupMarker("group.launch.modes")); //$NON-NLS-1$
+ manager.add(new GroupMarker("group.launch.additions")); //$NON-NLS-1$
+
+ manager.add(new Separator("group.showIn")); //$NON-NLS-1$
+ if (hasShowInSystemManagementAction()) {
+ manager.add(new CommandContributionItem(new CommandContributionItemParameter(PlatformUI.getWorkbench(),
+ "org.eclipse.tcf.te.ui.views.command.showIn.systemManagement", //$NON-NLS-1$
+ "org.eclipse.tcf.te.ui.command.showIn.systemManagement", //$NON-NLS-1$
+ CommandContributionItem.STYLE_PUSH)));
+ }
+
+ manager.add(new Separator("group.save")); //$NON-NLS-1$
+ // If the page should have an apply button, add one to the toolbar
+ if (hasApplyAction()) {
+ Action applyAction = doCreateApplyAction(getEditor());
+ if (applyAction != null) manager.add(applyAction);
+ }
+
+ manager.add(new Separator("group.help")); //$NON-NLS-1$
+ // If the page is associated with a context help id, add a default
+ // help action button into the toolbar
+ if (getContextHelpId() != null) {
+ Action helpAction = doCreateHelpAction(getContextHelpId());
+ if (helpAction != null) manager.add(helpAction);
+ }
+ }
+
+ /**
+ * Create the help action.
+ *
+ * @param contextHelpId The context help id. Must not be <code>null</code>.
+ * @return The help action or <code>null</code>.
+ */
+ protected Action doCreateHelpAction(String contextHelpId) {
+ Assert.isNotNull(contextHelpId);
+ return new HelpAction(contextHelpId);
+ }
+
+ /**
+ * Creates the apply action.
+ *
+ * @param part The editor part. Must not be <code>null</code>.
+ * @return The apply action or <code>null</code>.
+ */
+ protected Action doCreateApplyAction(IEditorPart part) {
+ Assert.isNotNull(part);
+ return new ApplyAction(part);
+ }
+
+ /**
+ * Returns if or if not the page should have an
+ * ShowInSystemManagementView button in the toolbar.
+ * <p>
+ * The default implementation returns <code>true</code>.
+ *
+ * @return <code>True</code> if the page does have an ShowInSystemManagementView button, <code>false</code> otherwise.
+ */
+ protected boolean hasShowInSystemManagementAction() {
+ return true;
+ }
+
+ /**
+ * Returns if or if not the page should have an apply button in
+ * the toolbar.
+ * <p>
+ * The default implementation returns <code>false</code>.
+ *
+ * @return <code>True</code> if the page does have an apply button, <code>false</code> otherwise.
+ */
+ protected boolean hasApplyAction() {
+ return false;
+ }
+
+ /**
+ * Do create the managed form content.
+ *
+ * @param parent The parent composite. Must not be <code>null</code>
+ * @param toolkit The {@link CustomFormToolkit} instance. Must not be <code>null</code>.
+ */
+ protected abstract void doCreateFormContent(Composite parent, CustomFormToolkit toolkit);
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/AbstractEditorPage.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/AbstractEditorPage.java
index b0309e0a7..836008178 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/AbstractEditorPage.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/AbstractEditorPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * 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
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/TreeViewerExplorerEditorPage.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/TreeViewerExplorerEditorPage.java
index 63c69d82c..4a2fb12c9 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/TreeViewerExplorerEditorPage.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/TreeViewerExplorerEditorPage.java
@@ -1,507 +1,507 @@
-/*******************************************************************************
- * 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.ui.views.editor.pages;
-
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.net.URL;
-
-import org.eclipse.core.commands.Command;
-import org.eclipse.core.commands.ParameterizedCommand;
-import org.eclipse.core.expressions.EvaluationContext;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.SafeRunner;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.util.SafeRunnable;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ILabelDecorator;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TreePath;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWTException;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.events.FocusAdapter;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeColumn;
-import org.eclipse.tcf.te.core.interfaces.IFilterable;
-import org.eclipse.tcf.te.core.interfaces.IPropertyChangeProvider;
-import org.eclipse.tcf.te.ui.forms.CustomFormToolkit;
-import org.eclipse.tcf.te.ui.trees.TreeControl;
-import org.eclipse.tcf.te.ui.utils.TreeViewerUtil;
-import org.eclipse.ui.ISources;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.commands.ICommandService;
-import org.eclipse.ui.forms.IManagedForm;
-import org.eclipse.ui.forms.widgets.Form;
-import org.eclipse.ui.handlers.IHandlerService;
-import org.eclipse.ui.part.MultiPageSelectionProvider;
-import org.osgi.framework.Bundle;
-
-/**
- * Tree viewer based editor page implementation.
- */
-public abstract class TreeViewerExplorerEditorPage extends AbstractCustomFormToolkitEditorPage implements IDoubleClickListener {
- // The references to the pages subcontrol's (needed for disposal)
- private TreeControl treeControl;
- private IToolBarManager toolbarMgr;
- private PropertyChangeListener pcListener;
- private Image formImage;
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.forms.editor.FormPage#dispose()
- */
- @Override
- public void dispose() {
- IPropertyChangeProvider provider = getPropertyChangeProvider();
- if(provider != null && pcListener != null) {
- provider.removePropertyChangeListener(pcListener);
- }
- if(formImage != null) {
- formImage.dispose();
- }
- if (treeControl != null) { treeControl.dispose(); treeControl = null; }
- super.dispose();
- }
-
- /**
- * Set the initial focus to the tree.
- */
- @Override
- public void setFocus() {
- Control control = treeControl.getViewer().getControl();
- if(control != null && !control.isDisposed()) {
- control.setFocus();
- }
- else {
- super.setFocus();
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.views.editor.pages.AbstractEditorPage#setInitializationData(org.eclipse.core.runtime.IConfigurationElement, java.lang.String, java.lang.Object)
- */
- @Override
- public void setInitializationData(IConfigurationElement config, String propertyName, Object data) {
- super.setInitializationData(config, propertyName, data);
- String iconPath = config.getAttribute("icon"); //$NON-NLS-1$
- if(iconPath != null) {
- String bundleId = config.getContributor().getName();
- Bundle bundle = Platform.getBundle(bundleId);
- if(bundle != null) {
- URL iconURL = bundle.getEntry(iconPath);
- if(iconURL != null) {
- ImageDescriptor iconDesc = ImageDescriptor.createFromURL(iconURL);
- if(iconDesc != null) {
- formImage = iconDesc.createImage();
- }
- }
- }
- }
- treeControl = doCreateTreeControl();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.views.editor.pages.AbstractCustomFormToolkitEditorPage#getFormImage()
- */
- @Override
- protected Image getFormImage() {
- return formImage;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.views.editor.pages.AbstractCustomFormToolkitEditorPage#createToolbarContributionItems(org.eclipse.jface.action.IToolBarManager)
- */
- @Override
- protected void createToolbarContributionItems(IToolBarManager manager) {
- this.toolbarMgr = manager;
- treeControl.createToolbarContributionItems(manager);
- super.createToolbarContributionItems(manager);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.views.editor.pages.AbstractCustomFormToolkitEditorPage#doCreateFormContent(org.eclipse.swt.widgets.Composite, org.eclipse.tcf.te.ui.forms.CustomFormToolkit)
- */
- @Override
- protected void doCreateFormContent(Composite parent, CustomFormToolkit toolkit) {
- Assert.isNotNull(parent);
- Assert.isNotNull(toolkit);
-
- // Setup the tree control
- Assert.isNotNull(treeControl);
- treeControl.setupFormPanel(parent, toolkit);
-
- // Register the context menu at the parent workbench part site.
- getSite().registerContextMenu(getId(), treeControl.getContextMenuManager(), treeControl.getViewer());
-
- // Set the initial input
- Object input = getViewerInput();
- treeControl.getViewer().setInput(input);
-
- addViewerListeners();
-
- // adjust the tree column width initially to take the full size of control
- adjustTreeColumnWidth(treeControl.getViewer());
-
- updateUI();
- }
-
- /**
- * Determines the current visible width of the tree control and
- * adjust the column width according to there relative weight.
- *
- * @param viewer The viewer or <code>null</code>.
- */
- protected void adjustTreeColumnWidth(Viewer viewer) {
- if (!(viewer instanceof TreeViewer)) return;
-
- final TreeViewer treeViewer = (TreeViewer)viewer;
- final Tree tree = treeViewer.getTree();
- tree.addControlListener(new ControlListener() {
-
- @Override
- public void controlResized(ControlEvent e) {
- int sumColumnWidth = 0;
- int treeWidth = tree.getSize().x - tree.getVerticalBar().getSize().x;
-
- TreeColumn[] columns = tree.getColumns();
-
- // Summarize the tree column width
- for (TreeColumn column : columns) {
- Object widthHint = column.getData("widthHint"); //$NON-NLS-1$
- sumColumnWidth += widthHint instanceof Integer ? ((Integer)widthHint).intValue() : column.getWidth();
- }
-
- // Calculate the new width for each column
- int sumColumnWidth2 = 0;
- TreeColumn maxColumn = null;
- for (TreeColumn column : columns) {
- Object widthHint = column.getData("widthHint"); //$NON-NLS-1$
- int width = widthHint instanceof Integer ? ((Integer)widthHint).intValue() : column.getWidth();
- int weight = (width * 100) / sumColumnWidth;
- int newWidth = (weight * treeWidth) / 100;
- sumColumnWidth2 += newWidth;
- column.setWidth(newWidth);
- if (maxColumn == null || maxColumn.getWidth() < column.getWidth()) {
- maxColumn = column;
- }
- }
-
- // If we end up with a slighter larger width of all columns than
- // the tree widget is, reduce the size of the largest column
- if (sumColumnWidth2 > treeWidth && maxColumn != null) {
- int delta = sumColumnWidth2 - treeWidth + 2;
- maxColumn.setWidth(maxColumn.getWidth() - delta);
- }
-
- tree.removeControlListener(this);
- }
-
- @Override
- public void controlMoved(ControlEvent e) {
- }
- });
- }
-
- /**
- * Add tree viewer listeners to the tree control.
- */
- private void addViewerListeners() {
- TreeViewer viewer = (TreeViewer) treeControl.getViewer();
- viewer.addSelectionChangedListener(new ISelectionChangedListener(){
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- propagateSelection();
- }});
- viewer.getTree().addFocusListener(new FocusAdapter(){
- @Override
- public void focusGained(FocusEvent e) {
- propagateSelection();
- }
- });
- viewer.addDoubleClickListener(this);
-
- IPropertyChangeProvider provider = getPropertyChangeProvider();
- if(provider != null) {
- pcListener = new PropertyChangeListener() {
- @Override
- public void propertyChange(final PropertyChangeEvent event) {
- Object object = event.getSource();
- Object input = getTreeViewerInput();
- if (object == input) {
- if (Display.getCurrent() != null) {
- updateUI();
- }
- else {
- Display display = getSite().getShell().getDisplay();
- display.asyncExec(new Runnable() {
- @Override
- public void run() {
- updateUI();
- }
- });
- }
- }
- }
- };
- provider.addPropertyChangeListener(pcListener);
- }
- }
-
- @Override
- public Object getAdapter(Class adapter) {
- if(TreeViewer.class.equals(adapter)) {
- return treeControl.getViewer();
- }
- return super.getAdapter(adapter);
- }
-
- /**
- * Get an adapter instance from the adaptable with the specified
- * adapter interface.
- *
- * @param adaptable The adaptable to get the adapter.
- * @param adapter The adapter interface class.
- * @return An adapter or null if it does not adapt to this type.
- */
- @SuppressWarnings("rawtypes")
- private Object getAdapter(Object adaptable, Class adapter) {
- Object adapted = null;
- if(adapter.isInstance(adaptable)) {
- adapted = adaptable;
- }
- if(adapted == null && adaptable instanceof IAdaptable) {
- adapted = ((IAdaptable)adaptable).getAdapter(adapter);
- }
- if(adapted == null && adaptable != null) {
- adapted = Platform.getAdapterManager().getAdapter(adaptable, adapter);
- }
- return adapted;
- }
-
- /**
- * Get an adapter of IFilteringLabelDecorator.
- *
- * @return an IFilteringLabelDecorator adapter or null if it does not adapt to IFilteringLabelDecorator.
- */
- private IFilterable adaptFilterable() {
- Object input = getTreeViewerInput();
- if (input != null) {
- return (IFilterable) getAdapter(input, IFilterable.class);
- }
- return null;
- }
-
- protected abstract Object getViewerInput();
-
- /**
- * Get the viewer input adapter for the input.
- *
- * @param input the input of the tree viewer.
- * @return The adapter.
- */
- private IPropertyChangeProvider getPropertyChangeProvider() {
- Object input = getTreeViewerInput();
- if (input != null) {
- return (IPropertyChangeProvider) getAdapter(input, IPropertyChangeProvider.class);
- }
- return null;
- }
-
- Object getTreeViewerInput() {
- if (treeControl != null && treeControl.getViewer() != null) {
- return treeControl.getViewer().getInput();
- }
- return null;
- }
-
- /**
- * Creates and returns a tree control.
- *
- * @return The new tree control.
- */
- protected TreeControl doCreateTreeControl() {
- return new TreeControl(getViewerId(), this);
- }
-
- /**
- * Returns the associated tree control.
- *
- * @return The associated tree control or <code>null</code>.
- */
- public final TreeControl getTreeControl() {
- return treeControl;
- }
-
- /**
- * Update the page's ui including its toolbar and title text and image.
- */
- protected void updateUI() {
- toolbarMgr.update(true);
- IManagedForm managedForm = getManagedForm();
- Form form = managedForm.getForm().getForm();
- Object element = getTreeViewerInput();
- boolean filterEnabled = false;
- IFilterable filterDecorator = adaptFilterable();
- if (filterDecorator != null) {
- TreeViewer viewer = (TreeViewer) treeControl.getViewer();
- filterEnabled = TreeViewerUtil.isFiltering(viewer, TreePath.EMPTY);
- }
- ILabelDecorator titleDecorator = getTitleBarDecorator();
- String text = getFormTitle();
- if (text != null) {
- if (titleDecorator != null) {
- text = titleDecorator.decorateText(text, element);
- }
- if (filterEnabled) {
- TreeViewer viewer = (TreeViewer) treeControl.getViewer();
- text = TreeViewerUtil.getDecoratedText(text, viewer, TreePath.EMPTY);
- }
- }
- Image image = getFormImage();
- if (image != null) {
- if (titleDecorator != null) {
- image = titleDecorator.decorateImage(image, element);
- }
- if (filterEnabled) {
- TreeViewer viewer = (TreeViewer) treeControl.getViewer();
- image = TreeViewerUtil.getDecoratedImage(image, viewer, TreePath.EMPTY);
- }
- }
- if (text != null) {
- try {
- form.setText(text);
- }
- catch (Exception e) {
- // Ignore any disposed exception
- }
- }
- if (image != null) {
- try {
- form.setImage(image);
- }
- catch (Exception e) {
- // Ignore any disposed exception
- }
- }
- }
-
- /**
- * Get the title bar's decorator or null if there's no decorator for it.
- */
- protected ILabelDecorator getTitleBarDecorator() {
- return null;
- }
-
- /**
- * Propagate the current selection to the editor's selection provider.
- */
- protected void propagateSelection() {
- ISelection selection = treeControl.getViewer().getSelection();
- ISelectionProvider selectionProvider = getSite().getSelectionProvider();
- // If the parent control is already disposed, we have no real chance of
- // testing for it. Catch the SWT exception here just in case.
- try {
- selectionProvider.setSelection(selection);
- if (selectionProvider instanceof MultiPageSelectionProvider) {
- SelectionChangedEvent changedEvent = new SelectionChangedEvent(selectionProvider, selection);
- ((MultiPageSelectionProvider) selectionProvider).firePostSelectionChanged(changedEvent);
- }
- }
- catch (SWTException e) {
- /* ignored on purpose */
- }
- }
-
- /**
- * Get the id of the command invoked when the tree is double-clicked.
- * If the id is null, then no command is invoked.
- *
- * @return The double-click command id.
- */
- protected String getDoubleClickCommandId() {
- return null;
- }
-
- /**
- * Get the tree viewer's id. This viewer id is used by
- * viewer extension to define columns and filters.
- *
- * @return This viewer's id or null.
- */
- protected abstract String getViewerId();
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(org.eclipse.jface.viewers.DoubleClickEvent)
- */
- @Override
- public void doubleClick(final DoubleClickEvent event) {
- // If an handled and enabled command is registered for the ICommonActionConstants.OPEN
- // retargetable action id, redirect the double click handling to the command handler.
- //
- // Note: The default tree node expansion must be re-implemented in the active handler!
- String commandId = getDoubleClickCommandId();
- Command cmd = null;
- if(commandId != null) {
- ICommandService service = (ICommandService)PlatformUI.getWorkbench().getService(ICommandService.class);
- cmd = service != null ? service.getCommand(commandId) : null;
- }
- if (cmd != null && cmd.isDefined() && cmd.isEnabled()) {
- final Command command = cmd;
- SafeRunner.run(new SafeRunnable(){
- @Override
- public void handleException(Throwable e) {
- // Ignore exception
- }
- @Override
- public void run() throws Exception {
- IHandlerService handlerSvc = (IHandlerService)PlatformUI.getWorkbench().getService(IHandlerService.class);
- Assert.isNotNull(handlerSvc);
-
- ISelection selection = event.getSelection();
- EvaluationContext ctx = new EvaluationContext(handlerSvc.getCurrentState(), selection);
- ctx.addVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME, selection);
- ctx.addVariable(ISources.ACTIVE_MENU_SELECTION_NAME, selection);
- ctx.setAllowPluginActivation(true);
-
- ParameterizedCommand pCmd = ParameterizedCommand.generateCommand(command, null);
- Assert.isNotNull(pCmd);
-
- handlerSvc.executeCommandInContext(pCmd, null, ctx);
- }});
- } else {
- IStructuredSelection selection = (IStructuredSelection) event.getSelection();
- Object element = selection.getFirstElement();
- TreeViewer viewer = (TreeViewer) treeControl.getViewer();
- if (viewer.isExpandable(element)) {
- viewer.setExpandedState(element, !viewer.getExpandedState(element));
- }
- }
- }
-}
+/*******************************************************************************
+ * 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.ui.views.editor.pages;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.net.URL;
+
+import org.eclipse.core.commands.Command;
+import org.eclipse.core.commands.ParameterizedCommand;
+import org.eclipse.core.expressions.EvaluationContext;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.SafeRunner;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.util.SafeRunnable;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ILabelDecorator;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreePath;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWTException;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.ControlListener;
+import org.eclipse.swt.events.FocusAdapter;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.tcf.te.core.interfaces.IFilterable;
+import org.eclipse.tcf.te.core.interfaces.IPropertyChangeProvider;
+import org.eclipse.tcf.te.ui.forms.CustomFormToolkit;
+import org.eclipse.tcf.te.ui.trees.TreeControl;
+import org.eclipse.tcf.te.ui.utils.TreeViewerUtil;
+import org.eclipse.ui.ISources;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.commands.ICommandService;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.widgets.Form;
+import org.eclipse.ui.handlers.IHandlerService;
+import org.eclipse.ui.part.MultiPageSelectionProvider;
+import org.osgi.framework.Bundle;
+
+/**
+ * Tree viewer based editor page implementation.
+ */
+public abstract class TreeViewerExplorerEditorPage extends AbstractCustomFormToolkitEditorPage implements IDoubleClickListener {
+ // The references to the pages subcontrol's (needed for disposal)
+ private TreeControl treeControl;
+ private IToolBarManager toolbarMgr;
+ private PropertyChangeListener pcListener;
+ private Image formImage;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.forms.editor.FormPage#dispose()
+ */
+ @Override
+ public void dispose() {
+ IPropertyChangeProvider provider = getPropertyChangeProvider();
+ if(provider != null && pcListener != null) {
+ provider.removePropertyChangeListener(pcListener);
+ }
+ if(formImage != null) {
+ formImage.dispose();
+ }
+ if (treeControl != null) { treeControl.dispose(); treeControl = null; }
+ super.dispose();
+ }
+
+ /**
+ * Set the initial focus to the tree.
+ */
+ @Override
+ public void setFocus() {
+ Control control = treeControl.getViewer().getControl();
+ if(control != null && !control.isDisposed()) {
+ control.setFocus();
+ }
+ else {
+ super.setFocus();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.views.editor.pages.AbstractEditorPage#setInitializationData(org.eclipse.core.runtime.IConfigurationElement, java.lang.String, java.lang.Object)
+ */
+ @Override
+ public void setInitializationData(IConfigurationElement config, String propertyName, Object data) {
+ super.setInitializationData(config, propertyName, data);
+ String iconPath = config.getAttribute("icon"); //$NON-NLS-1$
+ if(iconPath != null) {
+ String bundleId = config.getContributor().getName();
+ Bundle bundle = Platform.getBundle(bundleId);
+ if(bundle != null) {
+ URL iconURL = bundle.getEntry(iconPath);
+ if(iconURL != null) {
+ ImageDescriptor iconDesc = ImageDescriptor.createFromURL(iconURL);
+ if(iconDesc != null) {
+ formImage = iconDesc.createImage();
+ }
+ }
+ }
+ }
+ treeControl = doCreateTreeControl();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.views.editor.pages.AbstractCustomFormToolkitEditorPage#getFormImage()
+ */
+ @Override
+ protected Image getFormImage() {
+ return formImage;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.views.editor.pages.AbstractCustomFormToolkitEditorPage#createToolbarContributionItems(org.eclipse.jface.action.IToolBarManager)
+ */
+ @Override
+ protected void createToolbarContributionItems(IToolBarManager manager) {
+ this.toolbarMgr = manager;
+ treeControl.createToolbarContributionItems(manager);
+ super.createToolbarContributionItems(manager);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.views.editor.pages.AbstractCustomFormToolkitEditorPage#doCreateFormContent(org.eclipse.swt.widgets.Composite, org.eclipse.tcf.te.ui.forms.CustomFormToolkit)
+ */
+ @Override
+ protected void doCreateFormContent(Composite parent, CustomFormToolkit toolkit) {
+ Assert.isNotNull(parent);
+ Assert.isNotNull(toolkit);
+
+ // Setup the tree control
+ Assert.isNotNull(treeControl);
+ treeControl.setupFormPanel(parent, toolkit);
+
+ // Register the context menu at the parent workbench part site.
+ getSite().registerContextMenu(getId(), treeControl.getContextMenuManager(), treeControl.getViewer());
+
+ // Set the initial input
+ Object input = getViewerInput();
+ treeControl.getViewer().setInput(input);
+
+ addViewerListeners();
+
+ // adjust the tree column width initially to take the full size of control
+ adjustTreeColumnWidth(treeControl.getViewer());
+
+ updateUI();
+ }
+
+ /**
+ * Determines the current visible width of the tree control and
+ * adjust the column width according to there relative weight.
+ *
+ * @param viewer The viewer or <code>null</code>.
+ */
+ protected void adjustTreeColumnWidth(Viewer viewer) {
+ if (!(viewer instanceof TreeViewer)) return;
+
+ final TreeViewer treeViewer = (TreeViewer)viewer;
+ final Tree tree = treeViewer.getTree();
+ tree.addControlListener(new ControlListener() {
+
+ @Override
+ public void controlResized(ControlEvent e) {
+ int sumColumnWidth = 0;
+ int treeWidth = tree.getSize().x - tree.getVerticalBar().getSize().x;
+
+ TreeColumn[] columns = tree.getColumns();
+
+ // Summarize the tree column width
+ for (TreeColumn column : columns) {
+ Object widthHint = column.getData("widthHint"); //$NON-NLS-1$
+ sumColumnWidth += widthHint instanceof Integer ? ((Integer)widthHint).intValue() : column.getWidth();
+ }
+
+ // Calculate the new width for each column
+ int sumColumnWidth2 = 0;
+ TreeColumn maxColumn = null;
+ for (TreeColumn column : columns) {
+ Object widthHint = column.getData("widthHint"); //$NON-NLS-1$
+ int width = widthHint instanceof Integer ? ((Integer)widthHint).intValue() : column.getWidth();
+ int weight = (width * 100) / sumColumnWidth;
+ int newWidth = (weight * treeWidth) / 100;
+ sumColumnWidth2 += newWidth;
+ column.setWidth(newWidth);
+ if (maxColumn == null || maxColumn.getWidth() < column.getWidth()) {
+ maxColumn = column;
+ }
+ }
+
+ // If we end up with a slighter larger width of all columns than
+ // the tree widget is, reduce the size of the largest column
+ if (sumColumnWidth2 > treeWidth && maxColumn != null) {
+ int delta = sumColumnWidth2 - treeWidth + 2;
+ maxColumn.setWidth(maxColumn.getWidth() - delta);
+ }
+
+ tree.removeControlListener(this);
+ }
+
+ @Override
+ public void controlMoved(ControlEvent e) {
+ }
+ });
+ }
+
+ /**
+ * Add tree viewer listeners to the tree control.
+ */
+ private void addViewerListeners() {
+ TreeViewer viewer = (TreeViewer) treeControl.getViewer();
+ viewer.addSelectionChangedListener(new ISelectionChangedListener(){
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ propagateSelection();
+ }});
+ viewer.getTree().addFocusListener(new FocusAdapter(){
+ @Override
+ public void focusGained(FocusEvent e) {
+ propagateSelection();
+ }
+ });
+ viewer.addDoubleClickListener(this);
+
+ IPropertyChangeProvider provider = getPropertyChangeProvider();
+ if(provider != null) {
+ pcListener = new PropertyChangeListener() {
+ @Override
+ public void propertyChange(final PropertyChangeEvent event) {
+ Object object = event.getSource();
+ Object input = getTreeViewerInput();
+ if (object == input) {
+ if (Display.getCurrent() != null) {
+ updateUI();
+ }
+ else {
+ Display display = getSite().getShell().getDisplay();
+ display.asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ updateUI();
+ }
+ });
+ }
+ }
+ }
+ };
+ provider.addPropertyChangeListener(pcListener);
+ }
+ }
+
+ @Override
+ public Object getAdapter(Class adapter) {
+ if(TreeViewer.class.equals(adapter)) {
+ return treeControl.getViewer();
+ }
+ return super.getAdapter(adapter);
+ }
+
+ /**
+ * Get an adapter instance from the adaptable with the specified
+ * adapter interface.
+ *
+ * @param adaptable The adaptable to get the adapter.
+ * @param adapter The adapter interface class.
+ * @return An adapter or null if it does not adapt to this type.
+ */
+ @SuppressWarnings("rawtypes")
+ private Object getAdapter(Object adaptable, Class adapter) {
+ Object adapted = null;
+ if(adapter.isInstance(adaptable)) {
+ adapted = adaptable;
+ }
+ if(adapted == null && adaptable instanceof IAdaptable) {
+ adapted = ((IAdaptable)adaptable).getAdapter(adapter);
+ }
+ if(adapted == null && adaptable != null) {
+ adapted = Platform.getAdapterManager().getAdapter(adaptable, adapter);
+ }
+ return adapted;
+ }
+
+ /**
+ * Get an adapter of IFilteringLabelDecorator.
+ *
+ * @return an IFilteringLabelDecorator adapter or null if it does not adapt to IFilteringLabelDecorator.
+ */
+ private IFilterable adaptFilterable() {
+ Object input = getTreeViewerInput();
+ if (input != null) {
+ return (IFilterable) getAdapter(input, IFilterable.class);
+ }
+ return null;
+ }
+
+ protected abstract Object getViewerInput();
+
+ /**
+ * Get the viewer input adapter for the input.
+ *
+ * @param input the input of the tree viewer.
+ * @return The adapter.
+ */
+ private IPropertyChangeProvider getPropertyChangeProvider() {
+ Object input = getTreeViewerInput();
+ if (input != null) {
+ return (IPropertyChangeProvider) getAdapter(input, IPropertyChangeProvider.class);
+ }
+ return null;
+ }
+
+ Object getTreeViewerInput() {
+ if (treeControl != null && treeControl.getViewer() != null) {
+ return treeControl.getViewer().getInput();
+ }
+ return null;
+ }
+
+ /**
+ * Creates and returns a tree control.
+ *
+ * @return The new tree control.
+ */
+ protected TreeControl doCreateTreeControl() {
+ return new TreeControl(getViewerId(), this);
+ }
+
+ /**
+ * Returns the associated tree control.
+ *
+ * @return The associated tree control or <code>null</code>.
+ */
+ public final TreeControl getTreeControl() {
+ return treeControl;
+ }
+
+ /**
+ * Update the page's ui including its toolbar and title text and image.
+ */
+ protected void updateUI() {
+ toolbarMgr.update(true);
+ IManagedForm managedForm = getManagedForm();
+ Form form = managedForm.getForm().getForm();
+ Object element = getTreeViewerInput();
+ boolean filterEnabled = false;
+ IFilterable filterDecorator = adaptFilterable();
+ if (filterDecorator != null) {
+ TreeViewer viewer = (TreeViewer) treeControl.getViewer();
+ filterEnabled = TreeViewerUtil.isFiltering(viewer, TreePath.EMPTY);
+ }
+ ILabelDecorator titleDecorator = getTitleBarDecorator();
+ String text = getFormTitle();
+ if (text != null) {
+ if (titleDecorator != null) {
+ text = titleDecorator.decorateText(text, element);
+ }
+ if (filterEnabled) {
+ TreeViewer viewer = (TreeViewer) treeControl.getViewer();
+ text = TreeViewerUtil.getDecoratedText(text, viewer, TreePath.EMPTY);
+ }
+ }
+ Image image = getFormImage();
+ if (image != null) {
+ if (titleDecorator != null) {
+ image = titleDecorator.decorateImage(image, element);
+ }
+ if (filterEnabled) {
+ TreeViewer viewer = (TreeViewer) treeControl.getViewer();
+ image = TreeViewerUtil.getDecoratedImage(image, viewer, TreePath.EMPTY);
+ }
+ }
+ if (text != null) {
+ try {
+ form.setText(text);
+ }
+ catch (Exception e) {
+ // Ignore any disposed exception
+ }
+ }
+ if (image != null) {
+ try {
+ form.setImage(image);
+ }
+ catch (Exception e) {
+ // Ignore any disposed exception
+ }
+ }
+ }
+
+ /**
+ * Get the title bar's decorator or null if there's no decorator for it.
+ */
+ protected ILabelDecorator getTitleBarDecorator() {
+ return null;
+ }
+
+ /**
+ * Propagate the current selection to the editor's selection provider.
+ */
+ protected void propagateSelection() {
+ ISelection selection = treeControl.getViewer().getSelection();
+ ISelectionProvider selectionProvider = getSite().getSelectionProvider();
+ // If the parent control is already disposed, we have no real chance of
+ // testing for it. Catch the SWT exception here just in case.
+ try {
+ selectionProvider.setSelection(selection);
+ if (selectionProvider instanceof MultiPageSelectionProvider) {
+ SelectionChangedEvent changedEvent = new SelectionChangedEvent(selectionProvider, selection);
+ ((MultiPageSelectionProvider) selectionProvider).firePostSelectionChanged(changedEvent);
+ }
+ }
+ catch (SWTException e) {
+ /* ignored on purpose */
+ }
+ }
+
+ /**
+ * Get the id of the command invoked when the tree is double-clicked.
+ * If the id is null, then no command is invoked.
+ *
+ * @return The double-click command id.
+ */
+ protected String getDoubleClickCommandId() {
+ return null;
+ }
+
+ /**
+ * Get the tree viewer's id. This viewer id is used by
+ * viewer extension to define columns and filters.
+ *
+ * @return This viewer's id or null.
+ */
+ protected abstract String getViewerId();
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(org.eclipse.jface.viewers.DoubleClickEvent)
+ */
+ @Override
+ public void doubleClick(final DoubleClickEvent event) {
+ // If an handled and enabled command is registered for the ICommonActionConstants.OPEN
+ // retargetable action id, redirect the double click handling to the command handler.
+ //
+ // Note: The default tree node expansion must be re-implemented in the active handler!
+ String commandId = getDoubleClickCommandId();
+ Command cmd = null;
+ if(commandId != null) {
+ ICommandService service = (ICommandService)PlatformUI.getWorkbench().getService(ICommandService.class);
+ cmd = service != null ? service.getCommand(commandId) : null;
+ }
+ if (cmd != null && cmd.isDefined() && cmd.isEnabled()) {
+ final Command command = cmd;
+ SafeRunner.run(new SafeRunnable(){
+ @Override
+ public void handleException(Throwable e) {
+ // Ignore exception
+ }
+ @Override
+ public void run() throws Exception {
+ IHandlerService handlerSvc = (IHandlerService)PlatformUI.getWorkbench().getService(IHandlerService.class);
+ Assert.isNotNull(handlerSvc);
+
+ ISelection selection = event.getSelection();
+ EvaluationContext ctx = new EvaluationContext(handlerSvc.getCurrentState(), selection);
+ ctx.addVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME, selection);
+ ctx.addVariable(ISources.ACTIVE_MENU_SELECTION_NAME, selection);
+ ctx.setAllowPluginActivation(true);
+
+ ParameterizedCommand pCmd = ParameterizedCommand.generateCommand(command, null);
+ Assert.isNotNull(pCmd);
+
+ handlerSvc.executeCommandInContext(pCmd, null, ctx);
+ }});
+ } else {
+ IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+ Object element = selection.getFirstElement();
+ TreeViewer viewer = (TreeViewer) treeControl.getViewer();
+ if (viewer.isExpandable(element)) {
+ viewer.setExpandedState(element, !viewer.getExpandedState(element));
+ }
+ }
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/events/AbstractEventListener.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/events/AbstractEventListener.java
index b15ff9159..6ae3c99bd 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/events/AbstractEventListener.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/events/AbstractEventListener.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * 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
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/events/ViewerContentChangeEvent.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/events/ViewerContentChangeEvent.java
index 7e10dfc8c..a28276106 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/events/ViewerContentChangeEvent.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/events/ViewerContentChangeEvent.java
@@ -1,84 +1,84 @@
-/*******************************************************************************
- * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.ui.views.events;
-
-import java.util.EventObject;
-
-import org.eclipse.tcf.te.runtime.activator.CoreBundleActivator;
-import org.eclipse.tcf.te.runtime.interfaces.tracing.ITraceIds;
-
-/**
- * Target Explorer view viewer change event implementation.
- */
-public class ViewerContentChangeEvent extends EventObject {
- private static final long serialVersionUID = 7168841012111347036L;
-
- private String eventId;
-
- /**
- * Event id used if elements got directly added to the viewer.
- */
- public static final String ADD = "add"; //$NON-NLS-1$
-
- /**
- * Event id used if elements got directly removed the viewer.
- */
- public static final String REMOVE = "remove"; //$NON-NLS-1$
-
- /**
- * Event id used if the viewer got refreshed.
- */
- public static final String REFRESH = "refresh"; //$NON-NLS-1$
-
- /**
- * Constructor.
- *
- * @param source The source object. Must not be <code>null</code>.
- * @param eventId The event id. Must not be <code>null</code>.
- *
- * @exception IllegalArgumentException if eventId == null.
- */
- public ViewerContentChangeEvent(Object source, String eventId) {
- super(source);
-
- if (eventId == null) throw new IllegalArgumentException("null eventId"); //$NON-NLS-1$
- this.eventId = eventId;
- }
-
- /**
- * Returns the event id.
- *
- * @return The event id.
- */
- public final String getEventId() {
- return eventId;
- }
-
- /* (non-Javadoc)
- * @see java.util.EventObject#toString()
- */
- @Override
- public String toString() {
- StringBuilder toString = new StringBuilder(getClass().getName());
-
- String prefix = ""; //$NON-NLS-1$
- // if tracing the event, formating them a little bit better readable.
- if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITraceIds.TRACE_EVENTS))
- prefix = "\n\t\t"; //$NON-NLS-1$
-
- toString.append(prefix + "{eventId="); //$NON-NLS-1$
- toString.append(eventId);
- toString.append("," + prefix + "source="); //$NON-NLS-1$ //$NON-NLS-2$
- toString.append(source);
- toString.append("}"); //$NON-NLS-1$
-
- return toString.toString();
- }
-}
+/*******************************************************************************
+ * 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.ui.views.events;
+
+import java.util.EventObject;
+
+import org.eclipse.tcf.te.runtime.activator.CoreBundleActivator;
+import org.eclipse.tcf.te.runtime.interfaces.tracing.ITraceIds;
+
+/**
+ * Target Explorer view viewer change event implementation.
+ */
+public class ViewerContentChangeEvent extends EventObject {
+ private static final long serialVersionUID = 7168841012111347036L;
+
+ private String eventId;
+
+ /**
+ * Event id used if elements got directly added to the viewer.
+ */
+ public static final String ADD = "add"; //$NON-NLS-1$
+
+ /**
+ * Event id used if elements got directly removed the viewer.
+ */
+ public static final String REMOVE = "remove"; //$NON-NLS-1$
+
+ /**
+ * Event id used if the viewer got refreshed.
+ */
+ public static final String REFRESH = "refresh"; //$NON-NLS-1$
+
+ /**
+ * Constructor.
+ *
+ * @param source The source object. Must not be <code>null</code>.
+ * @param eventId The event id. Must not be <code>null</code>.
+ *
+ * @exception IllegalArgumentException if eventId == null.
+ */
+ public ViewerContentChangeEvent(Object source, String eventId) {
+ super(source);
+
+ if (eventId == null) throw new IllegalArgumentException("null eventId"); //$NON-NLS-1$
+ this.eventId = eventId;
+ }
+
+ /**
+ * Returns the event id.
+ *
+ * @return The event id.
+ */
+ public final String getEventId() {
+ return eventId;
+ }
+
+ /* (non-Javadoc)
+ * @see java.util.EventObject#toString()
+ */
+ @Override
+ public String toString() {
+ StringBuilder toString = new StringBuilder(getClass().getName());
+
+ String prefix = ""; //$NON-NLS-1$
+ // if tracing the event, formating them a little bit better readable.
+ if (CoreBundleActivator.getTraceHandler().isSlotEnabled(0, ITraceIds.TRACE_EVENTS))
+ prefix = "\n\t\t"; //$NON-NLS-1$
+
+ toString.append(prefix + "{eventId="); //$NON-NLS-1$
+ toString.append(eventId);
+ toString.append("," + prefix + "source="); //$NON-NLS-1$ //$NON-NLS-2$
+ toString.append(source);
+ toString.append("}"); //$NON-NLS-1$
+
+ return toString.toString();
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/expressions/PropertyTester.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/expressions/PropertyTester.java
index bcbbd614b..d71046ff4 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/expressions/PropertyTester.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/expressions/PropertyTester.java
@@ -1,48 +1,48 @@
-/*******************************************************************************
- * 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.ui.views.expressions;
-
-import org.eclipse.tcf.te.runtime.services.ServiceManager;
-import org.eclipse.tcf.te.runtime.services.interfaces.IUIService;
-import org.eclipse.tcf.te.ui.interfaces.handler.IEditorHandlerDelegate;
-import org.eclipse.tcf.te.ui.views.editor.Editor;
-import org.eclipse.tcf.te.ui.views.editor.EditorInput;
-import org.eclipse.tcf.te.ui.views.extensions.EditorPageBindingExtensionPointManager;
-import org.eclipse.ui.IEditorInput;
-
-
-/**
- * Property tester implementation.
- */
-public class PropertyTester extends org.eclipse.core.expressions.PropertyTester {
-
- /* (non-Javadoc)
- * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
- */
- @Override
- public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
-
- if ("hasApplicableEditorBindings".equals(property)) { //$NON-NLS-1$
- IUIService service = ServiceManager.getInstance().getService(receiver, IUIService.class);
- IEditorHandlerDelegate delegate = service != null ? service.getDelegate(receiver, IEditorHandlerDelegate.class) : null;
- IEditorInput input = (delegate != null) ? delegate.getEditorInput(receiver) : new EditorInput(receiver);
-
- return (expectedValue != null ? expectedValue : Boolean.TRUE).equals(Boolean.valueOf(EditorPageBindingExtensionPointManager.getInstance().getApplicableEditorPageBindings(input).length > 0));
- }
-
- if ("isDirty".equals(property) && receiver instanceof Editor && expectedValue instanceof Boolean) { //$NON-NLS-1$
- Editor editor = (Editor) receiver;
- return ((Boolean)expectedValue).booleanValue() == editor.isDirty();
- }
-
- return false;
- }
-
-}
+/*******************************************************************************
+ * 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.ui.views.expressions;
+
+import org.eclipse.tcf.te.runtime.services.ServiceManager;
+import org.eclipse.tcf.te.runtime.services.interfaces.IUIService;
+import org.eclipse.tcf.te.ui.interfaces.handler.IEditorHandlerDelegate;
+import org.eclipse.tcf.te.ui.views.editor.Editor;
+import org.eclipse.tcf.te.ui.views.editor.EditorInput;
+import org.eclipse.tcf.te.ui.views.extensions.EditorPageBindingExtensionPointManager;
+import org.eclipse.ui.IEditorInput;
+
+
+/**
+ * Property tester implementation.
+ */
+public class PropertyTester extends org.eclipse.core.expressions.PropertyTester {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
+ */
+ @Override
+ public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
+
+ if ("hasApplicableEditorBindings".equals(property)) { //$NON-NLS-1$
+ IUIService service = ServiceManager.getInstance().getService(receiver, IUIService.class);
+ IEditorHandlerDelegate delegate = service != null ? service.getDelegate(receiver, IEditorHandlerDelegate.class) : null;
+ IEditorInput input = (delegate != null) ? delegate.getEditorInput(receiver) : new EditorInput(receiver);
+
+ return (expectedValue != null ? expectedValue : Boolean.TRUE).equals(Boolean.valueOf(EditorPageBindingExtensionPointManager.getInstance().getApplicableEditorPageBindings(input).length > 0));
+ }
+
+ if ("isDirty".equals(property) && receiver instanceof Editor && expectedValue instanceof Boolean) { //$NON-NLS-1$
+ Editor editor = (Editor) receiver;
+ return ((Boolean)expectedValue).booleanValue() == editor.isDirty();
+ }
+
+ return false;
+ }
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/expressions/SelectionSourceProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/expressions/SelectionSourceProvider.java
index c1dc9d004..4b3c9c0f7 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/expressions/SelectionSourceProvider.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/expressions/SelectionSourceProvider.java
@@ -1,207 +1,207 @@
-/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.ui.views.expressions;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.expressions.IEvaluationContext;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.tcf.te.ui.views.interfaces.IUIConstants;
-import org.eclipse.ui.AbstractSourceProvider;
-import org.eclipse.ui.INullSelectionListener;
-import org.eclipse.ui.ISelectionService;
-import org.eclipse.ui.ISources;
-import org.eclipse.ui.IWindowListener;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.services.IEvaluationService;
-import org.eclipse.ui.services.IServiceLocator;
-
-/**
- * Selection service source provider implementation.
- */
-public class SelectionSourceProvider extends AbstractSourceProvider implements INullSelectionListener, IWindowListener {
-
- /**
- * Source name identifying the System Manager view selection.
- */
- public static final String systemManagerViewSelectionName = "systemManagerViewSelection"; //$NON-NLS-1$
-
- /**
- * Source name identifying the Debug View view selection.
- */
- public static final String debugViewSelectionName = "debugViewSelection"; //$NON-NLS-1$
-
- // The internal list of provided source names
- private final static String[] PROVIDED_SOURCE_NAMES = { systemManagerViewSelectionName, debugViewSelectionName };
-
- /**
- * Debug view identifier (value <code>"org.eclipse.debug.ui.DebugView"</code>).
- * @see IDebugUIConstants
- */
- private static final String ID_DEBUG_VIEW = "org.eclipse.debug.ui.DebugView"; //$NON-NLS-1$
-
- // The map containing the cached selections
- private final Map<String, ISelection> cache = new HashMap<String, ISelection>();
-
- // The reference to the expression evaluation service
- private IEvaluationService service = null;
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.AbstractSourceProvider#initialize(org.eclipse.ui.services.IServiceLocator)
- */
- @Override
- public void initialize(IServiceLocator locator) {
- super.initialize(locator);
-
- if (PlatformUI.getWorkbench() != null) {
- // Register the service provider as workbench window listener
- PlatformUI.getWorkbench().addWindowListener(this);
- // Initialize the selection cache and the selection listener
- if (PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null) {
- windowOpened(PlatformUI.getWorkbench().getActiveWorkbenchWindow());
- }
- }
-
- // Register the source provider with the expression evaluation service
- if (locator.hasService(IEvaluationService.class)) {
- service = (IEvaluationService)locator.getService(IEvaluationService.class);
- if (service != null) service.addSourceProvider(this);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.ISourceProvider#dispose()
- */
- @Override
- public void dispose() {
- // Unregister the selection listener
- if (PlatformUI.getWorkbench() != null) {
- // Unregister the service provide as workbench window listener
- PlatformUI.getWorkbench().removeWindowListener(this);
- // Unregister the selection listener
- if (PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null) {
- windowClosed(PlatformUI.getWorkbench().getActiveWorkbenchWindow());
- }
- }
-
- // Unregister the source provider from the expression evaluation service
- if (service != null) { service.removeSourceProvider(this); service = null; }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.ISourceProvider#getProvidedSourceNames()
- */
- @Override
- public String[] getProvidedSourceNames() {
- return PROVIDED_SOURCE_NAMES;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.ISourceProvider#getCurrentState()
- */
- @Override
- public Map getCurrentState() {
- Map<String, Object> state = new HashMap<String, Object>();
-
- ISelection selection = cache.get(IUIConstants.ID_EXPLORER);
- state.put(systemManagerViewSelectionName, selection != null ? selection : IEvaluationContext.UNDEFINED_VARIABLE);
-
- selection = cache.get(ID_DEBUG_VIEW);
- state.put(debugViewSelectionName, selection != null ? selection : IEvaluationContext.UNDEFINED_VARIABLE);
-
- return state;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
- */
- @Override
- public void selectionChanged(IWorkbenchPart part, ISelection selection) {
- String partId = part != null ? part.getSite().getId() : null;
- if (!IUIConstants.ID_EXPLORER.equals(partId) && !ID_DEBUG_VIEW.equals(partId)) {
- return;
- }
-
- // Update the cached selection
- if (selection != null) cache.put(partId, selection);
- else cache.remove(partId);
-
- // Fire the source changed notification
- fireSourceChanged(ISources.WORKBENCH, IUIConstants.ID_EXPLORER.equals(partId) ? systemManagerViewSelectionName : debugViewSelectionName,
- selection != null ? selection : IEvaluationContext.UNDEFINED_VARIABLE);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWindowListener#windowActivated(org.eclipse.ui.IWorkbenchWindow)
- */
- @Override
- public void windowActivated(IWorkbenchWindow window) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWindowListener#windowDeactivated(org.eclipse.ui.IWorkbenchWindow)
- */
- @Override
- public void windowDeactivated(IWorkbenchWindow window) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWindowListener#windowClosed(org.eclipse.ui.IWorkbenchWindow)
- */
- @Override
- public void windowClosed(IWorkbenchWindow window) {
- // Remove ourself as selection listener
- if (window != null && window.getSelectionService() != null) {
- ISelectionService service = window.getSelectionService();
- service.removePostSelectionListener(IUIConstants.ID_EXPLORER, this);
- service.removePostSelectionListener(ID_DEBUG_VIEW, this);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IWindowListener#windowOpened(org.eclipse.ui.IWorkbenchWindow)
- */
- @Override
- public void windowOpened(IWorkbenchWindow window) {
- // A new workbench window opened. We have to register
- // ourself as selection listener if not done
- if (window != null && window.getSelectionService() != null) {
- // Get the selection service
- ISelectionService service = window.getSelectionService();
-
- // Unregister the source provider first, just in case to
- // avoid the listener to be registered multiple time
- service.removePostSelectionListener(IUIConstants.ID_EXPLORER, this);
- service.removePostSelectionListener(ID_DEBUG_VIEW, this);
-
- // Register the source provider now as post selection listener
- service.addPostSelectionListener(IUIConstants.ID_EXPLORER, this);
- service.addPostSelectionListener(ID_DEBUG_VIEW, this);
-
- // Initialize the selections
- ISelection selection = service.getSelection(IUIConstants.ID_EXPLORER);
- if (selection != null) cache.put(IUIConstants.ID_EXPLORER, selection);
- else cache.remove(IUIConstants.ID_EXPLORER);
-
- fireSourceChanged(ISources.WORKBENCH, systemManagerViewSelectionName,
- selection != null ? selection : IEvaluationContext.UNDEFINED_VARIABLE);
-
- selection = service.getSelection(ID_DEBUG_VIEW);
- if (selection != null) cache.put(ID_DEBUG_VIEW, selection);
- else cache.remove(ID_DEBUG_VIEW);
-
- fireSourceChanged(ISources.WORKBENCH, debugViewSelectionName,
- selection != null ? selection : IEvaluationContext.UNDEFINED_VARIABLE);
- }
- }
-}
+/*******************************************************************************
+ * 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.ui.views.expressions;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.expressions.IEvaluationContext;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.tcf.te.ui.views.interfaces.IUIConstants;
+import org.eclipse.ui.AbstractSourceProvider;
+import org.eclipse.ui.INullSelectionListener;
+import org.eclipse.ui.ISelectionService;
+import org.eclipse.ui.ISources;
+import org.eclipse.ui.IWindowListener;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.services.IEvaluationService;
+import org.eclipse.ui.services.IServiceLocator;
+
+/**
+ * Selection service source provider implementation.
+ */
+public class SelectionSourceProvider extends AbstractSourceProvider implements INullSelectionListener, IWindowListener {
+
+ /**
+ * Source name identifying the System Manager view selection.
+ */
+ public static final String systemManagerViewSelectionName = "systemManagerViewSelection"; //$NON-NLS-1$
+
+ /**
+ * Source name identifying the Debug View view selection.
+ */
+ public static final String debugViewSelectionName = "debugViewSelection"; //$NON-NLS-1$
+
+ // The internal list of provided source names
+ private final static String[] PROVIDED_SOURCE_NAMES = { systemManagerViewSelectionName, debugViewSelectionName };
+
+ /**
+ * Debug view identifier (value <code>"org.eclipse.debug.ui.DebugView"</code>).
+ * @see IDebugUIConstants
+ */
+ private static final String ID_DEBUG_VIEW = "org.eclipse.debug.ui.DebugView"; //$NON-NLS-1$
+
+ // The map containing the cached selections
+ private final Map<String, ISelection> cache = new HashMap<String, ISelection>();
+
+ // The reference to the expression evaluation service
+ private IEvaluationService service = null;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.AbstractSourceProvider#initialize(org.eclipse.ui.services.IServiceLocator)
+ */
+ @Override
+ public void initialize(IServiceLocator locator) {
+ super.initialize(locator);
+
+ if (PlatformUI.getWorkbench() != null) {
+ // Register the service provider as workbench window listener
+ PlatformUI.getWorkbench().addWindowListener(this);
+ // Initialize the selection cache and the selection listener
+ if (PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null) {
+ windowOpened(PlatformUI.getWorkbench().getActiveWorkbenchWindow());
+ }
+ }
+
+ // Register the source provider with the expression evaluation service
+ if (locator.hasService(IEvaluationService.class)) {
+ service = (IEvaluationService)locator.getService(IEvaluationService.class);
+ if (service != null) service.addSourceProvider(this);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.ISourceProvider#dispose()
+ */
+ @Override
+ public void dispose() {
+ // Unregister the selection listener
+ if (PlatformUI.getWorkbench() != null) {
+ // Unregister the service provide as workbench window listener
+ PlatformUI.getWorkbench().removeWindowListener(this);
+ // Unregister the selection listener
+ if (PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null) {
+ windowClosed(PlatformUI.getWorkbench().getActiveWorkbenchWindow());
+ }
+ }
+
+ // Unregister the source provider from the expression evaluation service
+ if (service != null) { service.removeSourceProvider(this); service = null; }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.ISourceProvider#getProvidedSourceNames()
+ */
+ @Override
+ public String[] getProvidedSourceNames() {
+ return PROVIDED_SOURCE_NAMES;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.ISourceProvider#getCurrentState()
+ */
+ @Override
+ public Map getCurrentState() {
+ Map<String, Object> state = new HashMap<String, Object>();
+
+ ISelection selection = cache.get(IUIConstants.ID_EXPLORER);
+ state.put(systemManagerViewSelectionName, selection != null ? selection : IEvaluationContext.UNDEFINED_VARIABLE);
+
+ selection = cache.get(ID_DEBUG_VIEW);
+ state.put(debugViewSelectionName, selection != null ? selection : IEvaluationContext.UNDEFINED_VARIABLE);
+
+ return state;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection)
+ */
+ @Override
+ public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+ String partId = part != null ? part.getSite().getId() : null;
+ if (!IUIConstants.ID_EXPLORER.equals(partId) && !ID_DEBUG_VIEW.equals(partId)) {
+ return;
+ }
+
+ // Update the cached selection
+ if (selection != null) cache.put(partId, selection);
+ else cache.remove(partId);
+
+ // Fire the source changed notification
+ fireSourceChanged(ISources.WORKBENCH, IUIConstants.ID_EXPLORER.equals(partId) ? systemManagerViewSelectionName : debugViewSelectionName,
+ selection != null ? selection : IEvaluationContext.UNDEFINED_VARIABLE);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWindowListener#windowActivated(org.eclipse.ui.IWorkbenchWindow)
+ */
+ @Override
+ public void windowActivated(IWorkbenchWindow window) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWindowListener#windowDeactivated(org.eclipse.ui.IWorkbenchWindow)
+ */
+ @Override
+ public void windowDeactivated(IWorkbenchWindow window) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWindowListener#windowClosed(org.eclipse.ui.IWorkbenchWindow)
+ */
+ @Override
+ public void windowClosed(IWorkbenchWindow window) {
+ // Remove ourself as selection listener
+ if (window != null && window.getSelectionService() != null) {
+ ISelectionService service = window.getSelectionService();
+ service.removePostSelectionListener(IUIConstants.ID_EXPLORER, this);
+ service.removePostSelectionListener(ID_DEBUG_VIEW, this);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWindowListener#windowOpened(org.eclipse.ui.IWorkbenchWindow)
+ */
+ @Override
+ public void windowOpened(IWorkbenchWindow window) {
+ // A new workbench window opened. We have to register
+ // ourself as selection listener if not done
+ if (window != null && window.getSelectionService() != null) {
+ // Get the selection service
+ ISelectionService service = window.getSelectionService();
+
+ // Unregister the source provider first, just in case to
+ // avoid the listener to be registered multiple time
+ service.removePostSelectionListener(IUIConstants.ID_EXPLORER, this);
+ service.removePostSelectionListener(ID_DEBUG_VIEW, this);
+
+ // Register the source provider now as post selection listener
+ service.addPostSelectionListener(IUIConstants.ID_EXPLORER, this);
+ service.addPostSelectionListener(ID_DEBUG_VIEW, this);
+
+ // Initialize the selections
+ ISelection selection = service.getSelection(IUIConstants.ID_EXPLORER);
+ if (selection != null) cache.put(IUIConstants.ID_EXPLORER, selection);
+ else cache.remove(IUIConstants.ID_EXPLORER);
+
+ fireSourceChanged(ISources.WORKBENCH, systemManagerViewSelectionName,
+ selection != null ? selection : IEvaluationContext.UNDEFINED_VARIABLE);
+
+ selection = service.getSelection(ID_DEBUG_VIEW);
+ if (selection != null) cache.put(ID_DEBUG_VIEW, selection);
+ else cache.remove(ID_DEBUG_VIEW);
+
+ fireSourceChanged(ISources.WORKBENCH, debugViewSelectionName,
+ selection != null ? selection : IEvaluationContext.UNDEFINED_VARIABLE);
+ }
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/extensions/EditorPageBindingExtensionPointManager.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/extensions/EditorPageBindingExtensionPointManager.java
index 0ed911989..ff26ad511 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/extensions/EditorPageBindingExtensionPointManager.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/extensions/EditorPageBindingExtensionPointManager.java
@@ -1,194 +1,194 @@
-/*******************************************************************************
- * 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.ui.views.extensions;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.expressions.EvaluationContext;
-import org.eclipse.core.expressions.EvaluationResult;
-import org.eclipse.core.expressions.Expression;
-import org.eclipse.core.expressions.IEvaluationContext;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager;
-import org.eclipse.tcf.te.runtime.extensions.ExecutableExtensionProxy;
-import org.eclipse.tcf.te.ui.views.activator.UIPlugin;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.ISources;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.handlers.IHandlerService;
-
-
-/**
- * Details editor page binding extension point manager implementation.
- */
-public class EditorPageBindingExtensionPointManager extends AbstractExtensionPointManager<EditorPageBinding> {
-
- /*
- * Thread save singleton instance creation.
- */
- private static class LazyInstance {
- public static EditorPageBindingExtensionPointManager instance = new EditorPageBindingExtensionPointManager();
- }
-
- /**
- * Constructor.
- */
- EditorPageBindingExtensionPointManager() {
- super();
- }
-
- /**
- * Returns the singleton instance of the extension point manager.
- */
- public static EditorPageBindingExtensionPointManager getInstance() {
- return LazyInstance.instance;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager#getExtensionPointId()
- */
- @Override
- protected String getExtensionPointId() {
- return "org.eclipse.tcf.te.ui.views.editorPageBindings"; //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager#getConfigurationElementName()
- */
- @Override
- protected String getConfigurationElementName() {
- return "editorPageBinding"; //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager#doCreateExtensionProxy(org.eclipse.core.runtime.IConfigurationElement)
- */
- @Override
- protected ExecutableExtensionProxy<EditorPageBinding> doCreateExtensionProxy(IConfigurationElement element) throws CoreException {
- return new ExecutableExtensionProxy<EditorPageBinding>(element) {
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.extensions.ExecutableExtensionProxy#newInstance()
- */
- @Override
- public EditorPageBinding newInstance() {
- EditorPageBinding instance = new EditorPageBinding();
- try {
- instance.setInitializationData(getConfigurationElement(), null, null);
- } catch (CoreException e) {
- IStatus status = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(),
- e.getLocalizedMessage(), e);
- UIPlugin.getDefault().getLog().log(status);
- }
- return instance;
- }
- };
- }
-
- /**
- * Returns the applicable editor page bindings for the given data source model node..
- *
- * @param input The active editor input or <code>null</code>.
- * @return The list of applicable editor page bindings or an empty array.
- */
- public EditorPageBinding[] getApplicableEditorPageBindings(IEditorInput input) {
- List<EditorPageBinding> applicable = new ArrayList<EditorPageBinding>();
-
- for (EditorPageBinding binding : getEditorPageBindings()) {
- Expression enablement = binding.getEnablement();
-
- // The page binding is applicable by default if no expression
- // is specified.
- boolean isApplicable = enablement == null;
-
- if (enablement != null && input != null) {
- // Extract the node from the editor input
- Object node = input.getAdapter(Object.class);
- if (node != null) {
- // Set the default variable to the data source model node instance.
- IEvaluationContext currentState = ((IHandlerService)PlatformUI.getWorkbench().getService(IHandlerService.class)).getCurrentState();
- EvaluationContext context = new EvaluationContext(currentState, node);
- // Set the "activeEditorInput" variable to the data source model node instance.
- context.addVariable(ISources.ACTIVE_EDITOR_INPUT_NAME, node);
- // Allow plugin activation
- context.setAllowPluginActivation(true);
- // Evaluate the expression
- try {
- isApplicable = enablement.evaluate(context).equals(EvaluationResult.TRUE);
- } catch (CoreException e) {
- IStatus status = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(), e.getLocalizedMessage(), e);
- UIPlugin.getDefault().getLog().log(status);
- }
- } else {
- // The enablement is false by definition if we cannot
- // determine the data source model node.
- isApplicable = false;
- }
- }
-
- // Add the page if applicable
- if (isApplicable) applicable.add(binding);
- }
-
- for (EditorPageUnBinding unBinding : EditorPageUnBindingExtensionPointManager.getInstance().getApplicableEditorPageUnBindings(input)) {
- Iterator<EditorPageBinding> it = applicable.iterator();
- while (it.hasNext()) {
- EditorPageBinding binding = it.next();
- if (binding.getPageId().equals(unBinding.getPageId())) {
- it.remove();
- }
- }
- }
-
- return applicable.toArray(new EditorPageBinding[applicable.size()]);
- }
-
- /**
- * Returns the list of all contributed editor page bindings.
- *
- * @return The list of contributed editor page bindings, or an empty array.
- */
- public EditorPageBinding[] getEditorPageBindings() {
- List<EditorPageBinding> contributions = new ArrayList<EditorPageBinding>();
- Collection<ExecutableExtensionProxy<EditorPageBinding>> editorPageBindings = getExtensions().values();
- for (ExecutableExtensionProxy<EditorPageBinding> editorPageBinding : editorPageBindings) {
- EditorPageBinding instance = editorPageBinding.getInstance();
- if (instance != null && !contributions.contains(instance)) {
- contributions.add(instance);
- }
- }
-
- return contributions.toArray(new EditorPageBinding[contributions.size()]);
- }
-
- /**
- * Returns the editor page binding identified by its unique id. If no editor
- * page binding with the specified id is registered, <code>null</code> is returned.
- *
- * @param id The unique id of the editor page binding or <code>null</code>
- *
- * @return The editor page instance or <code>null</code>.
- */
- public EditorPageBinding getEditorPageBinding(String id) {
- EditorPageBinding contribution = null;
- if (getExtensions().containsKey(id)) {
- ExecutableExtensionProxy<EditorPageBinding> proxy = getExtensions().get(id);
- // Get the extension instance
- contribution = proxy.getInstance();
- }
-
- return contribution;
- }
-}
+/*******************************************************************************
+ * 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.ui.views.extensions;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.expressions.EvaluationContext;
+import org.eclipse.core.expressions.EvaluationResult;
+import org.eclipse.core.expressions.Expression;
+import org.eclipse.core.expressions.IEvaluationContext;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager;
+import org.eclipse.tcf.te.runtime.extensions.ExecutableExtensionProxy;
+import org.eclipse.tcf.te.ui.views.activator.UIPlugin;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.ISources;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.handlers.IHandlerService;
+
+
+/**
+ * Details editor page binding extension point manager implementation.
+ */
+public class EditorPageBindingExtensionPointManager extends AbstractExtensionPointManager<EditorPageBinding> {
+
+ /*
+ * Thread save singleton instance creation.
+ */
+ private static class LazyInstance {
+ public static EditorPageBindingExtensionPointManager instance = new EditorPageBindingExtensionPointManager();
+ }
+
+ /**
+ * Constructor.
+ */
+ EditorPageBindingExtensionPointManager() {
+ super();
+ }
+
+ /**
+ * Returns the singleton instance of the extension point manager.
+ */
+ public static EditorPageBindingExtensionPointManager getInstance() {
+ return LazyInstance.instance;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager#getExtensionPointId()
+ */
+ @Override
+ protected String getExtensionPointId() {
+ return "org.eclipse.tcf.te.ui.views.editorPageBindings"; //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager#getConfigurationElementName()
+ */
+ @Override
+ protected String getConfigurationElementName() {
+ return "editorPageBinding"; //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager#doCreateExtensionProxy(org.eclipse.core.runtime.IConfigurationElement)
+ */
+ @Override
+ protected ExecutableExtensionProxy<EditorPageBinding> doCreateExtensionProxy(IConfigurationElement element) throws CoreException {
+ return new ExecutableExtensionProxy<EditorPageBinding>(element) {
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.extensions.ExecutableExtensionProxy#newInstance()
+ */
+ @Override
+ public EditorPageBinding newInstance() {
+ EditorPageBinding instance = new EditorPageBinding();
+ try {
+ instance.setInitializationData(getConfigurationElement(), null, null);
+ } catch (CoreException e) {
+ IStatus status = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(),
+ e.getLocalizedMessage(), e);
+ UIPlugin.getDefault().getLog().log(status);
+ }
+ return instance;
+ }
+ };
+ }
+
+ /**
+ * Returns the applicable editor page bindings for the given data source model node..
+ *
+ * @param input The active editor input or <code>null</code>.
+ * @return The list of applicable editor page bindings or an empty array.
+ */
+ public EditorPageBinding[] getApplicableEditorPageBindings(IEditorInput input) {
+ List<EditorPageBinding> applicable = new ArrayList<EditorPageBinding>();
+
+ for (EditorPageBinding binding : getEditorPageBindings()) {
+ Expression enablement = binding.getEnablement();
+
+ // The page binding is applicable by default if no expression
+ // is specified.
+ boolean isApplicable = enablement == null;
+
+ if (enablement != null && input != null) {
+ // Extract the node from the editor input
+ Object node = input.getAdapter(Object.class);
+ if (node != null) {
+ // Set the default variable to the data source model node instance.
+ IEvaluationContext currentState = ((IHandlerService)PlatformUI.getWorkbench().getService(IHandlerService.class)).getCurrentState();
+ EvaluationContext context = new EvaluationContext(currentState, node);
+ // Set the "activeEditorInput" variable to the data source model node instance.
+ context.addVariable(ISources.ACTIVE_EDITOR_INPUT_NAME, node);
+ // Allow plugin activation
+ context.setAllowPluginActivation(true);
+ // Evaluate the expression
+ try {
+ isApplicable = enablement.evaluate(context).equals(EvaluationResult.TRUE);
+ } catch (CoreException e) {
+ IStatus status = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(), e.getLocalizedMessage(), e);
+ UIPlugin.getDefault().getLog().log(status);
+ }
+ } else {
+ // The enablement is false by definition if we cannot
+ // determine the data source model node.
+ isApplicable = false;
+ }
+ }
+
+ // Add the page if applicable
+ if (isApplicable) applicable.add(binding);
+ }
+
+ for (EditorPageUnBinding unBinding : EditorPageUnBindingExtensionPointManager.getInstance().getApplicableEditorPageUnBindings(input)) {
+ Iterator<EditorPageBinding> it = applicable.iterator();
+ while (it.hasNext()) {
+ EditorPageBinding binding = it.next();
+ if (binding.getPageId().equals(unBinding.getPageId())) {
+ it.remove();
+ }
+ }
+ }
+
+ return applicable.toArray(new EditorPageBinding[applicable.size()]);
+ }
+
+ /**
+ * Returns the list of all contributed editor page bindings.
+ *
+ * @return The list of contributed editor page bindings, or an empty array.
+ */
+ public EditorPageBinding[] getEditorPageBindings() {
+ List<EditorPageBinding> contributions = new ArrayList<EditorPageBinding>();
+ Collection<ExecutableExtensionProxy<EditorPageBinding>> editorPageBindings = getExtensions().values();
+ for (ExecutableExtensionProxy<EditorPageBinding> editorPageBinding : editorPageBindings) {
+ EditorPageBinding instance = editorPageBinding.getInstance();
+ if (instance != null && !contributions.contains(instance)) {
+ contributions.add(instance);
+ }
+ }
+
+ return contributions.toArray(new EditorPageBinding[contributions.size()]);
+ }
+
+ /**
+ * Returns the editor page binding identified by its unique id. If no editor
+ * page binding with the specified id is registered, <code>null</code> is returned.
+ *
+ * @param id The unique id of the editor page binding or <code>null</code>
+ *
+ * @return The editor page instance or <code>null</code>.
+ */
+ public EditorPageBinding getEditorPageBinding(String id) {
+ EditorPageBinding contribution = null;
+ if (getExtensions().containsKey(id)) {
+ ExecutableExtensionProxy<EditorPageBinding> proxy = getExtensions().get(id);
+ // Get the extension instance
+ contribution = proxy.getInstance();
+ }
+
+ return contribution;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/extensions/EditorPageExtensionPointManager.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/extensions/EditorPageExtensionPointManager.java
index a52db5323..04b52e989 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/extensions/EditorPageExtensionPointManager.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/extensions/EditorPageExtensionPointManager.java
@@ -1,102 +1,102 @@
-/*******************************************************************************
- * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.ui.views.extensions;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.tcf.te.ui.views.interfaces.IEditorPage;
-import org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager;
-import org.eclipse.tcf.te.runtime.extensions.ExecutableExtensionProxy;
-
-
-/**
- * Details editor page extension point manager implementation.
- */
-public class EditorPageExtensionPointManager extends AbstractExtensionPointManager<IEditorPage> {
- /*
- * Thread save singleton instance creation.
- */
- private static class LazyInstance {
- public static EditorPageExtensionPointManager instance = new EditorPageExtensionPointManager();
- }
-
- /**
- * Constructor.
- */
- EditorPageExtensionPointManager() {
- super();
- }
-
- /**
- * Returns the singleton instance of the extension point manager.
- */
- public static EditorPageExtensionPointManager getInstance() {
- return LazyInstance.instance;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager#getExtensionPointId()
- */
- @Override
- protected String getExtensionPointId() {
- return "org.eclipse.tcf.te.ui.views.editorPages"; //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager#getConfigurationElementName()
- */
- @Override
- protected String getConfigurationElementName() {
- return "editorPage"; //$NON-NLS-1$
- }
-
- /**
- * Returns the list of all contributed editor pages.
- *
- * @param unique If <code>true</code>, the method returns new instances for each
- * contributed editor page.
- *
- * @return The list of contributed editor pages, or an empty array.
- */
- public IEditorPage[] getEditorPages(boolean unique) {
- List<IEditorPage> contributions = new ArrayList<IEditorPage>();
- Collection<ExecutableExtensionProxy<IEditorPage>> editorPages = getExtensions().values();
- for (ExecutableExtensionProxy<IEditorPage> editorPage : editorPages) {
- IEditorPage instance = unique ? editorPage.newInstance() : editorPage.getInstance();
- if (instance != null && !contributions.contains(instance)) {
- contributions.add(instance);
- }
- }
-
- return contributions.toArray(new IEditorPage[contributions.size()]);
- }
-
- /**
- * Returns the editor page identified by its unique id. If no editor
- * page with the specified id is registered, <code>null</code> is returned.
- *
- * @param id The unique id of the editor page or <code>null</code>
- * @param unique If <code>true</code>, the method returns new instances of the editor page contribution.
- *
- * @return The editor page instance or <code>null</code>.
- */
- public IEditorPage getEditorPage(String id, boolean unique) {
- IEditorPage contribution = null;
- if (getExtensions().containsKey(id)) {
- ExecutableExtensionProxy<IEditorPage> proxy = getExtensions().get(id);
- // Get the extension instance
- contribution = unique ? proxy.newInstance() : proxy.getInstance();
- }
-
- return contribution;
- }
-}
+/*******************************************************************************
+ * 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.ui.views.extensions;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.tcf.te.ui.views.interfaces.IEditorPage;
+import org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager;
+import org.eclipse.tcf.te.runtime.extensions.ExecutableExtensionProxy;
+
+
+/**
+ * Details editor page extension point manager implementation.
+ */
+public class EditorPageExtensionPointManager extends AbstractExtensionPointManager<IEditorPage> {
+ /*
+ * Thread save singleton instance creation.
+ */
+ private static class LazyInstance {
+ public static EditorPageExtensionPointManager instance = new EditorPageExtensionPointManager();
+ }
+
+ /**
+ * Constructor.
+ */
+ EditorPageExtensionPointManager() {
+ super();
+ }
+
+ /**
+ * Returns the singleton instance of the extension point manager.
+ */
+ public static EditorPageExtensionPointManager getInstance() {
+ return LazyInstance.instance;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager#getExtensionPointId()
+ */
+ @Override
+ protected String getExtensionPointId() {
+ return "org.eclipse.tcf.te.ui.views.editorPages"; //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager#getConfigurationElementName()
+ */
+ @Override
+ protected String getConfigurationElementName() {
+ return "editorPage"; //$NON-NLS-1$
+ }
+
+ /**
+ * Returns the list of all contributed editor pages.
+ *
+ * @param unique If <code>true</code>, the method returns new instances for each
+ * contributed editor page.
+ *
+ * @return The list of contributed editor pages, or an empty array.
+ */
+ public IEditorPage[] getEditorPages(boolean unique) {
+ List<IEditorPage> contributions = new ArrayList<IEditorPage>();
+ Collection<ExecutableExtensionProxy<IEditorPage>> editorPages = getExtensions().values();
+ for (ExecutableExtensionProxy<IEditorPage> editorPage : editorPages) {
+ IEditorPage instance = unique ? editorPage.newInstance() : editorPage.getInstance();
+ if (instance != null && !contributions.contains(instance)) {
+ contributions.add(instance);
+ }
+ }
+
+ return contributions.toArray(new IEditorPage[contributions.size()]);
+ }
+
+ /**
+ * Returns the editor page identified by its unique id. If no editor
+ * page with the specified id is registered, <code>null</code> is returned.
+ *
+ * @param id The unique id of the editor page or <code>null</code>
+ * @param unique If <code>true</code>, the method returns new instances of the editor page contribution.
+ *
+ * @return The editor page instance or <code>null</code>.
+ */
+ public IEditorPage getEditorPage(String id, boolean unique) {
+ IEditorPage contribution = null;
+ if (getExtensions().containsKey(id)) {
+ ExecutableExtensionProxy<IEditorPage> proxy = getExtensions().get(id);
+ // Get the extension instance
+ contribution = unique ? proxy.newInstance() : proxy.getInstance();
+ }
+
+ return contribution;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/extensions/LabelProviderDelegateExtensionPointManager.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/extensions/LabelProviderDelegateExtensionPointManager.java
index f55a4116a..01be98f61 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/extensions/LabelProviderDelegateExtensionPointManager.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/extensions/LabelProviderDelegateExtensionPointManager.java
@@ -1,131 +1,131 @@
-/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.ui.views.extensions;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.core.expressions.EvaluationContext;
-import org.eclipse.core.expressions.EvaluationResult;
-import org.eclipse.core.expressions.Expression;
-import org.eclipse.core.expressions.ExpressionConverter;
-import org.eclipse.core.expressions.IEvaluationContext;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager;
-import org.eclipse.tcf.te.runtime.extensions.ExecutableExtensionProxy;
-import org.eclipse.tcf.te.ui.activator.UIPlugin;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.handlers.IHandlerService;
-
-/**
- * Label Provider Delegate extension point manager implementation.
- */
-public class LabelProviderDelegateExtensionPointManager extends AbstractExtensionPointManager<ILabelProvider> {
- /*
- * Thread save singleton instance creation.
- */
- private static class LazyInstance {
- public static LabelProviderDelegateExtensionPointManager instance = new LabelProviderDelegateExtensionPointManager();
- }
-
- /**
- * Constructor.
- */
- LabelProviderDelegateExtensionPointManager() {
- super();
- }
-
- /**
- * Returns the singleton instance of the extension point manager.
- */
- public static LabelProviderDelegateExtensionPointManager getInstance() {
- return LazyInstance.instance;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager#getExtensionPointId()
- */
- @Override
- protected String getExtensionPointId() {
- return "org.eclipse.tcf.te.ui.views.labelProviderDelegates"; //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager#getConfigurationElementName()
- */
- @Override
- protected String getConfigurationElementName() {
- return "labelProviderDelegate"; //$NON-NLS-1$
- }
-
- /**
- * Returns the list of all contributed label provider delegates.
- *
- * @param unique If <code>true</code>, the method returns new instances for each
- * contributed label provider delegate.
- *
- * @return The list of contributed label provider delegates, or an empty array.
- */
- public ILabelProvider[] getDelegates(Object context, boolean unique) {
- List<ILabelProvider> contributions = new ArrayList<ILabelProvider>();
- Collection<ExecutableExtensionProxy<ILabelProvider>> delegates = getExtensions().values();
- for (ExecutableExtensionProxy<ILabelProvider> delegate : delegates) {
- Expression enablement = null;
- // Read the sub elements of the extension
- IConfigurationElement[] children = delegate != null ? delegate.getConfigurationElement().getChildren() : null;
- // The "enablement" element is the only expected one
- if (children != null && children.length > 0) {
- try {
- enablement = ExpressionConverter.getDefault().perform(children[0]);
- }
- catch (CoreException e) {}
- }
-
- // The binding is applicable by default if no expression is specified.
- boolean isApplicable = enablement == null;
-
- if (enablement != null) {
- if (context != null) {
- // Set the default variable to the delegate context.
- IEvaluationContext currentState = ((IHandlerService)PlatformUI.getWorkbench().getService(IHandlerService.class)).getCurrentState();
- EvaluationContext evalContext = new EvaluationContext(currentState, context);
- evalContext.addVariable("context", context); //$NON-NLS-1$
- // Allow plugin activation
- evalContext.setAllowPluginActivation(true);
- // Evaluate the expression
- try {
- isApplicable = enablement.evaluate(evalContext).equals(EvaluationResult.TRUE);
- } catch (CoreException e) {
- IStatus status = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(), e.getLocalizedMessage(), e);
- Platform.getLog(UIPlugin.getDefault().getBundle()).log(status);
- }
- } else {
- // The enablement is false by definition if no delegate context is given.
- isApplicable = false;
- }
- }
-
- if (isApplicable) {
- ILabelProvider instance = unique ? delegate.newInstance() : delegate.getInstance();
- if (instance != null && !contributions.contains(instance)) {
- contributions.add(instance);
- }
- }
- }
-
- return contributions.toArray(new ILabelProvider[contributions.size()]);
- }
-}
+/*******************************************************************************
+ * 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.ui.views.extensions;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.eclipse.core.expressions.EvaluationContext;
+import org.eclipse.core.expressions.EvaluationResult;
+import org.eclipse.core.expressions.Expression;
+import org.eclipse.core.expressions.ExpressionConverter;
+import org.eclipse.core.expressions.IEvaluationContext;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager;
+import org.eclipse.tcf.te.runtime.extensions.ExecutableExtensionProxy;
+import org.eclipse.tcf.te.ui.activator.UIPlugin;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.handlers.IHandlerService;
+
+/**
+ * Label Provider Delegate extension point manager implementation.
+ */
+public class LabelProviderDelegateExtensionPointManager extends AbstractExtensionPointManager<ILabelProvider> {
+ /*
+ * Thread save singleton instance creation.
+ */
+ private static class LazyInstance {
+ public static LabelProviderDelegateExtensionPointManager instance = new LabelProviderDelegateExtensionPointManager();
+ }
+
+ /**
+ * Constructor.
+ */
+ LabelProviderDelegateExtensionPointManager() {
+ super();
+ }
+
+ /**
+ * Returns the singleton instance of the extension point manager.
+ */
+ public static LabelProviderDelegateExtensionPointManager getInstance() {
+ return LazyInstance.instance;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager#getExtensionPointId()
+ */
+ @Override
+ protected String getExtensionPointId() {
+ return "org.eclipse.tcf.te.ui.views.labelProviderDelegates"; //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.extensions.AbstractExtensionPointManager#getConfigurationElementName()
+ */
+ @Override
+ protected String getConfigurationElementName() {
+ return "labelProviderDelegate"; //$NON-NLS-1$
+ }
+
+ /**
+ * Returns the list of all contributed label provider delegates.
+ *
+ * @param unique If <code>true</code>, the method returns new instances for each
+ * contributed label provider delegate.
+ *
+ * @return The list of contributed label provider delegates, or an empty array.
+ */
+ public ILabelProvider[] getDelegates(Object context, boolean unique) {
+ List<ILabelProvider> contributions = new ArrayList<ILabelProvider>();
+ Collection<ExecutableExtensionProxy<ILabelProvider>> delegates = getExtensions().values();
+ for (ExecutableExtensionProxy<ILabelProvider> delegate : delegates) {
+ Expression enablement = null;
+ // Read the sub elements of the extension
+ IConfigurationElement[] children = delegate != null ? delegate.getConfigurationElement().getChildren() : null;
+ // The "enablement" element is the only expected one
+ if (children != null && children.length > 0) {
+ try {
+ enablement = ExpressionConverter.getDefault().perform(children[0]);
+ }
+ catch (CoreException e) {}
+ }
+
+ // The binding is applicable by default if no expression is specified.
+ boolean isApplicable = enablement == null;
+
+ if (enablement != null) {
+ if (context != null) {
+ // Set the default variable to the delegate context.
+ IEvaluationContext currentState = ((IHandlerService)PlatformUI.getWorkbench().getService(IHandlerService.class)).getCurrentState();
+ EvaluationContext evalContext = new EvaluationContext(currentState, context);
+ evalContext.addVariable("context", context); //$NON-NLS-1$
+ // Allow plugin activation
+ evalContext.setAllowPluginActivation(true);
+ // Evaluate the expression
+ try {
+ isApplicable = enablement.evaluate(evalContext).equals(EvaluationResult.TRUE);
+ } catch (CoreException e) {
+ IStatus status = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(), e.getLocalizedMessage(), e);
+ Platform.getLog(UIPlugin.getDefault().getBundle()).log(status);
+ }
+ } else {
+ // The enablement is false by definition if no delegate context is given.
+ isApplicable = false;
+ }
+ }
+
+ if (isApplicable) {
+ ILabelProvider instance = unique ? delegate.newInstance() : delegate.getInstance();
+ if (instance != null && !contributions.contains(instance)) {
+ contributions.add(instance);
+ }
+ }
+ }
+
+ return contributions.toArray(new ILabelProvider[contributions.size()]);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/FilterMRUContribution.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/FilterMRUContribution.java
index 496ea7e73..a57630965 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/FilterMRUContribution.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/FilterMRUContribution.java
@@ -1,108 +1,108 @@
-/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.ui.views.handler;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.tcf.te.ui.views.ViewsUtil;
-import org.eclipse.tcf.te.ui.views.interfaces.IUIConstants;
-import org.eclipse.tcf.te.ui.views.internal.preferences.IPreferenceKeys;
-import org.eclipse.ui.actions.CompoundContributionItem;
-import org.eclipse.ui.internal.navigator.NavigatorFilterService;
-import org.eclipse.ui.navigator.CommonNavigator;
-import org.eclipse.ui.navigator.CommonViewer;
-import org.eclipse.ui.navigator.ICommonFilterDescriptor;
-import org.eclipse.ui.navigator.INavigatorContentService;
-
-/**
- * The dynamic contribution of common filter MRU menu list.
- */
-@SuppressWarnings("restriction")
-public class FilterMRUContribution extends CompoundContributionItem {
-
- /**
- * A MRU item action to enable or disable specified common filter.
- */
- static class FilterMRUAction extends Action {
- // The filter service used to enable or disable this filter.
- private NavigatorFilterService filterService;
- // This filter's descriptor
- private ICommonFilterDescriptor filterDescriptor;
- // The common viewer of the navigator.
- private CommonViewer commonViewer;
-
- /**
- * Constructor
- */
- public FilterMRUAction(int order, ICommonFilterDescriptor filterDescriptor, NavigatorFilterService filterService, CommonViewer commonViewer) {
- super("" + order + " " + filterDescriptor.getName(), AS_CHECK_BOX); //$NON-NLS-1$//$NON-NLS-2$
- this.filterDescriptor = filterDescriptor;
- this.filterService = filterService;
- this.commonViewer = commonViewer;
- setChecked(filterService.isActive(filterDescriptor.getId()));
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.action.Action#run()
- */
- @Override
- public void run() {
- ICommonFilterDescriptor[] visibleFilters = filterService.getVisibleFilterDescriptorsForUI();
- Set<String> activeIds = new HashSet<String>();
- if (visibleFilters != null && visibleFilters.length > 0) {
- for (ICommonFilterDescriptor filter : visibleFilters) {
- if (filterService.isActive(filter.getId())) activeIds.add(filter.getId());
- }
- }
- if (isChecked()) activeIds.add(filterDescriptor.getId());
- else activeIds.remove(filterDescriptor.getId());
- UpdateActiveFiltersOperation updateFilters = new UpdateActiveFiltersOperation(commonViewer, activeIds.toArray(new String[activeIds.size()]));
- updateFilters.execute(null, null);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.actions.CompoundContributionItem#getContributionItems()
- */
- @Override
- protected IContributionItem[] getContributionItems() {
- CommonNavigator navigator = (CommonNavigator) ViewsUtil.getPart(IUIConstants.ID_EXPLORER);
- if (navigator == null) return new IContributionItem[0];
-
- INavigatorContentService contentService = navigator.getNavigatorContentService();
- NavigatorFilterService filterService = (NavigatorFilterService) contentService.getFilterService();
- Map<String, ICommonFilterDescriptor> fdMap = new HashMap<String, ICommonFilterDescriptor>();
- ICommonFilterDescriptor[] visibleFilterDescriptors = filterService.getVisibleFilterDescriptorsForUI();
- for(ICommonFilterDescriptor filterDescriptor : visibleFilterDescriptors) {
- fdMap.put(filterDescriptor.getId(), filterDescriptor);
- }
- List<IContributionItem> items = new ArrayList<IContributionItem>();
- List<String> filterSet = new MRUList(IPreferenceKeys.PREF_FILTER_MRU_LIST);
- CommonViewer commonViewer = navigator.getCommonViewer();
- for (int i = 0; i < filterSet.size(); i++) {
- String filterId = filterSet.get(i);
- ICommonFilterDescriptor filterDescriptor = fdMap.get(filterId);
- if (filterDescriptor != null) {
- items.add(new ActionContributionItem(new FilterMRUAction((i+1), filterDescriptor, filterService, commonViewer)));
- }
- }
- return items.toArray(new IContributionItem[items.size()]);
- }
-}
+/*******************************************************************************
+ * 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.ui.views.handler;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.tcf.te.ui.views.ViewsUtil;
+import org.eclipse.tcf.te.ui.views.interfaces.IUIConstants;
+import org.eclipse.tcf.te.ui.views.internal.preferences.IPreferenceKeys;
+import org.eclipse.ui.actions.CompoundContributionItem;
+import org.eclipse.ui.internal.navigator.NavigatorFilterService;
+import org.eclipse.ui.navigator.CommonNavigator;
+import org.eclipse.ui.navigator.CommonViewer;
+import org.eclipse.ui.navigator.ICommonFilterDescriptor;
+import org.eclipse.ui.navigator.INavigatorContentService;
+
+/**
+ * The dynamic contribution of common filter MRU menu list.
+ */
+@SuppressWarnings("restriction")
+public class FilterMRUContribution extends CompoundContributionItem {
+
+ /**
+ * A MRU item action to enable or disable specified common filter.
+ */
+ static class FilterMRUAction extends Action {
+ // The filter service used to enable or disable this filter.
+ private NavigatorFilterService filterService;
+ // This filter's descriptor
+ private ICommonFilterDescriptor filterDescriptor;
+ // The common viewer of the navigator.
+ private CommonViewer commonViewer;
+
+ /**
+ * Constructor
+ */
+ public FilterMRUAction(int order, ICommonFilterDescriptor filterDescriptor, NavigatorFilterService filterService, CommonViewer commonViewer) {
+ super("" + order + " " + filterDescriptor.getName(), AS_CHECK_BOX); //$NON-NLS-1$//$NON-NLS-2$
+ this.filterDescriptor = filterDescriptor;
+ this.filterService = filterService;
+ this.commonViewer = commonViewer;
+ setChecked(filterService.isActive(filterDescriptor.getId()));
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ ICommonFilterDescriptor[] visibleFilters = filterService.getVisibleFilterDescriptorsForUI();
+ Set<String> activeIds = new HashSet<String>();
+ if (visibleFilters != null && visibleFilters.length > 0) {
+ for (ICommonFilterDescriptor filter : visibleFilters) {
+ if (filterService.isActive(filter.getId())) activeIds.add(filter.getId());
+ }
+ }
+ if (isChecked()) activeIds.add(filterDescriptor.getId());
+ else activeIds.remove(filterDescriptor.getId());
+ UpdateActiveFiltersOperation updateFilters = new UpdateActiveFiltersOperation(commonViewer, activeIds.toArray(new String[activeIds.size()]));
+ updateFilters.execute(null, null);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.actions.CompoundContributionItem#getContributionItems()
+ */
+ @Override
+ protected IContributionItem[] getContributionItems() {
+ CommonNavigator navigator = (CommonNavigator) ViewsUtil.getPart(IUIConstants.ID_EXPLORER);
+ if (navigator == null) return new IContributionItem[0];
+
+ INavigatorContentService contentService = navigator.getNavigatorContentService();
+ NavigatorFilterService filterService = (NavigatorFilterService) contentService.getFilterService();
+ Map<String, ICommonFilterDescriptor> fdMap = new HashMap<String, ICommonFilterDescriptor>();
+ ICommonFilterDescriptor[] visibleFilterDescriptors = filterService.getVisibleFilterDescriptorsForUI();
+ for(ICommonFilterDescriptor filterDescriptor : visibleFilterDescriptors) {
+ fdMap.put(filterDescriptor.getId(), filterDescriptor);
+ }
+ List<IContributionItem> items = new ArrayList<IContributionItem>();
+ List<String> filterSet = new MRUList(IPreferenceKeys.PREF_FILTER_MRU_LIST);
+ CommonViewer commonViewer = navigator.getCommonViewer();
+ for (int i = 0; i < filterSet.size(); i++) {
+ String filterId = filterSet.get(i);
+ ICommonFilterDescriptor filterDescriptor = fdMap.get(filterId);
+ if (filterDescriptor != null) {
+ items.add(new ActionContributionItem(new FilterMRUAction((i+1), filterDescriptor, filterService, commonViewer)));
+ }
+ }
+ return items.toArray(new IContributionItem[items.size()]);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/NewWizardHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/NewWizardHandler.java
index 726fe27df..1809c140c 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/NewWizardHandler.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/NewWizardHandler.java
@@ -2,7 +2,7 @@
* NewWizardHandler.java
* Created on Jul 12, 2012
*
- * Copyright (c) 2012 Wind River Systems, Inc.
+ * Copyright (c) 2012, 2013 Wind River Systems, Inc.
*
* The right to copy, distribute, modify, or otherwise make use
* of this software may be licensed only pursuant to the terms
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/OpenEditorHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/OpenEditorHandler.java
index 86def91a5..6827af676 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/OpenEditorHandler.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/OpenEditorHandler.java
@@ -1,113 +1,113 @@
-/*******************************************************************************
- * 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.ui.views.handler;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.TreePath;
-import org.eclipse.jface.viewers.TreeSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.tcf.te.runtime.services.ServiceManager;
-import org.eclipse.tcf.te.runtime.services.interfaces.IUIService;
-import org.eclipse.tcf.te.ui.interfaces.handler.IEditorHandlerDelegate;
-import org.eclipse.tcf.te.ui.views.activator.UIPlugin;
-import org.eclipse.tcf.te.ui.views.editor.EditorInput;
-import org.eclipse.tcf.te.ui.views.interfaces.IUIConstants;
-import org.eclipse.tcf.te.ui.views.nls.Messages;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.handlers.HandlerUtil;
-import org.eclipse.ui.navigator.CommonNavigator;
-
-/**
- * TCF tree elements open command handler implementation.
- */
-public class OpenEditorHandler extends AbstractHandler {
-
- /* (non-Javadoc)
- * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- */
- @Override
- public Object execute(ExecutionEvent event) throws ExecutionException {
- // The selection is the Target Explorer tree selection
- ISelection selection = HandlerUtil.getCurrentSelection(event);
- // The active part is the Target Explorer view instance
- IWorkbenchPart part = HandlerUtil.getActivePart(event);
- // Get the currently active workbench window
- IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
- // ALT - Key pressed?
- Object ctrlPressed = HandlerUtil.getVariable(event, "ctrlPressed"); //$NON-NLS-1$
-
- boolean expand = ctrlPressed instanceof Boolean ? ((Boolean)ctrlPressed).booleanValue() : false;
-
- if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
- // If the tree node is expandable, expand or collapse it
- TreeViewer viewer = ((CommonNavigator)part).getCommonViewer();
- Object element = ((IStructuredSelection)selection).getFirstElement();
- if (selection instanceof TreeSelection) {
- TreePath[] path = ((TreeSelection)selection).getPaths();
- if (path != null && path.length > 0) {
- element = path[0].getLastSegment();
- }
- }
- if (viewer.isExpandable(element) && expand) {
- viewer.setExpandedState(element, !viewer.getExpandedState(element));
- }
- else {
- openEditorOnSelection(window, selection);
- }
- }
-
- return null;
- }
-
- /**
- * Opens the properties editor in the given workbench window on the given selection.
- *
- * @param window The workbench window. Must not be <code>null</code>.
- * @param selection The selection. Must not be <code>null</code>.
- */
- public static void openEditorOnSelection(IWorkbenchWindow window, ISelection selection) {
- Assert.isNotNull(window);
- Assert.isNotNull(selection);
-
- if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
- Object element = ((IStructuredSelection)selection).getFirstElement();
- if (element != null) {
- // Get the active page
- IWorkbenchPage page = window.getActivePage();
- // Create the editor input object
- IUIService service = ServiceManager.getInstance().getService(element, IUIService.class);
- IEditorHandlerDelegate delegate = service != null ? service.getDelegate(element, IEditorHandlerDelegate.class) : null;
- IEditorInput input = (delegate != null) ? delegate.getEditorInput(element) : new EditorInput(element);
- try {
- // Opens the Target Explorer properties editor
- IEditorPart editor = page.openEditor(input, IUIConstants.ID_EDITOR);
- // Lookup the ui service for post action
- if (delegate != null)
- delegate.postOpenEditor(editor, element);
- } catch (PartInitException e) {
- IStatus status = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(), Messages.OpenCommandHandler_error_openEditor, e);
- UIPlugin.getDefault().getLog().log(status);
- }
- }
- }
- }
-}
+/*******************************************************************************
+ * 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.ui.views.handler;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TreePath;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.tcf.te.runtime.services.ServiceManager;
+import org.eclipse.tcf.te.runtime.services.interfaces.IUIService;
+import org.eclipse.tcf.te.ui.interfaces.handler.IEditorHandlerDelegate;
+import org.eclipse.tcf.te.ui.views.activator.UIPlugin;
+import org.eclipse.tcf.te.ui.views.editor.EditorInput;
+import org.eclipse.tcf.te.ui.views.interfaces.IUIConstants;
+import org.eclipse.tcf.te.ui.views.nls.Messages;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.ui.navigator.CommonNavigator;
+
+/**
+ * TCF tree elements open command handler implementation.
+ */
+public class OpenEditorHandler extends AbstractHandler {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ @Override
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ // The selection is the Target Explorer tree selection
+ ISelection selection = HandlerUtil.getCurrentSelection(event);
+ // The active part is the Target Explorer view instance
+ IWorkbenchPart part = HandlerUtil.getActivePart(event);
+ // Get the currently active workbench window
+ IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
+ // ALT - Key pressed?
+ Object ctrlPressed = HandlerUtil.getVariable(event, "ctrlPressed"); //$NON-NLS-1$
+
+ boolean expand = ctrlPressed instanceof Boolean ? ((Boolean)ctrlPressed).booleanValue() : false;
+
+ if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
+ // If the tree node is expandable, expand or collapse it
+ TreeViewer viewer = ((CommonNavigator)part).getCommonViewer();
+ Object element = ((IStructuredSelection)selection).getFirstElement();
+ if (selection instanceof TreeSelection) {
+ TreePath[] path = ((TreeSelection)selection).getPaths();
+ if (path != null && path.length > 0) {
+ element = path[0].getLastSegment();
+ }
+ }
+ if (viewer.isExpandable(element) && expand) {
+ viewer.setExpandedState(element, !viewer.getExpandedState(element));
+ }
+ else {
+ openEditorOnSelection(window, selection);
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * Opens the properties editor in the given workbench window on the given selection.
+ *
+ * @param window The workbench window. Must not be <code>null</code>.
+ * @param selection The selection. Must not be <code>null</code>.
+ */
+ public static void openEditorOnSelection(IWorkbenchWindow window, ISelection selection) {
+ Assert.isNotNull(window);
+ Assert.isNotNull(selection);
+
+ if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
+ Object element = ((IStructuredSelection)selection).getFirstElement();
+ if (element != null) {
+ // Get the active page
+ IWorkbenchPage page = window.getActivePage();
+ // Create the editor input object
+ IUIService service = ServiceManager.getInstance().getService(element, IUIService.class);
+ IEditorHandlerDelegate delegate = service != null ? service.getDelegate(element, IEditorHandlerDelegate.class) : null;
+ IEditorInput input = (delegate != null) ? delegate.getEditorInput(element) : new EditorInput(element);
+ try {
+ // Opens the Target Explorer properties editor
+ IEditorPart editor = page.openEditor(input, IUIConstants.ID_EDITOR);
+ // Lookup the ui service for post action
+ if (delegate != null)
+ delegate.postOpenEditor(editor, element);
+ } catch (PartInitException e) {
+ IStatus status = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(), Messages.OpenCommandHandler_error_openEditor, e);
+ UIPlugin.getDefault().getLog().log(status);
+ }
+ }
+ }
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/ShowInSystemManagementHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/ShowInSystemManagementHandler.java
index 7f282b36e..77ba7328b 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/ShowInSystemManagementHandler.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/ShowInSystemManagementHandler.java
@@ -1,115 +1,115 @@
-/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.ui.views.handler;
-
-import java.util.concurrent.atomic.AtomicReference;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.tcf.te.ui.views.extensions.CategoriesExtensionPointManager;
-import org.eclipse.tcf.te.ui.views.interfaces.ICategory;
-import org.eclipse.tcf.te.ui.views.interfaces.IUIConstants;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.handlers.HandlerUtil;
-import org.eclipse.ui.navigator.CommonNavigator;
-import org.eclipse.ui.part.EditorPart;
-
-/**
- * "Show In System Management" command handler implementation.
- */
-public class ShowInSystemManagementHandler 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 active part
- IWorkbenchPart part = HandlerUtil.getActivePart(event);
- // The element to select
- Object element = null;
-
- // If the handler is invoked from an editor part, ignore the selection and
- // construct an artificial selection from the active editor input.
- if (part instanceof EditorPart) {
- IEditorInput input = ((EditorPart)part).getEditorInput();
- element = input != null ? input.getAdapter(Object.class) : null;
- }
-
- if (element != null) {
- setAndCheckSelection(IUIConstants.ID_EXPLORER, element);
- }
-
- return null;
- }
-
- private void setAndCheckSelection(final String id, final Object element) {
- Assert.isNotNull(id);
-
- final AtomicReference<IViewPart> viewPart = new AtomicReference<IViewPart>();
- // Create the runnable
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- // Check the active workbench window and active page instances
- if (PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null && PlatformUI
- .getWorkbench().getActiveWorkbenchWindow().getActivePage() != null) {
- // show the view
- try {
- viewPart.set(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(id));
- }
- catch (Exception e) {
- }
- }
- }
- };
- // Execute asynchronously
- if (PlatformUI.isWorkbenchRunning()) {
- PlatformUI.getWorkbench().getDisplay().syncExec(runnable);
- }
-
- // Create the runnable
- runnable = new Runnable() {
- @Override
- public void run() {
- IViewPart part = viewPart.get();
- ((CommonNavigator)part).getCommonViewer().setSelection(new StructuredSelection(element), true);
- IStructuredSelection newSel = (IStructuredSelection)((CommonNavigator)part).getCommonViewer().getSelection();
- if (newSel == null || newSel.isEmpty() || !newSel.getFirstElement().equals(element)) {
- for (ICategory category : CategoriesExtensionPointManager.getInstance().getCategories(false)) {
- if (category.belongsTo(element)) {
- if (part instanceof CommonNavigator) {
- ((CommonNavigator)part).getCommonViewer().setSelection(new StructuredSelection(category), true);
- ((CommonNavigator)part).getCommonViewer().expandToLevel(category, 1);
- }
- ((CommonNavigator)part).getCommonViewer().setSelection(new StructuredSelection(element), true);
- newSel = (IStructuredSelection)((CommonNavigator)part).getCommonViewer().getSelection();
- if (newSel != null && !newSel.isEmpty() && newSel.getFirstElement().equals(element)) {
- return;
- }
- }
- }
- }
- }
- };
-
- // Execute asynchronously
- if (PlatformUI.isWorkbenchRunning()) {
- PlatformUI.getWorkbench().getDisplay().asyncExec(runnable);
- }
- }
-}
+/*******************************************************************************
+ * 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.ui.views.handler;
+
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.tcf.te.ui.views.extensions.CategoriesExtensionPointManager;
+import org.eclipse.tcf.te.ui.views.interfaces.ICategory;
+import org.eclipse.tcf.te.ui.views.interfaces.IUIConstants;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.ui.navigator.CommonNavigator;
+import org.eclipse.ui.part.EditorPart;
+
+/**
+ * "Show In System Management" command handler implementation.
+ */
+public class ShowInSystemManagementHandler 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 active part
+ IWorkbenchPart part = HandlerUtil.getActivePart(event);
+ // The element to select
+ Object element = null;
+
+ // If the handler is invoked from an editor part, ignore the selection and
+ // construct an artificial selection from the active editor input.
+ if (part instanceof EditorPart) {
+ IEditorInput input = ((EditorPart)part).getEditorInput();
+ element = input != null ? input.getAdapter(Object.class) : null;
+ }
+
+ if (element != null) {
+ setAndCheckSelection(IUIConstants.ID_EXPLORER, element);
+ }
+
+ return null;
+ }
+
+ private void setAndCheckSelection(final String id, final Object element) {
+ Assert.isNotNull(id);
+
+ final AtomicReference<IViewPart> viewPart = new AtomicReference<IViewPart>();
+ // Create the runnable
+ Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ // Check the active workbench window and active page instances
+ if (PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null && PlatformUI
+ .getWorkbench().getActiveWorkbenchWindow().getActivePage() != null) {
+ // show the view
+ try {
+ viewPart.set(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(id));
+ }
+ catch (Exception e) {
+ }
+ }
+ }
+ };
+ // Execute asynchronously
+ if (PlatformUI.isWorkbenchRunning()) {
+ PlatformUI.getWorkbench().getDisplay().syncExec(runnable);
+ }
+
+ // Create the runnable
+ runnable = new Runnable() {
+ @Override
+ public void run() {
+ IViewPart part = viewPart.get();
+ ((CommonNavigator)part).getCommonViewer().setSelection(new StructuredSelection(element), true);
+ IStructuredSelection newSel = (IStructuredSelection)((CommonNavigator)part).getCommonViewer().getSelection();
+ if (newSel == null || newSel.isEmpty() || !newSel.getFirstElement().equals(element)) {
+ for (ICategory category : CategoriesExtensionPointManager.getInstance().getCategories(false)) {
+ if (category.belongsTo(element)) {
+ if (part instanceof CommonNavigator) {
+ ((CommonNavigator)part).getCommonViewer().setSelection(new StructuredSelection(category), true);
+ ((CommonNavigator)part).getCommonViewer().expandToLevel(category, 1);
+ }
+ ((CommonNavigator)part).getCommonViewer().setSelection(new StructuredSelection(element), true);
+ newSel = (IStructuredSelection)((CommonNavigator)part).getCommonViewer().getSelection();
+ if (newSel != null && !newSel.isEmpty() && newSel.getFirstElement().equals(element)) {
+ return;
+ }
+ }
+ }
+ }
+ }
+ };
+
+ // Execute asynchronously
+ if (PlatformUI.isWorkbenchRunning()) {
+ PlatformUI.getWorkbench().getDisplay().asyncExec(runnable);
+ }
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/interfaces/ICategory.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/interfaces/ICategory.java
index 8dadbcd2d..05e31427b 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/interfaces/ICategory.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/interfaces/ICategory.java
@@ -1,56 +1,56 @@
-/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.ui.views.interfaces;
-
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.tcf.te.runtime.interfaces.extensions.IExecutableExtension;
-import org.eclipse.tcf.te.ui.views.navigator.nodes.NewWizardNode;
-
-/**
- * Main view category node.
- */
-public interface ICategory extends IExecutableExtension {
-
- /**
- * Returns the category image.
- *
- * @return The category image or <code>null</code>.
- */
- public Image getImage();
-
- /**
- * Returns the sorting rank.
- *
- * @return The sorting rank, or a value less than -1 to fallback to alphabetical sorting.
- */
- public int getRank();
-
- /**
- * Check whether the given categorizable element belongs to this category.
- *
- * @param element The categorizable element.
- * @return <code>True</code> if the element should be shown within this category.
- */
- public boolean belongsTo(Object element);
-
- /**
- * Returns whether this category is enabled or not.
- *
- * @return <code>True</code> if the category is enabled, <code>false</code> otherwise.
- */
- public boolean isEnabled();
-
- /**
- * Returns an array of children that are always available in this category.
- * This might be a list of {@link NewWizardNode}
- * @return The children or <code>null</code>
- */
- public Object[] getChildren();
-}
+/*******************************************************************************
+ * 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.ui.views.interfaces;
+
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.tcf.te.runtime.interfaces.extensions.IExecutableExtension;
+import org.eclipse.tcf.te.ui.views.navigator.nodes.NewWizardNode;
+
+/**
+ * Main view category node.
+ */
+public interface ICategory extends IExecutableExtension {
+
+ /**
+ * Returns the category image.
+ *
+ * @return The category image or <code>null</code>.
+ */
+ public Image getImage();
+
+ /**
+ * Returns the sorting rank.
+ *
+ * @return The sorting rank, or a value less than -1 to fallback to alphabetical sorting.
+ */
+ public int getRank();
+
+ /**
+ * Check whether the given categorizable element belongs to this category.
+ *
+ * @param element The categorizable element.
+ * @return <code>True</code> if the element should be shown within this category.
+ */
+ public boolean belongsTo(Object element);
+
+ /**
+ * Returns whether this category is enabled or not.
+ *
+ * @return <code>True</code> if the category is enabled, <code>false</code> otherwise.
+ */
+ public boolean isEnabled();
+
+ /**
+ * Returns an array of children that are always available in this category.
+ * This might be a list of {@link NewWizardNode}
+ * @return The children or <code>null</code>
+ */
+ public Object[] getChildren();
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/interfaces/IEditorPage.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/interfaces/IEditorPage.java
index 0206833fb..39370a261 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/interfaces/IEditorPage.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/interfaces/IEditorPage.java
@@ -1,20 +1,20 @@
-/*******************************************************************************
- * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.ui.views.interfaces;
-
-import org.eclipse.core.runtime.IExecutableExtension;
-import org.eclipse.ui.forms.editor.IFormPage;
-
-/**
- * Details editor page public interface.
- */
-public interface IEditorPage extends IFormPage, IExecutableExtension {
-
-}
+/*******************************************************************************
+ * 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.ui.views.interfaces;
+
+import org.eclipse.core.runtime.IExecutableExtension;
+import org.eclipse.ui.forms.editor.IFormPage;
+
+/**
+ * Details editor page public interface.
+ */
+public interface IEditorPage extends IFormPage, IExecutableExtension {
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/interfaces/IEditorSaveAsAdapter.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/interfaces/IEditorSaveAsAdapter.java
index 8b7a1a25c..09eee796e 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/interfaces/IEditorSaveAsAdapter.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/interfaces/IEditorSaveAsAdapter.java
@@ -1,34 +1,34 @@
-/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.tcf.te.ui.views.interfaces;
-
-import org.eclipse.ui.IEditorInput;
-
-/**
- * IEditorSaveAsAdapter
- */
-public interface IEditorSaveAsAdapter {
-
- /**
- * Used by the editor to check whether saveAs is allowed or not.
- * @param input The editor input to check.
- * @return <code>true</code> if saveAs is supported.
- */
- public boolean isSaveAsAllowed(IEditorInput input);
-
- /**
- * Used by the editor to save the input under a new name.
- * @param input The editpr input to duplicate.
- * @return The new Object.
- */
- public Object doSaveAs(IEditorInput input);
-
-}
+/*******************************************************************************
+ * 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.ui.views.interfaces;
+
+import org.eclipse.ui.IEditorInput;
+
+/**
+ * IEditorSaveAsAdapter
+ */
+public interface IEditorSaveAsAdapter {
+
+ /**
+ * Used by the editor to check whether saveAs is allowed or not.
+ * @param input The editor input to check.
+ * @return <code>true</code> if saveAs is supported.
+ */
+ public boolean isSaveAsAllowed(IEditorInput input);
+
+ /**
+ * Used by the editor to save the input under a new name.
+ * @param input The editpr input to duplicate.
+ * @return The new Object.
+ */
+ public Object doSaveAs(IEditorInput input);
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/interfaces/IRoot.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/interfaces/IRoot.java
index f439fbeb1..6550d31ec 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/interfaces/IRoot.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/interfaces/IRoot.java
@@ -1,19 +1,19 @@
-/*******************************************************************************
- * 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.ui.views.interfaces;
-
-import org.eclipse.core.runtime.IAdaptable;
-
-/**
- * Main view root node.
- */
-public interface IRoot extends IAdaptable {
-
-}
+/*******************************************************************************
+ * 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.ui.views.interfaces;
+
+import org.eclipse.core.runtime.IAdaptable;
+
+/**
+ * Main view root node.
+ */
+public interface IRoot extends IAdaptable {
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/interfaces/IUIConstants.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/interfaces/IUIConstants.java
index f78a79a12..de4bb2628 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/interfaces/IUIConstants.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/interfaces/IUIConstants.java
@@ -1,60 +1,60 @@
-/*******************************************************************************
- * 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.ui.views.interfaces;
-
-/**
- * UI constants.
- */
-public interface IUIConstants {
-
- /**
- * The main view id.
- */
- public static final String ID_EXPLORER = "org.eclipse.tcf.te.ui.views.View"; //$NON-NLS-1$
-
- /**
- * The properties editor id.
- */
- public static final String ID_EDITOR = "org.eclipse.tcf.te.ui.views.Editor"; //$NON-NLS-1$
-
- /**
- * The tabbed properties contributor id.
- */
- public static final String TABBED_PROPERTIES_CONTRIBUTOR_ID = "org.eclipse.tcf.te.ui"; //$NON-NLS-1$
-
- // ***** Define the constants for the main view root mode *****
-
- /**
- * Root nodes are working sets.
- */
- public static final int MODE_WORKING_SETS = 0;
-
- /**
- * Root nodes are whatever is contributed to the view.
- */
- public static final int MODE_NORMAL = 1;
-
- // ***** Define the constants for the default view categories *****
-
- /**
- * Category: Favorites
- */
- public static final String ID_CAT_FAVORITES = "org.eclipse.tcf.te.ui.views.category.favorites"; //$NON-NLS-1$
-
- /**
- * Category: "My Targets"
- */
- public static final String ID_CAT_MY_TARGETS = "org.eclipse.tcf.te.ui.views.category.mytargets"; //$NON-NLS-1$
-
- /**
- * Category: Neighborhood
- */
- public static final String ID_CAT_NEIGHBORHOOD = "org.eclipse.tcf.te.ui.views.category.neighborhood"; //$NON-NLS-1$
-}
+/*******************************************************************************
+ * 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.ui.views.interfaces;
+
+/**
+ * UI constants.
+ */
+public interface IUIConstants {
+
+ /**
+ * The main view id.
+ */
+ public static final String ID_EXPLORER = "org.eclipse.tcf.te.ui.views.View"; //$NON-NLS-1$
+
+ /**
+ * The properties editor id.
+ */
+ public static final String ID_EDITOR = "org.eclipse.tcf.te.ui.views.Editor"; //$NON-NLS-1$
+
+ /**
+ * The tabbed properties contributor id.
+ */
+ public static final String TABBED_PROPERTIES_CONTRIBUTOR_ID = "org.eclipse.tcf.te.ui"; //$NON-NLS-1$
+
+ // ***** Define the constants for the main view root mode *****
+
+ /**
+ * Root nodes are working sets.
+ */
+ public static final int MODE_WORKING_SETS = 0;
+
+ /**
+ * Root nodes are whatever is contributed to the view.
+ */
+ public static final int MODE_NORMAL = 1;
+
+ // ***** Define the constants for the default view categories *****
+
+ /**
+ * Category: Favorites
+ */
+ public static final String ID_CAT_FAVORITES = "org.eclipse.tcf.te.ui.views.category.favorites"; //$NON-NLS-1$
+
+ /**
+ * Category: "My Targets"
+ */
+ public static final String ID_CAT_MY_TARGETS = "org.eclipse.tcf.te.ui.views.category.mytargets"; //$NON-NLS-1$
+
+ /**
+ * Category: Neighborhood
+ */
+ public static final String ID_CAT_NEIGHBORHOOD = "org.eclipse.tcf.te.ui.views.category.neighborhood"; //$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 39fdbe639..c54db9908 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
@@ -1,70 +1,70 @@
-/*******************************************************************************
- * 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.ui.views.interfaces;
-
-/**
- * Image registry constants.
- */
-public interface ImageConsts {
-
- // ***** The directory structure constants *****
-
- /**
- * The root directory where to load the images from, relative to
- * the bundle directory.
- */
- public final static String IMAGE_DIR_ROOT = "icons/"; //$NON-NLS-1$
-
- /**
- * The directory where to load view related images from, relative to
- * the image root directory.
- */
- public final static String IMAGE_DIR_EVIEW = "eview16/"; //$NON-NLS-1$
-
- /**
- * The directory where to load disabled toolbar images from,
- * relative to the image root directory.
- */
- public final static String IMAGE_DIR_DTOOL = "dtool16/"; //$NON-NLS-1$
-
- /**
- * The directory where to load enabled toolbar images from,
- * relative to the image root directory.
- */
- public final static String IMAGE_DIR_ETOOL = "etool16/"; //$NON-NLS-1$
-
- /**
- * The directory where to load model object images from,
- * relative to the image root directory.
- */
- public final static String IMAGE_DIR_OBJ = "obj16/"; //$NON-NLS-1$
-
- // ***** The image constants *****
-
- /**
- * The key to access the editor image.
- */
- public static final String EDITOR = "Editor"; //$NON-NLS-1$
-
- /**
- * The key to access the view image.
- */
- public static final String VIEW = "View"; //$NON-NLS-1$
-
- /**
- * The key to access the help action image.
- */
- public static final String HELP = "HelpAction"; //$NON-NLS-1$
-
- /**
- * The key to access the favorites category image.
- */
- public static final String FAVORITES = "Favorites"; //$NON-NLS-1$
-}
+/*******************************************************************************
+ * 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.ui.views.interfaces;
+
+/**
+ * Image registry constants.
+ */
+public interface ImageConsts {
+
+ // ***** The directory structure constants *****
+
+ /**
+ * The root directory where to load the images from, relative to
+ * the bundle directory.
+ */
+ public final static String IMAGE_DIR_ROOT = "icons/"; //$NON-NLS-1$
+
+ /**
+ * The directory where to load view related images from, relative to
+ * the image root directory.
+ */
+ public final static String IMAGE_DIR_EVIEW = "eview16/"; //$NON-NLS-1$
+
+ /**
+ * The directory where to load disabled toolbar images from,
+ * relative to the image root directory.
+ */
+ public final static String IMAGE_DIR_DTOOL = "dtool16/"; //$NON-NLS-1$
+
+ /**
+ * The directory where to load enabled toolbar images from,
+ * relative to the image root directory.
+ */
+ public final static String IMAGE_DIR_ETOOL = "etool16/"; //$NON-NLS-1$
+
+ /**
+ * The directory where to load model object images from,
+ * relative to the image root directory.
+ */
+ public final static String IMAGE_DIR_OBJ = "obj16/"; //$NON-NLS-1$
+
+ // ***** The image constants *****
+
+ /**
+ * The key to access the editor image.
+ */
+ public static final String EDITOR = "Editor"; //$NON-NLS-1$
+
+ /**
+ * The key to access the view image.
+ */
+ public static final String VIEW = "View"; //$NON-NLS-1$
+
+ /**
+ * The key to access the help action image.
+ */
+ public static final String HELP = "HelpAction"; //$NON-NLS-1$
+
+ /**
+ * The key to access the favorites category image.
+ */
+ public static final String FAVORITES = "Favorites"; //$NON-NLS-1$
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/interfaces/categories/ICategoryManager.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/interfaces/categories/ICategoryManager.java
index 614034a21..880885391 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/interfaces/categories/ICategoryManager.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/interfaces/categories/ICategoryManager.java
@@ -1,91 +1,91 @@
-/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.ui.views.interfaces.categories;
-
-/**
- * Interface to be implemented by category managers.
- */
-public interface ICategoryManager {
-
- /**
- * Flush the current category manager state.
- */
- public void flush();
-
- /**
- * Adds the given id to the given category.
- *
- * @param categoryId The category id. Must not be <code>null</code>.
- * @param id The id. Must not be <code>null</code>.
- *
- * @return <code>True</code> if the id has been added to the category, <code>false</code> if not.
- */
- public boolean add(String categoryId, String id);
-
- /**
- * Adds the given id to the given category.
- * <p>
- * <b>Note:</b> The category association is no persisted, the association is
- * transient and is lost when the category manager is disposed.
- *
- * @param categoryId The category id. Must not be <code>null</code>.
- * @param id The id. Must not be <code>null</code>.
- *
- * @return <code>True</code> if the id has been added to the category, <code>false</code> if not.
- */
- public boolean addTransient(String categoryId, String id);
-
- /**
- * Removes the given id from the given category.
- *
- * @param categoryId The category id. Must not be <code>null</code>.
- * @param id The id. Must not be <code>null</code>.
- *
- * @return <code>True</code> if the id has been removed from the category, <code>false</code> if not.
- */
- public boolean remove(String categoryId, String id);
-
- /**
- * Returns if or if not the given id belongs to the given category.
- *
- * @param categoryId The category id. Must not be <code>null</code>.
- * @param id The id. Must not be <code>null</code>.
- *
- * @return <code>True</code> if the id belongs to the category, <code>false</code> if not.
- */
- public boolean belongsTo(String categoryId, String id);
-
- /**
- * Returns if or if not the given id is linked to the given category.
- *
- * @param categoryId The category id. Must not be <code>null</code>.
- * @param id The id. Must not be <code>null</code>.
- *
- * @return <code>True</code> if the id is linekd to the category, <code>false</code> if not.
- */
- public boolean isLinked(String categoryId, String id);
-
- /**
- * Returns the list of categories the given id belongs to.
- *
- * @param id The id. Must not be <code>null</code>.
- * @return The list of category id's the id belongs to, or an empty list.
- */
- public String[] getCategoryIds(String id);
-
- /**
- * Returns the list of ids for the given category.
- *
- * @param categoryId The category id. Must not be <code>null</code>.
- * @return The list of id's that belongs to the given categoryId, or an empty list.
- */
- public String[] getIdsForCategory(String categoryId);
-
+/*******************************************************************************
+ * 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.ui.views.interfaces.categories;
+
+/**
+ * Interface to be implemented by category managers.
+ */
+public interface ICategoryManager {
+
+ /**
+ * Flush the current category manager state.
+ */
+ public void flush();
+
+ /**
+ * Adds the given id to the given category.
+ *
+ * @param categoryId The category id. Must not be <code>null</code>.
+ * @param id The id. Must not be <code>null</code>.
+ *
+ * @return <code>True</code> if the id has been added to the category, <code>false</code> if not.
+ */
+ public boolean add(String categoryId, String id);
+
+ /**
+ * Adds the given id to the given category.
+ * <p>
+ * <b>Note:</b> The category association is no persisted, the association is
+ * transient and is lost when the category manager is disposed.
+ *
+ * @param categoryId The category id. Must not be <code>null</code>.
+ * @param id The id. Must not be <code>null</code>.
+ *
+ * @return <code>True</code> if the id has been added to the category, <code>false</code> if not.
+ */
+ public boolean addTransient(String categoryId, String id);
+
+ /**
+ * Removes the given id from the given category.
+ *
+ * @param categoryId The category id. Must not be <code>null</code>.
+ * @param id The id. Must not be <code>null</code>.
+ *
+ * @return <code>True</code> if the id has been removed from the category, <code>false</code> if not.
+ */
+ public boolean remove(String categoryId, String id);
+
+ /**
+ * Returns if or if not the given id belongs to the given category.
+ *
+ * @param categoryId The category id. Must not be <code>null</code>.
+ * @param id The id. Must not be <code>null</code>.
+ *
+ * @return <code>True</code> if the id belongs to the category, <code>false</code> if not.
+ */
+ public boolean belongsTo(String categoryId, String id);
+
+ /**
+ * Returns if or if not the given id is linked to the given category.
+ *
+ * @param categoryId The category id. Must not be <code>null</code>.
+ * @param id The id. Must not be <code>null</code>.
+ *
+ * @return <code>True</code> if the id is linekd to the category, <code>false</code> if not.
+ */
+ public boolean isLinked(String categoryId, String id);
+
+ /**
+ * Returns the list of categories the given id belongs to.
+ *
+ * @param id The id. Must not be <code>null</code>.
+ * @return The list of category id's the id belongs to, or an empty list.
+ */
+ public String[] getCategoryIds(String id);
+
+ /**
+ * Returns the list of ids for the given category.
+ *
+ * @param categoryId The category id. Must not be <code>null</code>.
+ * @return The list of id's that belongs to the given categoryId, or an empty list.
+ */
+ public String[] getIdsForCategory(String categoryId);
+
} \ No newline at end of file
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/View.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/View.java
index 1e48fedf0..8a8b39178 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/View.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/View.java
@@ -1,255 +1,255 @@
-/*******************************************************************************
- * 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.ui.views.internal;
-
-import org.eclipse.core.commands.Command;
-import org.eclipse.core.commands.ParameterizedCommand;
-import org.eclipse.core.expressions.EvaluationContext;
-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.action.GroupMarker;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.viewers.ColumnViewerEditor;
-import org.eclipse.jface.viewers.ColumnViewerEditorActivationStrategy;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.TreeViewerEditor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.tcf.te.ui.trees.TreeViewerEditorActivationStrategy;
-import org.eclipse.tcf.te.ui.views.activator.UIPlugin;
-import org.eclipse.tcf.te.ui.views.interfaces.IUIConstants;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.ISources;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.commands.ICommandService;
-import org.eclipse.ui.handlers.IHandlerService;
-import org.eclipse.ui.navigator.CommonNavigator;
-import org.eclipse.ui.navigator.CommonViewer;
-import org.eclipse.ui.navigator.ICommonActionConstants;
-import org.eclipse.ui.navigator.IMementoAware;
-import org.eclipse.ui.views.properties.IPropertySheetPage;
-import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;
-import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
-
-
-/**
- * View implementation.
- * <p>
- * The view is based on the Eclipse Common Navigator framework.
- */
-public class View extends CommonNavigator implements ITabbedPropertySheetPageContributor {
- // The view root mode
- private int rootMode = IUIConstants.MODE_NORMAL;
-
- /**
- * Used only in the case of top level = MODE_NORMAL and only when some
- * working sets are selected.
- */
- private String workingSetLabel;
-
- // The state used to persisted the expanded nodes of the navigator tree.
- IMementoAware expandingState;
-
- /**
- * Constructor.
- */
- public View() {
- super();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.navigator.CommonNavigator#getInitialInput()
- */
- @Override
- protected Object getInitialInput() {
- return ViewRoot.getInstance();
- }
-
- /**
- * Sets the view's root mode.
- *
- * @param mode The root mode.
- * @see IUIConstants
- */
- @Override
- public void setRootMode(int mode) {
- rootMode = mode;
- }
-
- /**
- * Returns the view's root mode.
- *
- * @return The root mode
- * @see IUIConstants
- */
- @Override
- public int getRootMode() {
- return rootMode;
- }
-
- /**
- * Sets the working set label.
- *
- * @param label The working set label or <code>null</code>.
- */
- @Override
- public void setWorkingSetLabel(String label) {
- workingSetLabel = label;
- }
-
- /**
- * Returns the working set label.
- *
- * @return The working set label or <code>null</code>.
- */
- @Override
- public String getWorkingSetLabel() {
- return workingSetLabel;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.navigator.CommonNavigator#dispose()
- */
- @Override
- public void dispose() {
- super.dispose();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.navigator.CommonNavigator#createCommonViewerObject(org.eclipse.swt.widgets.Composite)
- */
- @Override
- protected CommonViewer createCommonViewerObject(Composite parent) {
- ViewViewer viewer = new ViewViewer(getViewSite().getId(), parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
- viewer.setComparer(new ViewViewerComparer());
- // Define an editor activation strategy for the common viewer so as to be invoked only programmatically.
- ColumnViewerEditorActivationStrategy activationStrategy = new TreeViewerEditorActivationStrategy(getSite().getId(), viewer);
- TreeViewerEditor.create(viewer, null, activationStrategy, ColumnViewerEditor.DEFAULT);
- return viewer;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.navigator.CommonNavigator#createPartControl(org.eclipse.swt.widgets.Composite)
- */
- @Override
- public void createPartControl(Composite parent) {
- super.createPartControl(parent);
-
- // Add the additional custom toolbar groups
- addCustomToolbarGroups();
-
- // Restore expanding state of the common viewer.
- expandingState = new ViewExpandingState(getCommonViewer());
- if (getMemento() != null) {
- expandingState.restoreState(getMemento());
- }
- }
-
- /**
- * Adds the custom toolbar groups to the view toolbar.
- */
- protected void addCustomToolbarGroups() {
- if (getViewSite() != null && getViewSite().getActionBars() != null) {
- IToolBarManager tbManager = getViewSite().getActionBars().getToolBarManager();
- if (tbManager != null) {
- tbManager.insertBefore("FRAME_ACTION_GROUP_ID", new GroupMarker("group.new")); //$NON-NLS-1$ //$NON-NLS-2$
- tbManager.appendToGroup("group.new", new Separator("group.configure")); //$NON-NLS-1$ //$NON-NLS-2$
- tbManager.appendToGroup("group.configure", new Separator("group.connect")); //$NON-NLS-1$ //$NON-NLS-2$
- tbManager.appendToGroup("group.connect", new Separator("group.symbols.rd")); //$NON-NLS-1$ //$NON-NLS-2$
- tbManager.appendToGroup("group.symbols.rd", new GroupMarker("group.symbols")); //$NON-NLS-1$ //$NON-NLS-2$
- tbManager.appendToGroup("group.symbols", new Separator("group.launch")); //$NON-NLS-1$ //$NON-NLS-2$
- tbManager.appendToGroup("group.launch", new GroupMarker("group.launch.rundebug")); //$NON-NLS-1$ //$NON-NLS-2$
- tbManager.appendToGroup("group.launch.rundebug", new GroupMarker("group.launch.modes")); //$NON-NLS-1$ //$NON-NLS-2$
- tbManager.appendToGroup("group.launch.modes", new GroupMarker("group.launch.additions")); //$NON-NLS-1$ //$NON-NLS-2$
- tbManager.appendToGroup("group.launch.additions", new Separator("group.refresh")); //$NON-NLS-1$ //$NON-NLS-2$
- tbManager.appendToGroup("group.refresh", new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); //$NON-NLS-1$
- }
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.navigator.CommonNavigator#saveState(org.eclipse.ui.IMemento)
- */
- @Override
- public void saveState(IMemento aMemento) {
- super.saveState(aMemento);
-
- // Save expanding state of the common viewer.
- if (expandingState != null && aMemento != null) {
- expandingState.saveState(aMemento);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.navigator.CommonNavigator#handleDoubleClick(org.eclipse.jface.viewers.DoubleClickEvent)
- */
- @Override
- protected void handleDoubleClick(DoubleClickEvent dblClickEvent) {
- // If an handled and enabled command is registered for the ICommonActionConstants.OPEN
- // retargetable action id, redirect the double click handling to the command handler.
- //
- // Note: The default tree node expansion must be re-implemented in the active handler!
- ICommandService service = (ICommandService)PlatformUI.getWorkbench().getService(ICommandService.class);
- Command command = service != null ? service.getCommand(ICommonActionConstants.OPEN) : null;
- if (command != null && command.isDefined() && command.isEnabled()) {
- try {
- IHandlerService handlerSvc = (IHandlerService)PlatformUI.getWorkbench().getService(IHandlerService.class);
- Assert.isNotNull(handlerSvc);
-
- ISelection selection = dblClickEvent.getSelection();
- EvaluationContext ctx = new EvaluationContext(handlerSvc.getCurrentState(), selection);
- ctx.addVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME, selection);
- ctx.addVariable(ISources.ACTIVE_MENU_SELECTION_NAME, selection);
- ctx.addVariable("altPressed", Boolean.valueOf(dblClickEvent instanceof AltDoubleClickEvent)); //$NON-NLS-1$
- ctx.setAllowPluginActivation(true);
-
- ParameterizedCommand pCmd = ParameterizedCommand.generateCommand(command, null);
- Assert.isNotNull(pCmd);
-
- handlerSvc.executeCommandInContext(pCmd, null, ctx);
- } catch (Exception e) {
- // If the platform is in debug mode, we print the exception to the log view
- if (Platform.inDebugMode()) {
- IStatus status = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(), e.getLocalizedMessage(), e);
- UIPlugin.getDefault().getLog().log(status);
- }
- }
- } else {
- // Fallback to the default implementation
- super.handleDoubleClick(dblClickEvent);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.navigator.CommonNavigator#getAdapter(java.lang.Class)
- */
- @Override
- public Object getAdapter(Class adapter) {
- if(adapter == IPropertySheetPage.class) {
- return new TabbedPropertySheetPage(this);
- }
- return super.getAdapter(adapter);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor#getContributorId()
- */
- @Override
- public String getContributorId() {
- return IUIConstants.TABBED_PROPERTIES_CONTRIBUTOR_ID;
- }
-}
+/*******************************************************************************
+ * 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.ui.views.internal;
+
+import org.eclipse.core.commands.Command;
+import org.eclipse.core.commands.ParameterizedCommand;
+import org.eclipse.core.expressions.EvaluationContext;
+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.action.GroupMarker;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.viewers.ColumnViewerEditor;
+import org.eclipse.jface.viewers.ColumnViewerEditorActivationStrategy;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.TreeViewerEditor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.tcf.te.ui.trees.TreeViewerEditorActivationStrategy;
+import org.eclipse.tcf.te.ui.views.activator.UIPlugin;
+import org.eclipse.tcf.te.ui.views.interfaces.IUIConstants;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.ISources;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.commands.ICommandService;
+import org.eclipse.ui.handlers.IHandlerService;
+import org.eclipse.ui.navigator.CommonNavigator;
+import org.eclipse.ui.navigator.CommonViewer;
+import org.eclipse.ui.navigator.ICommonActionConstants;
+import org.eclipse.ui.navigator.IMementoAware;
+import org.eclipse.ui.views.properties.IPropertySheetPage;
+import org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor;
+import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage;
+
+
+/**
+ * View implementation.
+ * <p>
+ * The view is based on the Eclipse Common Navigator framework.
+ */
+public class View extends CommonNavigator implements ITabbedPropertySheetPageContributor {
+ // The view root mode
+ private int rootMode = IUIConstants.MODE_NORMAL;
+
+ /**
+ * Used only in the case of top level = MODE_NORMAL and only when some
+ * working sets are selected.
+ */
+ private String workingSetLabel;
+
+ // The state used to persisted the expanded nodes of the navigator tree.
+ IMementoAware expandingState;
+
+ /**
+ * Constructor.
+ */
+ public View() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.CommonNavigator#getInitialInput()
+ */
+ @Override
+ protected Object getInitialInput() {
+ return ViewRoot.getInstance();
+ }
+
+ /**
+ * Sets the view's root mode.
+ *
+ * @param mode The root mode.
+ * @see IUIConstants
+ */
+ @Override
+ public void setRootMode(int mode) {
+ rootMode = mode;
+ }
+
+ /**
+ * Returns the view's root mode.
+ *
+ * @return The root mode
+ * @see IUIConstants
+ */
+ @Override
+ public int getRootMode() {
+ return rootMode;
+ }
+
+ /**
+ * Sets the working set label.
+ *
+ * @param label The working set label or <code>null</code>.
+ */
+ @Override
+ public void setWorkingSetLabel(String label) {
+ workingSetLabel = label;
+ }
+
+ /**
+ * Returns the working set label.
+ *
+ * @return The working set label or <code>null</code>.
+ */
+ @Override
+ public String getWorkingSetLabel() {
+ return workingSetLabel;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.CommonNavigator#dispose()
+ */
+ @Override
+ public void dispose() {
+ super.dispose();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.CommonNavigator#createCommonViewerObject(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected CommonViewer createCommonViewerObject(Composite parent) {
+ ViewViewer viewer = new ViewViewer(getViewSite().getId(), parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+ viewer.setComparer(new ViewViewerComparer());
+ // Define an editor activation strategy for the common viewer so as to be invoked only programmatically.
+ ColumnViewerEditorActivationStrategy activationStrategy = new TreeViewerEditorActivationStrategy(getSite().getId(), viewer);
+ TreeViewerEditor.create(viewer, null, activationStrategy, ColumnViewerEditor.DEFAULT);
+ return viewer;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.CommonNavigator#createPartControl(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ public void createPartControl(Composite parent) {
+ super.createPartControl(parent);
+
+ // Add the additional custom toolbar groups
+ addCustomToolbarGroups();
+
+ // Restore expanding state of the common viewer.
+ expandingState = new ViewExpandingState(getCommonViewer());
+ if (getMemento() != null) {
+ expandingState.restoreState(getMemento());
+ }
+ }
+
+ /**
+ * Adds the custom toolbar groups to the view toolbar.
+ */
+ protected void addCustomToolbarGroups() {
+ if (getViewSite() != null && getViewSite().getActionBars() != null) {
+ IToolBarManager tbManager = getViewSite().getActionBars().getToolBarManager();
+ if (tbManager != null) {
+ tbManager.insertBefore("FRAME_ACTION_GROUP_ID", new GroupMarker("group.new")); //$NON-NLS-1$ //$NON-NLS-2$
+ tbManager.appendToGroup("group.new", new Separator("group.configure")); //$NON-NLS-1$ //$NON-NLS-2$
+ tbManager.appendToGroup("group.configure", new Separator("group.connect")); //$NON-NLS-1$ //$NON-NLS-2$
+ tbManager.appendToGroup("group.connect", new Separator("group.symbols.rd")); //$NON-NLS-1$ //$NON-NLS-2$
+ tbManager.appendToGroup("group.symbols.rd", new GroupMarker("group.symbols")); //$NON-NLS-1$ //$NON-NLS-2$
+ tbManager.appendToGroup("group.symbols", new Separator("group.launch")); //$NON-NLS-1$ //$NON-NLS-2$
+ tbManager.appendToGroup("group.launch", new GroupMarker("group.launch.rundebug")); //$NON-NLS-1$ //$NON-NLS-2$
+ tbManager.appendToGroup("group.launch.rundebug", new GroupMarker("group.launch.modes")); //$NON-NLS-1$ //$NON-NLS-2$
+ tbManager.appendToGroup("group.launch.modes", new GroupMarker("group.launch.additions")); //$NON-NLS-1$ //$NON-NLS-2$
+ tbManager.appendToGroup("group.launch.additions", new Separator("group.refresh")); //$NON-NLS-1$ //$NON-NLS-2$
+ tbManager.appendToGroup("group.refresh", new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); //$NON-NLS-1$
+ }
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.navigator.CommonNavigator#saveState(org.eclipse.ui.IMemento)
+ */
+ @Override
+ public void saveState(IMemento aMemento) {
+ super.saveState(aMemento);
+
+ // Save expanding state of the common viewer.
+ if (expandingState != null && aMemento != null) {
+ expandingState.saveState(aMemento);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.CommonNavigator#handleDoubleClick(org.eclipse.jface.viewers.DoubleClickEvent)
+ */
+ @Override
+ protected void handleDoubleClick(DoubleClickEvent dblClickEvent) {
+ // If an handled and enabled command is registered for the ICommonActionConstants.OPEN
+ // retargetable action id, redirect the double click handling to the command handler.
+ //
+ // Note: The default tree node expansion must be re-implemented in the active handler!
+ ICommandService service = (ICommandService)PlatformUI.getWorkbench().getService(ICommandService.class);
+ Command command = service != null ? service.getCommand(ICommonActionConstants.OPEN) : null;
+ if (command != null && command.isDefined() && command.isEnabled()) {
+ try {
+ IHandlerService handlerSvc = (IHandlerService)PlatformUI.getWorkbench().getService(IHandlerService.class);
+ Assert.isNotNull(handlerSvc);
+
+ ISelection selection = dblClickEvent.getSelection();
+ EvaluationContext ctx = new EvaluationContext(handlerSvc.getCurrentState(), selection);
+ ctx.addVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME, selection);
+ ctx.addVariable(ISources.ACTIVE_MENU_SELECTION_NAME, selection);
+ ctx.addVariable("altPressed", Boolean.valueOf(dblClickEvent instanceof AltDoubleClickEvent)); //$NON-NLS-1$
+ ctx.setAllowPluginActivation(true);
+
+ ParameterizedCommand pCmd = ParameterizedCommand.generateCommand(command, null);
+ Assert.isNotNull(pCmd);
+
+ handlerSvc.executeCommandInContext(pCmd, null, ctx);
+ } catch (Exception e) {
+ // If the platform is in debug mode, we print the exception to the log view
+ if (Platform.inDebugMode()) {
+ IStatus status = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(), e.getLocalizedMessage(), e);
+ UIPlugin.getDefault().getLog().log(status);
+ }
+ }
+ } else {
+ // Fallback to the default implementation
+ super.handleDoubleClick(dblClickEvent);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.CommonNavigator#getAdapter(java.lang.Class)
+ */
+ @Override
+ public Object getAdapter(Class adapter) {
+ if(adapter == IPropertySheetPage.class) {
+ return new TabbedPropertySheetPage(this);
+ }
+ return super.getAdapter(adapter);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.views.properties.tabbed.ITabbedPropertySheetPageContributor#getContributorId()
+ */
+ @Override
+ public String getContributorId() {
+ return IUIConstants.TABBED_PROPERTIES_CONTRIBUTOR_ID;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/ViewViewer.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/ViewViewer.java
index 03d15899c..afab05672 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/ViewViewer.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/ViewViewer.java
@@ -1,153 +1,153 @@
-/*******************************************************************************
- * 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.ui.views.internal;
-
-import java.util.EventObject;
-
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.tcf.te.runtime.events.EventManager;
-import org.eclipse.tcf.te.ui.views.events.ViewerContentChangeEvent;
-import org.eclipse.ui.navigator.CommonViewer;
-import org.eclipse.ui.navigator.INavigatorContentService;
-
-/**
- * View common viewer implementation.
- */
-public class ViewViewer extends CommonViewer {
- // Flag to mark the viewer silent. In silent mode, no
- // ViewerContentChangeEvents are send.
- private boolean silent = false;
-
- // Remember the last double click selection event state mask
- private int lastDoubleClickSelectionEventStateMask = 0;
-
- /**
- * Constructor.
- *
- * @param view
- * The common navigator based parent view. Must not be <code>null</code>.
- * @param viewerId
- * An id tied to the extensions that is used to focus specific
- * content to a particular instance of the Common Navigator
- * @param parent
- * A Composite parent to contain the actual SWT widget
- * @param style
- * A style mask that will be used to create the TreeViewer
- * Composite.
- */
- public ViewViewer(String viewerId, Composite parent, int style) {
- super(viewerId, parent, style);
- }
-
- /**
- * Fire the given event if the viewer is not in silent mode.
- *
- * @param event The event or <code>null</code>.
- */
- private void fireEvent(EventObject event) {
- if (!silent && event != null) {
- EventManager.getInstance().fireEvent(event);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.navigator.CommonViewer#init()
- */
- @Override
- protected void init() {
- setUseHashlookup(true);
- INavigatorContentService contentService = getNavigatorContentService();
- setContentProvider(contentService.createCommonContentProvider());
- setLabelProvider(new ViewViewerDecoratingLabelProvider(this, contentService.createCommonLabelProvider()));
- initDragAndDrop();
- }
-
- /**
- * Sets the viewers event firing silent mode.
- *
- * @param silent <code>True</code> to stop firing change events, <code>false</code> otherwise.
- * @return <code>True</code> if the silent mode changed.
- */
- public boolean setSilentMode(boolean silent) {
- boolean changed = this.silent != silent;
- this.silent = silent;
- return changed;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.navigator.CommonViewer#add(java.lang.Object, java.lang.Object[])
- */
- @Override
- public void add(Object parentElement, Object[] childElements) {
- super.add(parentElement, childElements);
-
- ViewerContentChangeEvent event = new ViewerContentChangeEvent(this, ViewerContentChangeEvent.ADD);
- fireEvent(event);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.navigator.CommonViewer#remove(java.lang.Object[])
- */
- @Override
- public void remove(Object[] elements) {
- super.remove(elements);
-
- ViewerContentChangeEvent event = new ViewerContentChangeEvent(this, ViewerContentChangeEvent.REMOVE);
- fireEvent(event);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.AbstractTreeViewer#remove(java.lang.Object, java.lang.Object[])
- */
- @Override
- public void remove(Object parent, Object[] elements) {
- super.remove(parent, elements);
-
- ViewerContentChangeEvent event = new ViewerContentChangeEvent(this, ViewerContentChangeEvent.REMOVE);
- fireEvent(event);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.navigator.CommonViewer#refresh(java.lang.Object, boolean)
- */
- @Override
- public void refresh(Object element, boolean updateLabels) {
- super.refresh(element, updateLabels);
-
- ViewerContentChangeEvent event = new ViewerContentChangeEvent(this, ViewerContentChangeEvent.REFRESH);
- fireEvent(event);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.navigator.CommonViewer#handleDoubleSelect(org.eclipse.swt.events.SelectionEvent)
- */
- @Override
- protected void handleDoubleSelect(SelectionEvent event) {
- lastDoubleClickSelectionEventStateMask = event != null ? event.stateMask : 0;
- super.handleDoubleSelect(event);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.StructuredViewer#fireDoubleClick(org.eclipse.jface.viewers.DoubleClickEvent)
- */
- @Override
- protected void fireDoubleClick(DoubleClickEvent event) {
- boolean altPressed = (lastDoubleClickSelectionEventStateMask & SWT.ALT) != 0;
- if (altPressed) {
- event = new AltDoubleClickEvent((Viewer)event.getSource(), event.getSelection());
- }
- super.fireDoubleClick(event);
- }
-}
+/*******************************************************************************
+ * 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.ui.views.internal;
+
+import java.util.EventObject;
+
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.tcf.te.runtime.events.EventManager;
+import org.eclipse.tcf.te.ui.views.events.ViewerContentChangeEvent;
+import org.eclipse.ui.navigator.CommonViewer;
+import org.eclipse.ui.navigator.INavigatorContentService;
+
+/**
+ * View common viewer implementation.
+ */
+public class ViewViewer extends CommonViewer {
+ // Flag to mark the viewer silent. In silent mode, no
+ // ViewerContentChangeEvents are send.
+ private boolean silent = false;
+
+ // Remember the last double click selection event state mask
+ private int lastDoubleClickSelectionEventStateMask = 0;
+
+ /**
+ * Constructor.
+ *
+ * @param view
+ * The common navigator based parent view. Must not be <code>null</code>.
+ * @param viewerId
+ * An id tied to the extensions that is used to focus specific
+ * content to a particular instance of the Common Navigator
+ * @param parent
+ * A Composite parent to contain the actual SWT widget
+ * @param style
+ * A style mask that will be used to create the TreeViewer
+ * Composite.
+ */
+ public ViewViewer(String viewerId, Composite parent, int style) {
+ super(viewerId, parent, style);
+ }
+
+ /**
+ * Fire the given event if the viewer is not in silent mode.
+ *
+ * @param event The event or <code>null</code>.
+ */
+ private void fireEvent(EventObject event) {
+ if (!silent && event != null) {
+ EventManager.getInstance().fireEvent(event);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.navigator.CommonViewer#init()
+ */
+ @Override
+ protected void init() {
+ setUseHashlookup(true);
+ INavigatorContentService contentService = getNavigatorContentService();
+ setContentProvider(contentService.createCommonContentProvider());
+ setLabelProvider(new ViewViewerDecoratingLabelProvider(this, contentService.createCommonLabelProvider()));
+ initDragAndDrop();
+ }
+
+ /**
+ * Sets the viewers event firing silent mode.
+ *
+ * @param silent <code>True</code> to stop firing change events, <code>false</code> otherwise.
+ * @return <code>True</code> if the silent mode changed.
+ */
+ public boolean setSilentMode(boolean silent) {
+ boolean changed = this.silent != silent;
+ this.silent = silent;
+ return changed;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.CommonViewer#add(java.lang.Object, java.lang.Object[])
+ */
+ @Override
+ public void add(Object parentElement, Object[] childElements) {
+ super.add(parentElement, childElements);
+
+ ViewerContentChangeEvent event = new ViewerContentChangeEvent(this, ViewerContentChangeEvent.ADD);
+ fireEvent(event);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.CommonViewer#remove(java.lang.Object[])
+ */
+ @Override
+ public void remove(Object[] elements) {
+ super.remove(elements);
+
+ ViewerContentChangeEvent event = new ViewerContentChangeEvent(this, ViewerContentChangeEvent.REMOVE);
+ fireEvent(event);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.AbstractTreeViewer#remove(java.lang.Object, java.lang.Object[])
+ */
+ @Override
+ public void remove(Object parent, Object[] elements) {
+ super.remove(parent, elements);
+
+ ViewerContentChangeEvent event = new ViewerContentChangeEvent(this, ViewerContentChangeEvent.REMOVE);
+ fireEvent(event);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.CommonViewer#refresh(java.lang.Object, boolean)
+ */
+ @Override
+ public void refresh(Object element, boolean updateLabels) {
+ super.refresh(element, updateLabels);
+
+ ViewerContentChangeEvent event = new ViewerContentChangeEvent(this, ViewerContentChangeEvent.REFRESH);
+ fireEvent(event);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.CommonViewer#handleDoubleSelect(org.eclipse.swt.events.SelectionEvent)
+ */
+ @Override
+ protected void handleDoubleSelect(SelectionEvent event) {
+ lastDoubleClickSelectionEventStateMask = event != null ? event.stateMask : 0;
+ super.handleDoubleSelect(event);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.StructuredViewer#fireDoubleClick(org.eclipse.jface.viewers.DoubleClickEvent)
+ */
+ @Override
+ protected void fireDoubleClick(DoubleClickEvent event) {
+ boolean altPressed = (lastDoubleClickSelectionEventStateMask & SWT.ALT) != 0;
+ if (altPressed) {
+ event = new AltDoubleClickEvent((Viewer)event.getSource(), event.getSelection());
+ }
+ super.fireDoubleClick(event);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/adapters/EditorAdapterFactory.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/adapters/EditorAdapterFactory.java
index aea74c19e..49163cbc5 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/adapters/EditorAdapterFactory.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/adapters/EditorAdapterFactory.java
@@ -1,57 +1,57 @@
-/*******************************************************************************
- * 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.ui.views.internal.adapters;
-
-import org.eclipse.core.runtime.IAdapterFactory;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
-import org.eclipse.tcf.te.ui.views.editor.Editor;
-import org.eclipse.tcf.te.ui.views.editor.EditorInput;
-import org.eclipse.ui.forms.editor.IFormPage;
-
-/**
- * The adapter factory that adapts the editor to its active tree viewer.
- */
-public class EditorAdapterFactory implements IAdapterFactory {
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
- */
- @Override
- public Object getAdapter(Object adaptableObject, Class adapterType) {
- if(adaptableObject instanceof Editor) {
- Editor editor = (Editor) adaptableObject;
- if(TreeViewer.class.equals(adapterType)) {
- IFormPage activePage = editor.getActivePageInstance();
- if(activePage != null) {
- return activePage.getAdapter(TreeViewer.class);
- }
- }
- }
- if(adaptableObject instanceof EditorInput) {
- EditorInput editorInput = (EditorInput) adaptableObject;
- if(IModelNode.class.equals(adapterType)) {
- return editorInput.getAdapter(IModelNode.class);
- }
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
- */
- @Override
- public Class[] getAdapterList() {
- return new Class[]{TreeViewer.class, IModelNode.class};
- }
-
-}
+/*******************************************************************************
+ * 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.ui.views.internal.adapters;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
+import org.eclipse.tcf.te.ui.views.editor.Editor;
+import org.eclipse.tcf.te.ui.views.editor.EditorInput;
+import org.eclipse.ui.forms.editor.IFormPage;
+
+/**
+ * The adapter factory that adapts the editor to its active tree viewer.
+ */
+public class EditorAdapterFactory implements IAdapterFactory {
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
+ */
+ @Override
+ public Object getAdapter(Object adaptableObject, Class adapterType) {
+ if(adaptableObject instanceof Editor) {
+ Editor editor = (Editor) adaptableObject;
+ if(TreeViewer.class.equals(adapterType)) {
+ IFormPage activePage = editor.getActivePageInstance();
+ if(activePage != null) {
+ return activePage.getAdapter(TreeViewer.class);
+ }
+ }
+ }
+ if(adaptableObject instanceof EditorInput) {
+ EditorInput editorInput = (EditorInput) adaptableObject;
+ if(IModelNode.class.equals(adapterType)) {
+ return editorInput.getAdapter(IModelNode.class);
+ }
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
+ */
+ @Override
+ public Class[] getAdapterList() {
+ return new Class[]{TreeViewer.class, IModelNode.class};
+ }
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/categories/AbstractCategoryContributionItem.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/categories/AbstractCategoryContributionItem.java
index 8b9b05909..f54d967ec 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/categories/AbstractCategoryContributionItem.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/categories/AbstractCategoryContributionItem.java
@@ -1,305 +1,305 @@
-/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.ui.views.internal.categories;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.expressions.IEvaluationContext;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeSelection;
-import org.eclipse.jface.viewers.TreePath;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.tcf.te.ui.views.ViewsUtil;
-import org.eclipse.tcf.te.ui.views.extensions.CategoriesExtensionPointManager;
-import org.eclipse.tcf.te.ui.views.interfaces.ICategory;
-import org.eclipse.tcf.te.ui.views.interfaces.IUIConstants;
-import org.eclipse.tcf.te.ui.views.interfaces.categories.ICategorizable;
-import org.eclipse.ui.ISources;
-import org.eclipse.ui.actions.CompoundContributionItem;
-import org.eclipse.ui.handlers.IHandlerService;
-import org.eclipse.ui.menus.IWorkbenchContribution;
-import org.eclipse.ui.services.IServiceLocator;
-
-/**
- * Abstract categories dynamic menu contribution implementation.
- */
-public abstract class AbstractCategoryContributionItem extends CompoundContributionItem implements IWorkbenchContribution {
- // Service locator to located the handler service.
- protected IServiceLocator serviceLocator;
-
- /**
- * Abstract category action implementation.
- */
- protected abstract static class AbstractCategoryAction extends Action {
- // The parent contribution item
- private final AbstractCategoryContributionItem item;
- // The selection
- private final ISelection selection;
- // The category
- private final ICategory category;
-
- /**
- * Constructor.
- *
- * @param item The parent contribution item. Must not be <code>null</code>:
- * @param selection The selection. Must not be <code>null</code>.
- * @param category The category. Must not be <code>null</code>.
- * @param single <code>True</code> if the action is the only item added, <code>false</code> otherwise.
- */
- public AbstractCategoryAction(AbstractCategoryContributionItem item, ISelection selection, ICategory category, boolean single) {
- super();
-
- Assert.isNotNull(item);
- this.item = item;
- Assert.isNotNull(selection);
- this.selection = selection;
- Assert.isNotNull(category);
- this.category = category;
-
- initialize(single);
- }
-
- /**
- * Initialize the action state.
- *
- * @param single <code>True</code> if the action is the only item added, <code>false</code> otherwise.
- */
- protected void initialize(boolean single) {
- setText(single ? makeSingleText(category.getLabel()) : category.getLabel());
-
- Image image = category.getImage();
- if (image != null) setImageDescriptor(ImageDescriptor.createFromImage(image));
- }
-
- /**
- * Returns the action label in "single" mode.
- *
- * @param text The original label. Must not be <code>null</code>.
- * @return The "single" mode label.
- */
- protected String makeSingleText(String text) {
- Assert.isNotNull(text);
- return text;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.Action#run()
- */
- @Override
- public void run() {
- if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
- boolean refresh = false;
- Iterator<?> iterator = ((IStructuredSelection)selection).iterator();
- while (iterator.hasNext()) {
- Object element = iterator.next();
- refresh |= execute(element, category);
- }
-
- // Refresh the view
- if (refresh) ViewsUtil.refresh(IUIConstants.ID_EXPLORER);
- }
- }
-
- /**
- * Returns the categorizable for the given element.
- *
- * @param element The element or <code>null</code>.
- * @return The categorizable or <code>null</code>.
- */
- protected ICategorizable getCategorizable(Object element) {
- return item.getCategorizable(element);
- }
-
- /**
- * Executes the operation to do on the given element.
- *
- * @param selection The selection. Must not be <code>null</code>.
- * @param category The category. Must not be <code>null</code>.
- *
- * @return <code>True</code> if the view needs refreshment, <code>false</code> otherwise.
- */
- protected abstract boolean execute(Object element, ICategory category);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.menus.IWorkbenchContribution#initialize(org.eclipse.ui.services.IServiceLocator)
- */
- @Override
- public void initialize(IServiceLocator serviceLocator) {
- this.serviceLocator = serviceLocator;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.actions.CompoundContributionItem#getContributionItems()
- */
- @Override
- protected IContributionItem[] getContributionItems() {
- // Get the selected node.
- IHandlerService service = (IHandlerService)serviceLocator.getService(IHandlerService.class);
- IEvaluationContext state = service.getCurrentState();
- ISelection selection = (ISelection)state.getVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME);
- IStructuredSelection iss = (IStructuredSelection)selection;
-
- List<IContributionItem> items = new ArrayList<IContributionItem>();
- ICategory[] categories = getCategories(iss, true);
-
- // Generate the action contribution items
- for (ICategory category : categories) {
- IAction action = createAction(this, iss, category, categories.length == 1);
- if (action != null) {
- action.setEnabled(isEnabled(iss, category));
- items.add(new ActionContributionItem(action));
- }
- }
-
- return items.toArray(new IContributionItem[items.size()]);
- }
-
- /**
- * Returns the list of valid categories for the given selection.
- *
- * @param selection The selection. Must not be <code>null</code>.
- * @param onlyEnabled If <code>true</code>, returns categories which are valid and enabled only.
- *
- * @return The list of valid categories for the given selection, or an empty list.
- */
- protected ICategory[] getCategories(IStructuredSelection selection, boolean onlyEnabled) {
- Assert.isNotNull(selection);
-
- List<ICategory> categories = new ArrayList<ICategory>();
- ICategory[] allCategories = CategoriesExtensionPointManager.getInstance().getCategories(false);
-
- // Analyze the selection and add categories valid for all items in the selection
- boolean firstRun = true;
- Iterator<?> iterator = selection.iterator();
- while (iterator.hasNext()) {
- Object element = iterator.next();
- if (getCategorizable(element) == null) continue;
-
- ICategory parentCategory = getParentCategory(element, selection);
-
- List<ICategory> candidates = new ArrayList<ICategory>();
- for (ICategory category : allCategories) {
- if (!category.isEnabled()) continue;
- if (isValid(parentCategory, element, category)
- && (!onlyEnabled || isEnabled(selection, category))) {
- candidates.add(category);
- }
- }
-
- // On first run, we remember the candidates as is
- if (firstRun) {
- categories.addAll(candidates);
- firstRun = false;
- } else {
- // Eliminate all categories not being listed as candidate too
- Iterator<ICategory> catIterator = categories.iterator();
- while (catIterator.hasNext()) {
- ICategory category = catIterator.next();
- if (!candidates.contains(category)) {
- catIterator.remove();
- }
- }
- }
- }
-
- return categories.toArray(new ICategory[categories.size()]);
- }
-
- /**
- * Creates the category action instance.
- *
- * @param item The parent contribution item. Must not be <code>null</code>:
- * @param selection The selection. Must not be <code>null</code>.
- * @param category The category. Must not be <code>null</code>.
- * @param single <code>True</code> if the action is the only item added, <code>false</code> otherwise.
- *
- * @return The category action instance.
- */
- protected abstract IAction createAction(AbstractCategoryContributionItem item, ISelection selection, ICategory category, boolean single);
-
- /**
- * Tests if the given combination is valid. If not valid, the combination
- * will not be added to the menu.
- *
- * @param parentCategory The parent category or <code>null</code>.
- * @param element The element. Must not be <code>null</code>.
- * @param category The category. Must not be <code>null</code>.
- *
- * @return <code>True</code> if the given combination is valid, <code>false</code> otherwise.
- */
- protected abstract boolean isValid(ICategory parentCategory, Object element, ICategory category);
-
- /**
- * Tests if the given combination is enabled.
- *
- * @param element The selection. Must not be <code>null</code>.
- * @param category The category. Must not be <code>null</code>.
- *
- * @return <code>True</code> if the given combination is enabled, <code>false</code> otherwise.
- */
- protected abstract boolean isEnabled(ISelection selection, ICategory category);
-
- /**
- * Determines the parent category for the given element, based on the
- * given selection.
- *
- * @param element The element. Must not be <code>null</code>.
- * @param selection The selection. Must not be <code>null</code>.
- *
- * @return The parent category or <code>null</code>.
- */
- protected ICategory getParentCategory(Object element, IStructuredSelection selection) {
- Assert.isNotNull(element);
- Assert.isNotNull(selection);
-
- ICategory parent = null;
-
- if (selection instanceof ITreeSelection) {
- TreePath[] pathes = ((ITreeSelection)selection).getPathsFor(element);
- for (TreePath path : pathes) {
- TreePath parentPath = path.getParentPath();
- while (parentPath != null) {
- if (parentPath.getLastSegment() instanceof ICategory) {
- parent = (ICategory)parentPath.getLastSegment();
- break;
- }
- parentPath = parentPath.getParentPath();
- }
- if (parent != null) break;
- }
- }
-
- return parent;
- }
-
- /**
- * Returns the categorizable for the given element.
- *
- * @param element The element or <code>null</code>.
- * @return The categorizable or <code>null</code>.
- */
- protected ICategorizable getCategorizable(Object element) {
- ICategorizable categorizable = element instanceof IAdaptable ? (ICategorizable)((IAdaptable)element).getAdapter(ICategorizable.class) : null;
- if (categorizable == null) categorizable = (ICategorizable)Platform.getAdapterManager().getAdapter(element, ICategorizable.class);
- return categorizable;
- }
-}
+/*******************************************************************************
+ * 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.ui.views.internal.categories;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.expressions.IEvaluationContext;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeSelection;
+import org.eclipse.jface.viewers.TreePath;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.tcf.te.ui.views.ViewsUtil;
+import org.eclipse.tcf.te.ui.views.extensions.CategoriesExtensionPointManager;
+import org.eclipse.tcf.te.ui.views.interfaces.ICategory;
+import org.eclipse.tcf.te.ui.views.interfaces.IUIConstants;
+import org.eclipse.tcf.te.ui.views.interfaces.categories.ICategorizable;
+import org.eclipse.ui.ISources;
+import org.eclipse.ui.actions.CompoundContributionItem;
+import org.eclipse.ui.handlers.IHandlerService;
+import org.eclipse.ui.menus.IWorkbenchContribution;
+import org.eclipse.ui.services.IServiceLocator;
+
+/**
+ * Abstract categories dynamic menu contribution implementation.
+ */
+public abstract class AbstractCategoryContributionItem extends CompoundContributionItem implements IWorkbenchContribution {
+ // Service locator to located the handler service.
+ protected IServiceLocator serviceLocator;
+
+ /**
+ * Abstract category action implementation.
+ */
+ protected abstract static class AbstractCategoryAction extends Action {
+ // The parent contribution item
+ private final AbstractCategoryContributionItem item;
+ // The selection
+ private final ISelection selection;
+ // The category
+ private final ICategory category;
+
+ /**
+ * Constructor.
+ *
+ * @param item The parent contribution item. Must not be <code>null</code>:
+ * @param selection The selection. Must not be <code>null</code>.
+ * @param category The category. Must not be <code>null</code>.
+ * @param single <code>True</code> if the action is the only item added, <code>false</code> otherwise.
+ */
+ public AbstractCategoryAction(AbstractCategoryContributionItem item, ISelection selection, ICategory category, boolean single) {
+ super();
+
+ Assert.isNotNull(item);
+ this.item = item;
+ Assert.isNotNull(selection);
+ this.selection = selection;
+ Assert.isNotNull(category);
+ this.category = category;
+
+ initialize(single);
+ }
+
+ /**
+ * Initialize the action state.
+ *
+ * @param single <code>True</code> if the action is the only item added, <code>false</code> otherwise.
+ */
+ protected void initialize(boolean single) {
+ setText(single ? makeSingleText(category.getLabel()) : category.getLabel());
+
+ Image image = category.getImage();
+ if (image != null) setImageDescriptor(ImageDescriptor.createFromImage(image));
+ }
+
+ /**
+ * Returns the action label in "single" mode.
+ *
+ * @param text The original label. Must not be <code>null</code>.
+ * @return The "single" mode label.
+ */
+ protected String makeSingleText(String text) {
+ Assert.isNotNull(text);
+ return text;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
+ boolean refresh = false;
+ Iterator<?> iterator = ((IStructuredSelection)selection).iterator();
+ while (iterator.hasNext()) {
+ Object element = iterator.next();
+ refresh |= execute(element, category);
+ }
+
+ // Refresh the view
+ if (refresh) ViewsUtil.refresh(IUIConstants.ID_EXPLORER);
+ }
+ }
+
+ /**
+ * Returns the categorizable for the given element.
+ *
+ * @param element The element or <code>null</code>.
+ * @return The categorizable or <code>null</code>.
+ */
+ protected ICategorizable getCategorizable(Object element) {
+ return item.getCategorizable(element);
+ }
+
+ /**
+ * Executes the operation to do on the given element.
+ *
+ * @param selection The selection. Must not be <code>null</code>.
+ * @param category The category. Must not be <code>null</code>.
+ *
+ * @return <code>True</code> if the view needs refreshment, <code>false</code> otherwise.
+ */
+ protected abstract boolean execute(Object element, ICategory category);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.menus.IWorkbenchContribution#initialize(org.eclipse.ui.services.IServiceLocator)
+ */
+ @Override
+ public void initialize(IServiceLocator serviceLocator) {
+ this.serviceLocator = serviceLocator;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.actions.CompoundContributionItem#getContributionItems()
+ */
+ @Override
+ protected IContributionItem[] getContributionItems() {
+ // Get the selected node.
+ IHandlerService service = (IHandlerService)serviceLocator.getService(IHandlerService.class);
+ IEvaluationContext state = service.getCurrentState();
+ ISelection selection = (ISelection)state.getVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME);
+ IStructuredSelection iss = (IStructuredSelection)selection;
+
+ List<IContributionItem> items = new ArrayList<IContributionItem>();
+ ICategory[] categories = getCategories(iss, true);
+
+ // Generate the action contribution items
+ for (ICategory category : categories) {
+ IAction action = createAction(this, iss, category, categories.length == 1);
+ if (action != null) {
+ action.setEnabled(isEnabled(iss, category));
+ items.add(new ActionContributionItem(action));
+ }
+ }
+
+ return items.toArray(new IContributionItem[items.size()]);
+ }
+
+ /**
+ * Returns the list of valid categories for the given selection.
+ *
+ * @param selection The selection. Must not be <code>null</code>.
+ * @param onlyEnabled If <code>true</code>, returns categories which are valid and enabled only.
+ *
+ * @return The list of valid categories for the given selection, or an empty list.
+ */
+ protected ICategory[] getCategories(IStructuredSelection selection, boolean onlyEnabled) {
+ Assert.isNotNull(selection);
+
+ List<ICategory> categories = new ArrayList<ICategory>();
+ ICategory[] allCategories = CategoriesExtensionPointManager.getInstance().getCategories(false);
+
+ // Analyze the selection and add categories valid for all items in the selection
+ boolean firstRun = true;
+ Iterator<?> iterator = selection.iterator();
+ while (iterator.hasNext()) {
+ Object element = iterator.next();
+ if (getCategorizable(element) == null) continue;
+
+ ICategory parentCategory = getParentCategory(element, selection);
+
+ List<ICategory> candidates = new ArrayList<ICategory>();
+ for (ICategory category : allCategories) {
+ if (!category.isEnabled()) continue;
+ if (isValid(parentCategory, element, category)
+ && (!onlyEnabled || isEnabled(selection, category))) {
+ candidates.add(category);
+ }
+ }
+
+ // On first run, we remember the candidates as is
+ if (firstRun) {
+ categories.addAll(candidates);
+ firstRun = false;
+ } else {
+ // Eliminate all categories not being listed as candidate too
+ Iterator<ICategory> catIterator = categories.iterator();
+ while (catIterator.hasNext()) {
+ ICategory category = catIterator.next();
+ if (!candidates.contains(category)) {
+ catIterator.remove();
+ }
+ }
+ }
+ }
+
+ return categories.toArray(new ICategory[categories.size()]);
+ }
+
+ /**
+ * Creates the category action instance.
+ *
+ * @param item The parent contribution item. Must not be <code>null</code>:
+ * @param selection The selection. Must not be <code>null</code>.
+ * @param category The category. Must not be <code>null</code>.
+ * @param single <code>True</code> if the action is the only item added, <code>false</code> otherwise.
+ *
+ * @return The category action instance.
+ */
+ protected abstract IAction createAction(AbstractCategoryContributionItem item, ISelection selection, ICategory category, boolean single);
+
+ /**
+ * Tests if the given combination is valid. If not valid, the combination
+ * will not be added to the menu.
+ *
+ * @param parentCategory The parent category or <code>null</code>.
+ * @param element The element. Must not be <code>null</code>.
+ * @param category The category. Must not be <code>null</code>.
+ *
+ * @return <code>True</code> if the given combination is valid, <code>false</code> otherwise.
+ */
+ protected abstract boolean isValid(ICategory parentCategory, Object element, ICategory category);
+
+ /**
+ * Tests if the given combination is enabled.
+ *
+ * @param element The selection. Must not be <code>null</code>.
+ * @param category The category. Must not be <code>null</code>.
+ *
+ * @return <code>True</code> if the given combination is enabled, <code>false</code> otherwise.
+ */
+ protected abstract boolean isEnabled(ISelection selection, ICategory category);
+
+ /**
+ * Determines the parent category for the given element, based on the
+ * given selection.
+ *
+ * @param element The element. Must not be <code>null</code>.
+ * @param selection The selection. Must not be <code>null</code>.
+ *
+ * @return The parent category or <code>null</code>.
+ */
+ protected ICategory getParentCategory(Object element, IStructuredSelection selection) {
+ Assert.isNotNull(element);
+ Assert.isNotNull(selection);
+
+ ICategory parent = null;
+
+ if (selection instanceof ITreeSelection) {
+ TreePath[] pathes = ((ITreeSelection)selection).getPathsFor(element);
+ for (TreePath path : pathes) {
+ TreePath parentPath = path.getParentPath();
+ while (parentPath != null) {
+ if (parentPath.getLastSegment() instanceof ICategory) {
+ parent = (ICategory)parentPath.getLastSegment();
+ break;
+ }
+ parentPath = parentPath.getParentPath();
+ }
+ if (parent != null) break;
+ }
+ }
+
+ return parent;
+ }
+
+ /**
+ * Returns the categorizable for the given element.
+ *
+ * @param element The element or <code>null</code>.
+ * @return The categorizable or <code>null</code>.
+ */
+ protected ICategorizable getCategorizable(Object element) {
+ ICategorizable categorizable = element instanceof IAdaptable ? (ICategorizable)((IAdaptable)element).getAdapter(ICategorizable.class) : null;
+ if (categorizable == null) categorizable = (ICategorizable)Platform.getAdapterManager().getAdapter(element, ICategorizable.class);
+ return categorizable;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/categories/CategoryFactory.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/categories/CategoryFactory.java
index ff6af9538..cb9f998ab 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/categories/CategoryFactory.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/categories/CategoryFactory.java
@@ -1,49 +1,49 @@
-/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.ui.views.internal.categories;
-
-import java.util.concurrent.atomic.AtomicReference;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.tcf.te.ui.views.extensions.CategoriesExtensionPointManager;
-import org.eclipse.tcf.te.ui.views.interfaces.ICategory;
-import org.eclipse.ui.IElementFactory;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.PlatformUI;
-/**
- * The element factory for a category.
- */
-public class CategoryFactory implements IElementFactory {
- /*
- * (non-Javadoc)
- * @see org.eclipse.ui.IElementFactory#createElement(org.eclipse.ui.IMemento)
- */
- @Override
- public IAdaptable createElement(final IMemento memento) {
- final AtomicReference<ICategory> category = new AtomicReference<ICategory>();
-
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- String id = memento.getString("id"); //$NON-NLS-1$
- category.set(CategoriesExtensionPointManager.getInstance().getCategory(id, false));
- }
- };
-
- if (Display.findDisplay(Thread.currentThread()) == null) {
- PlatformUI.getWorkbench().getDisplay().syncExec(runnable);
- } else {
- runnable.run();
- }
-
- return category.get() instanceof IAdaptable ? (IAdaptable)category.get() : null;
- }
-}
+/*******************************************************************************
+ * 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.ui.views.internal.categories;
+
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.tcf.te.ui.views.extensions.CategoriesExtensionPointManager;
+import org.eclipse.tcf.te.ui.views.interfaces.ICategory;
+import org.eclipse.ui.IElementFactory;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.PlatformUI;
+/**
+ * The element factory for a category.
+ */
+public class CategoryFactory implements IElementFactory {
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.IElementFactory#createElement(org.eclipse.ui.IMemento)
+ */
+ @Override
+ public IAdaptable createElement(final IMemento memento) {
+ final AtomicReference<ICategory> category = new AtomicReference<ICategory>();
+
+ Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ String id = memento.getString("id"); //$NON-NLS-1$
+ category.set(CategoriesExtensionPointManager.getInstance().getCategory(id, false));
+ }
+ };
+
+ if (Display.findDisplay(Thread.currentThread()) == null) {
+ PlatformUI.getWorkbench().getDisplay().syncExec(runnable);
+ } else {
+ runnable.run();
+ }
+
+ return category.get() instanceof IAdaptable ? (IAdaptable)category.get() : null;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/categories/CategoryManager.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/categories/CategoryManager.java
index 228bc0d25..e65f6706b 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/categories/CategoryManager.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/categories/CategoryManager.java
@@ -1,364 +1,364 @@
-/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.ui.views.internal.categories;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.tcf.te.runtime.events.ChangeEvent;
-import org.eclipse.tcf.te.runtime.events.EventManager;
-import org.eclipse.tcf.te.runtime.persistence.interfaces.IURIPersistenceService;
-import org.eclipse.tcf.te.runtime.services.ServiceManager;
-import org.eclipse.tcf.te.ui.views.activator.UIPlugin;
-import org.eclipse.tcf.te.ui.views.extensions.CategoriesExtensionPointManager;
-import org.eclipse.tcf.te.ui.views.interfaces.categories.ICategoryManager;
-
-
-/**
- * Category manager implementation.
- */
-public class CategoryManager implements ICategoryManager {
- // The map maintaining the id list per category id
- private Map<String, List<String>> cat2id = new HashMap<String, List<String>>();
- // The map maintaining the category id list per id
- private Map<String, List<String>> id2cat = new HashMap<String, List<String>>();
-
- // The map maintaining the transient id list per category id
- private final Map<String, List<String>> _t_cat2id = new HashMap<String, List<String>>();
- // The map maintaining the transient category id list per id
- private final Map<String, List<String>> _t_id2cat = new HashMap<String, List<String>>();
-
- /**
- * Constructor.
- */
- public CategoryManager() {
- super();
- initialize();
- }
-
- /**
- * Returns the root path where to persist the maps between the sessions.
- *
- * @return The root path or <code>null</code>.
- */
- private IPath getRoot() {
- try {
- File file = UIPlugin.getDefault().getStateLocation().toFile();
- boolean exists = file.exists();
- if (!exists) {
- exists = file.mkdirs();
- }
- if (exists && file.canRead() && file.isDirectory()) {
- return new Path(file.toString());
- }
- } catch (IllegalStateException e) {
- /* ignored on purpose */
- }
-
- File file = new Path(System.getProperty("user.home")).append(".tcf").toFile(); //$NON-NLS-1$ //$NON-NLS-2$
- if (file.canRead() && file.isDirectory()) {
- return new Path(file.toString());
- }
-
- return null;
- }
-
- /**
- * Initialize the category manager.
- */
- private void initialize() {
- IPath root = getRoot();
- if (root == null) {
- return;
- }
-
- // Clear out the transient maps
- _t_cat2id.clear();
- _t_id2cat.clear();
-
- cat2id.clear();
- id2cat.clear();
-
- try {
- // Get the persistence service
- IURIPersistenceService uRIPersistenceService = ServiceManager.getInstance().getService(IURIPersistenceService.class);
- if (uRIPersistenceService == null) {
- throw new IOException("Persistence service instance unavailable."); //$NON-NLS-1$
- }
- // Save the history to the persistence storage
- cat2id = (Map<String,List<String>>)uRIPersistenceService.read(cat2id, root.append("cat2id.json").toFile().toURI()); //$NON-NLS-1$
- } catch (IOException e) {
- }
-
- try {
- // Get the persistence service
- IURIPersistenceService uRIPersistenceService = ServiceManager.getInstance().getService(IURIPersistenceService.class);
- if (uRIPersistenceService == null) {
- throw new IOException("Persistence service instance unavailable."); //$NON-NLS-1$
- }
- // Save the history to the persistence storage
- id2cat = (Map<String,List<String>>)uRIPersistenceService.read(id2cat, root.append("id2cat.json").toFile().toURI()); //$NON-NLS-1$
- } catch (IOException e) {
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.views.categories.ICategoryManager#flush()
- */
- @Override
- public void flush() {
- IPath root = getRoot();
- if (root == null) {
- return;
- }
-
- try {
- // Get the persistence service
- IURIPersistenceService uRIPersistenceService = ServiceManager.getInstance().getService(IURIPersistenceService.class);
- if (uRIPersistenceService == null) {
- throw new IOException("Persistence service instance unavailable."); //$NON-NLS-1$
- }
- // Save the history to the persistence storage
- uRIPersistenceService.write(cat2id, root.append("cat2id.json").toFile().toURI()); //$NON-NLS-1$
- } catch (IOException e) {
- }
-
- try {
- // Get the persistence service
- IURIPersistenceService uRIPersistenceService = ServiceManager.getInstance().getService(IURIPersistenceService.class);
- if (uRIPersistenceService == null) {
- throw new IOException("Persistence service instance unavailable."); //$NON-NLS-1$
- }
- // Save the history to the persistence storage
- uRIPersistenceService.write(id2cat, root.append("id2cat.json").toFile().toURI()); //$NON-NLS-1$
- } catch (IOException e) {
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.views.categories.ICategoryManager#add(java.lang.String, java.lang.String)
- */
- @Override
- public boolean add(String categoryId, String id) {
- Assert.isNotNull(categoryId);
- Assert.isNotNull(id);
-
- boolean added = false;
-
- List<String> ids = cat2id.get(categoryId);
- if (ids == null) {
- ids = new ArrayList<String>();
- cat2id.put(categoryId, ids);
- }
- if (!ids.contains(id)) {
- added |= ids.add(id);
- }
-
- List<String> cats = id2cat.get(id);
- if (cats == null) {
- cats = new ArrayList<String>();
- id2cat.put(id, cats);
- }
- if (!cats.contains(categoryId)) {
- added |= cats.add(categoryId);
- }
-
- if (added) {
- flush();
- EventManager.getInstance().fireEvent(
- new ChangeEvent(CategoriesExtensionPointManager.getInstance().getCategory(categoryId, false), ChangeEvent.ID_ADDED, null, id));
- }
-
- return added;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.views.interfaces.categories.ICategoryManager#addTransient(java.lang.String, java.lang.String)
- */
- @Override
- public boolean addTransient(String categoryId, String id) {
- Assert.isNotNull(categoryId);
- Assert.isNotNull(id);
-
- boolean added = false;
-
- List<String> ids = _t_cat2id.get(categoryId);
- if (ids == null) {
- ids = new ArrayList<String>();
- _t_cat2id.put(categoryId, ids);
- }
- if (!ids.contains(id)) {
- added |= ids.add(id);
- }
-
- List<String> cats = _t_id2cat.get(id);
- if (cats == null) {
- cats = new ArrayList<String>();
- _t_id2cat.put(id, cats);
- }
- if (!cats.contains(categoryId)) {
- added |= cats.add(categoryId);
- }
-
- if (added) {
- EventManager.getInstance().fireEvent(
- new ChangeEvent(CategoriesExtensionPointManager.getInstance().getCategory(categoryId, false), ChangeEvent.ID_ADDED, null, id));
- }
-
- return added;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.views.categories.ICategoryManager#remove(java.lang.String, java.lang.String)
- */
- @Override
- public boolean remove(String categoryId, String id) {
- Assert.isNotNull(categoryId);
- Assert.isNotNull(id);
-
- boolean removed = false;
-
- List<String> ids = cat2id.get(categoryId);
- if (ids != null) {
- removed |= ids.remove(id);
- if (ids.isEmpty()) {
- cat2id.remove(categoryId);
- }
- }
- ids = _t_cat2id.get(categoryId);
- if (ids != null) {
- removed |= ids.remove(id);
- if (ids.isEmpty()) {
- _t_cat2id.remove(categoryId);
- }
- }
-
- List<String> cats = id2cat.get(id);
- if (cats != null) {
- removed |= cats.remove(categoryId);
- if (cats.isEmpty()) {
- id2cat.remove(id);
- }
- }
- cats = _t_id2cat.get(id);
- if (cats != null) {
- removed |= cats.remove(categoryId);
- if (cats.isEmpty()) {
- _t_id2cat.remove(id);
- }
- }
-
- if (removed) {
- flush();
- EventManager.getInstance().fireEvent(
- new ChangeEvent(CategoriesExtensionPointManager.getInstance().getCategory(categoryId, false), ChangeEvent.ID_REMOVED, id, null));
- }
-
- return removed;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.views.categories.ICategoryManager#belongsTo(java.lang.String, java.lang.String)
- */
- @Override
- public boolean belongsTo(String categoryId, String id) {
- Assert.isNotNull(categoryId);
- Assert.isNotNull(id);
-
- boolean belongsTo = isLinked(categoryId, id);
-
- List<String> ids = cat2id.get(categoryId);
- if (!belongsTo) {
- ids = _t_cat2id.get(categoryId);
- if (ids != null && ids.contains(id)) {
- belongsTo = true;
- }
- }
-
- return belongsTo;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.views.interfaces.categories.ICategoryManager#isLinked(java.lang.String, java.lang.String)
- */
- @Override
- public boolean isLinked(String categoryId, String id) {
- Assert.isNotNull(categoryId);
- Assert.isNotNull(id);
-
- boolean belongsTo = false;
-
- List<String> ids = cat2id.get(categoryId);
- if (ids != null && ids.contains(id)) {
- belongsTo = true;
- }
-
- return belongsTo;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.views.categories.ICategoryManager#getCategoryIds(java.lang.String)
- */
- @Override
- public String[] getCategoryIds(String id) {
- Assert.isNotNull(id);
-
- List<String> allCategories = new ArrayList<String>();
-
- List<String> cats = id2cat.get(id);
- if (cats != null) {
- allCategories.addAll(cats);
- }
-
- cats = _t_id2cat.get(id);
- if (cats != null) {
- for (String cat : cats) {
- if (!allCategories.contains(cat)) {
- allCategories.add(cat);
- }
- }
- }
-
- return allCategories.toArray(new String[allCategories.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.views.interfaces.categories.ICategoryManager#getIdsForCategory(java.lang.String)
- */
- @Override
- public String[] getIdsForCategory(String categoryId) {
- Assert.isNotNull(categoryId);
-
- List<String> allIds = new ArrayList<String>();
-
- List<String> cats = cat2id.get(categoryId);
- if (cats != null) {
- allIds.addAll(cats);
- }
-
- cats = _t_cat2id.get(categoryId);
- if (cats != null) {
- for (String cat : cats) {
- if (!allIds.contains(cat)) {
- allIds.add(cat);
- }
- }
- }
-
- return allIds.toArray(new String[allIds.size()]);
- }
-}
+/*******************************************************************************
+ * 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.ui.views.internal.categories;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.tcf.te.runtime.events.ChangeEvent;
+import org.eclipse.tcf.te.runtime.events.EventManager;
+import org.eclipse.tcf.te.runtime.persistence.interfaces.IURIPersistenceService;
+import org.eclipse.tcf.te.runtime.services.ServiceManager;
+import org.eclipse.tcf.te.ui.views.activator.UIPlugin;
+import org.eclipse.tcf.te.ui.views.extensions.CategoriesExtensionPointManager;
+import org.eclipse.tcf.te.ui.views.interfaces.categories.ICategoryManager;
+
+
+/**
+ * Category manager implementation.
+ */
+public class CategoryManager implements ICategoryManager {
+ // The map maintaining the id list per category id
+ private Map<String, List<String>> cat2id = new HashMap<String, List<String>>();
+ // The map maintaining the category id list per id
+ private Map<String, List<String>> id2cat = new HashMap<String, List<String>>();
+
+ // The map maintaining the transient id list per category id
+ private final Map<String, List<String>> _t_cat2id = new HashMap<String, List<String>>();
+ // The map maintaining the transient category id list per id
+ private final Map<String, List<String>> _t_id2cat = new HashMap<String, List<String>>();
+
+ /**
+ * Constructor.
+ */
+ public CategoryManager() {
+ super();
+ initialize();
+ }
+
+ /**
+ * Returns the root path where to persist the maps between the sessions.
+ *
+ * @return The root path or <code>null</code>.
+ */
+ private IPath getRoot() {
+ try {
+ File file = UIPlugin.getDefault().getStateLocation().toFile();
+ boolean exists = file.exists();
+ if (!exists) {
+ exists = file.mkdirs();
+ }
+ if (exists && file.canRead() && file.isDirectory()) {
+ return new Path(file.toString());
+ }
+ } catch (IllegalStateException e) {
+ /* ignored on purpose */
+ }
+
+ File file = new Path(System.getProperty("user.home")).append(".tcf").toFile(); //$NON-NLS-1$ //$NON-NLS-2$
+ if (file.canRead() && file.isDirectory()) {
+ return new Path(file.toString());
+ }
+
+ return null;
+ }
+
+ /**
+ * Initialize the category manager.
+ */
+ private void initialize() {
+ IPath root = getRoot();
+ if (root == null) {
+ return;
+ }
+
+ // Clear out the transient maps
+ _t_cat2id.clear();
+ _t_id2cat.clear();
+
+ cat2id.clear();
+ id2cat.clear();
+
+ try {
+ // Get the persistence service
+ IURIPersistenceService uRIPersistenceService = ServiceManager.getInstance().getService(IURIPersistenceService.class);
+ if (uRIPersistenceService == null) {
+ throw new IOException("Persistence service instance unavailable."); //$NON-NLS-1$
+ }
+ // Save the history to the persistence storage
+ cat2id = (Map<String,List<String>>)uRIPersistenceService.read(cat2id, root.append("cat2id.json").toFile().toURI()); //$NON-NLS-1$
+ } catch (IOException e) {
+ }
+
+ try {
+ // Get the persistence service
+ IURIPersistenceService uRIPersistenceService = ServiceManager.getInstance().getService(IURIPersistenceService.class);
+ if (uRIPersistenceService == null) {
+ throw new IOException("Persistence service instance unavailable."); //$NON-NLS-1$
+ }
+ // Save the history to the persistence storage
+ id2cat = (Map<String,List<String>>)uRIPersistenceService.read(id2cat, root.append("id2cat.json").toFile().toURI()); //$NON-NLS-1$
+ } catch (IOException e) {
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.views.categories.ICategoryManager#flush()
+ */
+ @Override
+ public void flush() {
+ IPath root = getRoot();
+ if (root == null) {
+ return;
+ }
+
+ try {
+ // Get the persistence service
+ IURIPersistenceService uRIPersistenceService = ServiceManager.getInstance().getService(IURIPersistenceService.class);
+ if (uRIPersistenceService == null) {
+ throw new IOException("Persistence service instance unavailable."); //$NON-NLS-1$
+ }
+ // Save the history to the persistence storage
+ uRIPersistenceService.write(cat2id, root.append("cat2id.json").toFile().toURI()); //$NON-NLS-1$
+ } catch (IOException e) {
+ }
+
+ try {
+ // Get the persistence service
+ IURIPersistenceService uRIPersistenceService = ServiceManager.getInstance().getService(IURIPersistenceService.class);
+ if (uRIPersistenceService == null) {
+ throw new IOException("Persistence service instance unavailable."); //$NON-NLS-1$
+ }
+ // Save the history to the persistence storage
+ uRIPersistenceService.write(id2cat, root.append("id2cat.json").toFile().toURI()); //$NON-NLS-1$
+ } catch (IOException e) {
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.views.categories.ICategoryManager#add(java.lang.String, java.lang.String)
+ */
+ @Override
+ public boolean add(String categoryId, String id) {
+ Assert.isNotNull(categoryId);
+ Assert.isNotNull(id);
+
+ boolean added = false;
+
+ List<String> ids = cat2id.get(categoryId);
+ if (ids == null) {
+ ids = new ArrayList<String>();
+ cat2id.put(categoryId, ids);
+ }
+ if (!ids.contains(id)) {
+ added |= ids.add(id);
+ }
+
+ List<String> cats = id2cat.get(id);
+ if (cats == null) {
+ cats = new ArrayList<String>();
+ id2cat.put(id, cats);
+ }
+ if (!cats.contains(categoryId)) {
+ added |= cats.add(categoryId);
+ }
+
+ if (added) {
+ flush();
+ EventManager.getInstance().fireEvent(
+ new ChangeEvent(CategoriesExtensionPointManager.getInstance().getCategory(categoryId, false), ChangeEvent.ID_ADDED, null, id));
+ }
+
+ return added;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.views.interfaces.categories.ICategoryManager#addTransient(java.lang.String, java.lang.String)
+ */
+ @Override
+ public boolean addTransient(String categoryId, String id) {
+ Assert.isNotNull(categoryId);
+ Assert.isNotNull(id);
+
+ boolean added = false;
+
+ List<String> ids = _t_cat2id.get(categoryId);
+ if (ids == null) {
+ ids = new ArrayList<String>();
+ _t_cat2id.put(categoryId, ids);
+ }
+ if (!ids.contains(id)) {
+ added |= ids.add(id);
+ }
+
+ List<String> cats = _t_id2cat.get(id);
+ if (cats == null) {
+ cats = new ArrayList<String>();
+ _t_id2cat.put(id, cats);
+ }
+ if (!cats.contains(categoryId)) {
+ added |= cats.add(categoryId);
+ }
+
+ if (added) {
+ EventManager.getInstance().fireEvent(
+ new ChangeEvent(CategoriesExtensionPointManager.getInstance().getCategory(categoryId, false), ChangeEvent.ID_ADDED, null, id));
+ }
+
+ return added;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.views.categories.ICategoryManager#remove(java.lang.String, java.lang.String)
+ */
+ @Override
+ public boolean remove(String categoryId, String id) {
+ Assert.isNotNull(categoryId);
+ Assert.isNotNull(id);
+
+ boolean removed = false;
+
+ List<String> ids = cat2id.get(categoryId);
+ if (ids != null) {
+ removed |= ids.remove(id);
+ if (ids.isEmpty()) {
+ cat2id.remove(categoryId);
+ }
+ }
+ ids = _t_cat2id.get(categoryId);
+ if (ids != null) {
+ removed |= ids.remove(id);
+ if (ids.isEmpty()) {
+ _t_cat2id.remove(categoryId);
+ }
+ }
+
+ List<String> cats = id2cat.get(id);
+ if (cats != null) {
+ removed |= cats.remove(categoryId);
+ if (cats.isEmpty()) {
+ id2cat.remove(id);
+ }
+ }
+ cats = _t_id2cat.get(id);
+ if (cats != null) {
+ removed |= cats.remove(categoryId);
+ if (cats.isEmpty()) {
+ _t_id2cat.remove(id);
+ }
+ }
+
+ if (removed) {
+ flush();
+ EventManager.getInstance().fireEvent(
+ new ChangeEvent(CategoriesExtensionPointManager.getInstance().getCategory(categoryId, false), ChangeEvent.ID_REMOVED, id, null));
+ }
+
+ return removed;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.views.categories.ICategoryManager#belongsTo(java.lang.String, java.lang.String)
+ */
+ @Override
+ public boolean belongsTo(String categoryId, String id) {
+ Assert.isNotNull(categoryId);
+ Assert.isNotNull(id);
+
+ boolean belongsTo = isLinked(categoryId, id);
+
+ List<String> ids = cat2id.get(categoryId);
+ if (!belongsTo) {
+ ids = _t_cat2id.get(categoryId);
+ if (ids != null && ids.contains(id)) {
+ belongsTo = true;
+ }
+ }
+
+ return belongsTo;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.views.interfaces.categories.ICategoryManager#isLinked(java.lang.String, java.lang.String)
+ */
+ @Override
+ public boolean isLinked(String categoryId, String id) {
+ Assert.isNotNull(categoryId);
+ Assert.isNotNull(id);
+
+ boolean belongsTo = false;
+
+ List<String> ids = cat2id.get(categoryId);
+ if (ids != null && ids.contains(id)) {
+ belongsTo = true;
+ }
+
+ return belongsTo;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.views.categories.ICategoryManager#getCategoryIds(java.lang.String)
+ */
+ @Override
+ public String[] getCategoryIds(String id) {
+ Assert.isNotNull(id);
+
+ List<String> allCategories = new ArrayList<String>();
+
+ List<String> cats = id2cat.get(id);
+ if (cats != null) {
+ allCategories.addAll(cats);
+ }
+
+ cats = _t_id2cat.get(id);
+ if (cats != null) {
+ for (String cat : cats) {
+ if (!allCategories.contains(cat)) {
+ allCategories.add(cat);
+ }
+ }
+ }
+
+ return allCategories.toArray(new String[allCategories.size()]);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.views.interfaces.categories.ICategoryManager#getIdsForCategory(java.lang.String)
+ */
+ @Override
+ public String[] getIdsForCategory(String categoryId) {
+ Assert.isNotNull(categoryId);
+
+ List<String> allIds = new ArrayList<String>();
+
+ List<String> cats = cat2id.get(categoryId);
+ if (cats != null) {
+ allIds.addAll(cats);
+ }
+
+ cats = _t_cat2id.get(categoryId);
+ if (cats != null) {
+ for (String cat : cats) {
+ if (!allIds.contains(cat)) {
+ allIds.add(cat);
+ }
+ }
+ }
+
+ return allIds.toArray(new String[allIds.size()]);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/categories/CategoryPropertyTester.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/categories/CategoryPropertyTester.java
index 58cdca414..d61218544 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/categories/CategoryPropertyTester.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/categories/CategoryPropertyTester.java
@@ -1,176 +1,176 @@
-/*******************************************************************************
- * 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.ui.views.internal.categories;
-
-import org.eclipse.core.expressions.EvaluationContext;
-import org.eclipse.core.expressions.EvaluationResult;
-import org.eclipse.core.expressions.ICountable;
-import org.eclipse.core.expressions.IEvaluationContext;
-import org.eclipse.core.expressions.PropertyTester;
-import org.eclipse.core.internal.expressions.CountExpression;
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeSelection;
-import org.eclipse.jface.viewers.TreePath;
-import org.eclipse.tcf.te.ui.views.Managers;
-import org.eclipse.tcf.te.ui.views.ViewsUtil;
-import org.eclipse.tcf.te.ui.views.activator.UIPlugin;
-import org.eclipse.tcf.te.ui.views.extensions.CategoriesExtensionPointManager;
-import org.eclipse.tcf.te.ui.views.handler.CategoryAddToContributionItem;
-import org.eclipse.tcf.te.ui.views.interfaces.ICategory;
-import org.eclipse.tcf.te.ui.views.interfaces.IUIConstants;
-import org.eclipse.tcf.te.ui.views.interfaces.categories.ICategorizable;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.navigator.CommonNavigator;
-import org.eclipse.ui.navigator.INavigatorActivationService;
-import org.eclipse.ui.navigator.INavigatorContentService;
-
-/**
- * Category property tester.
- */
-@SuppressWarnings("restriction")
-public class CategoryPropertyTester extends PropertyTester {
-
- /* (non-Javadoc)
- * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
- */
- @Override
- public boolean test(final Object receiver, final String property, final Object[] args, final Object expectedValue) {
- if (receiver instanceof IStructuredSelection) {
- // Analyze the selection
- return testSelection((IStructuredSelection)receiver, property, args, expectedValue);
- }
-
- return internalTest(receiver, property, args, expectedValue);
- }
-
- /**
- * Test the specific selection properties.
- *
- * @param selection The selection. Must not be <code>null</code>.
- * @param property The property to test.
- * @param args The property arguments.
- * @param expectedValue The expected value.
- *
- * @return <code>True</code> if the property to test has the expected value, <code>false</code>
- * otherwise.
- */
- protected boolean testSelection(IStructuredSelection selection, String property, Object[] args, Object expectedValue) {
- Assert.isNotNull(selection);
-
- if ("parentCategoryId".equals(property) && !selection.isEmpty()) { //$NON-NLS-1$
- // Only single element selection is supported
- Object element = selection.getFirstElement();
-
- TreePath[] pathes = selection instanceof ITreeSelection ? ((ITreeSelection)selection).getPathsFor(element) : null;
- if (pathes != null) {
- for (TreePath path : pathes) {
- // Find the category within the tree path
- TreePath parentPath = path.getParentPath();
- while (parentPath != null) {
- Object lastSegment = parentPath.getLastSegment();
- if (lastSegment instanceof ICategory
- && ((ICategory)lastSegment).getId().equals(expectedValue)) {
- return true;
- }
- parentPath = parentPath.getParentPath();
- }
- }
- }
- }
-
- if ("validAddToCategoriesCount".equals(property)) { //$NON-NLS-1$
- // Determine the number of valid "Add To" Categories
- AbstractCategoryContributionItem item = new CategoryAddToContributionItem();
- ICategory[] categories = item.getCategories(selection, true);
- final int count = categories.length;
-
- // Re-use the count expression to allow the same value syntax
- String value = expectedValue instanceof String ? (String)expectedValue : expectedValue != null ? expectedValue.toString() : null;
- if (value != null) {
- CountExpression expression = new CountExpression(value);
- IEvaluationContext context = new EvaluationContext(null, new ICountable() {
- @Override
- public int count() {
- return count;
- }
- });
-
- EvaluationResult result = EvaluationResult.FALSE;
- try {
- result = expression.evaluate(context);
- } catch (CoreException e) {
- if (Platform.inDebugMode()) e.printStackTrace();
- }
-
- return result.equals(EvaluationResult.TRUE);
- }
- }
-
- return false;
- }
-
- /**
- * Internal helper to {@link #test(Object, String, Object[], Object)}.
- */
- protected boolean internalTest(Object receiver, String property, Object[] args, Object expectedValue) {
- ICategorizable categorizable = receiver instanceof IAdaptable ? (ICategorizable)((IAdaptable)receiver).getAdapter(ICategorizable.class) : null;
- if (categorizable == null) categorizable = (ICategorizable)Platform.getAdapterManager().getAdapter(receiver, ICategorizable.class);
-
- if ("belongsTo".equals(property) && categorizable != null) { //$NON-NLS-1$
- String id = categorizable.getId();
- if (id != null && expectedValue instanceof String) {
- return Managers.getCategoryManager().belongsTo((String)expectedValue, id);
- }
- }
-
- if ("isCategoryID".equals(property) && receiver instanceof ICategory) { //$NON-NLS-1$
- String id = ((ICategory)receiver).getId();
- return id.equals(expectedValue);
- }
-
- if ("isCategoryEnabled".equals(property) && expectedValue instanceof Boolean) { //$NON-NLS-1$
- String categoryId = args != null && args.length == 1 && args[0] instanceof String ? (String)args[0] : null;
- ICategory category = categoryId != null ? CategoriesExtensionPointManager.getInstance().getCategory(categoryId, false) : null;
-
- return category != null && (category.isEnabled() == ((Boolean)expectedValue).booleanValue());
- }
-
- if ("isHiddenByPreferences".equals(property) && receiver instanceof ICategory && expectedValue instanceof Boolean) { //$NON-NLS-1$
- String prefKey = ((ICategory)receiver).getId() + ".hide"; //$NON-NLS-1$
- boolean isHidden = UIPlugin.getScopedPreferences().getBoolean(prefKey) || Boolean.getBoolean(prefKey);
- return ((Boolean)expectedValue).booleanValue() == isHidden;
- }
-
- if ("isVisibleNavigatorContent".equals(property) && receiver instanceof ICategory && expectedValue instanceof Boolean) { //$NON-NLS-1$
- boolean isVisible = false;
-
- String navContentID = args != null && args.length == 1 && args[0] instanceof String ? (String)args[0] : null;
- IWorkbenchPart part = ViewsUtil.getPart(IUIConstants.ID_EXPLORER);
-
- if (part instanceof CommonNavigator) {
- CommonNavigator navigator = (CommonNavigator)part;
- INavigatorContentService service = navigator.getNavigatorContentService();
- INavigatorActivationService activationService = service != null ? service.getActivationService() : null;
- isVisible = activationService != null && navContentID != null && activationService.isNavigatorExtensionActive(navContentID);
- }
- else {
- return true;
- }
-
- return ((Boolean)expectedValue).booleanValue() == isVisible;
- }
-
- return false;
- }
-}
+/*******************************************************************************
+ * 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.ui.views.internal.categories;
+
+import org.eclipse.core.expressions.EvaluationContext;
+import org.eclipse.core.expressions.EvaluationResult;
+import org.eclipse.core.expressions.ICountable;
+import org.eclipse.core.expressions.IEvaluationContext;
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.core.internal.expressions.CountExpression;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeSelection;
+import org.eclipse.jface.viewers.TreePath;
+import org.eclipse.tcf.te.ui.views.Managers;
+import org.eclipse.tcf.te.ui.views.ViewsUtil;
+import org.eclipse.tcf.te.ui.views.activator.UIPlugin;
+import org.eclipse.tcf.te.ui.views.extensions.CategoriesExtensionPointManager;
+import org.eclipse.tcf.te.ui.views.handler.CategoryAddToContributionItem;
+import org.eclipse.tcf.te.ui.views.interfaces.ICategory;
+import org.eclipse.tcf.te.ui.views.interfaces.IUIConstants;
+import org.eclipse.tcf.te.ui.views.interfaces.categories.ICategorizable;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.navigator.CommonNavigator;
+import org.eclipse.ui.navigator.INavigatorActivationService;
+import org.eclipse.ui.navigator.INavigatorContentService;
+
+/**
+ * Category property tester.
+ */
+@SuppressWarnings("restriction")
+public class CategoryPropertyTester extends PropertyTester {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
+ */
+ @Override
+ public boolean test(final Object receiver, final String property, final Object[] args, final Object expectedValue) {
+ if (receiver instanceof IStructuredSelection) {
+ // Analyze the selection
+ return testSelection((IStructuredSelection)receiver, property, args, expectedValue);
+ }
+
+ return internalTest(receiver, property, args, expectedValue);
+ }
+
+ /**
+ * Test the specific selection properties.
+ *
+ * @param selection The selection. Must not be <code>null</code>.
+ * @param property The property to test.
+ * @param args The property arguments.
+ * @param expectedValue The expected value.
+ *
+ * @return <code>True</code> if the property to test has the expected value, <code>false</code>
+ * otherwise.
+ */
+ protected boolean testSelection(IStructuredSelection selection, String property, Object[] args, Object expectedValue) {
+ Assert.isNotNull(selection);
+
+ if ("parentCategoryId".equals(property) && !selection.isEmpty()) { //$NON-NLS-1$
+ // Only single element selection is supported
+ Object element = selection.getFirstElement();
+
+ TreePath[] pathes = selection instanceof ITreeSelection ? ((ITreeSelection)selection).getPathsFor(element) : null;
+ if (pathes != null) {
+ for (TreePath path : pathes) {
+ // Find the category within the tree path
+ TreePath parentPath = path.getParentPath();
+ while (parentPath != null) {
+ Object lastSegment = parentPath.getLastSegment();
+ if (lastSegment instanceof ICategory
+ && ((ICategory)lastSegment).getId().equals(expectedValue)) {
+ return true;
+ }
+ parentPath = parentPath.getParentPath();
+ }
+ }
+ }
+ }
+
+ if ("validAddToCategoriesCount".equals(property)) { //$NON-NLS-1$
+ // Determine the number of valid "Add To" Categories
+ AbstractCategoryContributionItem item = new CategoryAddToContributionItem();
+ ICategory[] categories = item.getCategories(selection, true);
+ final int count = categories.length;
+
+ // Re-use the count expression to allow the same value syntax
+ String value = expectedValue instanceof String ? (String)expectedValue : expectedValue != null ? expectedValue.toString() : null;
+ if (value != null) {
+ CountExpression expression = new CountExpression(value);
+ IEvaluationContext context = new EvaluationContext(null, new ICountable() {
+ @Override
+ public int count() {
+ return count;
+ }
+ });
+
+ EvaluationResult result = EvaluationResult.FALSE;
+ try {
+ result = expression.evaluate(context);
+ } catch (CoreException e) {
+ if (Platform.inDebugMode()) e.printStackTrace();
+ }
+
+ return result.equals(EvaluationResult.TRUE);
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Internal helper to {@link #test(Object, String, Object[], Object)}.
+ */
+ protected boolean internalTest(Object receiver, String property, Object[] args, Object expectedValue) {
+ ICategorizable categorizable = receiver instanceof IAdaptable ? (ICategorizable)((IAdaptable)receiver).getAdapter(ICategorizable.class) : null;
+ if (categorizable == null) categorizable = (ICategorizable)Platform.getAdapterManager().getAdapter(receiver, ICategorizable.class);
+
+ if ("belongsTo".equals(property) && categorizable != null) { //$NON-NLS-1$
+ String id = categorizable.getId();
+ if (id != null && expectedValue instanceof String) {
+ return Managers.getCategoryManager().belongsTo((String)expectedValue, id);
+ }
+ }
+
+ if ("isCategoryID".equals(property) && receiver instanceof ICategory) { //$NON-NLS-1$
+ String id = ((ICategory)receiver).getId();
+ return id.equals(expectedValue);
+ }
+
+ if ("isCategoryEnabled".equals(property) && expectedValue instanceof Boolean) { //$NON-NLS-1$
+ String categoryId = args != null && args.length == 1 && args[0] instanceof String ? (String)args[0] : null;
+ ICategory category = categoryId != null ? CategoriesExtensionPointManager.getInstance().getCategory(categoryId, false) : null;
+
+ return category != null && (category.isEnabled() == ((Boolean)expectedValue).booleanValue());
+ }
+
+ if ("isHiddenByPreferences".equals(property) && receiver instanceof ICategory && expectedValue instanceof Boolean) { //$NON-NLS-1$
+ String prefKey = ((ICategory)receiver).getId() + ".hide"; //$NON-NLS-1$
+ boolean isHidden = UIPlugin.getScopedPreferences().getBoolean(prefKey) || Boolean.getBoolean(prefKey);
+ return ((Boolean)expectedValue).booleanValue() == isHidden;
+ }
+
+ if ("isVisibleNavigatorContent".equals(property) && receiver instanceof ICategory && expectedValue instanceof Boolean) { //$NON-NLS-1$
+ boolean isVisible = false;
+
+ String navContentID = args != null && args.length == 1 && args[0] instanceof String ? (String)args[0] : null;
+ IWorkbenchPart part = ViewsUtil.getPart(IUIConstants.ID_EXPLORER);
+
+ if (part instanceof CommonNavigator) {
+ CommonNavigator navigator = (CommonNavigator)part;
+ INavigatorContentService service = navigator.getNavigatorContentService();
+ INavigatorActivationService activationService = service != null ? service.getActivationService() : null;
+ isVisible = activationService != null && navContentID != null && activationService.isNavigatorExtensionActive(navContentID);
+ }
+ else {
+ return true;
+ }
+
+ return ((Boolean)expectedValue).booleanValue() == isVisible;
+ }
+
+ return false;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/preferences/IPreferenceKeys.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/preferences/IPreferenceKeys.java
index 591e40b9e..0fc6705bb 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/preferences/IPreferenceKeys.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/preferences/IPreferenceKeys.java
@@ -1,50 +1,50 @@
-/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.ui.views.internal.preferences;
-
-/**
- * The constants for the preferences used in the main view.
- */
-public interface IPreferenceKeys {
- /**
- * Common prefix for all preference keys
- */
- public final String PREFIX = "te.ui."; //$NON-NLS-1$
-
- /**
- * The default size of MRU list.
- */
- public static final int DEFAULT_MAX_MRU = 3;
-
- /**
- * Preference key to access MRU filter list.
- */
- public static final String PREF_FILTER_MRU_LIST = PREFIX + "PrefFilterMRUs"; //$NON-NLS-1$
-
- /**
- * Preference key to access max MRU filter size.
- */
- public static final String PREF_MAX_FILTER_MRU = PREFIX + "PrefFilterMRUs.max"; //$NON-NLS-1$
-
- /**
- * Preference key to access MRU content list.
- */
- public static final String PREF_CONTENT_MRU_LIST = PREFIX + "PrefContentMRUs"; //$NON-NLS-1$
-
- /**
- * Preference key to access max MRU content size.
- */
- public static final String PREF_MAX_CONTENT_MRU = PREFIX + "PrefContentMRUs.max"; //$NON-NLS-1$
-
- /**
- * Preference key to access the flag to hide category content extension.
- */
- public static final String PREF_HIDE_CATEGORY_EXTENSION = "org.eclipse.tcf.te.ui.views.navigator.content.hide"; //$NON-NLS-1$
-}
+/*******************************************************************************
+ * 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.ui.views.internal.preferences;
+
+/**
+ * The constants for the preferences used in the main view.
+ */
+public interface IPreferenceKeys {
+ /**
+ * Common prefix for all preference keys
+ */
+ public final String PREFIX = "te.ui."; //$NON-NLS-1$
+
+ /**
+ * The default size of MRU list.
+ */
+ public static final int DEFAULT_MAX_MRU = 3;
+
+ /**
+ * Preference key to access MRU filter list.
+ */
+ public static final String PREF_FILTER_MRU_LIST = PREFIX + "PrefFilterMRUs"; //$NON-NLS-1$
+
+ /**
+ * Preference key to access max MRU filter size.
+ */
+ public static final String PREF_MAX_FILTER_MRU = PREFIX + "PrefFilterMRUs.max"; //$NON-NLS-1$
+
+ /**
+ * Preference key to access MRU content list.
+ */
+ public static final String PREF_CONTENT_MRU_LIST = PREFIX + "PrefContentMRUs"; //$NON-NLS-1$
+
+ /**
+ * Preference key to access max MRU content size.
+ */
+ public static final String PREF_MAX_CONTENT_MRU = PREFIX + "PrefContentMRUs.max"; //$NON-NLS-1$
+
+ /**
+ * Preference key to access the flag to hide category content extension.
+ */
+ public static final String PREF_HIDE_CATEGORY_EXTENSION = "org.eclipse.tcf.te.ui.views.navigator.content.hide"; //$NON-NLS-1$
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/preferences/PreferencesInitializer.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/preferences/PreferencesInitializer.java
index 367ad1001..3bbbc79c9 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/preferences/PreferencesInitializer.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/preferences/PreferencesInitializer.java
@@ -1,46 +1,46 @@
-/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.ui.views.internal.preferences;
-
-import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
-import org.eclipse.tcf.te.runtime.preferences.ScopedEclipsePreferences;
-import org.eclipse.tcf.te.ui.views.activator.UIPlugin;
-
-
-/**
- * The bundle's preference initializer implementation.
- */
-public class PreferencesInitializer extends AbstractPreferenceInitializer {
- /**
- * Constructor.
- */
- public PreferencesInitializer() {
- super();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
- */
- @Override
- public void initializeDefaultPreferences() {
- ScopedEclipsePreferences store = UIPlugin.getScopedPreferences();
-
- // Maximum MRU list size "Filter": default IPreferenceKeys.DEFAULT_MAX_MRU
- store.putDefaultInt(IPreferenceKeys.PREF_MAX_FILTER_MRU, IPreferenceKeys.DEFAULT_MAX_MRU);
- // Maximum MRU list size "Content": default IPreferenceKeys.DEFAULT_MAX_MRU
- store.putDefaultInt(IPreferenceKeys.PREF_MAX_CONTENT_MRU, IPreferenceKeys.DEFAULT_MAX_MRU);
- // "Filter" MRU list: default empty
- store.putDefaultString(IPreferenceKeys.PREF_FILTER_MRU_LIST, ""); //$NON-NLS-1$
- // "Content" MRU list: default empty
- store.putDefaultString(IPreferenceKeys.PREF_CONTENT_MRU_LIST, ""); //$NON-NLS-1$
- // [Hidden] Hide categories navigator content extension: default on
- store.putDefaultBoolean(IPreferenceKeys.PREF_HIDE_CATEGORY_EXTENSION, true);
- }
-}
+/*******************************************************************************
+ * 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.ui.views.internal.preferences;
+
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.tcf.te.runtime.preferences.ScopedEclipsePreferences;
+import org.eclipse.tcf.te.ui.views.activator.UIPlugin;
+
+
+/**
+ * The bundle's preference initializer implementation.
+ */
+public class PreferencesInitializer extends AbstractPreferenceInitializer {
+ /**
+ * Constructor.
+ */
+ public PreferencesInitializer() {
+ super();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
+ */
+ @Override
+ public void initializeDefaultPreferences() {
+ ScopedEclipsePreferences store = UIPlugin.getScopedPreferences();
+
+ // Maximum MRU list size "Filter": default IPreferenceKeys.DEFAULT_MAX_MRU
+ store.putDefaultInt(IPreferenceKeys.PREF_MAX_FILTER_MRU, IPreferenceKeys.DEFAULT_MAX_MRU);
+ // Maximum MRU list size "Content": default IPreferenceKeys.DEFAULT_MAX_MRU
+ store.putDefaultInt(IPreferenceKeys.PREF_MAX_CONTENT_MRU, IPreferenceKeys.DEFAULT_MAX_MRU);
+ // "Filter" MRU list: default empty
+ store.putDefaultString(IPreferenceKeys.PREF_FILTER_MRU_LIST, ""); //$NON-NLS-1$
+ // "Content" MRU list: default empty
+ store.putDefaultString(IPreferenceKeys.PREF_CONTENT_MRU_LIST, ""); //$NON-NLS-1$
+ // [Hidden] Hide categories navigator content extension: default on
+ store.putDefaultBoolean(IPreferenceKeys.PREF_HIDE_CATEGORY_EXTENSION, true);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/quickfilter/EditorQuickFilterTester.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/quickfilter/EditorQuickFilterTester.java
index d025e0cc6..2fde1982b 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/quickfilter/EditorQuickFilterTester.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/quickfilter/EditorQuickFilterTester.java
@@ -1,64 +1,64 @@
-/*******************************************************************************
- * 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.ui.views.internal.quickfilter;
-
-import org.eclipse.core.expressions.PropertyTester;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.tcf.te.core.interfaces.IFilterable;
-import org.eclipse.tcf.te.ui.views.editor.Editor;
-import org.eclipse.ui.forms.editor.IFormPage;
-
-/**
- * The tester to test if the current editor page is filterable.
- *
- */
-public class EditorQuickFilterTester extends PropertyTester {
-
- public EditorQuickFilterTester() {
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
- */
- @Override
- public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
- if (receiver instanceof Editor && "isEditorFilterable".equals(property)) { //$NON-NLS-1$
- Editor editor = (Editor) receiver;
- IFormPage page = editor.getActivePageInstance();
- if (page != null) {
- TreeViewer viewer = (TreeViewer) page.getAdapter(TreeViewer.class);
- if (viewer != null) {
- Object input = viewer.getInput();
- return adaptFilterable(input) != null;
- }
- }
- }
- return false;
- }
-
- private IFilterable adaptFilterable(Object element) {
- IFilterable decorator = null;
- if (element instanceof IFilterable) {
- decorator = (IFilterable) element;
- }
- if (decorator == null && element instanceof IAdaptable) {
- decorator = (IFilterable) ((IAdaptable) element).getAdapter(IFilterable.class);
- }
- if (decorator == null && element != null) {
- decorator = (IFilterable) Platform.getAdapterManager()
- .getAdapter(element, IFilterable.class);
- }
- return decorator;
- }
-
-}
+/*******************************************************************************
+ * 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.ui.views.internal.quickfilter;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.tcf.te.core.interfaces.IFilterable;
+import org.eclipse.tcf.te.ui.views.editor.Editor;
+import org.eclipse.ui.forms.editor.IFormPage;
+
+/**
+ * The tester to test if the current editor page is filterable.
+ *
+ */
+public class EditorQuickFilterTester extends PropertyTester {
+
+ public EditorQuickFilterTester() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
+ */
+ @Override
+ public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
+ if (receiver instanceof Editor && "isEditorFilterable".equals(property)) { //$NON-NLS-1$
+ Editor editor = (Editor) receiver;
+ IFormPage page = editor.getActivePageInstance();
+ if (page != null) {
+ TreeViewer viewer = (TreeViewer) page.getAdapter(TreeViewer.class);
+ if (viewer != null) {
+ Object input = viewer.getInput();
+ return adaptFilterable(input) != null;
+ }
+ }
+ }
+ return false;
+ }
+
+ private IFilterable adaptFilterable(Object element) {
+ IFilterable decorator = null;
+ if (element instanceof IFilterable) {
+ decorator = (IFilterable) element;
+ }
+ if (decorator == null && element instanceof IAdaptable) {
+ decorator = (IFilterable) ((IAdaptable) element).getAdapter(IFilterable.class);
+ }
+ if (decorator == null && element != null) {
+ decorator = (IFilterable) Platform.getAdapterManager()
+ .getAdapter(element, IFilterable.class);
+ }
+ return decorator;
+ }
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/services/MenuService.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/services/MenuService.java
index b0978eab8..09a13efda 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/services/MenuService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/services/MenuService.java
@@ -1,39 +1,39 @@
-/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.ui.views.internal.services;
-
-import org.eclipse.tcf.te.runtime.services.AbstractService;
-import org.eclipse.tcf.te.runtime.services.interfaces.IMenuService;
-import org.eclipse.tcf.te.ui.views.interfaces.ICategory;
-
-/**
- * Menu service implementation.
- */
-public class MenuService extends AbstractService implements IMenuService {
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.services.interfaces.IMenuService#isVisible(java.lang.Object, java.lang.String)
- */
- @Override
- public boolean isVisible(Object context, String contributionID) {
-
- if (context instanceof ICategory) {
- if (contributionID.endsWith("menu.showIn")) { //$NON-NLS-1$
- return false;
- }
- if (contributionID.endsWith("file.import") || contributionID.endsWith("file.export")) { //$NON-NLS-1$ //$NON-NLS-2$
- return false;
- }
- }
-
- return true;
- }
-
-}
+/*******************************************************************************
+ * 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.ui.views.internal.services;
+
+import org.eclipse.tcf.te.runtime.services.AbstractService;
+import org.eclipse.tcf.te.runtime.services.interfaces.IMenuService;
+import org.eclipse.tcf.te.ui.views.interfaces.ICategory;
+
+/**
+ * Menu service implementation.
+ */
+public class MenuService extends AbstractService implements IMenuService {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.services.interfaces.IMenuService#isVisible(java.lang.Object, java.lang.String)
+ */
+ @Override
+ public boolean isVisible(Object context, String contributionID) {
+
+ if (context instanceof ICategory) {
+ if (contributionID.endsWith("menu.showIn")) { //$NON-NLS-1$
+ return false;
+ }
+ if (contributionID.endsWith("file.import") || contributionID.endsWith("file.export")) { //$NON-NLS-1$ //$NON-NLS-2$
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/listeners/WorkbenchWindowListener.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/listeners/WorkbenchWindowListener.java
index 95d0d1a2d..a89aad722 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/listeners/WorkbenchWindowListener.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/listeners/WorkbenchWindowListener.java
@@ -1,36 +1,36 @@
-/*******************************************************************************
- * 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.ui.views.listeners;
-
-import org.eclipse.ui.IPartListener2;
-import org.eclipse.ui.IPerspectiveListener;
-
-/**
- * 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();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.views.listeners.AbstractWindowListener#createPerspectiveListener()
- */
- @Override
- protected IPerspectiveListener createPerspectiveListener() {
- return new WorkbenchPerspectiveListener();
- }
-}
+/*******************************************************************************
+ * 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.ui.views.listeners;
+
+import org.eclipse.ui.IPartListener2;
+import org.eclipse.ui.IPerspectiveListener;
+
+/**
+ * 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();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.views.listeners.AbstractWindowListener#createPerspectiveListener()
+ */
+ @Override
+ protected IPerspectiveListener createPerspectiveListener() {
+ return new WorkbenchPerspectiveListener();
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/navigator/LabelProviderDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/navigator/LabelProviderDelegate.java
index a6fd279a2..b1a19922c 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/navigator/LabelProviderDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/navigator/LabelProviderDelegate.java
@@ -1,50 +1,50 @@
-/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.ui.views.navigator;
-
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.tcf.te.ui.views.interfaces.ICategory;
-import org.eclipse.tcf.te.ui.views.navigator.nodes.NewWizardNode;
-
-/**
- * Category label provider delegate implementation.
- */
-public class LabelProviderDelegate extends LabelProvider {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
- */
- @Override
- public String getText(Object element) {
- if (element instanceof ICategory) {
- return ((ICategory)element).getLabel();
- }
- if (element instanceof NewWizardNode) {
- return ((NewWizardNode)element).getLabel();
- }
-
- return super.getText(element);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
- */
- @Override
- public Image getImage(Object element) {
- if (element instanceof ICategory) {
- return ((ICategory)element).getImage();
- }
- if (element instanceof NewWizardNode) {
- return ((NewWizardNode)element).getImage();
- }
- return super.getImage(element);
- }
-}
+/*******************************************************************************
+ * 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.ui.views.navigator;
+
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.tcf.te.ui.views.interfaces.ICategory;
+import org.eclipse.tcf.te.ui.views.navigator.nodes.NewWizardNode;
+
+/**
+ * Category label provider delegate implementation.
+ */
+public class LabelProviderDelegate extends LabelProvider {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
+ */
+ @Override
+ public String getText(Object element) {
+ if (element instanceof ICategory) {
+ return ((ICategory)element).getLabel();
+ }
+ if (element instanceof NewWizardNode) {
+ return ((NewWizardNode)element).getLabel();
+ }
+
+ return super.getText(element);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
+ */
+ @Override
+ public Image getImage(Object element) {
+ if (element instanceof ICategory) {
+ return ((ICategory)element).getImage();
+ }
+ if (element instanceof NewWizardNode) {
+ return ((NewWizardNode)element).getImage();
+ }
+ return super.getImage(element);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/navigator/ViewerContentProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/navigator/ViewerContentProvider.java
index 9d4eeaad9..cc013650b 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/navigator/ViewerContentProvider.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/navigator/ViewerContentProvider.java
@@ -1,126 +1,126 @@
-/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.ui.views.navigator;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.tcf.te.ui.views.extensions.CategoriesExtensionPointManager;
-import org.eclipse.tcf.te.ui.views.interfaces.ICategory;
-import org.eclipse.tcf.te.ui.views.interfaces.IRoot;
-import org.eclipse.tcf.te.ui.views.internal.ViewRoot;
-import org.eclipse.tcf.te.ui.views.navigator.nodes.NewWizardNode;
-import org.eclipse.ui.IMemento;
-import org.eclipse.ui.navigator.ICommonContentExtensionSite;
-import org.eclipse.ui.navigator.ICommonContentProvider;
-
-/**
- * Category content provider delegate implementation.
- */
-public class ViewerContentProvider implements ICommonContentProvider {
- private final static Object[] NO_ELEMENTS = new Object[0];
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
- */
- @Override
- public Object[] getChildren(Object parentElement) {
- Object[] children = NO_ELEMENTS;
-
- if (parentElement == null || parentElement instanceof IRoot) {
- // Get all contributed categories if there are any
- ICategory[] categories = CategoriesExtensionPointManager.getInstance().getCategories(false);
- // Filter out possible hidden categories
- List<ICategory> visibleCategories = new ArrayList<ICategory>();
- for (ICategory category : categories) {
- // If the category is not enabled by expression --> not shown
- if (!category.isEnabled()) continue;
- // Add category to the list of visible categories
- visibleCategories.add(category);
- }
-
- children = visibleCategories.toArray(new ICategory[visibleCategories.size()]);
- }
- if (parentElement instanceof ICategory) {
- children = ((ICategory)parentElement).getChildren();
- }
-
- return children;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
- */
- @Override
- public Object getParent(Object element) {
- if (element instanceof ICategory) {
- return ViewRoot.getInstance();
- }
- if (element instanceof NewWizardNode) {
- return ((NewWizardNode)element).getParent();
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
- */
- @Override
- public boolean hasChildren(Object element) {
- if (element instanceof ICategory) {
- return ((ICategory)element).getChildren() != null;
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getElements(java.lang.Object)
- */
- @Override
- public Object[] getElements(Object inputElement) {
- return getChildren(inputElement);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IContentProvider#dispose()
- */
- @Override
- public void dispose() {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
- */
- @Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.navigator.ICommonContentProvider#init(org.eclipse.ui.navigator.ICommonContentExtensionSite)
- */
- @Override
- public void init(ICommonContentExtensionSite aConfig) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.navigator.IMementoAware#restoreState(org.eclipse.ui.IMemento)
- */
- @Override
- public void restoreState(IMemento aMemento) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.navigator.IMementoAware#saveState(org.eclipse.ui.IMemento)
- */
- @Override
- public void saveState(IMemento aMemento) {
- }
-}
+/*******************************************************************************
+ * 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.ui.views.navigator;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.tcf.te.ui.views.extensions.CategoriesExtensionPointManager;
+import org.eclipse.tcf.te.ui.views.interfaces.ICategory;
+import org.eclipse.tcf.te.ui.views.interfaces.IRoot;
+import org.eclipse.tcf.te.ui.views.internal.ViewRoot;
+import org.eclipse.tcf.te.ui.views.navigator.nodes.NewWizardNode;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.navigator.ICommonContentExtensionSite;
+import org.eclipse.ui.navigator.ICommonContentProvider;
+
+/**
+ * Category content provider delegate implementation.
+ */
+public class ViewerContentProvider implements ICommonContentProvider {
+ private final static Object[] NO_ELEMENTS = new Object[0];
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
+ */
+ @Override
+ public Object[] getChildren(Object parentElement) {
+ Object[] children = NO_ELEMENTS;
+
+ if (parentElement == null || parentElement instanceof IRoot) {
+ // Get all contributed categories if there are any
+ ICategory[] categories = CategoriesExtensionPointManager.getInstance().getCategories(false);
+ // Filter out possible hidden categories
+ List<ICategory> visibleCategories = new ArrayList<ICategory>();
+ for (ICategory category : categories) {
+ // If the category is not enabled by expression --> not shown
+ if (!category.isEnabled()) continue;
+ // Add category to the list of visible categories
+ visibleCategories.add(category);
+ }
+
+ children = visibleCategories.toArray(new ICategory[visibleCategories.size()]);
+ }
+ if (parentElement instanceof ICategory) {
+ children = ((ICategory)parentElement).getChildren();
+ }
+
+ return children;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
+ */
+ @Override
+ public Object getParent(Object element) {
+ if (element instanceof ICategory) {
+ return ViewRoot.getInstance();
+ }
+ if (element instanceof NewWizardNode) {
+ return ((NewWizardNode)element).getParent();
+ }
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
+ */
+ @Override
+ public boolean hasChildren(Object element) {
+ if (element instanceof ICategory) {
+ return ((ICategory)element).getChildren() != null;
+ }
+ return false;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getElements(java.lang.Object)
+ */
+ @Override
+ public Object[] getElements(Object inputElement) {
+ return getChildren(inputElement);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ @Override
+ public void dispose() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
+ */
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.ICommonContentProvider#init(org.eclipse.ui.navigator.ICommonContentExtensionSite)
+ */
+ @Override
+ public void init(ICommonContentExtensionSite aConfig) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.IMementoAware#restoreState(org.eclipse.ui.IMemento)
+ */
+ @Override
+ public void restoreState(IMemento aMemento) {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.navigator.IMementoAware#saveState(org.eclipse.ui.IMemento)
+ */
+ @Override
+ public void saveState(IMemento aMemento) {
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/navigator/nodes/NewWizardNode.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/navigator/nodes/NewWizardNode.java
index a7a4f0830..6fd578290 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/navigator/nodes/NewWizardNode.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/navigator/nodes/NewWizardNode.java
@@ -2,7 +2,7 @@
* NewWizardNode.java
* Created on 28.06.2012
*
- * Copyright (c) 2012 Wind River Systems, Inc.
+ * Copyright (c) 2012, 2013 Wind River Systems, Inc.
*
* The right to copy, distribute, modify, or otherwise make use
* of this software may be licensed only pursuant to the terms
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 5976a46ab..a6cb81811 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * 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
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 d5e0eae10..f39f0ecd9 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
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+# 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
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/perspective/PerspectiveFactory.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/perspective/PerspectiveFactory.java
index 1ef502056..8ac85753d 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/perspective/PerspectiveFactory.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/perspective/PerspectiveFactory.java
@@ -1,77 +1,77 @@
-/*******************************************************************************
- * 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.ui.views.perspective;
-
-import org.eclipse.core.runtime.PlatformObject;
-import org.eclipse.ui.IFolderLayout;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IPerspectiveFactory;
-import org.eclipse.ui.IPlaceholderFolderLayout;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * Perspective factory.
- */
-public class PerspectiveFactory extends PlatformObject implements IPerspectiveFactory {
- private final static String[] VIEWS_FOR_LEFT_AREA = new String[] {
- "org.eclipse.tcf.te.ui.views.View", //$NON-NLS-1$
- "org.eclipse.ui.navigator.ProjectExplorer" //$NON-NLS-1$
- };
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IPerspectiveFactory#createInitialLayout(org.eclipse.ui.IPageLayout)
- */
- @Override
- public void createInitialLayout(IPageLayout layout) {
- // editor is placed for free
- String editorArea = layout.getEditorArea();
-
- boolean leftAreaActive = false;
- for (String viewId : VIEWS_FOR_LEFT_AREA) {
- leftAreaActive |= PlatformUI.getWorkbench().getViewRegistry().find(viewId) != null;
- if (leftAreaActive) break;
- }
-
- if (leftAreaActive) {
- // place resource navigator to the left of editor area
- IFolderLayout left = layout.createFolder("left", IPageLayout.LEFT, 0.3f, editorArea); //$NON-NLS-1$
-
- for (String viewId : VIEWS_FOR_LEFT_AREA) {
- if (PlatformUI.getWorkbench().getViewRegistry().find(viewId) != null) {
- left.addView(viewId);
- }
- }
- } else {
- layout.createPlaceholderFolder("left", IPageLayout.LEFT, 0.3f, editorArea); //$NON-NLS-1$
- }
-
- // place debug view and script pad to the left bottom
- IPlaceholderFolderLayout leftbottom = layout.createPlaceholderFolder("leftbottom", IPageLayout.BOTTOM, (float)0.60, "left");//$NON-NLS-1$ //$NON-NLS-2$
- if (PlatformUI.getWorkbench().getViewRegistry().find("org.eclipse.debug.ui.DebugView") != null) //$NON-NLS-1$
- leftbottom.addPlaceholder("org.eclipse.debug.ui.DebugView"); //$NON-NLS-1$
- if (PlatformUI.getWorkbench().getViewRegistry().find("org.eclipse.tcf.te.tcf.ui.views.scriptpad") != null) //$NON-NLS-1$
- leftbottom.addPlaceholder("org.eclipse.tcf.te.tcf.ui.views.scriptpad"); //$NON-NLS-1$
-
- // place console below the main editor
- IFolderLayout lowerRight = layout.createFolder("lowerRight", IPageLayout.BOTTOM, 0.7f, editorArea); //$NON-NLS-1$
- if (PlatformUI.getWorkbench().getViewRegistry().find("org.eclipse.pde.runtime.LogView") != null) //$NON-NLS-1$
- lowerRight.addView("org.eclipse.pde.runtime.LogView"); //$NON-NLS-1$
- if (PlatformUI.getWorkbench().getViewRegistry().find("org.eclipse.ui.views.TaskList") != null) //$NON-NLS-1$
- lowerRight.addPlaceholder("org.eclipse.ui.views.TaskList"); //$NON-NLS-1$
- if (PlatformUI.getWorkbench().getViewRegistry().find("org.eclipse.ui.views.PropertySheet") != null) //$NON-NLS-1$
- lowerRight.addPlaceholder("org.eclipse.ui.views.PropertySheet"); //$NON-NLS-1$
-
- // place details view port to the right of editor area
- IPlaceholderFolderLayout right = layout.createPlaceholderFolder("right", IPageLayout.RIGHT, 0.75f, editorArea); //$NON-NLS-1$
- if (PlatformUI.getWorkbench().getViewRegistry().find(IPageLayout.ID_OUTLINE) != null)
- right.addPlaceholder(IPageLayout.ID_OUTLINE);
- }
-
-}
+/*******************************************************************************
+ * 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.ui.views.perspective;
+
+import org.eclipse.core.runtime.PlatformObject;
+import org.eclipse.ui.IFolderLayout;
+import org.eclipse.ui.IPageLayout;
+import org.eclipse.ui.IPerspectiveFactory;
+import org.eclipse.ui.IPlaceholderFolderLayout;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Perspective factory.
+ */
+public class PerspectiveFactory extends PlatformObject implements IPerspectiveFactory {
+ private final static String[] VIEWS_FOR_LEFT_AREA = new String[] {
+ "org.eclipse.tcf.te.ui.views.View", //$NON-NLS-1$
+ "org.eclipse.ui.navigator.ProjectExplorer" //$NON-NLS-1$
+ };
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IPerspectiveFactory#createInitialLayout(org.eclipse.ui.IPageLayout)
+ */
+ @Override
+ public void createInitialLayout(IPageLayout layout) {
+ // editor is placed for free
+ String editorArea = layout.getEditorArea();
+
+ boolean leftAreaActive = false;
+ for (String viewId : VIEWS_FOR_LEFT_AREA) {
+ leftAreaActive |= PlatformUI.getWorkbench().getViewRegistry().find(viewId) != null;
+ if (leftAreaActive) break;
+ }
+
+ if (leftAreaActive) {
+ // place resource navigator to the left of editor area
+ IFolderLayout left = layout.createFolder("left", IPageLayout.LEFT, 0.3f, editorArea); //$NON-NLS-1$
+
+ for (String viewId : VIEWS_FOR_LEFT_AREA) {
+ if (PlatformUI.getWorkbench().getViewRegistry().find(viewId) != null) {
+ left.addView(viewId);
+ }
+ }
+ } else {
+ layout.createPlaceholderFolder("left", IPageLayout.LEFT, 0.3f, editorArea); //$NON-NLS-1$
+ }
+
+ // place debug view and script pad to the left bottom
+ IPlaceholderFolderLayout leftbottom = layout.createPlaceholderFolder("leftbottom", IPageLayout.BOTTOM, (float)0.60, "left");//$NON-NLS-1$ //$NON-NLS-2$
+ if (PlatformUI.getWorkbench().getViewRegistry().find("org.eclipse.debug.ui.DebugView") != null) //$NON-NLS-1$
+ leftbottom.addPlaceholder("org.eclipse.debug.ui.DebugView"); //$NON-NLS-1$
+ if (PlatformUI.getWorkbench().getViewRegistry().find("org.eclipse.tcf.te.tcf.ui.views.scriptpad") != null) //$NON-NLS-1$
+ leftbottom.addPlaceholder("org.eclipse.tcf.te.tcf.ui.views.scriptpad"); //$NON-NLS-1$
+
+ // place console below the main editor
+ IFolderLayout lowerRight = layout.createFolder("lowerRight", IPageLayout.BOTTOM, 0.7f, editorArea); //$NON-NLS-1$
+ if (PlatformUI.getWorkbench().getViewRegistry().find("org.eclipse.pde.runtime.LogView") != null) //$NON-NLS-1$
+ lowerRight.addView("org.eclipse.pde.runtime.LogView"); //$NON-NLS-1$
+ if (PlatformUI.getWorkbench().getViewRegistry().find("org.eclipse.ui.views.TaskList") != null) //$NON-NLS-1$
+ lowerRight.addPlaceholder("org.eclipse.ui.views.TaskList"); //$NON-NLS-1$
+ if (PlatformUI.getWorkbench().getViewRegistry().find("org.eclipse.ui.views.PropertySheet") != null) //$NON-NLS-1$
+ lowerRight.addPlaceholder("org.eclipse.ui.views.PropertySheet"); //$NON-NLS-1$
+
+ // place details view port to the right of editor area
+ IPlaceholderFolderLayout right = layout.createPlaceholderFolder("right", IPageLayout.RIGHT, 0.75f, editorArea); //$NON-NLS-1$
+ if (PlatformUI.getWorkbench().getViewRegistry().find(IPageLayout.ID_OUTLINE) != null)
+ right.addPlaceholder(IPageLayout.ID_OUTLINE);
+ }
+
+}

Back to the top