diff options
author | Tobias Schwarz | 2014-04-15 11:45:27 +0000 |
---|---|---|
committer | Tobias Schwarz | 2014-04-15 11:45:27 +0000 |
commit | 40a80b8b7408d584a9e73c67fe79c07a3abf0c4a (patch) | |
tree | 350cd379b5e9da6237c49f8ce12667cae2010aee /target_explorer | |
parent | a94360980e202068af5fd3c0853da81ce1da04c0 (diff) | |
download | org.eclipse.tcf-40a80b8b7408d584a9e73c67fe79c07a3abf0c4a.tar.gz org.eclipse.tcf-40a80b8b7408d584a9e73c67fe79c07a3abf0c4a.tar.xz org.eclipse.tcf-40a80b8b7408d584a9e73c67fe79c07a3abf0c4a.zip |
Target Explorer: rework action history after review session
Diffstat (limited to 'target_explorer')
16 files changed, 122 insertions, 199 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.core/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.core/plugin.xml index 5b4bd0c1d..22b79bd8a 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.core/plugin.xml +++ b/target_explorer/plugins/org.eclipse.tcf.te.core/plugin.xml @@ -30,10 +30,6 @@ label="%SetConnectStateStep.name" class="org.eclipse.tcf.te.core.steps.SetConnectStateStep"> </step> - <step id="org.eclipse.tcf.te.core.saveToHistoryStep" - label="%SaveToHistoryStep.name" - class="org.eclipse.tcf.te.core.steps.SaveToHistoryStep"> - </step> </extension> <!-- Reusable core expression fragments --> diff --git a/target_explorer/plugins/org.eclipse.tcf.te.core/src/org/eclipse/tcf/te/core/steps/SaveToHistoryStep.java b/target_explorer/plugins/org.eclipse.tcf.te.core/src/org/eclipse/tcf/te/core/steps/SaveToHistoryStep.java deleted file mode 100644 index d8ff4dc69..000000000 --- a/target_explorer/plugins/org.eclipse.tcf.te.core/src/org/eclipse/tcf/te/core/steps/SaveToHistoryStep.java +++ /dev/null @@ -1,55 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2014 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.core.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.interfaces.callback.ICallback; -import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; -import org.eclipse.tcf.te.runtime.persistence.history.HistoryManager; -import org.eclipse.tcf.te.runtime.stepper.StepperAttributeUtil; -import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId; -import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepAttributes; -import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext; -import org.eclipse.tcf.te.runtime.stepper.steps.AbstractStep; - -/** - * SaveToHistoryStep - */ -public class SaveToHistoryStep extends AbstractStep { - - public static final String PARAMETER_HISTORY_ID = "historyId"; //$NON-NLS-1$ - - /* (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 { - } - - /* (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, IProgressMonitor monitor, ICallback callback) { - String historyId = getParameters().get(PARAMETER_HISTORY_ID); - if (historyId == null) { - historyId = StepperAttributeUtil.getStringProperty(IStepAttributes.ATTR_HISTORY_ID, fullQualifiedId, data); - } - String initialData = StepperAttributeUtil.getStringProperty(IStepAttributes.ATTR_HISTORY_DATA, fullQualifiedId, data); - if (historyId != null && initialData != null && initialData.trim().length() > 0) { - HistoryManager.getInstance().add(historyId, initialData.trim()); - } - - callback.done(this, Status.OK_STATUS); - } -} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/filetransfer/FileTransferItem.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/filetransfer/FileTransferItem.java index eba0e2172..918978d12 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/filetransfer/FileTransferItem.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/filetransfer/FileTransferItem.java @@ -25,7 +25,7 @@ public class FileTransferItem extends PropertiesContainer implements IFileTransf */ public FileTransferItem() { setProperty(PROPERTY_ENABLED, true); - setProperty(PROPERTY_DIRECTION, HOST_TO_TARGET); + setProperty(PROPERTY_DIRECTION, ""+HOST_TO_TARGET); //$NON-NLS-1$ } public FileTransferItem(IPath fromHost, boolean enabled) { diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/interfaces/IStepAttributes.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/interfaces/IStepAttributes.java index 2853044de..8ac1180e8 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/interfaces/IStepAttributes.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/interfaces/IStepAttributes.java @@ -35,10 +35,9 @@ public interface IStepAttributes { public static final String ATTR_STEPPER_JOB_OPERATION = ATTR_PREFIX + ".stepper_job_operation"; //$NON-NLS-1$ /** - * The id to persist the data of stepper execution to the history. - * If this attribute is not set, it is filled automatically with <stepGroupId>@<stepContextId> + * The initial step group. */ - public static final String ATTR_HISTORY_ID = ATTR_PREFIX + ".history_id"; //$NON-NLS-1$ + public static final String ATTR_STEP_GROUP_ID = ATTR_PREFIX + ".step_group_id"; //$NON-NLS-1$ /** * The data to persist to the history. @@ -47,8 +46,8 @@ public interface IStepAttributes { public static final String ATTR_HISTORY_DATA = ATTR_PREFIX + ".history_data"; //$NON-NLS-1$ /** - * The number of entries in the history. - * If this attribute is not set, the history manager default is used. + * History id used by the stepper to remember the last run. */ - public static final String ATTR_HISTORY_COUNT = ATTR_PREFIX + ".history_count"; //$NON-NLS-1$ + public static final String PROP_LAST_RUN_HISTORY_ID = ATTR_PREFIX + ".last_run_history"; //$NON-NLS-1$ + } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/stepper/Stepper.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/stepper/Stepper.java index eb3e870d2..d33bb5cdc 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/stepper/Stepper.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.stepper/src/org/eclipse/tcf/te/runtime/stepper/stepper/Stepper.java @@ -172,12 +172,10 @@ public class Stepper implements IStepper { // but not finished yet this.finished = false; - if (!data.containsKey(IStepAttributes.ATTR_HISTORY_DATA)) { + if (!data.isEmpty()) { + data.setProperty(IStepAttributes.ATTR_STEP_GROUP_ID, stepGroupId); data.setProperty(IStepAttributes.ATTR_HISTORY_DATA, DataHelper.encodePropertiesContainer(data)); } - if (!data.containsKey(IStepAttributes.ATTR_HISTORY_ID)) { - data.setProperty(IStepAttributes.ATTR_HISTORY_ID, stepGroupId + "@" + context.getId()); //$NON-NLS-1$ - } // call the hook for the subclasses to initialize themselves onInitialize(this.data, fullQualifiedId, this.monitor); @@ -354,16 +352,9 @@ public class Stepper implements IStepper { List<IStatus> statusContainer = new ArrayList<IStatus>(); // save execution to history - String historyId = data.getStringProperty(IStepAttributes.ATTR_HISTORY_ID); String historyData = data.getStringProperty(IStepAttributes.ATTR_HISTORY_DATA); - int historyCount = data.getIntProperty(IStepAttributes.ATTR_HISTORY_COUNT); - if (historyId != null && historyData != null) { - if (historyCount > 0) { - HistoryManager.getInstance().add(historyId, historyData, historyCount); - } - else { - HistoryManager.getInstance().add(historyId, historyData); - } + if (historyData != null) { + HistoryManager.getInstance().add(IStepAttributes.PROP_LAST_RUN_HISTORY_ID + "@" + context.getId(), historyData, 10); //$NON-NLS-1$ } // start execution diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/utils/TEHelper.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/utils/TEHelper.java index 45bb5fa2f..a70464fc8 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/utils/TEHelper.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.cdt/src/org/eclipse/tcf/te/tcf/launch/cdt/utils/TEHelper.java @@ -63,7 +63,7 @@ public class TEHelper { FileTransferItem item = new FileTransferItem(new Path(localFilePath), new Path(remoteFilePath)); item.setProperty(IFileTransferItem.PROPERTY_DIRECTION, - IFileTransferItem.HOST_TO_TARGET); + ""+IFileTransferItem.HOST_TO_TARGET); //$NON-NLS-1$ final Callback callback = new Callback(); FileTransferService.transfer(peer, null, item, monitor, callback); // Wait till the step finished, an execution occurred or the diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/filetransfer/AddEditFileTransferDialog.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/filetransfer/AddEditFileTransferDialog.java index 3326315a4..0036644f4 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/filetransfer/AddEditFileTransferDialog.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.launch.ui/src/org/eclipse/tcf/te/tcf/launch/ui/filetransfer/AddEditFileTransferDialog.java @@ -260,7 +260,7 @@ public class AddEditFileTransferDialog extends CustomTitleAreaDialog { wc.setProperty(IFileTransferItem.PROPERTY_OPTIONS, options.getEditFieldControlText()); int direction = toTarget.getSelection() ? IFileTransferItem.HOST_TO_TARGET : IFileTransferItem.TARGET_TO_HOST; - wc.setProperty(IFileTransferItem.PROPERTY_DIRECTION, direction); + wc.setProperty(IFileTransferItem.PROPERTY_DIRECTION, ""+direction); //$NON-NLS-1$ } /* (non-Javadoc) diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.properties index 2fdfa0c2b..f1b69f03f 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.properties +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/plugin.properties @@ -90,7 +90,6 @@ command.launch.label=Launch Terminal... command.launch.mnemonic=L command.launch.tooltip=Opens a terminal on the selected target. -command.history.label=Action History -command.history.tooltip=Press 'CTRL' to open an action in the edit dialog. +command.history.label=Action History... toolbar.label=System Management 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 6dccc54ae..31723f387 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 @@ -612,19 +612,10 @@ </menuContribution> <menuContribution locationURI="menu:org.eclipse.tcf.te.tcf.ui.DefaultContextActionsToolbarContribution?after=group.history"> + <dynamic + class="org.eclipse.tcf.te.tcf.ui.handler.ActionHistoryToolbarContribution" + id="org.eclipse.tcf.te.tcf.ui.ActionHistoryToolbarContribution"/> <command commandId="org.eclipse.tcf.te.tcf.ui.toolbar.command.history"/> - <!--menu - label="%command.history.label" - tooltip="%command.history.tooltip"> - <dynamic - class="org.eclipse.tcf.te.tcf.ui.handler.ActionHistoryToolbarContribution" - id="org.eclipse.tcf.te.tcf.ui.ActionHistoryToolbarContribution"/> - <visibleWhen> - <with variable="defaultContextSelection"> - <test property="org.eclipse.tcf.te.tcf.ui.hasHistory"/> - </with> - </visibleWhen> - </menu--> </menuContribution> <menuContribution locationURI="menu:org.eclipse.tcf.te.tcf.ui.DefaultContextActionsToolbarContribution?after=group.launch.rundebug"> <command commandId="org.eclipse.tcf.te.tcf.ui.toolbar.command.debug"> diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/delegates/AbstractDefaultContextToolbarDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/delegates/AbstractDefaultContextToolbarDelegate.java index a6d40c6b3..6ac942461 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/delegates/AbstractDefaultContextToolbarDelegate.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/delegates/AbstractDefaultContextToolbarDelegate.java @@ -11,6 +11,9 @@ package org.eclipse.tcf.te.tcf.ui.delegates; import org.eclipse.swt.graphics.Image; +import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; +import org.eclipse.tcf.te.runtime.persistence.utils.DataHelper; +import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepAttributes; import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.ui.interfaces.IDefaultContextToolbarDelegate; @@ -28,49 +31,55 @@ public abstract class AbstractDefaultContextToolbarDelegate implements IDefaultC } /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.ui.interfaces.IDefaultContextToolbarDelegate#getToolbarHistoryIds(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode, java.lang.String[]) + * @see org.eclipse.tcf.te.tcf.ui.interfaces.IDefaultContextToolbarDelegate#getHandledStepGroupIds(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode) */ @Override - public String[] getToolbarHistoryIds(IPeerNode peerNode, String[] historyIds) { - return historyIds; + public String[] getHandledStepGroupIds(IPeerNode peerNode) { + return new String[0]; } /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.ui.interfaces.IDefaultContextToolbarDelegate#getLabel(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode, java.lang.String, java.lang.String) + * @see org.eclipse.tcf.te.tcf.ui.interfaces.IDefaultContextToolbarDelegate#getLabel(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode, java.lang.String) */ @Override - public String getLabel(IPeerNode peerNode, String historyId, String entry) { + public String getLabel(IPeerNode peerNode, String entry) { return null; } /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.ui.interfaces.IDefaultContextToolbarDelegate#getDescription(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode, java.lang.String, java.lang.String) + * @see org.eclipse.tcf.te.tcf.ui.interfaces.IDefaultContextToolbarDelegate#getImage(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode, java.lang.String) */ @Override - public String getDescription(IPeerNode peerNode, String historyId, String entry) { - return getLabel(peerNode, historyId, entry); + public Image getImage(IPeerNode peerNode, String entry) { + return null; } /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.ui.interfaces.IDefaultContextToolbarDelegate#getImage(IPeerNode, String, String) + * @see org.eclipse.tcf.te.tcf.ui.interfaces.IDefaultContextToolbarDelegate#getDescription(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode, java.lang.String) */ @Override - public Image getImage(IPeerNode peerNode, String historyId, String entry) { - return null; + public String getDescription(IPeerNode peerNode, String entry) { + return getLabel(peerNode, entry); } /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.ui.interfaces.IDefaultContextToolbarDelegate#execute(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode, java.lang.String, java.lang.String, boolean) + * @see org.eclipse.tcf.te.tcf.ui.interfaces.IDefaultContextToolbarDelegate#validate(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode, java.lang.String) */ @Override - public void execute(IPeerNode peerNode, String historyId, String entry, boolean showDialog) { + public boolean validate(IPeerNode peerNode, String entry) { + return false; } /* (non-Javadoc) - * @see org.eclipse.tcf.te.tcf.ui.interfaces.IDefaultContextToolbarDelegate#validate(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode, java.lang.String, java.lang.String) + * @see org.eclipse.tcf.te.tcf.ui.interfaces.IDefaultContextToolbarDelegate#execute(org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode, java.lang.String, boolean) */ @Override - public boolean validate(IPeerNode peerNode, String historyId, String entry) { - return true; + public boolean execute(IPeerNode peerNode, String entry, boolean showDialog) { + return false; + } + + protected String getStepGroupId(String entry) { + IPropertiesContainer data = DataHelper.decodePropertiesContainer(entry); + return data.getStringProperty(IStepAttributes.ATTR_STEP_GROUP_ID); } } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/AbstractArraySelectionDialog.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/AbstractArraySelectionDialog.java index b23b0582d..938c829e7 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/AbstractArraySelectionDialog.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/AbstractArraySelectionDialog.java @@ -139,7 +139,6 @@ public abstract class AbstractArraySelectionDialog extends CustomTitleAreaDialog }); viewer.refresh(); - updateEnablement(viewer); } protected IContentProvider getContentProvider() { @@ -182,6 +181,10 @@ public abstract class AbstractArraySelectionDialog extends CustomTitleAreaDialog protected void updateEnablement(TableViewer viewer) { Assert.isNotNull(viewer); + if (viewer.getTable().getSelectionCount() == 0) { + viewer.getTable().setSelection(0); + } + // Adjust the OK button enablement Button okButton = getButton(IDialogConstants.OK_ID); int selCount = viewer.getTable().getSelectionCount(); diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/ActionHistorySelectionDialog.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/ActionHistorySelectionDialog.java index fc02598c6..24de08dca 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/ActionHistorySelectionDialog.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/dialogs/ActionHistorySelectionDialog.java @@ -27,10 +27,13 @@ import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Shell; +import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; import org.eclipse.tcf.te.runtime.persistence.history.HistoryManager; +import org.eclipse.tcf.te.runtime.persistence.utils.DataHelper; import org.eclipse.tcf.te.runtime.services.ServiceManager; import org.eclipse.tcf.te.runtime.services.interfaces.IDelegateService; import org.eclipse.tcf.te.runtime.services.interfaces.IService; +import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepAttributes; import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.locator.interfaces.services.IDefaultContextService; import org.eclipse.tcf.te.tcf.ui.activator.UIPlugin; @@ -46,7 +49,6 @@ import org.eclipse.tcf.te.ui.swt.SWTControlUtil; public class ActionHistorySelectionDialog extends AbstractArraySelectionDialog { protected static class Entry { - String historyId; IPeerNode peerNode; IDefaultContextToolbarDelegate delegate; String data; @@ -66,8 +68,8 @@ public class ActionHistorySelectionDialog extends AbstractArraySelectionDialog { */ @Override protected void createButtonsForButtonBar(Composite parent) { - createButton(parent, IDialogConstants.CLIENT_ID, Messages.ActionHistorySelectionDialog_button_edit, true); - createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true); + createButton(parent, IDialogConstants.CLIENT_ID, Messages.ActionHistorySelectionDialog_button_edit, false); + createButton(parent, IDialogConstants.OK_ID, Messages.ActionHistorySelectionDialog_button_execute, true); createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); } @@ -87,7 +89,9 @@ public class ActionHistorySelectionDialog extends AbstractArraySelectionDialog { protected void editPressed() { Entry entry = getSelectedEntry(); if (entry != null) { - entry.delegate.execute(entry.peerNode, entry.historyId, entry.data, true); + if (entry.delegate.execute(entry.peerNode, entry.data, true)) { + close(); + } } } @@ -99,7 +103,9 @@ public class ActionHistorySelectionDialog extends AbstractArraySelectionDialog { Entry entry = getSelectedEntry(); super.okPressed(); if (entry != null) { - entry.delegate.execute(entry.peerNode, entry.historyId, entry.data, true); + if (entry.delegate.execute(entry.peerNode, entry.data, false)) { + close(); + } } } @@ -119,11 +125,15 @@ public class ActionHistorySelectionDialog extends AbstractArraySelectionDialog { */ @Override protected void updateEnablement(TableViewer viewer) { + if (viewer.getTable().getSelectionCount() == 0) { + viewer.getTable().setSelection(0); + } + Entry entry = getSelectedEntry(); // Adjust the OK button enablement Button okButton = getButton(IDialogConstants.OK_ID); - SWTControlUtil.setEnabled(okButton, entry != null && entry.delegate.validate(entry.peerNode, entry.historyId, entry.data)); + SWTControlUtil.setEnabled(okButton, entry != null && entry.delegate.validate(entry.peerNode, entry.data)); // Adjust the edit button enablement Button editButton = getButton(IDialogConstants.CLIENT_ID); @@ -138,16 +148,14 @@ public class ActionHistorySelectionDialog extends AbstractArraySelectionDialog { final IPeerNode peerNode = ServiceManager.getInstance().getService(IDefaultContextService.class).getDefaultContext(null); IService[] services = ServiceManager.getInstance().getServices(peerNode, IDelegateService.class, false); - Map<String, IDefaultContextToolbarDelegate> historyIds = new LinkedHashMap<String, IDefaultContextToolbarDelegate>(); - String[] ids = new String[0]; + Map<String, IDefaultContextToolbarDelegate> delegates = new LinkedHashMap<String, IDefaultContextToolbarDelegate>(); for (IService service : services) { if (service instanceof IDelegateService) { IDefaultContextToolbarDelegate delegate = ((IDelegateService)service).getDelegate(peerNode, IDefaultContextToolbarDelegate.class); if (delegate != null) { - ids = delegate.getToolbarHistoryIds(peerNode, ids); - for (String newId : ids) { - if (!historyIds.containsKey(newId)) { - historyIds.put(newId, delegate); + for (String stepGroupId : delegate.getHandledStepGroupIds(peerNode)) { + if (!delegates.containsKey(stepGroupId)) { + delegates.put(stepGroupId, delegate); } } } @@ -155,21 +163,21 @@ public class ActionHistorySelectionDialog extends AbstractArraySelectionDialog { } List<Entry> actions = new ArrayList<Entry>(); - for (final String historyId : ids) { - String[] entries = HistoryManager.getInstance().getHistory(historyId); - final IDefaultContextToolbarDelegate delegate = historyIds.get(historyId); - if (entries != null && entries.length > 0) { - for (final String entry : entries) { - Entry action = new Entry(); - action.peerNode = peerNode; - action.historyId = historyId; - action.delegate = delegate; - action.data = entry; - - actions.add(action); - } - } - } + String[] entries = HistoryManager.getInstance().getHistory(IStepAttributes.PROP_LAST_RUN_HISTORY_ID + "@" + peerNode.getPeerId()); //$NON-NLS-1$ + if (entries != null && entries.length > 0) { + for (final String entry : entries) { + IPropertiesContainer decoded = DataHelper.decodePropertiesContainer(entry); + String stepGroupId = decoded.getStringProperty(IStepAttributes.ATTR_STEP_GROUP_ID); + if (stepGroupId != null && delegates.containsKey(stepGroupId)) { + Entry action = new Entry(); + action.peerNode = peerNode; + action.delegate = delegates.get(stepGroupId); + action.data = entry; + actions.add(action); + } + } + } + return actions.toArray(); } @@ -194,20 +202,20 @@ public class ActionHistorySelectionDialog extends AbstractArraySelectionDialog { @Override public String getToolTipText(Object element) { Entry entry = (Entry)element; - return entry.delegate.getDescription(entry.peerNode, entry.historyId, entry.data); + return entry.delegate.getDescription(entry.peerNode, entry.data); } public String getText(Object element) { Entry entry = (Entry)element; - return entry.delegate.getLabel(entry.peerNode, entry.historyId, entry.data); + return entry.delegate.getLabel(entry.peerNode, entry.data); } public Image getImage(Object element) { Entry entry = (Entry)element; AbstractImageDescriptor descriptor = new ActionHistoryImageDescriptor( UIPlugin.getDefault().getImageRegistry(), - entry.delegate.getImage(entry.peerNode, entry.historyId, entry.data), - entry.delegate.validate(entry.peerNode, entry.historyId, entry.data)); + entry.delegate.getImage(entry.peerNode, entry.data), + entry.delegate.validate(entry.peerNode, entry.data)); return UIPlugin.getSharedImage(descriptor); } }; diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/ActionHistoryToolbarContribution.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/ActionHistoryToolbarContribution.java index f689e7834..fb2752d3d 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/ActionHistoryToolbarContribution.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/ActionHistoryToolbarContribution.java @@ -9,14 +9,15 @@ import org.eclipse.jface.action.Action; import org.eclipse.jface.action.ActionContributionItem; import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IContributionItem; -import org.eclipse.jface.action.Separator; -import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Event; import org.eclipse.tcf.te.core.interfaces.IConnectable; +import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; import org.eclipse.tcf.te.runtime.persistence.history.HistoryManager; +import org.eclipse.tcf.te.runtime.persistence.utils.DataHelper; import org.eclipse.tcf.te.runtime.services.ServiceManager; import org.eclipse.tcf.te.runtime.services.interfaces.IDelegateService; import org.eclipse.tcf.te.runtime.services.interfaces.IService; +import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepAttributes; import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.locator.interfaces.services.IDefaultContextService; import org.eclipse.tcf.te.tcf.ui.activator.UIPlugin; @@ -53,52 +54,44 @@ public class ActionHistoryToolbarContribution extends CompoundContributionItem i boolean enabled = (peerNode != null && peerNode.getConnectState() == IConnectable.STATE_CONNECTED); IService[] services = ServiceManager.getInstance().getServices(peerNode, IDelegateService.class, false); - Map<String, IDefaultContextToolbarDelegate> historyIds = new LinkedHashMap<String, IDefaultContextToolbarDelegate>(); - String[] ids = new String[0]; + Map<String, IDefaultContextToolbarDelegate> delegates = new LinkedHashMap<String, IDefaultContextToolbarDelegate>(); for (IService service : services) { if (service instanceof IDelegateService) { IDefaultContextToolbarDelegate delegate = ((IDelegateService)service).getDelegate(peerNode, IDefaultContextToolbarDelegate.class); if (delegate != null) { - ids = delegate.getToolbarHistoryIds(peerNode, ids); - for (String newId : ids) { - if (!historyIds.containsKey(newId)) { - historyIds.put(newId, delegate); + for (String stepGroupId : delegate.getHandledStepGroupIds(peerNode)) { + if (!delegates.containsKey(stepGroupId)) { + delegates.put(stepGroupId, delegate); } } } } } - for (final String historyId : ids) { - String[] entries = HistoryManager.getInstance().getHistory(historyId); - final IDefaultContextToolbarDelegate delegate = historyIds.get(historyId); - if (entries != null && entries.length > 0) { - if (!items.isEmpty()) { - items.add(new Separator()); - } - List<String> labels = new ArrayList<String>(); - for (final String entry : entries) { - String label = delegate.getLabel(peerNode, historyId, entry); - if (labels.contains(label)) { - label += " ..."; //$NON-NLS-1$ - } - else { - labels.add(label); - } - IAction action = new Action(label) { + String[] entries = HistoryManager.getInstance().getHistory(IStepAttributes.PROP_LAST_RUN_HISTORY_ID + "@" + peerNode.getPeerId()); //$NON-NLS-1$ + if (entries != null && entries.length > 0) { + int count = 0; + for (final String entry : entries) { + if (++count > 5) { + break; + } + IPropertiesContainer decoded = DataHelper.decodePropertiesContainer(entry); + String stepGroupId = decoded.getStringProperty(IStepAttributes.ATTR_STEP_GROUP_ID); + if (stepGroupId != null && delegates.containsKey(stepGroupId)) { + final IDefaultContextToolbarDelegate delegate = delegates.get(stepGroupId); + IAction action = new Action("&" + count + " " + delegate.getLabel(peerNode, entry)) { //$NON-NLS-1$ //$NON-NLS-2$ @Override public void runWithEvent(Event event) { - delegate.execute(peerNode, historyId, entry, (event.stateMask & SWT.CTRL) == SWT.CTRL); + delegate.execute(peerNode, entry, false); } }; - action.setEnabled(enabled); AbstractImageDescriptor descriptor = new ActionHistoryImageDescriptor( UIPlugin.getDefault().getImageRegistry(), - delegate.getImage(peerNode, historyId, entry), - delegate.validate(peerNode, historyId, entry)); + delegate.getImage(peerNode, entry), + delegate.validate(peerNode, entry)); UIPlugin.getSharedImage(descriptor); - action.setImageDescriptor(UIPlugin.getImageDescriptor(descriptor.getDecriptorKey())); + action.setEnabled(enabled); IContributionItem item = new ActionContributionItem(action); items.add(item); } diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/interfaces/IDefaultContextToolbarDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/interfaces/IDefaultContextToolbarDelegate.java index aec284435..de78f5c92 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/interfaces/IDefaultContextToolbarDelegate.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/interfaces/IDefaultContextToolbarDelegate.java @@ -28,57 +28,51 @@ public interface IDefaultContextToolbarDelegate { public String[] getToolbarNewConfigWizardIds(Object context); /** - * Returns a list if history ids that should be used to diaply the "recently used actions" in the toolbar actions sub menu. + * Returns a list of handled step group ids. * @param peerNode The selected default context. - * @param historyIds - * @return Array of ids. + * @return */ - public String[] getToolbarHistoryIds(IPeerNode peerNode, String[] historyIds); + public String[] getHandledStepGroupIds(IPeerNode peerNode); /** * Get the label for a history action. * @param peerNode - * @param historyId * @param entry * @return */ - public String getLabel(IPeerNode peerNode, String historyId, String entry); + public String getLabel(IPeerNode peerNode, String entry); /** * Get the description for a history action. * @param peerNode - * @param historyId * @param entry * @return */ - public String getDescription(IPeerNode peerNode, String historyId, String entry); + public String getDescription(IPeerNode peerNode,String entry); /** * Get the image for a history action. * @param peerNode - * @param historyId * @param entry * @return */ - public Image getImage(IPeerNode peerNode, String historyId, String entry); + public Image getImage(IPeerNode peerNode, String entry); /** * Execute a history action. * Depending on showDialog, a dialog is shown first. * @param peerNode - * @param historyId * @param entry * @param showDialog */ - public void execute(IPeerNode peerNode, String historyId, String entry, boolean showDialog); + public boolean execute(IPeerNode peerNode, String entry, boolean showDialog); /** * Validate the entry. * @param peerNode - * @param historyId * @param entry * @return */ - public boolean validate(IPeerNode peerNode, String historyId, String entry); + public boolean validate(IPeerNode peerNode, String entry); } 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 4f9ab8171..024cb211e 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 @@ -19,6 +19,7 @@ import org.eclipse.tcf.te.runtime.persistence.history.HistoryManager; import org.eclipse.tcf.te.runtime.services.ServiceManager; import org.eclipse.tcf.te.runtime.services.interfaces.IDelegateService; import org.eclipse.tcf.te.runtime.services.interfaces.IService; +import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepAttributes; import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerNode; import org.eclipse.tcf.te.tcf.locator.interfaces.services.IDefaultContextService; import org.eclipse.tcf.te.tcf.locator.model.ModelManager; @@ -57,15 +58,10 @@ public class PropertyTester extends org.eclipse.core.expressions.PropertyTester if (service instanceof IDelegateService) { IDefaultContextToolbarDelegate delegate = ((IDelegateService)service).getDelegate(peerNode, IDefaultContextToolbarDelegate.class); if (delegate != null) { - String[] newIds = delegate.getToolbarHistoryIds(peerNode, new String[0]); - if (newIds != null) { - for (String newId : newIds) { - String[] entries = HistoryManager.getInstance().getHistory(newId); - if (entries != null && entries.length > 0) { - return true; - } - } - } + String[] entries = HistoryManager.getInstance().getHistory(IStepAttributes.PROP_LAST_RUN_HISTORY_ID + "@" + peerNode.getPeerId()); //$NON-NLS-1$ + if (entries != null && entries.length > 0) { + return true; + } } } } 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 893be6f61..ed782cbc9 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 @@ -111,7 +111,7 @@ ActionHistorySelectionDialog_dialogTitle=Action History ActionHistorySelectionDialog_title=Select an Action for ''{0}'' ActionHistorySelectionDialog_message=Select an action from the history to execute or edit. ActionHistorySelectionDialog_button_edit=Edit -ActionHistorySelectionDialog_button_execute=Ok +ActionHistorySelectionDialog_button_execute=Execute RedirectHandler_error_title=Error RedirectHandler_error_redirectFailed=Failed to redirect target communication. @@ -162,8 +162,7 @@ DefaultContextSelectorToolbarContribution_tooltip_new=Click to create a new conn DefaultContextSelectorToolbarContribution_label_new=New Connection... DefaultContextSelectorToolbarContribution_tooltip_button=Click to change the default connection or create a new connection. -DefaultContextActionsToolbarContribution_tooltip_button=Click to see actions for the selected default connection.\n\ -History actions can be edited by pressing 'CTRL'. +DefaultContextActionsToolbarContribution_tooltip_button=Click to see actions for the selected default connection. DefaultContextActionsToolbarContribution_tooltip_button_disabled=Please connect to see actions for the selected default connection. DefaultContextActionsToolbarContribution_tooltip_button_noContext=Please create a new connection first. |