Search in sources :

Example 1 with FileEditorInput

use of org.eclipse.ui.part.FileEditorInput in project tdi-studio-se by Talend.

the class TalendJavaSourceViewer method initializeModel.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.core.ui.viewer.ReconcilerViewer#initializeModel(IDocument document)
     */
@Override
protected void initializeModel() {
    getSourceViewerDecorationSupport().install(JavaPlugin.getDefault().getCombinedPreferenceStore());
    this.setRangeIndicator(new DefaultRangeIndicator());
    IAnnotationModel model;
    IDocument document;
    if (checkCode) {
        IDocumentProvider provider = JavaPlugin.getDefault().getCompilationUnitDocumentProvider();
        IEditorInput ei = new FileEditorInput(file);
        try {
            provider.connect(ei);
        } catch (CoreException e) {
            ExceptionHandler.process(e);
        }
        document = provider.getDocument(ei);
        model = provider.getAnnotationModel(ei);
    } else {
        model = new AnnotationModel();
        document = getDocument();
        model.connect(document);
    }
    if (document != null) {
        setDocument(document, model);
        showAnnotations(model != null && checkCode);
    }
    super.initializeModel();
}
Also used : DefaultRangeIndicator(org.eclipse.ui.texteditor.DefaultRangeIndicator) IDocumentProvider(org.eclipse.ui.texteditor.IDocumentProvider) CoreException(org.eclipse.core.runtime.CoreException) FileEditorInput(org.eclipse.ui.part.FileEditorInput) IAnnotationModel(org.eclipse.jface.text.source.IAnnotationModel) AnnotationModel(org.eclipse.jface.text.source.AnnotationModel) IAnnotationModel(org.eclipse.jface.text.source.IAnnotationModel) IDocument(org.eclipse.jface.text.IDocument) IEditorInput(org.eclipse.ui.IEditorInput)

Example 2 with FileEditorInput

use of org.eclipse.ui.part.FileEditorInput in project tdi-studio-se by Talend.

the class AbstractMultiPageTalendEditor method createFileEditorInput.

protected FileEditorInput createFileEditorInput() {
    IPath codePath = processor.getCodePath();
    if (codePath == null || codePath.isEmpty()) {
        // (should not happen)
        try {
            processor.initPath();
        } catch (ProcessorException e) {
            MessageBoxExceptionHandler.process(e);
        }
        codePath = processor.getCodePath();
    }
    IFile codeFile = processor.getCodeProject().getFile(codePath);
    if (!codeFile.exists()) {
        // Create empty one
        try {
            //$NON-NLS-1$
            codeFile.create(new ByteArrayInputStream("".getBytes()), true, null);
        } catch (CoreException e) {
        // Do nothing.
        }
    }
    return new FileEditorInput(codeFile);
}
Also used : ProcessorException(org.talend.designer.runprocess.ProcessorException) IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) CoreException(org.eclipse.core.runtime.CoreException) ByteArrayInputStream(java.io.ByteArrayInputStream) FileEditorInput(org.eclipse.ui.part.FileEditorInput)

Example 3 with FileEditorInput

use of org.eclipse.ui.part.FileEditorInput in project tdi-studio-se by Talend.

the class AbstractMultiPageTalendEditor method updateCodeEditorContent.

private void updateCodeEditorContent() {
    if (!(processor.getProperty().getItem() instanceof JobletProcessItem)) {
        FileEditorInput input = createFileEditorInput();
        codeEditor.setInput(input);
    }
}
Also used : JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) FileEditorInput(org.eclipse.ui.part.FileEditorInput)

Example 4 with FileEditorInput

use of org.eclipse.ui.part.FileEditorInput in project tdi-studio-se by Talend.

the class StandAloneTalendJavaEditor method doSetInput.

@Override
public void doSetInput(IEditorInput input) throws CoreException {
    // Lock the process :
    IRepositoryService service = DesignerPlugin.getDefault().getRepositoryService();
    IProxyRepositoryFactory repFactory = service.getProxyRepositoryFactory();
    if (input instanceof RepositoryEditorInput) {
        rEditorInput = (RepositoryEditorInput) input;
    } else {
        FileEditorInput fileInput = (FileEditorInput) input;
        rEditorInput = new RepositoryEditorInput(fileInput.getFile(), rEditorInput.getItem());
    }
    if (rEditorInput.getRepositoryNode() == null) {
        // retrieve node
        rEditorInput.setRepositoryNode(null);
    }
    try {
        // see bug 1321
        item = (FileItem) rEditorInput.getItem();
        if (!rEditorInput.isReadOnly()) {
            if (getRepositoryFactory().getStatus(item).isPotentiallyEditable()) {
                item.getProperty().eAdapters().add(dirtyListener);
                repFactory.lock(item);
            }
        } else {
            rEditorInput.getFile().setReadOnly(true);
        }
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }
    rEditorInput.getFile().refreshLocal(IResource.DEPTH_ONE, null);
    super.doSetInput(rEditorInput);
    setName();
    // only for sql template
    if (item instanceof SQLPatternItem) {
        Workspace ws = (Workspace) ResourcesPlugin.getWorkspace();
        ws.broadcastBuildEvent(item, IResourceChangeEvent.POST_CHANGE, 1);
    }
}
Also used : RepositoryEditorInput(org.talend.core.repository.ui.editor.RepositoryEditorInput) FileEditorInput(org.eclipse.ui.part.FileEditorInput) SQLPatternItem(org.talend.core.model.properties.SQLPatternItem) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException) LoginException(org.talend.commons.exception.LoginException) InvocationTargetException(java.lang.reflect.InvocationTargetException) PersistenceException(org.talend.commons.exception.PersistenceException) IRepositoryService(org.talend.repository.model.IRepositoryService) Workspace(org.eclipse.core.internal.resources.Workspace) IWorkspace(org.eclipse.core.resources.IWorkspace)

Example 5 with FileEditorInput

use of org.eclipse.ui.part.FileEditorInput in project KaiZen-OpenAPI-Editor by RepreZen.

the class TextDocumentMarkerResolution method run.

public void run(IMarker marker) {
    try {
        IResource resource = marker.getResource();
        if (resource.getType() != IResource.FILE) {
            throw new CoreException(createStatus(null, "The editor is not a File: " + resource.getName()));
        }
        IFile file = (IFile) resource;
        ITextEditor editor = openTextEditor(file);
        IDocument document = editor.getDocumentProvider().getDocument(new FileEditorInput(file));
        if (document == null) {
            throw new CoreException(createStatus(null, "The document is null"));
        }
        IRegion region = processFix(document, marker);
        if (region != null) {
            editor.selectAndReveal(region.getOffset(), region.getLength());
        }
    } catch (CoreException e) {
        Activator.getDefault().getLog().log(e.getStatus());
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) ITextEditor(org.eclipse.ui.texteditor.ITextEditor) CoreException(org.eclipse.core.runtime.CoreException) FileEditorInput(org.eclipse.ui.part.FileEditorInput) IResource(org.eclipse.core.resources.IResource) IDocument(org.eclipse.jface.text.IDocument) IRegion(org.eclipse.jface.text.IRegion)

Aggregations

FileEditorInput (org.eclipse.ui.part.FileEditorInput)262 IFile (org.eclipse.core.resources.IFile)187 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)99 PartInitException (org.eclipse.ui.PartInitException)96 IEditorPart (org.eclipse.ui.IEditorPart)64 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)58 IPath (org.eclipse.core.runtime.IPath)57 IEditorInput (org.eclipse.ui.IEditorInput)55 CoreException (org.eclipse.core.runtime.CoreException)51 IResource (org.eclipse.core.resources.IResource)39 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)38 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)37 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)35 SaveAsDialog (org.eclipse.ui.dialogs.SaveAsDialog)35 EObject (org.eclipse.emf.ecore.EObject)33 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)33 HashMap (java.util.HashMap)32 Resource (org.eclipse.emf.ecore.resource.Resource)32 ISelection (org.eclipse.jface.viewers.ISelection)32 URI (org.eclipse.emf.common.util.URI)31