comparison org.eclipse.ui.forms/src/org/eclipse/ui/forms/AbstractFormPart.d @ 12:bc29606a740c

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