Search in sources :

Example 76 with NullProgressMonitor

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

the class ImportAbstract method doImport.

/**
	 * 导入文件内容
	 * @param fileContent
	 * @param srcLang
	 * @param monitor
	 * @return ;
	 * @throws ImportException
	 */
public int doImport(String fileContent, String srcLang, IProgressMonitor monitor) throws ImportException {
    if (monitor == null) {
        this.monitor = new NullProgressMonitor();
    } else {
        this.monitor = monitor;
    }
    // 解析文件
    String message = "";
    VTDGen vg = new VTDGen();
    vg.setDoc(fileContent.getBytes());
    try {
        vg.parse(true);
    } catch (EncodingException e) {
        logger.error(Messages.getString("document.ImportAbstract.logger1"), e);
        message = Messages.getString("document.ImportAbstract.msg1");
        throw new ImportException(message + e.getMessage());
    } catch (EOFException e) {
        logger.error("", e);
        message = Messages.getString("document.ImportAbstract.tbx.msg1");
        throw new ImportException(message + e.getMessage());
    } catch (EntityException e) {
        logger.error("", e);
        message = Messages.getString("document.ImportAbstract.tbx.msg1");
        throw new ImportException(message + e.getMessage());
    } catch (ParseException e) {
        logger.error(Messages.getString("document.ImportAbstract.logger3"), e);
        String errMsg = e.getMessage();
        if (errMsg.indexOf("invalid encoding") != -1) {
            // 编码异常
            message = Messages.getString("document.ImportAbstract.msg1");
        } else {
            message = Messages.getString("document.ImportAbstract.tbx.msg1");
        }
        throw new ImportException(message + e.getMessage());
    }
    try {
        // 构建VTD解析工具
        vu = new VTDUtils(vg.getNav());
        dbOperator.beginTransaction();
        // 执行导入
        executeImport(srcLang);
        dbOperator.commit();
    } catch (VTDException e) {
        logger.error("", e);
        try {
            dbOperator.rollBack();
        } catch (SQLException e1) {
            logger.error("", e);
        }
        return FAILURE_4;
    } catch (SQLException e) {
        logger.error("", e);
        try {
            dbOperator.rollBack();
        } catch (SQLException e1) {
            logger.error("", e1);
        }
        throw new ImportException(Messages.getString("document.ImportAbstract.tbx.importDbError") + e.getMessage());
    } catch (OperationCanceledException e) {
        logger.error("", e);
        try {
            dbOperator.rollBack();
        } catch (SQLException e1) {
            logger.error("", e1);
            return CANCEL;
        }
    } catch (Exception e) {
        logger.error("", e);
        try {
            dbOperator.rollBack();
        } catch (SQLException e1) {
            logger.error("", e1);
        }
        throw new ImportException(Messages.getString("document.ImportAbstract.tbx.importDbError") + e.getMessage());
    }
    return SUCCESS;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) EncodingException(com.ximpleware.EncodingException) SQLException(java.sql.SQLException) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) EntityException(com.ximpleware.EntityException) VTDGen(com.ximpleware.VTDGen) NavException(com.ximpleware.NavException) EncodingException(com.ximpleware.EncodingException) SQLException(java.sql.SQLException) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) ImportException(net.heartsome.cat.common.core.exception.ImportException) TranscodeException(com.ximpleware.TranscodeException) XPathEvalException(com.ximpleware.XPathEvalException) EOFException(com.ximpleware.EOFException) XPathParseException(com.ximpleware.XPathParseException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) ModifyException(com.ximpleware.ModifyException) ParseException(com.ximpleware.ParseException) VTDException(com.ximpleware.VTDException) EntityException(com.ximpleware.EntityException) ImportException(net.heartsome.cat.common.core.exception.ImportException) VTDUtils(net.heartsome.xml.vtdimpl.VTDUtils) VTDException(com.ximpleware.VTDException) EOFException(com.ximpleware.EOFException) XPathParseException(com.ximpleware.XPathParseException) ParseException(com.ximpleware.ParseException)

Example 77 with NullProgressMonitor

use of org.eclipse.core.runtime.NullProgressMonitor in project cubrid-manager by CUBRID.

the class UnifyHostConfigEditor method createToolBar.

/**
	 * 
	 * Create the tool bar
	 * 
	 * @param parent the Composite
	 * 
	 */
private void createToolBar(Composite parent) {
    final Composite toolBarComp = new Composite(parent, SWT.NONE);
    {
        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
        toolBarComp.setLayoutData(gd);
        GridLayout gridLayout = new GridLayout();
        gridLayout.marginHeight = 0;
        gridLayout.horizontalSpacing = 0;
        gridLayout.marginWidth = 0;
        toolBarComp.setLayout(gridLayout);
    }
    ToolBar toolBar = new ToolBar(toolBarComp, SWT.FLAT);
    ToolItem saveItem = new ToolItem(toolBar, SWT.PUSH);
    saveItem.setImage(CubridManagerUIPlugin.getImage("icons/queryeditor/file_save.png"));
    saveItem.setToolTipText(Messages.msgTipSaveAction);
    saveItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            if (isDirty) {
                String errMsg = validate();
                if (errMsg != null) {
                    CommonUITool.openErrorBox(errMsg);
                    return;
                }
                doSave(new NullProgressMonitor());
                setDirty(false);
            }
        }
    });
    new ToolItem(toolBar, SWT.SEPARATOR);
    ToolItem addPropItem = new ToolItem(toolBar, SWT.PUSH);
    addPropItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/table_record_insert.png"));
    addPropItem.setToolTipText(com.cubrid.common.ui.common.Messages.cubridBrokerConfEditorAddPropItemLabel);
    addPropItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            HashMap<String, String> dataMap = new HashMap<String, String>();
            dataMap.put("0", "new property");
            TableViewer addDataTableViewer = null;
            if (confTabFolder.getSelection() == brokerConfTableCTabItem) {
                cubridBrokerConfListData.add(dataMap);
                addDataTableViewer = brokerConfTabTableViewer;
            } else if (confTabFolder.getSelection() == cubridConfTableCTabItem) {
                cubridConfConfigListData.add(dataMap);
                addDataTableViewer = cubridConfTabTableViewer;
            } else if (confTabFolder.getSelection() == cubridCMConfTableCTabItem) {
                cubridConfCMConfigListData.add(dataMap);
                addDataTableViewer = cubridCMConfTabTableViewer;
            }
            for (int i = 1; i < addDataTableViewer.getTable().getColumnCount(); i++) {
                dataMap.put(i + "", "");
            }
            addDataTableViewer.refresh();
            setDirty(true);
            addDataTableViewer.getTable().showItem(addDataTableViewer.getTable().getItem(addDataTableViewer.getTable().getItemCount() - 1));
        }
    });
    ToolItem deletePropItem = new ToolItem(toolBar, SWT.PUSH);
    deletePropItem.setImage(CommonUIPlugin.getImage("icons/queryeditor/table_record_delete.png"));
    deletePropItem.setToolTipText(com.cubrid.common.ui.common.Messages.cubridBrokerConfEditorDeletePropItemLabel);
    deletePropItem.addSelectionListener(new SelectionAdapter() {

        @SuppressWarnings("all")
        public void widgetSelected(SelectionEvent event) {
            TableViewer delDataTableViewer = null;
            List<Map<String, String>> delConfListData = null;
            if (confTabFolder.getSelection() == brokerConfTableCTabItem) {
                delDataTableViewer = brokerConfTabTableViewer;
                delConfListData = cubridBrokerConfListData;
            } else if (confTabFolder.getSelection() == cubridConfTableCTabItem) {
                delDataTableViewer = cubridConfTabTableViewer;
                delConfListData = cubridConfConfigListData;
            } else if (confTabFolder.getSelection() == cubridCMConfTableCTabItem) {
                delDataTableViewer = cubridCMConfTabTableViewer;
                delConfListData = cubridConfCMConfigListData;
            }
            int selectionIndex = delDataTableViewer.getTable().getSelectionIndex();
            if (selectionIndex < 0) {
                CommonUITool.openErrorBox(com.cubrid.common.ui.common.Messages.cubridBrokerConfEditorDeletePropertyMsg);
                return;
            }
            IStructuredSelection selection = (IStructuredSelection) delDataTableViewer.getSelection();
            HashMap<String, String> valueMap = (HashMap<String, String>) selection.getFirstElement();
            if (!CommonUITool.openConfirmBox(Messages.bind(com.cubrid.common.ui.common.Messages.cubridBrokerConfEditorDeleteBrokerPropConfirm, valueMap.get("0")))) {
                return;
            }
            delConfListData.remove(valueMap);
            delDataTableViewer.refresh();
            setDirty(true);
        }
    });
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) Composite(org.eclipse.swt.widgets.Composite) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent) List(java.util.List) ArrayList(java.util.ArrayList) TableViewer(org.eclipse.jface.viewers.TableViewer) ToolItem(org.eclipse.swt.widgets.ToolItem)

Example 78 with NullProgressMonitor

use of org.eclipse.core.runtime.NullProgressMonitor in project cubrid-manager by CUBRID.

the class EditConfigEditor method createToolBar.

/**
	 *
	 * Create the tool bar
	 *
	 * @param parent the Composite
	 *
	 */
private void createToolBar(Composite parent) {
    final Composite toolBarComp = new Composite(parent, SWT.NONE);
    {
        GridData gd = new GridData(GridData.FILL_HORIZONTAL);
        toolBarComp.setLayoutData(gd);
        GridLayout gridLayout = new GridLayout();
        gridLayout.marginHeight = 0;
        gridLayout.horizontalSpacing = 0;
        gridLayout.marginWidth = 0;
        toolBarComp.setLayout(gridLayout);
    }
    ToolBar toolBar = new ToolBar(toolBarComp, SWT.FLAT);
    ToolItem saveItem = new ToolItem(toolBar, SWT.PUSH);
    saveItem.setImage(CubridManagerUIPlugin.getImage("icons/queryeditor/file_save.png"));
    saveItem.setToolTipText(Messages.msgTipSaveAction);
    saveItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            if (isDirty) {
                doSave(new NullProgressMonitor());
            }
        }
    });
    new ToolItem(toolBar, SWT.SEPARATOR);
    ToolItem importItem = new ToolItem(toolBar, SWT.PUSH);
    importItem.setImage(CubridManagerUIPlugin.getImage("icons/queryeditor/file_open.png"));
    importItem.setToolTipText(Messages.msgTipOpenAction);
    importItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            doImport();
        }
    });
    ToolItem exportItem = new ToolItem(toolBar, SWT.PUSH);
    exportItem.setImage(CubridManagerUIPlugin.getImage("icons/queryeditor/file_saveas.png"));
    exportItem.setToolTipText(Messages.msgTipSaveasAction);
    exportItem.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            doExport();
        }
    });
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) ToolBar(org.eclipse.swt.widgets.ToolBar) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ToolItem(org.eclipse.swt.widgets.ToolItem)

Example 79 with NullProgressMonitor

use of org.eclipse.core.runtime.NullProgressMonitor in project cubrid-manager by CUBRID.

the class EditQueryPlanDialog method initPara.

/**
	 * Sets the queryPlanInfo and selection which is a folder
	 *
	 * @param selection the selection to set
	 */
public void initPara(DefaultSchemaNode selection) {
    childrenLabel = new ArrayList<String>();
    ICubridNode[] childrenNode = null;
    QueryPlanInfo qpi = null;
    if (operation == AddEditType.EDIT) {
        qpi = (QueryPlanInfo) selection.getAdapter(QueryPlanInfo.class);
        childrenNode = selection.getParent().getChildren(new NullProgressMonitor());
    } else {
        qpi = new QueryPlanInfo();
        childrenNode = selection.getChildren(new NullProgressMonitor());
    }
    queryPlanInfo = new QueryPlanInfoHelp();
    queryPlanInfo.setQueryPlanInfo(qpi);
    database = selection.getDatabase();
    for (ICubridNode childNode : childrenNode) {
        childrenLabel.add(childNode.getLabel());
    }
    withUser = CompatibleUtil.isSupportQueryPlanWithUser(database.getDatabaseInfo());
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) QueryPlanInfoHelp(com.cubrid.cubridmanager.core.cubrid.jobauto.model.QueryPlanInfoHelp) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) QueryPlanInfo(com.cubrid.cubridmanager.core.cubrid.jobauto.model.QueryPlanInfo)

Example 80 with NullProgressMonitor

use of org.eclipse.core.runtime.NullProgressMonitor in project cubrid-manager by CUBRID.

the class EditBackupPlanDialog method initPara.

/**
	 * Initials the backupPlanInfo,database and childrenLabel
	 *
	 * @param selection the selection to set
	 */
public void initPara(DefaultSchemaNode selection) {
    childrenLabel = new ArrayList<String>();
    ICubridNode[] childrenNode = null;
    database = selection.getDatabase();
    if (operation == AddEditType.EDIT) {
        backupPlanInfo = (BackupPlanInfo) selection.getAdapter(BackupPlanInfo.class);
        childrenNode = selection.getParent().getChildren(new NullProgressMonitor());
    } else {
        backupPlanInfo = new BackupPlanInfo();
        String dbPath = database.getDatabaseInfo().getDbDir();
        dbPath = FileUtil.changeSeparatorByOS(dbPath, database.getServer().getServerInfo().getServerOsInfo());
        defaultPath = dbPath + selection.getServer().getServerInfo().getPathSeparator() + "backup";
        childrenNode = selection.getChildren(new NullProgressMonitor());
    }
    for (ICubridNode childNode : childrenNode) {
        childrenLabel.add(childNode.getLabel());
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) BackupPlanInfo(com.cubrid.cubridmanager.core.cubrid.jobauto.model.BackupPlanInfo)

Aggregations

NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1614 CoreException (org.eclipse.core.runtime.CoreException)416 Test (org.junit.Test)382 IFile (org.eclipse.core.resources.IFile)342 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)267 IProject (org.eclipse.core.resources.IProject)258 File (java.io.File)205 IPath (org.eclipse.core.runtime.IPath)182 IOException (java.io.IOException)153 Path (org.eclipse.core.runtime.Path)132 ArrayList (java.util.ArrayList)122 IStatus (org.eclipse.core.runtime.IStatus)113 IFolder (org.eclipse.core.resources.IFolder)87 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)69 SubProgressMonitor (org.eclipse.core.runtime.SubProgressMonitor)63 InvocationTargetException (java.lang.reflect.InvocationTargetException)60 List (java.util.List)59 IProjectDescription (org.eclipse.core.resources.IProjectDescription)57 IType (org.eclipse.jdt.core.IType)57 Status (org.eclipse.core.runtime.Status)55