01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.views.markers.internal;
11:
12: import org.eclipse.jface.viewers.ISelectionProvider;
13: import org.eclipse.jface.viewers.IStructuredSelection;
14: import org.eclipse.ui.IWorkbenchPart;
15: import org.eclipse.ui.actions.SelectionProviderAction;
16:
17: /**
18: * ActionMarkerProperties is the action for opening a properties dialog.
19: *
20: */
21: public class ActionMarkerProperties extends SelectionProviderAction {
22:
23: private IWorkbenchPart part;
24:
25: private String markerName;
26:
27: /**
28: * Create a new instance of the receiver.
29: *
30: * @param part
31: * @param provider
32: * @param markerName
33: * the name describing the specific type of marker.
34: */
35: public ActionMarkerProperties(IWorkbenchPart part,
36: ISelectionProvider provider, String markerName) {
37: super (provider, MarkerMessages.propertiesAction_title);
38: setEnabled(false);
39: this .part = part;
40: this .markerName = markerName;
41: }
42:
43: /*
44: * (non-Javadoc)
45: *
46: * @see org.eclipse.jface.action.Action#run()
47: */
48: public void run() {
49: if (!isEnabled()) {
50: return;
51: }
52: Object obj = getStructuredSelection().getFirstElement();
53: if (!(obj instanceof ConcreteMarker)) {
54: return;
55: }
56: ConcreteMarker marker = (ConcreteMarker) obj;
57: DialogMarkerProperties dialog = new DialogMarkerProperties(part
58: .getSite().getShell(),
59: MarkerMessages.propertiesDialog_title, markerName);
60: dialog.setMarker(marker.getMarker());
61: dialog.open();
62: }
63:
64: /*
65: * (non-Javadoc)
66: *
67: * @see org.eclipse.ui.actions.SelectionProviderAction#selectionChanged(org.eclipse.jface.viewers.IStructuredSelection)
68: */
69: public void selectionChanged(IStructuredSelection selection) {
70: setEnabled(selection != null && selection.size() == 1);
71: }
72: }
|