當前位置: 首頁>>代碼示例>>Java>>正文


Java HandlerUtil類代碼示例

本文整理匯總了Java中org.eclipse.ui.handlers.HandlerUtil的典型用法代碼示例。如果您正苦於以下問題:Java HandlerUtil類的具體用法?Java HandlerUtil怎麽用?Java HandlerUtil使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


HandlerUtil類屬於org.eclipse.ui.handlers包,在下文中一共展示了HandlerUtil類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: execute

import org.eclipse.ui.handlers.HandlerUtil; //導入依賴的package包/類
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
	/*MessageDialog.openInformation(
			window.getShell(),
			"Plugin",
			"Hello, Eclipse world");*/
	
	// Pfad vom Projekt
    if (window != null)
    {
        IStructuredSelection selection = (IStructuredSelection) window.getSelectionService().getSelection();
        Object firstElement = selection.getFirstElement();
        if (firstElement instanceof IAdaptable)
        {
            IProject project = (IProject)((IAdaptable)firstElement).getAdapter(IProject.class);
            IPath path = project.getFullPath();
            System.out.println("Projekt: "+path);
            StartEGL.start(""+path);
        }
    }
	
	return null;
}
 
開發者ID:Nielko,項目名稱:MBSE-Vacation-Manager,代碼行數:25,代碼來源:ExportHandler.java

示例2: execute

import org.eclipse.ui.handlers.HandlerUtil; //導入依賴的package包/類
@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;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:26,代碼來源:XpectCompareCommandHandler.java

示例3: execute

import org.eclipse.ui.handlers.HandlerUtil; //導入依賴的package包/類
@Override
public final Object execute ( final ExecutionEvent event ) throws ExecutionException
{
    final IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked ( event );

    final Object value = event.getParameter ( PARAMETER_NAME_VIEW_ID );

    try
    {
        final String[] viewIds = ( (String)value ).split ( ":" );
        if ( viewIds.length == 1 )
        {
            openView ( viewIds[0], null, window );
        }
        else if ( viewIds.length == 2 )
        {
            openView ( viewIds[0], viewIds[1], window );
        }
    }
    catch ( final PartInitException e )
    {
        throw new ExecutionException ( "Part could not be initialized", e ); //$NON-NLS-1$
    }

    return null;
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:27,代碼來源:ShowViewHandler.java

示例4: execute

import org.eclipse.ui.handlers.HandlerUtil; //導入依賴的package包/類
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;
	}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:25,代碼來源:ConvertToHandler.java

示例5: getProject

import org.eclipse.ui.handlers.HandlerUtil; //導入依賴的package包/類
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;
}
 
開發者ID:pgcodekeeper,項目名稱:pgcodekeeper,代碼行數:20,代碼來源:OpenProjectUtils.java

示例6: execute

import org.eclipse.ui.handlers.HandlerUtil; //導入依賴的package包/類
@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;
}
 
開發者ID:pgcodekeeper,項目名稱:pgcodekeeper,代碼行數:19,代碼來源:UpdateDdl.java

示例7: execute

import org.eclipse.ui.handlers.HandlerUtil; //導入依賴的package包/類
/**
 * the command has been executed, so extract extract the needed information
 * from the application context.
 */
public Object execute(ExecutionEvent event) throws ExecutionException {
	IWorkbenchWindow window = HandlerUtil
			.getActiveWorkbenchWindowChecked(event);
	final Display display = Display.getDefault();
	final Shell shell = window.getShell();
	Locale.setDefault(Locale.ENGLISH);
	final TipDayEx tipDayEx = new TipDayEx();
	for (String tipMessage : new String[] { "This is the first tip",
			"This is the second tip", "This is the third tip",
			"This is the forth tip", "This is the fifth tip" }) {
		tipDayEx.addTip(String.format(
				"<h4>%s</h4>" + "<b>%s</b> " + "<u>%s</u> " + "<i>%s</i> " + "%s "
						+ "%s<br/>" + "<p color=\"#A00000\">%s</p>",
				tipMessage, tipMessage, tipMessage, tipMessage, tipMessage,
				tipMessage, tipMessage));

	}
	tipDayEx.open(shell, display);
	return null;
}
 
開發者ID:sergueik,項目名稱:SWET,代碼行數:25,代碼來源:SampleHandler.java

示例8: execute

import org.eclipse.ui.handlers.HandlerUtil; //導入依賴的package包/類
@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);
  sourceProvider.setPassive();

  final Thread thread = new Thread(new Runnable() {
    @Override
    public void run() {
      AlloyValidator.isCanceled = true;
      AlloyOtherSolutionReasoning.getInstance().finish();
      AlloyOtherSolutionDiscovering.getInstance().finish();
      AlloyOtherSolutionReasoningForAtom.getInstance().finish();
      Visualization.showViz();
    }
  });
  thread.start();
  return true;
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:23,代碼來源:VizStopOtherSolutionHandler.java

示例9: execute

import org.eclipse.ui.handlers.HandlerUtil; //導入依賴的package包/類
@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;
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:25,代碼來源:OpenCloseEvaluatorHandler.java

示例10: execute

import org.eclipse.ui.handlers.HandlerUtil; //導入依賴的package包/類
@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);
  sourceProvider.setActive(ReasoningType.DISCOVER_RELATION);

  final Thread thread = new Thread(new Runnable() {
    @Override
    public void run() {
      final AlloyReasoning alloyReasoning = new AlloyReasoning();
      final boolean reasoning = alloyReasoning.reasoning();
      if (!reasoning) {
        sourceProvider.setPassive();
      }

      Visualization.showViz();
    }
  });
  thread.start();
  return true;
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:25,代碼來源:VizDiscoverRelationsHandler.java

示例11: execute

import org.eclipse.ui.handlers.HandlerUtil; //導入依賴的package包/類
@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);
  sourceProvider.setActive(ReasoningType.DISCOVER_ATOM);

  final Thread thread = new Thread(new Runnable() {
    @Override
    public void run() {
      final AlloyDiscovering alloyDiscovering = new AlloyDiscovering();
      final boolean discovering =
          alloyDiscovering.discovering();
      if (!discovering) {
        Visualization.sourceProvider.setPassive();
      }
      Visualization.showViz();
    }
  });
  thread.start();
  return true;
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:25,代碼來源:VizDiscoverAtomsHandler.java

示例12: execute

import org.eclipse.ui.handlers.HandlerUtil; //導入依賴的package包/類
@Override
public Object execute(final ExecutionEvent event) throws ExecutionException {

	final IEditorPart editorPart = HandlerUtil.getActiveEditor(event);
	final ICompilationUnit icu = JavaUI.getWorkingCopyManager().getWorkingCopy(editorPart.getEditorInput());

	try {
		final IType type = icu.getTypes()[0];
		final List<Field> fields = new ArrayList<>();
		for (final IField field : type.getFields()) {
			final String fieldName = field.getElementName();
			final String fieldType = Signature.getSignatureSimpleName(field.getTypeSignature());
			fields.add(new Field(fieldName, fieldType));
		}

		new WizardDialog(HandlerUtil.getActiveShell(event), new BuilderGeneratorWizard(icu, fields)).open();

	}
	catch (final JavaModelException e) {
		e.printStackTrace();
	}

	return null;
}
 
開發者ID:khabali,項目名稱:java-builders-generator,代碼行數:25,代碼來源:GenerateBuildersHandler.java

示例13: execute

import org.eclipse.ui.handlers.HandlerUtil; //導入依賴的package包/類
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	TreeSelection selection = (TreeSelection) HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getSelection();
	Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
	Object firstElement = selection.getFirstElement();
	
	if (firstElement instanceof IAdaptable)
       {
           IFile file = (IFile)((IAdaptable)firstElement).getAdapter(IFile.class);
           IPath path = file.getLocation();
           
           try {
           	//TODO fix
			SurveyGenerator.generateAll(path.toOSString(), path.toOSString());
			MessageDialog.openInformation(shell, "Success", "Code was generated successfully");
		} catch (Exception e) {
			//MessageDialog.openError(shell, "Error", e.getMessage());
			e.printStackTrace();
		}
       }
	return null;
}
 
開發者ID:TodorovicNikola,項目名稱:SurveyDSL,代碼行數:23,代碼來源:GenerateATLHandler.java

示例14: execute

import org.eclipse.ui.handlers.HandlerUtil; //導入依賴的package包/類
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
  final IPath containerPath = new Path(Initializer.APGAS_CONTAINER_ID);
  try {
    final IJavaProject javaProject = JavaCore
        .create(((IAdaptable) ((IStructuredSelection) HandlerUtil
            .getCurrentSelection(event)).getFirstElement())
                .getAdapter(IProject.class));
    final IClasspathEntry[] entries = javaProject.getRawClasspath();
    for (int i = 0; i < entries.length; i++) {
      if (entries[i].getEntryKind() == IClasspathEntry.CPE_CONTAINER
          && entries[i].getPath().equals(containerPath)) {
        return null;
      }
    }
    final IClasspathEntry[] cp = new IClasspathEntry[entries.length + 1];
    System.arraycopy(entries, 0, cp, 0, entries.length);
    cp[entries.length] = JavaCore.newContainerEntry(containerPath);
    javaProject.setRawClasspath(cp, new NullProgressMonitor());
  } catch (final Exception e) {
    throw new ExecutionException(e.toString(), e);
  }
  return null;
}
 
開發者ID:x10-lang,項目名稱:apgas,代碼行數:25,代碼來源:Handler.java

示例15: execute

import org.eclipse.ui.handlers.HandlerUtil; //導入依賴的package包/類
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	markSpec = getMark();
	IEditorPart edPart = HandlerUtil.getActiveEditor(event);
	if (edPart instanceof FluentMkEditor) {
		editor = (FluentMkEditor) edPart;
		doc = editor.getDocument();
		if (doc != null) {
			ISelection sel = HandlerUtil.getCurrentSelection(event);
			if (sel instanceof TextSelection) {
				TextSelection tsel = (TextSelection) sel;
				int beg = tsel.getOffset();
				int len = tsel.getLength();
				cpos = editor.getCursorOffset();
				if (len == 0) beg = cpos;
				try {
					if (samePartition(beg, len)) {
						toggle(beg, len);
					}
				} catch (BadLocationException e) {}
			}
		}
	}
	return null;
}
 
開發者ID:grosenberg,項目名稱:fluentmark,代碼行數:26,代碼來源:AbstractMarksHandler.java


注:本文中的org.eclipse.ui.handlers.HandlerUtil類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。