Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Schwarz2013-07-04 05:25:48 -0400
committerTobias Schwarz2013-07-04 05:25:48 -0400
commit410ba38cbca8edea5a734ff86bca80239fd980b2 (patch)
treecce186c619dcf2c042fbb4263a48fe354165b322 /target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf
parent02629e28cb4af2650160ee0d3699ed880ba372a7 (diff)
downloadorg.eclipse.tcf-410ba38cbca8edea5a734ff86bca80239fd980b2.tar.gz
org.eclipse.tcf-410ba38cbca8edea5a734ff86bca80239fd980b2.tar.xz
org.eclipse.tcf-410ba38cbca8edea5a734ff86bca80239fd980b2.zip
Target Explorer: move context selector out of launch plugins
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/activator/UIPlugin.java22
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/ContextSelectorSectionControl.java69
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.java1
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.properties1
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/sections/ContextSelectorSection.java113
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/AbstractConfigWizard.java20
6 files changed, 209 insertions, 17 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/activator/UIPlugin.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/activator/UIPlugin.java
index 22df90325..4521dac4d 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/activator/UIPlugin.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/activator/UIPlugin.java
@@ -21,8 +21,8 @@ import org.eclipse.tcf.te.core.async.AsyncCallbackCollector;
import org.eclipse.tcf.te.runtime.concurrent.util.ExecutorsUtil;
import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
-import org.eclipse.tcf.te.runtime.properties.PropertiesContainer;
import org.eclipse.tcf.te.runtime.services.ServiceManager;
+import org.eclipse.tcf.te.runtime.services.interfaces.IService;
import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepperService;
import org.eclipse.tcf.te.runtime.stepper.job.StepperJob;
@@ -126,15 +126,21 @@ public class UIPlugin extends AbstractUIPlugin {
IPeerModel[] peers = model.getPeers();
// Loop them and check if disconnect is available
for (IPeerModel peerModel : peers) {
- IStepperService service = ServiceManager.getInstance().getService(peerModel, IStepperService.class);
- if (service != null) {
- String stepGroupId = service.getStepGroupId(peerModel, IStepperServiceOperations.DISCONNECT);
- IStepContext stepContext = service.getStepContext(peerModel, IStepperServiceOperations.DISCONNECT);
- String name = service.getStepGroupName(peerModel, IStepperServiceOperations.DISCONNECT);
- boolean isEnabled = service.isEnabled(peerModel, IStepperServiceOperations.DISCONNECT);
+ IService[] services = ServiceManager.getInstance().getServices(peerModel, IStepperService.class, false);
+ IStepperService stepperService = null;
+ for (IService service : services) {
+ if (service instanceof IStepperService && ((IStepperService)service).isHandledOperation(peerModel, IStepperServiceOperations.DISCONNECT)) {
+ stepperService = (IStepperService)service;
+ }
+ }
+ if (stepperService != null) {
+ String stepGroupId = stepperService.getStepGroupId(peerModel, IStepperServiceOperations.DISCONNECT);
+ IStepContext stepContext = stepperService.getStepContext(peerModel, IStepperServiceOperations.DISCONNECT);
+ String name = stepperService.getStepGroupName(peerModel, IStepperServiceOperations.DISCONNECT);
+ boolean isEnabled = stepperService.isEnabled(peerModel, IStepperServiceOperations.DISCONNECT);
+ IPropertiesContainer data = stepperService.getStepData(peerModel, IStepperServiceOperations.DISCONNECT);
if (isEnabled && stepGroupId != null && stepContext != null) {
- IPropertiesContainer data = new PropertiesContainer();
StepperJob job = new StepperJob(name != null ? name : "", //$NON-NLS-1$
stepContext,
data,
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/ContextSelectorSectionControl.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/ContextSelectorSectionControl.java
new file mode 100644
index 000000000..86ac93640
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/ContextSelectorSectionControl.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.tcf.te.tcf.ui.controls;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.dialogs.IDialogPage;
+import org.eclipse.jface.viewers.DecoratingLabelProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.tcf.te.tcf.locator.model.Model;
+import org.eclipse.tcf.te.tcf.ui.navigator.ContentProviderDelegate;
+import org.eclipse.tcf.te.tcf.ui.navigator.DelegatingLabelProvider;
+import org.eclipse.tcf.te.ui.views.controls.AbstractContextSelectorControl;
+import org.eclipse.tcf.te.ui.views.sections.AbstractContextSelectorSection;
+
+/**
+ * Locator model launch context selector control.
+ */
+public class ContextSelectorSectionControl extends AbstractContextSelectorControl {
+
+ private final AbstractContextSelectorSection section;
+
+ /**
+ * Constructor.
+ *
+ * @param section The parent context selector section. Must not be <code>null</code>.
+ * @param parentPage The parent target connection page this control is embedded in. Might be
+ * <code>null</code> if the control is not associated with a page.
+ */
+ public ContextSelectorSectionControl(AbstractContextSelectorSection section, IDialogPage parentPage) {
+ super(parentPage);
+ Assert.isNotNull(section);
+ this.section = section;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.ui.tabs.launchcontext.AbstractContextSelectorControl#onCheckStateChanged(java.lang.Object, boolean)
+ */
+ @Override
+ protected void onCheckStateChanged(Object element, boolean checked) {
+ super.onCheckStateChanged(element, checked);
+ section.getManagedForm().dirtyStateChanged();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.ui.tabs.launchcontext.AbstractContextSelectorControl#getInitialViewerInput()
+ */
+ @Override
+ protected Object getInitialViewerInput() {
+ return Model.getModel();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.ui.tabs.launchcontext.AbstractContextSelectorControl#doConfigureTreeContentAndLabelProvider(org.eclipse.jface.viewers.TreeViewer)
+ */
+ @Override
+ protected void doConfigureTreeContentAndLabelProvider(TreeViewer viewer) {
+ viewer.setContentProvider(new ContentProviderDelegate(true));
+ DelegatingLabelProvider labelProvider = new DelegatingLabelProvider();
+ viewer.setLabelProvider(new DecoratingLabelProvider(labelProvider, labelProvider));
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.java
index 08084ef8f..eb97503c4 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.java
@@ -239,5 +239,4 @@ public class Messages extends NLS {
public static String PeerImportWizardPage_overwrite_button;
public static String PeerImportWizardPage_overwriteDialog_message;
public static String PeerImportWizardPage_overwriteDialogToggle_message;
-
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.properties
index 794adabc6..e8594fb52 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.properties
@@ -198,4 +198,3 @@ PeerImportWizardPage_locationIsFile_error=Please enter or select a valid directo
PeerImportWizardPage_overwrite_button=Overwrite existing configuration(s) without warning
PeerImportWizardPage_overwriteDialog_message=The configuration ''{0}'' already exists. Do you want to overwrite it?
PeerImportWizardPage_overwriteDialogToggle_message=Remember my decision
-
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/sections/ContextSelectorSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/sections/ContextSelectorSection.java
new file mode 100644
index 000000000..0a34a497a
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/sections/ContextSelectorSection.java
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.ui.sections;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.tcf.protocol.IPeer;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
+import org.eclipse.tcf.te.runtime.persistence.PersistenceManager;
+import org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistenceDelegate;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
+import org.eclipse.tcf.te.tcf.ui.controls.ContextSelectorSectionControl;
+import org.eclipse.tcf.te.ui.views.controls.AbstractContextSelectorControl;
+import org.eclipse.tcf.te.ui.views.sections.AbstractContextSelectorSection;
+import org.eclipse.ui.forms.IManagedForm;
+
+/**
+ * Locator model context selector section implementation.
+ */
+public abstract class ContextSelectorSection extends AbstractContextSelectorSection {
+
+ /**
+ * Constructor.
+ * @param form The managed form.
+ * @param parent The parent composite.
+ */
+ public ContextSelectorSection(IManagedForm form, Composite parent) {
+ super(form, parent);
+ }
+
+ /**
+ * Constructor.
+ * @param form The managed form.
+ * @param parent The parent composite.
+ * @param style
+ */
+ public ContextSelectorSection(IManagedForm form, Composite parent, int style) {
+ super(form, parent, style);
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.launch.ui.tabs.launchcontext.AbstractContextSelectorSection#doCreateContextSelector()
+ */
+ @Override
+ protected AbstractContextSelectorControl doCreateContextSelector() {
+ return new ContextSelectorSectionControl(this, null);
+ }
+
+ public static final String encode(IModelNode[] contexts) {
+ try {
+ if (contexts != null && contexts.length > 0) {
+ IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(IPeer.class, String.class);
+ return (String)delegate.writeList(contexts, String.class);
+ }
+ }
+ catch (Exception e) {
+ }
+ return null;
+ }
+
+ public static final IModelNode[] decode (String encoded) {
+ try {
+ if (encoded != null && encoded.trim().length() > 0) {
+ IPersistenceDelegate delegate = PersistenceManager.getInstance().getDelegate(IPeer.class, String.class);
+ Object[] input = delegate.readList(IPeerModel.class, encoded);
+ List<IModelNode> peers = new ArrayList<IModelNode>();
+ for (Object object : input) {
+ if (object instanceof IModelNode) {
+ peers.add((IModelNode)object);
+ }
+ }
+ return peers.toArray(new IPeerModel[peers.size()]);
+ }
+ }
+ catch (Exception e) {
+ }
+ return new IModelNode[0];
+ }
+
+ protected abstract String getContextListDataKey();
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.data.IDataExchangeNode#setupData(org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer)
+ */
+ @Override
+ public void setupData(IPropertiesContainer data) {
+ String encoded = data.getStringProperty(getContextListDataKey());
+ IModelNode[] list = decode(encoded);
+ selector.setCheckedModelContexts(list);
+ if (selector != null && selector.getViewer() != null) {
+ selector.getViewer().refresh();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.data.IDataExchangeNode#extractData(org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer)
+ */
+ @Override
+ public void extractData(IPropertiesContainer data) {
+ data.setProperty(getContextListDataKey(), encode(selector.getCheckedModelContexts()));
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/AbstractConfigWizard.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/AbstractConfigWizard.java
index 63dca42bb..ea8a1c17a 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/AbstractConfigWizard.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/AbstractConfigWizard.java
@@ -12,8 +12,8 @@ package org.eclipse.tcf.te.tcf.ui.wizards;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
-import org.eclipse.tcf.te.runtime.properties.PropertiesContainer;
import org.eclipse.tcf.te.runtime.services.ServiceManager;
+import org.eclipse.tcf.te.runtime.services.interfaces.IService;
import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepperService;
import org.eclipse.tcf.te.runtime.stepper.job.StepperJob;
@@ -74,14 +74,20 @@ public abstract class AbstractConfigWizard extends NewTargetWizard {
if (!autoConnect) return;
// Connect the connection
- IStepperService service = ServiceManager.getInstance().getService(peerModel, IStepperService.class);
- if (service != null) {
- String stepGroupId = service.getStepGroupId(peerModel, IStepperServiceOperations.CONNECT);
- IStepContext stepContext = service.getStepContext(peerModel, IStepperServiceOperations.CONNECT);
- String name = service.getStepGroupName(peerModel, IStepperServiceOperations.CONNECT);
+ IService[] services = ServiceManager.getInstance().getServices(peerModel, IStepperService.class, false);
+ IStepperService stepperService = null;
+ for (IService service : services) {
+ if (service instanceof IStepperService && ((IStepperService)service).isHandledOperation(peerModel, IStepperServiceOperations.CONNECT)) {
+ stepperService = (IStepperService)service;
+ }
+ }
+ if (stepperService != null) {
+ String stepGroupId = stepperService.getStepGroupId(peerModel, IStepperServiceOperations.CONNECT);
+ IStepContext stepContext = stepperService.getStepContext(peerModel, IStepperServiceOperations.CONNECT);
+ String name = stepperService.getStepGroupName(peerModel, IStepperServiceOperations.CONNECT);
+ IPropertiesContainer data = stepperService.getStepData(peerModel, IStepperServiceOperations.CONNECT);
if (stepGroupId != null && stepContext != null) {
- IPropertiesContainer data = new PropertiesContainer();
StepperJob job = new StepperJob(name != null ? name : "", //$NON-NLS-1$
stepContext,
data,

Back to the top