use of org.eclipse.core.runtime.IStatus in project translationstudio8 by heartsome.
the class RenameResourceAndCloseEditorAction method queryNewResourceName.
/**
* Return the new name to be given to the target resource.
*
* @return java.lang.String
* @param resource
* the resource to query status on
*/
protected String queryNewResourceName(final IResource resource) {
final IWorkspace workspace = IDEWorkbenchPlugin.getPluginWorkspace();
final IPath prefix = resource.getFullPath().removeLastSegments(1);
IInputValidator validator = new IInputValidator() {
public String isValid(String string) {
if (resource.getName().equals(string)) {
return IDEWorkbenchMessages.RenameResourceAction_nameMustBeDifferent;
}
IStatus status = workspace.validateName(string, resource.getType());
if (!status.isOK()) {
return status.getMessage();
}
if (workspace.getRoot().exists(prefix.append(string))) {
return IDEWorkbenchMessages.RenameResourceAction_nameExists;
}
return null;
}
};
InputDialog dialog = new InputDialog(shellProvider.getShell(), IDEWorkbenchMessages.RenameResourceAction_inputDialogTitle, IDEWorkbenchMessages.RenameResourceAction_inputDialogMessage, resource.getName(), validator);
dialog.setBlockOnOpen(true);
int result = dialog.open();
if (result == Window.OK)
return dialog.getValue();
return null;
}
use of org.eclipse.core.runtime.IStatus in project translationstudio8 by heartsome.
the class TmDbManagerDialog method createNewDatabase.
/**
* 创建新库 ;
*/
private void createNewDatabase() {
// 数据库连接参数输入合法性检查
IStatus status = validator();
if (status.getSeverity() != IStatus.OK) {
MessageDialog.openInformation(getShell(), Messages.getString("dialog.TmDbManagerDialog.msgTitle"), status.getMessage());
return;
}
SystemDBOperator sysDbOp = getCurrSysDbOp();
if (sysDbOp == null) {
return;
}
// 连接检查
if (!sysDbOp.checkDbConnection()) {
MessageDialog.openInformation(getShell(), Messages.getString("dialog.TmDbManagerDialog.msgTitle"), Messages.getString("dialog.TmDbManagerDialog.msg1"));
return;
}
DatabaseNameInputDialog inputDbNameialog = new DatabaseNameInputDialog(getShell(), Messages.getString("dialog.TmDbManagerDialog.inputDbNameialogTitle"), Messages.getString("dialog.TmDbManagerDialog.inputDbNameialogMsg"), "", new IInputValidator() {
public String isValid(String newText) {
String vRs = DbValidator.valiateDbName(newText);
return vRs;
}
});
inputDbNameialog.setSystemDbOp(sysDbOp);
if (inputDbNameialog.open() == Window.OK) {
// 刷新界面
executeSearch(sysDbOp);
}
}
use of org.eclipse.core.runtime.IStatus in project translationstudio8 by heartsome.
the class WizardFileSystemResourceExportPage2 method executeExportOperation.
/**
* Set up and execute the passed Operation. Answer a boolean indicating success.
* @return boolean
*/
protected boolean executeExportOperation(FileSystemExportOperation op) {
op.setCreateLeadupStructure(true);
op.setOverwriteFiles(overwriteExistingFilesCheckbox.getSelection());
try {
getContainer().run(true, true, op);
} catch (InterruptedException e) {
return false;
} catch (InvocationTargetException e) {
displayErrorDialog(e.getTargetException());
return false;
}
IStatus status = op.getStatus();
if (!status.isOK()) {
// no
ErrorDialog.openError(// no
getContainer().getShell(), // no
DataTransferMessages.DataTransfer_exportProblems, // no
null, // message
status);
return false;
}
return true;
}
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;
}
Aggregations