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


Java IWorkbenchPage类代码示例

本文整理汇总了Java中org.eclipse.ui.IWorkbenchPage的典型用法代码示例。如果您正苦于以下问题:Java IWorkbenchPage类的具体用法?Java IWorkbenchPage怎么用?Java IWorkbenchPage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: execute

import org.eclipse.ui.IWorkbenchPage; //导入依赖的package包/类
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
	IWorkbench workbench = PlatformUI.getWorkbench();
	if (workbench==null){
		return null;
	}
	IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow();
	if (activeWorkbenchWindow==null){
		return null;
	}
	IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
	if (activePage==null){
		return null;
	}
	IEditorPart editor = activePage.getActiveEditor();
	
	if (editor instanceof BashEditor){
		executeOnBashEditor((BashEditor) editor);
	}
	return null;
}
 
开发者ID:de-jcup,项目名称:eclipse-bash-editor,代码行数:22,代码来源:AbstractBashEditorHandler.java

示例2: openXtextEditor

import org.eclipse.ui.IWorkbenchPage; //导入依赖的package包/类
/**
 * Obtains or opens {@link XtextEditor} for provided {@link Resource} and editor id. Upon activation or opening of
 * the editor waits a moment for editor to become active.
 *
 * @param uri
 *            URI to be opened
 * @param editorExtensionID
 *            {String} defining the id of the editor extension to use
 * @return {@link Optional} instance of {@link XtextEditor} for given {@link Resource}.
 */
public static final Optional<XtextEditor> openXtextEditor(URI uri, String editorExtensionID) {

	String platformStr = uri.toString().replace("platform:/resource/", "");
	IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(platformStr));

	Optional<IWorkbenchPage> page = getActivePage();
	Optional<IEditorPart> internalFileEditor = getFileEditor(file, page.get(), editorExtensionID);

	if ((page.isPresent() && internalFileEditor.isPresent()) == false) {
		logger.warn("Cannot obtain editor components for " + file.getRawLocationURI());
		return Optional.empty();
	}

	IEditorPart ieditorPart = internalFileEditor.get();
	if (ieditorPart instanceof XtextEditor == false) {
		logger.warn("cannot obtain Xtext editor for file " + file.getRawLocation());
		return Optional.empty();
	}

	waitForEditorToBeActive(ieditorPart, page.get());

	return Optional.ofNullable((XtextEditor) ieditorPart);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:34,代码来源:EditorsUtil.java

示例3: resourceChanged

import org.eclipse.ui.IWorkbenchPage; //导入依赖的package包/类
@Override
public void resourceChanged(IResourceChangeEvent event) {
	if (event.getType() == IResourceChangeEvent.PRE_CLOSE) {
		Display.getDefault().asyncExec(new Runnable() {
			public void run() {
				IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages();
				for (int i = 0; i < pages.length; i++) {
					if (((FileEditorInput) getEditorInput()).getFile().getProject().equals(event.getResource())) {
						IEditorPart editorPart = pages[i].findEditor(getEditorInput());
						pages[i].closeEditor(editorPart, true);
					}
				}
			}
		});
	}
}
 
开发者ID:dstl,项目名称:Open_Source_ECOA_Toolset_AS5,代码行数:17,代码来源:IntDeploymentEditor.java

示例4: updateJobTrackingStatus

import org.eclipse.ui.IWorkbenchPage; //导入依赖的package包/类
/**
 * 
 * Called by web socket server, message contain execution tracking status that updated on job canvas.
 *
 * @param message the message
 * @param session the session
 */
@OnMessage
public void updateJobTrackingStatus(String message, Session session) { 

	final String status = message; 
	Display.getDefault().asyncExec(new Runnable() {
		public void run() {
			Gson gson = new Gson();
			ExecutionStatus executionStatus=gson.fromJson(status, ExecutionStatus.class);
			IWorkbenchPage page = PlatformUI.getWorkbench().getWorkbenchWindows()[0].getActivePage();
			IEditorReference[] refs = page.getEditorReferences();
			for (IEditorReference ref : refs){
				IEditorPart editor = ref.getEditor(false);
				if(editor instanceof ELTGraphicalEditor){
					ELTGraphicalEditor editPart=(ELTGraphicalEditor)editor;
					if(editPart.getJobId().equals(executionStatus.getJobId()) || (((editPart.getContainer()!=null) && 
							(editPart.getContainer().getUniqueJobId().equals(executionStatus.getJobId()))) && editPart.getContainer().isOpenedForTracking() )){
							TrackingStatusUpdateUtils.INSTANCE.updateEditorWithCompStatus(executionStatus, (ELTGraphicalEditor)editor,false);
					}
				}
			}
		}
	});
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:31,代码来源:HydrographUiClientSocket.java

示例5: tryValidateManifestInEditor

import org.eclipse.ui.IWorkbenchPage; //导入依赖的package包/类
private void tryValidateManifestInEditor(final IResourceDelta delta) {
	if (isWorkbenchRunning()) {
		Display.getDefault().asyncExec(() -> {
			final IWorkbenchWindow window = getWorkbench().getActiveWorkbenchWindow();
			if (null != window) {
				final IWorkbenchPage page = window.getActivePage();
				for (final IEditorReference editorRef : page.getEditorReferences()) {
					if (isEditorForResource(editorRef, delta.getResource())) {
						final IWorkbenchPart part = editorRef.getPart(true);
						if (part instanceof XtextEditor) {
							editorCallback.afterSave((XtextEditor) part);
							return;
						}
					}
				}
			}
		});
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:20,代码来源:N4JSAllContainersState.java

示例6: notifyDbChanged

import org.eclipse.ui.IWorkbenchPage; //导入依赖的package包/类
public static void notifyDbChanged(DbInfo dbinfo) {
    String action = Activator.getDefault().getPreferenceStore().getString(PG_EDIT_PREF.EDITOR_UPDATE_ACTION);
    if (action.equals(PG_EDIT_PREF.NO_ACTION)) {
        return;
    }
    for (IWorkbenchWindow wnd : PlatformUI.getWorkbench().getWorkbenchWindows()) {
        for (IWorkbenchPage page : wnd.getPages()) {
            for (IEditorReference ref : page.getEditorReferences()) {
                IEditorPart ed = ref.getEditor(false);
                if (ed instanceof ProjectEditorDiffer) {
                    notifyDbChanged(dbinfo, (ProjectEditorDiffer) ed, action.equals(PG_EDIT_PREF.UPDATE));
                }
            }
        }
    }
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:17,代码来源:ProjectEditorDiffer.java

示例7: getEditors

import org.eclipse.ui.IWorkbenchPage; //导入依赖的package包/类
/**
 * Obtains all editors that are currently opened.
 * @return the collection of the opened editors
 */
public static List<IEditorPart> getEditors() {
    List<IEditorPart> editors = new ArrayList<IEditorPart>();
    IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
    
    for (IWorkbenchWindow window : windows) {
        IWorkbenchPage[] pages = window.getPages();
        
        for (IWorkbenchPage page : pages) {
            IEditorReference[] refs = page.getEditorReferences();
            
            for (IEditorReference ref : refs) {
                IEditorPart part = ref.getEditor(false);
                if (part != null) {
                    editors.add(part);
                }
            }
        }
    }
    return editors;
}
 
开发者ID:liaoziyang,项目名称:ContentAssist,代码行数:25,代码来源:EditorUtilities.java

示例8: resourceChanged

import org.eclipse.ui.IWorkbenchPage; //导入依赖的package包/类
/**
 * Closes all project files on project close.
 */
public void resourceChanged(final IResourceChangeEvent event) {
	if (event.getType() == IResourceChangeEvent.PRE_CLOSE) {
		Display.getDefault().asyncExec(new Runnable() {
			public void run() {
				IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages();
				for (int i = 0; i < pages.length; i++) {
					if (((FileEditorInput) editor.getEditorInput()).getFile().getProject().equals(event.getResource())) {
						IEditorPart editorPart = pages[i].findEditor(editor.getEditorInput());
						pages[i].closeEditor(editorPart, true);
					}
				}
			}
		});
	}
}
 
开发者ID:dstl,项目名称:Open_Source_ECOA_Toolset_AS5,代码行数:19,代码来源:TypesEditor.java

示例9: init

import org.eclipse.ui.IWorkbenchPage; //导入依赖的package包/类
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
	super.init(site, input);
	if (site == null) {
		return;
	}
	IWorkbenchPage page = site.getPage();
	if (page == null) {
		return;
	}

	// workaround to show action set for block mode etc.
	// https://www.eclipse.org/forums/index.php/t/366630/
	page.showActionSet("org.eclipse.ui.edit.text.actionSet.presentation");

}
 
开发者ID:de-jcup,项目名称:eclipse-batch-editor,代码行数:17,代码来源:BatchEditor.java

示例10: resourceChanged

import org.eclipse.ui.IWorkbenchPage; //导入依赖的package包/类
/**
 * Closes all project files on project close.
 */
public void resourceChanged(final IResourceChangeEvent event) {
	if (event.getType() == IResourceChangeEvent.PRE_CLOSE) {
		Display.getDefault().asyncExec(new Runnable() {
			public void run() {
				IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages();
				for (int i = 0; i < pages.length; i++) {
					if (((FileEditorInput) editor.getEditorInput()).getFile().getProject()
							.equals(event.getResource())) {
						IEditorPart editorPart = pages[i].findEditor(editor.getEditorInput());
						pages[i].closeEditor(editorPart, true);
					}
				}
			}
		});
	}
}
 
开发者ID:bsteker,项目名称:bdf2,代码行数:20,代码来源:PropEditor.java

示例11: getEditor

import org.eclipse.ui.IWorkbenchPage; //导入依赖的package包/类
protected AvroSchemaEditor getEditor() {
	
	IWorkbench workbench = PlatformUI.getWorkbench();
       IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();

       if (window != null) {
           IWorkbenchPage workbenchPage = window.getActivePage();
           if (workbenchPage != null) {
           	IWorkbenchPart activePart = workbenchPage.getActivePart();                
               if (activePart instanceof IWithAvroSchemaEditor) {
               	return ((IWithAvroSchemaEditor) activePart).getEditor();
               }
           }
       }
       
       return null;
}
 
开发者ID:Talend,项目名称:avro-schema-editor,代码行数:18,代码来源:SchemaEditorPropertyTester.java

示例12: editFile

import org.eclipse.ui.IWorkbenchPage; //导入依赖的package包/类
public static IEditorPart editFile(File file, boolean preferIdeEditor) throws IOException, PartInitException {

        if (file == null || !file.exists() || !file.isFile() || !file.canRead()) {
            throw new IOException("Invalid file: '" + file + "'");
        }

        IWorkbench workBench = PlatformUI.getWorkbench();
        IWorkbenchPage page = workBench.getActiveWorkbenchWindow().getActivePage();
        IPath location = Path.fromOSString(file.getAbsolutePath());

        IFileStore fileStore = EFS.getLocalFileSystem().getStore(location);
        FileStoreEditorInput fileStoreEditorInput = new FileStoreEditorInput(fileStore);

        String editorId = IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID;
        if (preferIdeEditor) {
            IEditorDescriptor editorDescriptor = workBench.getEditorRegistry().getDefaultEditor(file.getName());
            if (editorDescriptor != null) {
                editorId = editorDescriptor.getId();
            }
        }

        return page.openEditor(fileStoreEditorInput, editorId);
    }
 
开发者ID:baloise,项目名称:eZooKeeper,代码行数:24,代码来源:FileEditor.java

示例13: openView

import org.eclipse.ui.IWorkbenchPage; //导入依赖的package包/类
/**
 * Opens the view with the given identifier.
 * 
 * @param viewId
 *            The view to open; must not be <code>null</code>
 * @throws PartInitException
 *             If the part could not be initialized.
 */
private final void openView ( final String viewId, final String secondaryId, final IWorkbenchWindow activeWorkbenchWindow ) throws PartInitException
{

    final IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage ();
    if ( activePage == null )
    {
        return;
    }
    if ( secondaryId != null )
    {
        activePage.showView ( viewId, secondaryId, IWorkbenchPage.VIEW_ACTIVATE );
    }
    else
    {
        activePage.showView ( viewId );
    }

}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:27,代码来源:ShowViewHandler.java

示例14: execute

import org.eclipse.ui.IWorkbenchPage; //导入依赖的package包/类
public Object execute ( final ExecutionEvent event ) throws ExecutionException
{
    for ( final Item item : getItems () )
    {
        GeneratorView view;
        try
        {
            view = (GeneratorView)getActivePage ().showView ( GeneratorView.VIEW_ID, asSecondardId ( item ), IWorkbenchPage.VIEW_ACTIVATE );
        }
        catch ( final PartInitException e )
        {
            throw new ExecutionException ( "Failed to open view", e );
        }
        view.setDataItem ( item );
    }

    return null;
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:19,代码来源:OpenSignalGenerator.java

示例15: loadProperties

import org.eclipse.ui.IWorkbenchPage; //导入依赖的package包/类
/**
 * 
 * loading the properties files
 */
public void loadProperties() {
	IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
	if (page.getActiveEditor().getEditorInput() instanceof IFileEditorInput) {
		IFileEditorInput input = (IFileEditorInput) page.getActiveEditor().getEditorInput();
		List<File> paramNameList = null;
		IFile file = input.getFile();
		IProject activeProject = file.getProject();
		final File globalparamFilesPath = new File(activeProject.getLocation().toString() + "/" + "globalparam");
		final File localParamFilePath = new File(activeProject.getLocation().toString() + "/" + Constants.PARAM_FOLDER);
		File[] files = (File[]) ArrayUtils.addAll(listFilesForFolder(globalparamFilesPath),
				getJobsPropertyFile(localParamFilePath,file));
		if (files != null) {
			paramNameList = Arrays.asList(files);
			getParamMap(paramNameList, null);
		}
	}
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:22,代码来源:Utils.java


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