org.eclipse.core.commands.ExecutionEvent Java Examples

The following examples show how to use org.eclipse.core.commands.ExecutionEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ShowPreviousFuzzyHandler.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
	IEditorPart editor = HandlerUtil.getActiveEditor(event);
	if (!(editor instanceof XLIFFEditorImplWithNatTable)) {
		return null;
	}
	XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor;
	int[] selectedRows = xliffEditor.getSelectedRows();
	if (selectedRows.length < 1) {
		return null;
	}
	Arrays.sort(selectedRows);
	int firstSelectedRow = selectedRows[0];
	XLFHandler handler = xliffEditor.getXLFHandler();

	int row = handler.getPreviousFuzzySegmentIndex(firstSelectedRow);
	if (row != -1) {
		xliffEditor.jumpToRow(row);
	} else {
		IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
		MessageDialog.openWarning(window.getShell(), "", "不存在上一模糊匹配文本段。");
	}

	return null;
}
 
Example #2
Source File: ServiceUtils.java    From google-cloud-eclipse with Apache License 2.0 6 votes vote down vote up
/**
 * Returns an OSGi service from {@link ExecutionEvent}. It looks up a service in the following
 * locations (if exist) in the given order:
 *
 * {@code HandlerUtil.getActiveSite(event)}
 * {@code HandlerUtil.getActiveEditor(event).getEditorSite()}
 * {@code HandlerUtil.getActiveEditor(event).getSite()}
 * {@code HandlerUtil.getActiveWorkbenchWindow(event)}
 * {@code PlatformUI.getWorkbench()}
 */
public static <T> T getService(ExecutionEvent event, Class<T> api) {
  IWorkbenchSite activeSite = HandlerUtil.getActiveSite(event);
  if (activeSite != null) {
    return activeSite.getService(api);
  }

  IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
  if (activeEditor != null) {
    IEditorSite editorSite = activeEditor.getEditorSite();
    if (editorSite != null) {
      return editorSite.getService(api);
    }
    IWorkbenchPartSite site = activeEditor.getSite();
    if (site != null) {
      return site.getService(api);
    }
  }

  IWorkbenchWindow workbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event);
  if (workbenchWindow != null) {
    return workbenchWindow.getService(api);
  }

  return PlatformUI.getWorkbench().getService(api);
}
 
Example #3
Source File: XrefExtension.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
private void startLocalEdit(Brief brief){
	if (brief != null) {
		ICommandService commandService =
			(ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
		Command command =
			commandService.getCommand("ch.elexis.core.ui.command.startEditLocalDocument"); //$NON-NLS-1$
		
		PlatformUI.getWorkbench().getService(IEclipseContext.class)
			.set(command.getId().concat(".selection"), new StructuredSelection(brief));
		try {
			command.executeWithChecks(
				new ExecutionEvent(command, Collections.EMPTY_MAP, this, null));
		} catch (ExecutionException | NotDefinedException | NotEnabledException
				| NotHandledException e) {
			MessageDialog.openError(Display.getDefault().getActiveShell(),
				Messages.BriefAuswahl_errorttile,
				Messages.BriefAuswahl_erroreditmessage);
		}
	}
}
 
Example #4
Source File: ShowNextSegmentHandler.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
	IEditorPart editor = HandlerUtil.getActiveEditor(event);
	if (!(editor instanceof XLIFFEditorImplWithNatTable)) {
		return null;
	}
	XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor;
	int[] selectedRows = xliffEditor.getSelectedRows();
	if (selectedRows.length < 1) {
		return null;
	}
	Arrays.sort(selectedRows);
	int lastSelectedRow = selectedRows[selectedRows.length - 1];
	XLFHandler handler = xliffEditor.getXLFHandler();
	int lastRow = handler.countEditableTransUnit() - 1;
	if (lastSelectedRow == lastRow) {
		lastSelectedRow = lastRow - 1;
	}
	xliffEditor.jumpToRow(lastSelectedRow + 1);
	return null;
}
 
Example #5
Source File: FindBarActions.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException
{
	FindBarDecorator dec = findBarDecorator.get();
	if (dec != null)
	{
		IEclipsePreferences preferenceStore = EclipseUtil.instanceScope().getNode(FindBarPlugin.PLUGIN_ID);
		boolean openEclipseFindBar = preferenceStore.getBoolean(
				IPreferencesConstants.CTRL_F_TWICE_OPENS_ECLIPSE_FIND_BAR, false);

		if (openEclipseFindBar)
		{
			dec.showFindReplaceDialog();
		}
		else
		{
			dec.textFind.setFocus();
			dec.textFind.setSelection(new Point(0, dec.textFind.getText().length()));
		}
	}
	return null;
}
 
Example #6
Source File: AddSelectionSegmentNotesHandler.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
	String tshelp = System.getProperties().getProperty("TSHelp");
	String tsstate = System.getProperties().getProperty("TSState");
	if (tshelp == null || !"true".equals(tshelp) || tsstate == null || !"true".equals(tsstate)) {
		LoggerFactory.getLogger(AddSelectionSegmentNotesHandler.class).error("Exception:key hs008 is lost.(Can't find the key)");
		System.exit(0);
	}
	IEditorPart editorPart = HandlerUtil.getActiveEditor(event);
	if (editorPart instanceof XLIFFEditorImplWithNatTable) {
		XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editorPart;
		AddOrUpdateNoteDialog dialog = new AddOrUpdateNoteDialog(xliffEditor.getSite().getShell(), xliffEditor,
				AddOrUpdateNoteDialog.DIALOG_ADD, null);
		dialog.open();
	}

	return null;
}
 
Example #7
Source File: NotSendToTMHandler.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
	IEditorPart editor = HandlerUtil.getActiveEditor(event);
	if (editor instanceof XLIFFEditorImplWithNatTable) {
		XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor;
		List<String> selectedRowIds = xliffEditor.getSelectedRowIds();
		if (selectedRowIds != null && selectedRowIds.size() > 0) {
			boolean isSendtoTm = true;
			XLFHandler handler = xliffEditor.getXLFHandler();
			for (String rowId : selectedRowIds) {
				if (!handler.isSendToTM(rowId) && isSendtoTm) {
					isSendtoTm = false;
					break;
				}
			}
			NattableUtil util = NattableUtil.getInstance(xliffEditor);
			util.changeSendToTmState(selectedRowIds, isSendtoTm ? "yes" : "no");
		}
	}
	return null;
}
 
Example #8
Source File: CompareWithRouteAction.java    From eip-designer with Apache License 2.0 6 votes vote down vote up
@Override
public void run(IAction action) {
   System.err.println("In run(IACtion)");
   if (serviceLocator == null) {
      serviceLocator = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
   } 
   
   // Create an ExecutionEvent using Eclipse machinery.
   ICommandService srv = (ICommandService) serviceLocator.getService(ICommandService.class);
   IHandlerService hsrv = (IHandlerService) serviceLocator.getService(IHandlerService.class);
   ExecutionEvent event = hsrv.createExecutionEvent(srv.getCommand(ActionCommands.COMPARE_WITH_ROUTE_ACTION), null);
   // Fill it my current active selection.
   if (event.getApplicationContext() instanceof IEvaluationContext) {
      ((IEvaluationContext) event.getApplicationContext()).addVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME, mySelection);
   }
   
   try {
      handler.execute(event);
   } catch (ExecutionException e) {
      Activator.handleError(e.getMessage(), e, true);
   }
}
 
Example #9
Source File: PersistToRouteModelAction.java    From eip-designer with Apache License 2.0 6 votes vote down vote up
@Override
public void run(IAction action) {
   if (serviceLocator == null) {
      serviceLocator = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
   } 
   
   // Create an ExecutionEvent using Eclipse machinery.
   ICommandService srv = (ICommandService) serviceLocator.getService(ICommandService.class);
   IHandlerService hsrv = (IHandlerService) serviceLocator.getService(IHandlerService.class);
   ExecutionEvent event = hsrv.createExecutionEvent(srv.getCommand(ActionCommands.PERSIST_TO_ROUTE_MODEL_ACTION), null);
   // Fill it my current active selection.
   if (event.getApplicationContext() instanceof IEvaluationContext) {
      ((IEvaluationContext) event.getApplicationContext()).addVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME, mySelection);
   }
   
   try {
      handler.execute(event);
   } catch (ExecutionException e) {
      Activator.handleError(e.getMessage(), e, true);
   }
}
 
Example #10
Source File: ContributionAction.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
public Object executeCommand(){
	try {
		ICommandService commandService =
			(ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
		
		Command cmd = commandService.getCommand(commandId);
		if (selection != null) {
			PlatformUI.getWorkbench().getService(IEclipseContext.class)
				.set(commandId.concat(".selection"), new StructuredSelection(selection));
		}
		ExecutionEvent ee = new ExecutionEvent(cmd, Collections.EMPTY_MAP, null, null);
		return cmd.executeWithChecks(ee);
	} catch (Exception e) {
		LoggerFactory.getLogger(getClass())
			.error("cannot execute command with id: " + commandId, e);
	}
	return null;
}
 
Example #11
Source File: BillingProposalViewCreateBillsHandler.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
private List<Konsultation> getToBill(ExecutionEvent event){
	String selectionParameter =
		event.getParameter("ch.elexis.core.ui.BillingProposalViewCreateBills.selection");
	if ("selection".equals(selectionParameter)) {
		ISelection selection = HandlerUtil.getCurrentSelection(event);
		if (selection != null && !selection.isEmpty()) {
			@SuppressWarnings("unchecked")
			List<Object> selectionList = ((IStructuredSelection) selection).toList();
			// map to List<Konsultation> depending on type
			if (selectionList.get(0) instanceof Konsultation) {
				return selectionList.stream().map(o -> ((Konsultation) o))
					.collect(Collectors.toList());
			} else if (selectionList.get(0) instanceof BillingProposalView.BillingInformation) {
				return selectionList.stream()
					.map(o -> ((BillingProposalView.BillingInformation) o).getKonsultation())
					.collect(Collectors.toList());
			}
		}
	} else {
		BillingProposalView view = getOpenView(event);
		if (view != null) {
			return view.getToBill();
		}
	}
	return Collections.emptyList();
}
 
Example #12
Source File: StartExporter.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Object execute ( final ExecutionEvent event ) throws ExecutionException
{
    for ( final IFile file : SelectionHelper.iterable ( getSelection (), IFile.class ) )
    {
        try
        {
            HivesPlugin.getDefault ().getServerHost ().startServer ( file );
            getActivePage ().showView ( "org.eclipse.scada.da.server.ui.ServersView" ); //$NON-NLS-1$
        }
        catch ( final Exception e )
        {
            logger.warn ( "Failed to start file: " + file, e ); //$NON-NLS-1$
            StatusManager.getManager ().handle ( StatusHelper.convertStatus ( Activator.PLUGIN_ID, e ), StatusManager.BLOCK );
        }
    }
    return null;
}
 
Example #13
Source File: ShowPreviousUnapprovedHandler.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
	IEditorPart editor = HandlerUtil.getActiveEditor(event);
	if (!(editor instanceof XLIFFEditorImplWithNatTable)) {
		return null;
	}
	XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor;
	int[] selectedRows = xliffEditor.getSelectedRows();
	if (selectedRows.length < 1) {
		return null;
	}
	Arrays.sort(selectedRows);
	int firstSelectedRow = selectedRows[0];
	XLFHandler handler = xliffEditor.getXLFHandler();

	int row = handler.getPreviousUnapprovedSegmentIndex(firstSelectedRow);
	if (row != -1) {
		xliffEditor.jumpToRow(row);
	} else {
		IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
		MessageDialog.openWarning(window.getShell(), "", "不存在上一未批准文本段。");
	}

	return null;
}
 
Example #14
Source File: DeleteTemplateCommand.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException{
	ISelection selection =
		HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection();
	if (selection != null) {
		IStructuredSelection strucSelection = (IStructuredSelection) selection;
		Object firstElement = strucSelection.getFirstElement();
		if (firstElement != null && firstElement instanceof TextTemplate) {
			TextTemplate textTemplate = (TextTemplate) firstElement;
			Brief template = textTemplate.getTemplate();
			textTemplate.removeTemplateReference();
			
			if (template != null) {
				template.delete();
				
				ElexisEventDispatcher.getInstance().fire(new ElexisEvent(Brief.class, null,
					ElexisEvent.EVENT_RELOAD, ElexisEvent.PRIORITY_NORMAL));
			}
		}
	}
	
	return null;
}
 
Example #15
Source File: OpenTLCErrorViewHandler.java    From tlaplus with MIT License 6 votes vote down vote up
public Object execute(final ExecutionEvent event) throws ExecutionException {
      final Map<String, String> params = new HashMap<String, String>();
      params.put(OpenViewHandler.PARAM_VIEW_NAME, TLCErrorView.ID);
      
      UIHelper.runCommand(OpenViewHandler.COMMAND_ID, params);

      final IEditorPart activeEditor = UIHelper.getActiveEditor();
if (activeEditor != null) {
	if (activeEditor instanceof ModelEditor) {
		final ModelEditor activeModelEditor = (ModelEditor) activeEditor;
		if (activeModelEditor.getModel() != null) {
			UIHelper.runUISync(() -> {
				TLCErrorView.updateErrorView(activeModelEditor);
			});
		}
	}
}

      return null;
  }
 
Example #16
Source File: OpenDeclarationHandler.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	XtextEditor xtextEditor = EditorUtils.getActiveXtextEditor(event);
	if (xtextEditor != null) {
		ITextSelection selection = (ITextSelection) xtextEditor.getSelectionProvider().getSelection();

		IRegion region = new Region(selection.getOffset(), selection.getLength());

		ISourceViewer internalSourceViewer = xtextEditor.getInternalSourceViewer();

		IHyperlink[] hyperlinks = getDetector().detectHyperlinks(internalSourceViewer, region, false);
		if (hyperlinks != null && hyperlinks.length > 0) {
			IHyperlink hyperlink = hyperlinks[0];
			hyperlink.open();
		}
	}		
	return null;
}
 
Example #17
Source File: GotoCompilationUnitHandler.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    Shell shell = WorkbenchUtils.getActivePartShell();
    
    HashSet<String> exts = new HashSet<String>(); 
    exts.addAll(XdsFileUtils.COMPILATION_UNIT_FILE_EXTENSIONS);
    
    SelectModulaSourceFileDialog dlg = new SelectModulaSourceFileDialog(Messages.GotoCompilationUnitHandler_OpenModule, shell, ResourceUtils.getWorkspaceRoot(), exts);
    if (SelectModulaSourceFileDialog.OK == dlg.open()){
        IFile file = (IFile)dlg.getResultAsResource();
        if (file != null) {
            IEditorInput editorInput = new FileEditorInput(file);
            try {
            	CoreEditorUtils.openInEditor(editorInput, true);
            } catch (CoreException e) {
                LogHelper.logError(e);
            }
        }
    }
    return null;
}
 
Example #18
Source File: ReverseRegionHandler.java    From e4macs with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @see com.mulgasoft.emacsplus.commands.EmacsPlusCmdHandler#transform(ITextEditor, IDocument, ITextSelection, ExecutionEvent)
 */
@Override
protected int transform(ITextEditor editor, IDocument document, ITextSelection currentSelection,
		ExecutionEvent event) throws BadLocationException {
   	ITextSelection selection = getLineSelection(editor,document,currentSelection);
   	if (selection != null) {
   		int offset = selection.getOffset();
   		int endOffset = offset+selection.getLength(); 
   		int begin = document.getLineOfOffset(offset);
   		int end = document.getLineOfOffset(endOffset);
		if (begin != end && begin < end) {
			// grab the lines
			int len = end-begin+1; 
			String[] array = new String[len];
			for (int i = 0; i < len; i++) {
				IRegion region = document.getLineInformation(begin+i);
				array[i] = document.get(region.getOffset(),region.getLength());
			}
			// and reverse them
			updateLines(document,new TextSelection(document,offset,endOffset-offset),reverse(array));
		}
	} else {
		EmacsPlusUtils.showMessage(editor, NO_REGION, true);
	}
	return NO_OFFSET;
}
 
Example #19
Source File: SwitchMedicationHandler.java    From elexis-3-core with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException{
	ISelection selection =
		HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection();
	if (selection != null) {
		IStructuredSelection strucSelection = (IStructuredSelection) selection;
		Object firstElement = strucSelection.getFirstElement();
		
		if (firstElement instanceof MedicationTableViewerItem) {
			MedicationTableViewerItem mtvItem = (MedicationTableViewerItem) firstElement;
			IPrescription p = mtvItem.getPrescription();
			if (p != null) {
				originalPresc = p;
				copyShortArticleNameToClipboard();
				openLeistungsView();
			}
		}
	}
	return null;
}
 
Example #20
Source File: KbdMacroBindHandler.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @see com.mulgasoft.emacsplus.commands.EmacsPlusCmdHandler#transform(ITextEditor, IDocument, ITextSelection, ExecutionEvent)
 */
@Override
protected int transform(ITextEditor editor, IDocument document, ITextSelection currentSelection,
		ExecutionEvent event) throws BadLocationException {
	boolean named = isUniversalPresent();
	if (KbdMacroSupport.getInstance().hasKbdMacro(named) && !KbdMacroSupport.getInstance().isBusy()) {
		mbState = (named ? nameState() : bindState(null));
		return mbState.run(editor);
	} else {
		asyncShowMessage(editor, NO_MACRO_ERROR, true);
	}
	return NO_OFFSET;
}
 
Example #21
Source File: DisposeHostedServerHandler.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Object execute ( final ExecutionEvent event ) throws ExecutionException
{
    for ( final HostedServer server : SelectionHelper.iterable ( getSelection (), HostedServer.class ) )
    {
        server.dispose ();
    }
    return null;
}
 
Example #22
Source File: AufPrintHandler.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException{
	try {
		IViewPart viewPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
			.getActivePage().showView(AUFZeugnis.ID);
		if (viewPart instanceof AUFZeugnis) {
			((AUFZeugnis) viewPart).createAUZ();
		}
	} catch (Exception ex) {
		ExHandler.handle(ex);
	}
	return null;
}
 
Example #23
Source File: MetaXMinibuffer.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public boolean beginSession(ITextEditor editor, IWorkbenchPage page, ExecutionEvent event) {
	try {
		setMxLaunch(true);
		boolean result = super.beginSession(editor, page, event);
		if (!result){
			super.setResultMessage(NOCOMMANDS_MSG, true);
		}
		return result;
	} finally {
		setMxLaunch(false);
	}
}
 
Example #24
Source File: LogSniffer.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Handles user commands.
 */
@Override
public Object execute(ExecutionEvent event) {
  switch (Commands.valueOf((String) event.getParameters().get(CMD_PARAM_ID))) {
    case CMD_DUMP:
      dumpLog();
      break;
    case CMD_CLEAR:
      clearLog();
      break;
  }

  return null;
}
 
Example #25
Source File: ErrorsPauseAndEdit.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
	GamaPreferences.Runtime.CORE_REVEAL_AND_STOP.set(!GamaPreferences.Runtime.CORE_REVEAL_AND_STOP.getValue());
	final ICommandService service =
			HandlerUtil.getActiveWorkbenchWindowChecked(event).getService(ICommandService.class);
	service.refreshElements(event.getCommand().getId(), null);
	return null;
}
 
Example #26
Source File: CopySourceHandler.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
	IEditorPart editor = HandlerUtil.getActiveEditor(event);
	if (editor instanceof XLIFFEditorImplWithNatTable) {
		XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor;
		XLFHandler handler = xliffEditor.getXLFHandler();
		List<String> rowIds = xliffEditor.getSelectedRowIds();
		
		boolean locked = false;
		Map<String,String> map = new HashMap<String, String>();
		for (int i = 0; i < rowIds.size(); i++) {
			String rowId = rowIds.get(i);
			if (handler.isLocked(rowId)) { // 已经批准或者已锁定,则不进行修改。
				locked = true;
				continue;
			}
			String srcContent = handler.getSrcContent(rowId);
			String newValue = srcContent == null ? "" : srcContent;
			map.put(rowId, newValue);
		}

		if (locked) {
			if (!MessageDialog.openConfirm(xliffEditor.getSite().getShell(),
					Messages.getString("handler.CopySourceHandler.msgTitle"),
					Messages.getString("handler.CopySourceHandler.msg"))) {
				return null;
			}
		}
		StyledTextCellEditor cellEditor = HsMultiActiveCellEditor.getTargetStyledEditor();
		if(cellEditor != null){
			HsMultiActiveCellEditor.setCellEditorForceFocus(cellEditor.getColumnPosition(), cellEditor.getRowPosition());
		}
		xliffEditor.updateSegments(map, xliffEditor.getTgtColumnIndex(), null, null);
	}
	return null;
}
 
Example #27
Source File: ExpandAllRegionsHandler.java    From tlaplus with MIT License 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
       final TLAEditor editor = EditorUtil.getTLAEditorWithFocus();

	if (editor != null) {
		final TextOperationAction action = new TextOperationAction(RESOURCE_BUNDLE, "Projection.ExpandAll.", editor,
				ProjectionViewer.EXPAND_ALL, true);

		action.setActionDefinitionId(IFoldingCommandIds.FOLDING_EXPAND_ALL);
		action.run();
       }

       return null;
}
 
Example #28
Source File: AcceptMatch2.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
/** (non-Javadoc)
 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
 */
public Object execute(ExecutionEvent event) throws ExecutionException {
	IViewPart viewPart = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(
			"net.heartsome.cat.ts.ui.translation.view.matchview");		
	if (viewPart != null && viewPart instanceof IMatchViewPart) {				
		IMatchViewPart matchView = (IMatchViewPart) viewPart;
		matchView.acceptMatchByIndex(1);
	}
	return null;
}
 
Example #29
Source File: OpenEngineLogCommand.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Boolean execute(final ExecutionEvent event) throws ExecutionException {
    final IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    final File logFile = BOSWebServerManager.getInstance().getBonitaLogFile();
    if (logFile != null && logFile.exists()) {
        IFileStore fileStore;
        try {
            fileStore = EFS.getLocalFileSystem().getStore(logFile.toURI());
            final File localFile = fileStore.toLocalFile(EFS.NONE, Repository.NULL_PROGRESS_MONITOR);
            final long fileSize = localFile.length();
            if (fileSize < MAX_FILE_SIZE) {
                IDE.openEditorOnFileStore(page, fileStore);
            } else {
                Program textEditor = Program.findProgram("log");
                if (textEditor == null) {
                    textEditor = Program.findProgram("txt");
                }
                if (textEditor != null) {
                    final boolean success = textEditor.execute(localFile.getAbsolutePath());
                    if (!success) {
                        showWarningMessage(localFile);
                    }
                } else {
                    showWarningMessage(localFile);
                }
            }

            return Boolean.TRUE;
        } catch (final Exception e) {
            BonitaStudioLog.error(e);
            return Boolean.FALSE;
        }
    } else {
        MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                Messages.unableTofindLogTitle, Messages.unableTofindLogMessage);
        return Boolean.FALSE;
    }
}
 
Example #30
Source File: AdvancedFilterCommand.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException{
	AdvancedFilterDialog afd =
		new AdvancedFilterDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell());
	int retVal = afd.open();
	//System.out.println(retVal);
	return null;
}