001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.uml.ui.controls.editcontrol;
043:
044: import java.util.Vector;
045:
046: import org.netbeans.modules.uml.common.generics.ETPairT;
047: import org.netbeans.modules.uml.core.metamodel.core.foundation.IElement;
048: import org.netbeans.modules.uml.core.support.umlutils.IPropertyDefinition;
049: import org.netbeans.modules.uml.core.support.umlutils.IPropertyElement;
050:
051: public interface ITranslator {
052: /**
053: * Gets/Sets the Model Element
054: */
055: public IElement getElement();
056:
057: /**
058: * Gets/Sets the Model Element
059: */
060: public void setElement(IElement value);
061:
062: /**
063: * Sets/Returns the AxEdit control (if setting, re-initializes the translator).
064: */
065: public IEditControl getEditControl();
066:
067: /**
068: * Sets/Returns the AxEdit control (if setting, re-initializes the translator).
069: */
070: public void setEditControl(IEditControl value);
071:
072: /**
073: * Sets the AxEdit control, does not re-initialize.
074: */
075: public void setEditControl2(IEditControl value);
076:
077: /**
078: * Returns the formatted string value for this translator's Model Element
079: */
080: public String getSimple();
081:
082: /**
083: * Returns the current formatted string value for this translator (after editing)
084: */
085: public String getCurrent();
086:
087: /**
088: * Gets a TextFields collection breaking down the translated string into its constituents.
089: */
090: public Vector getTextFields();
091:
092: /**
093: * Get/Sets the caret position.
094: */
095: public int getPosition();
096:
097: /**
098: * Get/Sets the caret position.
099: */
100: public void setPosition(int value);
101:
102: /**
103: * Updates the starting and ending positions within the edit control of the editable text contained by this translator.
104: */
105: public int getTextStartPos();
106:
107: public int getTextEndPos();
108:
109: /**
110: * Returns the starting add ending positions within the edit control of the text contained by this translator.
111: */
112: public int getFieldStartPos();
113:
114: public int getFieldEndPos();
115:
116: /**
117: * Returns the starting position within the edit control of the text contained by this translator.
118: */
119: public void setFieldPos(int nStartPosition);
120:
121: /**
122: * Sets the current selection.
123: */
124: public void setPosition(int nStartPos, int nEndPos);
125:
126: /**
127: * Processes KeyDown notifications from the edit control.
128: */
129: public boolean handleKeyDown(int nKey);
130:
131: /**
132: * Processes KeyUp notifications from the edit control.
133: */
134: public boolean handleKeyUp(int nKey);
135:
136: /**
137: * Processes character keypress notifications from the edit control.
138: */
139: public boolean handleChar(String nChangedChar);
140:
141: public boolean handleDelete(boolean deleteRightwards);
142:
143: /**
144: * Processes a left mouse button down event.
145: */
146: public boolean handleLButtonDown(int nPosition);
147:
148: /**
149: * Processes a left mouse button double click event.
150: */
151: public boolean handleLButtonDblClk(int nPosition);
152:
153: /**
154: * Processes a left mouse button triple click event.
155: */
156: public boolean handleLButtonTripleClk(int nPosition);
157:
158: /**
159: * Called by the edit control with it initially gains focus (except via the mouse)
160: */
161: public void onSetFocus();
162:
163: /**
164: * Commits this translator's modelelement.
165: */
166: public void saveModelElement();
167:
168: /**
169: * Sets the internal position pointer without updating the edit control.
170: */
171: public void setCurrentPosition(int nPos);
172:
173: /**
174: * Hides fields with no data, call after manually updating fields to affect the display.
175: */
176: public void updateVisibleFields(IEditControlField pField);
177:
178: /**
179: * Cuts the selected text from the edit control to the Clipboard.
180: */
181: public void cutToClipboard();
182:
183: /**
184: * Pastes the Clipboard contents in the the text field at the current position.
185: */
186: public void pasteFromClipboard();
187:
188: /**
189: * Copies the selected text into the Clipboard.
190: */
191: public void copyToClipboard();
192:
193: /**
194: * Returns the tooltip text for translators that contain multiple fields.
195: */
196: public String getTooltipLeftText();
197:
198: public String getTooltipSubjectText();
199:
200: public String getTooltipRightText();
201:
202: public String getTooltipText();
203:
204: /**
205: * Reload the tooltip's data.
206: */
207: public void updateToolTip();
208:
209: public void updateHints();
210:
211: /**
212: * Reads and formats the internal components of the model element for editing.
213: */
214: public void initTextFields();
215:
216: /**
217: * Inserts a new text field that is described by a property element.
218: */
219: public void addField(IPropertyElement pData, boolean bNoUpdate);
220:
221: /**
222: * Helper to save this element's fields. Called by SaveModelElement().
223: */
224: public void saveFields();
225:
226: /**
227: * Called by the edit control on mouse moves.
228: */
229: public void onMouseMove(int x, int y);
230:
231: /**
232: * Responds to hint window being clicked.
233: */
234: public void handleHint();
235:
236: /**
237: * Responds to hint list window being closed.
238: */
239: public IEditControlField handleHintText(String sText);
240:
241: /**
242: * If the keychar is a separator, performs the appropriate action.
243: */
244: public ETPairT<Boolean, Boolean> handleSeparator(int nChar,
245: int nCurrentPos);
246:
247: /**
248: * If the keychar is a separator, performs the appropriate action.
249: */
250: public boolean handleTopLevelSeparators(int nChar);
251:
252: /**
253: * Inserts a new text field that is described by a property definition.
254: */
255: public IEditControlField addFieldDefinition(
256: IPropertyDefinition pDefinition,
257: IEditControlField pInsertField);
258:
259: /**
260: * Temporary
261: */
262: public void dump(String sPad);
263:
264: /**
265: * Returns the next text field following pPreviousField, or the first field if pPreviousField is 0.
266: */
267: public IEditControlField getNextField(
268: IEditControlField pPreviousField);
269:
270: /**
271: * Returns the previous text field preceeding pNextField, or the last field if pNextField is 0.
272: */
273: public IEditControlField getPreviousField(
274: IEditControlField pNextField);
275:
276: /**
277: * Attaches a collection of property elements to their respective fields. The fields' data is not reloaded.
278: */
279: public void updateFields(Vector pElements);
280:
281: /**
282: * Get/Set the textfield that contains this translator, if applicable.
283: */
284: public IEditControlField getParentField();
285:
286: /**
287: * Get/Set the textfield that contains this translator, if applicable.
288: */
289: public void setParentField(IEditControlField value);
290:
291: /**
292: * Recalculates field positions rightward from the current field.
293: */
294: public void updateFieldPositions(IEditControlField pCurrent);
295:
296: /**
297: * For translators with repeating fields, add a new, empty field.
298: */
299: public boolean handleDelimitor(int nChar, int m_nCurrentPos);
300:
301: /**
302: * Informs the field that editing is complete and it should re-format itself depending on its rules.
303: */
304: public void updateField(IEditControlField pField);
305:
306: /**
307: * Is this translator deleted?
308: */
309: public boolean getDeleted();
310:
311: /**
312: * Is this translator deleted?
313: */
314: public void setDeleted(boolean value);
315:
316: /**
317: * Causes enabled field to be displayed, or hidden.
318: */
319: public void enableFields(boolean EnableFields);
320:
321: /**
322: * Is this translator modified?
323: */
324: public boolean getModified();
325:
326: /**
327: * Is this translator modified?
328: */
329: public void setModified(boolean value);
330:
331: /**
332: * Returns the text field that the caret is currently in.
333: */
334: public IEditControlField getCurrentField();
335:
336: /**
337: * Tells the translator to register its accelerators with the edit control.
338: */
339: public void registerAccelerators();
340:
341: /**
342: * Called when an accelerator is pressed.
343: */
344: public boolean handleAccelerator(int nChar);
345:
346: /**
347: * gets the text position of last visible text field
348: */
349: public int getLastTextStartPos();
350: }
|