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;
}
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;
}
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();
}
}
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;
}
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];
}
Aggregations