当前位置: 首页>>代码示例>>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;未经允许,请勿转载。