當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。