View | Details | Raw Unified | Return to bug 221172 | Differences between
and this patch

Collapse All | Expand All

(-)plugin.properties (+1 lines)
Lines 259-264 Link Here
259
command.showView.name = Show View
259
command.showView.name = Show View
260
command.showView.description = Shows a particular view
260
command.showView.description = Shows a particular view
261
command.showView.viewIdParameter = View
261
command.showView.viewIdParameter = View
262
command.showView.secondaryIdParameter = Secondary Id
262
command.showView.makeFastParameter = As FastView
263
command.showView.makeFastParameter = As FastView
263
command.switchToEditor.description = Switch to an editor
264
command.switchToEditor.description = Switch to an editor
264
command.switchToEditor.name = Switch to Editor
265
command.switchToEditor.name = Switch to Editor
(-)plugin.xml (+4 lines)
Lines 1121-1126 Link Here
1121
      			id="org.eclipse.ui.views.showView.viewId"
1121
      			id="org.eclipse.ui.views.showView.viewId"
1122
      			name="%command.showView.viewIdParameter"
1122
      			name="%command.showView.viewIdParameter"
1123
      			values="org.eclipse.ui.internal.registry.ViewParameterValues" />
1123
      			values="org.eclipse.ui.internal.registry.ViewParameterValues" />
1124
      		<commandParameter
1125
      			id="org.eclipse.ui.views.showView.secondaryId"
1126
      			name="%command.showView.secondaryIdParameter"
1127
      			optional="true"/>
1124
        <commandParameter
1128
        <commandParameter
1125
              id="org.eclipse.ui.views.showView.makeFast"
1129
              id="org.eclipse.ui.views.showView.makeFast"
1126
              name="%command.showView.makeFastParameter"
1130
              name="%command.showView.makeFastParameter"
(-)Eclipse UI/org/eclipse/ui/handlers/ShowViewHandler.java (-10 / +13 lines)
Lines 11-17 Link Here
11
package org.eclipse.ui.handlers;
11
package org.eclipse.ui.handlers;
12
12
13
import java.util.Map;
13
import java.util.Map;
14
15
import org.eclipse.core.commands.AbstractHandler;
14
import org.eclipse.core.commands.AbstractHandler;
16
import org.eclipse.core.commands.ExecutionEvent;
15
import org.eclipse.core.commands.ExecutionEvent;
17
import org.eclipse.core.commands.ExecutionException;
16
import org.eclipse.core.commands.ExecutionException;
Lines 45-50 Link Here
45
	private static final String PARAMETER_NAME_VIEW_ID = "org.eclipse.ui.views.showView.viewId"; //$NON-NLS-1$
44
	private static final String PARAMETER_NAME_VIEW_ID = "org.eclipse.ui.views.showView.viewId"; //$NON-NLS-1$
46
    private boolean makeFast = false;
45
    private boolean makeFast = false;
47
	private static final String PARAMETER_MAKE_FAST = "org.eclipse.ui.views.showView.makeFast"; //$NON-NLS-1$
46
	private static final String PARAMETER_MAKE_FAST = "org.eclipse.ui.views.showView.makeFast"; //$NON-NLS-1$
47
	private static final String PARAMETER_SECONDARY_ID = "org.eclipse.ui.views.showView.secondaryId"; //$NON-NLS-1$
48
  
48
  
49
    /**
49
    /**
50
     * Creates a new ShowViewHandler that will open the view in its default location.
50
     * Creates a new ShowViewHandler that will open the view in its default location.
Lines 70-83 Link Here
70
				.getActiveWorkbenchWindowChecked(event);
70
				.getActiveWorkbenchWindowChecked(event);
71
		// Get the view identifier, if any.
71
		// Get the view identifier, if any.
72
		final Map parameters = event.getParameters();
72
		final Map parameters = event.getParameters();
73
		final Object value = parameters.get(PARAMETER_NAME_VIEW_ID);
73
		final Object viewId = parameters.get(PARAMETER_NAME_VIEW_ID);
74
		final Object secondary = parameters.get(PARAMETER_SECONDARY_ID);
74
		makeFast = "true".equals(parameters.get(PARAMETER_MAKE_FAST)); //$NON-NLS-1$
75
		makeFast = "true".equals(parameters.get(PARAMETER_MAKE_FAST)); //$NON-NLS-1$
75
		
76
		
76
		if (value == null) {
77
		if (viewId == null) {
77
			openOther(window);
78
			openOther(window);
78
		} else {
79
		} else {
79
            try {
80
            try {
80
                openView((String) value, window);
81
				openView((String) viewId, (String) secondary, window);
81
            } catch (PartInitException e) {
82
            } catch (PartInitException e) {
82
                throw new ExecutionException("Part could not be initialized", e); //$NON-NLS-1$
83
                throw new ExecutionException("Part could not be initialized", e); //$NON-NLS-1$
83
            }
84
            }
Lines 106-112 Link Here
106
		final IViewDescriptor[] descriptors = dialog.getSelection();
107
		final IViewDescriptor[] descriptors = dialog.getSelection();
107
		for (int i = 0; i < descriptors.length; ++i) {
108
		for (int i = 0; i < descriptors.length; ++i) {
108
			try {
109
			try {
109
                openView(descriptors[i].getId(), window);
110
				openView(descriptors[i].getId(), null, window);
110
			} catch (PartInitException e) {
111
			} catch (PartInitException e) {
111
				StatusUtil.handleStatus(e.getStatus(),
112
				StatusUtil.handleStatus(e.getStatus(),
112
						WorkbenchMessages.ShowView_errorTitle
113
						WorkbenchMessages.ShowView_errorTitle
Lines 121-130 Link Here
121
	 * 
122
	 * 
122
	 * @param viewId
123
	 * @param viewId
123
	 *            The view to open; must not be <code>null</code>
124
	 *            The view to open; must not be <code>null</code>
125
	 * @param secondaryId
126
	 *            an optional secondary id; may be <code>null</code>
124
	 * @throws PartInitException
127
	 * @throws PartInitException
125
	 *             If the part could not be initialized.
128
	 *             If the part could not be initialized.
126
	 */
129
	 */
127
	private final void openView(final String viewId,
130
	private final void openView(final String viewId, final String secondaryId,
128
			final IWorkbenchWindow activeWorkbenchWindow)
131
			final IWorkbenchWindow activeWorkbenchWindow)
129
			throws PartInitException {
132
			throws PartInitException {
130
133
Lines 140-146 Link Here
140
            // If we're making a fast view then use the new mechanism directly
143
            // If we're making a fast view then use the new mechanism directly
141
            boolean useNewMinMax = Perspective.useNewMinMax(persp);
144
            boolean useNewMinMax = Perspective.useNewMinMax(persp);
142
            if (useNewMinMax) {
145
            if (useNewMinMax) {
143
            	IViewReference ref = persp.getViewReference(viewId, null);
146
				IViewReference ref = persp.getViewReference(viewId, secondaryId);
144
            	if (ref == null)
147
            	if (ref == null)
145
            		return;
148
            		return;
146
149
Lines 150-159 Link Here
150
        		return;
153
        		return;
151
            }
154
            }
152
            
155
            
153
            IViewReference ref = wp.findViewReference(viewId);
156
			IViewReference ref = wp.findViewReference(viewId, secondaryId);
154
            
157
            
155
            if (ref == null) {
158
            if (ref == null) {
156
                IViewPart part = wp.showView(viewId, null, IWorkbenchPage.VIEW_CREATE);
159
				IViewPart part = wp.showView(viewId, secondaryId, IWorkbenchPage.VIEW_CREATE);
157
                ref = (IViewReference)wp.getReference(part); 
160
                ref = (IViewReference)wp.getReference(part); 
158
            }
161
            }
159
            
162
            
Lines 162-168 Link Here
162
            }
165
            }
163
            wp.activate(ref.getPart(true));
166
            wp.activate(ref.getPart(true));
164
        } else {
167
        } else {
165
            activePage.showView(viewId);
168
			activePage.showView(viewId, secondaryId, IWorkbenchPage.VIEW_ACTIVATE);
166
        }
169
        }
167
		
170
		
168
	}
171
	}
(-)Eclipse UI/org/eclipse/ui/internal/ShowViewMenu.java (-16 / +85 lines)
Lines 11-25 Link Here
11
11
12
package org.eclipse.ui.internal;
12
package org.eclipse.ui.internal;
13
13
14
import com.ibm.icu.text.Collator;
14
import java.util.ArrayList;
15
import java.util.ArrayList;
15
import java.util.Arrays;
16
import java.util.Collections;
16
import java.util.Collections;
17
import java.util.Comparator;
17
import java.util.Comparator;
18
import java.util.HashMap;
18
import java.util.HashMap;
19
import java.util.Iterator;
19
import java.util.Iterator;
20
import java.util.List;
20
import java.util.List;
21
import java.util.Map;
21
import java.util.Map;
22
23
import org.eclipse.core.commands.Command;
22
import org.eclipse.core.commands.Command;
24
import org.eclipse.core.commands.ExecutionException;
23
import org.eclipse.core.commands.ExecutionException;
25
import org.eclipse.core.commands.IParameter;
24
import org.eclipse.core.commands.IParameter;
Lines 39-44 Link Here
39
import org.eclipse.swt.widgets.Menu;
38
import org.eclipse.swt.widgets.Menu;
40
import org.eclipse.swt.widgets.MenuItem;
39
import org.eclipse.swt.widgets.MenuItem;
41
import org.eclipse.ui.IPluginContribution;
40
import org.eclipse.ui.IPluginContribution;
41
import org.eclipse.ui.IViewReference;
42
import org.eclipse.ui.IWorkbenchCommandConstants;
42
import org.eclipse.ui.IWorkbenchCommandConstants;
43
import org.eclipse.ui.IWorkbenchPage;
43
import org.eclipse.ui.IWorkbenchPage;
44
import org.eclipse.ui.IWorkbenchWindow;
44
import org.eclipse.ui.IWorkbenchWindow;
Lines 53-60 Link Here
53
import org.eclipse.ui.views.IViewDescriptor;
53
import org.eclipse.ui.views.IViewDescriptor;
54
import org.eclipse.ui.views.IViewRegistry;
54
import org.eclipse.ui.views.IViewRegistry;
55
55
56
import com.ibm.icu.text.Collator;
57
58
/**
56
/**
59
 * A <code>ShowViewMenu</code> is used to populate a menu manager with Show
57
 * A <code>ShowViewMenu</code> is used to populate a menu manager with Show
60
 * View actions. The visible views are determined by user preference from the
58
 * View actions. The visible views are determined by user preference from the
Lines 66-73 Link Here
66
	 */
64
	 */
67
	public static final String SHOW_VIEW_ID= IWorkbenchCommandConstants.VIEWS_SHOW_VIEW;
65
	public static final String SHOW_VIEW_ID= IWorkbenchCommandConstants.VIEWS_SHOW_VIEW;
68
	public static final String VIEW_ID_PARM = "org.eclipse.ui.views.showView.viewId"; //$NON-NLS-1$
66
	public static final String VIEW_ID_PARM = "org.eclipse.ui.views.showView.viewId"; //$NON-NLS-1$
67
	private static final String PARAMETER_SECONDARY_ID = "org.eclipse.ui.views.showView.secondaryId"; //$NON-NLS-1$
69
	private static final String PARAMETER_MAKE_FAST = "org.eclipse.ui.views.showView.makeFast"; //$NON-NLS-1$
68
	private static final String PARAMETER_MAKE_FAST = "org.eclipse.ui.views.showView.makeFast"; //$NON-NLS-1$
70
69
70
	static class Pair {
71
		public final Object a;
72
		public final Object b;
73
		int hashCode = -1;
74
75
		/**
76
		 * @param a
77
		 *            must not be <code>null</code>
78
		 * @param b
79
		 *            can be <code>null</code>
80
		 */
81
		public Pair(Object a, Object b) {
82
			this.a = a;
83
			this.b = b;
84
		}
85
86
		/*
87
		 * (non-Javadoc)
88
		 * 
89
		 * @see java.lang.Object#hashCode()
90
		 */
91
		public int hashCode() {
92
			if (hashCode == -1) {
93
				final int prime = 31;
94
				hashCode = 1;
95
				hashCode = prime * hashCode + ((a == null) ? 0 : a.hashCode());
96
				hashCode = prime * hashCode + ((b == null) ? 0 : b.hashCode());
97
				if (hashCode == -1) {
98
					hashCode = a.hashCode();
99
				}
100
			}
101
			return hashCode;
102
		}
103
104
		/*
105
		 * (non-Javadoc)
106
		 * 
107
		 * @see java.lang.Object#equals(java.lang.Object)
108
		 */
109
		public boolean equals(Object obj) {
110
			if (this == obj) {
111
				return true;
112
			}
113
			Pair p = (Pair) obj;
114
			if (!a.equals(p.a)) {
115
				return false;
116
			}
117
			if (b == p.b) {
118
				return true;
119
			}
120
			if (b == null || p.b == null) {
121
				return false;
122
			}
123
			return b.equals(p.b);
124
		}
125
	}
126
71
	private IWorkbenchWindow window;
127
	private IWorkbenchWindow window;
72
128
73
	private static final String NO_TARGETS_MSG = WorkbenchMessages.Workbench_showInNoTargets;
129
	private static final String NO_TARGETS_MSG = WorkbenchMessages.Workbench_showInNoTargets;
Lines 87-95 Link Here
87
143
88
	private Map actions = new HashMap(21);
144
	private Map actions = new HashMap(21);
89
145
90
	// Maps pages to a list of opened views
91
	private Map openedViews = new HashMap();
92
93
	protected boolean dirty = true;
146
	protected boolean dirty = true;
94
147
95
	private IMenuListener menuListener = new IMenuListener() {
148
	private IMenuListener menuListener = new IMenuListener() {
Lines 193-210 Link Here
193
		}
246
		}
194
247
195
		// Get visible actions.
248
		// Get visible actions.
196
		List viewIds = Arrays.asList(page.getShowViewShortcuts());
249
		List viewIds = getShortcuts(page);
197
250
198
		// add all open views
251
		// add all open views
199
		viewIds = addOpenedViews(page, viewIds);
252
		viewIds = addOpenedViews(page, viewIds);
200
253
201
		List actions = new ArrayList(viewIds.size());
254
		List actions = new ArrayList(viewIds.size());
202
		for (Iterator i = viewIds.iterator(); i.hasNext();) {
255
		for (Iterator i = viewIds.iterator(); i.hasNext();) {
203
			String id = (String) i.next();
256
			Pair id = (Pair) i.next();
204
			if (id.equals(IIntroConstants.INTRO_VIEW_ID)) {
257
			if (id.a.equals(IIntroConstants.INTRO_VIEW_ID)) {
205
				continue;
258
				continue;
206
			}
259
			}
207
			CommandContributionItemParameter item = getItem(id);
260
			CommandContributionItemParameter item = getItem((String) id.a, (String) id.b);
208
			if (item != null) {
261
			if (item != null) {
209
				actions.add(item);
262
				actions.add(item);
210
			}
263
			}
Lines 230-235 Link Here
230
		innerMgr.add(showDlgAction);
283
		innerMgr.add(showDlgAction);
231
	}
284
	}
232
285
286
	/**
287
	 * @param page
288
	 * @return
289
	 */
290
	private List getShortcuts(IWorkbenchPage page) {
291
		ArrayList list = new ArrayList();
292
		String[] shortcuts = page.getShowViewShortcuts();
293
		for (int i = 0; i < shortcuts.length; i++) {
294
			list.add(new Pair(shortcuts[i], null));
295
		}
296
		return list;
297
	}
298
233
	static class PluginCCIP extends CommandContributionItemParameter implements
299
	static class PluginCCIP extends CommandContributionItemParameter implements
234
			IPluginContribution {
300
			IPluginContribution {
235
301
Lines 263-269 Link Here
263
329
264
	}
330
	}
265
331
266
	private CommandContributionItemParameter getItem(String viewId) {
332
	private CommandContributionItemParameter getItem(String viewId, String secondaryId) {
267
		IViewRegistry reg = WorkbenchPlugin.getDefault().getViewRegistry();
333
		IViewRegistry reg = WorkbenchPlugin.getDefault().getViewRegistry();
268
		IViewDescriptor desc = reg.find(viewId);
334
		IViewDescriptor desc = reg.find(viewId);
269
		if (desc==null) {
335
		if (desc==null) {
Lines 282-287 Link Here
282
		if (makeFast) {
348
		if (makeFast) {
283
			parms.parameters.put(PARAMETER_MAKE_FAST, "true"); //$NON-NLS-1$
349
			parms.parameters.put(PARAMETER_MAKE_FAST, "true"); //$NON-NLS-1$
284
		}
350
		}
351
		if (secondaryId != null) {
352
			parms.parameters.put(PARAMETER_SECONDARY_ID, secondaryId);
353
		}
285
		return parms;
354
		return parms;
286
	}
355
	}
287
356
Lines 305-314 Link Here
305
	}
374
	}
306
375
307
	private ArrayList getParts(IWorkbenchPage page) {
376
	private ArrayList getParts(IWorkbenchPage page) {
308
		ArrayList parts = (ArrayList) openedViews.get(page);
377
		ArrayList parts = new ArrayList();
309
		if (parts == null) {
378
		IViewReference[] refs = page.getViewReferences();
310
			parts = new ArrayList();
379
		for (int i = 0; i < refs.length; i++) {
311
			openedViews.put(page, parts);
380
			parts.add(new Pair(refs[i].getId(), refs[i].getSecondaryId()));
312
		}
381
		}
313
		return parts;
382
		return parts;
314
	}
383
	}

Return to bug 221172