org.eclipse.ui.IEditorInput Java Examples

The following examples show how to use org.eclipse.ui.IEditorInput. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PyEditTitle.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
private boolean isDjangoHandledModule(String djangoModulesHandling, IEditorInput input, String lastSegment) {
    boolean handled = false;
    if (djangoModulesHandling == PyTitlePreferencesPage.TITLE_EDITOR_DJANGO_MODULES_SHOW_PARENT_AND_DECORATE
            || djangoModulesHandling == PyTitlePreferencesPage.TITLE_EDITOR_DJANGO_MODULES_DECORATE) {

        if (input instanceof IFileEditorInput) {
            IFileEditorInput iFileEditorInput = (IFileEditorInput) input;
            IFile file = iFileEditorInput.getFile();
            IProject project = file.getProject();
            try {
                if (project.hasNature(PythonNature.DJANGO_NATURE_ID)) {
                    if (PyTitlePreferencesPage.isDjangoModuleToDecorate(lastSegment)) {
                        //remove the module name.
                        handled = true;
                    }
                }
            } catch (CoreException e) {
                Log.log(e);
            }
        }
    }
    return handled;
}
 
Example #2
Source File: SelectionUtils.java    From wildwebdeveloper with Eclipse Public License 2.0 6 votes vote down vote up
private static IFile getSelectedIFile() {
	try {
		ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
		if (selection instanceof IStructuredSelection) {
			return Adapters.adapt(((IStructuredSelection)selection).getFirstElement(), IFile.class);
		}
	} catch (Exception e) {
		Activator.getDefault().getLog().log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e));
	}
	IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
	if (editor != null) {
		IEditorInput input = editor.getEditorInput();
		if (input instanceof IFileEditorInput) {
			return ((IFileEditorInput)input).getFile();
		}
	}
	return null;
}
 
Example #3
Source File: XLIFFEditor.java    From tmxeditor8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 启动编辑器。
 * 
 * @param site
 *            the site
 * @param input
 *            the input
 * @throws PartInitException
 *             the part init exception
 * @see org.eclipse.ui.part.EditorPart#init(org.eclipse.ui.IEditorSite,
 *      org.eclipse.ui.IEditorInput)
 */
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
	if (LOGGER.isDebugEnabled()) {
		LOGGER.debug("init(IEditorSite site, IEditorInput input)");
	}
	setSite(site);
	setInput(input);
	// 设置Editor标题栏的显示名称,否则名称用plugin.xml中的name属性
	setPartName(input.getName());

	Image oldTitleImage = titleImage;
	if (input != null) {
		IEditorRegistry editorRegistry = PlatformUI.getWorkbench().getEditorRegistry();
		IEditorDescriptor editorDesc = editorRegistry.findEditor(getSite().getId());
		ImageDescriptor imageDesc = editorDesc != null ? editorDesc.getImageDescriptor() : null;
		titleImage = imageDesc != null ? imageDesc.createImage() : null;
	}

	setTitleImage(titleImage);
	if (oldTitleImage != null && !oldTitleImage.isDisposed()) {
		oldTitleImage.dispose();
	}

	getSite().setSelectionProvider(this);
}
 
Example #4
Source File: ExtendendResourceLinkHelper.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public IStructuredSelection findSelection(IEditorInput anInput) {
    IDiagramDocument document = ProcessDiagramEditorPlugin.getInstance().getDocumentProvider()
            .getDiagramDocument(anInput);
    if (document == null) {
        return super.findSelection(anInput);
    }
    Diagram diagram = document.getDiagram();
    if (diagram == null || diagram.eResource() == null) {
        return StructuredSelection.EMPTY;
    }
    IFile file = WorkspaceSynchronizer.getFile(diagram.eResource());
    if (file != null) {
        return new StructuredSelection(file);
    }
    return StructuredSelection.EMPTY;
}
 
Example #5
Source File: IDEFileReportProvider.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public IPath getInputPath( IEditorInput input )
{
	if ( input instanceof IURIEditorInput )
	{
		//return new Path( ( (IURIEditorInput) input ).getURI( ).getPath( ) );
		URI uri = ( (IURIEditorInput) input ).getURI( );
		if(uri == null && input instanceof IFileEditorInput)
			return ((IFileEditorInput)input).getFile( ).getFullPath( );
		IPath localPath = URIUtil.toPath( uri );
		String host = uri.getHost( );
		if ( host != null && localPath == null )
		{
			return new Path( host + uri.getPath( ) ).makeUNC( true );
		}
		return localPath;
	}
	if ( input instanceof IFileEditorInput )
	{
		return ( (IFileEditorInput) input ).getFile( ).getLocation( );
	}
	return null;
}
 
Example #6
Source File: JavaSourceViewerConfiguration.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private IJavaProject getProject() {
	ITextEditor editor= getEditor();
	if (editor == null)
		return null;

	IJavaElement element= null;
	IEditorInput input= editor.getEditorInput();
	IDocumentProvider provider= editor.getDocumentProvider();
	if (provider instanceof ICompilationUnitDocumentProvider) {
		ICompilationUnitDocumentProvider cudp= (ICompilationUnitDocumentProvider) provider;
		element= cudp.getWorkingCopy(input);
	} else if (input instanceof IClassFileEditorInput) {
		IClassFileEditorInput cfei= (IClassFileEditorInput) input;
		element= cfei.getClassFile();
	}

	if (element == null)
		return null;

	return element.getJavaProject();
}
 
Example #7
Source File: CommonReconcilingStrategy.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
protected IFile getFile()
{
	AbstractThemeableEditor editor = fEditor;
	if (editor != null)
	{
		IEditorInput editorInput = editor.getEditorInput();

		if (editorInput instanceof IFileEditorInput)
		{
			IFileEditorInput fileEditorInput = (IFileEditorInput) editorInput;
			return fileEditorInput.getFile();
		}
	}

	return null;
}
 
Example #8
Source File: IDEMultiPageReportEditor.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
protected void setInput( IEditorInput input )
{

	// The workspace never changes for an editor. So, removing and re-adding
	// the
	// resourceListener is not necessary. But it is being done here for the
	// sake
	// of proper implementation. Plus, the resourceListener needs to be
	// added
	// to the workspace the first time around.
	if ( isWorkspaceResource )
	{
		getFile( getEditorInput( ) ).getWorkspace( )
				.removeResourceChangeListener( resourceListener );
	}

	isWorkspaceResource = input instanceof IFileEditorInput;

	super.setInput( input );

	if ( isWorkspaceResource )
	{
		getFile( getEditorInput( ) ).getWorkspace( )
				.addResourceChangeListener( resourceListener );
	}
}
 
Example #9
Source File: SpellUncheckAction.java    From texlipse with Eclipse Public License 1.0 6 votes vote down vote up
/**
    * Clear the spelling error markers.
    * @param action the action
 */
public void run(IAction action) {
       
       if (targetEditor == null) {
           return;
       }
       if (!(targetEditor instanceof ITextEditor)) {
           return;
       }
       
       ITextEditor textEditor = (ITextEditor) targetEditor;
       IEditorInput input = textEditor.getEditorInput();
       
       if (input instanceof FileEditorInput) {
           SpellChecker.clearMarkers(((FileEditorInput)input).getFile());
       }
}
 
Example #10
Source File: CoreEditorUtils.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
/**
    * Returns File underlying this editor input. 
    * 
    * This method should be modified, whenever new editor input is supported 
    * for some editor requiring access to File.
    * 
    * @param input the editor input to operate on.
    * 
    * @return file underlying given editor input.
    */    
   public static File editorInputToFile(IEditorInput input) {
	if (input == null) 
	    return null;
	
       if (input instanceof IFileEditorInput) {
       	IFile file = editorInputToIFile(input);
           if (file != null) {
               return ResourceUtils.getAbsoluteFile(file);
           }
       }
       else if (input instanceof IURIEditorInput) {
           IURIEditorInput uriEditorInput = (IURIEditorInput) input;
           return new File(uriEditorInput.getURI());
       }
       else if (input instanceof CommonSourceNotFoundEditorInput || input instanceof CompareEditorInput || input instanceof IStorageEditorInput) {
       	// do nothing
	}
       else{
       	LogHelper.logError("Unknown editor input");
       }
       
       return null;
}
 
Example #11
Source File: PydevPackageExplorer.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Returns the element contained in the EditorInput
 */
Object getElementOfInput(IEditorInput input) {
    if (input instanceof IFileEditorInput) {
        return ((IFileEditorInput) input).getFile();
    }
    if (input instanceof IURIEditorInput) {
        IURIEditorInput iuriEditorInput = (IURIEditorInput) input;
        URI uri = iuriEditorInput.getURI();
        return new File(uri);

    }
    if (input instanceof PydevZipFileEditorInput) {
        PydevZipFileEditorInput pydevZipFileEditorInput = (PydevZipFileEditorInput) input;
        try {
            IStorage storage = pydevZipFileEditorInput.getStorage();
            if (storage instanceof PydevZipFileStorage) {
                PydevZipFileStorage pydevZipFileStorage = (PydevZipFileStorage) storage;
                return pydevZipFileStorage;
            }
        } catch (CoreException e) {
            Log.log(e);
        }

    }
    return null;
}
 
Example #12
Source File: DeleteEditorFileHandler.java    From eclipse-extras with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public Object execute( ExecutionEvent event ) {
  IEditorInput editorInput = HandlerUtil.getActiveEditorInput( event );
  IFile resource = ResourceUtil.getFile( editorInput );
  if( resource != null ) {
    if( resource.isAccessible() ) {
      deleteResource( HandlerUtil.getActiveWorkbenchWindow( event ), resource );
    }
  } else {
    File file = getFile( editorInput );
    IWorkbenchWindow workbenchWindow = HandlerUtil.getActiveWorkbenchWindow( event );
    if( file != null && prompter.confirmDelete( workbenchWindow, file )) {
      deleteFile( workbenchWindow, file );
    }
  }
  return null;
}
 
Example #13
Source File: EditorUtility.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Returns the editors to save before performing global Java-related
 * operations.
 *
 * @param saveUnknownEditors <code>true</code> iff editors with unknown buffer management should also be saved
 * @return the editors to save
 * @since 3.3
 */
public static IEditorPart[] getDirtyEditorsToSave(boolean saveUnknownEditors) {
	Set<IEditorInput> inputs= new HashSet<IEditorInput>();
	List<IEditorPart> result= new ArrayList<IEditorPart>(0);
	IWorkbench workbench= PlatformUI.getWorkbench();
	IWorkbenchWindow[] windows= workbench.getWorkbenchWindows();
	for (int i= 0; i < windows.length; i++) {
		IWorkbenchPage[] pages= windows[i].getPages();
		for (int x= 0; x < pages.length; x++) {
			IEditorPart[] editors= pages[x].getDirtyEditors();
			for (int z= 0; z < editors.length; z++) {
				IEditorPart ep= editors[z];
				IEditorInput input= ep.getEditorInput();
				if (!mustSaveDirtyEditor(ep, input, saveUnknownEditors))
					continue;

				if (inputs.add(input))
					result.add(ep);
			}
		}
	}
	return result.toArray(new IEditorPart[result.size()]);
}
 
Example #14
Source File: SourceFileStore.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void closeRelatedEditorIfOpened(final ICompilationUnit compilationUnit) throws PartInitException {
    Optional<IWorkbenchPage> activePage = Optional.ofNullable(PlatformUI.getWorkbench().getActiveWorkbenchWindow())
            .map(IWorkbenchWindow::getActivePage);
    if (activePage.isPresent()) {
        if (editorPart != null) {
            if (PlatformUI.isWorkbenchRunning()) {
                activePage.get().closeEditor(editorPart, false);
            }
        } else {
            if (PlatformUI.isWorkbenchRunning()) {
                for (final IEditorReference editorReference : activePage.get().getEditorReferences()) {
                    final IEditorInput editorInput = editorReference.getEditorInput();
                    if (compilationUnit.getResource()
                            .equals(EditorUtil.retrieveResourceFromEditorInput(editorInput))) {
                        activePage.get().closeEditors(new IEditorReference[] { editorReference }, false);
                        break;
                    }
                }
            }
        }
    }
}
 
Example #15
Source File: EditorUtility.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private static IEditorInput getEditorInput(IJavaElement element) {
	while (element != null) {
		if (element instanceof ICompilationUnit) {
			ICompilationUnit unit= ((ICompilationUnit) element).getPrimary();
				IResource resource= unit.getResource();
				if (resource instanceof IFile)
					return new FileEditorInput((IFile) resource);
		}

		if (element instanceof IClassFile)
			return new InternalClassFileEditorInput((IClassFile) element);

		element= element.getParent();
	}

	return null;
}
 
Example #16
Source File: DefaultMergeViewer.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
protected void configureSourceViewer(SourceViewer sourceViewer) {
	IEditorInput editorInput = getEditorInput(sourceViewer);
	SourceViewerConfiguration sourceViewerConfiguration = createSourceViewerConfiguration(sourceViewer, editorInput);
	sourceViewer.unconfigure();
	sourceViewer.configure(sourceViewerConfiguration);
	IXtextDocument xtextDocument = xtextDocumentUtil.getXtextDocument(sourceViewer);
	if (xtextDocument != null) {
		if (!xtextDocument.readOnly(TEST_EXISTING_XTEXT_RESOURCE)) {
			String[] configuredContentTypes = sourceViewerConfiguration.getConfiguredContentTypes(sourceViewer);
			for (String contentType : configuredContentTypes) {
				sourceViewer.removeTextHovers(contentType);
			}
			sourceViewer.setHyperlinkDetectors(null, sourceViewerConfiguration.getHyperlinkStateMask(sourceViewer));
		}
	}
}
 
Example #17
Source File: LanguageSpecificURIEditorOpener.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public IEditorPart open(final URI uri, final EReference crossReference, final int indexInList, final boolean select) {
	Iterator<Pair<IStorage, IProject>> storages = mapper.getStorages(uri.trimFragment()).iterator();
	if (storages != null && storages.hasNext()) {
		try {
			IStorage storage = storages.next().getFirst();
			IEditorInput editorInput = EditorUtils.createEditorInput(storage);
			IWorkbenchPage activePage = workbench.getActiveWorkbenchWindow().getActivePage();
			final IEditorPart editor = IDE.openEditor(activePage, editorInput, getEditorId());
			selectAndReveal(editor, uri, crossReference, indexInList, select);
			return EditorUtils.getXtextEditor(editor);
		} catch (WrappedException e) {
			logger.error("Error while opening editor part for EMF URI '" + uri + "'", e.getCause());
		} catch (PartInitException partInitException) {
			logger.error("Error while opening editor part for EMF URI '" + uri + "'", partInitException);
		}
	}
	return null;
}
 
Example #18
Source File: TLAHyperlinkDetector.java    From tlaplus with MIT License 6 votes vote down vote up
private int[] getDocumentAndRegion(SyntaxTreeNode csNode, IDocumentProvider documentProvider, IEditorInput editorInput)
		throws CoreException {
	IDocument document;
	// connect to the resource
	try {
		documentProvider.connect(editorInput);
		document = documentProvider.getDocument(editorInput);
	} finally {
		/*
		 * Once the document has been retrieved, the document provider is not needed.
		 * Always disconnect it to avoid a memory leak.
		 * 
		 * Keeping it connected only seems to provide synchronization of the document
		 * with file changes. That is not necessary in this context.
		 */
		documentProvider.disconnect(editorInput);
	}

	return getRegion(csNode, document);
}
 
Example #19
Source File: HtmlBrowserEditor.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
	setSite(site);
	setInput(input);
	setPartName(input.getName());
	
	Image oldTitleImage = titleImage;
	if (input != null) {
		IEditorRegistry editorRegistry = PlatformUI.getWorkbench().getEditorRegistry();
		IEditorDescriptor editorDesc = editorRegistry.findEditor(getSite().getId());
		ImageDescriptor imageDesc = editorDesc != null ? editorDesc.getImageDescriptor() : null;
		titleImage = imageDesc != null ? imageDesc.createImage() : null;
	}

	setTitleImage(titleImage);
	if (oldTitleImage != null && !oldTitleImage.isDisposed()) {
		oldTitleImage.dispose();
	}

	FileEditorInput fileInput = (FileEditorInput) input;
	htmlUrl = fileInput.getFile().getLocation().toOSString();
}
 
Example #20
Source File: PartEventListener.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
private void subscribeDocumentEventListener(IWorkbenchPartReference partRef) {
	IWorkbenchPart part = partRef.getPart(false);
	if (part instanceof IEditorPart) {
		IEditorPart editor = (IEditorPart) part;
		IEditorInput input = editor.getEditorInput();

		if (editor instanceof ITextEditor && input instanceof FileEditorInput) {
			ITextEditor textEditor = (ITextEditor) editor;

			// EventManager.setEditor(textEditor);

			saveListener(textEditor);

			IDocument document = textEditor.getDocumentProvider().getDocument(input);

			DocumentEventListener documentListener = new DocumentEventListener(textEditor.getTitle());
			document.addDocumentListener(documentListener);
		}
	}
}
 
Example #21
Source File: DockerRunLaunchShortcut.java    From doclipser with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void launch(IEditorPart editor, String mode) {
    IEditorInput input = editor.getEditorInput();
    IFile dockerfile = (IFile) input.getAdapter(IFile.class);
    IPath dockerfilePath = null;
    if (dockerfile != null) {
        dockerfilePath = dockerfile.getLocation().removeLastSegments(1);
    }
    if (dockerfilePath == null) {
        ILocationProvider locationProvider = (ILocationProvider) input
                .getAdapter(ILocationProvider.class);
        if (locationProvider != null) {
            dockerfilePath = locationProvider.getPath(input);
        }
    }
    if (dockerfilePath != null) {
        launch(dockerfile, dockerfilePath);
    }
}
 
Example #22
Source File: PyDebugModelPresentation.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Returns editor to be displayed
 */
@Override
public IEditorInput getEditorInput(Object element) {
    if (element instanceof PyBreakpoint) {
        String file = ((PyBreakpoint) element).getFile();
        if (file != null) {
            return EditorInputFactory.create(new File(file), false);

            //We should not open the editor here, just create the input... the debug framework opens it later on.
            //IPath path = new Path(file);
            //IEditorPart part = PyOpenEditor.doOpenEditor(path);
            //return part.getEditorInput();
        }
    }
    return null;
}
 
Example #23
Source File: PySourceLocatorBase.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
public IEditorInput findFromOpenedPyEdits() {
    Object ret = OpenEditors.iterOpenEditorsUntilFirstReturn(new ICallback<Object, IPyEdit>() {

        @Override
        public Object call(IPyEdit pyEdit) {
            IEditorInput editorInput = (IEditorInput) pyEdit.getEditorInput();
            if (editorInput instanceof IPathEditorInput) {
                IPathEditorInput pathEditorInput = (IPathEditorInput) editorInput;
                IPath localPath = pathEditorInput.getPath();
                if (localPath != null) {
                    if (matchesPath(matchName, editorInput, localPath)) {
                        return editorInput;
                    }
                }
            } else {
                File editorFile = pyEdit.getEditorFile();
                if (editorFile != null) {
                    if (matchesFile(matchName, editorInput, editorFile)) {
                        return editorInput;
                    }
                }
            }
            return null;
        }
    });
    return (IEditorInput) ret;
}
 
Example #24
Source File: CustomProcessDiagramEditor.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
    super.init(site, input);
    DiagramFileStore store = repositoryAccessor.getRepositoryStore(DiagramRepositoryStore.class)
            .getChild(input.getName(), true);
    if (store != null) {
        webPageNameResourceChangeListener.setMainProcess(store.getContent());
        repositoryAccessor.getWorkspace().addResourceChangeListener(webPageNameResourceChangeListener);
    }
}
 
Example #25
Source File: EditorUtils.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Open an editor anywhere on the file system using Eclipse's default editor registered for the given file.
 *
 * @param fileToOpen File to open
 * @note we must be in the UI thread for this method to work.
 * @return Editor opened or created
 */
public static IEditorPart openFile(File fileToOpen, boolean activate) {

    final IWorkbench workbench = PlatformUI.getWorkbench();
    if (workbench == null) {
        throw new RuntimeException("workbench cannot be null");
    }

    IWorkbenchWindow activeWorkbenchWindow = workbench.getActiveWorkbenchWindow();
    if (activeWorkbenchWindow == null) {
        throw new RuntimeException(
                "activeWorkbenchWindow cannot be null (we have to be in a ui thread for this to work)");
    }

    IWorkbenchPage wp = activeWorkbenchWindow.getActivePage();

    final IFileStore fileStore = EFS.getLocalFileSystem().getStore(fileToOpen.toURI());

    try {
        if (activate) {
            // open the editor on the file
            return IDE.openEditorOnFileStore(wp, fileStore);
        }

        // Workaround when we don't want to activate (as there's no suitable API
        // in the core for that).
        IEditorInput input = getEditorInput(fileStore);
        String editorId = getEditorId(input, null);

        return wp.openEditor(input, editorId, activate);

    } catch (Exception e) {
        Log.log("Editor failed to open", e);
        return null;
    }
}
 
Example #26
Source File: H5Editor.java    From dawnsci with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Get the file path from a FileStoreEditorInput. Removes any "file:"
 * from the URI to the file path if it exists.
 * 
 * @param fileInput
 * @return String
 */
public String getFilePath(IEditorInput fileInput) {
	
	final IFile file = (IFile)fileInput.getAdapter(IFile.class);
	if (file!=null) return file.getLocation().toOSString();

	if (fileInput instanceof IURIEditorInput) {
		String path = ((IURIEditorInput)fileInput).getURI().toString();
		if (path.startsWith("file:")) path = path.substring(5);
		path = path.replace("%20", " ");
		return path;
	} 
	return null;
}
 
Example #27
Source File: FormEditor.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void init ( final IEditorSite site, final IEditorInput input ) throws PartInitException
{
    setPartName ( input.toString () );
    setSite ( site );
    try
    {
        setInput ( input );
    }
    catch ( final Exception e )
    {
        throw new PartInitException ( "Failed to initialize editor", e );
    }
}
 
Example #28
Source File: OsgiEditor.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected void doSaveAs ( URI uri, IEditorInput editorInput )
{
    ( editingDomain.getResourceSet ().getResources ().get ( 0 ) ).setURI ( uri );
    setInputWithNotify ( editorInput );
    setPartName ( editorInput.getName () );
    IProgressMonitor progressMonitor = getActionBars ().getStatusLineManager () != null ? getActionBars ().getStatusLineManager ().getProgressMonitor () : new NullProgressMonitor ();
    doSave ( progressMonitor );
}
 
Example #29
Source File: MemoryEditor.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * This is called during startup.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
@Override
public void init ( IEditorSite site, IEditorInput editorInput )
{
    setSite ( site );
    setInputWithNotify ( editorInput );
    setPartName ( editorInput.getName () );
    site.setSelectionProvider ( this );
    site.getPage ().addPartListener ( partListener );
    ResourcesPlugin.getWorkspace ().addResourceChangeListener ( resourceChangeListener, IResourceChangeEvent.POST_CHANGE );
}
 
Example #30
Source File: JsonEditor.java    From KaiZen-OpenAPI-Editor with Eclipse Public License 1.0 5 votes vote down vote up
public SafeWorkspaceJob(String name) {
    super(name);
    setPriority(Job.INTERACTIVE);
    IEditorInput editorInput = JsonEditor.this.getEditorInput();
    if (editorInput != null && editorInput instanceof FileEditorInput) {
        setRule(((FileEditorInput) editorInput).getFile());
    }
}