/** @see java.awt.event.KeyListener#keyPressed(java.awt.event.KeyEvent) */ public void keyPressed(KeyEvent ke) { int key = ke.getKeyCode(); if (key == KeyEvent.VK_UP || key == KeyEvent.VK_DOWN) { CompartmentFigText ft = unhighlight(); if (ft != null) { int i = new Vector(getAttributesFig().getFigs()).indexOf(ft); FigGroup fg = getAttributesFig(); if (i == -1) { i = new Vector(getOperationsFig().getFigs()).indexOf(ft); fg = getOperationsFig(); } if (i != -1) { if (key == KeyEvent.VK_UP) { ft = (CompartmentFigText) getPreviousVisibleFeature(fg, ft, i); } else { ft = (CompartmentFigText) getNextVisibleFeature(fg, ft, i); } if (ft != null) { ft.setHighlighted(true); highlightedFigText = ft; return; } } } } else if (key == KeyEvent.VK_ENTER && highlightedFigText != null) { highlightedFigText.startTextEditor(ke); ke.consume(); return; } super.keyPressed(ke); }
public void setEnclosingFig(Fig encloser) { if (encloser == getEncloser()) { return; } if (encloser == null || (encloser != null && !Model.getFacade().isAInstance(encloser.getOwner()))) { super.setEnclosingFig(encloser); } if (!(Model.getFacade().isAUMLElement(getOwner()))) { return; } if (encloser != null && (Model.getFacade().isAComponent(encloser.getOwner()))) { moveIntoComponent(encloser); super.setEnclosingFig(encloser); } }
/** @see org.argouml.uml.diagram.ui.FigNodeModelElement#renderingChanged() */ public void renderingChanged() { if (getOwner() != null) { updateAttributes(); updateOperations(); updateAbstract(); } super.renderingChanged(); }
/** @see org.tigris.gef.presentation.Fig#translate(int, int) */ public void translate(int dx, int dy) { super.translate(dx, dy); Editor ce = Globals.curEditor(); Selection sel = ce.getSelectionManager().findSelectionFor(this); if (sel instanceof SelectionClass) { ((SelectionClass) sel).hideButtons(); } }
/** * @see * org.argouml.uml.diagram.ui.FigNodeModelElement#textEditStarted(org.tigris.gef.presentation.FigText) */ protected void textEditStarted(FigText ft) { super.textEditStarted(ft); if (getAttributesFig().getFigs().contains(ft)) { showHelp("parsing.help.attribute"); } if (getOperationsFig().getFigs().contains(ft)) { showHelp("parsing.help.operation"); } }
/** Updates the name if modelchanged receives an "isAbstract" event. */ protected void updateAbstract() { Rectangle rect = getBounds(); if (getOwner() == null) { return; } Object cls = /*(MClass)*/ getOwner(); if (Model.getFacade().isAbstract(cls)) { getNameFig().setFont(getItalicLabelFont()); } else { getNameFig().setFont(getLabelFont()); } super.updateNameText(); setBounds(rect.x, rect.y, rect.width, rect.height); }
/** @see org.tigris.gef.presentation.Fig#setEnclosingFig(org.tigris.gef.presentation.Fig) */ public void setEnclosingFig(Fig encloser) { if (encloser == null || (encloser != null && !Model.getFacade().isAInstance(encloser.getOwner()))) { super.setEnclosingFig(encloser); } if (!(Model.getFacade().isAModelElement(getOwner()))) return; if (encloser != null && (Model.getFacade().isAComponent(encloser.getOwner()))) { Object component = /*(MComponent)*/ encloser.getOwner(); Object in = /*(MInterface)*/ getOwner(); Model.getCoreHelper().setContainer(resident, component); Model.getCoreHelper().setResident(resident, in); } else { Model.getCoreHelper().setContainer(resident, null); Model.getCoreHelper().setResident(resident, null); } }
/** * @see * org.argouml.uml.diagram.ui.FigNodeModelElement#textEdited(org.tigris.gef.presentation.FigText) */ protected void textEdited(FigText ft) throws PropertyVetoException { super.textEdited(ft); Object classifier = getOwner(); if (classifier == null) { return; } int i = new Vector(getAttributesFig().getFigs()).indexOf(ft); if (i != -1) { highlightedFigText = (CompartmentFigText) ft; highlightedFigText.setHighlighted(true); try { Object attribute = highlightedFigText.getOwner(); ParserDisplay.SINGLETON.parseAttributeFig( classifier, attribute, highlightedFigText.getText().trim()); ProjectBrowser.getInstance().getStatusBar().showStatus(""); } catch (ParseException pe) { String msg = "statusmsg.bar.error.parsing.attribute"; Object[] args = {pe.getLocalizedMessage(), new Integer(pe.getErrorOffset())}; ProjectBrowser.getInstance().getStatusBar().showStatus(Translator.messageFormat(msg, args)); } return; } i = new Vector(getOperationsFig().getFigs()).indexOf(ft); if (i != -1) { highlightedFigText = (CompartmentFigText) ft; highlightedFigText.setHighlighted(true); try { Object operation = highlightedFigText.getOwner(); ParserDisplay.SINGLETON.parseOperationFig( classifier, operation, highlightedFigText.getText().trim()); ProjectBrowser.getInstance().getStatusBar().showStatus(""); } catch (ParseException pe) { String msg = "statusmsg.bar.error.parsing.operation"; Object[] args = {pe.getLocalizedMessage(), new Integer(pe.getErrorOffset())}; ProjectBrowser.getInstance().getStatusBar().showStatus(Translator.messageFormat(msg, args)); } return; } }
/** @see org.argouml.uml.diagram.ui.FigNodeModelElement#updateListeners(java.lang.Object) */ protected void updateListeners(Object newOwner) { Object oldOwner = getOwner(); if (oldOwner != null && oldOwner != newOwner) { // remove the listeners if the owner is changed Iterator it = Model.getFacade().getFeatures(oldOwner).iterator(); while (it.hasNext()) { Object feat = it.next(); Model.getPump().removeModelEventListener(this, feat); Collection c = new ArrayList(Model.getFacade().getStereotypes(feat)); if (Model.getFacade().isAOperation(feat)) { c.addAll(Model.getFacade().getParameters(feat)); } Iterator it2 = c.iterator(); while (it2.hasNext()) { Object obj = it2.next(); Model.getPump().removeModelEventListener(this, obj); } } } if (newOwner != null) { // add the listeners to the newOwner Iterator it = Model.getFacade().getFeatures(newOwner).iterator(); while (it.hasNext()) { Object feat = it.next(); Collection c = new ArrayList(Model.getFacade().getStereotypes(feat)); if (Model.getFacade().isAOperation(feat)) { c.addAll(Model.getFacade().getParameters(feat)); } Iterator it2 = c.iterator(); while (it2.hasNext()) { Object obj = it2.next(); Model.getPump().addModelEventListener(this, obj); } } } super.updateListeners(newOwner); }
/** @see org.argouml.uml.diagram.ui.FigNodeModelElement#updateNameText() */ protected void updateNameText() { super.updateNameText(); calcBounds(); setBounds(getBounds()); }
/** * Handles changes of the model. Takes into account the event that occured. If you need to update * the whole fig, consider using renderingChanged. * * @see * org.argouml.uml.diagram.ui.FigNodeModelElement#modelChanged(java.beans.PropertyChangeEvent) */ protected void modelChanged(PropertyChangeEvent mee) { if (getOwner() == null) { return; } Object source = null; if (mee != null) { source = mee.getSource(); } else { LOG.warn( "ModelChanged called with no event. " + "Please javadoc the situation in which this can happen"); } // attributes if (mee == null || Model.getFacade().isAAttribute(source) || (source == getOwner() && mee.getPropertyName().equals("feature"))) { updateAttributes(); damage(); } // operations if (mee == null || Model.getFacade().isAOperation(source) || Model.getFacade().isAParameter(source) || (source == getOwner() && mee.getPropertyName().equals("feature"))) { updateOperations(); damage(); } if (mee != null && mee.getPropertyName().equals("parameter") && Model.getFacade().isAOperation(source)) { if (mee instanceof AddAssociationEvent) { AddAssociationEvent aae = (AddAssociationEvent) mee; /* Ensure we will get an event for the name change of * the newly created attribute: */ Model.getPump() .addModelEventListener( this, aae.getChangedValue(), new String[] {"name", "kind", "type", "defaultValue"}); damage(); return; } else if (mee instanceof RemoveAssociationEvent) { RemoveAssociationEvent rae = (RemoveAssociationEvent) mee; Model.getPump().removeModelEventListener(this, rae.getChangedValue()); damage(); return; } } if (mee == null || mee.getPropertyName().equals("isAbstract")) { updateAbstract(); damage(); } if (mee == null || mee.getPropertyName().equals("stereotype")) { updateListeners(getOwner()); updateStereotypeText(); updateAttributes(); updateOperations(); damage(); } if (mee != null && Model.getFacade().isAStereotype(source)) { if (Model.getFacade().getStereotypes(getOwner()).contains(source)) { updateStereotypeText(); damage(); } else if (mee.getPropertyName().equals("name")) { updateAttributes(); updateOperations(); damage(); } } // name updating super.modelChanged(mee); }