本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}