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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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;
}
 
Example 41
Project: Hydrograph   File: StopJobHandler.java   Source Code and License 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	((StopJobHandler) RunStopButtonCommunicator.StopJob.getHandler()).setStopJobEnabled(false);
	JobManager.INSTANCE.killJob(JobManager.INSTANCE.getActiveCanvas());
	
	return null;
}
 
Example 42
Project: Hydrograph   File: ExternalSchemaUpdaterHandler.java   Source Code and License 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent arg0) throws ExecutionException {

	List<File> selectedJobFile = getSelectedJobFile();
	if (selectedJobFile.size() > 0) {
		updatedExternalSchema(selectedJobFile);
	}
	return null;
}
 
Example 43
Project: time4sys   File: NewTime4SysProject.java   Source Code and License 5 votes vote down vote up
public Object execute(ExecutionEvent event) throws ExecutionException {
	// Open the new Time4Sys project wizard
	final IWizard wizard = new Time4SysProjectWizard();
	final WizardDialog dialog = new WizardDialog(
			PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard);
	dialog.open();
	return null;
}
 
Example 44
Project: visuflow-plugin   File: DebugStepOverHandler.java   Source Code and License 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	EventAdmin ea = ServiceUtil.getService(EventAdmin.class);
	Event stepOver = new Event(EA_TOPIC_DEBUGGING_ACTION_STEP_OVER, Collections.emptyMap());
	ea.sendEvent(stepOver);

	// has to be null (see javadoc)
	return null;
}
 
Example 45
Project: visuflow-plugin   File: LinkTargetProject.java   Source Code and License 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	
	IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
	TargetHandlerDialog targetHandler = new TargetHandlerDialog(window.getShell());
	targetHandler.open();
	return null;
}
 
Example 46
Project: Tarski   File: DropDownCommandHandler.java   Source Code and License 5 votes vote down vote up
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {
  // Sanity check.
  if (null == event) {
    return null;
  }

  // Class check.
  if (!(event.getTrigger() instanceof Event)) {
    return null;
  }

  final Event eventWidget = (Event) event.getTrigger();

  // Makes sure event came from a ToolItem.
  if (!(eventWidget.widget instanceof ToolItem)) {
    return null;
  }

  final ToolItem toolItem = (ToolItem) eventWidget.widget;

  // Creates fake selection event.
  final Event newEvent = new Event();
  newEvent.button = 1;
  newEvent.widget = toolItem;
  newEvent.detail = SWT.ARROW;
  newEvent.x = toolItem.getBounds().x;
  newEvent.y = toolItem.getBounds().y + toolItem.getBounds().height;

  // Dispatches the event.
  toolItem.notifyListeners(SWT.Selection, newEvent);

  return null;
}
 
Example 47
Project: Hydrograph   File: PaletteHandler.java   Source Code and License 5 votes vote down vote up
/**
 * open Palette view
 * @param event
 * @return Object
 */
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	
	try {
		PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
		.showView("org.eclipse.gef.ui.palette_view");
	} catch (PartInitException e) {
		logger.error(e.getMessage());
	}
	return null;
}
 
Example 48
Project: neoscada   File: OpenChartViewWithParameters.java   Source Code and License 5 votes vote down vote up
private Chart makeConfiguration ( final ExecutionEvent event )
{
    final String queryTimespec = event.getParameter ( "org.eclipse.scada.ui.chart.queryTimespec" ); //$NON-NLS-1$

    final Chart configuration = Charts.makeDefaultConfiguration ();

    final XAxis x = configuration.getSelectedXAxis ().get ( 0 );
    final YAxis y = configuration.getSelectedYAxis ().get ( 0 );

    if ( queryTimespec != null && !queryTimespec.isEmpty () )
    {
        final String toks[] = queryTimespec.split ( "[: ]+" ); //$NON-NLS-1$

        final long now = System.currentTimeMillis ();

        final int left = Integer.parseInt ( toks[0] );
        final int right = Integer.parseInt ( toks[1] );
        x.setMinimum ( now - left );
        x.setMaximum ( now + right );

        if ( toks.length >= 4 )
        {
            final double min = Double.parseDouble ( toks[2] );
            final double max = Double.parseDouble ( toks[3] );
            y.setMinimum ( min );
            y.setMaximum ( max );
        }
    }

    Charts.addCompositeQuality ( configuration );

    return configuration;
}
 
Example 49
Project: neoscada   File: DeleteConnection.java   Source Code and License 5 votes vote down vote up
@Override
public Object execute ( final ExecutionEvent event ) throws ExecutionException
{
    logger.info ( "Execute command: {}", event ); //$NON-NLS-1$

    final Collection<ConnectionHolder> connections = getConnections ();

    final boolean result = MessageDialog.openQuestion ( getWorkbenchWindow ().getShell (), Messages.DeleteConnection_MessageDialog_Title, MessageFormat.format ( Messages.DeleteConnection_MessageDialog_Message, connections.size () ) );
    if ( !result )
    {
        // user pressed "NO"
        return null;
    }

    final MultiStatus status = new MultiStatus ( Activator.PLUGIN_ID, 0, Messages.DeleteConnection_MultiStatus_Text, null );

    for ( final ConnectionHolder holder : connections )
    {
        final ConnectionStore store = AdapterHelper.adapt ( holder.getDiscoverer (), ConnectionStore.class );
        if ( store != null )
        {
            try
            {
                store.remove ( holder.getConnectionInformation () );
            }
            catch ( final CoreException e )
            {
                logger.info ( "Failed to remove connection", e ); //$NON-NLS-1$
                status.add ( e.getStatus () );
            }
        }
    }

    return null;
}
 
Example 50
Project: Tarski   File: MarkAllHandler.java   Source Code and License 5 votes vote down vote up
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
  if (AlloyUtilities.isExists()) {
    this.createMarkers();
    this.refresh();
  } else {
    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 51
Project: neoscada   File: OpenConnection.java   Source Code and License 5 votes vote down vote up
@Override
public Object execute ( final ExecutionEvent event ) throws ExecutionException
{
    logger.info ( "Execute command: {}", event ); //$NON-NLS-1$

    for ( final ConnectionHolder holder : getConnections () )
    {
        holder.connect ( DisplayCallbackHandler.createDefault ( getShell () ) );
    }

    return null;
}
 
Example 52
Project: neoscada   File: RemoveHandler.java   Source Code and License 5 votes vote down vote up
public Object execute ( final ExecutionEvent event ) throws ExecutionException
{
    for ( final QueryBean query : getQueryList () )
    {
        query.remove ();
    }
    return null;
}
 
Example 53
Project: neoscada   File: AcknowledgeHandler.java   Source Code and License 5 votes vote down vote up
@Override
public Object execute ( final ExecutionEvent handlerEvent ) throws ExecutionException
{
    final IWorkbenchPart part = getActivePage ().getActivePart ();
    if ( ! ( part instanceof MonitorSubscriptionAlarmsEventsView ) )
    {
        return null;
    }

    final MonitorSubscriptionAlarmsEventsView view = (MonitorSubscriptionAlarmsEventsView)part;

    final Iterator<?> i = getSelection ().iterator ();

    while ( i.hasNext () )
    {
        final AckInformation ackInformation = AdapterHelper.adapt ( i.next (), AckInformation.class );
        if ( ackInformation == null )
        {
            continue;
        }

        final MonitorStatus status = ackInformation.getMonitorStatus ();
        switch ( status )
        {
            case NOT_AKN:
            case NOT_OK_NOT_AKN:
                view.acknowledgeMonitor ( ackInformation.getMonitorId (), ackInformation.getTimestamp (), new DisplayCallbackHandler ( getShell (), "Acknowledge", "Confirmation required" ) );
                break;
            default:
                break;
        }
    }

    return null;
}
 
Example 54
Project: neoscada   File: AknHandler.java   Source Code and License 5 votes vote down vote up
public Object execute ( final ExecutionEvent event ) throws ExecutionException
{
    for ( final MonitorStatusBean bean : getMonitors () )
    {
        bean.akn ();
    }
    return null;
}
 
Example 55
Project: neoscada   File: LoginDialogHandler.java   Source Code and License 5 votes vote down vote up
public Object execute ( final ExecutionEvent event ) throws ExecutionException
{
    final Shell shell = PlatformUI.getWorkbench ().getActiveWorkbenchWindow ().getShell ();

    final LoginDialog dlg = new LoginDialog ( shell );
    return dlg.open ();
}
 
Example 56
Project: avro-schema-editor   File: CollapseNodeAllHandler.java   Source Code and License 5 votes vote down vote up
@Override
protected void doExecute(ExecutionEvent event, AvroSchemaEditor schemaEditor, AvroContext context) {		
	SchemaViewer viewer = schemaEditor.getContentPart().getSchemaViewer(context.getKind());
	SchemaNode selectedSchemaNode = getSelectedSchemaNode(viewer, context);
	if (selectedSchemaNode != null) {
		UIUtils.collapseAll(viewer.getTreeViewer(), selectedSchemaNode);
	}			
}
 
Example 57
Project: neoscada   File: CloseQueryHandler.java   Source Code and License 5 votes vote down vote up
@Override
public Object execute ( final ExecutionEvent event ) throws ExecutionException
{
    for ( final AbstractQueryBuffer query : getQueries () )
    {
        query.close ();
    }
    return null;
}
 
Example 58
Project: pandionj   File: Activator.java   Source Code and License 5 votes vote down vote up
private static void showView(ExecutionEvent event) {
	IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
	try {
		window.getActivePage().showView("pt.iscte.pandionj.view");
	} catch (PartInitException e) {

	}
}
 
Example 59
Project: neoscada   File: PreviewHandler.java   Source Code and License 5 votes vote down vote up
@Override
public Object execute ( final ExecutionEvent event ) throws ExecutionException
{
    final MultiStatus ms = new MultiStatus ( Activator.PLUGIN_ID, 0, "Opening preview", null );

    for ( final IFile file : SelectionHelper.iterable ( getSelection (), IFile.class ) )
    {
        final IEditorInput input = new FileEditorInput ( file );
        try
        {
            getActivePage ().openEditor ( input, PreviewEditorImpl.EDITOR_ID, true, IWorkbenchPage.MATCH_ID );
        }
        catch ( final PartInitException e )
        {
            ms.add ( e.getStatus () );
        }
    }

    if ( !ms.isOK () )
    {
        final IStatus[] childs = ms.getChildren ();
        if ( childs.length < 2 )
        {
            StatusManager.getManager ().handle ( childs[0], StatusManager.SHOW );
        }
        else
        {
            StatusManager.getManager ().handle ( ms, StatusManager.SHOW );
        }
    }

    return null;
}
 
Example 60
Project: neoscada   File: ReloadHandler.java   Source Code and License 5 votes vote down vote up
@Override
public Object execute ( final ExecutionEvent event ) throws ExecutionException
{
    final IEditorPart editor = PlatformUI.getWorkbench ().getActiveWorkbenchWindow ().getActivePage ().getActiveEditor ();
    if ( editor instanceof PreviewEditorImpl )
    {
        ( (PreviewEditorImpl)editor ).reload ();
    }
    return null;
}