Search in sources :

Example 16 with IStatus

use of org.eclipse.core.runtime.IStatus in project translationstudio8 by heartsome.

the class NewFolderDialogOfHs method validateFolderName.

/**
		 * Checks if the folder name is valid.
		 *
		 * @return null if the new folder name is valid.
		 * 	a message that indicates the problem otherwise.
		 */
@SuppressWarnings("restriction")
private boolean validateFolderName() {
    String name = folderNameField.getText();
    IWorkspace workspace = container.getWorkspace();
    IStatus nameStatus = workspace.validateName(name, IResource.FOLDER);
    if ("".equals(name)) {
        //$NON-NLS-1$
        updateStatus(IStatus.ERROR, IDEWorkbenchMessages.NewFolderDialog_folderNameEmpty);
        return false;
    }
    if (nameStatus.isOK() == false) {
        updateStatus(nameStatus);
        return false;
    }
    // 修改创建文件夹时,所进行的文件名特殊字符验证	--robert	2013-07-01
    String result = null;
    if ((result = CommonFunction.validResourceName(name)) != null) {
        updateStatus(new ResourceStatus(IResourceStatus.INVALID_VALUE, null, result));
        return false;
    }
    IPath path = new Path(name);
    if (container.getFolder(path).exists() || container.getFile(path).exists()) {
        updateStatus(IStatus.ERROR, NLS.bind(IDEWorkbenchMessages.NewFolderDialog_alreadyExists, name));
        return false;
    }
    //$NON-NLS-1$
    updateStatus(IStatus.OK, "");
    return true;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IStatus(org.eclipse.core.runtime.IStatus) IPath(org.eclipse.core.runtime.IPath) IWorkspace(org.eclipse.core.resources.IWorkspace) ResourceStatus(org.eclipse.core.internal.resources.ResourceStatus) IResourceStatus(org.eclipse.core.resources.IResourceStatus)

Example 17 with IStatus

use of org.eclipse.core.runtime.IStatus in project translationstudio8 by heartsome.

the class ConverterUtils method throwConverterException.

/**
	 * Throw converter exception.
	 * @param plugin
	 *            the plugin
	 * @param message
	 *            the message
	 * @param e
	 *            the e
	 * @throws ConverterException
	 *             the converter exception
	 * @author John Zhu
	 */
public static void throwConverterException(String plugin, String message, Throwable e) throws ConverterException {
    if (e instanceof OperationCanceledException) {
        return;
    }
    IStatus status = new Status(IStatus.ERROR, plugin, IStatus.ERROR, message, e);
    ConverterException ce = new ConverterException(status);
    throw ce;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) ConverterException(net.heartsome.cat.converter.ConverterException) IStatus(org.eclipse.core.runtime.IStatus) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException)

Example 18 with IStatus

use of org.eclipse.core.runtime.IStatus in project translationstudio8 by heartsome.

the class AutomaticUpdate method doUpdate.

private void doUpdate() {
    if (operation == null) {
        return;
    }
    IStatus status = operation.getResolutionResult();
    // user cancelled
    if (status.getSeverity() == IStatus.CANCEL)
        return;
    // Special case those statuses where we would never want to open a wizard
    if (status.getCode() == UpdateOperation.STATUS_NOTHING_TO_UPDATE) {
        return;
    }
    if (getProvisioningUI().getPolicy().continueWorkingWithOperation(operation, getShell())) {
        UpdateWizard wizard = new UpdateWizard(getProvisioningUI(), operation, operation.getSelectedUpdates());
        TSWizardDialog dialog = new TSWizardDialog(getShell(), wizard);
        dialog.create();
        dialog.open();
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) UpdateWizard(net.heartsome.cat.p2update.ui.UpdateWizard) TSWizardDialog(net.heartsome.cat.common.ui.wizard.TSWizardDialog)

Example 19 with IStatus

use of org.eclipse.core.runtime.IStatus in project translationstudio8 by heartsome.

the class ImportProjectWizardPage method createProjects.

/**
	 * Create the selected projects
	 * 
	 * @return boolean <code>true</code> if all project creations were
	 * 	successful.
	 */
public boolean createProjects() {
    saveWidgetValues();
    final Object[] selected = projectsList.getCheckedElements();
    createdProjects = new ArrayList();
    WorkspaceModifyOperation op = new WorkspaceModifyOperation() {

        protected void execute(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            try {
                //$NON-NLS-1$
                monitor.beginTask("", selected.length);
                if (monitor.isCanceled()) {
                    throw new OperationCanceledException();
                }
                for (int i = 0; i < selected.length; i++) {
                    createExistingProject((ProjectRecord) selected[i], new SubProgressMonitor(monitor, 1));
                }
            } finally {
                monitor.done();
            }
        }
    };
    // run the new project creation operation
    try {
        getContainer().run(true, true, op);
    } catch (InterruptedException e) {
        return false;
    } catch (InvocationTargetException e) {
        // one of the steps resulted in a core exception
        Throwable t = e.getTargetException();
        String message = DataTransferMessages.WizardExternalProjectImportPage_errorMessage;
        IStatus status;
        if (t instanceof CoreException) {
            status = ((CoreException) t).getStatus();
        } else {
            status = new Status(IStatus.ERROR, IDEWorkbenchPlugin.IDE_WORKBENCH, 1, message, t);
        }
        ErrorDialog.openError(getShell(), message, null, status);
        return false;
    }
    ArchiveFileManipulations.closeStructureProvider(structureProvider, getShell());
    return true;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) WorkspaceModifyOperation(org.eclipse.ui.actions.WorkspaceModifyOperation) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) ArrayList(java.util.ArrayList) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor) InvocationTargetException(java.lang.reflect.InvocationTargetException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException)

Example 20 with IStatus

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

the class ASTProvider method createAST.

private static CompilationUnit createAST(final ITypeRoot input, final IProgressMonitor progressMonitor) {
    if (progressMonitor != null && progressMonitor.isCanceled())
        return null;
    final ASTParser parser = ASTParser.newParser(SHARED_AST_LEVEL);
    parser.setResolveBindings(true);
    parser.setStatementsRecovery(SHARED_AST_STATEMENT_RECOVERY);
    parser.setBindingsRecovery(SHARED_BINDING_RECOVERY);
    parser.setSource(input);
    if (progressMonitor != null && progressMonitor.isCanceled())
        return null;
    final CompilationUnit[] root = new CompilationUnit[1];
    SafeRunner.run(new ISafeRunnable() {

        public void run() {
            try {
                if (progressMonitor != null && progressMonitor.isCanceled())
                    return;
                root[0] = (CompilationUnit) parser.createAST(progressMonitor);
                //mark as unmodifiable
                ASTNodes.setFlagsToAST(root[0], ASTNode.PROTECT);
            } catch (OperationCanceledException ex) {
                return;
            }
        }

        public void handleException(Throwable ex) {
            //$NON-NLS-1$
            IStatus status = new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IStatus.OK, "Error in JDT Core during AST creation", ex);
            JavaPlugin.getDefault().getLog().log(status);
        }
    });
    return root[0];
}
Also used : CompilationUnit(org.eclipse.jdt.core.dom.CompilationUnit) Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IStatus(org.eclipse.core.runtime.IStatus) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) ISafeRunnable(org.eclipse.core.runtime.ISafeRunnable) ASTParser(org.eclipse.jdt.core.dom.ASTParser)

Aggregations

IStatus (org.eclipse.core.runtime.IStatus)417 Status (org.eclipse.core.runtime.Status)195 CoreException (org.eclipse.core.runtime.CoreException)103 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)81 IOException (java.io.IOException)48 ArrayList (java.util.ArrayList)46 File (java.io.File)40 InvocationTargetException (java.lang.reflect.InvocationTargetException)39 ITask (com.cubrid.common.core.task.ITask)37 Job (org.eclipse.core.runtime.jobs.Job)32 IFile (org.eclipse.core.resources.IFile)31 TaskJobExecutor (com.cubrid.common.ui.spi.progress.TaskJobExecutor)29 IPath (org.eclipse.core.runtime.IPath)29 List (java.util.List)23 IResource (org.eclipse.core.resources.IResource)22 MultiStatus (org.eclipse.core.runtime.MultiStatus)22 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)19 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)19 IJobChangeEvent (org.eclipse.core.runtime.jobs.IJobChangeEvent)18 InputStream (java.io.InputStream)17