@Override public void setSelected(boolean select) { super.setSelected(select); component.select(); if (select) component.notifyObservers(UpdateMessage.SELECT); else component.notifyObservers(UpdateMessage.UNSELECT); if (!select) for (final TextBox t : getAllTextBox()) t.setSelected(false); }
/** Create a new method with default type and name, without parameter. */ public void addMethod() { final Method method = new Method("method", PrimitiveType.VOID_TYPE, Visibility.PUBLIC, component); prepareNewMethod(method); if (component.addMethod(method)) component.notifyObservers(UpdateMessage.ADD_METHOD); }
/** Create a new attribute with default type and name. */ public void addAttribute() { final Attribute attribute = new Attribute("attribute", PrimitiveType.VOID_TYPE); prepareNewAttribute(attribute); component.addAttribute(attribute); component.notifyObservers(UpdateMessage.ADD_ATTRIBUTE); }
/** * Remove the method associated with TextBoxMethod from model (UML) * * @param tbMethod the method to remove. * @return true if component has been removed; false otherwise. */ public boolean removeMethod(TextBoxMethod tbMethod) { if (component.removeMethod((Method) tbMethod.getAssociedComponent())) { component.notifyObservers(); updateHeight(); return true; } return false; }
/** * Remove the attribute associated with TextBoxAttribute from model (UML). * * @param tbAttribute the attribute to remove. * @return true if the attribute has been removed; false otherwise */ public boolean removeAttribute(TextBoxAttribute tbAttribute) { if (component.removeAttribute((Attribute) tbAttribute.getAssociedComponent())) { component.notifyObservers(); updateHeight(); return true; } return false; }
@Override public void actionPerformed(ActionEvent e) { super.actionPerformed(e); if ("AddMethod".equals(e.getActionCommand())) addMethod(); else if ("AddAttribute".equals(e.getActionCommand())) addAttribute(); else if ("Delete".equals(e.getActionCommand())) { if (SMessageDialog.showQuestionMessageYesNo( "Are you sur to delete this component and all its associated components?") == JOptionPane.NO_OPTION) return; if (pressedTextBox != null) removeTextBox(pressedTextBox); else delete(); } else if ("ViewAttribute".equals(e.getActionCommand())) { parent.showAttributsForSelectedEntity(true); parent.showMethodsForSelectedEntity(false); } else if ("ViewMethods".equals(e.getActionCommand())) { parent.showAttributsForSelectedEntity(false); parent.showMethodsForSelectedEntity(true); } else if ("ViewAll".equals(e.getActionCommand())) { parent.showAttributsForSelectedEntity(true); parent.showMethodsForSelectedEntity(true); } else if ("ViewNothing".equals(e.getActionCommand())) { parent.showAttributsForSelectedEntity(false); parent.showMethodsForSelectedEntity(false); } else if ("ViewTypeAndName".equals(e.getActionCommand())) methodViewChangeClicked(ParametersViewStyle.TYPE_AND_NAME); else if ("ViewType".equals(e.getActionCommand())) methodViewChangeClicked(ParametersViewStyle.TYPE); else if ("ViewName".equals(e.getActionCommand())) methodViewChangeClicked(ParametersViewStyle.NAME); else if ("ViewMethodNothing".equals(e.getActionCommand())) methodViewChangeClicked(ParametersViewStyle.NOTHING); else if (Slyum.ACTION_TEXTBOX_UP.equals(e.getActionCommand()) || Slyum.ACTION_TEXTBOX_DOWN.equals(e.getActionCommand())) { int offset = 1; if (Slyum.ACTION_TEXTBOX_UP.equals(e.getActionCommand())) offset = -1; if (pressedTextBox.getClass() == TextBoxAttribute.class) { final Attribute attribute = (Attribute) ((TextBoxAttribute) pressedTextBox).getAssociedComponent(); component.moveAttributePosition(attribute, offset); } else if (pressedTextBox.getClass() == TextBoxMethod.class) { final Method method = (Method) ((TextBoxMethod) pressedTextBox).getAssociedComponent(); component.moveMethodPosition(method, offset); } component.notifyObservers(); } }