Java 类org.eclipse.ui.IFileEditorInput 实例源码
项目:gemoc-studio-modeldebugging
文件:EMFEditorUtils.java
/**
* 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;
}
项目:neoscada
文件:HDSEditor.java
@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" );
}
}
项目:neoscada
文件:AbstractModelEditor.java
@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 );
}
}
项目:Hydrograph
文件:ValidatorUtility.java
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;
}
项目:Hydrograph
文件:CustomizeNewClassWizardPage.java
@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);
}
}
项目:Hydrograph
文件:Utils.java
/**
*
* 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);
}
}
}
项目:Hydrograph
文件:ELTGraphicalEditor.java
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;
}
}
项目:Hydrograph
文件:ELTGraphicalEditor.java
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);
}
}
}
项目:Hydrograph
文件:ELTGraphicalEditor.java
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);
}
}
项目:Hydrograph
文件:ELTGraphicalEditor.java
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();
}
}
}
项目:Hydrograph
文件:ELTGraphicalEditor.java
/**
* 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);
}
}
}
项目:Tarski
文件:MarkerFactory.java
/**
* 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;
}
项目:iTrace-Archive
文件:AstManager.java
/**
* 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();
}
项目:subclipse
文件:WorkspaceAction.java
/**
* 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;
}
项目:texlipse
文件:TexEditor.java
/**
* 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();
}
}
项目:EclipsePlugins
文件:DeployLaunchShortcut.java
@Override
public void launch(IEditorPart editor, String mode)
{
// Extract resource from editor
if (editor != null) {
IFileEditorInput input = (IFileEditorInput) editor.getEditorInput();
IFile file = input.getFile();
IProject activeProject = file.getProject();
// If editor existed, run config using extracted resource in
// indicated mode
runConfig(activeProject, mode, editor.getSite().getWorkbenchWindow().getShell());
} else {
WPILibCPPPlugin.logError("Editor was null.", null);
}
}
项目:CodeCheckerEclipsePlugin
文件:CodeCheckerContext.java
/**
* Refresh add custom report list view.
*
* @param secondaryId the ReportListCustomView secondary id
*/
public void refreshAddCustomReportListView(String secondaryId) {
IWorkbenchWindow activeWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if(activeWindow == null) {
Logger.log(IStatus.ERROR, "Error activeWindow is null!");
return;
}
IEditorPart partRef = activeWindow.getActivePage().getActiveEditor();
if(partRef == null) {
Logger.log(IStatus.INFO, "partRef is null!");
return;
}
activeEditorPart = partRef;
IFile file = ((IFileEditorInput) partRef.getEditorInput()).getFile();
IProject project = file.getProject();
IWorkbenchPage[] pages = activeWindow.getPages();
this.refreshCustom(pages, project, secondaryId, true);
this.activeProject = project;
}
项目:ermaster-k
文件:AbstractBaseAction.java
protected void refreshProject() {
IEditorInput input = this.getEditorPart().getEditorInput();
if (input instanceof IFileEditorInput) {
IFile iFile = ((IFileEditorInput) this.getEditorPart()
.getEditorInput()).getFile();
IProject project = iFile.getProject();
try {
project.refreshLocal(IResource.DEPTH_INFINITE, null);
} catch (CoreException e) {
ERDiagramActivator.showExceptionDialog(e);
}
}
}
项目:code
文件:WorkspaceUtilities.java
public static IProject getCurrentProject(IWorkbenchWindow window) {
IProject project = null;
IWorkbenchPage activePage = window.getActivePage();
if (activePage != null) {
IEditorPart editor = activePage.getActiveEditor();
if (editor != null) {
IEditorInput input = editor.getEditorInput();
IFile file = null;
if (input instanceof IFileEditorInput) {
file = ((IFileEditorInput) input).getFile();
}
if (file != null) {
project = file.getProject();
}
}
}
return project;
}
项目:code
文件:WorkspaceUtilities.java
public static IProject getCurrentProject(IWorkbenchWindow window) {
IProject project = null;
IWorkbenchPage activePage = window.getActivePage();
if (activePage != null) {
IEditorPart editor = activePage.getActiveEditor();
if (editor != null) {
IEditorInput input = editor.getEditorInput();
IFile file = null;
if (input instanceof IFileEditorInput) {
file = ((IFileEditorInput) input).getFile();
}
if (file != null) {
project = file.getProject();
}
}
}
return project;
}
项目:dsl-devkit
文件:PlatformPluginAwareEditorOpener.java
/**
* Gets the name of the project in which the currently active editor's resource is contained.
*
* @return the project name
*/
private String getProjectName() {
try {
final IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow();
if (activeWorkbenchWindow != null) {
IEditorPart editorPart = activeWorkbenchWindow.getActivePage().getActiveEditor();
if (editorPart != null) {
IFileEditorInput input = (IFileEditorInput) editorPart.getEditorInput();
IProject activeProject = input.getFile().getProject();
return activeProject.getName();
}
}
// CHECKSTYLE:OFF
} catch (Exception e) {
// CHECKSTYLE:ON
}
return "<unknown plugin>"; //$NON-NLS-1$
}
项目:tlaplus
文件:TLAProofFoldingStructureProvider.java
/**
* Initializes this folding structure provider for the given editor.
*
* @param editor
*/
public TLAProofFoldingStructureProvider(TLAEditor editor)
{
canPerformFoldingCommands = true;
this.editor = editor;
this.document = editor.getDocumentProvider().getDocument(editor.getEditorInput());
foldPositions = new Vector<TLAProofPosition>();
// add this as listener to document to listen for changes
document.addDocumentListener(this);
// get a parse result if the parse result broadcaster has already stored one
if (editor.getEditorInput() instanceof IFileEditorInput) {
IFileEditorInput editorInput = (IFileEditorInput) editor.getEditorInput();
IPath location = editorInput.getFile().getLocation();
ParseResult parseResult = ParseResultBroadcaster.getParseResultBroadcaster().getParseResult(location);
if (parseResult != null)
{
newParseResult(parseResult);
}
}
// now listen to any new parse results
ParseResultBroadcaster.getParseResultBroadcaster().addParseResultListener(this);
}
项目:tlaplus
文件:ProducePDFHandler.java
public Object execute(ExecutionEvent event) {
if (!saveDirtyEditor(event)) {
return null;
}
boolean useEmbeddedViewer = TLA2TeXActivator.getDefault()
.getPreferenceStore()
.getBoolean(ITLA2TeXPreferenceConstants.EMBEDDED_VIEWER);
IEditorInput editorInput = activeEditor.getEditorInput();
if (editorInput instanceof IFileEditorInput) {
final IResource fileToTranslate = ((IFileEditorInput) editorInput)
.getFile();
if (fileToTranslate != null
&& ResourceHelper.isModule(fileToTranslate)) {
if (useEmbeddedViewer) {
runPDFJob(new EmbeddedPDFViewerRunnable(this, activeEditor.getSite(), fileToTranslate),
fileToTranslate);
} else {
runPDFJob(new StandalonePDFViewerRunnable(this, activeEditor.getSite(), fileToTranslate), fileToTranslate);
}
}
}
return null;
}
项目:PDFReporter-Studio
文件:XMLDocumentProvider.java
/**
* Initializes the given document from the given editor input using the given character encoding.
*
* @param document
* the document to be initialized
* @param editorInput
* the input from which to derive the content of the document
* @param encoding
* the character encoding used to read the editor input
* @return if the document content could be set, otherwise
* @throws CoreException
* if the given editor input cannot be accessed
* @since 2.0
*/
@Override
protected boolean setDocumentContent(IDocument document, IEditorInput editorInput, String encoding)
throws CoreException {
InputStream stream = null;
try {
if (editorInput instanceof IFileEditorInput) {
String fileExtention = JrxmlEditor.getFileExtension(editorInput);
if (fileExtention.equals(FileExtension.JASPER)) {
IFile file = ((IFileEditorInput) editorInput).getFile();
stream = file.getContents(false);
setDocumentContent(document,
JrxmlEditor.getXML(jrContext, editorInput, encoding, stream, JRXmlWriterHelper.LAST_VERSION), encoding);
} else
return super.setDocumentContent(document, editorInput, encoding);
}
} catch (JRException e) {
e.printStackTrace();
} finally {
FileUtils.closeStream(stream);
}
return true;
}
项目:ForgedUI-Eclipse
文件:ImageCellEditor.java
private TitaniumProject getProject(){
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchWindow activeWorkbenchWindow = workbench
.getActiveWorkbenchWindow();
IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
IEditorPart activeEditor = activePage.getActiveEditor();
if (activeEditor != null) {
IEditorInput editorInput = activeEditor.getEditorInput();
if ((editorInput instanceof IFileEditorInput)) {
IFile editorFile = ((IFileEditorInput) editorInput)
.getFile();
return (TitaniumProject) editorFile
.getProject().getAdapter(TitaniumProject.class);
}
}
return null;//how???
}
项目:ForgedUI-Eclipse
文件:ImageBrowserDialog.java
/**
*
* @return url or file path relative to Resources folder
*/
public String getSelectedImagePath() {
if (supportUrl && getUrl() != null){
return getUrl();
} else if (getSelectedFile() != null){
IEditorPart activeEditor = getActiveEditor();
if (activeEditor != null) {
IEditorInput editorInput = activeEditor.getEditorInput();
if ((editorInput instanceof IFileEditorInput)) {
IFile editorFile = ((IFileEditorInput) editorInput)
.getFile();
TitaniumProject titProject = (TitaniumProject) editorFile
.getProject().getAdapter(TitaniumProject.class);
IPath path = new Path(getSelectedFile().getAbsolutePath());
path = path.makeRelativeTo(titProject.getReourcesFolder().getLocation());
return path.toPortableString();
}
}
}
return null;
}
项目:bts
文件:PreferenceStoreAccessImpl.java
@SuppressWarnings("deprecation")
public IPreferenceStore getWritablePreferenceStore(Object context) {
lazyInitialize();
if (context instanceof IFileEditorInput) {
context = ((IFileEditorInput) context).getFile().getProject();
}
if (context instanceof IProject) {
ProjectScope projectScope = new ProjectScope((IProject) context);
FixedScopedPreferenceStore result = new FixedScopedPreferenceStore(projectScope, getQualifier());
result.setSearchContexts(new IScopeContext[] {
projectScope,
new InstanceScope(),
new ConfigurationScope()
});
return result;
}
return getWritablePreferenceStore();
}
项目:PDFReporter-Studio
文件:PreviewJRPrint.java
protected void loadJRPrint(IEditorInput input) throws PartInitException {
InputStream in = null;
try {
IFile file = null;
if (input instanceof IFileEditorInput) {
file = ((IFileEditorInput) input).getFile();
in = file.getContents();
} else {
throw new PartInitException("Invalid Input: Must be IFileEditorInput or FileStoreEditorInput"); //$NON-NLS-1$
}
Statistics stats = new Statistics();
if (file.getFileExtension().equals(".jrpxml")) {
setJasperPrint(stats, JRPrintXmlLoader.load(in));
} else {
Object obj = JRLoader.loadObject(in);
if (obj instanceof JasperPrint)
setJasperPrint(stats, (JasperPrint) obj);
}
} catch (Exception e) {
throw new PartInitException("Invalid Input", e);
}
}
项目:eavp
文件:CSVPlot.java
@Override
public String createAdditionalPage(MultiPageEditorPart parent, IFileEditorInput file, int pageNum) {
// Create the specified page
switch (pageNum) {
// Page 2 is the file's data displayed in text
case 1:
// Create a text editor with the file as input and add its page with
// the name Data
try {
editor = (IEditorPart) new TextEditor();
parent.addPage(editor, file);
return "Data";
} catch (PartInitException e) {
logger.error("Error initializing text editor for CSV Plot Editor.");
}
break;
}
// If the page number is not supported, return null
return null;
}
项目:statecharts
文件:ActiveEditorTracker.java
/**
* @return The project which contains the file that is open in the last
* active editor in the current workbench page.
*/
public static IProject getLastActiveEditorProject() {
final IEditorPart editor = getLastActiveEditor();
if (editor == null)
return null;
final IEditorInput editorInput = editor.getEditorInput();
if (editorInput instanceof IFileEditorInput) {
final IFileEditorInput input = (IFileEditorInput) editorInput;
return input.getFile().getProject();
} else if (editorInput instanceof URIEditorInput) {
final URI uri = ((URIEditorInput) editorInput).getURI();
if (uri.isPlatformResource()) {
final String platformString = uri.toPlatformString(true);
return ResourcesPlugin.getWorkspace().getRoot().findMember(platformString).getProject();
}
}
return null;
}
项目:VariantSync
文件:ContextController.java
public void activateContext(String featureExpression) {
if (!isPartActivated) {
IWorkbench wb = PlatformUI.getWorkbench();
IWorkbenchWindow win = wb.getActiveWorkbenchWindow();
IWorkbenchPage page = win.getActivePage();
IWorkbenchPart part = page.getActivePart();
if (part instanceof IEditorPart) {
if (((IEditorPart) part).getEditorInput() instanceof IFileEditorInput) {
IFile file = ((IFileEditorInput) ((EditorPart) part)
.getEditorInput()).getFile();
System.out
.println("\n====== LOCATION OF ACTIVE FILE IN EDITOR ======");
System.out.println(file.getLocation());
System.out
.println("===============================================");
MarkerHandler.getInstance().refreshMarker(file);
setBaseVersion(file);
}
}
}
contextOperations.activateContext(featureExpression);
}
项目:cppcheclipse
文件:AbstractResourceSelectionJobCommand.java
private IStructuredSelection getEditorFileSelection(IEditorPart editor) {
if (editor == null) {
return null;
}
IEditorInput input = editor.getEditorInput();
if (input == null) {
return null;
}
IFileEditorInput fileInput = (IFileEditorInput) input
.getAdapter(IFileEditorInput.class);
if (fileInput == null) {
return null;
}
List<IFile> fileList = new LinkedList<IFile>();
fileList.add(fileInput.getFile());
return new StructuredSelection(fileList);
}
项目:hssd
文件:HSSDEditorExportDBData.java
public Object execute(ExecutionEvent event) {
return watchedExecute(() -> {
final HSSDEditor editor = getActiveHSSDEditor();
if(editor == null) {
return null;
}
if(!(editor.getEditorInput() instanceof IFileEditorInput)) {
return null;
}
IFileEditorInput input = (IFileEditorInput)editor.getEditorInput();
final Object res = input.getFile();
final IWorkbenchPage activePage = Helper.getActiveWBPage();
if(activePage.saveAllEditors(true)) {
File loc = ((IFile)res).getLocation().toFile();
doExportDBData(editor.getMasterCP().getDB(), loc.getParentFile());
}
return null;
});
}
项目:junit-tools
文件:JDTUtils.java
public static Vector<IJavaElement> getCompilationUnits(ISelection selection)
throws JavaModelException, JUTWarning {
if (selection instanceof IStructuredSelection) {
return getCompilationUnits(selection, null);
} else {
IEditorInput editorInput = EclipseUIUtils.getEditorInput();
if (editorInput instanceof IFileEditorInput) {
return getCompilationUnits(null, (IFileEditorInput) editorInput);
}
}
return new Vector<IJavaElement>();
}
项目:ModelDebugging
文件:EMFEditorUtils.java
/**
* 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;
}
项目:PDFReporter-Studio
文件:AJDEditPart.java
/**
* Returns the file associated.
* <p>
* Given the current edit part belonging to the active JRXML editor (report designer) the related file is returned.
*
* @return the associated file resource
*/
public IResource getAssociatedFile() {
IEditorInput edinput = null;
if (getViewer() != null && getViewer().getEditDomain() instanceof DefaultEditDomain) {
IEditorPart ip = ((DefaultEditDomain) getViewer().getEditDomain()).getEditorPart();
edinput = ip.getEditorInput();
} else {
IEditorPart ep = SelectionHelper.getActiveJRXMLEditor();
if (ep != null)
edinput = ep.getEditorInput();
}
if (edinput instanceof IFileEditorInput) {
return ((IFileEditorInput) edinput).getFile();
}
return null;
}
项目:depan
文件:GraphEditor.java
private void initFromInput(IEditorInput input) throws PartInitException {
if (!(input instanceof IFileEditorInput)) {
throw new PartInitException("Invalid Input: Must be IFileEditorInput");
}
// load the graph
file = ((IFileEditorInput) input).getFile();
GraphDocLogger.LOG.info("Reading {}", file.getRawLocationURI());
graph = ResourceCache.fetchGraphDocument(file);
GraphDocLogger.LOG.info(" DONE");
DependencyModel model = graph.getDependencyModel();
graphResources = GraphResourceBuilder.forModel(model);
// set the title to the filename, excepted the file extension
String title = file.getName();
title = title.substring(0, title.lastIndexOf('.'));
this.setPartName(title);
}
项目:depan
文件:NodeListEditor.java
private void initFromInput(IEditorInput input) throws PartInitException {
if (input instanceof NodeListEditorInput) {
NodeListEditorInput docInput = (NodeListEditorInput) input;
file = null;
nodeListInfo = docInput.getNodeListDocument();
baseName = docInput.getBaseName();
setPartName(docInput.getName());
needsSave = true;
} else if (input instanceof IFileEditorInput) {
IFileEditorInput fileInput = (IFileEditorInput) input;
file = fileInput.getFile();
NodeListDocXmlPersist persist = NodeListDocXmlPersist.buildForLoad(file);
nodeListInfo = persist.load(file.getRawLocationURI());
baseName = buildFileInputBaseName(file);
setPartName(fileInput.getName());
needsSave = false;
} else {
// Something unexpected
throw new PartInitException(
"Input is not suitable for the NodeList editor.");
}
}
项目:depan
文件:EdgeMatcherEditor.java
@Override
public void init(IEditorSite site, IEditorInput input)
throws PartInitException {
setSite(site);
setInput(input);
// only accept a file as input.
if (input instanceof IFileEditorInput) {
// get the URI
IFileEditorInput fileInput = (IFileEditorInput) input;
file = fileInput.getFile();
EdgeMatcherDocXmlPersist persist = EdgeMatcherDocXmlPersist.build(true);
matcherInfo = persist.load(file.getRawLocationURI());
setPartName(buildPartName());
setDirtyState(false);
return;
}
// Something unexpected
throw new PartInitException(
"Input for editor is not suitable for the RelationSetDescriptorEditor");
}
项目:limpet
文件:ApplicationWorkbenchWindowAdvisor.java
private void setTitlePath()
{
String titlePath = null;
if (lastActiveEditor != null)
{
IEditorInput editorInput = lastActiveEditor.getEditorInput();
if (editorInput instanceof IFileEditorInput)
{
titlePath = computeTitlePath((IFileEditorInput) editorInput);
}
else if (editorInput instanceof FileStoreEditorInput)
{
titlePath = computeTitlePath((FileStoreEditorInput) editorInput);
}
}
titlePathUpdater.updateTitlePath(getWindowConfigurer().getWindow()
.getShell(), titlePath);
}