當前位置: 首頁>>代碼示例>>Java>>正文


Java HandlerUtil.getActivePart方法代碼示例

本文整理匯總了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;
}
 
開發者ID:NineWorlds,項目名稱:xstreamer,代碼行數:27,代碼來源:ImageViewSaveAsHandler.java

示例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);
}
 
開發者ID:cchabanois,項目名稱:mesfavoris,代碼行數:19,代碼來源:AbstractBookmarkPartOperationHandler.java

示例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;
}
 
開發者ID:eclipse,項目名稱:gemoc-studio,代碼行數:9,代碼來源:FollowHandler.java

示例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;
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:16,代碼來源:DeleteHandler.java

示例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;
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:36,代碼來源:PasteHandler.java

示例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;
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:10,代碼來源:CutHandler.java

示例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;	
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:15,代碼來源:CopyHandler.java

示例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;
}
 
開發者ID:Talend,項目名稱:avro-schema-editor,代碼行數:9,代碼來源:AbstractDebugHandler.java

示例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;
}
 
開發者ID:Talend,項目名稱:avro-schema-editor,代碼行數:13,代碼來源:AbstractRegistryViewHandler.java

示例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;
}
 
開發者ID:Talend,項目名稱:avro-schema-editor,代碼行數:28,代碼來源:SwitchEditorLayoutHandler.java

示例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;
}
 
開發者ID:NineWorlds,項目名稱:xstreamer,代碼行數:14,代碼來源:ImageViewZoomInHandler.java

示例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;
}
 
開發者ID:NineWorlds,項目名稱:xstreamer,代碼行數:14,代碼來源:ImageViewFitHandler.java

示例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;
}
 
開發者ID:NineWorlds,項目名稱:xstreamer,代碼行數:14,代碼來源:ImageViewZoomOutHandler.java

示例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;
}
 
開發者ID:NineWorlds,項目名稱:xstreamer,代碼行數:11,代碼來源:ImageViewOpenHandler.java

示例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;
}
 
開發者ID:NineWorlds,項目名稱:xstreamer,代碼行數:14,代碼來源:ImageViewShowOriginalHandler.java


注:本文中的org.eclipse.ui.handlers.HandlerUtil.getActivePart方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。