From 1872071ffb080b222581a39ca6ddf5d714e86889 Mon Sep 17 00:00:00 2001 From: ustieber Date: Thu, 12 May 2011 11:02:19 +0000 Subject: Target Explorer: Rework "Add Peer..." dialog action to become a regular common navigator new wizard --- .../icons/dtool16/newRemoteTarget_wiz.gif | Bin 0 -> 152 bytes .../icons/dtool16/newconnection_wiz.gif | Bin 202 -> 0 bytes .../icons/etool16/newRemoteTarget_wiz.gif | Bin 0 -> 940 bytes .../icons/etool16/newconnection_wiz.gif | Bin 328 -> 0 bytes .../org.eclipse.tm.te.tcf.ui/plugin.properties | 16 +- .../plugins/org.eclipse.tm.te.tcf.ui/plugin.xml | 59 ++--- .../te/tcf/ui/internal/dialogs/AddPeerDialog.java | 267 --------------------- .../ui/internal/handler/AddPeerCommandHandler.java | 107 --------- .../te/tcf/ui/internal/help/IContextHelpIds.java | 4 +- .../tm/te/tcf/ui/internal/nls/Messages.java | 20 +- .../tm/te/tcf/ui/internal/nls/Messages.properties | 18 +- .../ui/internal/wizards/NewRemoteTargetWizard.java | 115 +++++++++ .../wizards/pages/NewRemoteTargetWizardPage.java | 249 +++++++++++++++++++ .../plugins/org.eclipse.tm.te.ui.views/plugin.xml | 18 ++ .../views/internal/actions/NewActionProvider.java | 103 ++++++++ .../tm/te/ui/views/internal/nls/Messages.java | 2 + .../te/ui/views/internal/nls/Messages.properties | 4 + .../org.eclipse.tm.te.ui/META-INF/MANIFEST.MF | 7 +- .../plugins/org.eclipse.tm.te.ui/build.properties | 3 +- .../plugins/org.eclipse.tm.te.ui/plugin.properties | 4 + .../plugins/org.eclipse.tm.te.ui/plugin.xml | 14 ++ .../eclipse/tm/te/ui/wizards/AbstractWizard.java | 81 +++++++ .../tm/te/ui/wizards/pages/AbstractWizardPage.java | 103 ++++++++ 23 files changed, 751 insertions(+), 443 deletions(-) create mode 100644 target_explorer/plugins/org.eclipse.tm.te.tcf.ui/icons/dtool16/newRemoteTarget_wiz.gif delete mode 100644 target_explorer/plugins/org.eclipse.tm.te.tcf.ui/icons/dtool16/newconnection_wiz.gif create mode 100644 target_explorer/plugins/org.eclipse.tm.te.tcf.ui/icons/etool16/newRemoteTarget_wiz.gif delete mode 100644 target_explorer/plugins/org.eclipse.tm.te.tcf.ui/icons/etool16/newconnection_wiz.gif delete mode 100644 target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/dialogs/AddPeerDialog.java delete mode 100644 target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/handler/AddPeerCommandHandler.java create mode 100644 target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/wizards/NewRemoteTargetWizard.java create mode 100644 target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/wizards/pages/NewRemoteTargetWizardPage.java create mode 100644 target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/actions/NewActionProvider.java create mode 100644 target_explorer/plugins/org.eclipse.tm.te.ui/plugin.xml create mode 100644 target_explorer/plugins/org.eclipse.tm.te.ui/src/org/eclipse/tm/te/ui/wizards/AbstractWizard.java create mode 100644 target_explorer/plugins/org.eclipse.tm.te.ui/src/org/eclipse/tm/te/ui/wizards/pages/AbstractWizardPage.java (limited to 'target_explorer') diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/icons/dtool16/newRemoteTarget_wiz.gif b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/icons/dtool16/newRemoteTarget_wiz.gif new file mode 100644 index 000000000..fd7af8403 Binary files /dev/null and b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/icons/dtool16/newRemoteTarget_wiz.gif differ diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/icons/dtool16/newconnection_wiz.gif b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/icons/dtool16/newconnection_wiz.gif deleted file mode 100644 index 5d9eae9e5..000000000 Binary files a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/icons/dtool16/newconnection_wiz.gif and /dev/null differ diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/icons/etool16/newRemoteTarget_wiz.gif b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/icons/etool16/newRemoteTarget_wiz.gif new file mode 100644 index 000000000..5b0b25fbe Binary files /dev/null and b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/icons/etool16/newRemoteTarget_wiz.gif differ diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/icons/etool16/newconnection_wiz.gif b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/icons/etool16/newconnection_wiz.gif deleted file mode 100644 index 9f2b4acc7..000000000 Binary files a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/icons/etool16/newconnection_wiz.gif and /dev/null differ diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/plugin.properties b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/plugin.properties index 910ffda8c..3d656b10a 100644 --- a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/plugin.properties +++ b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/plugin.properties @@ -11,17 +11,17 @@ pluginName = Target Explorer, TCF UI Plug-in providerName = Eclipse.org +# ***** Wizards ***** + +NewPeerWizard.name=TCF Remote Target + # ***** Editor Pages ***** NodePropertiesEditorPage.name=General # ***** Command Contributions ***** -TcfDataSource.command.category.name=Target Explorer Commands (TCF) - -TcfDataSource.command.refresh.name=Refresh Command -TcfDataSource.command.refresh.label=Re&fresh -TcfDataSource.command.refresh.tooltip=Refresh +command.category.name=Target Explorer Commands (TCF) -TcfDataSource.command.addPeer.name=Add New Peer Command -TcfDataSource.command.addPeer.label=&New Peer... -TcfDataSource.command.addPeer.tooltip=Adds a new peer to the discovery view. +command.refresh.name=Refresh Command +command.refresh.label=Re&fresh +command.refresh.tooltip=Refresh diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/plugin.xml b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/plugin.xml index d78082a31..849edcefb 100644 --- a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/plugin.xml +++ b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/plugin.xml @@ -29,8 +29,27 @@ + + + + + + + + + + + + @@ -57,27 +76,6 @@ - - - - - - - - - - - - - + tooltip="%command.refresh.tooltip"> @@ -105,19 +103,13 @@ + name="%command.category.name"> - - + name="%command.refresh.name"> @@ -127,10 +119,5 @@ class="org.eclipse.tm.te.tcf.ui.internal.handler.RefreshCommandHandler" commandId="org.eclipse.tm.te.tcf.ui.command.refresh"> - - - diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/dialogs/AddPeerDialog.java b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/dialogs/AddPeerDialog.java deleted file mode 100644 index ab8446780..000000000 --- a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/dialogs/AddPeerDialog.java +++ /dev/null @@ -1,267 +0,0 @@ -/******************************************************************************* - * 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.tcf.ui.internal.dialogs; - -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.IDialogSettings; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Combo; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; -import org.eclipse.tm.tcf.protocol.IPeer; -import org.eclipse.tm.te.tcf.ui.internal.help.IContextHelpIds; -import org.eclipse.tm.te.tcf.ui.internal.nls.Messages; -import org.eclipse.tm.te.ui.dialogs.CustomTrayDialog; - - -/** - * Target Explorer: Add peer dialog implementation. - */ -public class AddPeerDialog extends CustomTrayDialog { - private Combo fTransportTypeControl; - private Text fAddressControl; - private Text fPortControl; - private Text fPeerIdControl; - private Text fPeerNameControl; - - private Map fPeerAttributes = null; - - /** - * Constructor. - * - * @param parent The parent shell used to view the dialog. - */ - public AddPeerDialog(Shell parent) { - this(parent, IContextHelpIds.ADD_PEER_DIALOG); - } - - /** - * Constructor. - * - * @param parent The parent shell used to view the dialog. - * @param contextHelpId The dialog context help id or 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 HashMap(); - // Update with the current control content - updatePeerAttributes(fPeerAttributes); - - super.okPressed(); - } - - /** - * Updates the given attributes map with the current control content. - */ - protected void updatePeerAttributes(Map peerAttributes) { - assert peerAttributes != null; - - peerAttributes.put(IPeer.ATTR_IP_HOST, fAddressControl.getText()); - peerAttributes.put(IPeer.ATTR_IP_PORT, fPortControl.getText()); - peerAttributes.put(IPeer.ATTR_ID, fPeerIdControl.getText()); - peerAttributes.put(IPeer.ATTR_NAME, fPeerNameControl.getText()); - peerAttributes.put(IPeer.ATTR_TRANSPORT_NAME, fTransportTypeControl.getText()); - } - - /** - * Returns the peer attributes. - * - * @return The peer attributes or null if canceled. - */ - public final Map getPeerAttributes() { - return fPeerAttributes; - } - - - /* (non-Javadoc) - * @see org.eclipse.tm.te.tcf.ide.target.ui.dialogs.WRUnifiedTitleAreaDialog#saveWidgetValues() - */ - protected void saveWidgetValues() { - IDialogSettings settings = getDialogSettings(); - if (settings != null) { - // The transport type control is not saved - settings.put(IPeer.ATTR_IP_HOST, fAddressControl.getText()); - settings.put(IPeer.ATTR_IP_PORT, fPortControl.getText()); - settings.put(IPeer.ATTR_ID, fPeerIdControl.getText()); - settings.put(IPeer.ATTR_NAME, fPeerNameControl.getText()); - } - } - - /* (non-Javadoc) - * @see org.eclipse.tm.te.tcf.ide.target.ui.dialogs.WRUnifiedTitleAreaDialog#restoreWidgetValues() - */ - protected void restoreWidgetValues() { - IDialogSettings settings = getDialogSettings(); - if (settings != null) { - // The transport type control is not restored - if (settings.get(IPeer.ATTR_IP_HOST) != null) fAddressControl.setText(settings.get(IPeer.ATTR_IP_HOST)); - if (settings.get(IPeer.ATTR_IP_PORT) != null) fPortControl.setText(settings.get(IPeer.ATTR_IP_PORT)); - if (settings.get(IPeer.ATTR_ID) != null) fPeerIdControl.setText(settings.get(IPeer.ATTR_ID)); - if (settings.get(IPeer.ATTR_NAME) != null) fPeerNameControl.setText(settings.get(IPeer.ATTR_NAME)); - } - } -} diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/handler/AddPeerCommandHandler.java b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/handler/AddPeerCommandHandler.java deleted file mode 100644 index de0f820d9..000000000 --- a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/handler/AddPeerCommandHandler.java +++ /dev/null @@ -1,107 +0,0 @@ -/******************************************************************************* - * 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.tcf.ui.internal.handler; - -import java.util.Map; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.tm.tcf.protocol.IChannel; -import org.eclipse.tm.tcf.protocol.IPeer; -import org.eclipse.tm.tcf.protocol.Protocol; -import org.eclipse.tm.te.tcf.core.Tcf; -import org.eclipse.tm.te.tcf.core.interfaces.IChannelManager; -import org.eclipse.tm.te.tcf.locator.interfaces.nodes.ILocatorModel; -import org.eclipse.tm.te.tcf.locator.interfaces.nodes.IPeerModel; -import org.eclipse.tm.te.tcf.locator.interfaces.services.ILocatorModelLookupService; -import org.eclipse.tm.te.tcf.ui.internal.dialogs.AddPeerDialog; -import org.eclipse.tm.te.tcf.ui.internal.model.Model; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.handlers.HandlerUtil; - - -/** - * Target Explorer: Adds a new peer to the TCF locator model. - */ -public class AddPeerCommandHandler extends AbstractHandler { - - /* (non-Javadoc) - * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) - */ - public Object execute(ExecutionEvent event) throws ExecutionException { - // Get the shell - Shell shell = HandlerUtil.getActiveShell(event); - // Open the dialog - AddPeerDialog dialog = new AddPeerDialog(shell); - if (dialog.open() == Window.OK) { - // Get the new peer attributes - final Map peerAttributes = dialog.getPeerAttributes(); - if (peerAttributes != null) { - // Try to connect to the peer - IChannel channel = null; - try { - IWorkbenchPart activePart = HandlerUtil.getActivePart(event); - IEditorPart editorPart = activePart != null ? (IEditorPart)activePart.getAdapter(IEditorPart.class) : null; - final ISelectionProvider selectionProvider = editorPart != null ? editorPart.getEditorSite().getSelectionProvider() : null; - - Tcf.getChannelManager().openChannel(peerAttributes, new IChannelManager.DoneOpenChannel() { - public void doneOpenChannel(Throwable error, IChannel channel) { - if (error == null) { - IPeer peer = channel.getRemotePeer(); - if (selectionProvider != null && peer != null) { - // OK, we have the peer instance now, for the rest, - // we need the locator model - ILocatorModel model = Model.getModel(); - if (model != null) { - final IPeerModel peerNode = model.getService(ILocatorModelLookupService.class).lkupPeerModelById(peer.getID()); - if (peerNode != null) { - PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { - public void run() { - selectionProvider.setSelection(new StructuredSelection(peerNode)); - } - }); - } - } - } - } - - channel.close(); - } - }); - } catch (Exception e) { - } finally { - // Close the channel again - if (channel != null) { - final IChannel finChannel = channel; - if (Protocol.isDispatchThread()) { - finChannel.close(); - } else { - Protocol.invokeAndWait(new Runnable() { - public void run() { - finChannel.close(); - } - }); - } - } - } - } - } - - return null; - } - -} diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/help/IContextHelpIds.java b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/help/IContextHelpIds.java index 6497cb459..cdd7b9a48 100644 --- a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/help/IContextHelpIds.java +++ b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/help/IContextHelpIds.java @@ -22,9 +22,9 @@ public interface IContextHelpIds { public final static String PREFIX = UIPlugin.getUniqueIdentifier() + "."; //$NON-NLS-1$ /** - * Add new peer dialog. + * New TCF remote target wizard main page. */ - public final static String ADD_PEER_DIALOG = PREFIX + "AddPeerDialog"; //$NON-NLS-1$ + public final static String NEW_REMOTE_TARGET_WIZARD_PAGE = PREFIX + "NewRemoteTargetWizardPage"; //$NON-NLS-1$ /** * Target Explorer details editor page: Node properties diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/nls/Messages.java b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/nls/Messages.java index e7267fb35..f0dadb93f 100644 --- a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/nls/Messages.java +++ b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/nls/Messages.java @@ -83,15 +83,13 @@ public class Messages extends NLS { public static String NodePropertiesLabelProvider_services_local; public static String NodePropertiesLabelProvider_services_remote; - public static String AddPeerDialog_title; - - public static String TransportTypeControl_label; - - public static String AgentHostControl_label; - - public static String AgentPortControl_label; - - public static String PeerIdControl_label; - - public static String PeerNameControl_label; + public static String NewRemoteTargetWizard_windowTitle; + + public static String NewRemoteTargetWizardPage_title; + public static String NewRemoteTargetWizardPage_description; + public static String NewRemoteTargetWizardPage_TransportTypeControl_label; + public static String NewRemoteTargetWizardPage_AgentHostControl_label; + public static String NewRemoteTargetWizardPage_AgentPortControl_label; + public static String NewRemoteTargetWizardPage_PeerIdControl_label; + public static String NewRemoteTargetWizardPage_PeerNameControl_label; } diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/nls/Messages.properties index 94fdbfa19..d656ee622 100644 --- a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/nls/Messages.properties +++ b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/nls/Messages.properties @@ -19,12 +19,12 @@ NodePropertiesLabelProvider_services_remote=Remote Services AddPeerDialog_title=Add New Peer -TransportTypeControl_label=Type: - -AgentHostControl_label=Host: - -AgentPortControl_label=Port: - -PeerIdControl_label=ID: - -PeerNameControl_label=Name: +NewRemoteTargetWizard_windowTitle=New Remote Target + +NewRemoteTargetWizardPage_title=New Remote Target +NewRemoteTargetWizardPage_description=Specify the attributes to connect to the remote target. +NewRemoteTargetWizardPage_TransportTypeControl_label=Type: +NewRemoteTargetWizardPage_AgentHostControl_label=Host: +NewRemoteTargetWizardPage_AgentPortControl_label=Port: +NewRemoteTargetWizardPage_PeerIdControl_label=ID: +NewRemoteTargetWizardPage_PeerNameControl_label=Name: diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/wizards/NewRemoteTargetWizard.java b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/wizards/NewRemoteTargetWizard.java new file mode 100644 index 000000000..15a306277 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/wizards/NewRemoteTargetWizard.java @@ -0,0 +1,115 @@ +/******************************************************************************* + * 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.tcf.ui.internal.wizards; + +import java.util.Map; + +import org.eclipse.jface.viewers.ISelectionProvider; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.wizard.IWizardPage; +import org.eclipse.tm.tcf.protocol.IChannel; +import org.eclipse.tm.tcf.protocol.IPeer; +import org.eclipse.tm.tcf.protocol.Protocol; +import org.eclipse.tm.te.tcf.core.Tcf; +import org.eclipse.tm.te.tcf.core.interfaces.IChannelManager; +import org.eclipse.tm.te.tcf.locator.interfaces.nodes.ILocatorModel; +import org.eclipse.tm.te.tcf.locator.interfaces.nodes.IPeerModel; +import org.eclipse.tm.te.tcf.locator.interfaces.services.ILocatorModelLookupService; +import org.eclipse.tm.te.tcf.ui.internal.model.Model; +import org.eclipse.tm.te.tcf.ui.internal.nls.Messages; +import org.eclipse.tm.te.tcf.ui.internal.wizards.pages.NewRemoteTargetWizardPage; +import org.eclipse.tm.te.ui.views.interfaces.IUIConstants; +import org.eclipse.tm.te.ui.wizards.AbstractWizard; +import org.eclipse.ui.INewWizard; +import org.eclipse.ui.IViewReference; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.PlatformUI; + +/** + * New TCF remote target wizard implementation. + */ +public class NewRemoteTargetWizard extends AbstractWizard implements INewWizard { + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection) + */ + public void init(IWorkbench workbench, IStructuredSelection selection) { + // Set the window title + setWindowTitle(Messages.NewRemoteTargetWizard_windowTitle); + // Create and add the wizard pages + addPage(new NewRemoteTargetWizardPage()); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.wizard.Wizard#performFinish() + */ + @Override + public boolean performFinish() { + IWizardPage page = getPage(NewRemoteTargetWizardPage.class.getName()); + if (page instanceof NewRemoteTargetWizardPage) { + // Trigger the saving of the widget history + ((NewRemoteTargetWizardPage)page).saveWidgetValues(); + // Get the peer attributes map from the page + Map peerAttributes = ((NewRemoteTargetWizardPage)page).getPeerAttributes(); + if (peerAttributes != null) { + // Try to connect to the peer + IChannel channel = null; + try { + Tcf.getChannelManager().openChannel(peerAttributes, new IChannelManager.DoneOpenChannel() { + public void doneOpenChannel(Throwable error, IChannel channel) { + // We ignore the error here, because we don't present it to the user + if (channel != null && channel.getRemotePeer() != null) { + IPeer peer = channel.getRemotePeer(); + ILocatorModel model = Model.getModel(); + if (model != null) { + final IPeerModel peerNode = model.getService(ILocatorModelLookupService.class).lkupPeerModelById(peer.getID()); + if (peerNode != null && PlatformUI.isWorkbenchRunning()) { + PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { + public void run() { + if (PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null && PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() != null) { + IViewReference reference = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findViewReference(IUIConstants.ID_EXPLORER); + IWorkbenchPart part = reference != null ? reference.getPart(false) : null; + ISelectionProvider selectionProvider = part != null && part.getSite() != null ? part.getSite().getSelectionProvider() : null; + if (selectionProvider != null) selectionProvider.setSelection(new StructuredSelection(peerNode)); + } + } + }); + } + } + } + + if (channel != null) channel.close(); + } + }); + } catch (Exception e) { + } finally { + // Close the channel again + if (channel != null) { + final IChannel finChannel = channel; + if (Protocol.isDispatchThread()) { + finChannel.close(); + } else { + Protocol.invokeAndWait(new Runnable() { + public void run() { + finChannel.close(); + } + }); + } + } + } + } + } + + return true; + } + +} diff --git a/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/wizards/pages/NewRemoteTargetWizardPage.java b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/wizards/pages/NewRemoteTargetWizardPage.java new file mode 100644 index 000000000..39f67d2b1 --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tm.te.tcf.ui/src/org/eclipse/tm/te/tcf/ui/internal/wizards/pages/NewRemoteTargetWizardPage.java @@ -0,0 +1,249 @@ +/******************************************************************************* + * 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.tcf.ui.internal.wizards.pages; + +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogSettings; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; +import org.eclipse.tm.tcf.protocol.IPeer; +import org.eclipse.tm.te.tcf.ui.internal.help.IContextHelpIds; +import org.eclipse.tm.te.tcf.ui.internal.nls.Messages; +import org.eclipse.tm.te.ui.wizards.pages.AbstractWizardPage; +import org.eclipse.ui.PlatformUI; + +/** + * Wizard page implementation querying all information needed + * to create the different TCF peer types. + */ +public class NewRemoteTargetWizardPage extends AbstractWizardPage { + private Combo fTransportTypeControl; + private Text fAddressControl; + private Text fPortControl; + private Text fPeerIdControl; + private Text fPeerNameControl; + + /** + * Constructor. + */ + public NewRemoteTargetWizardPage() { + this(NewRemoteTargetWizardPage.class.getName()); + } + + /** + * Constructor. + * + * @param pageName The page name. Must not be null. + */ + 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(Map peerAttributes) { + Assert.isNotNull(peerAttributes); + + peerAttributes.put(IPeer.ATTR_IP_HOST, fAddressControl.getText()); + peerAttributes.put(IPeer.ATTR_IP_PORT, fPortControl.getText()); + peerAttributes.put(IPeer.ATTR_ID, fPeerIdControl.getText()); + peerAttributes.put(IPeer.ATTR_NAME, fPeerNameControl.getText()); + peerAttributes.put(IPeer.ATTR_TRANSPORT_NAME, fTransportTypeControl.getText()); + } + + /** + * Returns the peer attributes. + * + * @return The peer attributes or null if canceled. + */ + public final Map getPeerAttributes() { + // Create a new peer attributes map + Map peerAttributes = new HashMap(); + // Update with the current control content + updatePeerAttributes(peerAttributes); + + return peerAttributes; + } + + /* (non-Javadoc) + * @see org.eclipse.tm.te.ui.wizards.pages.AbstractWizardPage#saveWidgetValues() + */ + @Override + public void saveWidgetValues() { + IDialogSettings settings = getDialogSettings(); + if (settings != null) { + // The transport type control is not saved + settings.put(IPeer.ATTR_IP_HOST, fAddressControl.getText()); + settings.put(IPeer.ATTR_IP_PORT, fPortControl.getText()); + settings.put(IPeer.ATTR_ID, fPeerIdControl.getText()); + settings.put(IPeer.ATTR_NAME, fPeerNameControl.getText()); + } + } + + /* (non-Javadoc) + * @see org.eclipse.tm.te.ui.wizards.pages.AbstractWizardPage#restoreWidgetValues() + */ + @Override + public void restoreWidgetValues() { + IDialogSettings settings = getDialogSettings(); + if (settings != null) { + // The transport type control is not restored + if (settings.get(IPeer.ATTR_IP_HOST) != null) fAddressControl.setText(settings.get(IPeer.ATTR_IP_HOST)); + if (settings.get(IPeer.ATTR_IP_PORT) != null) fPortControl.setText(settings.get(IPeer.ATTR_IP_PORT)); + if (settings.get(IPeer.ATTR_ID) != null) fPeerIdControl.setText(settings.get(IPeer.ATTR_ID)); + if (settings.get(IPeer.ATTR_NAME) != null) fPeerNameControl.setText(settings.get(IPeer.ATTR_NAME)); + } + } +} diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.views/plugin.xml b/target_explorer/plugins/org.eclipse.tm.te.ui.views/plugin.xml index e6a5192c6..296c2584f 100644 --- a/target_explorer/plugins/org.eclipse.tm.te.ui.views/plugin.xml +++ b/target_explorer/plugins/org.eclipse.tm.te.ui.views/plugin.xml @@ -50,8 +50,26 @@ + + + + + + + + + + + + + + " content menu + * content. + */ +public class NewActionProvider extends CommonActionProvider { + // Reference to the action showing the "Other..." dialog + private IWorkbenchAction fOtherDialogAction = null; + // Reference to the action group managing the context sensitive new wizards + private WizardActionGroup fNewWizardActionGroup = null; + + /* (non-Javadoc) + * @see org.eclipse.ui.navigator.CommonActionProvider#init(org.eclipse.ui.navigator.ICommonActionExtensionSite) + */ + @Override + public void init(ICommonActionExtensionSite site) { + super.init(site); + + if (site.getViewSite() instanceof ICommonViewerWorkbenchSite) { + // To initialize the actions, the workbench window instance is required + IWorkbenchWindow window = ((ICommonViewerWorkbenchSite)site.getViewSite()).getWorkbenchWindow(); + // Initialize the actions + fOtherDialogAction = ActionFactory.NEW.create(window); + fNewWizardActionGroup = new WizardActionGroup(window, + PlatformUI.getWorkbench().getNewWizardRegistry(), + WizardActionGroup.TYPE_NEW, + site.getContentService()); + } + } + + /* (non-Javadoc) + * @see org.eclipse.ui.actions.ActionGroup#dispose() + */ + @Override + public void dispose() { + if (fOtherDialogAction != null) { + fOtherDialogAction.dispose(); + fOtherDialogAction = null; + } + if (fNewWizardActionGroup != null) { + fNewWizardActionGroup.dispose(); + fNewWizardActionGroup = null; + } + super.dispose(); + } + + /* (non-Javadoc) + * @see org.eclipse.ui.actions.ActionGroup#fillContextMenu(org.eclipse.jface.action.IMenuManager) + */ + @Override + public void fillContextMenu(IMenuManager menu) { + // If none of the actions got created, there is nothing to do here + if (fOtherDialogAction == null && fNewWizardActionGroup == null) { + return; + } + + // Create the new sub menu + IMenuManager newMenu = new MenuManager(Messages.NewActionProvider_NewMenu_label, IUIConstants.ID_EXPLORER + ".menu.new"); //$NON-NLS-1$ + + // Add the context sensitive wizards (commonWizard element) + if (fNewWizardActionGroup != null) { + fNewWizardActionGroup.setContext(getContext()); + fNewWizardActionGroup.fillContextMenu(newMenu); + } + + // Add the standard additions marker + newMenu.add(new Separator(ICommonMenuConstants.GROUP_ADDITIONS)); + + // Add the "Other..." dialog action + if (fOtherDialogAction != null) { + newMenu.add(new Separator()); + newMenu.add(fOtherDialogAction); + } + + // The menu will be appended after the GROUP_NEW group. + menu.insertAfter(ICommonMenuConstants.GROUP_NEW, newMenu); + } +} diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/nls/Messages.java b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/nls/Messages.java index 5a0520bb9..c82162003 100644 --- a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/nls/Messages.java +++ b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/nls/Messages.java @@ -30,4 +30,6 @@ public class Messages extends NLS { // **** Declare externalized string id's down here ***** public static String PropertiesCommandHandler_error_initPartFailed; + + public static String NewActionProvider_NewMenu_label; } diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/nls/Messages.properties index c88578ab4..d437b577f 100644 --- a/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/nls/Messages.properties +++ b/target_explorer/plugins/org.eclipse.tm.te.ui.views/src/org/eclipse/tm/te/ui/views/internal/nls/Messages.properties @@ -4,3 +4,7 @@ # PropertiesCommandHandler_error_initPartFailed=Failed to initialize the Target Explorer details editor. + +# ***** Action Provider ***** + +NewActionProvider_NewMenu_label=&New diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tm.te.ui/META-INF/MANIFEST.MF index e1ff19a51..0f776b4e0 100644 --- a/target_explorer/plugins/org.eclipse.tm.te.ui/META-INF/MANIFEST.MF +++ b/target_explorer/plugins/org.eclipse.tm.te.ui/META-INF/MANIFEST.MF @@ -8,7 +8,8 @@ Bundle-Vendor: %providerName Require-Bundle: org.eclipse.core.runtime;bundle-version="3.6.0", org.eclipse.core.expressions;bundle-version="3.4.200", org.eclipse.ui;bundle-version="3.6.2", - org.eclipse.ui.forms;bundle-version="3.5.2" + org.eclipse.ui.forms;bundle-version="3.5.2", + org.eclipse.help;bundle-version="3.5.0" Bundle-RequiredExecutionEnvironment: J2SE-1.5 Bundle-ActivationPolicy: lazy Bundle-Localization: plugin @@ -20,4 +21,6 @@ Export-Package: org.eclipse.tm.te.ui;version="1.0.0", org.eclipse.tm.te.ui.nls;version="1.0.0", org.eclipse.tm.te.ui.tables;version="1.0.0", org.eclipse.tm.te.ui.tables.properties;version="1.0.0", - org.eclipse.tm.te.ui.trees;version="1.0.0" + org.eclipse.tm.te.ui.trees;version="1.0.0", + org.eclipse.tm.te.ui.wizards;version="1.0.0", + org.eclipse.tm.te.ui.wizards.pages;version="1.0.0" diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui/build.properties b/target_explorer/plugins/org.eclipse.tm.te.ui/build.properties index aa1a00826..30b2fc40b 100644 --- a/target_explorer/plugins/org.eclipse.tm.te.ui/build.properties +++ b/target_explorer/plugins/org.eclipse.tm.te.ui/build.properties @@ -2,4 +2,5 @@ source.. = src/ output.. = bin/ bin.includes = META-INF/,\ .,\ - plugin.properties + plugin.properties,\ + plugin.xml diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui/plugin.properties b/target_explorer/plugins/org.eclipse.tm.te.ui/plugin.properties index 9007e2197..73ddc751a 100644 --- a/target_explorer/plugins/org.eclipse.tm.te.ui/plugin.properties +++ b/target_explorer/plugins/org.eclipse.tm.te.ui/plugin.properties @@ -10,3 +10,7 @@ pluginName = Target Explorer, Common UI Controls and Helper providerName = Eclipse.org + +# ***** Wizards ***** + +NewWizards.category.name=Target Explorer diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui/plugin.xml b/target_explorer/plugins/org.eclipse.tm.te.ui/plugin.xml new file mode 100644 index 000000000..28b9fa9eb --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tm.te.ui/plugin.xml @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/target_explorer/plugins/org.eclipse.tm.te.ui/src/org/eclipse/tm/te/ui/wizards/AbstractWizard.java b/target_explorer/plugins/org.eclipse.tm.te.ui/src/org/eclipse/tm/te/ui/wizards/AbstractWizard.java new file mode 100644 index 000000000..8d40041ed --- /dev/null +++ b/target_explorer/plugins/org.eclipse.tm.te.ui/src/org/eclipse/tm/te/ui/wizards/AbstractWizard.java @@ -0,0 +1,81 @@ +/******************************************************************************* + * 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; + +import org.eclipse.jface.dialogs.IDialogSettings; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.tm.te.ui.activator.UIPlugin; + +/** + * An abstract wizard implementation. + *

+ * 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