Java Code Examples for org.eclipse.core.commands.ExecutionEvent

The following are top voted examples for showing how to use org.eclipse.core.commands.ExecutionEvent. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Tarski   File: CountMarkersInFileHandler.java   View source code 7 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
  ISelection sel = Activator.getDefault().getWorkbench().getActiveWorkbenchWindow()
      .getSelectionService().getSelection();
  if (sel instanceof ITreeSelection) {
    ITreeSelection treeSel = (ITreeSelection) sel;
    if (treeSel.getFirstElement() instanceof IFile) {
      IFile file = (IFile) treeSel.getFirstElement();
      List<IMarker> markers = MarkerFactory.findMarkers(file);
      MessageDialog dialog = new MessageDialog(MarkerActivator.getShell(), "Marker Count", null,
          markers.size() + " marker(s)", MessageDialog.INFORMATION, new String[] {"OK"}, 0);
      dialog.open();
    }
  }
  return null;
}
 
Example 2
Project: n4js   File: XpectCompareCommandHandler.java   View source code 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

	IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelectionChecked(event);

	IWorkbenchWindow[] windows = N4IDEXpectUIPlugin.getDefault().getWorkbench().getWorkbenchWindows();
	try {
		view = (N4IDEXpectView) windows[0].getActivePage().showView(
				N4IDEXpectView.ID);
	} catch (PartInitException e) {
		N4IDEXpectUIPlugin.logError("cannot refresh test view window", e);
	}

	Description desc = (Description) selection.getFirstElement();
	if (desc.isTest() && view.testsExecutionStatus.hasFailed(desc)) {
		Throwable failureException = view.testsExecutionStatus.getFailure(desc).getException();

		if (failureException instanceof ComparisonFailure) {
			ComparisonFailure cf = (ComparisonFailure) failureException;
			// display comparison view
			displayComparisonView(cf, desc);
		}
	}
	return null;
}
 
Example 3
Project: Tarski   File: OpenCloseEvaluatorHandler.java   View source code 6 votes vote down vote up
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
  final IWorkbenchWindow activeWorkbenchWindow = HandlerUtil.getActiveWorkbenchWindow(event);
  final ISourceProviderService service =
      activeWorkbenchWindow.getService(ISourceProviderService.class);
  final AnalysisSourceProvider sourceProvider =
      (AnalysisSourceProvider) service.getSourceProvider(AnalysisSourceProvider.ANALYSIS_STATE);

  final Thread thread = new Thread(new Runnable() {
    @Override
    public void run() {
      if (sourceProvider.getEvaluationState() == EvaluationState.OPEN) {
        Visualization.evaluatorOpen = false;
        sourceProvider.setEvaluationState(EvaluationState.CLOSE);
      } else if (sourceProvider.getEvaluationState() == EvaluationState.CLOSE) {
        Visualization.evaluatorOpen = true;
        sourceProvider.setEvaluationState(EvaluationState.OPEN);
      }
      Visualization.showViz();
    }
  });
  thread.start();
  return true;
}
 
Example 4
Project: ContentAssist   File: CommandExecutionManager.java   View source code 6 votes vote down vote up
/**
 * Receives a command that is about to execute.
 * @param commandId the identifier of the command that is about to execute
 * @param event the event that will be passed to the <code>execute</code> method
 */
@Override
public void preExecute(String commandId, ExecutionEvent event) {
    long time = Time.getCurrentTime();
    String path = recorder.getActiveInputFilePath();
    
    ExecutionMacro macro = new ExecutionMacro(time, "Exec", path, commandId);
    recorder.recordExecutionMacro(macro);
    
    try {
        String id = event.getCommand().getCategory().getId();
        if (id.endsWith("category.refactoring")) {
            recorder.setParentMacro(macro);
            
            TriggerMacro trigger = new TriggerMacro(time, "Refactoring", path, TriggerMacro.Kind.BEGIN);
            recorder.recordTriggerMacro(trigger);
        }
    } catch (NotDefinedException e) {
        e.printStackTrace();
    }
}
 
Example 5
Project: Tarski   File: CountMarkersInResourceHandler.java   View source code 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
  ISelection selection = MarkerFactory.getSelection();
  if (selection instanceof ITreeSelection) {
    ITreeSelection treeSelection = (ITreeSelection) selection;
    if (treeSelection.getFirstElement() instanceof IOpenable
        || treeSelection.getFirstElement() instanceof IFile) {
      IResource resource =
          ((IAdaptable) treeSelection.getFirstElement()).getAdapter(IResource.class);
      List<IMarker> markers = MarkerFactory.findMarkers(resource);
      MessageDialog dialog = new MessageDialog(MarkerActivator.getShell(), "Marker Count", null,
          markers.size() + " marker(s)", MessageDialog.INFORMATION, new String[] {"OK"}, 0);
      dialog.open();
    }
  }
  return null;
}
 
Example 6
Project: gemoc-studio-modeldebugging   File: CreateDomainModelProjectHandler.java   View source code 6 votes vote down vote up
@Override
public Object executeForSelectedLanguage(ExecutionEvent event,
		IProject updatedGemocLanguageProject, Language language)
		throws ExecutionException {
	CreateDomainModelWizardContextAction action = new CreateDomainModelWizardContextAction(
			updatedGemocLanguageProject); 
	action.actionToExecute = CreateDomainModelAction.CREATE_NEW_EMF_PROJECT;
	action.execute();
	
	if(action.getCreatedEcoreUri() != null){
		waitForAutoBuild();
		updateMelange(event,language,action.getCreatedEcoreUri());
	}
	
	return null;
}
 
Example 7
Project: vertigo-chroma-kspplugin   File: OpenKspDeclarationHandler.java   View source code 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	OpenDialogFactory.openDialog(new OpenDialogTemplate() {

		@Override
		public String getNature() {
			return "KSP declaration";
		}

		@Override
		public Object[] getElements() {
			/* Charge les KSP du cache du KspManager. */
			return KspManager.getInstance().getWorkspace().getKspDeclarations().toArray();
		}
	});
	return null;
}
 
Example 8
Project: eclipse-batch-editor   File: AbstractBatchEditorHandler.java   View source code 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	IWorkbench workbench = PlatformUI.getWorkbench();
	if (workbench==null){
		return null;
	}
	IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow();
	if (activeWorkbenchWindow==null){
		return null;
	}
	IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
	if (activePage==null){
		return null;
	}
	IEditorPart editor = activePage.getActiveEditor();
	
	if (editor instanceof BatchEditor){
		executeOnBatchEditor((BatchEditor) editor);
	}
	return null;
}
 
Example 9
Project: neoscada   File: LoadMoreHandler.java   View source code 6 votes vote down vote up
public Object execute ( final ExecutionEvent event ) throws ExecutionException
{
    final String data = event.getParameter ( "org.eclipse.scada.ae.ui.testing.loadMore.count" );
    final int count;

    if ( data == null )
    {
        count = 1000;
    }
    else
    {
        count = Integer.parseInt ( data );
    }

    for ( final QueryBean query : getQueryList () )
    {
        query.getQuery ().loadMore ( count );
    }
    return null;
}
 
Example 10
Project: neoscada   File: OpenDetailsView.java   View source code 6 votes vote down vote up
@Override
public Object execute ( final ExecutionEvent event ) throws ExecutionException
{
    for ( final Item item : getItems () )
    {
        try
        {
            openItem ( item );
        }
        catch ( final PartInitException e )
        {
            throw new ExecutionException ( "Failed to run", e ); //$NON-NLS-1$
        }
    }
    return null;
}
 
Example 11
Project: neoscada   File: OpenExplorerHandler.java   View source code 6 votes vote down vote up
@Override
public Object execute ( final ExecutionEvent event ) throws ExecutionException
{
    try
    {
        // the following cast might look a bit weird. But first an adapter is requested and it only adapts to "core" connection services.
        final ConnectionService connectionService = (ConnectionService)SelectionHelper.first ( getSelection (), org.eclipse.scada.core.connection.provider.ConnectionService.class );
        final IViewPart view = getActivePage ().showView ( SummaryExplorerViewPart.VIEW_ID, "" + this.counter++, IWorkbenchPage.VIEW_ACTIVATE );

        ( (SummaryExplorerViewPart)view ).setConnectionService ( connectionService );
    }
    catch ( final PartInitException e )
    {
        throw new ExecutionException ( "Failed to open view", e );
    }
    return null;
}
 
Example 12
Project: neoscada   File: AbstractServerHandler.java   View source code 6 votes vote down vote up
@Override
public Object execute ( final ExecutionEvent event ) throws ExecutionException
{
    final MultiStatus ms = new MultiStatus ( HivesPlugin.PLUGIN_ID, 0, getLabel (), null );

    for ( final ServerLifecycle server : SelectionHelper.iterable ( getSelection (), ServerLifecycle.class ) )
    {
        try
        {
            process ( server );
        }
        catch ( final CoreException e )
        {
            ms.add ( e.getStatus () );
        }
    }
    if ( !ms.isOK () )
    {
        StatusManager.getManager ().handle ( ms, StatusManager.SHOW );
    }
    return null;
}
 
Example 13
Project: neoscada   File: FillFieldNumbersHandler.java   View source code 6 votes vote down vote up
@Override
public Object execute ( final ExecutionEvent event ) throws ExecutionException
{

    final IEditorPart editor = getActivePage ().getActiveEditor ();

    byte b = (byte)1;
    for ( final Attribute attribute : SelectionHelper.iterable ( getSelection (), Attribute.class ) )
    {
        EditingDomain domain = AdapterFactoryEditingDomain.getEditingDomainFor ( attribute );

        if ( domain == null && editor instanceof IEditingDomainProvider )
        {
            domain = ( (IEditingDomainProvider)editor ).getEditingDomain ();
        }

        SetCommand.create ( domain, attribute, ProtocolPackage.Literals.ATTRIBUTE__FIELD_NUMBER, b ).execute ();

        b++;
    }

    return null;
}
 
Example 14
Project: neoscada   File: SetMasterHandler.java   View source code 6 votes vote down vote up
@Override
public Object execute ( final ExecutionEvent event ) throws ExecutionException
{
    final MasterSelectionDialog dlg;
    try
    {
        dlg = selectMaster ();
    }
    catch ( final CoreException e )
    {
        throw new ExecutionException ( "Failed to select driver", e );
    }

    if ( dlg != null )
    {
        setMaster ( dlg.getMaster (), dlg.getMode () );
    }
    return null;
}
 
Example 15
Project: Tarski   File: DeleteHandler.java   View source code 6 votes vote down vote up
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
  AlloyOtherSolutionReasoning.getInstance().finish();

  if (AlloyUtilities.isExists()) {
    candidateToTypeChanging = new ArrayList<IMarker>();
    file = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor()
        .getEditorInput().getAdapter(IFile.class);
    selection =
        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
    editor =
        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    marker = getMarkerFromEditor();

    deleteMarker();
    refresh();
  } else {
    final MessageDialog infoDialog = new MessageDialog(MarkerActivator.getShell(),
        "System Information", null, "You dont have any registered alloy file to system.",
        MessageDialog.INFORMATION, new String[] {"OK"}, 0);
    infoDialog.open();
  }
  return null;
}
 
Example 16
Project: neoscada   File: ShowComponentSpy.java   View source code 6 votes vote down vote up
@Override
public Object execute ( final ExecutionEvent event ) throws ExecutionException
{
    final Component component = SelectionHelper.first ( getSelection (), Component.class );
    if ( component == null )
    {
        return null;
    }

    try
    {
        final IObservableSet input = Helper.createObversableInput ( DisplayRealm.getRealm ( getShell ().getDisplay () ), component );
        new ComponentOutputDialog ( getShell (), input ).open ();
    }
    catch ( final Exception e )
    {
        StatusManager.getManager ().handle ( StatusHelper.convertStatus ( Activator.PLUGIN_ID, "Failed to generate component output", e ), StatusManager.BLOCK );
        throw new ExecutionException ( "Failed to generate component output", e );
    }

    return null;
}
 
Example 17
Project: eclipse-bash-editor   File: AbstractBashEditorHandler.java   View source code 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	IWorkbench workbench = PlatformUI.getWorkbench();
	if (workbench==null){
		return null;
	}
	IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow();
	if (activeWorkbenchWindow==null){
		return null;
	}
	IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
	if (activePage==null){
		return null;
	}
	IEditorPart editor = activePage.getActiveEditor();
	
	if (editor instanceof BashEditor){
		executeOnBashEditor((BashEditor) editor);
	}
	return null;
}
 
Example 18
Project: eclipse-bash-editor   File: OpenWithBashEditor.java   View source code 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	IFile file = getSelectedFile();
	if (file==null){
		return null;
	}
	IWorkbenchPage page = EclipseUtil.getActivePage();
	if (page==null){
		return null;
	}
	try {
		page.openEditor(new FileEditorInput(file), BashEditor.EDITOR_ID);
	} catch (PartInitException e) {
		throw new ExecutionException("Was not able to open bash editor for file:"+file.getName(),e);
	}
	return null;
}
 
Example 19
Project: pgcodekeeper   File: UpdateDdl.java   View source code 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) {
    IWorkbenchPart part = HandlerUtil.getActiveEditor(event);

    if (part instanceof SQLEditor){
        SQLEditor sqlEditor = (SQLEditor) part;

        if (sqlEditor.getCurrentDb() != null) {
            sqlEditor.updateDdl();
        } else {
            MessageBox mb = new MessageBox(HandlerUtil.getActiveShell(event), SWT.ICON_INFORMATION);
            mb.setText(Messages.UpdateDdl_select_source);
            mb.setMessage(Messages.UpdateDdl_select_source_msg);
            mb.open();
        }
    }
    return null;
}
 
Example 20
Project: Open_Source_ECOA_Toolset_AS5   File: ServicesWizardCommand.java   View source code 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	IWizardDescriptor descriptor = PlatformUI.getWorkbench().getNewWizardRegistry().findWizard(ID);
	if (descriptor == null) {
		descriptor = PlatformUI.getWorkbench().getImportWizardRegistry().findWizard(ID);
	}
	if (descriptor == null) {
		descriptor = PlatformUI.getWorkbench().getExportWizardRegistry().findWizard(ID);
	}
	try {
		if (descriptor != null) {
			IWizard wizard = descriptor.createWizard();
			WizardDialog wd = new WizardDialog(Display.getDefault().getActiveShell(), wizard);
			wd.setTitle(wizard.getWindowTitle());
			wd.open();
		}
	} catch (CoreException e) {
		e.printStackTrace();
	}
	return null;
}
 
Example 21
Project: Open_Source_ECOA_Toolset_AS5   File: CompDefWizardCommand.java   View source code 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	IWizardDescriptor descriptor = PlatformUI.getWorkbench().getNewWizardRegistry().findWizard(ID);
	if (descriptor == null) {
		descriptor = PlatformUI.getWorkbench().getImportWizardRegistry().findWizard(ID);
	}
	if (descriptor == null) {
		descriptor = PlatformUI.getWorkbench().getExportWizardRegistry().findWizard(ID);
	}
	try {
		if (descriptor != null) {
			IWizard wizard = descriptor.createWizard();
			WizardDialog wd = new WizardDialog(Display.getDefault().getActiveShell(), wizard);
			wd.setTitle(wizard.getWindowTitle());
			wd.open();
		}
	} catch (CoreException e) {
		e.printStackTrace();
	}
	return null;
}
 
Example 22
Project: Open_Source_ECOA_Toolset_AS5   File: InitAssmblWizardCommand.java   View source code 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	IWizardDescriptor descriptor = PlatformUI.getWorkbench().getNewWizardRegistry().findWizard(ID);
	if (descriptor == null) {
		descriptor = PlatformUI.getWorkbench().getImportWizardRegistry().findWizard(ID);
	}
	if (descriptor == null) {
		descriptor = PlatformUI.getWorkbench().getExportWizardRegistry().findWizard(ID);
	}
	try {
		if (descriptor != null) {
			IWizard wizard = descriptor.createWizard();
			WizardDialog wd = new WizardDialog(Display.getDefault().getActiveShell(), wizard);
			wd.setTitle(wizard.getWindowTitle());
			wd.open();
		}
	} catch (CoreException e) {
		e.printStackTrace();
	}
	return null;
}
 
Example 23
Project: Tarski   File: LoadSpecificationHandler.java   View source code 6 votes vote down vote up
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
  final MessageDialog warningdialog =
      new MessageDialog(MarkerActivator.getShell(), "Mark Information", null,
          "If new alloy file will be parsed , your all marker type will be lost !",
          MessageDialog.WARNING, new String[] {"OK", "Cancel"}, 0);
  if (warningdialog.open() != 0) {
    return null;
  }

  final String filePath = getFilePath();
  if (filePath == null) {
    return null;
  }
  AlloyParseUtil.parse(filePath);

  try {
    TraceManager.get().loadSpec(filePath);
  } catch (final TraceException e) {
    e.printStackTrace();
  }
  return null;
}
 
Example 24
Project: Open_Source_ECOA_Toolset_AS5   File: TypesWizardCommand.java   View source code 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	IWizardDescriptor descriptor = PlatformUI.getWorkbench().getNewWizardRegistry().findWizard(ID);
	if (descriptor == null) {
		descriptor = PlatformUI.getWorkbench().getImportWizardRegistry().findWizard(ID);
	}
	if (descriptor == null) {
		descriptor = PlatformUI.getWorkbench().getExportWizardRegistry().findWizard(ID);
	}
	try {
		if (descriptor != null) {
			IWizard wizard = descriptor.createWizard();
			WizardDialog wd = new WizardDialog(Display.getDefault().getActiveShell(), wizard);
			wd.setTitle(wizard.getWindowTitle());
			wd.open();
		}
	} catch (CoreException e) {
		e.printStackTrace();
	}
	return null;
}
 
Example 25
Project: gw4e.project   File: ConvertToHandler.java   View source code 6 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {

		ISelection sel = HandlerUtil.getCurrentSelection(event);
		if (sel.isEmpty())
			return null;
		if (!(sel instanceof IStructuredSelection))
			return null;
		Object obj = ((IStructuredSelection) sel).getFirstElement();
		if (!(obj instanceof IFile))
			return null;
 
		try {
			ConvertToFileCreationWizard wizard = new ConvertToFileCreationWizard( );
			wizard.init(PlatformUI.getWorkbench(), (IStructuredSelection)sel);
			Shell activeShell = HandlerUtil.getActiveShell(event);
			if (activeShell==null) return null;
			WizardDialog dialog = new WizardDialog(activeShell,wizard);
			dialog.open();
		} catch (Exception e) {
			ResourceManager.logException(e);
		}
 
		return null;
	}
 
Example 26
Project: pgcodekeeper   File: OpenProjectUtils.java   View source code 6 votes vote down vote up
static PgDbProject getProject(ExecutionEvent event){
    try{
        ISelection sel = HandlerUtil.getActiveMenuSelection(event);
        IStructuredSelection selection = (IStructuredSelection) sel;
        if (selection == null){
            return null;
        }
        Object firstElement = selection.getFirstElement();
        if (firstElement instanceof IProject) {
            IProject proj = (IProject)firstElement;
            if (proj.getNature(NATURE.ID) != null) {
                return new PgDbProject(proj);
            }
        }
    } catch (CoreException ce){
        Log.log(Log.LOG_ERROR, ce.getMessage());
    }
    return null;
}
 
Example 27
Project: vertigo-chroma-kspplugin   File: OpenServiceHandler.java   View source code 6 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	OpenDialogFactory.openDialog(new OpenDialogTemplate() {

		@Override
		public String getNature() {
			return "service method";
		}

		@Override
		public Object[] getElements() {
			/* Charge les services du cache du ServiceManager. */
			return ServiceManager.getInstance().getWorkspace().getServiceImplementations().toArray();
		}
	});
	return null;
}
 
Example 28
Project: pgcodekeeper   File: CommitProject.java   View source code 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) {
    IWorkbenchPart part = HandlerUtil.getActiveEditor(event);
    if (part instanceof ProjectEditorDiffer){
        ProjectEditorDiffer differ = (ProjectEditorDiffer) part;
        try {
            differ.commit();
        } catch (PgCodekeeperException ex) {
            ExceptionNotifier.notifyDefault(Messages.error_creating_dependency_graph, ex);
        }
    }
    return null;
}
 
Example 29
Project: n4js   File: ConsiderOverridenMembersHandler.java   View source code 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	Command cmd = event.getCommand();
	boolean currentState = HandlerUtil.toggleCommandState(cmd);
	N4JSReferenceQueryExecutor.considerOverridenMethods = !currentState;
	return null;
}
 
Example 30
Project: n4js   File: OpenExternalLibraryPreferencePageHandler.java   View source code 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	Shell shell = HandlerUtil.getActiveShell(event);
	PreferenceDialog dialog = createPreferenceDialogOn(shell, ExternalLibraryPreferencePage.ID, FILTER_IDS, null);
	if (null != dialog) {
		dialog.open();
	}
	return null;
}
 
Example 31
Project: n4js   File: OpenGeneratedSourceInEditorHandler.java   View source code 5 votes vote down vote up
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {

	final ISelection selection = getCurrentSelection(event);
	if (null == selection) {
		return null;
	}

	if (selection.isEmpty()) {
		return null;
	}

	final AtomicReference<IFile> fileRef = new AtomicReference<>();

	if (selection instanceof IStructuredSelection) {
		final Object element = ((IStructuredSelection) selection).getFirstElement();
		if (element instanceof IFile) {
			fileRef.set((IFile) element);
		}
	} else if (selection instanceof ITextSelection) {
		final IEditorPart editorPart = getActiveEditor(event);
		if (null != editorPart) {
			final IEditorInput input = editorPart.getEditorInput();
			if (input instanceof IFileEditorInput) {
				fileRef.set(((IFileEditorInput) input).getFile());
			}
		}
	}

	if (null != fileRef.get()) {
		final Optional<IFile> generatedSource = fileLocator.tryGetGeneratedSourceForN4jsFile(fileRef.get());
		if (generatedSource.isPresent()) {
			tryOpenFileInEditor(fileRef.get(), generatedSource.get());
		}
	}

	return null;
}
 
Example 32
Project: n4js   File: CreateNewN4JSElementInModuleHandler.java   View source code 5 votes vote down vote up
/**
 * Returns the active tree resource selection if there is one.
 *
 * Examines the active workspace selection and if it is a resource inside of a tree returns it.
 *
 * @param event
 *            The execution event
 * @returns The resource or {@code null} on failure.
 *
 */
private static IResource getActiveTreeResourceSelection(ExecutionEvent event) {

	ISelection activeSelection = HandlerUtil.getCurrentSelection(event);

	if (activeSelection instanceof TreeSelection) {
		Object firstElement = ((TreeSelection) activeSelection).getFirstElement();

		if (firstElement instanceof IResource) {
			return (IResource) firstElement;
		}
	}
	return null;
}
 
Example 33
Project: Hydrograph   File: CopyHandler.java   View source code 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	IWorkbenchPart part = HandlerUtil.getActivePart(event);
	if(part instanceof CommonNavigator){
		CopyToClipboardAction action=new CopyToClipboardAction(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart().getSite());
		action.run();
	}

	else if(part instanceof ELTGraphicalEditor){
		IEditorPart editor = HandlerUtil.getActiveEditor(event);
		((ELTGraphicalEditor)editor).copySelection();
	}
	return null;	
}
 
Example 34
Project: gemoc-studio-modeldebugging   File: StepBackIntoHandler.java   View source code 5 votes vote down vote up
@Override
/**
 * the command has been executed, so extract extract the needed information
 * from the application context.
 */
public Object execute(ExecutionEvent event) throws ExecutionException {
	Supplier<OmniscientGenericSequentialModelDebugger> debuggerSupplier = Activator.getDefault().getDebuggerSupplier();
	if (debuggerSupplier != null) {
		OmniscientGenericSequentialModelDebugger debugger = debuggerSupplier.get();
		debugger.stepBackInto();
	}
	
	return null;
}
 
Example 35
Project: gemoc-studio-modeldebugging   File: StepBackOutHandler.java   View source code 5 votes vote down vote up
@Override
/**
 * the command has been executed, so extract extract the needed information
 * from the application context.
 */
public Object execute(ExecutionEvent event) throws ExecutionException {
	Supplier<OmniscientGenericSequentialModelDebugger> debuggerSupplier = Activator.getDefault().getDebuggerSupplier();
	if (debuggerSupplier != null) {
		OmniscientGenericSequentialModelDebugger debugger = debuggerSupplier.get();
		debugger.stepBackOut();
	}
	
	return null;
}
 
Example 36
Project: pgcodekeeper   File: QuickUpdate.java   View source code 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) {
    SQLEditor editor = (SQLEditor) HandlerUtil.getActiveEditor(event);
    DbInfo dbInfo = editor.getCurrentDb();
    if (dbInfo == null){
        ExceptionNotifier.notifyDefault(Messages.sqlScriptDialog_script_select_storage, null);
        return null;
    }
    String text = editor.getEditorText();
    if (text.trim().isEmpty()) {
        ExceptionNotifier.notifyDefault(Messages.QuickUpdate_empty_script, null);
        return null;
    }

    IFile file = ResourceUtil.getFile(editor.getEditorInput());
    editor.doSave(new NullProgressMonitor());
    byte[] textSnapshot;
    try {
        textSnapshot = text.getBytes(file.getCharset());
    } catch (UnsupportedEncodingException | CoreException e) {
        ExceptionNotifier.notifyDefault(Messages.QuickUpdate_error_charset, e);
        return null;
    }

    QuickUpdateJob quickUpdateJob = new QuickUpdateJob(file, dbInfo, textSnapshot, editor);
    quickUpdateJob.setUser(true);
    quickUpdateJob.schedule();
    editor.saveLastDb(dbInfo);

    return null;
}
 
Example 37
Project: avro-schema-editor   File: ExpandAllDebugHandler.java   View source code 5 votes vote down vote up
@Override
protected Object execute(AvroSchemaEditorDebugView debugView, ExecutionEvent event) {
	
	TreeViewer treeViewer = debugView.getViewer();
	UIUtils.expandAll(treeViewer, CMD_ID);
	
	return null;
}
 
Example 38
Project: gemoc-studio-modeldebugging   File: CreateAnimatorProjectHandler.java   View source code 5 votes vote down vote up
@Override
public Object executeForSelectedLanguage(ExecutionEvent event,
		IProject updatedGemocLanguageProject, Language language)
		throws ExecutionException {
	CreateAnimatorProjectWizardContextAction action = new CreateAnimatorProjectWizardContextAction(
			updatedGemocLanguageProject, language);
	action.actionToExecute = CreateAnimatorProjectAction.CREATE_NEW_SIRIUS_PROJECT;
	action.execute();
	return null;
}
 
Example 39
Project: Hydrograph   File: RedoHandler.java   View source code 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	
	IEditorPart editor = HandlerUtil.getActiveEditor(event);
	if(editor instanceof ELTGraphicalEditor)((ELTGraphicalEditor)editor).redoSelection();
	return null;
}
 
Example 40
Project: gemoc-studio-modeldebugging   File: OpenSemanticsHandler.java   View source code 5 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
	Supplier<IExecutionEngine> engineSupplier = org.eclipse.gemoc.executionframework.debugger.Activator.getDefault().getEngineSupplier();
	Supplier<String> bundleSupplier = org.eclipse.gemoc.executionframework.debugger.Activator.getDefault().getBundleSymbolicNameSupplier();
	if (engineSupplier != null) {
		this.engine = engineSupplier.get();
	}
	if (bundleSupplier != null) {
		this.bundleSymbolicName = bundleSupplier.get();
	}
	
	TreeSelection selection = (TreeSelection) HandlerUtil.getCurrentSelection(event);
	locateAndOpenSource(selection);
	return null;
}