01: package org.drools.eclipse.flow.common.view.property;
02:
03: /*
04: * Copyright 2005 JBoss Inc
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: import org.eclipse.jface.dialogs.Dialog;
20: import org.eclipse.swt.SWT;
21: import org.eclipse.swt.graphics.Point;
22: import org.eclipse.swt.widgets.Shell;
23:
24: /**
25: * Dialog for editing a JavaBean.
26: *
27: * @author <a href="mailto:kris_verlaenen@hotmail.com">Kris Verlaenen</a>
28: */
29: public abstract class EditBeanDialog extends Dialog {
30:
31: private String title;
32: private Object value;
33:
34: protected EditBeanDialog(Shell parentShell, String title) {
35: super (parentShell);
36: this .title = title;
37: setShellStyle(getShellStyle() | SWT.RESIZE);
38: }
39:
40: protected void configureShell(Shell newShell) {
41: super .configureShell(newShell);
42: newShell.setText(title);
43: }
44:
45: protected Point getInitialSize() {
46: return new Point(400, 200);
47: }
48:
49: public Object getValue() {
50: return value;
51: }
52:
53: protected void okPressed() {
54: try {
55: value = updateValue(value);
56: super .okPressed();
57: } catch (IllegalArgumentException e) {
58: // value could not be set, ignoring ok
59: }
60: }
61:
62: protected abstract Object updateValue(Object value);
63:
64: public void setValue(Object value) {
65: this.value = value;
66: }
67: }
|