Search in sources :

Example 6 with IFileEditorInput

use of org.eclipse.ui.IFileEditorInput in project bndtools by bndtools.

the class PrivatePackagesPart method getJavaProject.

private IJavaProject getJavaProject() {
    IFormPage page = (IFormPage) getManagedForm().getContainer();
    IEditorInput input = page.getEditorInput();
    if (!IFileEditorInput.class.isInstance(input)) {
        return null;
    }
    IProject project = ((IFileEditorInput) input).getFile().getProject();
    return JavaCore.create(project);
}
Also used : IFileEditorInput(org.eclipse.ui.IFileEditorInput) IFormPage(org.eclipse.ui.forms.editor.IFormPage) IEditorInput(org.eclipse.ui.IEditorInput) IProject(org.eclipse.core.resources.IProject)

Example 7 with IFileEditorInput

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

the class QuickOutline method handleMultiView.

protected void handleMultiView() {
    currentScope = currentScope.next();
    SwaggerFileFinder fileFinder = new SwaggerFileFinder(fileContentType);
    IEditorInput input = editor.getEditorInput();
    IFile currentFile = null;
    if (input instanceof IFileEditorInput) {
        currentFile = ((IFileEditorInput) input).getFile();
    }
    Iterable<IFile> files = fileFinder.collectFiles(currentScope, currentFile);
    setInfoText(statusMessage());
    if (currentScope == Scope.LOCAL) {
        treeViewer.setAutoExpandLevel(2);
    } else {
        treeViewer.setAutoExpandLevel(0);
    }
    setInput(Model.parseYaml(files, getSchema()));
}
Also used : SwaggerFileFinder(com.reprezen.swagedit.core.utils.SwaggerFileFinder) IFile(org.eclipse.core.resources.IFile) IFileEditorInput(org.eclipse.ui.IFileEditorInput) IEditorInput(org.eclipse.ui.IEditorInput)

Example 8 with IFileEditorInput

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

the class CpuDumpEditor method init.

/*
     * @see MultiPageEditorPart#init(IEditorSite, IEditorInput)
     */
@Override
public void init(IEditorSite site, IEditorInput input) throws PartInitException {
    super.init(site, input);
    cpuModel = new CpuModelFactory().createCpuModel();
    cpuModel.addModelChangeListener(new ICpuModelChangeListener() {

        @Override
        public void modelChanged(CpuModelEvent event) {
            if (event.state == CpuModelState.CallersCalleesTargetChanged) {
                refresh();
                if (cpuModel.getCallersCalleesTarget() != null) {
                    showCallerCalleeTab();
                }
            }
        }
    });
    setPartName(input.getName());
    if (input instanceof IFileEditorInput) {
        String filePath = ((IFileEditorInput) input).getFile().getRawLocation().toOSString();
        loadDumpFile(filePath);
    } else if (input instanceof FileStoreEditorInput) {
        String filePath = ((FileStoreEditorInput) input).getURI().getPath();
        loadDumpFile(filePath);
    }
}
Also used : ICpuModelChangeListener(org.talend.designer.runtime.visualization.internal.core.cpu.ICpuModelChangeListener) IFileEditorInput(org.eclipse.ui.IFileEditorInput) CpuModelFactory(org.talend.designer.runtime.visualization.internal.core.cpu.CpuModelFactory) CpuModelEvent(org.talend.designer.runtime.visualization.internal.core.cpu.CpuModelEvent) FileStoreEditorInput(org.eclipse.ui.ide.FileStoreEditorInput)

Example 9 with IFileEditorInput

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

the class InfoPage method doSave.

/**
     * Saves the changed editor contents.
     * 
     * @param monitor The progress monitor
     */
protected void doSave(IProgressMonitor monitor) {
    IEditorInput input = editor.getEditorInput();
    IFile resourceFile = null;
    File file = null;
    InputStream inputStream = null;
    String comments = commentsText.getText();
    try {
        if (input instanceof IFileEditorInput) {
            resourceFile = ((IFileEditorInput) input).getFile();
            inputStream = new BufferedInputStream(resourceFile.getContents());
            file = resourceFile.getRawLocation().toFile();
        } else if (input instanceof FileStoreEditorInput) {
            file = new File(((FileStoreEditorInput) input).getURI().getPath());
            inputStream = new FileInputStream(file);
        } else {
            return;
        }
        Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(inputStream);
        Element root = document.getDocumentElement();
        //$NON-NLS-1$
        root.setAttribute("comments", comments);
        DOMSource source = new DOMSource(root);
        StreamResult result = new StreamResult(file);
        TransformerFactory.newInstance().newTransformer().transform(source, result);
        if (resourceFile != null) {
            resourceFile.refreshLocal(0, monitor);
        }
        lastComments = comments;
        editor.firePropertyChange(IEditorPart.PROP_DIRTY);
    } catch (CoreException e) {
        Activator.log(IStatus.ERROR, Messages.saveFileFailedMsg, e);
    } catch (SAXException e) {
        Activator.log(IStatus.ERROR, Messages.saveFileFailedMsg, e);
    } catch (IOException e) {
        Activator.log(IStatus.ERROR, Messages.saveFileFailedMsg, e);
    } catch (ParserConfigurationException e) {
        Activator.log(IStatus.ERROR, Messages.saveFileFailedMsg, e);
    } catch (TransformerException e) {
        Activator.log(IStatus.ERROR, Messages.saveFileFailedMsg, e);
    } finally {
        if (inputStream != null) {
            try {
                inputStream.close();
            } catch (IOException e) {
            // do nothing
            }
        }
    }
}
Also used : DOMSource(javax.xml.transform.dom.DOMSource) IFile(org.eclipse.core.resources.IFile) StreamResult(javax.xml.transform.stream.StreamResult) BufferedInputStream(java.io.BufferedInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) Element(org.w3c.dom.Element) IOException(java.io.IOException) Document(org.w3c.dom.Document) FileInputStream(java.io.FileInputStream) SAXException(org.xml.sax.SAXException) CoreException(org.eclipse.core.runtime.CoreException) BufferedInputStream(java.io.BufferedInputStream) IFileEditorInput(org.eclipse.ui.IFileEditorInput) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) IFile(org.eclipse.core.resources.IFile) File(java.io.File) IEditorInput(org.eclipse.ui.IEditorInput) FileStoreEditorInput(org.eclipse.ui.ide.FileStoreEditorInput) TransformerException(javax.xml.transform.TransformerException)

Example 10 with IFileEditorInput

use of org.eclipse.ui.IFileEditorInput in project bndtools by bndtools.

the class BndEditor method getFileAndProject.

static Pair<String, String> getFileAndProject(IEditorInput input) {
    String path;
    String projectName;
    if (input instanceof IFileEditorInput) {
        IFile file = ((IFileEditorInput) input).getFile();
        path = file.getProjectRelativePath().toString();
        projectName = file.getProject().getName();
    } else {
        path = input.getName();
        projectName = null;
    }
    return Pair.newInstance(path, projectName);
}
Also used : IFile(org.eclipse.core.resources.IFile) IFileEditorInput(org.eclipse.ui.IFileEditorInput)

Aggregations

IFileEditorInput (org.eclipse.ui.IFileEditorInput)10 IFile (org.eclipse.core.resources.IFile)8 IEditorInput (org.eclipse.ui.IEditorInput)8 IOException (java.io.IOException)2 InputStream (java.io.InputStream)2 CoreException (org.eclipse.core.runtime.CoreException)2 IDocument (org.eclipse.jface.text.IDocument)2 PartInitException (org.eclipse.ui.PartInitException)2 FileStoreEditorInput (org.eclipse.ui.ide.FileStoreEditorInput)2 Model (com.reprezen.swagedit.core.model.Model)1 SwaggerFileFinder (com.reprezen.swagedit.core.utils.SwaggerFileFinder)1 BufferedInputStream (java.io.BufferedInputStream)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 Method (java.lang.reflect.Method)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 TransformerException (javax.xml.transform.TransformerException)1 DOMSource (javax.xml.transform.dom.DOMSource)1 StreamResult (javax.xml.transform.stream.StreamResult)1 NullDocumentListener (net.vtst.ow.eclipse.js.closure.util.listeners.NullDocumentListener)1