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