Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 206403 | Differences between
and this patch

Collapse All | Expand All

(-)Eclipse (+16 lines)
Added Link Here
1
package org.eclipse.ui.tests.progress;
2
3
import org.eclipse.core.commands.AbstractHandler;
4
import org.eclipse.core.commands.ExecutionEvent;
5
import org.eclipse.core.commands.IHandler;
6
7
public class CommandHandler extends AbstractHandler implements IHandler {
8
9
	
10
	public boolean executed;
11
	public Object execute(ExecutionEvent event) {
12
		executed = true;
13
		return null;
14
	}
15
16
}
(-)Eclipse UI Tests/org/eclipse/ui/tests/progress/ProgressContantsTest.java (+46 lines)
Lines 11-21 Link Here
11
11
12
package org.eclipse.ui.tests.progress;
12
package org.eclipse.ui.tests.progress;
13
13
14
import org.eclipse.core.commands.Command;
15
import org.eclipse.core.commands.ParameterizedCommand;
14
import org.eclipse.core.runtime.IStatus;
16
import org.eclipse.core.runtime.IStatus;
15
import org.eclipse.core.runtime.Status;
17
import org.eclipse.core.runtime.Status;
16
import org.eclipse.core.runtime.jobs.Job;
18
import org.eclipse.core.runtime.jobs.Job;
17
import org.eclipse.ui.IPageLayout;
19
import org.eclipse.ui.IPageLayout;
20
import org.eclipse.ui.IWorkbench;
18
import org.eclipse.ui.IWorkbenchWindow;
21
import org.eclipse.ui.IWorkbenchWindow;
22
import org.eclipse.ui.PlatformUI;
23
import org.eclipse.ui.commands.ICommandService;
24
import org.eclipse.ui.handlers.IHandlerService;
19
import org.eclipse.ui.internal.progress.JobInfo;
25
import org.eclipse.ui.internal.progress.JobInfo;
20
import org.eclipse.ui.internal.progress.ProgressInfoItem;
26
import org.eclipse.ui.internal.progress.ProgressInfoItem;
21
import org.eclipse.ui.internal.progress.ProgressView;
27
import org.eclipse.ui.internal.progress.ProgressView;
Lines 36-41 Link Here
36
		super(testName);
42
		super(testName);
37
	}
43
	}
38
44
45
	public void testCommandProperty() throws Exception {
46
47
		IWorkbenchWindow window = openTestWindow("org.eclipse.ui.resourcePerspective");
48
		ProgressView progressView = (ProgressView) window.getActivePage().showView(IPageLayout.ID_PROGRESS_VIEW);
49
		assertNotNull(progressView);
50
		processEvents();
51
52
		DummyJob okJob = new DummyJob("OK Job", Status.OK_STATUS);
53
54
		IWorkbench workbench = PlatformUI.getWorkbench();
55
		ICommandService commandService = (ICommandService) workbench.getService(ICommandService.class);
56
		String commandId = "org.eclipse.ui.tests.progressViewCommand";
57
		Command command = commandService.getCommand(commandId);
58
		ParameterizedCommand parameterizedCommand = new ParameterizedCommand(command, null);
59
		okJob.setProperty(IProgressConstants.COMMAND_PROPERTY, parameterizedCommand);
60
		okJob.setProperty(IProgressConstants.KEEP_PROPERTY, Boolean.TRUE);
61
		okJob.schedule();
62
63
		IHandlerService service = (IHandlerService) workbench.getService(IHandlerService.class);
64
		CommandHandler handler = new CommandHandler();
65
		service.activateHandler(commandId, handler);
66
67
		okJob.join();
68
69
		processEvents();
70
71
		ProgressInfoItem[] progressInfoItems = progressView.getViewer().getProgressInfoItems();
72
		for (int i = 0; i < progressInfoItems.length; i++) {
73
			JobInfo[] jobInfos = progressInfoItems[i].getJobInfos();
74
			for (int j = 0; j < jobInfos.length; j++) {
75
				Job job = jobInfos[j].getJob();
76
				if (job.equals(okJob)) {
77
					progressInfoItems[i].executeTrigger();
78
				}
79
			}
80
		}
81
82
		assertTrue(handler.executed);
83
	}
84
39
	public void testKeepProperty() throws Exception {
85
	public void testKeepProperty() throws Exception {
40
86
41
		IWorkbenchWindow window = openTestWindow("org.eclipse.ui.resourcePerspective");
87
		IWorkbenchWindow window = openTestWindow("org.eclipse.ui.resourcePerspective");
(-)plugin.xml (+4 lines)
Lines 4215-4220 Link Here
4215
                  id="org.eclipse.ui.commands.radioState">
4215
                  id="org.eclipse.ui.commands.radioState">
4216
            </state>
4216
            </state>
4217
         </command>
4217
         </command>
4218
         <command
4219
               id="org.eclipse.ui.tests.progressViewCommand"
4220
               name="Progress View Command">
4221
         </command>
4218
      </extension>
4222
      </extension>
4219
   <extension id="rcpSessionApplication" point="org.eclipse.core.runtime.applications">
4223
   <extension id="rcpSessionApplication" point="org.eclipse.core.runtime.applications">
4220
	   <application cardinality="singleton-global" thread="main" visible="true">
4224
	   <application cardinality="singleton-global" thread="main" visible="true">
(-).settings/.api_filters (-24 / +32 lines)
Lines 1-16 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
1
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
<component id="org.eclipse.ui.workbench" version="2">
2
<component id="org.eclipse.ui.workbench" version="2">
3
    <resource path="Eclipse UI/org/eclipse/ui/services/IEvaluationReference.java" type="org.eclipse.ui.services.IEvaluationReference">
3
    <resource path="Eclipse UI/org/eclipse/ui/branding/IBundleGroupConstants.java" type="org.eclipse.ui.branding.IBundleGroupConstants">
4
        <filter id="403853384">
4
        <filter id="403767336">
5
            <message_arguments>
5
            <message_arguments>
6
                <message_argument value="org.eclipse.ui.services.IEvaluationReference"/>
6
                <message_argument value="org.eclipse.ui.branding.IBundleGroupConstants"/>
7
                <message_argument value="BRANDING_BUNDLE_VERSION"/>
8
            </message_arguments>
9
        </filter>
10
        <filter id="403767336">
11
            <message_arguments>
12
                <message_argument value="org.eclipse.ui.branding.IBundleGroupConstants"/>
13
                <message_argument value="BRANDING_BUNDLE_ID"/>
7
            </message_arguments>
14
            </message_arguments>
8
        </filter>
15
        </filter>
9
    </resource>
16
    </resource>
10
    <resource path="Eclipse UI/org/eclipse/ui/statushandlers/WorkbenchStatusDialogManager.java" type="org.eclipse.ui.statushandlers.WorkbenchStatusDialogManager">
17
    <resource path="Eclipse UI/org/eclipse/ui/menus/CommandContributionItemParameter.java" type="org.eclipse.ui.menus.CommandContributionItemParameter">
11
        <filter id="336744520">
18
        <filter id="338948223">
12
            <message_arguments>
19
            <message_arguments>
13
                <message_argument value="org.eclipse.ui.statushandlers.WorkbenchStatusDialogManager"/>
20
                <message_argument value="org.eclipse.ui.menus.CommandContributionItemParameter"/>
21
                <message_argument value="CommandContributionItemParameter(IServiceLocator, String, String, Map, ImageDescriptor, ImageDescriptor, ImageDescriptor, String, String, String, int, String, boolean)"/>
14
            </message_arguments>
22
            </message_arguments>
15
        </filter>
23
        </filter>
16
    </resource>
24
    </resource>
Lines 18-30 Link Here
18
        <filter id="420630660">
26
        <filter id="420630660">
19
            <message_arguments>
27
            <message_arguments>
20
                <message_argument value="org.eclipse.ui.part.MultiPageEditorPart"/>
28
                <message_argument value="org.eclipse.ui.part.MultiPageEditorPart"/>
21
                <message_argument value="getActivePage()"/>
29
                <message_argument value="getActiveEditor()"/>
22
            </message_arguments>
30
            </message_arguments>
23
        </filter>
31
        </filter>
24
        <filter id="421679236">
32
        <filter id="420630660">
25
            <message_arguments>
33
            <message_arguments>
26
                <message_argument value="org.eclipse.ui.part.MultiPageEditorPart"/>
34
                <message_argument value="org.eclipse.ui.part.MultiPageEditorPart"/>
27
                <message_argument value="getActiveEditor()"/>
35
                <message_argument value="getActivePage()"/>
28
            </message_arguments>
36
            </message_arguments>
29
        </filter>
37
        </filter>
30
        <filter id="421679236">
38
        <filter id="421679236">
Lines 33-64 Link Here
33
                <message_argument value="getActivePage()"/>
41
                <message_argument value="getActivePage()"/>
34
            </message_arguments>
42
            </message_arguments>
35
        </filter>
43
        </filter>
36
        <filter id="420630660">
44
        <filter id="421679236">
37
            <message_arguments>
45
            <message_arguments>
38
                <message_argument value="org.eclipse.ui.part.MultiPageEditorPart"/>
46
                <message_argument value="org.eclipse.ui.part.MultiPageEditorPart"/>
39
                <message_argument value="getActiveEditor()"/>
47
                <message_argument value="getActiveEditor()"/>
40
            </message_arguments>
48
            </message_arguments>
41
        </filter>
49
        </filter>
42
    </resource>
50
    </resource>
43
    <resource path="Eclipse UI/org/eclipse/ui/branding/IBundleGroupConstants.java" type="org.eclipse.ui.branding.IBundleGroupConstants">
51
    <resource path="Eclipse UI/org/eclipse/ui/progress/IProgressConstants.java" type="org.eclipse.ui.progress.IProgressConstants">
44
        <filter id="403767336">
52
        <filter id="403767336">
45
            <message_arguments>
53
            <message_arguments>
46
                <message_argument value="org.eclipse.ui.branding.IBundleGroupConstants"/>
54
                <message_argument value="org.eclipse.ui.progress.IProgressConstants"/>
47
                <message_argument value="BRANDING_BUNDLE_ID"/>
55
                <message_argument value="COMMAND_PROPERTY"/>
48
            </message_arguments>
49
        </filter>
50
        <filter id="403767336">
51
            <message_arguments>
52
                <message_argument value="org.eclipse.ui.branding.IBundleGroupConstants"/>
53
                <message_argument value="BRANDING_BUNDLE_VERSION"/>
54
            </message_arguments>
56
            </message_arguments>
55
        </filter>
57
        </filter>
56
    </resource>
58
    </resource>
57
    <resource path="Eclipse UI/org/eclipse/ui/menus/CommandContributionItemParameter.java" type="org.eclipse.ui.menus.CommandContributionItemParameter">
59
    <resource path="Eclipse UI/org/eclipse/ui/services/IEvaluationReference.java" type="org.eclipse.ui.services.IEvaluationReference">
58
        <filter id="338948223">
60
        <filter id="403853384">
59
            <message_arguments>
61
            <message_arguments>
60
                <message_argument value="org.eclipse.ui.menus.CommandContributionItemParameter"/>
62
                <message_argument value="org.eclipse.ui.services.IEvaluationReference"/>
61
                <message_argument value="CommandContributionItemParameter(IServiceLocator, String, String, Map, ImageDescriptor, ImageDescriptor, ImageDescriptor, String, String, String, int, String, boolean)"/>
62
            </message_arguments>
63
            </message_arguments>
63
        </filter>
64
        </filter>
64
    </resource>
65
    </resource>
Lines 69-72 Link Here
69
            </message_arguments>
70
            </message_arguments>
70
        </filter>
71
        </filter>
71
    </resource>
72
    </resource>
73
    <resource path="Eclipse UI/org/eclipse/ui/statushandlers/WorkbenchStatusDialogManager.java" type="org.eclipse.ui.statushandlers.WorkbenchStatusDialogManager">
74
        <filter id="336744520">
75
            <message_arguments>
76
                <message_argument value="org.eclipse.ui.statushandlers.WorkbenchStatusDialogManager"/>
77
            </message_arguments>
78
        </filter>
79
    </resource>
72
</component>
80
</component>
(-)Eclipse UI/org/eclipse/ui/internal/progress/AnimationItem.java (-1 / +8 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2003, 2006 IBM Corporation and others.
2
 * Copyright (c) 2003, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 169-172 Link Here
169
    void setAnimationContainer(IAnimationContainer container) {
169
    void setAnimationContainer(IAnimationContainer container) {
170
        this.animationContainer = container;
170
        this.animationContainer = container;
171
    }
171
    }
172
173
	/**
174
	 * @return Returns the window.
175
	 */
176
	public WorkbenchWindow getWindow() {
177
		return window;
178
	}
172
}
179
}
(-)Eclipse UI/org/eclipse/ui/internal/progress/ProgressAnimationItem.java (-23 / +65 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2008 IBM Corporation and others.
2
 * Copyright (c) 2004, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 10-16 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.internal.progress;
11
package org.eclipse.ui.internal.progress;
12
12
13
import org.eclipse.core.commands.ExecutionException;
14
import org.eclipse.core.commands.NotEnabledException;
15
import org.eclipse.core.commands.NotHandledException;
16
import org.eclipse.core.commands.ParameterizedCommand;
17
import org.eclipse.core.commands.common.NotDefinedException;
13
import org.eclipse.core.runtime.IStatus;
18
import org.eclipse.core.runtime.IStatus;
19
import org.eclipse.core.runtime.Status;
14
import org.eclipse.core.runtime.jobs.Job;
20
import org.eclipse.core.runtime.jobs.Job;
15
import org.eclipse.jface.action.IAction;
21
import org.eclipse.jface.action.IAction;
16
import org.eclipse.jface.util.Util;
22
import org.eclipse.jface.util.Util;
Lines 35-41 Link Here
35
import org.eclipse.swt.widgets.ProgressBar;
41
import org.eclipse.swt.widgets.ProgressBar;
36
import org.eclipse.swt.widgets.ToolBar;
42
import org.eclipse.swt.widgets.ToolBar;
37
import org.eclipse.swt.widgets.ToolItem;
43
import org.eclipse.swt.widgets.ToolItem;
44
import org.eclipse.ui.IWorkbenchWindow;
38
import org.eclipse.ui.PlatformUI;
45
import org.eclipse.ui.PlatformUI;
46
import org.eclipse.ui.handlers.IHandlerService;
39
import org.eclipse.ui.internal.WorkbenchImages;
47
import org.eclipse.ui.internal.WorkbenchImages;
40
import org.eclipse.ui.progress.IProgressConstants;
48
import org.eclipse.ui.progress.IProgressConstants;
41
import org.eclipse.ui.statushandlers.StatusAdapter;
49
import org.eclipse.ui.statushandlers.StatusAdapter;
Lines 109-138 Link Here
109
						StatusManager.getManager().handle(statusAdapter,
117
						StatusManager.getManager().handle(statusAdapter,
110
								StatusManager.SHOW);
118
								StatusManager.SHOW);
111
119
112
						JobTreeElement topElement = (JobTreeElement) ji
120
						removeTopElement(ji);
113
								.getParent();
114
						if (topElement == null) {
115
							topElement = ji;
116
						}
117
						FinishedJobs.getInstance().remove(topElement);
118
					}
121
					}
119
122
120
					IAction action = null;
123
					execute(ji, job);
121
					Object property = job
122
							.getProperty(IProgressConstants.ACTION_PROPERTY);
123
					if (property instanceof IAction) {
124
						action = (IAction) property;
125
					}
126
					if (action != null && action.isEnabled()) {
127
						action.run();
128
						JobTreeElement topElement = (JobTreeElement) ji
129
								.getParent();
130
						if (topElement == null) {
131
							topElement = ji;
132
						}
133
						FinishedJobs.getInstance().remove(topElement);
134
						return;
135
					}
136
				}
124
				}
137
			}
125
			}
138
		}
126
		}
Lines 141-146 Link Here
141
		refresh();
129
		refresh();
142
	}
130
	}
143
131
132
	/**
133
	 * @param ji
134
	 * @param job
135
	 */
136
	private void execute(JobInfo ji, Job job) {
137
138
		Object prop = job.getProperty(IProgressConstants.ACTION_PROPERTY);
139
		if (prop instanceof IAction && ((IAction) prop).isEnabled()) {
140
			IAction action = (IAction) prop;
141
			action.run();
142
			removeTopElement(ji);
143
		}
144
145
		prop = job.getProperty(IProgressConstants.COMMAND_PROPERTY);
146
		if (prop instanceof ParameterizedCommand) {
147
			ParameterizedCommand command = (ParameterizedCommand) prop;
148
			IWorkbenchWindow window = getWindow();
149
			IHandlerService service = (IHandlerService) window
150
					.getService(IHandlerService.class);
151
			Exception exception = null;
152
			try {
153
				service.executeCommand(command, null);
154
				removeTopElement(ji);
155
			} catch (ExecutionException e) {
156
				exception = e;
157
			} catch (NotDefinedException e) {
158
				exception = e;
159
			} catch (NotEnabledException e) {
160
				exception = e;
161
			} catch (NotHandledException e) {
162
				exception = e;
163
			}
164
165
			if (exception != null) {
166
				Status status = new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID,
167
						exception.getMessage(), exception);
168
				StatusManager.getManager().handle(status,
169
						StatusManager.LOG | StatusManager.SHOW);
170
			}
171
172
		}
173
	}
174
175
	/**
176
	 * @param ji
177
	 */
178
	private void removeTopElement(JobInfo ji) {
179
		JobTreeElement topElement = (JobTreeElement) ji.getParent();
180
		if (topElement == null) {
181
			topElement = ji;
182
		}
183
		FinishedJobs.getInstance().remove(topElement);
184
	}
185
144
	private IAction getAction(Job job) {
186
	private IAction getAction(Job job) {
145
		Object property = job.getProperty(IProgressConstants.ACTION_PROPERTY);
187
		Object property = job.getProperty(IProgressConstants.ACTION_PROPERTY);
146
		if (property instanceof IAction) {
188
		if (property instanceof IAction) {
(-)Eclipse UI/org/eclipse/ui/internal/progress/ProgressInfoItem.java (-31 / +86 lines)
Lines 1-7 Link Here
1
package org.eclipse.ui.internal.progress;
1
package org.eclipse.ui.internal.progress;
2
2
3
/*******************************************************************************
3
/*******************************************************************************
4
 * Copyright (c) 2005, 2008 IBM Corporation and others.
4
 * Copyright (c) 2005, 2009 IBM Corporation and others.
5
 * All rights reserved. This program and the accompanying materials
5
 * All rights reserved. This program and the accompanying materials
6
 * are made available under the terms of the Eclipse Public License v1.0
6
 * are made available under the terms of the Eclipse Public License v1.0
7
 * which accompanies this distribution, and is available at
7
 * which accompanies this distribution, and is available at
Lines 16-23 Link Here
16
import java.util.Date;
16
import java.util.Date;
17
import java.util.Iterator;
17
import java.util.Iterator;
18
import java.util.List;
18
import java.util.List;
19
import org.eclipse.core.commands.ExecutionException;
20
import org.eclipse.core.commands.NotEnabledException;
21
import org.eclipse.core.commands.NotHandledException;
22
import org.eclipse.core.commands.ParameterizedCommand;
23
import org.eclipse.core.commands.common.NotDefinedException;
19
import org.eclipse.core.runtime.IProgressMonitor;
24
import org.eclipse.core.runtime.IProgressMonitor;
20
import org.eclipse.core.runtime.IStatus;
25
import org.eclipse.core.runtime.IStatus;
26
import org.eclipse.core.runtime.Status;
21
import org.eclipse.core.runtime.jobs.Job;
27
import org.eclipse.core.runtime.jobs.Job;
22
import org.eclipse.jface.action.IAction;
28
import org.eclipse.jface.action.IAction;
23
import org.eclipse.jface.dialogs.Dialog;
29
import org.eclipse.jface.dialogs.Dialog;
Lines 49-57 Link Here
49
import org.eclipse.swt.widgets.ProgressBar;
55
import org.eclipse.swt.widgets.ProgressBar;
50
import org.eclipse.swt.widgets.ToolBar;
56
import org.eclipse.swt.widgets.ToolBar;
51
import org.eclipse.swt.widgets.ToolItem;
57
import org.eclipse.swt.widgets.ToolItem;
58
import org.eclipse.ui.IWorkbench;
52
import org.eclipse.ui.PlatformUI;
59
import org.eclipse.ui.PlatformUI;
60
import org.eclipse.ui.handlers.IHandlerService;
53
import org.eclipse.ui.internal.WorkbenchImages;
61
import org.eclipse.ui.internal.WorkbenchImages;
54
import org.eclipse.ui.progress.IProgressConstants;
62
import org.eclipse.ui.progress.IProgressConstants;
63
import org.eclipse.ui.statushandlers.StatusManager;
55
64
56
/**
65
/**
57
 * ProgressInfoItem is the item used to show jobs.
66
 * ProgressInfoItem is the item used to show jobs.
Lines 93-99 Link Here
93
102
94
	private static final String TEXT_KEY = "Text"; //$NON-NLS-1$
103
	private static final String TEXT_KEY = "Text"; //$NON-NLS-1$
95
104
96
	private static final String ACTION_KEY = "Action";//$NON-NLS-1$
105
	private static final String TRIGGER_KEY = "Trigger";//$NON-NLS-1$
97
106
98
	interface IndexListener {
107
	interface IndexListener {
99
		/**
108
		/**
Lines 124-129 Link Here
124
133
125
	private ResourceManager resourceManager;
134
	private ResourceManager resourceManager;
126
135
136
	private Link link;
137
127
	static {
138
	static {
128
		JFaceResources
139
		JFaceResources
129
				.getImageRegistry()
140
				.getImageRegistry()
Lines 231-237 Link Here
231
				actionButton.setEnabled(false);
242
				actionButton.setEnabled(false);
232
				cancelOrRemove();
243
				cancelOrRemove();
233
			}
244
			}
234
235
		});
245
		});
236
		actionBar.addListener(SWT.Traverse, new Listener() {
246
		actionBar.addListener(SWT.Traverse, new Listener() {
237
			/*
247
			/*
Lines 728-734 Link Here
728
	 */
738
	 */
729
	void setLinkText(Job linkJob, String taskString, int index) {
739
	void setLinkText(Job linkJob, String taskString, int index) {
730
740
731
		Link link;
732
		if (index >= taskEntries.size()) {// Is it new?
741
		if (index >= taskEntries.size()) {// Is it new?
733
			link = new Link(this, SWT.NONE);
742
			link = new Link(this, SWT.NONE);
734
743
Lines 756-763 Link Here
756
765
757
			link.setLayoutData(linkData);
766
			link.setLayoutData(linkData);
758
767
759
			final Link finalLink = link;
760
761
			link.addSelectionListener(new SelectionAdapter() {
768
			link.addSelectionListener(new SelectionAdapter() {
762
				/*
769
				/*
763
				 * (non-Javadoc)
770
				 * (non-Javadoc)
Lines 765-782 Link Here
765
				 * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
772
				 * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
766
				 */
773
				 */
767
				public void widgetSelected(SelectionEvent e) {
774
				public void widgetSelected(SelectionEvent e) {
768
775
					executeTrigger();
769
					IAction action = (IAction) finalLink.getData(ACTION_KEY);
770
					action.run();
771
772
					updateAction(action, finalLink);
773
774
					Object text = finalLink.getData(TEXT_KEY);
775
					if (text == null)
776
						return;
777
778
					// Refresh the text as enablement might have changed
779
					updateText((String) text, finalLink);
780
				}
776
				}
781
			});
777
			});
782
778
Lines 788-798 Link Here
788
				 */
784
				 */
789
				public void handleEvent(Event event) {
785
				public void handleEvent(Event event) {
790
786
791
					Object text = finalLink.getData(TEXT_KEY);
787
					Object text = link.getData(TEXT_KEY);
792
					if (text == null)
788
					if (text == null)
793
						return;
789
						return;
794
790
795
					updateText((String) text, finalLink);
791
					updateText((String) text, link);
796
792
797
				}
793
				}
798
			});
794
			});
Lines 805-832 Link Here
805
		link.setData(TEXT_KEY, taskString);
801
		link.setData(TEXT_KEY, taskString);
806
802
807
		// check for action property
803
		// check for action property
808
		Object property = linkJob
804
		Object actionProperty = linkJob
809
				.getProperty(IProgressConstants.ACTION_PROPERTY);
805
				.getProperty(IProgressConstants.ACTION_PROPERTY);
810
		updateAction(property, link);
806
		Object commandProperty = linkJob
807
				.getProperty(IProgressConstants.COMMAND_PROPERTY);
808
809
		if (actionProperty != null && commandProperty != null) {
810
			// if both are specified, then use neither
811
			updateTrigger(null, link);
812
		} else {
813
			Object property = actionProperty != null ? actionProperty
814
					: commandProperty;
815
			updateTrigger(property, link);
816
		}
811
817
812
		updateText(taskString, link);
818
		updateText(taskString, link);
813
819
814
	}
820
	}
815
821
822
	public void executeTrigger() {
823
824
		Object data = link.getData(TRIGGER_KEY);
825
		if (data instanceof IAction) {
826
			IAction action = (IAction) data;
827
			if (action.isEnabled())
828
				action.run();
829
			updateTrigger(action, link);
830
		} else if (data instanceof ParameterizedCommand) {
831
			IWorkbench workbench = PlatformUI
832
					.getWorkbench();
833
			IHandlerService handlerService = (IHandlerService) workbench
834
					.getService(
835
							IHandlerService.class);
836
			IStatus status = Status.OK_STATUS;
837
			try {
838
				handlerService
839
						.executeCommand((ParameterizedCommand) data, null);
840
			} catch (ExecutionException e) {
841
				status = new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, e
842
						.getMessage(), e);
843
			} catch (NotDefinedException e) {
844
				status = new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, e
845
						.getMessage(), e);
846
			} catch (NotEnabledException e) {
847
				status = new Status(IStatus.WARNING, PlatformUI.PLUGIN_ID, e
848
						.getMessage(), e);
849
			} catch (NotHandledException e) {
850
				status = new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, e
851
						.getMessage(), e);
852
			}
853
854
			if (!status.isOK()) {
855
				StatusManager.getManager().handle(status,
856
						StatusManager.LOG | StatusManager.SHOW);
857
			}
858
		}
859
860
		Object text = link.getData(TEXT_KEY);
861
		if (text == null)
862
			return;
863
864
		// Refresh the text as enablement might have changed
865
		updateText((String) text, link);
866
	}
867
816
	/**
868
	/**
817
	 * Update the action key if action is enabled or remove it if not
869
	 * Update the trigger key if either action is available and enabled or
870
	 * command is available
818
	 * 
871
	 * 
819
	 * @param action
872
	 * @param trigger
820
	 *            {@link Object} or <code>null</code>
873
	 *            {@link Object} or <code>null</code>
821
	 * @param link
874
	 * @param link
822
	 */
875
	 */
823
	private void updateAction(Object action, Link link) {
876
	private void updateTrigger(Object trigger, Link link) {
824
877
825
		if (action != null && action instanceof IAction
878
		if (trigger instanceof IAction && ((IAction) trigger).isEnabled()) {
826
				&& ((IAction) action).isEnabled())
879
			link.setData(TRIGGER_KEY, trigger);
827
			link.setData(ACTION_KEY, action);
880
		} else if (trigger instanceof ParameterizedCommand) {
828
		else
881
			link.setData(TRIGGER_KEY, trigger);
829
			link.setData(ACTION_KEY, null);
882
		} else {
883
			link.setData(TRIGGER_KEY, null);
884
		}
830
885
831
	}
886
	}
832
887
Lines 840-846 Link Here
840
		taskString = Dialog.shortenText(taskString, link);
895
		taskString = Dialog.shortenText(taskString, link);
841
896
842
		// Put in a hyperlink if there is an action
897
		// Put in a hyperlink if there is an action
843
		link.setText(link.getData(ACTION_KEY) == null ? taskString : NLS.bind(
898
		link.setText(link.getData(TRIGGER_KEY) == null ? taskString : NLS.bind(
844
				"<a>{0}</a>", taskString));//$NON-NLS-1$
899
				"<a>{0}</a>", taskString));//$NON-NLS-1$
845
	}
900
	}
846
901
(-)Eclipse UI/org/eclipse/ui/progress/IProgressConstants.java (-17 / +39 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2006 IBM Corporation and others.
2
 * Copyright (c) 2004, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 63-87 Link Here
63
    public static final QualifiedName KEEPONE_PROPERTY = new QualifiedName(
63
    public static final QualifiedName KEEPONE_PROPERTY = new QualifiedName(
64
            PROPERTY_PREFIX, "keepone"); //$NON-NLS-1$
64
            PROPERTY_PREFIX, "keepone"); //$NON-NLS-1$
65
65
66
    /**
66
	/**
67
     * This property is used to associate an <code>IAction</code> with a Job.
67
	 * This property is used to associate an <code>IAction</code> with a Job. If
68
     * If the Job is shown in the UI, the action might be represented as a button or
68
	 * the Job is shown in the UI, the action might be represented as a button
69
     * hyper link to allow the user to trigger a job specific action, like showing
69
	 * or hyper link to allow the user to trigger a job specific action, like
70
     * the Job's results.
70
	 * showing the Job's results.
71
     * <p>
71
	 * <p>
72
     * The progress UI will track the enabled state of the action and its tooltip text.
72
	 * The progress UI will track the enabled state of the action and its
73
     * </p>
73
	 * tooltip text.
74
     * <p>
74
	 * </p>
75
     * If the action implements <code>ActionFactory.IWorkbenchAction</code>, its
75
	 * <p>
76
     * <code>dispose</code> method will be called as soon as the Job is finally
76
	 * If the action implements <code>ActionFactory.IWorkbenchAction</code>, its
77
     * removed from the set of kept jobs.
77
	 * <code>dispose</code> method will be called as soon as the Job is finally
78
     * </p>
78
	 * removed from the set of kept jobs.
79
     * @see org.eclipse.jface.action.IAction
79
	 * </p>
80
     * @see org.eclipse.ui.actions.ActionFactory.IWorkbenchAction
80
	 * <p>
81
     **/
81
	 * Note: Only one of <code>ACTION_PROPERTY</code> or
82
	 * <code>COMMAND_PROPERTY</code> should be used
83
	 * </p>
84
	 * 
85
	 * @see org.eclipse.jface.action.IAction
86
	 * @see org.eclipse.ui.actions.ActionFactory.IWorkbenchAction
87
	 **/
82
    public static final QualifiedName ACTION_PROPERTY = new QualifiedName(
88
    public static final QualifiedName ACTION_PROPERTY = new QualifiedName(
83
            PROPERTY_PREFIX, "action"); //$NON-NLS-1$
89
            PROPERTY_PREFIX, "action"); //$NON-NLS-1$
84
90
91
	/**
92
	 * This property is used to associate a <code>ParameterizedCommand</code>
93
	 * with a Job. If the Job is shown in the UI, the command might be
94
	 * represented as a button or hyper link to allow the user to trigger a job
95
	 * specific action, like showing the Job's results.
96
	 * <p>
97
	 * Note: Only one of <code>ACTION_PROPERTY</code> or
98
	 * <code>COMMAND_PROPERTY</code> should be used
99
	 * </p>
100
	 * 
101
	 * @see org.eclipse.core.commands.ParameterizedCommand
102
	 * @since 3.6
103
	 **/
104
	public static final QualifiedName COMMAND_PROPERTY = new QualifiedName(
105
			PROPERTY_PREFIX, "command"); //$NON-NLS-1$
106
85
    /**
107
    /**
86
     * This property is used to associate an <code>ImageDescriptor</code> with a Job.
108
     * This property is used to associate an <code>ImageDescriptor</code> with a Job.
87
     * If the Job is shown in the UI, this descriptor is used to create an icon that
109
     * If the Job is shown in the UI, this descriptor is used to create an icon that

Return to bug 206403