當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。