Search in sources :

Example 66 with IStatus

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

the class TermDbManagerDialog method createNewDatabase.

/**
	 * 创建新库 ;
	 */
private void createNewDatabase() {
    // 数据库连接参数输入合法性检查
    IStatus status = validator();
    if (status.getSeverity() != IStatus.OK) {
        MessageDialog.openInformation(getShell(), Messages.getString("dialog.TermDbManagerDialog.msgTitle"), status.getMessage());
        return;
    }
    SystemDBOperator sysDbOp = getCurrSysDbOp();
    if (sysDbOp == null) {
        return;
    }
    // 连接检查
    if (!sysDbOp.checkDbConnection()) {
        MessageDialog.openInformation(getShell(), Messages.getString("dialog.TermDbManagerDialog.msgTitle"), Messages.getString("dialog.TermDbManagerDialog.msg1"));
        return;
    }
    TermDbNameInputDialog inputDbNameialog = new TermDbNameInputDialog(getShell(), Messages.getString("dialog.TermDbManagerDialog.inputDbNameialogTitle"), Messages.getString("dialog.TermDbManagerDialog.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 67 with IStatus

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

the class OpenMessageUtils method openMessageWithReason.

/**
	 * 弹出错误或警告对话框,需要提供错误或警告的文本原因信息
	 * @param severity
	 *            必须是<code>IStatus.ERROR<code>,<code>IStatus.WARNING<code>
	 * @param message
	 *            错误、警告的文本信息,不能为null或空串;
	 * @param reasonMsg
	 *            错误或警告的文本原因信息,不能为null或空串;
	 */
public static void openMessageWithReason(int severity, String message, String reasonMsg) {
    Assert.isLegal(severity == IStatus.ERROR || severity == IStatus.WARNING);
    Assert.isLegal(message != null && message.length() > 0);
    IStatus status = getIStatus(severity, reasonMsg);
    String title = getMessageDlgTitle(severity);
    if (title == null) {
        return;
    }
    ErrorDialog.openError(new Shell(Display.getDefault()), title, message, status);
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Shell(org.eclipse.swt.widgets.Shell)

Example 68 with IStatus

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

the class OpenMessageUtils method openErrorMsgWithDetail.

/**
	 * 弹出错误或警告对话框,需要提供错误或警告的文本原因信息以及详细的异常<code>Throwable<code>
	 * @param message
	 *            错误或警告的文本信息,不能为null或空串
	 * @param reasonMsg
	 *            错误、警告的文本原因信息,不能为null或空串
	 * @param throwable
	 *            <code>Throwable<code> 对象,错误或警告的详细异常信息;
	 */
public static void openErrorMsgWithDetail(String message, String reasonMsg, Throwable throwable) {
    Assert.isLegal(message != null && message.length() > 0);
    Assert.isLegal(reasonMsg != null && reasonMsg.length() > 0);
    Assert.isLegal(throwable != null);
    IStatus status = throwable2MultiStatus(reasonMsg, throwable);
    String title = getMessageDlgTitle(IStatus.ERROR);
    if (title == null) {
        return;
    }
    ErrorDialog.openError(new Shell(Display.getDefault()), title, message, status);
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Shell(org.eclipse.swt.widgets.Shell)

Example 69 with IStatus

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

the class ResourceDropAdapterAssistant method handleDrop.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ui.navigator.CommonDropAdapterAssistant#handleDrop(CommonDropAdapter,
	 *      DropTargetEvent, Object)
	 */
public IStatus handleDrop(CommonDropAdapter aDropAdapter, DropTargetEvent aDropTargetEvent, Object aTarget) {
    if (Policy.DEBUG_DND) {
        System.out.println(//$NON-NLS-1$
        "ResourceDropAdapterAssistant.handleDrop (begin)");
    }
    // alwaysOverwrite = false;
    if (aTarget == null || aDropTargetEvent.data == null) {
        return Status.CANCEL_STATUS;
    }
    IStatus status = null;
    IResource[] resources = null;
    TransferData currentTransfer = aDropAdapter.getCurrentTransfer();
    if (LocalSelectionTransfer.getTransfer().isSupportedType(currentTransfer)) {
        resources = getSelectedResources();
    } else if (ResourceTransfer.getInstance().isSupportedType(currentTransfer)) {
        resources = (IResource[]) aDropTargetEvent.data;
    }
    if (FileTransfer.getInstance().isSupportedType(currentTransfer)) {
        status = performFileDrop(aDropAdapter, aDropTargetEvent.data);
    } else if (resources != null && resources.length > 0) {
        if ((aDropAdapter.getCurrentOperation() == DND.DROP_COPY) || (aDropAdapter.getCurrentOperation() == DND.DROP_LINK)) {
            if (Policy.DEBUG_DND) {
                System.out.println(//$NON-NLS-1$
                "ResourceDropAdapterAssistant.handleDrop executing COPY.");
            }
            status = performResourceCopy(aDropAdapter, getShell(), resources);
        } else {
            if (Policy.DEBUG_DND) {
                System.out.println(//$NON-NLS-1$
                "ResourceDropAdapterAssistant.handleDrop executing MOVE.");
            }
            status = performResourceMove(aDropAdapter, resources);
        }
    }
    openError(status);
    IContainer target = getActualTarget((IResource) aTarget);
    if (target != null && target.isAccessible()) {
        try {
            target.refreshLocal(IResource.DEPTH_ONE, null);
        } catch (CoreException e) {
        }
    }
    return status;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) CoreException(org.eclipse.core.runtime.CoreException) TransferData(org.eclipse.swt.dnd.TransferData) IContainer(org.eclipse.core.resources.IContainer) IResource(org.eclipse.core.resources.IResource)

Example 70 with IStatus

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

the class ResourceMgmtActionProvider method makeActions.

protected void makeActions() {
    IShellProvider sp = new IShellProvider() {

        public Shell getShell() {
            return shell;
        }
    };
    openProjectAction = new OpenResourceAction(sp);
    openProjectAction.setText(WorkbenchNavigatorMessages.actions_ResourceMgmtActionProvider_openProjectAction);
    closeProjectAction = new CloseResourceAction(sp);
    closeProjectAction.setText(WorkbenchNavigatorMessages.actions_ResourceMgmtActionProvider_closeProjectAction);
    //
    // closeUnrelatedProjectsAction = new CloseUnrelatedProjectsAction(sp);
    // closeUnrelatedProjectsAction.setText("关闭无关的项目");
    refreshAction = new RefreshAction(sp) {

        public void run() {
            final IStatus[] errorStatus = new IStatus[1];
            errorStatus[0] = Status.OK_STATUS;
            final WorkspaceModifyOperation op = (WorkspaceModifyOperation) createOperation(errorStatus);
            WorkspaceJob job = new //$NON-NLS-1$
            WorkspaceJob(//$NON-NLS-1$
            "refresh") {

                public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
                    try {
                        op.run(monitor);
                        if (shell != null && !shell.isDisposed()) {
                            shell.getDisplay().asyncExec(new Runnable() {

                                public void run() {
                                    StructuredViewer viewer = getActionSite().getStructuredViewer();
                                    if (viewer != null && viewer.getControl() != null && !viewer.getControl().isDisposed()) {
                                        viewer.refresh();
                                    }
                                }
                            });
                        }
                    } catch (InvocationTargetException e) {
                        String msg = NLS.bind(WorkbenchNavigatorMessages.actions_ResourceMgmtActionProvider_logTitle, getClass().getName(), e.getTargetException());
                        throw new CoreException(new Status(IStatus.ERROR, NavigatorPlugin.PLUGIN_ID, IStatus.ERROR, msg, e.getTargetException()));
                    } catch (InterruptedException e) {
                        return Status.CANCEL_STATUS;
                    }
                    return errorStatus[0];
                }
            };
            ISchedulingRule rule = op.getRule();
            if (rule != null) {
                job.setRule(rule);
            }
            job.setUser(true);
            job.schedule();
        }
    };
    refreshAction.setText(WorkbenchNavigatorMessages.actions_ResourceMgmtActionProvider_refreshAction);
    //$NON-NLS-1$
    refreshAction.setDisabledImageDescriptor(getImageDescriptor("dlcl16/refresh_nav.gif"));
    //$NON-NLS-1$
    refreshAction.setImageDescriptor(getImageDescriptor("elcl16/refresh_nav.gif"));
    refreshAction.setActionDefinitionId(IWorkbenchCommandConstants.FILE_REFRESH);
    if (getContext() == null) {
        refreshAction.setEnabled(false);
    } else {
        IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
        refreshAction.selectionChanged(selection);
        refreshAction.setEnabled(!selection.isEmpty());
    }
// buildAction = new BuildAction(sp, IncrementalProjectBuilder.INCREMENTAL_BUILD);
// buildAction.setActionDefinitionId(IWorkbenchCommandConstants.PROJECT_BUILD_PROJECT);
}
Also used : IShellProvider(org.eclipse.jface.window.IShellProvider) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) CloseResourceAction(org.eclipse.ui.actions.CloseResourceAction) IStatus(org.eclipse.core.runtime.IStatus) WorkspaceModifyOperation(org.eclipse.ui.actions.WorkspaceModifyOperation) WorkspaceJob(org.eclipse.core.resources.WorkspaceJob) OpenResourceAction(org.eclipse.ui.actions.OpenResourceAction) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) InvocationTargetException(java.lang.reflect.InvocationTargetException) ISchedulingRule(org.eclipse.core.runtime.jobs.ISchedulingRule) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) RefreshAction(org.eclipse.ui.actions.RefreshAction) CoreException(org.eclipse.core.runtime.CoreException) StructuredViewer(org.eclipse.jface.viewers.StructuredViewer)

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