Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'target_explorer/plugins')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/ISimulatorService.java179
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/steps/WaitStep.java164
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/AbstractSimulatorService.java41
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/META-INF/MANIFEST.MF1
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml14
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/SimulatorPayloadBoottimeControl.java91
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/SimulatorTypeSelectionControl.java268
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/AbstractConfigurationEditorPage.java189
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/PropertyTester.java14
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.java20
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.properties20
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/sections/TargetSelectorSection.java525
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/AbstractConfigWizard.java95
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/AbstractConfigWizardPage.java472
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.swt/META-INF/MANIFEST.MF2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/dialogs/AbstractSectionDialog.java295
16 files changed, 2214 insertions, 176 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/ISimulatorService.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/ISimulatorService.java
index 3ea29e4d3..98d185a4a 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/ISimulatorService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/ISimulatorService.java
@@ -1,83 +1,96 @@
-/*******************************************************************************
- * Copyright (c) 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.runtime.services.interfaces;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
-
-/**
- * Simulator service.
- * <p>
- * Allows to start/stop external simulators.
- * <p>
- * Simulator instance related UI parts, like configuration panels, are retrieved
- * by clients via the {@link IUIService}.
- */
-public interface ISimulatorService extends IService {
-
- /**
- * The constants for the simulator state.
- */
- public enum State { Stopped, Starting, Started, Stopping }
-
- /**
- * Starts the simulator.
- *
- * @param context The context. Must not be <code>null</code>.
- * @param config The encoded simulator settings or <code>null</code>.
- * @param callback The callback to invoke once the operation finishes. Must not be <code>null</code>.
- * @param monitor The progress monitor or <code>null</code>.
- */
- public void start(Object context, String config, ICallback callback, IProgressMonitor monitor);
-
- /**
- * Stops the simulator.
- *
- * @param context The context. Must not be <code>null</code>.
- * @param config The encoded simulator settings or <code>null</code>.
- * @param callback The callback to invoke once the operation finishes. Must not be <code>null</code>.
- * @param monitor The progress monitor or <code>null</code>.
- */
- public void stop(Object context, String config, ICallback callback, IProgressMonitor monitor);
-
- /**
- * Checks if the simulator is running.
- * <p>
- * The result of the check is return as {@link Boolean} object by the callback's {@link ICallback#getResult()} method.
- *
- * @param context The context. Must not be <code>null</code>.
- * @param config The encoded simulator settings or <code>null</code>.
- * @param callback The callback to invoke once the operation finishes. Must not be <code>null</code>.
- */
- public void isRunning(Object context, String config, ICallback callback);
-
- /**
- * Get the state of the simulator for the given context.
- * @param context The context. Must not be <code>null</code>.
- * @param config The encoded simulator settings or <code>null</code>.
- * @return The simulator state.
- */
- public State getState(Object context, String config);
-
- /**
- * Get the default config for the simulator.
- * The returned config does not need to be valid!
- * @return The default config or <code>null</code>.
- */
- public String getDefaultConfig();
-
- /**
- * Validate a simulator config.
- * @param context The context. Must not be <code>null</code>.
- * @param config The config to validate.
- * @return <code>true</code> if the config is valid.
- */
- public boolean isValidConfig(Object context, String config);
-}
+/*******************************************************************************
+ * Copyright (c) 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.runtime.services.interfaces;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
+
+/**
+ * Simulator service.
+ * <p>
+ * Allows to start/stop external simulators.
+ * <p>
+ * Simulator instance related UI parts, like configuration panels, are retrieved
+ * by clients via the {@link IUIService}.
+ */
+public interface ISimulatorService extends IService {
+
+ /**
+ * The constants for the simulator state.
+ */
+ public enum State { Stopped, Starting, Started, Stopping }
+
+ /**
+ * Starts the simulator.
+ *
+ * @param context The context. Must not be <code>null</code>.
+ * @param config The encoded simulator settings or <code>null</code>.
+ * @param callback The callback to invoke once the operation finishes. Must not be <code>null</code>.
+ * @param monitor The progress monitor or <code>null</code>.
+ */
+ public void start(Object context, String config, ICallback callback, IProgressMonitor monitor);
+
+ /**
+ * Stops the simulator.
+ *
+ * @param context The context. Must not be <code>null</code>.
+ * @param config The encoded simulator settings or <code>null</code>.
+ * @param callback The callback to invoke once the operation finishes. Must not be <code>null</code>.
+ * @param monitor The progress monitor or <code>null</code>.
+ */
+ public void stop(Object context, String config, ICallback callback, IProgressMonitor monitor);
+
+ /**
+ * Checks if the simulator is running.
+ * <p>
+ * The result of the check is return as {@link Boolean} object by the callback's {@link ICallback#getResult()} method.
+ *
+ * @param context The context. Must not be <code>null</code>.
+ * @param config The encoded simulator settings or <code>null</code>.
+ * @param callback The callback to invoke once the operation finishes. Must not be <code>null</code>.
+ */
+ public void isRunning(Object context, String config, ICallback callback);
+
+ /**
+ * Get the state of the simulator for the given context.
+ * @param context The context. Must not be <code>null</code>.
+ * @param config The encoded simulator settings or <code>null</code>.
+ * @return The simulator state.
+ */
+ public State getState(Object context, String config);
+
+ /**
+ * Get the default configuration for the simulator.
+ * <p>
+ * The returned configuration does not need to be valid!
+ *
+ * @return The default configuration or <code>null</code>.
+ */
+ public String getDefaultConfig();
+
+ /**
+ * Validate a simulator configuration
+ * .
+ * @param context The context. Must not be <code>null</code>.
+ * @param config The configuration to validate.
+ *
+ * @return <code>true</code> if the configuration is valid.
+ */
+ public boolean isValidConfig(Object context, String config);
+
+ /**
+ * Returns the default simulator payload (guest) boot time. If the
+ * method returns <code>-1</code>, the simulator start sequence will
+ * not wait for the simulator payload (guest) to boot up.
+ *
+ * @return The default simulator payload (guest) boot time in seconds or <code>-1</code>.
+ */
+ public int getDefaultPayloadBoottime();
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/steps/WaitStep.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/steps/WaitStep.java
index 94a321cd5..b438816a6 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/steps/WaitStep.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/steps/WaitStep.java
@@ -1,72 +1,92 @@
-/*******************************************************************************
- * Copyright (c) 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.runtime.stepper.steps;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.tcf.te.runtime.concurrent.util.ExecutorsUtil;
-import org.eclipse.tcf.te.runtime.interfaces.IConditionTester;
-import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
-import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
-
-/**
- * Step to wait some time.
- * The timeout is 1000ms per default.
- * A specific timeout can be set through parameter "timeout" for a step group reference.
- */
-public class WaitStep extends AbstractStep {
-
- /**
- * Constructor.
- */
- public WaitStep() {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStep#execute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback)
- */
- @Override
- public void execute(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, final IProgressMonitor monitor, ICallback callback) {
- long timeout = 1000;
- if (getParameters() != null) {
- String value = getParameters().get("timeout"); //$NON-NLS-1$
- if (value != null) {
- try {
- timeout = Long.parseLong(value);
- }
- catch (Exception e) {
- }
- }
- }
-
- ExecutorsUtil.waitAndExecute(timeout, new IConditionTester() {
- @Override
- public boolean isConditionFulfilled() {
- return monitor.isCanceled();
- }
-
- @Override
- public void cleanup() {
- }
- });
- callback.done(this, monitor.isCanceled() ? Status.CANCEL_STATUS : Status.OK_STATUS);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStep#validateExecute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void validateExecute(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException {
- }
-}
+/*******************************************************************************
+ * Copyright (c) 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.runtime.stepper.steps;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.tcf.te.runtime.concurrent.util.ExecutorsUtil;
+import org.eclipse.tcf.te.runtime.interfaces.IConditionTester;
+import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
+
+/**
+ * Step to wait some time.
+ * The timeout is 1000ms per default.
+ * A specific timeout can be set through parameter "timeout" for a step group reference.
+ */
+public class WaitStep extends AbstractStep {
+
+ /**
+ * Constructor.
+ */
+ public WaitStep() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStep#execute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback)
+ */
+ @Override
+ public void execute(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, final IProgressMonitor monitor, ICallback callback) {
+ int timeout = 1000;
+ if (getParameters() != null) {
+ String value = getParameters().get("timeout"); //$NON-NLS-1$
+ if (value != null) {
+ try {
+ timeout = Integer.parseInt(value);
+ }
+ catch (Exception e) {
+ }
+ }
+ }
+
+ ExecutorsUtil.waitAndExecute(timeout, new IConditionTester() {
+ @Override
+ public boolean isConditionFulfilled() {
+ return monitor.isCanceled();
+ }
+
+ @Override
+ public void cleanup() {
+ }
+ });
+ callback.done(this, monitor.isCanceled() ? Status.CANCEL_STATUS : Status.OK_STATUS);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.stepper.steps.AbstractStep#getCancelTimeout()
+ */
+ @Override
+ public int getCancelTimeout() {
+ int timeout = 1000;
+ if (getParameters() != null) {
+ String value = getParameters().get("timeout"); //$NON-NLS-1$
+ if (value != null) {
+ try {
+ timeout = Integer.parseInt(value);
+ }
+ catch (Exception e) {
+ }
+ }
+ }
+
+ return Math.max(super.getCancelTimeout(), timeout + 10000);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStep#validateExecute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void validateExecute(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException {
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/AbstractSimulatorService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/AbstractSimulatorService.java
index 5e0d5a20e..8f3ab6c64 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/AbstractSimulatorService.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/services/AbstractSimulatorService.java
@@ -1,20 +1,21 @@
-/**
- * AbstractSimulatorService.java
- * Created on Mar 22, 2013
- *
- * Copyright (c) 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
- * of an applicable Wind River license agreement.
- */
-package org.eclipse.tcf.te.tcf.locator.services;
-
-import org.eclipse.tcf.te.runtime.services.AbstractService;
-import org.eclipse.tcf.te.runtime.services.interfaces.ISimulatorService;
-
-/**
- * Abstract simulator service implementation.
- */
-public abstract class AbstractSimulatorService extends AbstractService implements ISimulatorService {
-}
+/**
+ * AbstractSimulatorService.java
+ * Created on Mar 22, 2013
+ *
+ * Copyright (c) 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
+ * of an applicable Wind River license agreement.
+ */
+package org.eclipse.tcf.te.tcf.locator.services;
+
+import org.eclipse.tcf.te.runtime.services.AbstractService;
+import org.eclipse.tcf.te.runtime.services.interfaces.ISimulatorService;
+
+/**
+ * Abstract simulator service implementation.
+ */
+public abstract class AbstractSimulatorService extends AbstractService implements ISimulatorService {
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/META-INF/MANIFEST.MF
index 41d8dbbc6..78e6c581d 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/META-INF/MANIFEST.MF
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/META-INF/MANIFEST.MF
@@ -53,6 +53,7 @@ Export-Package: org.eclipse.tcf.te.tcf.ui.activator,
org.eclipse.tcf.te.tcf.ui.navigator.nodes,
org.eclipse.tcf.te.tcf.ui.nls,
org.eclipse.tcf.te.tcf.ui.preferences,
+ org.eclipse.tcf.te.tcf.ui.sections,
org.eclipse.tcf.te.tcf.ui.tabbed,
org.eclipse.tcf.te.tcf.ui.wizards,
org.eclipse.tcf.te.tcf.ui.wizards.pages
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml
index 5c85661e6..a6eab6d67 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.xml
@@ -37,6 +37,20 @@
properties="canDelete,canMakeAvailableOffline"
type="org.eclipse.jface.viewers.ISelection">
</propertyTester>
+ <propertyTester
+ class="org.eclipse.tcf.te.tcf.ui.internal.PropertyTester"
+ id="org.eclipse.tcf.te.tcf.ui.propertyTester.wizard"
+ namespace="org.eclipse.tcf.te.tcf.ui"
+ properties="isWizardId"
+ type="org.eclipse.tcf.te.ui.views.navigator.nodes.NewWizardNode">
+ </propertyTester>
+ <propertyTester
+ class="org.eclipse.tcf.te.tcf.ui.internal.PropertyTester"
+ id="org.eclipse.tcf.te.tcf.ui.propertyTester.simulator"
+ namespace="org.eclipse.tcf.te.tcf.ui"
+ properties="isValidSimulatorConfig"
+ type="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel">
+ </propertyTester>
</extension>
<!-- Preference contributions -->
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/SimulatorPayloadBoottimeControl.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/SimulatorPayloadBoottimeControl.java
new file mode 100644
index 000000000..9959b3f47
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/SimulatorPayloadBoottimeControl.java
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.ui.controls;
+
+import org.eclipse.jface.dialogs.IDialogPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.VerifyListener;
+import org.eclipse.tcf.te.tcf.ui.nls.Messages;
+import org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl;
+import org.eclipse.tcf.te.ui.controls.validator.NumberValidator;
+import org.eclipse.tcf.te.ui.controls.validator.NumberVerifyListener;
+import org.eclipse.tcf.te.ui.controls.validator.Validator;
+
+/**
+ * Simulator payload boot time control implementation.
+ */
+public class SimulatorPayloadBoottimeControl extends BaseEditBrowseTextControl {
+
+ /**
+ * Constructor
+ *
+ * @param parentPage The parent dialog page this control is embedded in.
+ * Might be <code>null</code> if the control is not associated with a page.
+ */
+ public SimulatorPayloadBoottimeControl(IDialogPage page) {
+ super(page);
+
+ setIsGroup(false);
+ setEditFieldLabel(Messages.SimulatorPayloadBoottimeControl_label);
+ setHasHistory(false);
+ setHideBrowseButton(true);
+ setLabelIsButton(true);
+ setLabelButtonStyle(SWT.CHECK);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl#doCreateEditFieldValidator()
+ */
+ @Override
+ protected Validator doCreateEditFieldValidator() {
+ return new NumberValidator();
+ }
+
+ private VerifyListener verifyListener;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl#doGetEditFieldControlVerifyListener()
+ */
+ @Override
+ protected VerifyListener doGetEditFieldControlVerifyListener() {
+ if (verifyListener == null) {
+ verifyListener = new NumberVerifyListener();
+ }
+ return verifyListener;
+ }
+
+ /**
+ * Sets the simulator payload boot time in seconds.
+ *
+ * @param boottime The simulator payload boot time in seconds.
+ */
+ public void setSimulatorPayloadBoottime(int boottime) {
+ if (boottime > 0) {
+ setEditFieldControlText(Integer.toString(boottime));
+ setLabelControlSelection(true);
+ } else {
+ setEditFieldControlText(""); //$NON-NLS-1$
+ setLabelControlSelection(false);
+ }
+ }
+
+ /**
+ * Returns the simulator payload boot time in seconds.
+ *
+ * @return The simulator payload boot time in seconds.
+ */
+ public int getSimulatorPayloadBoottime() {
+ int boottime = 0;
+ if (!"".equals(getEditFieldControlText())) { //$NON-NLS-1$
+ boottime = Integer.decode(getEditFieldControlText()).intValue();
+ }
+ return boottime;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/SimulatorTypeSelectionControl.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/SimulatorTypeSelectionControl.java
new file mode 100644
index 000000000..a70be21e5
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/SimulatorTypeSelectionControl.java
@@ -0,0 +1,268 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.ui.controls;
+
+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.jface.dialogs.IMessageProvider;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.tcf.te.runtime.services.ServiceManager;
+import org.eclipse.tcf.te.runtime.services.interfaces.IService;
+import org.eclipse.tcf.te.runtime.services.interfaces.ISimulatorService;
+import org.eclipse.tcf.te.runtime.services.interfaces.IUIService;
+import org.eclipse.tcf.te.tcf.ui.nls.Messages;
+import org.eclipse.tcf.te.tcf.ui.sections.TargetSelectorSection;
+import org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl;
+import org.eclipse.tcf.te.ui.interfaces.services.ISimulatorServiceUIDelegate;
+import org.eclipse.tcf.te.ui.jface.interfaces.IValidatingContainer;
+import org.eclipse.tcf.te.ui.swt.SWTControlUtil;
+
+/**
+ * Simulator type selection control implementation.
+ */
+public class SimulatorTypeSelectionControl extends BaseEditBrowseTextControl {
+ private final Map<String, ISimulatorServiceUIDelegate> id2delegate = new HashMap<String, ISimulatorServiceUIDelegate>();
+ private final Map<String, String> name2id = new HashMap<String, String>();
+ private final Map<String, String> id2name = new HashMap<String, String>();
+ private final Map<String, String> id2config = new HashMap<String, String>();
+
+ private final TargetSelectorSection parentSection;
+
+ /**
+ * Constructor.
+ *
+ * @param parentSection The parent section.
+ */
+ public SimulatorTypeSelectionControl(TargetSelectorSection parentSection) {
+ super(null);
+
+ Assert.isNotNull(parentSection);
+ this.parentSection = parentSection;
+
+ setIsGroup(false);
+ setEditFieldLabel(Messages.SimulatorTypeSelectionControl_label);
+ setButtonLabel(Messages.SimulatorTypeSelectionControl_button_configure);
+ setHasHistory(true);
+ setReadOnly(true);
+ }
+
+ /**
+ * Initialize the control based on the given context.
+ *
+ * @param context The context or <code>null</code>.
+ */
+ public void initialize(Object context) {
+ SWTControlUtil.removeAll(getEditFieldControl());
+ id2delegate.clear();
+ name2id.clear();
+ id2name.clear();
+ id2config.clear();
+
+ List<String> entries = new ArrayList<String>();
+
+ if (context != null) {
+ // Get all simulator services for the given context
+ IService[] services = ServiceManager.getInstance().getServices(context, ISimulatorService.class, false);
+ for (IService service : services) {
+ Assert.isTrue(service instanceof ISimulatorService);
+ // Get the UI service which is associated with the simulator service
+ IUIService uiService = ServiceManager.getInstance().getService(service, IUIService.class);
+ if (uiService == null) {
+ continue;
+ }
+ // Get the simulator service UI delegate
+ ISimulatorServiceUIDelegate uiDelegate = uiService.getDelegate(service, ISimulatorServiceUIDelegate.class);
+ String id = service.getId();
+ String name = uiDelegate != null ? uiDelegate.getName() : id;
+ id2delegate.put(id, uiDelegate);
+ name2id.put(name, id);
+ id2name.put(id, name);
+ if (!entries.contains(name)) {
+ entries.add(name);
+ }
+ }
+ }
+
+ SWTControlUtil.setItems(getEditFieldControl(), entries.toArray(new String[entries.size()]));
+ SWTControlUtil.select(getEditFieldControl(), 0);
+
+ if (getEditFieldControl() != null && getEditFieldControl().getLayoutData() instanceof GridData) {
+ doAdjustEditFieldControlLayoutData((GridData)getEditFieldControl().getLayoutData());
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl#doAdjustEditFieldControlLayoutData(org.eclipse.swt.layout.GridData)
+ */
+ @Override
+ protected void doAdjustEditFieldControlLayoutData(GridData layoutData) {
+ super.doAdjustEditFieldControlLayoutData(layoutData);
+
+ int maxWidth = -1;
+ for (String item : SWTControlUtil.getItems(getEditFieldControl())) {
+ maxWidth = Math.max(item.length(), maxWidth);
+ }
+
+ if (maxWidth != -1) {
+ layoutData.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING;
+ layoutData.grabExcessHorizontalSpace = false;
+ layoutData.widthHint = SWTControlUtil.convertWidthInCharsToPixels(getEditFieldControl(), maxWidth + 4);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.BaseDialogPageControl#getValidatingContainer()
+ */
+ @Override
+ public IValidatingContainer getValidatingContainer() {
+ Object container = parentSection.getManagedForm().getContainer();
+ return container instanceof IValidatingContainer ? (IValidatingContainer)container : null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl#onButtonControlSelected()
+ */
+ @Override
+ protected void onButtonControlSelected() {
+ // Get the corresponding simulator service UI delegate
+ ISimulatorServiceUIDelegate uiDelegate = id2delegate.get(getSelectedSimulatorId());
+ if (uiDelegate != null) {
+ String oldConfig = getSimulatorConfig();
+ String newConfig = uiDelegate.configure(parentSection.getOriginalData(), oldConfig);
+ if ((oldConfig != null && !oldConfig.equals(newConfig)) || (newConfig != null && !newConfig.equals(oldConfig))) {
+ id2config.put(getSelectedSimulatorId(), newConfig);
+ parentSection.dataChanged(null);
+ }
+ }
+ }
+
+ /**
+ * Set the selected simulator id.
+ * @param id The selected simulator id or <code>null</code>.
+ */
+ public void setSelectedSimulatorId(String id) {
+ String name = id2name.get(id);
+ if (name != null && name.trim().length() > 0) {
+ int index = ((Combo)getEditFieldControl()).indexOf(name);
+ if (index >= 0) {
+ SWTControlUtil.select(getEditFieldControl(), index);
+ }
+ }
+ }
+
+ /**
+ * Get the selected simulator id.
+ * @return The selected simulator id or <code>null</code>.
+ */
+ public String getSelectedSimulatorId() {
+ return name2id.get(getEditFieldControlText());
+ }
+
+ /**
+ * Set the simulator configuration for the selected simulator.
+ *
+ * @param config The simulator configuration or <code>null</code>.
+ */
+ public void setSimulatorConfig(String config) {
+ id2config.put(getSelectedSimulatorId(), config);
+ }
+
+ /**
+ * Get the simulator configuration for the selected simulator.
+ * If no configuration was set, the default configuration or <code>null</code> will be returned.
+ *
+ * @return The simulator configuration or <code>null</code>.
+ */
+ public String getSimulatorConfig() {
+ String config = id2config.get(getSelectedSimulatorId());
+ ISimulatorServiceUIDelegate uiDelegate = id2delegate.get(getSelectedSimulatorId());
+ if (uiDelegate != null && (config == null || config.trim().length() == 0)) {
+ config = uiDelegate.getService().getDefaultConfig();
+ }
+ return config;
+ }
+
+ private void setConfigureEnabled(boolean enabled) {
+ // Get the currently selected simulator type name
+ String id = getSelectedSimulatorId();
+ // Get the corresponding simulator service UI delegate
+ ISimulatorServiceUIDelegate uiDelegate = id2delegate.get(id);
+ if (getButtonControl() != null) {
+ getButtonControl().setEnabled(enabled && uiDelegate != null && uiDelegate.canConfigure());
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl#widgetSelected(org.eclipse.swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ super.widgetSelected(e);
+ setConfigureEnabled(isEnabled());
+ parentSection.dataChanged(e);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl#setEnabled(boolean)
+ */
+ @Override
+ public void setEnabled(boolean enabled) {
+ super.setEnabled(enabled);
+ setConfigureEnabled(enabled);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl#onLabelControlSelectedChanged()
+ */
+ @Override
+ protected void onLabelControlSelectedChanged() {
+ super.onLabelControlSelectedChanged();
+ setConfigureEnabled(isLabelControlSelected());
+ parentSection.dataChanged(null);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl#isValid()
+ */
+ @Override
+ public boolean isValid() {
+ boolean valid = super.isValid();
+
+ if (valid) {
+ // Get the corresponding simulator service UI delegate
+ ISimulatorServiceUIDelegate uiDelegate = id2delegate.get(getSelectedSimulatorId());
+ String config = getSimulatorConfig();
+ String defaultConfig = uiDelegate != null ? uiDelegate.getService().getDefaultConfig() : null;
+ valid = uiDelegate != null ? uiDelegate.getService().isValidConfig(parentSection.getOriginalData(), config) : true;
+ boolean isDefaultConfig = (defaultConfig != null && defaultConfig.equals(config)) || (defaultConfig == null && config == null);
+ if (!valid) {
+ setMessage(Messages.SimulatorTypeSelectionControl_error_invalidConfiguration, isDefaultConfig ? IMessageProvider.INFORMATION : IMessageProvider.ERROR);
+ }
+ }
+
+ if (getControlDecoration() != null) {
+ // Setup and show the control decoration if necessary
+ if (isEnabled() && (!valid || (getMessage() != null && getMessageType() != IMessageProvider.NONE))) {
+ // Update the control decorator
+ updateControlDecoration(getMessage(), getMessageType());
+ } else {
+ updateControlDecoration(null, IMessageProvider.NONE);
+ }
+ }
+
+ return valid;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/AbstractConfigurationEditorPage.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/AbstractConfigurationEditorPage.java
new file mode 100644
index 000000000..a25dc6291
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/AbstractConfigurationEditorPage.java
@@ -0,0 +1,189 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.ui.editor;
+
+import java.io.IOException;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.tcf.protocol.Protocol;
+import org.eclipse.tcf.te.runtime.persistence.interfaces.IURIPersistenceService;
+import org.eclipse.tcf.te.runtime.services.ServiceManager;
+import org.eclipse.tcf.te.runtime.services.interfaces.ISimulatorService;
+import org.eclipse.tcf.te.runtime.statushandler.StatusHandlerUtil;
+import org.eclipse.tcf.te.runtime.utils.StatusHelper;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
+import org.eclipse.tcf.te.tcf.locator.interfaces.services.ILocatorModelRefreshService;
+import org.eclipse.tcf.te.tcf.ui.help.IContextHelpIds;
+import org.eclipse.tcf.te.tcf.ui.nls.Messages;
+import org.eclipse.tcf.te.tcf.ui.sections.TargetSelectorSection;
+import org.eclipse.tcf.te.ui.views.ViewsUtil;
+import org.eclipse.tcf.te.ui.views.editor.pages.AbstractCustomFormToolkitEditorPage;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.widgets.TableWrapData;
+
+/**
+ * Abstract configuration editor page implementation.
+ */
+public abstract class AbstractConfigurationEditorPage extends AbstractCustomFormToolkitEditorPage {
+
+ // Section to select real or simulator
+ /* default */ TargetSelectorSection targetSelectorSection = null;
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.views.editor.pages.AbstractEditorPage#setInput(org.eclipse.ui.IEditorInput)
+ */
+ @Override
+ protected void setInput(IEditorInput input) {
+ IEditorInput oldInput = getEditorInput();
+ // do nothing when input did not change
+ if (oldInput != null && oldInput.equals(input)) {
+ return;
+ }
+ super.setInput(input);
+ }
+
+ /**
+ * Returns the history id to use to save the editor to the
+ * history manager.
+ *
+ * @return The history id. Never <code>null</code>.
+ */
+ protected abstract String getHistoryId();
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.views.editor.pages.AbstractCustomFormToolkitEditorPage#hasApplyAction()
+ */
+ @Override
+ protected boolean hasApplyAction() {
+ return true;
+ }
+
+ /**
+ * Add the target selector section if an {@link ISimulatorService} is available.
+ * @param form The form.
+ * @param parent The parent composite.
+ */
+ protected void addTargetSelectorSection(IManagedForm form, Composite parent) {
+ ISimulatorService service = ServiceManager.getInstance().getService(getEditorInputNode(), ISimulatorService.class);
+ if (service != null) {
+ targetSelectorSection = doCreateTargetSelectorSection(form, parent);
+ targetSelectorSection.getSection().setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP));
+ getManagedForm().addPart(targetSelectorSection);
+ }
+ }
+
+ protected TargetSelectorSection getTargetSelectorSection() {
+ return targetSelectorSection;
+ }
+
+ /**
+ * Create the target selector section.
+ * @param form The form.
+ * @param parent The parent composite.
+ * @return The target selector section.
+ */
+ protected TargetSelectorSection doCreateTargetSelectorSection (IManagedForm form, Composite parent) {
+ return new TargetSelectorSection(getManagedForm(), parent);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.views.editor.pages.AbstractCustomFormToolkitEditorPage#dispose()
+ */
+ @Override
+ public void dispose() {
+ if (targetSelectorSection != null) { targetSelectorSection.dispose(); targetSelectorSection = null; }
+ super.dispose();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.views.editor.pages.AbstractEditorPage#setActive(boolean)
+ */
+ @Override
+ public void setActive(boolean active) {
+ super.setActive(active);
+
+ if (targetSelectorSection != null) {
+ targetSelectorSection.setActive(active);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.views.editor.pages.AbstractEditorPage#doValidate()
+ */
+ @Override
+ protected ValidationResult doValidate() {
+ ValidationResult result = super.doValidate();
+
+ if (targetSelectorSection != null) {
+ targetSelectorSection.isValid();
+ result.setResult(targetSelectorSection);
+ }
+
+ return result;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.views.editor.pages.AbstractEditorPage#postDoSave(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ @Override
+ public void postDoSave(IProgressMonitor monitor) {
+ super.postDoSave(monitor);
+
+ // If necessary, write the changed peer attributes
+ final Object input = getEditorInputNode();
+ if (input instanceof IPeerModel) {
+ Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ try {
+ boolean isDynamic = !((IPeerModel)input).isStatic();
+
+ // 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 peer node to the new persistence storage
+ uRIPersistenceService.write(((IPeerModel)input).getPeer(), null);
+
+ // In case the node had been dynamically discovered before, we have to trigger a refresh
+ // to the locator model to read in the newly created static peer
+ if (isDynamic) {
+ // Refresh the static peers
+ ((IPeerModel)input).getModel().getService(ILocatorModelRefreshService.class).refreshStaticPeers();
+
+ // Reopen the editor on the current page
+ ViewsUtil.reopenEditor(getEditor(), getEditor().getActivePageInstance().getId(), false);
+ }
+ } catch (IOException e) {
+ // Build up the message template
+ String template = NLS.bind(Messages.AbstractConfigurationEditorPage_error_save, ((IPeerModel)input).getName(), Messages.AbstractConfigurationEditorPage_error_possibleCause);
+ // Handle the status
+ StatusHandlerUtil.handleStatus(StatusHelper.getStatus(e), input, template, null, IContextHelpIds.MESSAGE_SAVE_FAILED, AbstractConfigurationEditorPage.this, null);
+ }
+ }
+ };
+ Assert.isTrue(!Protocol.isDispatchThread());
+ Protocol.invokeAndWait(runnable);
+
+ Protocol.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+ // Trigger a change event for the original data node
+ ((IPeerModel)input).fireChangeEvent("properties", null, ((IPeerModel)input).getProperties()); //$NON-NLS-1$
+ }
+ });
+ }
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/PropertyTester.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/PropertyTester.java
index 6f8121349..f64dc482d 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/PropertyTester.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/PropertyTester.java
@@ -11,8 +11,11 @@ package org.eclipse.tcf.te.tcf.ui.internal;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
+import org.eclipse.tcf.te.tcf.locator.utils.SimulatorUtils;
import org.eclipse.tcf.te.tcf.ui.handler.DeleteHandler;
import org.eclipse.tcf.te.tcf.ui.handler.OfflineCommandHandler;
+import org.eclipse.tcf.te.ui.views.navigator.nodes.NewWizardNode;
@@ -34,6 +37,17 @@ public class PropertyTester extends org.eclipse.core.expressions.PropertyTester
// Analyze the selection
return testSelection((IStructuredSelection)receiver, property, args, expectedValue);
}
+
+ if ("isWizardId".equals(property) && receiver instanceof NewWizardNode) { //$NON-NLS-1$
+ return ((NewWizardNode)receiver).getWizardId().equals(expectedValue);
+ }
+
+ if ("isValidSimulatorConfig".equals(property) && receiver instanceof IPeerModel && expectedValue instanceof Boolean) { //$NON-NLS-1$
+ SimulatorUtils.Result simulator = SimulatorUtils.getSimulatorService((IPeerModel)receiver);
+ boolean valid = simulator != null && simulator.service.isValidConfig(receiver, simulator.settings);
+ return ((Boolean)expectedValue).booleanValue() == valid;
+ }
+
return false;
}
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 aeded0905..b58ee8657 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
@@ -169,6 +169,26 @@ public class Messages extends NLS {
public static String RenameHandler_dialog_error_nameExist;
public static String RenameHandler_dialog_promptNewName;
+ public static String TargetSelectorSection_title;
+ public static String TargetSelectorSection_button_enableSimulator;
+ public static String TargetSelectorSection_button_enableReal;
+
+ public static String SimulatorPayloadBoottimeControl_label;
+
+ public static String SimulatorTypeSelectionControl_label;
+ public static String SimulatorTypeSelectionControl_button_configure;
+ public static String SimulatorTypeSelectionControl_error_invalidConfiguration;
+
+ public static String AbstractConfigurationEditorPage_error_possibleCause;
+ public static String AbstractConfigurationEditorPage_error_save;
+
+ public static String AbstractConfigWizardPage_configName_label;
+ public static String AbstractConfigWizardPage_configName_infoMissingValue;
+ public static String AbstractConfigWizardPage_configName_nameInUse;
+ public static String AbstractConfigWizardPage_launchDbg_label;
+ public static String AbstractConfigWizardPage_advancedButton_label;
+ public static String AbstractConfigWizardPage_connectJob_label;
+
public static String LoggingPreferencePage_label;
public static String LoggingPreferencePage_enabled_label;
public static String LoggingPreferencePage_monitorEnabled_label;
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 692602031..7de8e30fa 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
@@ -126,6 +126,26 @@ RenameHandler_dialog_message=Please enter a new name for the selected target.
RenameHandler_dialog_error_nameExist=A target with the name you specified already exists! Specify a different name.
RenameHandler_dialog_promptNewName=New Name:
+TargetSelectorSection_title=Target
+TargetSelectorSection_button_enableReal=Use running Target
+TargetSelectorSection_button_enableSimulator=Start local Simulator:
+
+SimulatorPayloadBoottimeControl_label=Time to wait while the Simulator guest boots (in seconds):
+
+SimulatorTypeSelectionControl_label=Simulator Type:
+SimulatorTypeSelectionControl_button_configure=Configure...
+SimulatorTypeSelectionControl_error_invalidConfiguration=The simulator configuration is not valid. Please click on ''Configure...'' to configure the simulator.
+
+AbstractConfigurationEditorPage_error_possibleCause=Possible Cause:\n{0}
+AbstractConfigurationEditorPage_error_save=Failed to save connection: {0}.\n\n{1}
+
+AbstractConfigWizardPage_configName_label=Connection Name:
+AbstractConfigWizardPage_configName_infoMissingValue=Please enter a connection name.
+AbstractConfigWizardPage_configName_nameInUse=This connection name is already used. Please choose a unique name.
+AbstractConfigWizardPage_launchDbg_label=Start debugger after connection has been established
+AbstractConfigWizardPage_advancedButton_label=Advanced...
+AbstractConfigWizardPage_connectJob_label=Connect ''{0}''
+
# ***** Preference Pages *****
LoggingPreferencePage_label=Logging settings for agent communication:
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/sections/TargetSelectorSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/sections/TargetSelectorSection.java
new file mode 100644
index 000000000..5286dfc92
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/sections/TargetSelectorSection.java
@@ -0,0 +1,525 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.ui.sections;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.TypedEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.tcf.core.TransientPeer;
+import org.eclipse.tcf.protocol.IPeer;
+import org.eclipse.tcf.protocol.Protocol;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.runtime.properties.PropertiesContainer;
+import org.eclipse.tcf.te.runtime.services.interfaces.ISimulatorService;
+import org.eclipse.tcf.te.tcf.core.peers.Peer;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties;
+import org.eclipse.tcf.te.tcf.locator.nodes.PeerRedirector;
+import org.eclipse.tcf.te.tcf.locator.utils.SimulatorUtils;
+import org.eclipse.tcf.te.tcf.ui.controls.SimulatorTypeSelectionControl;
+import org.eclipse.tcf.te.tcf.ui.nls.Messages;
+import org.eclipse.tcf.te.ui.forms.parts.AbstractSection;
+import org.eclipse.tcf.te.ui.interfaces.data.IDataExchangeNode;
+import org.eclipse.tcf.te.ui.jface.interfaces.IValidatingContainer;
+import org.eclipse.tcf.te.ui.swt.SWTControlUtil;
+import org.eclipse.tcf.te.ui.views.editor.pages.AbstractEditorPage;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Section;
+
+/**
+ * Simulator section implementation.
+ */
+public class TargetSelectorSection extends AbstractSection implements IDataExchangeNode {
+ // The section sub controls
+ /* default */ Button real;
+ /* default */ SimulatorTypeSelectionControl type;
+
+ // Reference to the original data object
+ /* default */ IPeerModel od;
+ // Reference to a copy of the original data
+ /* default */ final IPropertiesContainer odc = new PropertiesContainer();
+ // Reference to the properties container representing the working copy for the section
+ /* default */ final IPropertiesContainer wc = new PropertiesContainer();
+
+ protected static final int SELECTION_REAL = 0;
+ protected static final int SELECTION_SIM = 1;
+
+ /**
+ * Constructor.
+ *
+ * @param form The parent managed form. Must not be <code>null</code>.
+ * @param parent The parent composite. Must not be <code>null</code>.
+ */
+ public TargetSelectorSection(IManagedForm form, Composite parent) {
+ super(form, parent, SWT.NONE);
+ createClient(getSection(), form.getToolkit());
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param form The parent managed form. Must not be <code>null</code>.
+ * @param parent The parent composite. Must not be <code>null</code>.
+ * @param style The section style.
+ */
+ public TargetSelectorSection(IManagedForm form, Composite parent, int style) {
+ super(form, parent, style);
+ createClient(getSection(), form.getToolkit());
+ }
+
+ /**
+ * Get the original data.
+ * @return The original set data or <code>null</code>;
+ */
+ public Object getOriginalData() {
+ return od;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.forms.AbstractFormPart#dispose()
+ */
+ @Override
+ public void dispose() {
+ if (type != null) { type.dispose(); type = null; }
+ super.dispose();
+ }
+
+ @Override
+ public IValidatingContainer getValidatingContainer() {
+ Object container = getManagedForm().getContainer();
+ return container instanceof IValidatingContainer ? (IValidatingContainer)container : null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.forms.parts.AbstractSection#createClient(org.eclipse.ui.forms.widgets.Section, org.eclipse.ui.forms.widgets.FormToolkit)
+ */
+ @Override
+ protected void createClient(Section section, FormToolkit toolkit) {
+ Assert.isNotNull(section);
+ Assert.isNotNull(toolkit);
+
+ // Configure the section
+ section.setText(Messages.TargetSelectorSection_title);
+ if (section.getParent().getLayout() instanceof GridLayout) {
+ section.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ }
+
+ // Create the section client
+ Composite client = createClientContainer(section, 3, toolkit);
+ Assert.isNotNull(client);
+ section.setClient(client);
+
+ real = toolkit.createButton(client, Messages.TargetSelectorSection_button_enableReal, SWT.RADIO);
+ GridData gd = new GridData(SWT.BEGINNING, SWT.CENTER, false, false);
+ gd.horizontalSpan = 3;
+ real.setSelection(true);
+ real.setLayoutData(gd);
+ real.setBackground(client.getBackground());
+ real.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (real.getSelection()) {
+ onSelectionChanged(SELECTION_REAL);
+ }
+ // validate the page
+ getValidatingContainer().validate();
+ dataChanged(null);
+ }
+ });
+
+ type = new SimulatorTypeSelectionControl(this) {
+ @SuppressWarnings("synthetic-access")
+ @Override
+ protected void onLabelControlSelectedChanged() {
+ super.onLabelControlSelectedChanged();
+ if (type.isLabelControlSelected()) {
+ onSelectionChanged(SELECTION_SIM);
+ if (!isUpdating()) {
+ onSimulatorChanged(false, true, getSelectedSimulatorId(), getSelectedSimulatorId(), getSimulatorConfig(), getSimulatorConfig());
+ }
+ }
+ }
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ super.widgetSelected(e);
+ String newId = getSelectedSimulatorId();
+ onSimulatorChanged(isLabelControlSelected(), isLabelControlSelected(), null, newId, getSimulatorConfig(), getSimulatorConfig());
+ }
+ @Override
+ protected void onButtonControlSelected() {
+ String oldConfig = getSimulatorConfig();
+ super.onButtonControlSelected();
+ String newConfig = getSimulatorConfig();
+ if ((newConfig != null && !newConfig.equals(oldConfig)) || (newConfig == null && oldConfig != null)) {
+ onSimulatorChanged(isLabelControlSelected(), isLabelControlSelected(), getSelectedSimulatorId(), getSelectedSimulatorId(), oldConfig, newConfig);
+ }
+ }
+ };
+ type.setLabelIsButton(true);
+ type.setLabelButtonStyle(SWT.RADIO);
+ type.setEditFieldLabel(Messages.TargetSelectorSection_button_enableSimulator);
+ type.setParentControlIsInnerPanel(true);
+ type.setupPanel(client);
+
+ // Adjust the control enablement
+ updateEnablement();
+
+ // Mark the control update as completed now
+ setIsUpdating(false);
+ }
+
+ /**
+ * Called on radio button selection changed.
+ * @param selectionType The new selected type.
+ */
+ protected void onSelectionChanged(int selectionType) {
+ }
+
+ /**
+ * Called on simulator enabled, simulator type or simulator configuration changed.
+ *
+ * @param oldEnabled The old simulator enabled state.
+ * @param newEnabled The simulator enabled state.
+ * @param oldType The old selected simulator type.
+ * @param newType The selected simulator type.
+ * @param oldConfig The old simulator configuration.
+ * @param newConfig The new simulator configuration.
+ */
+ protected void onSimulatorChanged(boolean oldEnabled, boolean newEnabled, String oldType, String newType, String oldConfig, String newConfig) {
+ }
+
+ /**
+ * Indicates whether the sections parent page has become the active in the editor.
+ *
+ * @param active <code>True</code> if the parent page should be visible, <code>false</code> otherwise.
+ */
+ public void setActive(boolean active) {
+ // If the parent page has become the active and it does not contain
+ // unsaved data, than fill in the data from the selected node
+ if (active) {
+ // Leave everything unchanged if the page is in dirty state
+ if (getManagedForm().getContainer() instanceof AbstractEditorPage
+ && !((AbstractEditorPage)getManagedForm().getContainer()).isDirty()) {
+ Object node = ((AbstractEditorPage)getManagedForm().getContainer()).getEditorInputNode();
+ if (node instanceof IPeerModel) {
+ setupData((IPeerModel)node);
+ }
+ }
+ } else {
+ // Evaluate the dirty state even if going inactive
+ dataChanged(null);
+ }
+ }
+
+ /* (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) {
+ // Mark the control update as in-progress now
+ setIsUpdating(true);
+
+ // Initialize the simulator type selection control
+ if (type != null) {
+ type.initialize(od);
+ type.setSelectedSimulatorId(data.getStringProperty(IPeerModelProperties.PROP_SIM_TYPE));
+ type.setSimulatorConfig(data.getStringProperty(IPeerModelProperties.PROP_SIM_PROPERTIES));
+ type.setLabelControlSelection(data.getBooleanProperty(IPeerModelProperties.PROP_SIM_ENABLED));
+ }
+
+ SWTControlUtil.setSelection(real, !data.getBooleanProperty(IPeerModelProperties.PROP_SIM_ENABLED));
+
+ onSelectionChanged(data.getBooleanProperty(IPeerModelProperties.PROP_SIM_ENABLED) ? SELECTION_SIM : SELECTION_REAL);
+
+ // Mark the control update as completed now
+ setIsUpdating(false);
+ // Re-evaluate the dirty state
+ dataChanged(null);
+ }
+
+ /**
+ * Initialize the page widgets based of the data from the given peer model
+ * node.
+ * <p>
+ * This method may called multiple times during the lifetime of the page and
+ * the given context node might be even <code>null</code>.
+ *
+ * @param node The peer model node or <code>null</code>.
+ */
+ public void setupData(final IPeerModel node) {
+ // If the section is dirty, nothing is changed
+ if (isDirty()) {
+ return;
+ }
+
+ boolean updateWidgets = true;
+
+ // If the passed in node is the same as the previous one,
+ // no need for updating the section widgets.
+ if ((node == null && od == null) || (node != null && node.equals(od))) {
+ updateWidgets = false;
+ }
+
+ // Besides the node itself, we need to look at the node data to determine
+ // if the widgets needs to be updated. For the comparisation, keep the
+ // current properties of the original data copy in a temporary container.
+ final IPropertiesContainer previousOdc = new PropertiesContainer();
+ previousOdc.setProperties(odc.getProperties());
+
+ // Store a reference to the original data
+ od = node;
+ // Clean the original data copy
+ odc.clearProperties();
+ // Clean the working copy
+ wc.clearProperties();
+
+ // If no data is available, we are done
+ if (node == null) {
+ return;
+ }
+
+ // Thread access to the model is limited to the executors thread.
+ // Copy the data over to the working copy to ease the access.
+ Protocol.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ // The section is handling the simulator related properties
+ // Ignore other properties.
+ odc.setProperty(IPeerModelProperties.PROP_SIM_ENABLED, node.getPeer().getAttributes().get(IPeerModelProperties.PROP_SIM_ENABLED));
+ odc.setProperty(IPeerModelProperties.PROP_SIM_PROPERTIES, node.getPeer().getAttributes().get(IPeerModelProperties.PROP_SIM_PROPERTIES));
+ odc.setProperty(IPeerModelProperties.PROP_SIM_TYPE, node.getPeer().getAttributes().get(IPeerModelProperties.PROP_SIM_TYPE));
+ // Initially, the working copy is a duplicate of the original data copy
+ wc.setProperties(odc.getProperties());
+ }
+ });
+
+ // From here on, work with the working copy only!
+
+ // If the original data copy does not match the previous original
+ // data copy, the widgets needs to be updated to present the correct data.
+ if (!previousOdc.getProperties().equals(odc.getProperties())) {
+ updateWidgets = true;
+ }
+
+ if (updateWidgets) {
+ setupData(wc);
+ }
+ else {
+ // Re-evaluate the dirty state
+ dataChanged(null);
+ }
+ }
+
+ /* (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) {
+ Assert.isNotNull(data);
+
+ // Extract the widget data into the working copy
+ if (type != null) {
+ data.setProperty(IPeerModelProperties.PROP_SIM_ENABLED, type.isLabelControlSelected());
+ data.setProperty(IPeerModelProperties.PROP_SIM_TYPE, type.getSelectedSimulatorId());
+ data.setProperty(IPeerModelProperties.PROP_SIM_PROPERTIES, type.getSimulatorConfig());
+ }
+ }
+
+ /**
+ * Stores the page widgets current values to the given peer node.
+ * <p>
+ * This method may called multiple times during the lifetime of the page and
+ * the given peer node might be even <code>null</code>.
+ *
+ * @param node The peer node or <code>null</code>.
+ */
+ public void extractData(final IPeerModel node) {
+ // If no data is available, we are done
+ if (node == null) {
+ return;
+ }
+
+ // Extract the widget data into the working copy
+ extractData(wc);
+
+ // If the data has not changed compared to the original data copy,
+ // we are done here and return immediately
+ if (odc.equals(wc)) {
+ return;
+ }
+
+ // Copy the working copy data back to the original properties container
+ Protocol.invokeAndWait(new Runnable() {
+ @Override
+ public void run() {
+ boolean isSimEnabled = wc.getBooleanProperty(IPeerModelProperties.PROP_SIM_ENABLED);
+ String configs = wc.getStringProperty(IPeerModelProperties.PROP_SIM_PROPERTIES);
+ String type = wc.getStringProperty(IPeerModelProperties.PROP_SIM_TYPE);
+
+ // To update the peer attributes, the peer needs to be recreated
+ IPeer oldPeer = node.getPeer();
+ // Create a write able copy of the peer attributes
+ Map<String, String> attributes = new HashMap<String, String>(oldPeer.getAttributes());
+ // Update the data
+ if (isSimEnabled) {
+ attributes.put(IPeerModelProperties.PROP_SIM_ENABLED, Boolean.toString(isSimEnabled));
+ } else {
+ attributes.remove(IPeerModelProperties.PROP_SIM_ENABLED);
+ }
+ if (configs != null) {
+ attributes.put(IPeerModelProperties.PROP_SIM_PROPERTIES, configs);
+ } else {
+ attributes.remove(IPeerModelProperties.PROP_SIM_PROPERTIES);
+ }
+ if (type != null) {
+ attributes.put(IPeerModelProperties.PROP_SIM_TYPE, type);
+ } else {
+ attributes.remove(IPeerModelProperties.PROP_SIM_TYPE);
+ }
+ // And merge it to the peer model node
+ if (oldPeer instanceof TransientPeer && !(oldPeer instanceof PeerRedirector || oldPeer instanceof Peer)) {
+ // Create a peer object
+ IPeer newPeer = new Peer(attributes);
+ // Update the peer instance
+ node.setProperty(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties.PROP_INSTANCE, newPeer);
+ } else {
+ if (oldPeer instanceof PeerRedirector) {
+ ((PeerRedirector)oldPeer).updateAttributes(attributes);
+ } else if (oldPeer instanceof Peer) {
+ ((Peer)oldPeer).updateAttributes(attributes);
+ }
+ }
+ }
+ });
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.forms.parts.AbstractSection#isValid()
+ */
+ @Override
+ public boolean isValid() {
+ // Validation is skipped while the controls are updated
+ if (isUpdating()) {
+ return true;
+ }
+
+ boolean valid = super.isValid();
+
+ if (type != null && type.isLabelControlSelected()) {
+ valid &= type.isValid();
+ if (type.getMessageType() > getMessageType()) {
+ setMessage(type.getMessage(), type.getMessageType());
+ }
+ }
+
+ return valid;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.forms.AbstractFormPart#commit(boolean)
+ */
+ @Override
+ public void commit(boolean onSave) {
+ // Remember the current dirty state
+ boolean needsSaving = isDirty();
+ // Call the super implementation (resets the dirty state)
+ super.commit(onSave);
+
+ // Nothing to do if not on save or saving is not needed
+ if (!onSave || !needsSaving) {
+ return;
+ }
+
+ // Extract the data into the peer model node
+ extractData((IPeerModel)getManagedForm().getInput());
+ }
+
+ /**
+ * Called to signal that the data associated has been changed.
+ *
+ * @param e The event which triggered the invocation or <code>null</code>.
+ */
+ public void dataChanged(TypedEvent e) {
+ // dataChanged is not evaluated while the controls are updated
+ if (isUpdating()) {
+ return;
+ }
+
+ boolean isDirty = false;
+
+ // Compare the data
+ if (type != null) {
+ boolean oldEnabled = odc.getBooleanProperty(IPeerModelProperties.PROP_SIM_ENABLED);
+ isDirty |= (oldEnabled != type.isLabelControlSelected());
+
+ if (type.isLabelControlSelected()) {
+ String newType = type.getSelectedSimulatorId();
+ String oldType = odc.getStringProperty(IPeerModelProperties.PROP_SIM_TYPE);
+ if (newType == null || "".equals(newType)) { //$NON-NLS-1$
+ isDirty |= oldType != null && !"".equals(oldType); //$NON-NLS-1$
+ } else {
+ isDirty |= !newType.equals(oldType);
+ }
+
+ String newConfig = type.getSimulatorConfig();
+ String oldConfig = odc.getStringProperty(IPeerModelProperties.PROP_SIM_PROPERTIES);
+ if (newConfig == null || "".equals(newConfig)) { //$NON-NLS-1$
+ isDirty |= oldConfig != null && !"".equals(oldConfig); //$NON-NLS-1$
+ }
+ else {
+ isDirty |= !newConfig.equals(oldConfig);
+ }
+ }
+ }
+
+ // If dirty, mark the form part dirty.
+ // Otherwise call refresh() to reset the dirty (and stale) flag
+ markDirty(isDirty);
+
+ // Adjust the control enablement
+ updateEnablement();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.forms.parts.AbstractSection#getAdapter(java.lang.Class)
+ */
+ @Override
+ public Object getAdapter(Class adapter) {
+ if (SimulatorTypeSelectionControl.class.equals(adapter)) {
+ return type;
+ }
+ return super.getAdapter(adapter);
+ }
+
+ /**
+ * Updates the control enablement.
+ */
+ protected void updateEnablement() {
+ SimulatorUtils.Result simulator = od != null ? SimulatorUtils.getSimulatorService(od) : null;
+
+ boolean enabled = simulator == null || simulator.service.getState(od, simulator.settings) == ISimulatorService.State.Stopped;
+ SWTControlUtil.setEnabled(real, enabled);
+
+ if (type != null) {
+ SWTControlUtil.setEnabled(type.getEditFieldControl(), type.isLabelControlSelected() && enabled);
+ }
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/AbstractConfigWizard.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/AbstractConfigWizard.java
new file mode 100644
index 000000000..64506914f
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/AbstractConfigWizard.java
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.ui.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.stepper.interfaces.IStepContext;
+import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepperService;
+import org.eclipse.tcf.te.runtime.stepper.job.StepperJob;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
+import org.eclipse.tcf.te.tcf.ui.activator.UIPlugin;
+import org.eclipse.tcf.te.tcf.ui.wizards.pages.AbstractConfigWizardPage;
+import org.eclipse.ui.IWorkbench;
+
+/**
+ * Abstract new configuration wizard implementation.
+ */
+public abstract class AbstractConfigWizard extends NewTargetWizard {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
+ */
+ @Override
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ super.init(workbench, selection);
+ // Set the window title
+ setWindowTitle(getWizardTitle());
+ // Signal the need for a progress monitor
+ setNeedsProgressMonitor(true);
+ }
+
+ /**
+ * Returns the new configuration wizard title.
+ *
+ * @return The wizard title. Never <code>null</code>.
+ */
+ protected abstract String getWizardTitle();
+
+ /**
+ * Returns the new configuration wizard page.
+ *
+ * @return The new configuration wizard page or <code>null</code>:
+ */
+ protected abstract AbstractConfigWizardPage getConfigWizardPage();
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.ui.wizards.NewTargetWizard#postPerformFinish(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel)
+ */
+ @Override
+ protected void postPerformFinish(final IPeerModel peerModel) {
+ Assert.isNotNull(peerModel);
+
+ // Determine if or if not to auto-connect the created connection.
+ boolean autoConnect = true;
+ // If set as system property, take the system property into account first
+ if (System.getProperty("NoWizardAutoConnect") != null) { //$NON-NLS-1$
+ autoConnect &= !Boolean.getBoolean("NoWizardAutoConnect"); //$NON-NLS-1$
+ }
+ // Apply the preference setting
+ autoConnect &= !UIPlugin.getDefault().getPreferenceStore().getBoolean("NoWizardAutoConnect"); //$NON-NLS-1$
+
+ // If auto-connect is switched off, we are done here.
+ if (!autoConnect) return;
+
+ // Connect the connection
+ IStepperService service = ServiceManager.getInstance().getService(peerModel, IStepperService.class);
+ if (service != null) {
+ String stepGroupId = service.getStepGroupId(peerModel, IStepperService.OPERATION_CONNECT);
+ IStepContext stepContext = service.getStepContext(peerModel, IStepperService.OPERATION_CONNECT);
+ String name = service.getStepGroupName(peerModel, IStepperService.OPERATION_CONNECT);
+
+ if (stepGroupId != null && stepContext != null) {
+ IPropertiesContainer data = new PropertiesContainer();
+ StepperJob job = new StepperJob(name != null ? name : "", //$NON-NLS-1$
+ stepContext,
+ data,
+ stepGroupId,
+ IStepperService.OPERATION_CONNECT,
+ true);
+
+ job.schedule();
+ }
+ }
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/AbstractConfigWizardPage.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/AbstractConfigWizardPage.java
new file mode 100644
index 000000000..679aaa7f4
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/wizards/pages/AbstractConfigWizardPage.java
@@ -0,0 +1,472 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Wind River Systems, Inc. and others. All rights reserved.
+ * This program and the accompanying materials are made available under the terms
+ * of the Eclipse Public License v1.0 which accompanies this distribution, and is
+ * available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.ui.wizards.pages;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.dialogs.IDialogPage;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.osgi.util.NLS;
+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.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.tcf.protocol.IPeer;
+import org.eclipse.tcf.protocol.Protocol;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
+import org.eclipse.tcf.te.tcf.locator.model.Model;
+import org.eclipse.tcf.te.tcf.ui.controls.PeerNameControl;
+import org.eclipse.tcf.te.tcf.ui.nls.Messages;
+import org.eclipse.tcf.te.ui.controls.validator.RegexValidator;
+import org.eclipse.tcf.te.ui.controls.validator.Validator;
+import org.eclipse.tcf.te.ui.forms.CustomFormToolkit;
+import org.eclipse.tcf.te.ui.forms.parts.AbstractSection;
+import org.eclipse.tcf.te.ui.interfaces.data.IDataExchangeNode;
+import org.eclipse.tcf.te.ui.swt.SWTControlUtil;
+import org.eclipse.tcf.te.ui.wizards.pages.AbstractFormsWizardPage;
+import org.eclipse.ui.forms.IManagedForm;
+
+/**
+ * Abstract new configuration wizard page implementation.
+ */
+public abstract class AbstractConfigWizardPage extends AbstractFormsWizardPage implements IDataExchangeNode {
+ private ConfigNameControl configName = null;
+ private AbstractSection selectorSection = null;
+ private AbstractSection detailsSection = null;
+ /* default */ Button launchDbg = null;
+ private Button advancedButton = null;
+
+ /* default */ boolean autoLaunchDbg = true;
+
+ // The list of existing configuration names. Used to generate a unique name
+ // and validate the wizard
+ /* default */ final java.util.List<String> usedNames = new ArrayList<String>();
+
+ /**
+ * Internal configuration name control implementation.
+ */
+ protected static class ConfigNameControl extends PeerNameControl {
+
+ /**
+ * Constructor.
+ * @param parentPage The parent dialog page this control is embedded in.
+ * Might be <code>null</code> if the control is not associated with a page.
+ */
+ public ConfigNameControl(IDialogPage parentPage) {
+ super(parentPage);
+
+ setEditFieldLabel(Messages.AbstractConfigWizardPage_configName_label);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl#doCreateEditFieldValidator()
+ */
+ @Override
+ protected Validator doCreateEditFieldValidator() {
+ return new RegexValidator(Validator.ATTR_MANDATORY, ".*"); //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl#configureEditFieldValidator(org.eclipse.tcf.te.ui.controls.validator.Validator)
+ */
+ @Override
+ protected void configureEditFieldValidator(Validator validator) {
+ if (validator instanceof RegexValidator) {
+ validator.setMessageText(RegexValidator.INFO_MISSING_VALUE, Messages.AbstractConfigWizardPage_configName_infoMissingValue);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl#isValid()
+ */
+ @Override
+ public boolean isValid() {
+ boolean valid = true;
+
+ String name = getEditFieldControlTextForValidation();
+ if (!"".equals(name)) { //$NON-NLS-1$
+ // Name is not empty -> check against the list of used names
+ if (getParentPage() instanceof AbstractConfigWizardPage) {
+ valid = !((AbstractConfigWizardPage)getParentPage()).usedNames.contains(name.trim().toUpperCase());
+ if (!valid) {
+ setMessage(Messages.AbstractConfigWizardPage_configName_nameInUse, IMessageProvider.ERROR);
+ }
+ }
+ }
+
+ return valid ? super.isValid() : false;
+ }
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param pageName The page name. Must not be <code>null</code>.
+ */
+ public AbstractConfigWizardPage(String pageName) {
+ super(pageName);
+
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param pageName The page name. Must not be <code>null</code>.
+ * @param title The wizard page title or <code>null</code>.
+ * @param titleImage The wizard page title image or <code>null</code>.
+ */
+ public AbstractConfigWizardPage(String pageName, String title, ImageDescriptor titleImage) {
+ super(pageName, title, titleImage);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.DialogPage#dispose()
+ */
+ @Override
+ public void dispose() {
+ if (configName != null) { configName.dispose(); configName = null; }
+ if (selectorSection != null) { selectorSection.dispose(); selectorSection = null; }
+ if (detailsSection != null) { detailsSection.dispose(); detailsSection = null; }
+
+ super.dispose();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.wizards.pages.AbstractFormsWizardPage#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);
+
+ // Add the controls
+ configName = new ConfigNameControl(this);
+ configName.setupPanel(parent);
+
+ Label label = new Label(parent, SWT.HORIZONTAL | SWT.SEPARATOR);
+ label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+ selectorSection = doCreateSelectorSection(getManagedForm(), parent);
+ if (selectorSection != null) {
+ selectorSection.getSection().setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
+ }
+
+ detailsSection = doCreateDetailsSection(getManagedForm(), parent);
+ if (detailsSection != null) {
+ detailsSection.getSection().setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
+ }
+
+ launchDbg = new Button(parent, SWT.CHECK);
+ launchDbg.setText(Messages.AbstractConfigWizardPage_launchDbg_label);
+ launchDbg.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ launchDbg.setSelection(autoLaunchDbg);
+ launchDbg.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ autoLaunchDbg = SWTControlUtil.getSelection(launchDbg);
+ }
+ });
+
+ if (hasAdvancedButton()) {
+ advancedButton = new Button(parent, SWT.PUSH);
+ advancedButton.setText(" " + Messages.AbstractConfigWizardPage_advancedButton_label + " "); //$NON-NLS-1$ //$NON-NLS-2$
+ advancedButton.setLayoutData(new GridData(SWT.END, SWT.CENTER, true, false));
+ advancedButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ onAdvancedButtonSelected();
+ }
+ });
+ }
+
+ // restore the widget values from the history
+ restoreWidgetValues();
+
+ // Initialize the used configuration name list
+ initializeUsedNameList();
+ }
+
+ /**
+ * Creates the selector section.
+ *
+ * @param form The managed form instance. Must not be <code>null</code>.
+ * @param parent The parent composite. Must not be <code>null</code>.
+ *
+ * @return The selector section instance or <code>null</code>.
+ */
+ protected abstract AbstractSection doCreateSelectorSection(IManagedForm form, Composite parent);
+
+ /**
+ * Returns the selector section instance.
+ *
+ * @return The selector section instance or <code>null</code> if not yet created.
+ */
+ protected final AbstractSection getSelectorSection() {
+ return selectorSection;
+ }
+
+ /**
+ * Creates the details section.
+ *
+ * @param form The managed form instance. Must not be <code>null</code>.
+ * @param parent The parent composite. Must not be <code>null</code>.
+ *
+ * @return The details section instance or <code>null</code>.
+ */
+ protected abstract AbstractSection doCreateDetailsSection(IManagedForm form, Composite parent);
+
+ /**
+ * Returns the details section instance.
+ *
+ * @return The details section instance or <code>null</code> if not yet created.
+ */
+ protected final AbstractSection getDetailsSection() {
+ return detailsSection;
+ }
+
+ /**
+ * Returns if or if not the page should show an advanced button.
+ *
+ * @return <code>True</code> if the page has an advanced button, <code>false</code> if not.
+ */
+ protected boolean hasAdvancedButton() {
+ return false;
+ }
+
+ /**
+ * Called once the user pressed the advanced button. Subclasses
+ * needs to overwrite this method to provide the logic behind the
+ * advanced button if {@link #hasAdvancedButton()} returned <code>true</code>.
+ */
+ protected void onAdvancedButtonSelected() {
+ }
+
+ /**
+ * Returns the peer type.
+ *
+ * @return The peer type. Never <code>null</code>.
+ */
+ protected abstract String getPeerType();
+
+ /**
+ * Returns the default configuration name template.
+ *
+ * @return The default configuration name template. Never <code>null</code>.
+ */
+ protected abstract String getDefaultConfigNameTemplate();
+
+ /**
+ * Return the pattern that matches a configuration name with
+ * the default name. The pattern is used to decide if the user
+ * modified the configuration name or not.
+ *
+ * @param The default configuration name template. Must not be <code>null</code>.
+ * @return The default configuration name pattern. Never <code>null</code>.
+ */
+ protected abstract String getDefaultConfigNamePattern(String template);
+
+ /**
+ * Initialize the used name list.
+ */
+ protected void initializeUsedNameList() {
+ usedNames.clear();
+
+ Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ // Get all peer model objects
+ IPeerModel[] peers = Model.getModel().getPeers();
+ // Loop them and find the ones which are of our handled types
+ for (IPeerModel peerModel : peers) {
+ if (peerModel.isStatic()) {
+ String name = peerModel.getPeer().getName();
+ Assert.isNotNull(name);
+ if (!"".equals(name) && !usedNames.contains(name)) { //$NON-NLS-1$
+ usedNames.add(name.trim().toUpperCase());
+ }
+ }
+ }
+ }
+ };
+
+ Assert.isTrue(!Protocol.isDispatchThread());
+ Protocol.invokeAndWait(runnable);
+ }
+
+ /**
+ * Auto-generate a configuration name.
+ *
+ * @param customID The custom ID to bind with the default configuration name template, or <code>null</code>.
+ */
+ public void autoGenerateConfigurationName(String customID) {
+ // Get the default configuration name template
+ String template = getDefaultConfigNameTemplate();
+ Assert.isNotNull(template);
+ // If the user modified the configuration name, we have to leave it alone.
+ String pattern = getDefaultConfigNamePattern(template);
+ Assert.isNotNull(pattern);
+ String currentName = configName != null ? configName.getEditFieldControlText().trim() : null;
+ if (currentName != null && !"".equals(currentName.trim()) && !currentName.matches(pattern)) { //$NON-NLS-1$
+ return;
+ }
+ // Generate a new proposal
+ final String origProposedName = NLS.bind(template, customID != null ? customID : ""); //$NON-NLS-1$
+ String proposedName = origProposedName;
+
+ // Unify the proposed name to avoid duplicated configuration names
+ int count = 0;
+ while (usedNames.contains(proposedName.trim().toUpperCase())) {
+ count++;
+ proposedName = origProposedName.trim() + " (" + count + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ // Set the configuration name
+ if (configName != null) {
+ configName.setEditFieldControlText(proposedName.trim());
+ }
+ }
+
+ /**
+ * Returns if or if not to auto-start the debugger after the configuration got created.
+ *
+ * @return <code>True</code> to auto-start the debugger, <code>false</code> if not.
+ */
+ public final boolean isAutoStartDebugger() {
+ return autoLaunchDbg;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.wizards.pages.AbstractValidatingWizardPage#doValidate()
+ */
+ @Override
+ protected ValidationResult doValidate() {
+ ValidationResult result = new ValidationResult();
+
+ boolean valid = true;
+
+ if (configName != null) {
+ valid &= configName.isValid();
+ result.setResult(configName);
+ }
+
+ if (selectorSection != null) {
+ valid &= selectorSection.isValid();
+ result.setResult(selectorSection);
+ }
+
+ if (detailsSection != null) {
+ valid &= detailsSection.isValid();
+ result.setResult(detailsSection);
+ }
+
+ result.setValid(valid);
+
+ return result;
+ }
+
+ /* (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) {
+ }
+
+ /**
+ * Updates the given attributes properties container with the current control content.
+ *
+ * @param peerAttributes The peer attributes. Must not be <code>null</code>.
+ */
+ protected void updatePeerAttributes(IPropertiesContainer peerAttributes) {
+ Assert.isNotNull(peerAttributes);
+
+ // If the page has been never shown, we are done here
+ if (getControl() == null) {
+ return;
+ }
+
+ String value = configName != null ? configName.getEditFieldControlText() : null;
+ if (value != null && !"".equals(value)) { //$NON-NLS-1$
+ peerAttributes.setProperty(IPeer.ATTR_NAME, value);
+ }
+
+ if (isAutoStartDebugger()) {
+ peerAttributes.setProperty(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProperties.PROP_AUTO_START_DEBUGGER, true);
+ }
+
+ if (selectorSection != null) {
+ updateAttribute(selectorSection, peerAttributes);
+ }
+ if (detailsSection != null) {
+ updateAttribute(detailsSection, peerAttributes);
+ }
+ }
+
+ /**
+ * Update the given attributes properties container with the section
+ * attributes.
+ *
+ * @param section The section. Must not be <code>null</code>.
+ * @param peerAttributes The peer attributes. Must not be <code>null</code>.
+ */
+ protected abstract void updateAttribute(AbstractSection section, IPropertiesContainer peerAttributes);
+
+ /* (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) {
+ Assert.isNotNull(data);
+ // Update with the current control content
+ updatePeerAttributes(data);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.wizards.pages.AbstractWizardPage#saveWidgetValues()
+ */
+ @Override
+ public void saveWidgetValues() {
+ super.saveWidgetValues();
+
+ IDialogSettings settings = getDialogSettings();
+ if (settings != null) {
+ if (selectorSection != null) {
+ selectorSection.saveWidgetValues(settings);
+ }
+ if (detailsSection != null) {
+ detailsSection.saveWidgetValues(settings);
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.wizards.pages.AbstractWizardPage#restoreWidgetValues()
+ */
+ @Override
+ public void restoreWidgetValues() {
+ super.restoreWidgetValues();
+
+ IDialogSettings settings = getDialogSettings();
+ if (settings != null) {
+ if (selectorSection != null) {
+ selectorSection.restoreWidgetValues(settings);
+ }
+ if (detailsSection != null) {
+ detailsSection.restoreWidgetValues(settings);
+ }
+ }
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.swt/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.ui.swt/META-INF/MANIFEST.MF
index fab3a180f..4afe37764 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.swt/META-INF/MANIFEST.MF
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.swt/META-INF/MANIFEST.MF
@@ -16,5 +16,5 @@ Export-Package: org.eclipse.tcf.te.ui.jface.dialogs,
org.eclipse.tcf.te.ui.swt,
org.eclipse.tcf.te.ui.swt.activator;x-internal:=true,
org.eclipse.tcf.te.ui.swt.listener,
- org.eclipse.tcf.te.ui.swt.nls;x-internal:=true,
+ org.eclipse.tcf.te.ui.swt.nls,
org.eclipse.tcf.te.ui.swt.widgets
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/dialogs/AbstractSectionDialog.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/dialogs/AbstractSectionDialog.java
new file mode 100644
index 000000000..6131fe1cb
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/dialogs/AbstractSectionDialog.java
@@ -0,0 +1,295 @@
+/*******************************************************************************
+ * Copyright (c) 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.dialogs;
+
+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.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
+import org.eclipse.tcf.te.runtime.properties.PropertiesContainer;
+import org.eclipse.tcf.te.ui.activator.UIPlugin;
+import org.eclipse.tcf.te.ui.forms.CustomFormToolkit;
+import org.eclipse.tcf.te.ui.forms.FormLayoutFactory;
+import org.eclipse.tcf.te.ui.forms.parts.AbstractSection;
+import org.eclipse.tcf.te.ui.interfaces.data.IDataExchangeNode;
+import org.eclipse.tcf.te.ui.jface.dialogs.CustomTitleAreaDialog;
+import org.eclipse.tcf.te.ui.jface.interfaces.IValidatingContainer;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.ManagedForm;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+
+/**
+ * Section dialog implementation.
+ */
+public abstract class AbstractSectionDialog extends CustomTitleAreaDialog implements IValidatingContainer, IDataExchangeNode {
+ // References to the sections
+ private AbstractSection[] sections = null;
+
+ private IPropertiesContainer data = null;
+ private final boolean readOnly;
+ private final String dialogTitle;
+ private final String title;
+ private final String message;
+
+ /**
+ * Constructor.
+ *
+ * @param form The managed form.
+ * @param dialogTitle The dialog window title.
+ * @param title The title area title.
+ * @param readOnly <code>True</code> to open the dialog in read-only mode, <code>false</code> otherwise.
+ * @param contextHelpId The context help id or <code>null</code>.
+ */
+ public AbstractSectionDialog(Shell shell, String dialogTitle, String title, String message, boolean readOnly, String contextHelpId) {
+ super(shell, contextHelpId);
+
+ this.dialogTitle = dialogTitle;
+ this.title = title;
+ this.message = message;
+ this.readOnly = readOnly;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.jface.dialogs.CustomTrayDialog#doGetDialogSettingsToInitialize()
+ */
+ @Override
+ protected IDialogSettings doGetDialogSettingsToInitialize() {
+ return UIPlugin.getDefault().getDialogSettings();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#getDialogBoundsSettings()
+ */
+ @Override
+ protected IDialogSettings getDialogBoundsSettings() {
+ return super.getDialogSettings();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#isResizable()
+ */
+ @Override
+ protected boolean isResizable() {
+ return true;
+ }
+
+ /**
+ * Create the sections for this dialog.
+ * @param form The managed form.
+ * @param parent The parent composite.
+ * @return The sections.
+ */
+ protected abstract AbstractSection[] createSections(IManagedForm form, Composite parent);
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.jface.dialogs.CustomTitleAreaDialog#createDialogAreaContent(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected void createDialogAreaContent(Composite parent) {
+ super.createDialogAreaContent(parent);
+
+ setDialogTitle(dialogTitle);
+ setTitle(title);
+ setMessage(message);
+
+ FormToolkit toolkit = new FormToolkit(getShell().getDisplay());
+ ScrolledForm scrolledForm = new CustomFormToolkit(toolkit).createScrolledForm(parent, null, true);
+ scrolledForm.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ scrolledForm.getBody().setLayout(FormLayoutFactory.createClearGridLayout(false, 1));
+
+ IManagedForm form = new ManagedForm(toolkit, scrolledForm) {
+ @Override
+ public void dirtyStateChanged() {
+ validate();
+ }
+ @Override
+ public void staleStateChanged() {
+ validate();
+ }
+ };
+
+ sections = createSections(form, scrolledForm.getBody());
+ if (sections != null) {
+ for (AbstractSection section : sections) {
+ section.setReadOnly(readOnly);
+ form.addPart(section);
+ }
+ }
+
+ restoreWidgetValues();
+ if (data != null && sections != null) {
+ for (AbstractSection section : sections) {
+ if (section instanceof IDataExchangeNode) {
+ ((IDataExchangeNode)section).setupData(data);
+ }
+ }
+ }
+
+ applyDialogFont(scrolledForm.getBody());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.jface.dialogs.CustomTrayDialog#getDialogSettingsSectionName()
+ */
+ @Override
+ public String getDialogSettingsSectionName() {
+ String name = getClass().getSimpleName();
+ Class<?> enclosing = getClass().getEnclosingClass();
+ while ((name == null || name.trim().length() == 0) && enclosing != null) {
+ name = enclosing.getSimpleName();
+ enclosing = getClass().getEnclosingClass();
+ }
+
+ return (name != null && name.trim().length() > 0) ? name : "SectionDialog"; //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.TitleAreaDialog#createContents(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Control createContents(Composite parent) {
+ Control control = super.createContents(parent);
+ validate();
+ return control;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.TitleAreaDialog#getInitialSize()
+ */
+ @Override
+ protected final Point getInitialSize() {
+ return adjustInitialSize(super.getInitialSize());
+ }
+
+ /**
+ * Adjust the initial size of the dialog.
+ *
+ * @param size The current initial size. Must not be <code>null</code>.
+ * @return The new initial size.
+ */
+ protected Point adjustInitialSize(Point size) {
+ Assert.isNotNull(size);
+ return size;
+ }
+
+ /* (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) {
+ Assert.isNotNull(data);
+
+ this.data = new PropertiesContainer();
+ this.data.setProperties(data.getProperties());
+
+ if (sections != null) {
+ for (AbstractSection section : sections) {
+ if (section instanceof IDataExchangeNode) {
+ ((IDataExchangeNode)section).setupData(data);
+ }
+ else if (Platform.inDebugMode()){
+ Platform.getLog(UIPlugin.getDefault().getBundle()).log(new Status(IStatus.WARNING,
+ UIPlugin.getUniqueIdentifier(),
+ "Section "+section.getClass().getName()+" does not implement IDataExchangeNode!")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ }
+ }
+
+ /* (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) {
+ Assert.isNotNull(data);
+ data.setProperties(this.data.getProperties());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.jface.dialogs.CustomTrayDialog#okPressed()
+ */
+ @Override
+ protected void okPressed() {
+ // Extract the properties from the logging section
+ if (data == null) {
+ data = new PropertiesContainer();
+ }
+ if (sections != null) {
+ for (AbstractSection section : sections) {
+ if (section instanceof IDataExchangeNode) {
+ ((IDataExchangeNode)section).extractData(data);
+ }
+ else if (Platform.inDebugMode()){
+ Platform.getLog(UIPlugin.getDefault().getBundle()).log(new Status(IStatus.WARNING,
+ UIPlugin.getUniqueIdentifier(),
+ "Section "+section.getClass().getName()+" does not implement IDataExchangeNode!")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ }
+
+ super.okPressed();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.jface.dialogs.CustomTrayDialog#restoreWidgetValues()
+ */
+ @Override
+ protected void restoreWidgetValues() {
+ super.restoreWidgetValues();
+ if (sections != null) {
+ for (AbstractSection section : sections) {
+ section.restoreWidgetValues(getDialogSettings());
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.jface.dialogs.CustomTrayDialog#saveWidgetValues()
+ */
+ @Override
+ protected void saveWidgetValues() {
+ super.saveWidgetValues();
+ if (sections != null) {
+ for (AbstractSection section : sections) {
+ section.saveWidgetValues(getDialogSettings());
+ }
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.jface.interfaces.IValidatingContainer#validate()
+ */
+ @Override
+ public void validate() {
+ boolean valid = true;
+ if (sections != null) {
+ for (AbstractSection section : sections) {
+ valid &= section.isValid();
+ setMessage(section.getMessage(), section.getMessageType());
+ }
+ if (!isMessageSet()) {
+ setMessage(message);
+ }
+ }
+ if (getButton(IDialogConstants.OK_ID) != null) {
+ getButton(IDialogConstants.OK_ID).setEnabled(!readOnly && valid);
+ }
+ }
+}

Back to the top