Search in sources :

Example 66 with CoreException

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

the class ContributionContextTypeRegistry method createResolver.

private static TemplateVariableResolver createResolver(IConfigurationElement element) throws CoreException {
    try {
        String type = element.getAttribute(TYPE);
        if (type != null) {
            TemplateVariableResolver resolver = (TemplateVariableResolver) element.createExecutableExtension(CLASS);
            resolver.setType(type);
            String desc = element.getAttribute(DESCRIPTION);
            //$NON-NLS-1$
            resolver.setDescription(desc == null ? "" : desc);
            return resolver;
        }
    } catch (ClassCastException e) {
        //$NON-NLS-1$
        throw new CoreException(new Status(IStatus.ERROR, "org.eclipse.ui.editors", IStatus.OK, "extension does not implement " + TemplateVariableResolver.class.getName(), e));
    }
    return null;
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) CoreException(org.eclipse.core.runtime.CoreException) TemplateVariableResolver(org.eclipse.jface.text.templates.TemplateVariableResolver)

Example 67 with CoreException

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

the class ContributionContextTypeRegistry method createContextType.

/**
	 * Tries to create a context type given an id. Contributions to the
	 * <code>org.eclipse.ui.editors.templates</code> extension point are
	 * searched for the given identifier and the specified context type
	 * instantiated if it is found. Any contributed
	 * {@link org.eclipse.jface.text.templates.TemplateVariableResolver}s
	 * are also instantiated and added to the context type.
	 *
	 * @param id the id for the context type as specified in XML
	 * @return the instantiated and configured context type, or
	 *         <code>null</code> if it is not found or cannot be instantiated
	 */
public static TemplateContextType createContextType(String id) {
    Assert.isNotNull(id);
    IConfigurationElement[] extensions = getTemplateExtensions();
    TemplateContextType type;
    try {
        type = createContextType(extensions, id);
        if (type != null) {
            TemplateVariableResolver[] resolvers = createResolvers(extensions, id);
            for (int i = 0; i < resolvers.length; i++) type.addResolver(resolvers[i]);
        }
    } catch (CoreException e) {
        JavaPlugin.log(e);
        type = null;
    }
    return type;
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) TemplateContextType(org.eclipse.jface.text.templates.TemplateContextType) TemplateVariableResolver(org.eclipse.jface.text.templates.TemplateVariableResolver)

Example 68 with CoreException

use of org.eclipse.core.runtime.CoreException in project jop by jop-devel.

the class JOPBoardConfigurationTab method updateQuartusProjectLocationFromConfig.

/**
     * @param configuration
     */
protected void updateQuartusProjectLocationFromConfig(ILaunchConfiguration configuration) {
    String qproj = IJOPUIConstants.EMPTY_STRING;
    try {
        qproj = configuration.getAttribute(IJOPLaunchConfigurationConstants.ATTR_QUARTUS_PROJECT, IJOPUIConstants.EMPTY_STRING);
    } catch (CoreException e) {
        setErrorMessage(e.getStatus().getMessage());
    }
    fQuartusProjectLocation = new Path(qproj);
    fQuartusProjectText.setText(fQuartusProjectLocation.toOSString());
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) CoreException(org.eclipse.core.runtime.CoreException)

Example 69 with CoreException

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

the class CUCorrectionProposal method apply.

/* (non-Javadoc)
	 * @see org.eclipse.jface.text.contentassist.ICompletionProposal#apply(org.eclipse.jface.text.IDocument)
	 */
@Override
public void apply(IDocument document) {
    try {
        ICompilationUnit unit = getCompilationUnit();
        //			IEditorPart part= null;
        if (unit.getResource().exists()) {
            boolean canEdit = performValidateEdit(unit);
            if (!canEdit) {
                return;
            }
        //				part= EditorUtility.isOpenInEditor(unit);
        //				if (part == null) {
        //					part= JavaUI.openInEditor(unit);
        //					if (part != null) {
        //						fSwitchedEditor= true;
        //						document= JavaUI.getDocumentProvider().getDocument(part.getEditorInput());
        //					}
        //				}
        //				IWorkbenchPage page= JavaPlugin.getActivePage();
        //				if (page != null && part != null) {
        //					page.bringToTop(part);
        //				}
        //				if (part != null) {
        //					part.setFocus();
        //				}
        }
        performChange(/*part, */
        document);
    } catch (CoreException e) {
        //			ExceptionHandler.handle(e, CorrectionMessages.CUCorrectionProposal_error_title, CorrectionMessages.CUCorrectionProposal_error_message);
        JavaPlugin.log(e);
    }
}
Also used : ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) CoreException(org.eclipse.core.runtime.CoreException)

Example 70 with CoreException

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

the class RenameSupport method perform.

//	/**
//	 * Opens the refactoring dialog for this rename support.
//	 *
//	 * @param parent a shell used as a parent for the refactoring dialog.
//	 * @throws CoreException if an unexpected exception occurs while opening the
//	 * dialog.
//	 *
//	 * @see #openDialog(Shell, boolean)
//	 */
//	public void openDialog(Shell parent) throws CoreException {
//		openDialog(parent, false);
//	}
//
//	/**
//	 * Opens the refactoring dialog for this rename support.
//	 *
//	 * <p>
//	 * This method has to be called from within the UI thread.
//	 * </p>
//	 *
//	 * @param parent a shell used as a parent for the refactoring, preview, or error dialog
//	 * @param showPreviewOnly if <code>true</code>, the dialog skips all user input pages and
//	 * directly shows the preview or error page. Otherwise, shows all pages.
//	 * @return <code>true</code> if the refactoring has been executed successfully,
//	 * <code>false</code> if it has been canceled or if an error has happened during
//	 * initial conditions checking.
//	 *
//	 * @throws CoreException if an error occurred while executing the
//	 * operation.
//	 *
//	 * @see #openDialog(Shell)
//	 * @since 3.3
//	 */
//	public boolean openDialog(Shell parent, boolean showPreviewOnly) throws CoreException {
//		ensureChecked();
//		if (fPreCheckStatus.hasFatalError()) {
//			showInformation(parent, fPreCheckStatus);
//			return false;
//		}
//
//		UserInterfaceStarter starter;
//		if (!showPreviewOnly) {
//			starter = RenameUserInterfaceManager.getDefault().getStarter(fRefactoring);
//		} else {
//			starter = new RenameUserInterfaceStarter();
//			RenameRefactoringWizard wizard = new RenameRefactoringWizard(fRefactoring, fRefactoring.getName(), null, null, null) {
//				@Override
//				protected void addUserInputPages() {
//					// nothing to add
//				}
//			};
//			wizard.setForcePreviewReview(showPreviewOnly);
//			starter.initialize(wizard);
//		}
//		return starter.activate(fRefactoring, parent, getJavaRenameProcessor().getSaveMode());
//	}
//
/**
	 * Executes the rename refactoring without showing a dialog to gather
	 * additional user input (for example the new name of the <tt>IJavaElement</tt>).
	 * Only an error dialog is shown (if necessary) to present the result
	 * of the refactoring's full precondition checking.
	 * <p>
	 * The method has to be called from within the UI thread.
	 * </p>
	 *
	 *
	 * @throws InterruptedException if the operation has been canceled by the
	 * user.
	 * @throws InvocationTargetException if an error occurred while executing the
	 * operation.
	 */
public RefactoringStatus perform() throws InterruptedException, InvocationTargetException {
    try {
        ensureChecked();
        if (fPreCheckStatus.hasFatalError()) {
            return fPreCheckStatus;
        }
        RefactoringExecutionHelper helper = new RefactoringExecutionHelper(fRefactoring, RefactoringCore.getConditionCheckingFailedSeverity(), getJavaRenameProcessor().getSaveMode());
        RefactoringStatus status = helper.perform(true, true);
        fPerformChangeOperation = helper.getfPerformChangeOperation();
        return status;
    } catch (CoreException e) {
        throw new InvocationTargetException(e);
    }
}
Also used : RefactoringExecutionHelper(org.eclipse.jdt.internal.ui.refactoring.RefactoringExecutionHelper) CoreException(org.eclipse.core.runtime.CoreException) RefactoringStatus(org.eclipse.ltk.core.refactoring.RefactoringStatus) InvocationTargetException(java.lang.reflect.InvocationTargetException)

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