null
.
- */
- public AddPeerDialog(Shell parent, String contextHelpId) {
- super(parent, contextHelpId);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tm.te.tcf.ide.target.ui.dialogs.WRUnifiedTitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
- */
- @Override
- protected Control createDialogArea(Composite parent) {
- Composite composite = (Composite)super.createDialogArea(parent);
-
- configureTitles();
-
- Composite panel = new Composite(composite, SWT.NONE);
- panel.setLayout(new GridLayout(2, false));
- panel.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- // Add the controls
- Label label = new Label(panel, SWT.NONE);
- label.setText(Messages.TransportTypeControl_label);
-
- fTransportTypeControl = new Combo(panel, SWT.READ_ONLY);
- fTransportTypeControl.setItems(new String[] { "TCP" }); //$NON-NLS-1$
- fTransportTypeControl.select(0);
- fTransportTypeControl.setEnabled(false);
- fTransportTypeControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- label = new Label(panel, SWT.NONE);
- label.setText(Messages.AgentHostControl_label);
-
- fAddressControl = new Text(panel, SWT.SINGLE | SWT.BORDER);
- fAddressControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- fAddressControl.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- updatePeerId();
- }
- });
-
- label = new Label(panel, SWT.NONE);
- label.setText(Messages.AgentPortControl_label);
-
- fPortControl = new Text(panel, SWT.SINGLE | SWT.BORDER);
- fPortControl.setText("1534"); //$NON-NLS-1$
- fPortControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- fPortControl.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- updatePeerId();
- }
- });
-
- label = new Label(panel, SWT.NONE);
- label.setText(Messages.PeerIdControl_label);
-
- fPeerIdControl = new Text(panel, SWT.SINGLE | SWT.BORDER);
- fPeerIdControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- label = new Label(panel, SWT.NONE);
- label.setText(Messages.PeerNameControl_label);
-
- fPeerNameControl = new Text(panel, SWT.SINGLE | SWT.BORDER);
- fPeerNameControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // Setup the control content
- setupContent();
-
- // Adjust the font
- applyDialogFont(composite);
-
- return composite;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.TrayDialog#createButtonBar(org.eclipse.swt.widgets.Composite)
- */
- @Override
- protected Control createButtonBar(Composite parent) {
- Control control = super.createButtonBar(parent);
- validateDialog();
- return control;
- }
-
- /**
- * Configure the dialog title and the title area content. The method
- * is called from {@link #createDialogArea(Composite)}.
- */
- protected void configureTitles() {
- setDialogTitle(Messages.AddPeerDialog_title);
- }
-
- /**
- * Setup the control content.
- */
- protected void setupContent() {
- restoreWidgetValues();
- updatePeerId();
- }
-
- /**
- * Update peer id control.
- */
- protected void updatePeerId() {
- String address = fAddressControl.getText();
- String port = fPortControl.getText();
- String type = fTransportTypeControl.getText();
-
- if (!"".equals(address) && !"".equals(port)) { //$NON-NLS-1$ //$NON-NLS-2$
- fPeerIdControl.setText(type + ":" //$NON-NLS-1$
- + address + ":" //$NON-NLS-1$
- + port);
- } else {
- fPeerIdControl.setText(""); //$NON-NLS-1$
- }
-
- validateDialog();
- }
-
- /**
- * Validates the dialog.
- */
- protected void validateDialog() {
- boolean valid = true;
-
- if ("".equals(fAddressControl.getText()) || "".equals(fPortControl)) { //$NON-NLS-1$ //$NON-NLS-2$
- valid = false;
- }
-
- if (getButton(IDialogConstants.OK_ID) != null)
- getButton(IDialogConstants.OK_ID).setEnabled(valid);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#cancelPressed()
- */
- @Override
- protected void cancelPressed() {
- // Dispose the peer attributes
- fPeerAttributes = null;
-
- super.cancelPressed();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tm.te.tcf.ide.target.ui.dialogs.WRUnifiedTitleAreaDialog#okPressed()
- */
- @Override
- protected void okPressed() {
- saveWidgetValues();
-
- // Create a new peer attributes map
- fPeerAttributes = new HashMapnull
if canceled.
- */
- public final Mapnull
.
+ */
+ public NewRemoteTargetWizardPage(String pageName) {
+ super(pageName);
+ }
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+ // Setup title and description
+ setTitle(Messages.NewRemoteTargetWizardPage_title);
+ setDescription(Messages.NewRemoteTargetWizardPage_description);
+
+ // Create the main panel
+ Composite mainPanel = new Composite(parent, SWT.NONE);
+ mainPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ mainPanel.setLayout(new GridLayout());
+
+ setControl(mainPanel);
+
+ // Setup the help
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(mainPanel, IContextHelpIds.NEW_REMOTE_TARGET_WIZARD_PAGE);
+
+ // Create the main panel sub controls
+ createMainPanelControls(mainPanel);
+
+ // Adjust the font
+ Dialog.applyDialogFont(mainPanel);
+ }
+
+ /**
+ * Creates the main panel sub controls.
+ *
+ * @param parent The parent main panel composite. Must not be null
.
+ */
+ protected void createMainPanelControls(Composite parent) {
+ Assert.isNotNull(parent);
+
+ Composite panel = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout(2, false);
+ layout.marginHeight = 0; layout.marginWidth = 0;
+ panel.setLayout(layout);
+ panel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+ // Add the controls
+ Label label = new Label(panel, SWT.NONE);
+ label.setText(Messages.NewRemoteTargetWizardPage_TransportTypeControl_label);
+
+ fTransportTypeControl = new Combo(panel, SWT.READ_ONLY);
+ fTransportTypeControl.setItems(new String[] { "TCP" }); //$NON-NLS-1$
+ fTransportTypeControl.select(0);
+ fTransportTypeControl.setEnabled(false);
+ fTransportTypeControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ label = new Label(panel, SWT.NONE);
+ label.setText(Messages.NewRemoteTargetWizardPage_AgentHostControl_label);
+
+ fAddressControl = new Text(panel, SWT.SINGLE | SWT.BORDER);
+ fAddressControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ fAddressControl.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ updatePeerId();
+ }
+ });
+
+ label = new Label(panel, SWT.NONE);
+ label.setText(Messages.NewRemoteTargetWizardPage_AgentPortControl_label);
+
+ fPortControl = new Text(panel, SWT.SINGLE | SWT.BORDER);
+ fPortControl.setText("1534"); //$NON-NLS-1$
+ fPortControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ fPortControl.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ updatePeerId();
+ }
+ });
+
+ label = new Label(panel, SWT.NONE);
+ label.setText(Messages.NewRemoteTargetWizardPage_PeerIdControl_label);
+
+ fPeerIdControl = new Text(panel, SWT.SINGLE | SWT.BORDER);
+ fPeerIdControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ label = new Label(panel, SWT.NONE);
+ label.setText(Messages.NewRemoteTargetWizardPage_PeerNameControl_label);
+
+ fPeerNameControl = new Text(panel, SWT.SINGLE | SWT.BORDER);
+ fPeerNameControl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ // Restore the page history and trigger
+ // an update of the peer id
+ setupContent();
+ }
+
+ /**
+ * Setup the control content.
+ */
+ protected void setupContent() {
+ restoreWidgetValues();
+ updatePeerId();
+ }
+
+ /**
+ * Update peer id control.
+ */
+ protected void updatePeerId() {
+ String address = fAddressControl.getText();
+ String port = fPortControl.getText();
+ String type = fTransportTypeControl.getText();
+
+ if (!"".equals(address) && !"".equals(port)) { //$NON-NLS-1$ //$NON-NLS-2$
+ fPeerIdControl.setText(type + ":" //$NON-NLS-1$
+ + address + ":" //$NON-NLS-1$
+ + port);
+ } else {
+ fPeerIdControl.setText(""); //$NON-NLS-1$
+ }
+
+ validatePage();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tm.te.ui.wizards.pages.AbstractWizardPage#validatePage()
+ */
+ @Override
+ public void validatePage() {
+ boolean valid = true;
+
+ if ("".equals(fAddressControl.getText()) || "".equals(fPortControl)) { //$NON-NLS-1$ //$NON-NLS-2$
+ valid = false;
+ }
+
+ setPageComplete(valid);
+ }
+
+ /**
+ * Updates the given attributes map with the current control content.
+ *
+ * @param peerAttributes The peer attributes map to update. Must not be null
.
+ */
+ protected void updatePeerAttributes(Mapnull
if canceled.
+ */
+ public final Map+ * This wizard implementation is adding dialog settings management. + */ +public abstract class AbstractWizard extends Wizard { + // A marker to remember if the dialog settings got + // initialized for this wizard + private boolean fDialogSettingsInitialized = false; + + /** + * Initialize the dialog settings and associate them with the wizard. + */ + private final void initializeDialogSettings() { + // Get the root dialog settings + IDialogSettings rootSettings = getRootDialogSettings(); + // Get the wizards dialog settings section + IDialogSettings section = rootSettings.getSection(getWizardSectionName()); + if (section == null) { + // The section does not exist -> create it + section = rootSettings.addNewSection(getWizardSectionName()); + } + // Push the section to the wizard + setDialogSettings(section); + // Mark the dialog settings initialized + fDialogSettingsInitialized = true; + } + + /** + * Returns the root dialog settings. + *
+ * Typically, this are the dialog settings of the parent bundle. The
+ * default implementation returns the dialog settings of the bundle
+ * "org.eclipse.tm.te.ui
". Overwrite to return
+ * different root dialog settings.
+ *
+ * @return The root dialog settings.
+ */
+ protected IDialogSettings getRootDialogSettings() {
+ return UIPlugin.getDefault().getDialogSettings();
+ }
+
+ /**
+ * Returns the name of the wizards associated dialog settings
+ * section.
+ *
+ * The default implementation returns the simple name of the + * implementation class. + * + * @return The name of the wizards dialog settings section. + */ + protected String getWizardSectionName() { + return getClass().getSimpleName(); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.wizard.Wizard#getDialogSettings() + */ + @Override + public IDialogSettings getDialogSettings() { + if (!fDialogSettingsInitialized) { + initializeDialogSettings(); + } + return super.getDialogSettings(); + } +} diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui/src/org/eclipse/tm/te/ui/wizards/pages/AbstractWizardPage.java b/target_explorer/plugins/org.eclipse.tm.te.ui/src/org/eclipse/tm/te/ui/wizards/pages/AbstractWizardPage.java new file mode 100644 index 000000000..69b295540 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tm.te.ui/src/org/eclipse/tm/te/ui/wizards/pages/AbstractWizardPage.java @@ -0,0 +1,103 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Uwe Stieber (Wind River) - initial API and implementation + *******************************************************************************/ +package org.eclipse.tm.te.ui.wizards.pages; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.ui.PlatformUI; + +/** + * An abstract common wizard page implementation. + *
+ * This wizard page implementation is adding control history management
+ * and link the page with the context help system.
+ */
+public abstract class AbstractWizardPage extends WizardPage {
+ // The context help id of the wizard page
+ private String fContextHelpId = null;
+
+ /**
+ * Constructor.
+ *
+ * @param pageName The page name. Must not be null
.
+ */
+ public AbstractWizardPage(String pageName) {
+ super(pageName);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param pageName The page name. Must not be null
.
+ * @param title The wizard page title or null
.
+ * @param titleImage The wizard page title image or null
.
+ */
+ public AbstractWizardPage(String pageName, String title, ImageDescriptor titleImage) {
+ super(pageName, title, titleImage);
+ }
+
+ /**
+ * Set the wizard page context help id.
+ *
+ * If set to non null
, than the help id is associated
+ * with the pages control once subclasses calls {@link #setControl(org.eclipse.swt.widgets.Control)}.
+ *
+ * @param contextHelpId The context help id or null
if none.
+ */
+ protected final void setContextHelpId(String contextHelpId) {
+ fContextHelpId = contextHelpId;
+ }
+
+ /**
+ * Returns the wizard page context help id.
+ *
+ * @return The context help id or null
if none.
+ */
+ protected final String getContextHelpId() {
+ return fContextHelpId;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.DialogPage#performHelp()
+ */
+ @Override
+ public void performHelp() {
+ String contextHelpId = getContextHelpId();
+ if (contextHelpId != null) {
+ PlatformUI.getWorkbench().getHelpSystem().displayHelp(contextHelpId);
+ }
+ }
+
+ /**
+ * Saves the widget history of all UI elements of the page.
+ */
+ public void saveWidgetValues() {
+ }
+
+ /**
+ * Restores the widget history of all UI elements of the page.
+ */
+ public void restoreWidgetValues() {
+ }
+
+ /**
+ * Validates the page status.
+ *
+ * If necessary, set corresponding messages and message types to signal if some + * control on the page needs attention. + *
+ * Depending on the outcome of the page data validation, call {@link WizardPage#setPageComplete(boolean)}
+ * with either true
or false
to signal if the wizard
+ * can finish given the current page data or not.
+ */
+ public void validatePage() {
+ }
+
+}
--
cgit v1.2.3