Exemple #1
0
 /**
  * Action!
  *
  * @see org.scilab.modules.gui.events.callback.CallBack#callBack()
  */
 @Override
 public void callBack() {
   try {
     asynchronousScilabExec(null, "clear('" + getSelectedVariable() + "'); updatebrowsevar()");
   } catch (InterpreterException e1) {
     System.err.println(
         "An error in the interpreter has been catched: " + e1.getLocalizedMessage());
   }
 }
  /**
   * Start the variable editor
   *
   * @param variableVisibility the visibility of the variable
   * @param variableName The variable name
   */
  public void startEditVar(String variableVisibility, String variableName) {
    // Global variables are not editable yet
    if (variableVisibility.equals("global")) {
      ScilabModalDialog.show(
          getBrowserTab(),
          UiDataMessages.GLOBAL_NOT_EDITABLE,
          UiDataMessages.VARIABLE_EDITOR,
          IconType.ERROR_ICON);
      return;
    }

    try {
      asynchronousScilabExec(
          null,
          "if exists(\""
              + variableName
              + "\") == 1 then "
              + "  try "
              + "    editvar(\""
              + variableName
              + "\"); "
              + "  catch "
              + "    messagebox(\"Variables of type \"\"\" + typeof ("
              + variableName
              + ") + \"\"\" can not be edited.\""
              + ",\""
              + UiDataMessages.VARIABLE_EDITOR
              + "\", \"error\", \"modal\");"
              + "    clear ans;" // clear return value of messagebox
              + "  end "
              + "else "
              + "  messagebox(\"Variable \"\""
              + variableName
              + "\"\" no more exists.\""
              + ",\""
              + UiDataMessages.VARIABLE_EDITOR
              + "\", \"error\", \"modal\");"
              + "  clear ans;" // clear return value of messagebox
              + "  browsevar();" // Reload browsevar to remove cleared variables
              + "end");
    } catch (InterpreterException e1) {
      System.err.println(
          "An error in the interpreter has been catched: " + e1.getLocalizedMessage());
    }
  }
Exemple #3
0
  @Override
  public void actionPerformed(ActionEvent e) {
    final XcosDiagram graph = (XcosDiagram) getGraph(e);
    final ScilabDirectHandler handler = ScilabDirectHandler.acquire();
    if (handler == null) {
      return;
    }

    final BasicBlock block;
    final ActionListener callback;
    try {
      /*
       * Export the whole diagram, to update all the sub-diagrams on demand.
       */
      handler.writeDiagram(graph.getRootDiagram());

      /*
       * Then export the selected block
       */
      Object cell = graph.getSelectionCell();
      if (cell instanceof BasicBlock) {
        block = (BasicBlock) cell;
        handler.writeBlock(block);
      } else {
        block = null;
      }

      /*
       * Import the updated block
       */
      if (block != null) {
        callback =
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                try {

                  final BasicBlock modifiedBlock = handler.readBlock();
                  block.updateBlockSettings(modifiedBlock);

                  graph.fireEvent(
                      new mxEventObject(
                          XcosEvent.ADD_PORTS, XcosConstants.EVENT_BLOCK_UPDATED, block));
                } catch (ScicosFormatException e1) {
                  LOG.severe(e1.getMessage());
                } finally {
                  handler.release();
                }
              }
            };
      } else {
        callback =
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                handler.release();
              }
            };
      }

      ScilabInterpreterManagement.asynchronousScilabExec(callback, localCommand);
    } catch (InterpreterException e2) {
      LOG.warning(e2.toString());

      handler.release();
    }
  }