01: /* uDig - User Friendly Desktop Internet GIS client
02: * http://udig.refractions.net
03: * (C) 2004, Refractions Research Inc.
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation;
08: * version 2.1 of the License.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: */
15: package net.refractions.udig.ui;
16:
17: import org.eclipse.jface.viewers.CellEditor;
18: import org.eclipse.swt.SWT;
19: import org.eclipse.swt.widgets.Composite;
20: import org.eclipse.swt.widgets.Control;
21: import org.eclipse.swt.widgets.Label;
22:
23: /**
24: * A Cell editor that tells the user a message. For example: I'm sorry this cell cannot be edited ( or some such ).
25: *
26: * @author Jesse
27: * @since 1.1.0
28: */
29: public class WarningCellEditor extends CellEditor {
30:
31: private final String warning;
32: private Object value;
33: private Control label;
34:
35: public WarningCellEditor(Composite control, String warning) {
36: this .warning = warning;
37: this .label = createControl(control);
38: }
39:
40: @Override
41: protected Control createControl(Composite parent) {
42: Label label = new Label(parent, SWT.FLAT);
43: label.setText(warning);
44: label.setBackground(label.getDisplay().getSystemColor(
45: SWT.COLOR_YELLOW));
46: return label;
47: }
48:
49: @Override
50: public Control getControl() {
51: return label;
52: }
53:
54: @Override
55: protected Object doGetValue() {
56: return value;
57: }
58:
59: @Override
60: protected void doSetFocus() {
61: }
62:
63: @Override
64: protected void doSetValue(Object value) {
65: this .value = value;
66: }
67:
68: @Override
69: public void dispose() {
70: if (!label.isDisposed())
71: label.dispose();
72: }
73:
74: @Override
75: public void deactivate() {
76: label.setVisible(false);
77: }
78:
79: @Override
80: public void activate() {
81: label.setVisible(true);
82: }
83: }
|