01: package org.eclipse.ui.internal.provisional.views.markers;
02:
03: /*******************************************************************************
04: * Copyright (c) 2007 IBM Corporation and others.
05: * All rights reserved. This program and the accompanying materials
06: * are made available under the terms of the Eclipse Public License v1.0
07: * which accompanies this distribution, and is available at
08: * http://www.eclipse.org/legal/epl-v10.html
09: *
10: * Contributors:
11: * IBM Corporation - initial API and implementation
12: ******************************************************************************/
13:
14: import org.eclipse.core.commands.ExecutionEvent;
15: import org.eclipse.core.commands.IHandler;
16: import org.eclipse.core.resources.IMarker;
17: import org.eclipse.core.runtime.CoreException;
18: import org.eclipse.ui.statushandlers.StatusManager;
19: import org.eclipse.ui.views.bookmarkexplorer.BookmarkPropertiesDialog;
20: import org.eclipse.ui.views.markers.internal.DialogMarkerProperties;
21: import org.eclipse.ui.views.markers.internal.DialogProblemProperties;
22: import org.eclipse.ui.views.markers.internal.DialogTaskProperties;
23:
24: /**
25: * The PropertiesHandler is the handler for opening a properties dialog on a
26: * selected marker.
27: *
28: * @since 3.4
29: *
30: */
31: public class PropertiesHandler extends MarkerViewHandler implements
32: IHandler {
33:
34: /*
35: * (non-Javadoc)
36: *
37: * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
38: */
39: public Object execute(ExecutionEvent event) {
40: ExtendedMarkersView view = getView(event);
41: if (view == null)
42: return this ;
43: // Assume there is only one item selected.
44: IMarker selection = view.getSelectedMarkers()[0];
45: DialogMarkerProperties dialog = null;
46: try {
47: if (selection.isSubtypeOf(IMarker.PROBLEM))
48: dialog = new DialogProblemProperties(view.getSite()
49: .getShell());
50: if (selection.isSubtypeOf(IMarker.TASK))
51: dialog = new DialogTaskProperties(view.getSite()
52: .getShell());
53: if (selection.isSubtypeOf(IMarker.BOOKMARK))
54: dialog = new BookmarkPropertiesDialog(view.getSite()
55: .getShell());
56: } catch (CoreException exception) {
57: StatusManager.getManager().handle(exception.getStatus());
58: }
59: if (dialog == null)
60: return this;
61:
62: dialog.setMarker(selection);
63: dialog.open();
64: return this;
65: }
66: }
|