当前位置: 首页>>代码示例>>Java>>正文


Java HandlerUtil.getActiveEditor方法代码示例

本文整理汇总了Java中org.eclipse.ui.handlers.HandlerUtil.getActiveEditor方法的典型用法代码示例。如果您正苦于以下问题:Java HandlerUtil.getActiveEditor方法的具体用法?Java HandlerUtil.getActiveEditor怎么用?Java HandlerUtil.getActiveEditor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.ui.handlers.HandlerUtil的用法示例。


在下文中一共展示了HandlerUtil.getActiveEditor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: getService

import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
/**
 * Returns an OSGi service from {@link ExecutionEvent}. It looks up a service in the following
 * locations (if exist) in the given order:
 *
 * {@code HandlerUtil.getActiveSite(event)}
 * {@code HandlerUtil.getActiveEditor(event).getEditorSite()}
 * {@code HandlerUtil.getActiveEditor(event).getSite()}
 * {@code HandlerUtil.getActiveWorkbenchWindow(event)}
 * {@code PlatformUI.getWorkbench()}
 */
public static <T> T getService(ExecutionEvent event, Class<T> api) {
  IWorkbenchSite activeSite = HandlerUtil.getActiveSite(event);
  if (activeSite != null) {
    return activeSite.getService(api);
  }

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

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

  return PlatformUI.getWorkbench().getService(api);
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:36,代码来源:ServiceUtils.java

示例4: 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

示例5: execute

import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	IEditorPart edPart = HandlerUtil.getActiveEditor(event);
	if (edPart instanceof FluentMkEditor) {
		FluentMkEditor editor = (FluentMkEditor) edPart;
		IDocument 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();

				switch (checkPartition(doc, beg, len)) {
					case NONE:
						addComment(doc, beg, len);
						break;
					case SAME:
						removeComment(doc, beg);
						break;
				}
			}
		}
	}
	return null;
}
 
开发者ID:grosenberg,项目名称:fluentmark,代码行数:27,代码来源:ToggleHiddenCommentHandler.java

示例6: execute

import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) {
    IWorkbenchPart part = HandlerUtil.getActiveEditor(event);

    if (part instanceof ProjectEditorDiffer){
        ProjectEditorDiffer differ = (ProjectEditorDiffer) part;
        differ.diff();
    }
    return null;
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:11,代码来源:DiffProject.java

示例7: execute

import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) {
    IEditorPart part = HandlerUtil.getActiveEditor(event);

    if (part instanceof ProjectEditorDiffer){
        ((ProjectEditorDiffer) part).getChanges();
    } else if (part instanceof SQLEditor && part.getEditorInput() instanceof IFileEditorInput) {
        try {
            SQLEditor sqlEditor = (SQLEditor) part;
            IProject proj = ((IFileEditorInput) sqlEditor.getEditorInput()).getFile().getProject();

            DbInfo remote = sqlEditor.getCurrentDb();
            ProjectEditorDiffer editor = ChangesJobTester.findProjectEditor(proj);
            if (editor == null) {
                ProjectEditorDiffer.saveLastDb(remote, proj);
                ProjectEditorInput projectEditorInput = new ProjectEditorInput(proj.getName());
                editor = (ProjectEditorDiffer) sqlEditor.getSite().getPage()
                        .openEditor(projectEditorInput, EDITOR.PROJECT);
            } else {
                editor.setCurrentDb(remote);
                editor.getSite().getPage().activate(editor);
            }
            editor.getChanges();
        } catch (PartInitException e) {
            ExceptionNotifier.notifyDefault(e.getLocalizedMessage(), e);
        }
    }
    return null;
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:30,代码来源:GetChanges.java

示例8: 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;
        sqlEditor.cancelDdl();
    }

    return null;
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:12,代码来源:CancelDdl.java

示例9: execute

import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) {
    IWorkbenchPart part = HandlerUtil.getActiveEditor(event);

    if (part instanceof ProjectEditorDiffer){
        ProjectEditorDiffer differ = (ProjectEditorDiffer) part;
        differ.addDependency();
    }
    return null;
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:11,代码来源:AddDepcy.java

示例10: execute

import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
@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;
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:32,代码来源:QuickUpdate.java

示例11: execute

import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
@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;
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:14,代码来源:CommitProject.java

示例12: execute

import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {

	IEditorPart editor = HandlerUtil.getActiveEditor(event);
	if (editor instanceof ELTGraphicalEditor)
		((ELTGraphicalEditor) editor).selectAllSelection();

	return null;
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:10,代码来源:SelectAllHandler.java

示例13: execute

import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	
	IEditorPart editor = HandlerUtil.getActiveEditor(event);
	if(editor instanceof ELTGraphicalEditor)((ELTGraphicalEditor)editor).redoSelection();
	return null;
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:8,代码来源:RedoHandler.java

示例14: execute

import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	IWorkbenchPart part = HandlerUtil.getActivePart(event);
	if(part instanceof CommonNavigator){
		DeleteAction action=new DeleteAction(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart().getSite());
		action.run();
	}
	
	else if (part instanceof ELTGraphicalEditor) {
		IEditorPart editor = HandlerUtil.getActiveEditor(event);
		((ELTGraphicalEditor) editor).deleteSelection();
		((ELTGraphicalEditor) editor).hideToolTip();
	}
	return null;
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:16,代码来源:DeleteHandler.java

示例15: execute

import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	List<IFile> jobFiles = new ArrayList<>();
	List<IFile> pastedFileList = new ArrayList<>();
	IWorkbenchPart part = HandlerUtil.getActivePart(event);
	if(part instanceof CommonNavigator){
		PasteAction action = new PasteAction(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart().getSite());
		action.run();
		IWorkspaceRoot workSpaceRoot = ResourcesPlugin.getWorkspace().getRoot();
		IProject project = workSpaceRoot.getProject(JobCopyParticipant.getCopyToPath().split("/")[1]);
		IFolder jobFolder = project.getFolder(
				JobCopyParticipant.getCopyToPath().substring(JobCopyParticipant.getCopyToPath().indexOf('/', 2)));
		IFolder paramFolder = project.getFolder(PARAMETER_FOLDER_NAME);
		try {
			createCurrentJobFileList(jobFolder, jobFiles);
			pastedFileList=getPastedFileList(jobFiles);
			generateUniqueJobIdForPastedFiles(pastedFileList);
			createXmlFilesForPastedJobFiles(pastedFileList);
			List<String> copiedPropertiesList = getCopiedPropertiesList();
			createPropertiesFilesForPastedFiles(paramFolder, pastedFileList, copiedPropertiesList);
			JobCopyParticipant.cleanUpStaticResourcesAfterPasteOperation();

		} catch (CoreException  coreException) {
			logger.warn("Error while copy paste jobFiles",coreException.getMessage() );
		}
		
	}
	
	else if(part instanceof ELTGraphicalEditor){
		IEditorPart editor = HandlerUtil.getActiveEditor(event);
		((ELTGraphicalEditor)editor).pasteSelection();
	}
	
	return null;
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:36,代码来源:PasteHandler.java


注:本文中的org.eclipse.ui.handlers.HandlerUtil.getActiveEditor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。