Example #1
0
  @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);
  }
Example #2
0
  @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();
    }
  }
Example #3
0
  @Override
  public void maybeShowPopup(MouseEvent e, JPopupMenu popupMenu) {
    if (e.isPopupTrigger()) {
      String text = "Delete ";

      // if context menu is requested on a TextBox, customize popup menu.
      if (pressedTextBox != null) {
        text += pressedTextBox.getText();
        menuItemMoveUp.setEnabled(
            attributesView.indexOf(pressedTextBox) != 0
                && methodsView.indexOf(pressedTextBox) != 0);
        menuItemMoveDown.setEnabled(
            (attributesView.size() == 0
                    || attributesView.indexOf(pressedTextBox) != attributesView.size() - 1)
                && (methodsView.size() == 0
                    || methodsView.indexOf(pressedTextBox) != methodsView.size() - 1));
      } else {
        text += component.getName();
        menuItemMoveUp.setEnabled(false);
        menuItemMoveDown.setEnabled(false);
      }
      menuItemDelete.setText(text);
    }

    super.maybeShowPopup(e, popupMenu);
  }
Example #4
0
  @Override
  public void gMouseClicked(MouseEvent e) {
    super.gMouseClicked(e);

    final TextBox textBox = GraphicView.searchComponentWithPosition(getAllTextBox(), e.getPoint());

    if (textBox != null) {
      final AbstractIDiagramComponent idc = textBox.getAssociedComponent();

      if (idc != null) {
        idc.select();
        idc.notifyObservers(UpdateMessage.SELECT);
      }

      if (e.getClickCount() == 2) textBox.editing();
    }
  }
Example #5
0
  /** Adjust the width according to its content. */
  public void adjustWidth() {
    int width = Short.MIN_VALUE;

    for (final TextBox tb : getAllTextBox()) {
      final int tbWidth = tb.getTextDim().width;

      if (tbWidth > width) width = tbWidth; // get the longer content
    }

    // change the width according to the grid
    final Rectangle bounds = getBounds();

    Change.push(new BufferBounds(this));
    setBounds(
        new Rectangle(bounds.x, bounds.y, width + GraphicView.getGridSize() + 15, bounds.height));
    Change.push(new BufferBounds(this));
  }