Пример #1
0
  /**
   * Tests that the returned JButton of <code>createManualToolBarButton</code>: 1. Is disabled upon
   * return. 2. Inherits the tooltip of the Action parameter <code>a</code>.
   */
  public void testCreateManualToolBarButton() {
    final Action a =
        new AbstractAction("Test Action") {
          public void actionPerformed(ActionEvent ae) {}
        };

    a.putValue(Action.LONG_DESCRIPTION, "test tooltip");
    Utilities.invokeAndWait(
        new Runnable() {
          public void run() {
            _but = _frame._createManualToolBarButton(a);
          }
        });

    assertTrue("Returned JButton is enabled.", !_but.isEnabled());
    assertEquals("Tooltip text not set.", "test tooltip", _but.getToolTipText());
    _log.log("testCreateManualToobarButton completed");
  }
  // Add icons and friendly names to actions we care about.
  protected void makeActionsPretty() {
    Action a;
    a = textComp.getActionMap().get(DefaultEditorKit.cutAction);
    a.putValue(Action.SMALL_ICON, new ImageIcon("icons/cut.gif"));
    a.putValue(Action.NAME, "Cut");

    a = textComp.getActionMap().get(DefaultEditorKit.copyAction);
    a.putValue(Action.SMALL_ICON, new ImageIcon("icons/copy.gif"));
    a.putValue(Action.NAME, "Copy");

    a = textComp.getActionMap().get(DefaultEditorKit.pasteAction);
    a.putValue(Action.SMALL_ICON, new ImageIcon("icons/paste.gif"));
    a.putValue(Action.NAME, "Paste");

    a = textComp.getActionMap().get(DefaultEditorKit.selectAllAction);
    a.putValue(Action.NAME, "Select All");
  }
Пример #3
0
  /** Helper method to initialize the actions used for the buttons. */
  private void initActions() {

    /*actionUndo = new AbstractAction() {
    	public void actionPerformed(ActionEvent ae) {
    		try {
    			// do redo
    			undoManager.undo();

    			// notify undo manager/toolbar of change
    			GUIPrism.getGUI().notifyEventListeners(
    					new GUIClipboardEvent(GUIClipboardEvent.UNDOMANAGER_CHANGE,
    							GUIPrism.getGUI().getFocussedPlugin().getFocussedComponent()));
    		} catch (CannotUndoException ex) {
    			//GUIPrism.getGUI().getMultiLogger().logMessage(PrismLogLevel.PRISM_ERROR, ex.getMessage());
    		}
    	}
    };
    actionUndo.putValue(Action.LONG_DESCRIPTION, "Undo the most recent action.");
    actionUndo.putValue(Action.NAME, "Undo");
    actionUndo.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallUndo.png"));

    actionRedo = new AbstractAction() {
    	public void actionPerformed(ActionEvent ae) {
    		try {
    			// do redo
    			undoManager.redo();

    			// notify undo manager/toolbar of change
    			GUIPrism.getGUI().notifyEventListeners(
    					new GUIClipboardEvent(GUIClipboardEvent.UNDOMANAGER_CHANGE,
    							GUIPrism.getGUI().getFocussedPlugin().getFocussedComponent()));
    		} catch (CannotRedoException ex) {
    			//GUIPrism.getGUI().getMultiLogger().logMessage(PrismLogLevel.PRISM_ERROR, ex.getMessage());
    		}
    	}
    };


    actionRedo.putValue(Action.LONG_DESCRIPTION, "Redos the most recent undo");
    actionRedo.putValue(Action.NAME, "Redo");
    actionRedo.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("smallRedo.png"));
    */
    actionJumpToError =
        new AbstractAction() {
          public void actionPerformed(ActionEvent ae) {
            jumpToError();
          }
        };

    actionJumpToError.putValue(Action.NAME, "Jump to error");
    actionJumpToError.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("tinyError.png"));
    actionJumpToError.putValue(
        Action.ACCELERATOR_KEY,
        KeyStroke.getKeyStroke(
            KeyEvent.VK_E, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));

    // search and replace action
    actionSearch =
        new AbstractAction() {
          public void actionPerformed(ActionEvent ae) {
            /*
                		// System.out.println("search button pressed");
                		if (GUIMultiModelHandler.isDoingSearch()) {

            } else {
            	try {
            		GUIMultiModelHandler.setDoingSearch(true);
            		FindReplaceForm.launch(GUIPrism.getGUI().getMultiModel());
            	} catch (PluginNotFoundException pnfe) {
            		GUIPrism.getGUI().getMultiLogger().logMessage(prism.log.PrismLogLevel.PRISM_ERROR,
            				pnfe.getMessage());
            	}
            }
            */
          }
        };
    actionSearch.putValue(Action.LONG_DESCRIPTION, "Opens a find and replace dialog.");
    // actionSearch.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("find.png"));
    actionSearch.putValue(Action.NAME, "Find/Replace");
    // actionSearch.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_R,
    // Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));

    insertDTMC =
        new AbstractAction() {
          public void actionPerformed(ActionEvent ae) {
            int caretPosition = editor.getCaretPosition();
            try {
              editor.getDocument().insertString(caretPosition, "dtmc", new SimpleAttributeSet());
            } catch (BadLocationException ble) {
              // todo log?
            }
          }
        };

    insertDTMC.putValue(
        Action.LONG_DESCRIPTION, "Marks this model as a \"Discrete-Time Markov Chain\"");
    // actionSearch.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("find.png"));
    insertDTMC.putValue(Action.NAME, "Probabilistic (DTMC)");

    insertCTMC =
        new AbstractAction() {
          public void actionPerformed(ActionEvent ae) {
            int caretPosition = editor.getCaretPosition();
            try {
              editor.getDocument().insertString(caretPosition, "ctmc", new SimpleAttributeSet());
            } catch (BadLocationException ble) {
              // todo log?
            }
          }
        };

    insertCTMC.putValue(
        Action.LONG_DESCRIPTION, "Marks this model as a \"Continous-Time Markov Chain\"");
    // actionSearch.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("find.png"));
    insertCTMC.putValue(Action.NAME, "Stochastic (CTMC)");

    insertMDP =
        new AbstractAction() {
          public void actionPerformed(ActionEvent ae) {
            int caretPosition = editor.getCaretPosition();
            try {
              editor.getDocument().insertString(caretPosition, "mdp", new SimpleAttributeSet());
            } catch (BadLocationException ble) {
              // todo log?
            }
          }
        };

    insertMDP.putValue(
        Action.LONG_DESCRIPTION, "Marks this model as a \"Markov Decision Process\"");
    // actionSearch.putValue(Action.SMALL_ICON, GUIPrism.getIconFromImage("find.png"));
    insertMDP.putValue(Action.NAME, "Non-deterministic (MDP)");
  }