Example #1
0
 /**
  * Action!
  *
  * @see org.scilab.modules.gui.events.callback.CallBack#callBack()
  */
 @Override
 public void callBack() {
   CommonCallBack copyAction = new CopyAction();
   copyAction.callBack();
   CommonCallBack deleteAction = new DeleteAction();
   deleteAction.callBack();
 }
  public void update(int property, Object value) {
    switch (property) {
      case __GO_VISIBLE__:
        setVisible((Boolean) value);
        break;
      case __GO_UI_TITLE_POSITION__:
        Integer pos = (Integer) value;
        switch (Uicontrol.TitlePositionType.intToEnum(pos)) {
          case BOTTOM:
            setTabPlacement(JTabbedPane.BOTTOM);
            break;
          case LEFT:
            setTabPlacement(JTabbedPane.LEFT);
            break;
          case RIGHT:
            setTabPlacement(JTabbedPane.RIGHT);
            break;
          case TOP:
          default:
            setTabPlacement(JTabbedPane.TOP);
            break;
        }
        break;
      case __GO_UI_TITLE_SCROLL__:
        if ((Boolean) value) {
          setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
        } else {
          setTabLayoutPolicy(JTabbedPane.WRAP_TAB_LAYOUT);
        }
        break;
      case __GO_UI_FONTNAME__:
      case __GO_UI_FONTANGLE__:
      case __GO_UI_FONTSIZE__:
      case __GO_UI_FONTWEIGHT__:
        {
          for (int i = 0; i < getTabCount(); i++) {
            setTitleAt(i, null);
          }
          break;
        }
      case __GO_POSITION__:
        {
          Double[] positions = (Double[]) value;
          setSize(positions[2].intValue(), positions[3].intValue());
          Position javaPosition =
              PositionConverter.scilabToJava(
                  new Position(positions[0].intValue(), positions[1].intValue()),
                  new Size(getSize().width, getSize().height),
                  getParent());
          setLocation(javaPosition.getX(), javaPosition.getY());
          break;
        }
      case __GO_UI_VALUE__:
        {
          Double[] doubleValue = ((Double[]) value);
          if (doubleValue.length == 0) {
            return;
          }

          Integer val = doubleValue[0].intValue();
          // if intValue[0] is out of bounds, do not update view but let "wrong" value in model
          if (val > 0 && val <= getTabCount()) {
            setSelectedIndex(val - 1);
          }
          break;
        }
      case __GO_UI_STRING__:
        {
          // set tab by his name
          String name = ((String[]) value)[0];
          for (int i = 0; i < getTabCount(); i++) {
            JLabel current = (JLabel) getTabComponentAt(i);
            if (current != null && current.getText() != null && current.getText().equals(name)) {
              setSelectedIndex(i);
              break;
            }
          }
          break;
        }
      case __GO_CALLBACK__:
        {
          int cbType =
              (Integer) GraphicController.getController().getProperty(getId(), __GO_CALLBACKTYPE__);
          callback = CommonCallBack.createCallback((String) value, cbType, getId());
          break;
        }
      case __GO_CALLBACKTYPE__:
        {
          String cbString =
              (String) GraphicController.getController().getProperty(getId(), __GO_CALLBACK__);
          if ((Integer) value == CallBack.UNTYPED) {
            // Disable callback
            callback = null;
          } else {
            callback = CommonCallBack.createCallback(cbString, (Integer) value, getId());
          }
          break;
        }
      default:
        {
          SwingViewWidget.update(this, property, value);
        }
    }
  }