01: package net.refractions.udig.style.sld.editor;
02:
03: import net.refractions.udig.project.internal.Layer;
04: import net.refractions.udig.style.IStyleConfigurator;
05:
06: import org.eclipse.swt.SWT;
07: import org.eclipse.swt.layout.GridData;
08: import org.eclipse.swt.layout.RowLayout;
09: import org.eclipse.swt.widgets.Composite;
10: import org.geotools.event.GTEvent;
11:
12: public class StyleEditorPageAdapter extends StyleEditorPage {
13: IStyleConfigurator configurator;
14:
15: public static final String XPID = "net.refractions.udig.style.styleConfigurator"; //$NON-NLS-1$
16:
17: public StyleEditorPageAdapter(IStyleConfigurator configurator) {
18: this .configurator = configurator;
19: }
20:
21: @Override
22: public void createPageContent(Composite parent) {
23: Composite configHolder = new Composite(parent, SWT.NONE);
24: RowLayout layout = new RowLayout(SWT.HORIZONTAL);
25: layout.pack = false;
26: layout.wrap = true;
27: layout.type = SWT.HORIZONTAL;
28: layout.fill = true;
29: layout.marginLeft = 0;
30: layout.marginRight = 0;
31: layout.marginTop = 0;
32: layout.marginBottom = 0;
33: layout.spacing = 0;
34: configHolder.setLayout(layout);
35: GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
36: gd.widthHint = 400;
37: configHolder.setLayoutData(gd);
38:
39: configurator.createControl(configHolder);
40:
41: Layer selectedLayer = getContainer().getSelectedLayer();
42: if (configurator.canStyle(selectedLayer)) {
43:
44: configurator.setAction(getContainer().getApplyAction());
45: configurator.focus(selectedLayer);
46: }
47: }
48:
49: @Override
50: public String getLabel() {
51: return null;
52: }
53:
54: @Override
55: public boolean performCancel() {
56: return false;
57: }
58:
59: @Override
60: public String getErrorMessage() {
61: return null;
62: }
63:
64: public void styleChanged(GTEvent event) {
65: //do nothing
66: }
67:
68: public void gotFocus() {
69: refresh();
70: };
71:
72: public boolean okToLeave() {
73: return true;
74: }
75:
76: public boolean performOk() {
77: return false;
78: }
79:
80: public boolean performApply() {
81: configurator.preApply();
82: return true;
83: }
84:
85: public void refresh() {
86: configurator.setAction(getContainer().getApplyAction());
87: configurator.focus(getSelectedLayer());
88: }
89:
90: }
|