示例#1
0
 public void enterMode(ModeSwitchHint... args) throws CommandExecutionException {
   placeCursor();
   editorAdaptor.getCursorService().setCaret(CaretType.RECTANGULAR);
   super.enterMode(args);
   if (args.length > 0 && args[0] instanceof ExecuteCommandHint) {
     try {
       executeCommand(((ExecuteCommandHint.OnEnter) args[0]).getCommand());
     } catch (CommandExecutionException e) {
       editorAdaptor.getUserInterfaceService().setErrorMessage(e.getMessage());
     }
   }
 }
示例#2
0
 @Override
 public void enterMode(final ModeSwitchHint... hints) throws CommandExecutionException {
   boolean fixSelection = false;
   boolean keepSelection = false;
   boolean recallSelection = false;
   ExecuteCommandHint onEnterCommand = null;
   for (final ModeSwitchHint hint : hints) {
     if (hint == FIX_SELECTION_HINT) {
       keepSelection = true;
       fixSelection = true;
     }
     if (hint == KEEP_SELECTION_HINT) {
       keepSelection = true;
     }
     if (hint == RECALL_SELECTION_HINT) {
       recallSelection = true;
     }
     if (hint instanceof ExecuteCommandHint) {
       onEnterCommand = (ExecuteCommandHint) hint;
     }
   }
   if (recallSelection) {
     Selection previousSel = editorAdaptor.getLastActiveSelection();
     CursorService cursorService = editorAdaptor.getCursorService();
     Position from = cursorService.getMark(CursorService.INTERNAL_LAST_SELECT_FROM_MARK);
     Position to = cursorService.getMark(CursorService.INTERNAL_LAST_SELECT_TO_MARK);
     if (previousSel == null) {
       VrapperLog.info("Previous selection was null, selection not recalled.");
     } else {
       Selection updatedSel = updateSelection(editorAdaptor, previousSel, from, to);
       // Makes sure to set the sticky column.
       editorAdaptor.setPosition(updatedSel.getTo(), StickyColumnPolicy.ON_CHANGE);
       editorAdaptor.setSelection(updatedSel);
     }
   } else if (!keepSelection) {
     editorAdaptor.setSelection(null);
   }
   Selection currentSelection = editorAdaptor.getSelection();
   if (fixSelection && currentSelection != null) {
     editorAdaptor.setSelection(fixSelection(currentSelection));
   }
   super.enterMode(hints);
   if (onEnterCommand != null) {
     try {
       super.executeCommand(onEnterCommand.getCommand());
     } catch (final CommandExecutionException e) {
       editorAdaptor.getUserInterfaceService().setErrorMessage(e.getMessage());
     }
   }
   fixCaret();
 }
示例#3
0
 @Override
 public void enterMode(final ModeSwitchHint... args) throws CommandExecutionException {
   placeCursor();
   editorAdaptor.getCursorService().setCaret(CaretType.RECTANGULAR);
   super.enterMode(args);
   if (args.length > 0) {
     if (args[0] instanceof ExecuteCommandHint) {
       try {
         executeCommand(((ExecuteCommandHint.OnEnter) args[0]).getCommand());
       } catch (final CommandExecutionException e) {
         editorAdaptor.getUserInterfaceService().setErrorMessage(e.getMessage());
       }
     } else if (args[0] == InsertMode.RETURN_TO_INSERTMODE) {
       returnToInsertMode = true;
     }
   }
 }