本文整理匯總了Java中org.eclipse.ui.IFileEditorInput類的典型用法代碼示例。如果您正苦於以下問題:Java IFileEditorInput類的具體用法?Java IFileEditorInput怎麽用?Java IFileEditorInput使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
IFileEditorInput類屬於org.eclipse.ui包,在下文中一共展示了IFileEditorInput類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getEditorID
import org.eclipse.ui.IFileEditorInput; //導入依賴的package包/類
/**
* Gets the default editor ID for the given {@link IEditorInput} and element.
*
* @param input
* the {@link IEditorInput}
* @param element
* the element
* @return the default editor ID for the given {@link IEditorInput} and element if any, <code>null</code>
* otherwise
*/
public static String getEditorID(IEditorInput input, Object element) {
final String res;
if (input instanceof URIEditorInput) {
res = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(
((URIEditorInput)input).getURI().lastSegment()).getId();
} else if (input instanceof IFileEditorInput) {
IEditorDescriptor defaultEditor = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(
((IFileEditorInput)input).getFile().getName());
if (defaultEditor != null) {
res = defaultEditor.getId();
} else {
res = "org.eclipse.emf.ecore.presentation.ReflectiveEditorID";
}
} else {
res = null;
}
return res;
}
示例2: init
import org.eclipse.ui.IFileEditorInput; //導入依賴的package包/類
@Override
public void init ( final IEditorSite site, final IEditorInput input ) throws PartInitException
{
setSite ( site );
setInput ( input );
final IFileEditorInput fileInput = AdapterHelper.adapt ( input, IFileEditorInput.class );
if ( fileInput != null )
{
this.loader = new FileLoader ( fileInput );
setContentDescription ( fileInput.getName () );
setPartName ( fileInput.getName () );
}
if ( this.loader == null )
{
throw new PartInitException ( "Invalid editor input. Unable to load data" );
}
}
示例3: setInputWithNotify
import org.eclipse.ui.IFileEditorInput; //導入依賴的package包/類
@Override
protected void setInputWithNotify ( final IEditorInput input )
{
super.setInputWithNotify ( input );
this.fileInput = (IFileEditorInput)input;
final IFile file = this.fileInput.getFile ();
try
{
final URI uri = URI.createPlatformResourceURI ( file.getFullPath ().toString (), true );
// we need a real platform URI since otherwise the StaticSymbolLoader cannot resolve URIs
final Resource resource = getEditingDomain ().getResourceSet ().createResource ( uri );
resource.load ( null );
}
catch ( final IOException e )
{
throw new RuntimeException ( "Failed to load input", e );
}
}
示例4: createJavaProjectThroughActiveEditor
import org.eclipse.ui.IFileEditorInput; //導入依賴的package包/類
private IJavaProject createJavaProjectThroughActiveEditor() {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
if(page.getActiveEditor().getEditorInput() instanceof IFileEditorInput)
{
IFileEditorInput input = (IFileEditorInput) page.getActiveEditor().getEditorInput();
IFile file = input.getFile();
IProject activeProject = file.getProject();
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(activeProject.getName());
return JavaCore.create(project);
}
else if(page.getActiveEditor().getEditorInput() instanceof IClassFileEditorInput)
{
IClassFileEditorInput classFileEditorInput=(InternalClassFileEditorInput)page.getActiveEditor().getEditorInput() ;
IClassFile classFile=classFileEditorInput.getClassFile();
return classFile.getJavaProject();
}
return null;
}
示例5: createContainerControls
import org.eclipse.ui.IFileEditorInput; //導入依賴的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);
}
}
示例6: loadProperties
import org.eclipse.ui.IFileEditorInput; //導入依賴的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);
}
}
}
示例7: getParameterFileIPath
import org.eclipse.ui.IFileEditorInput; //導入依賴的package包/類
private IPath getParameterFileIPath(){
if(getEditorInput() instanceof IFileEditorInput){
IFileEditorInput input = (IFileEditorInput)getEditorInput() ;
IFile file = input.getFile();
IProject activeProject = file.getProject();
String activeProjectName = activeProject.getName();
IPath parameterFileIPath =new Path("/"+activeProjectName+"/param/"+ getPartName().replace(".job", ".properties"));
activeProjectName.concat("_").concat(getPartName().replace(".job", "_"));
return parameterFileIPath;
}else{
return null;
}
}
示例8: disableRunningGraphResource
import org.eclipse.ui.IFileEditorInput; //導入依賴的package包/類
private void disableRunningGraphResource(IEditorInput editorInput,String partName){
if(editorInput instanceof IFileEditorInput){
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(true);
attributes.setExecutable(true);
try {
fileJob.setResourceAttributes(attributes);
fileXml.setResourceAttributes(attributes);
} catch (CoreException e) {
logger.error("Unable to disable running job resources", e);
}
}
}
示例9: enableRunningGraphResource
import org.eclipse.ui.IFileEditorInput; //導入依賴的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);
}
}
示例10: updateMainGraphOnSavingSubjob
import org.eclipse.ui.IFileEditorInput; //導入依賴的package包/類
private void updateMainGraphOnSavingSubjob() {
hydrograph.ui.graph.model.Component subjobComponent=null;
if (container != null && container.getLinkedMainGraphPath()!=null) {
for (int i = 0; i < container.getUIComponentList().size(); i++) {
subjobComponent = ((ComponentEditPart)(container.getSubjobComponentEditPart())).getCastedModel();
break;
}
if(subjobComponent!=null){
String path=getEditorInput().getToolTipText();
if (getEditorInput() instanceof IFileEditorInput)
path = ((IFileEditorInput) getEditorInput()).getFile().getFullPath().toString();
IPath subJobFilePath=new Path(path);
SubJobUtility subJobUtility=new SubJobUtility();
SubjobUtility.INSTANCE.showOrHideErrorSymbolOnComponent(container,subjobComponent);
if (subjobComponent.getComponentEditPart() != null) {
((ComponentEditPart) subjobComponent.getComponentEditPart()).updateComponentStatus();
}
subJobUtility.updateContainerAndSubjob(container, subjobComponent, subJobFilePath);
((ComponentEditPart)container.getSubjobComponentEditPart()).changePortSettings();
}
}
}
示例11: removeTempSubJobTrackFiles
import org.eclipse.ui.IFileEditorInput; //導入依賴的package包/類
/**
* Remove temp tracking subjob file after tool close, rerun and modification.
*/
public void removeTempSubJobTrackFiles() {
if(deleteOnDispose){
try {
IFile file=((IFileEditorInput)getEditorInput()).getFile();
if(file.exists()){
ResourcesPlugin.getWorkspace().getRoot().getFile(file.getFullPath()).delete(true, null);
ResourcesPlugin.getWorkspace().getRoot().getFile(file.getFullPath().removeFileExtension().addFileExtension(Constants.XML_EXTENSION_FOR_IPATH)).delete(true, null);
}
} catch (Exception e) {
logger.error("Failed to remove temp subjob tracking files: "+e);
}
}
}
示例12: getOpenEditorOfMarker
import org.eclipse.ui.IFileEditorInput; //導入依賴的package包/類
/**
* Note: it compares marker's resource file name and open editors' file name.
*
* @param marker
* @return if marker's editor is open, return editor, else return null
*/
public static IEditorPart getOpenEditorOfMarker(final IMarker marker) {
final IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
for (final IWorkbenchWindow iWorkbenchWindow : windows) {
final IWorkbenchPage[] pages = iWorkbenchWindow.getPages();
for (final IWorkbenchPage iWorkbenchPage : pages) {
final IEditorReference[] editors = iWorkbenchPage.getEditorReferences();
for (final IEditorReference iEditorReference : editors) {
try {
if (iEditorReference instanceof IFileEditorInput) {
final IFileEditorInput input = (IFileEditorInput) iEditorReference.getEditorInput();
final IFile file = input.getFile();
// TODO Caused by: java.lang.NullPointerException when delete marker on ecore editor.
if (file.getFullPath().equals(marker.getResource().getFullPath())) {
return iEditorReference.getEditor(false);
}
}
} catch (final PartInitException e) {
e.printStackTrace();
}
}
}
}
return null;
}
示例13: AstManager
import org.eclipse.ui.IFileEditorInput; //導入依賴的package包/類
/**
* Constructor. Loads the AST and sets up the StyledText to automatically
* reload after certain events.
* @param editor IEditorPart which owns the following StyledText.
* @param styledText StyledText to which this AST pertains.
*/
public AstManager(IEditorPart editor, StyledText styledText) {
try {
editorPath = ((IFileEditorInput) editor.getEditorInput()).getFile()
.getFullPath().toFile().getCanonicalPath();
} catch (IOException e) {
// ignore IOErrors while constructing path
editorPath = "?";
}
this.editor = editor;
this.styledText = styledText;
//This is the only why I know to get the ProjectionViewer. Perhaps there is better way. ~Ben
ITextOperationTarget t = (ITextOperationTarget) editor.getAdapter(ITextOperationTarget.class);
if(t instanceof ProjectionViewer) projectionViewer = (ProjectionViewer)t;
hookupAutoReload();
reload();
}
示例14: needsToSaveDirtyEditors
import org.eclipse.ui.IFileEditorInput; //導入依賴的package包/類
/**
* Most SVN workspace actions modify the workspace and thus should
* save dirty editors.
* @see org.tigris.subversion.subclipse.ui.actions.SVNAction#needsToSaveDirtyEditors()
*/
protected boolean needsToSaveDirtyEditors() {
IResource[] selectedResources = getSelectedResources();
if (selectedResources != null && selectedResources.length > 0) {
IEditorReference[] editorReferences = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
for (IEditorReference editorReference : editorReferences) {
if (editorReference.isDirty()) {
try {
IEditorInput editorInput = editorReference.getEditorInput();
if (editorInput instanceof IFileEditorInput) {
IFile file = ((IFileEditorInput)editorInput).getFile();
if (needsToSave(file, selectedResources)) {
return true;
}
}
} catch (PartInitException e) {}
}
}
}
return false;
}
示例15: registerFullOutline
import org.eclipse.ui.IFileEditorInput; //導入依賴的package包/類
/**
* register the full outline.
* @param view the view.
*/
public void registerFullOutline(TexOutlineTreeView view) {
boolean projectChange = false;
if (view == null || view.getEditor() == null) {
projectChange = true;
}
else if (view.getEditor().getEditorInput() instanceof IFileEditorInput) {
IFileEditorInput oldInput = (IFileEditorInput) view.getEditor().getEditorInput();
IProject newProject = getProject();
// Check whether the project changes
if (!oldInput.getFile().getProject().equals(newProject))
projectChange = true;
} else
projectChange = true;
this.fullOutline = view;
this.fullOutline.setEditor(this);
if (projectChange) {
//If the project changes we have to update the fulloutline
this.fullOutline.projectChanged();
this.documentModel.updateNow();
}
}