/** Synchronizes the state of the actions to the current state of this host. */ private void updateActions() { final DeviceController currentDeviceController = getDeviceController(); final boolean deviceControllerSet = currentDeviceController != null; final boolean deviceCapturing = deviceControllerSet && currentDeviceController.isCapturing(); final boolean deviceSetup = deviceControllerSet && !deviceCapturing && currentDeviceController.isSetup(); getAction(CaptureAction.ID).setEnabled(deviceControllerSet); getAction(CancelCaptureAction.ID).setEnabled(deviceCapturing); getAction(RepeatCaptureAction.ID).setEnabled(deviceSetup); final boolean projectChanged = this.projectManager.getCurrentProject().isChanged(); final boolean projectSavedBefore = this.projectManager.getCurrentProject().getFilename() != null; final boolean dataAvailable = this.dataContainer.hasCapturedData(); getAction(SaveProjectAction.ID).setEnabled(projectChanged); getAction(SaveProjectAsAction.ID).setEnabled(projectSavedBefore && projectChanged); getAction(SaveDataFileAction.ID).setEnabled(dataAvailable); getAction(ZoomInAction.ID).setEnabled(dataAvailable); getAction(ZoomOutAction.ID).setEnabled(dataAvailable); getAction(ZoomDefaultAction.ID).setEnabled(dataAvailable); getAction(ZoomFitAction.ID).setEnabled(dataAvailable); final boolean triggerEnable = dataAvailable && this.dataContainer.hasTriggerData(); getAction(GotoTriggerAction.ID).setEnabled(triggerEnable); // Update the cursor actions accordingly... final boolean enableCursors = dataAvailable && this.dataContainer.isCursorsEnabled(); for (int c = 0; c < CapturedData.MAX_CURSORS; c++) { final boolean enabled = enableCursors && this.dataContainer.isCursorPositionSet(c); getAction(GotoNthCursorAction.getID(c)).setEnabled(enabled); } getAction(GotoFirstCursorAction.ID).setEnabled(enableCursors); getAction(GotoLastCursorAction.ID).setEnabled(enableCursors); getAction(SetCursorModeAction.ID).setEnabled(dataAvailable); getAction(SetCursorModeAction.ID) .putValue(Action.SELECTED_KEY, Boolean.valueOf(this.dataContainer.isCursorsEnabled())); boolean anyCursorSet = false; for (int c = 0; c < CapturedData.MAX_CURSORS; c++) { final boolean cursorPositionSet = this.dataContainer.isCursorPositionSet(c); anyCursorSet |= cursorPositionSet; final Action action = getAction(SetCursorAction.getCursorId(c)); action.setEnabled(dataAvailable); action.putValue(Action.SELECTED_KEY, Boolean.valueOf(cursorPositionSet)); } getAction(ClearCursors.ID).setEnabled(enableCursors && anyCursorSet); }
@Override public void ioResult(IOServiceEvent e) { if (e.getState() == IOServiceEvent.MOUNT_SUCCESS || e.getState() == IOServiceEvent.MOUNT_FAILURE) { lumberjack.setFullModel(buildModel(e.getResolverBundle().getResolvers())); toggleAction.setEnabled(cpos != null); toggleAction.putValue( Action.SELECTED_KEY, (Boolean) toggleAction.getValue(Action.SELECTED_KEY) && cpos != null); } }
/** 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)"); }