01: package net.refractions.udig.style.ui;
02:
03: import net.refractions.udig.project.internal.Layer;
04:
05: import org.eclipse.jface.action.IAction;
06: import org.eclipse.jface.viewers.ISelection;
07: import org.eclipse.jface.viewers.IStructuredSelection;
08: import org.eclipse.jface.viewers.StructuredSelection;
09: import org.eclipse.swt.widgets.Display;
10: import org.eclipse.ui.IWorkbenchPage;
11: import org.eclipse.ui.IWorkbenchWindow;
12: import org.eclipse.ui.IWorkbenchWindowActionDelegate;
13: import org.eclipse.ui.PartInitException;
14: import org.eclipse.ui.PlatformUI;
15:
16: public class EditStyleAction implements IWorkbenchWindowActionDelegate {
17:
18: public final static String ID = "net.refractions.udig.style.openStyleEditorAction"; //$NON-NLS-1$
19:
20: private Layer selectedLayer;
21:
22: public void dispose() {
23: }
24:
25: public void init(IWorkbenchWindow window) {
26:
27: }
28:
29: public void run(IAction action) {
30: Display.getDefault().asyncExec(new Runnable() {
31: public void run() {
32: StyleView styleView = null;
33: try {
34: IWorkbenchPage page = PlatformUI.getWorkbench()
35: .getActiveWorkbenchWindow().getActivePage();
36: page.showView(StyleView.VIEW_ID);
37:
38: //styleView = (StyleView)
39: //if (selectedLayer != null);
40: //styleView.setSelectedLayer(selectedLayer);
41: } catch (PartInitException e2) {
42: e2.printStackTrace();
43: }
44: }
45: });
46: }
47:
48: public void selectionChanged(IAction action, ISelection selection) {
49: if (selection.isEmpty()
50: || !(selection instanceof IStructuredSelection))
51: return;
52:
53: StructuredSelection sselection = (StructuredSelection) selection;
54: if (sselection.getFirstElement() instanceof Layer) {
55: selectedLayer = (Layer) sselection.getFirstElement();
56: }
57: }
58:
59: }
|