コード例 #1
0
ファイル: FieldParam.java プロジェクト: WU-ARL/RLI
 public FieldParam(ParamSpec fps, ONLComponent pc, Command cs) {
   super((ParamSpec) fps, pc, cs);
   if (cs.getFieldOwner() == null && pc instanceof Field.Owner) fieldOwner = (Field.Owner) pc;
   else fieldOwner = cs.getFieldOwner();
   getField();
   setDefaultValue(fps.getDefaultValue());
   ExpCoordinator.print(
       new String(
           "FieldParam("
               + label
               + ")(ParamSpec, ONLComponent, Command) command:"
               + cs.getLabel()
               + " default:"
               + fps.getDefaultValue()),
       TEST_FIELDPARAM);
 }
コード例 #2
0
ファイル: TextView.java プロジェクト: dirkk/basex
  /** Saves the displayed text. */
  private void save() {
    final BaseXFileChooser fc =
        new BaseXFileChooser(SAVE_AS, gui.gopts.get(GUIOptions.WORKPATH), gui).suffix(IO.XMLSUFFIX);

    final IO file = fc.select(Mode.FSAVE);
    if (file == null) return;
    gui.gopts.set(GUIOptions.WORKPATH, file.path());

    gui.cursor(CURSORWAIT, true);
    final MainOptions opts = gui.context.options;
    final int mh = opts.get(MainOptions.MAXHITS);
    opts.set(MainOptions.MAXHITS, -1);
    opts.set(MainOptions.CACHEQUERY, false);

    try (final PrintOutput out = new PrintOutput(file.toString())) {
      if (cmd != null) {
        cmd.execute(gui.context, out);
      } else if (ns != null) {
        ns.serialize(Serializer.get(out));
      } else {
        final byte[] txt = text.getText();
        for (final byte t : txt) if (t < 0 || t > ' ' || ws(t)) out.write(t);
      }
    } catch (final IOException ex) {
      BaseXDialog.error(gui, Util.info(FILE_NOT_SAVED_X, file));
    } finally {
      opts.set(MainOptions.MAXHITS, mh);
      opts.set(MainOptions.CACHEQUERY, true);
      gui.cursor(CURSORARROW, true);
    }
  }
コード例 #3
0
 /**
  * Handles key down events. Cursor keys are handled by the view the other key events are
  * delegated to the currently active tool.
  */
 public void keyPressed(KeyEvent e) {
   int code = e.getKeyCode();
   if ((code == KeyEvent.VK_BACK_SPACE) || (code == KeyEvent.VK_DELETE)) {
     if (deleteCmd.isExecutable()) {
       deleteCmd.execute();
       //					deleteCmd.viewSelectionChanged(this);
     }
   } else if ((code == KeyEvent.VK_DOWN)
       || (code == KeyEvent.VK_UP)
       || (code == KeyEvent.VK_RIGHT)
       || (code == KeyEvent.VK_LEFT)) {
     handleCursorKey(code);
   } else {
     tool().keyDown(e, code);
   }
   checkDamage();
 }
コード例 #4
0
ファイル: Commands.java プロジェクト: dschachinger/colibri
 public static JMenuItem makeMenuItem(Command cmd) {
   JMenuItem item;
   if (cmd instanceof ToggleCommand) {
     item = new JCheckBoxMenuItem(cmd);
     item.setSelected(((ToggleCommand) cmd).isSelected());
   } else {
     item = new JMenuItem(cmd);
   }
   cmd.bind(item);
   return item;
 }
コード例 #5
0
ファイル: Calculator.java プロジェクト: GeorgeZhuo/Gridworld
    public void actionPerformed(ActionEvent event) {

      String command = event.getActionCommand();
      if (command.equals("OK")) {
        double x = Double.parseDouble(firstNumber.getText());
        double y = Double.parseDouble(secondNumber.getText());
        calculate(x, y);

      } else {

        Command.setText(command);
        lastCommand = command;
      }
    }
コード例 #6
0
ファイル: Commands.java プロジェクト: dschachinger/colibri
 public static AbstractButton makeToolBarButton(Command cmd) {
   AbstractButton b;
   if (cmd instanceof ToggleCommand) {
     b = new JToggleButton(cmd);
     b.setSelected(((ToggleCommand) cmd).isSelected());
   } else {
     b = new JButton(cmd);
   }
   b.setFocusable(false);
   b.setText(null);
   // b.setMargin(new Insets(2, 2, 2, 2));
   b.setBorderPainted(false);
   cmd.bind(b);
   return b;
 }
コード例 #7
0
ファイル: TextView.java プロジェクト: dirkk/basex
  /**
   * Caches the output.
   *
   * @param out cached output
   * @param c command
   * @param r result
   * @throws QueryException query exception
   */
  public void cacheText(final ArrayOutput out, final Command c, final Result r)
      throws QueryException {

    // cache command or node set
    cmd = null;
    ns = null;

    final int mh = gui.context.options.get(MainOptions.MAXHITS);
    boolean parse = false;
    if (mh >= 0 && r != null && r.size() >= mh) {
      parse = true;
    } else if (out.finished()) {
      if (r instanceof DBNodes) ns = (DBNodes) r;
      else parse = true;
    }
    // create new command instance
    if (parse) cmd = new CommandParser(c.toString(), gui.context).parseSingle();
  }
コード例 #8
0
ファイル: Calculator.java プロジェクト: GeorgeZhuo/Gridworld
  public CalculatorPanel() {

    result = 0;
    lastCommand = "+";
    ActionListener command = new CommandAction();

    GridLayout layout = new GridLayout(2, 5);
    layout.setHgap(5);
    layout.setVgap(5);

    panel = new JPanel();
    panel.setLayout(layout);
    panel.setPreferredSize(new Dimension(400, 200));

    // add display
    display = new JTextField();
    Command = new JTextField("+");
    firstNumber = new JTextField();
    secondNumber = new JTextField();
    JTextField equal = new JTextField("=");

    equal.setEnabled(false);
    display.setEnabled(false);
    Command.setEnabled(false);

    panel.add(firstNumber);
    panel.add(Command);
    panel.add(secondNumber);
    panel.add(equal);
    panel.add(display);

    addButton("+", command);
    addButton("-", command);
    addButton("*", command);
    addButton("/", command);
    addButton("OK", command);
    add(panel, BorderLayout.CENTER);
  }
コード例 #9
0
 /**
  * This method implements ActionListener, which is a super-interface of Action. When a component
  * generates an ActionEvent, it is passed to this method. This method simply passes it on to the
  * Command object which is also an ActionListener object
  */
 public void actionPerformed(ActionEvent e) {
   command.actionPerformed(e);
 }