comparison dwtx/ui/forms/AbstractFormPart.d @ 75:5d489b9f966c

Fix continue porting
author Frank Benoit <benoit@tionex.de>
date Sat, 24 May 2008 05:11:16 +0200
parents
children
comparison
equal deleted inserted replaced
74:dad2e11b8ae4 75:5d489b9f966c
1 /*******************************************************************************
2 * Copyright (c) 2000, 2005 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 * Port to the D programming language:
11 * Frank Benoit <benoit@tionex.de>
12 *******************************************************************************/
13 module dwtx.ui.forms.AbstractFormPart;
14
15 import dwtx.ui.forms.IFormPart;
16 import dwtx.ui.forms.IManagedForm;
17
18 import dwt.dwthelper.utils;
19
20 /**
21 * AbstractFormPart implements IFormPart interface and can be used as a
22 * convenient base class for concrete form parts. If a method contains
23 * code that must be called, look for instructions to call 'super'
24 * when overriding.
25 *
26 * @see dwtx.ui.forms.widgets.Section
27 * @since 3.0
28 */
29 public abstract class AbstractFormPart : IFormPart {
30 private IManagedForm managedForm;
31 private bool dirty = false;
32 private bool stale = true;
33 /**
34 * @see dwtx.ui.forms.IFormPart#initialize(dwtx.ui.forms.IManagedForm)
35 */
36 public void initialize(IManagedForm form) {
37 this.managedForm = form;
38 }
39 /**
40 * Returns the form that manages this part.
41 *
42 * @return the managed form
43 */
44 public IManagedForm getManagedForm() {
45 return managedForm;
46 }
47 /**
48 * Disposes the part. Subclasses should override to release any system
49 * resources.
50 */
51 public void dispose() {
52 }
53 /**
54 * Commits the part. Subclasses should call 'super' when overriding.
55 *
56 * @param onSave
57 * <code>true</code> if the request to commit has arrived as a
58 * result of the 'save' action.
59 */
60 public void commit(bool onSave) {
61 dirty = false;
62 }
63 /**
64 * Sets the overall form input. Subclases may elect to override the method
65 * and adjust according to the form input.
66 *
67 * @param input
68 * the form input object
69 * @return <code>false</code>
70 */
71 public bool setFormInput(Object input) {
72 return false;
73 }
74 /**
75 * Instructs the part to grab keyboard focus.
76 */
77 public void setFocus() {
78 }
79 /**
80 * Refreshes the section after becoming stale (falling behind data in the
81 * model). Subclasses must call 'super' when overriding this method.
82 */
83 public void refresh() {
84 stale = false;
85 // since we have refreshed, any changes we had in the
86 // part are gone and we are not dirty
87 dirty = false;
88 }
89 /**
90 * Marks the part dirty. Subclasses should call this method as a result of
91 * user interaction with the widgets in the section.
92 */
93 public void markDirty() {
94 dirty = true;
95 managedForm.dirtyStateChanged();
96 }
97 /**
98 * Tests whether the part is dirty i.e. its widgets have state that is
99 * newer than the data in the model.
100 *
101 * @return <code>true</code> if the part is dirty, <code>false</code>
102 * otherwise.
103 */
104 public bool isDirty() {
105 return dirty;
106 }
107 /**
108 * Tests whether the part is stale i.e. its widgets have state that is
109 * older than the data in the model.
110 *
111 * @return <code>true</code> if the part is stale, <code>false</code>
112 * otherwise.
113 */
114 public bool isStale() {
115 return stale;
116 }
117 /**
118 * Marks the part stale. Subclasses should call this method as a result of
119 * model notification that indicates that the content of the section is no
120 * longer in sync with the model.
121 */
122 public void markStale() {
123 stale = true;
124 managedForm.staleStateChanged();
125 }
126 }