Search in sources :

Example 71 with IStatus

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;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) InputDialog(org.eclipse.jface.dialogs.InputDialog) IPath(org.eclipse.core.runtime.IPath) IWorkspace(org.eclipse.core.resources.IWorkspace) Point(org.eclipse.swt.graphics.Point) IInputValidator(org.eclipse.jface.dialogs.IInputValidator)

Example 72 with IStatus

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);
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) SystemDBOperator(net.heartsome.cat.database.SystemDBOperator) IInputValidator(org.eclipse.jface.dialogs.IInputValidator)

Example 73 with IStatus

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;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 74 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 75 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)

Aggregations

IStatus (org.eclipse.core.runtime.IStatus)1423 Status (org.eclipse.core.runtime.Status)500 CoreException (org.eclipse.core.runtime.CoreException)369 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)270 File (java.io.File)169 IOException (java.io.IOException)154 ArrayList (java.util.ArrayList)141 IPath (org.eclipse.core.runtime.IPath)138 IFile (org.eclipse.core.resources.IFile)130 Job (org.eclipse.core.runtime.jobs.Job)123 MultiStatus (org.eclipse.core.runtime.MultiStatus)113 InvocationTargetException (java.lang.reflect.InvocationTargetException)106 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)85 IProject (org.eclipse.core.resources.IProject)84 List (java.util.List)83 Path (org.eclipse.core.runtime.Path)52 Test (org.junit.Test)52 IResource (org.eclipse.core.resources.IResource)51 SubMonitor (org.eclipse.core.runtime.SubMonitor)51 Composite (org.eclipse.swt.widgets.Composite)44