Search in sources :

Example 41 with CoreException

use of org.eclipse.core.runtime.CoreException in project flux by eclipse.

the class ASTRewriteCorrectionProposal method addEdits.

/* (non-Javadoc)
	 * @see org.eclipse.jdt.internal.ui.text.correction.CUCorrectionProposal#addEdits(org.eclipse.jface.text.IDocument)
	 */
@Override
protected void addEdits(IDocument document, TextEdit editRoot) throws CoreException {
    super.addEdits(document, editRoot);
    ASTRewrite rewrite = getRewrite();
    if (rewrite != null) {
        try {
            TextEdit edit = rewrite.rewriteAST();
            editRoot.addChild(edit);
        } catch (IllegalArgumentException e) {
            throw new CoreException(JavaUIStatus.createError(IStatus.ERROR, e));
        }
    }
    if (fImportRewrite != null) {
        editRoot.addChild(fImportRewrite.rewriteImports(new NullProgressMonitor()));
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) TextEdit(org.eclipse.text.edits.TextEdit) ASTRewrite(org.eclipse.jdt.core.dom.rewrite.ASTRewrite)

Example 42 with CoreException

use of org.eclipse.core.runtime.CoreException in project flux by eclipse.

the class CUCorrectionProposal method getAdditionalProposalInfo.

@Override
public Object getAdditionalProposalInfo(IProgressMonitor monitor) {
    StringBuffer buf = new StringBuffer();
    try {
        TextChange change = getTextChange();
        change.setKeepPreviewEdits(true);
        IDocument previewDocument = change.getPreviewDocument(monitor);
        TextEdit rootEdit = change.getPreviewEdit(change.getEdit());
        EditAnnotator ea = new EditAnnotator(buf, previewDocument);
        rootEdit.accept(ea);
        // Final pre-existing region
        ea.unchangedUntil(previewDocument.getLength());
    } catch (CoreException e) {
        JavaPlugin.log(e);
    }
    return buf.toString();
}
Also used : EditAnnotator(org.eclipse.jdt.internal.ui.text.correction.proposals.EditAnnotator) CoreException(org.eclipse.core.runtime.CoreException) MultiTextEdit(org.eclipse.text.edits.MultiTextEdit) TextEdit(org.eclipse.text.edits.TextEdit) TextChange(org.eclipse.ltk.core.refactoring.TextChange) IDocument(org.eclipse.jface.text.IDocument)

Example 43 with CoreException

use of org.eclipse.core.runtime.CoreException in project flux by eclipse.

the class ChangeCorrectionProposal method getAdditionalProposalInfo.

/*
	 * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension5#getAdditionalProposalInfo(org.eclipse.core.runtime.IProgressMonitor)
	 */
public Object getAdditionalProposalInfo(IProgressMonitor monitor) {
    StringBuffer buf = new StringBuffer();
    //$NON-NLS-1$
    buf.append("<p>");
    try {
        Change change = getChange();
        if (change != null) {
            String name = change.getName();
            if (name.length() == 0) {
                return null;
            }
            buf.append(name);
        } else {
            return null;
        }
    } catch (CoreException e) {
        //$NON-NLS-1$
        buf.append("Unexpected error when accessing this proposal:<p><pre>");
        buf.append(e.getLocalizedMessage());
        //$NON-NLS-1$
        buf.append("</pre>");
    }
    //$NON-NLS-1$
    buf.append("</p>");
    return buf.toString();
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) NullChange(org.eclipse.ltk.core.refactoring.NullChange) Change(org.eclipse.ltk.core.refactoring.Change) StyledString(org.eclipse.jface.viewers.StyledString)

Example 44 with CoreException

use of org.eclipse.core.runtime.CoreException in project flux by eclipse.

the class ContributionContextTypeRegistry method createContextType.

private static TemplateContextType createContextType(IConfigurationElement element) throws CoreException {
    String id = element.getAttribute(ID);
    try {
        TemplateContextType contextType = (TemplateContextType) element.createExecutableExtension(CLASS);
        String name = element.getAttribute(NAME);
        if (name == null)
            name = id;
        if (contextType.getId() == null)
            contextType.setId(id);
        if (contextType.getName() == null)
            contextType.setName(name);
        return contextType;
    } catch (ClassCastException e) {
        //$NON-NLS-1$
        throw new CoreException(new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK, "extension does not implement " + TemplateContextType.class.getName(), e));
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) CoreException(org.eclipse.core.runtime.CoreException) TemplateContextType(org.eclipse.jface.text.templates.TemplateContextType)

Example 45 with CoreException

use of org.eclipse.core.runtime.CoreException in project flux by eclipse.

the class InitializeServiceEnvironment method initializeProject.

private void initializeProject(String projectName) {
    try {
        // already connected project
        if (repository.isConnected(projectName))
            return;
        // project doesn't exist in workspace
        DownloadProject downloadProject = new DownloadProject(messagingConnector, projectName, repository.getUsername());
        downloadProject.run(new CompletionCallback() {

            @Override
            public void downloadFailed() {
            }

            @Override
            public void downloadComplete(IProject downloadedProject) {
                try {
                    downloadedProject.build(IncrementalProjectBuilder.FULL_BUILD, null);
                } catch (CoreException e) {
                    e.printStackTrace();
                }
                repository.addProject(downloadedProject);
            }
        });
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) CompletionCallback(org.eclipse.flux.core.DownloadProject.CompletionCallback) DownloadProject(org.eclipse.flux.core.DownloadProject) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) JSONException(org.json.JSONException)

Aggregations

CoreException (org.eclipse.core.runtime.CoreException)987 IStatus (org.eclipse.core.runtime.IStatus)264 Status (org.eclipse.core.runtime.Status)240 IFile (org.eclipse.core.resources.IFile)176 IOException (java.io.IOException)174 IProject (org.eclipse.core.resources.IProject)133 IResource (org.eclipse.core.resources.IResource)132 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)128 IPath (org.eclipse.core.runtime.IPath)126 ArrayList (java.util.ArrayList)125 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)100 File (java.io.File)95 InvocationTargetException (java.lang.reflect.InvocationTargetException)95 InputStream (java.io.InputStream)76 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)67 Path (org.eclipse.core.runtime.Path)61 ByteArrayInputStream (java.io.ByteArrayInputStream)54 IWorkspace (org.eclipse.core.resources.IWorkspace)53 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)52 IFileStore (org.eclipse.core.filesystem.IFileStore)51