本文整理汇总了Java中org.eclipse.ui.handlers.HandlerUtil.getActivePart方法的典型用法代码示例。如果您正苦于以下问题:Java HandlerUtil.getActivePart方法的具体用法?Java HandlerUtil.getActivePart怎么用?Java HandlerUtil.getActivePart使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.ui.handlers.HandlerUtil
的用法示例。
在下文中一共展示了HandlerUtil.getActivePart方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
ImageView imageView = (ImageView) activePart;
SWTImageCanvas imageCanvas = imageView.imageCanvas;
if (imageCanvas == null) {
return null;
}
Shell shell = HandlerUtil.getActiveShell(event);
FileDialog dialog = new FileDialog(shell, SWT.SAVE);
dialog.setFilterExtensions(new String[] { "*.png", "*.*" });
dialog.setFilterNames(new String[] { "PNG Files", "All Files" });
String fileSelected = dialog.open();
if (fileSelected != null) {
ImageLoader imageLoader = new ImageLoader();
imageLoader.data = new ImageData[] { imageCanvas.getImageData() };
System.out.println("Selected file: " + fileSelected);
imageLoader.save(fileSelected, SWT.IMAGE_PNG);
}
return null;
}
示例2: getOperationContext
import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
protected BookmarkPartOperationContext getOperationContext(ExecutionEvent event) {
IWorkbenchPart part = HandlerUtil.getActivePart(event);
ISelection selection;
if (part != null) {
// see bug #375220 or #282969 to understand why we don't use
// HandlerUtil.getCurrentSelection(event);
selection = part.getSite().getSelectionProvider().getSelection();
} else {
selection = HandlerUtil.getCurrentSelection(event);
}
if (part instanceof BookmarksView) {
part = ((BookmarksView) part).getPreviousActivePart();
if (part != null) {
selection = part.getSite().getSelectionProvider().getSelection();
}
}
return new BookmarkPartOperationContext(part, selection);
}
示例3: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final AbstractTimelineView timelineView = (AbstractTimelineView)HandlerUtil.getActivePart(event);
final Command command = event.getCommand();
final boolean oldValue = HandlerUtil.toggleCommandState(command);
timelineView.setFollow(!oldValue);
return null;
}
示例4: 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;
}
示例5: 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;
}
示例6: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchPart part = HandlerUtil.getActivePart(event);
if(part instanceof ELTGraphicalEditor){
copy.execute(event);
cut.execute(event);
}
return null;
}
示例7: 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){
CopyToClipboardAction action=new CopyToClipboardAction(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart().getSite());
action.run();
}
else if(part instanceof ELTGraphicalEditor){
IEditorPart editor = HandlerUtil.getActiveEditor(event);
((ELTGraphicalEditor)editor).copySelection();
}
return null;
}
示例8: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
if (activePart instanceof AvroSchemaEditorDebugView) {
return execute((AvroSchemaEditorDebugView)activePart, event);
}
return null;
}
示例9: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
if (activePart instanceof SchemaRegistryView) {
SchemaRegistryView registryView = (SchemaRegistryView) activePart;
AvroSchemaEditor editor = registryView.getEditor();
if (editor != null) {
return execute(registryView, editor, event);
}
}
return null;
}
示例10: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
if (activePart instanceof IWithAvroSchemaEditor) {
AvroSchemaEditor editor = ((IWithAvroSchemaEditor) activePart).getEditor();
EditorLayout editorLayout = editor.getContentPart().getEditorLayout();
EditorLayout newLayout = null;
switch (editorLayout) {
case TREE_AND_ATTRIBUTES:
newLayout = EditorLayout.TWO_TREES;
break;
case TWO_TREES:
newLayout = EditorLayout.TREE_AND_ATTRIBUTES;
break;
default:
throw new UnsupportedOperationException();
}
editor.getContentPart().setEditorLayout(newLayout);
}
return null;
}
示例11: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
ImageView imageView = (ImageView) activePart;
SWTImageCanvas imageCanvas = imageView.imageCanvas;
if (imageCanvas == null) {
return null;
}
imageCanvas.zoomIn();
return null;
}
示例12: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
ImageView imageView = (ImageView) activePart;
SWTImageCanvas imageCanvas = imageView.imageCanvas;
if (imageCanvas == null) {
return null;
}
imageCanvas.fitCanvas();
return null;
}
示例13: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
ImageView imageView = (ImageView) activePart;
SWTImageCanvas imageCanvas = imageView.imageCanvas;
if (imageCanvas == null) {
return null;
}
imageCanvas.zoomOut();
return null;
}
示例14: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
ImageView imageView = (ImageView) activePart;
SWTImageCanvas imageCanvas = imageView.imageCanvas;
imageCanvas.onFileOpen();
return null;
}
示例15: execute
import org.eclipse.ui.handlers.HandlerUtil; //导入方法依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchPart activePart = HandlerUtil.getActivePart(event);
ImageView imageView = (ImageView) activePart;
SWTImageCanvas imageCanvas = imageView.imageCanvas;
if (imageCanvas == null) {
return null;
}
imageCanvas.showOriginal();
return null;
}