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


Java IEditorInput类代码示例

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


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

示例1: init

import org.eclipse.ui.IEditorInput; //导入依赖的package包/类
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
    if (!(input instanceof ProjectEditorInput)) {
        throw new PartInitException(Messages.ProjectEditorDiffer_error_bad_input_type);
    }

    ProjectEditorInput in = (ProjectEditorInput) input;
    Exception ex = in.getError();
    if (ex != null) {
        throw new PartInitException(in.getError().getLocalizedMessage(), ex);
    }

    setInput(input);
    setSite(site);
    setPartName(in.getName());

    proj = new PgDbProject(in.getProject());
    sp = new ProjectEditorSelectionProvider(proj.getProject());

    // message box
    if(!site.getPage().getPerspective().getId().equals(PERSPECTIVE.MAIN)){
        askPerspectiveChange(site);
    }
    getSite().setSelectionProvider(sp);
}
 
开发者ID:pgcodekeeper,项目名称:pgcodekeeper,代码行数:26,代码来源:ProjectEditorDiffer.java

示例2: getActiveEditorFile

import org.eclipse.ui.IEditorInput; //导入依赖的package包/类
/**
 * Returns the opened file of the currently active editor.
 *
 * Returns null if no editor is open.
 */
private static IFile getActiveEditorFile() {
	IEditorPart activeEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
			.getActiveEditor();

	if (null == activeEditor) {
		return null;
	}

	IEditorInput input = activeEditor.getEditorInput();

	if (input instanceof FileEditorInput) {
		return ((FileEditorInput) input).getFile();
	} else {
		return null;
	}

}
 
开发者ID:eclipse,项目名称:n4js,代码行数:23,代码来源:CreateNewN4JSElementInModuleHandler.java

示例3: findSelection

import org.eclipse.ui.IEditorInput; //导入依赖的package包/类
@Override
public IStructuredSelection findSelection(final IEditorInput input) {
	final IStructuredSelection selection = super.findSelection(input);
	if (null == selection || selection.isEmpty() && input instanceof XtextReadonlyEditorInput) {
		try {
			final IStorage storage = ((XtextReadonlyEditorInput) input).getStorage();
			if (storage instanceof URIBasedStorage) {
				final URI uri = ((URIBasedStorage) storage).getURI();
				if (uri.isFile()) {
					final File file = new File(uri.toFileString());
					if (file.exists() && file.isFile()) {
						final Node node = getResourceNode(file);
						if (null != node) {
							return new StructuredSelection(node);
						}
					}
				}
			}
		} catch (final CoreException e) {
			LOGGER.error("Error while extracting storage from read-only Xtext editor input.", e);
			return EMPTY;
		}
	}
	return selection;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:26,代码来源:N4JSResourceLinkHelper.java

示例4: getShowInContext

import org.eclipse.ui.IEditorInput; //导入依赖的package包/类
/**
 * Provides input so that the Project Explorer can locate the editor's input in its tree.
 */
@Override
public ShowInContext getShowInContext() {
	IEditorInput editorInput = getEditorInput();
	if (editorInput instanceof FileEditorInput) {
		FileEditorInput fei = (FileEditorInput) getEditorInput();
		return new ShowInContext(fei.getFile(), null);
	} else if (editorInput instanceof XtextReadonlyEditorInput) {
		XtextReadonlyEditorInput readOnlyEditorInput = (XtextReadonlyEditorInput) editorInput;
		IStorage storage;
		try {
			storage = readOnlyEditorInput.getStorage();
			return new ShowInContext(storage.getFullPath(), null);
		} catch (CoreException e) {
			// Do nothing
		}
	}
	return new ShowInContext(null, null);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:22,代码来源:N4MFEditor.java

示例5: getEditorInput

import org.eclipse.ui.IEditorInput; //导入依赖的package包/类
/**
 * Gets the default {@link IEditorInput} for the given {@link Object}.
 * 
 * @param element
 *            the {@link Object}
 * @return the default {@link IEditorInput} for the given {@link Object} if any, <code>null</code>
 *         otherwise
 */
public static IEditorInput getEditorInput(Object element) {
	final IEditorInput res;
	if (element instanceof EObject) {
		Resource resource = ((EObject)element).eResource();
		if (resource != null) {
			res = getEditorInputFromURI(resource.getURI());
		} else {
			res = null;
		}
	} else if (element instanceof DSLBreakpoint) {
		res = getEditorInputFromURI(((DSLBreakpoint)element).getURI().trimFragment());
	} else {
		res = null;
	}
	return res;
}
 
开发者ID:eclipse,项目名称:gemoc-studio-modeldebugging,代码行数:25,代码来源:EMFEditorUtils.java

示例6: closeConnectorEditors

import org.eclipse.ui.IEditorInput; //导入依赖的package包/类
public void closeConnectorEditors() {
	IWorkbenchPage activePage = PlatformUI
									.getWorkbench()
									.getActiveWorkbenchWindow()
									.getActivePage();
	if (activePage != null) {
		IEditorReference[] editorRefs = activePage.getEditorReferences();
		for (int i=0;i<editorRefs.length;i++) {
			IEditorReference editorRef = (IEditorReference)editorRefs[i];
			try {
				IEditorInput editorInput = editorRef.getEditorInput();
				if ((editorInput != null) && (editorInput instanceof ConnectorEditorInput)) {
					if (((ConnectorEditorInput)editorInput).is(getObject()))
						activePage.closeEditor(editorRef.getEditor(false),true);
				}
			}
			catch(PartInitException e) {
				ConvertigoPlugin.logException(e, "Error while retrieving the connector editor '" + editorRef.getName() + "'");
			}
		}
	}
}
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:23,代码来源:ProjectTreeObject.java

示例7: init

import org.eclipse.ui.IEditorInput; //导入依赖的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

示例8: runWithObject

import org.eclipse.ui.IEditorInput; //导入依赖的package包/类
@Override
public void runWithObject(Object object) throws Exception {

    String editorId = getAssociatedEditorId(object);
    if (editorId == null) {
        return;
    }

    IEditorInput input = getAssociatedEditorInput(editorId, object);
    if (input == null) {
        return;
    }

    String pageId = getAssociatedEditorPageId(editorId, object);

    try {
        open(object, input, editorId, pageId);
    }
    catch (Exception e) {
        throw new Exception(getOpenErrorMessage(object, input, editorId, e), e);
    }
}
 
开发者ID:baloise,项目名称:eZooKeeper,代码行数:23,代码来源:BaseOpenAction.java

示例9: canRun

import org.eclipse.ui.IEditorInput; //导入依赖的package包/类
public boolean canRun() {

        InputType inputType = getInputType();

        if (inputType.isStructuredSelection()) {
            IStructuredSelection structuredSelection = getCurrentStructuredSelection();
            if (canRunWithStructuredSelection(structuredSelection)) {
                return true;
            }
        }
        else if (inputType.isEditorInput()) {

            IEditorPart editor = getActiveEditor();
            IEditorInput editorInput = (editor != null) ? editor.getEditorInput() : null;

            if (canRunWithEditorInput(editorInput)) {
                return true;
            }
        }
        else if (canRunWithNothing()) {
            return true;
        }

        return false;

    }
 
开发者ID:baloise,项目名称:eZooKeeper,代码行数:27,代码来源:BaseAction.java

示例10: closeComponentFileEditor

import org.eclipse.ui.IEditorInput; //导入依赖的package包/类
private void closeComponentFileEditor(final IFile file) {
	try {
		IWorkbenchPage activePage = PlatformUI
				.getWorkbench()
				.getActiveWorkbenchWindow()
				.getActivePage();
		
		for (IEditorReference editorReference : activePage.getEditorReferences()) {
			IEditorInput editorInput = editorReference.getEditorInput();
			if (editorInput instanceof ComponentFileEditorInput) {
				ComponentFileEditorInput cfei = (ComponentFileEditorInput) editorInput;
				if (cfei.getFile().equals(file)) {
					activePage.closeEditor(editorReference.getEditor(false), true);
					return;
				}
			}
		}
	} catch (Exception e) {
		
	}
}
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:22,代码来源:MobileUIComponentTreeObject.java

示例11: getConnectorEditor

import org.eclipse.ui.IEditorInput; //导入依赖的package包/类
private IEditorPart getConnectorEditor(IWorkbenchPage activePage, Connector connector) {
	IEditorPart editorPart = null;
	if (activePage != null) {
		if (connector != null) {
			IEditorReference[] editorRefs = activePage.getEditorReferences();
			for (int i=0;i<editorRefs.length;i++) {
				IEditorReference editorRef = (IEditorReference)editorRefs[i];
				try {
					IEditorInput editorInput = editorRef.getEditorInput();
					if ((editorInput != null) && (editorInput instanceof ConnectorEditorInput)) {
						if (((ConnectorEditorInput)editorInput).is(connector)) {
							editorPart = editorRef.getEditor(false);
							break;
						}
					}
				}
				catch(PartInitException e) {
					//ConvertigoPlugin.logException(e, "Error while retrieving the connector editor '" + editorRef.getName() + "'");
				}
			}
		}
	}
	return editorPart;
}
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:25,代码来源:ConnectorTreeObject.java

示例12: handleOpen

import org.eclipse.ui.IEditorInput; //导入依赖的package包/类
public static void handleOpen ( final IWorkbenchPage page, final ISelection selection )
{
    final MultiStatus status = new MultiStatus ( Activator.PLUGIN_ID, 0, "Open editor", null );

    final IEditorInput[] inputs = EditorHelper.createInput ( selection );

    for ( final IEditorInput input : inputs )
    {
        try
        {
            if ( input instanceof ConfigurationEditorInput )
            {
                page.openEditor ( input, MultiConfigurationEditor.EDITOR_ID, true );
            }
            else if ( input instanceof FactoryEditorInput )
            {
                page.openEditor ( input, FactoryEditor.EDITOR_ID, true );
            }
        }
        catch ( final PartInitException e )
        {
            status.add ( e.getStatus () );
        }
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:26,代码来源:EditorHelper.java

示例13: getJscriptTransactionEditor

import org.eclipse.ui.IEditorInput; //导入依赖的package包/类
/**
 * Gets the jscript editor associated with given transaction.
 * !!MUST BE CALLED IN A UI-THREAD!!
 * @return IEditorPart : the found jscript editor or null
 */
public IEditorPart getJscriptTransactionEditor(Transaction transaction) {
	IEditorPart editorPart = null;
	IWorkbenchPage activePage = getActivePage();
	if (activePage != null) {
		if (transaction != null) {
			IEditorReference[] editorRefs = activePage.getEditorReferences();
			for (int i=0;i<editorRefs.length;i++) {
				IEditorReference editorRef = (IEditorReference)editorRefs[i];
				try {
					IEditorInput editorInput = editorRef.getEditorInput();
					if ((editorInput != null) && (editorInput instanceof JscriptTransactionEditorInput)) {
						if (((JscriptTransactionEditorInput)editorInput).transaction.equals(transaction)) {
							editorPart = editorRef.getEditor(false);
							break;
						}
					}
				}
				catch(PartInitException e) {
					//ConvertigoPlugin.logException(e, "Error while retrieving the jscript transaction editor '" + editorRef.getName() + "'");
				}
			}
		}
	}
	return editorPart;
}
 
开发者ID:convertigo,项目名称:convertigo-eclipse,代码行数:31,代码来源:ConvertigoPlugin.java

示例14: createContainerControls

import org.eclipse.ui.IEditorInput; //导入依赖的package包/类
@Override
protected void createContainerControls(Composite parent, int nColumns) {

	super.createContainerControls(parent, nColumns);
	Text text = (Text) parent.getChildren()[1];
	text.setEditable(false);
	IEditorInput editorInput = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage()
			.getActiveEditor().getEditorInput();
	if (editorInput instanceof IFileEditorInput) {
		IFileEditorInput fileEditorInput = (IFileEditorInput) editorInput;
		IProject project = fileEditorInput.getFile().getProject();
		if (project != null) {
			IFolder srcFolder = project.getFolder("src/main/java");
			if (srcFolder != null && srcFolder.exists()) {
				text.setText(project.getName() + "/" + srcFolder.getProjectRelativePath().toString());
			}
		}
		Button button = (Button) parent.getChildren()[2];
		button.setEnabled(false);
	}
}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:22,代码来源:CustomizeNewClassWizardPage.java

示例15: enableRunningGraphResource

import org.eclipse.ui.IEditorInput; //导入依赖的package包/类
private void enableRunningGraphResource(IEditorInput editorInput,
		String partName) {
	IFileEditorInput input = (IFileEditorInput)editorInput ;
	IFile fileJob = input.getFile();
	IPath xmlFileIPath =new Path(input.getFile().getFullPath().toOSString().replace(".job", ".xml"));
	IFile fileXml = ResourcesPlugin.getWorkspace().getRoot().getFile(xmlFileIPath);
	ResourceAttributes attributes = new ResourceAttributes();
	attributes.setReadOnly(false);
	attributes.setExecutable(true);

	try {
		if(fileJob.exists()){
			
			fileJob.setResourceAttributes(attributes);
		}
		if(fileXml.exists()){
			
			fileXml.setResourceAttributes(attributes);
		}
	} catch (CoreException e) {
		logger.error("Unable to enable locked job resources",e);
	}

}
 
开发者ID:capitalone,项目名称:Hydrograph,代码行数:25,代码来源:ELTGraphicalEditor.java


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