KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > views > markers > internal > ActionMarkerProperties


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.ui.views.markers.internal;
13
14 import org.eclipse.jface.viewers.ISelectionProvider;
15 import org.eclipse.jface.viewers.IStructuredSelection;
16 import org.eclipse.ui.IWorkbenchPart;
17 import org.eclipse.ui.actions.SelectionProviderAction;
18
19 /**
20  * ActionMarkerProperties is the action for opening a properties dialog.
21  *
22  */

23 public class ActionMarkerProperties extends SelectionProviderAction {
24
25     private IWorkbenchPart part;
26
27     private String JavaDoc markerName;
28
29     /**
30      * Create a new instance of the receiver.
31      *
32      * @param part
33      * @param provider
34      * @param markerName
35      * the name describing the specific type of marker.
36      */

37     public ActionMarkerProperties(IWorkbenchPart part,
38             ISelectionProvider provider, String JavaDoc markerName) {
39         super(provider, MarkerMessages.propertiesAction_title);
40         setEnabled(false);
41         this.part = part;
42         this.markerName = markerName;
43     }
44
45     /*
46      * (non-Javadoc)
47      *
48      * @see org.eclipse.jface.action.Action#run()
49      */

50     public void run() {
51         if (!isEnabled()) {
52             return;
53         }
54         Object JavaDoc obj = getStructuredSelection().getFirstElement();
55         if (!(obj instanceof ConcreteMarker)) {
56             return;
57         }
58         ConcreteMarker marker = (ConcreteMarker) obj;
59         DialogMarkerProperties dialog = new DialogMarkerProperties(part
60                 .getSite().getShell(), MarkerMessages.propertiesDialog_title, markerName);
61         dialog.setMarker(marker.getMarker());
62         dialog.open();
63     }
64
65     /*
66      * (non-Javadoc)
67      *
68      * @see org.eclipse.ui.actions.SelectionProviderAction#selectionChanged(org.eclipse.jface.viewers.IStructuredSelection)
69      */

70     public void selectionChanged(IStructuredSelection selection) {
71         setEnabled(selection != null && selection.size() == 1);
72     }
73 }
74
Popular Tags