Search in sources :

Example 81 with NullProgressMonitor

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

the class TableEditorPart method completeAll.

public void completeAll() {
    CommonUITool.openInformationBox(Messages.titleSuccess, Messages.bind(Messages.msgNull2DefComplete, jobName));
    if (this.isNewTableFlag) {
        ICubridNode node = database.getChild(database.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridTablesFolderLoader.TABLES_FOLDER_ID);
        if (node == null || !node.getLoader().isLoaded()) {
            return;
        }
        String id = node.getId() + ICubridNodeLoader.NODE_SEPARATOR + tableName;
        boolean isPartition = newSchemaInfo.getPartitionList() != null && newSchemaInfo.getPartitionList().size() > 0;
        ClassInfo newClassInfo = new ClassInfo(tableName, owner, ClassType.NORMAL, false, isPartition);
        ICubridNode newNode = CubridTablesFolderLoader.createUserTableNode(node, id, newClassInfo, node.getLoader().getLevel(), new NullProgressMonitor());
        if (CubridNavigatorView.findNavigationView() == null) {
            getSite().getWorkbenchWindow().getActivePage().closeEditor(editor, false);
            return;
        }
        TreeViewer treeViewer = CubridNavigatorView.findNavigationView().getViewer();
        if (treeViewer == null || treeViewer.getTree() == null || treeViewer.getTree().isDisposed()) {
            getSite().getWorkbenchWindow().getActivePage().closeEditor(editor, false);
            return;
        }
        CommonUITool.addNodeToTree(treeViewer, node, newNode);
        // refresh table folder count label
        CommonUITool.updateFolderNodeLabelIncludingChildrenCount(treeViewer, node);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(newNode, CubridNodeChangedEventType.NODE_ADD));
    } else {
        if (database == null) {
            return;
        }
        database.getDatabaseInfo().removeSchema(tableName);
        if (oldPartitionInfoList.isEmpty() && !partitionInfoList.isEmpty()) {
            editedTableNode.setIconPath("icons/navigator/schema_table_partition.png");
            editedTableNode.setType(NodeType.USER_PARTITIONED_TABLE_FOLDER);
            editedTableNode.setLoader(new CubridPartitionedTableLoader());
        } else if (!oldPartitionInfoList.isEmpty() && partitionInfoList.isEmpty()) {
            editedTableNode.setIconPath("icons/navigator/schema_table_item.png");
            editedTableNode.setType(NodeType.USER_TABLE);
            editedTableNode.setLoader(new CubridUserTableLoader());
        }
        TreeViewer treeViewer = CubridNavigatorView.findNavigationView().getViewer();
        if (treeViewer == null || treeViewer.getTree() == null || treeViewer.getTree().isDisposed()) {
            getSite().getWorkbenchWindow().getActivePage().closeEditor(editor, false);
            return;
        }
        CommonUITool.refreshNavigatorTree(treeViewer, editedTableNode);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(editedTableNode, CubridNodeChangedEventType.NODE_REFRESH));
        /* Broadcast the view changed */
        QueryEditorUtil.fireSchemaNodeChanged(editedTableNode);
    }
    getSite().getWorkbenchWindow().getActivePage().closeEditor(editor, false);
}
Also used : CubridPartitionedTableLoader(com.cubrid.common.ui.spi.model.loader.schema.CubridPartitionedTableLoader) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) TreeViewer(org.eclipse.jface.viewers.TreeViewer) CubridUserTableLoader(com.cubrid.common.ui.spi.model.loader.schema.CubridUserTableLoader) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) ClassInfo(com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo)

Example 82 with NullProgressMonitor

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

the class LoginQueryEditDialog method initial.

/**
	 * initialize some values
	 * 
	 */
private void initial() {
    //load the register CUBRID server and CUBRID database
    List<CubridServer> servers = CMHostNodePersistManager.getInstance().getAllServers();
    serverMap = new HashMap<String, CubridServer>();
    databaseMap = new HashMap<String, List<CubridDatabase>>();
    allHostCombo.removeAll();
    for (CubridServer server : servers) {
        serverMap.put(server.getName(), server);
        allHostCombo.add(server.getName());
        List<ICubridNode> children = server.getChildren();
        for (ICubridNode child : children) {
            if (!NodeType.DATABASE_FOLDER.equals(child.getType())) {
                continue;
            }
            ICubridNode[] dbs = child.getChildren(new NullProgressMonitor());
            if (dbs.length == 0) {
                continue;
            }
            List<CubridDatabase> dbList = new ArrayList<CubridDatabase>();
            for (ICubridNode database : dbs) {
                if (NodeType.DATABASE.equals(database.getType())) {
                    CubridDatabase db = (CubridDatabase) database;
                    dbList.add(db);
                }
            }
            databaseMap.put(server.getName(), dbList);
        }
    }
    //load the self defined CUBRID server and CUBRID database
    CubridServer selfDefinedServer = DatabaseNavigatorMenu.SELF_DATABASE.getServer();
    if (selfDefinedServer == null) {
        selfDefinedServer = new CubridServer(DatabaseNavigatorMenu.SELF_DATABASE_ID, DatabaseNavigatorMenu.SELF_DATABASE_SELECTED_LABEL, null, null);
        DatabaseNavigatorMenu.SELF_DATABASE.setServer(selfDefinedServer);
    }
    serverMap.put(selfDefinedServer.getName(), selfDefinedServer);
    allHostCombo.add(selfDefinedServer.getName());
    List<CubridDatabase> dbList = new ArrayList<CubridDatabase>();
    dbList.add(DatabaseNavigatorMenu.SELF_DATABASE);
    databaseMap.put(selfDefinedServer.getName(), dbList);
    connectionComp.init(null, this);
    changeSelection();
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ArrayList(java.util.ArrayList) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) ArrayList(java.util.ArrayList) List(java.util.List) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 83 with NullProgressMonitor

use of org.eclipse.core.runtime.NullProgressMonitor in project dbeaver by serge-rider.

the class RenameHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    SQLEditor editor = RuntimeUtils.getObjectAdapter(HandlerUtil.getActivePart(event), SQLEditor.class);
    if (editor == null) {
        log.error("No active SQL editor");
        return null;
    }
    Shell shell = HandlerUtil.getActiveShell(event);
    IFile file = EditorUtils.getFileFromInput(editor.getEditorInput());
    if (file == null) {
        UIUtils.showErrorDialog(shell, "Rename", "Can't rename - no source file");
        return null;
    }
    String newName = EnterNameDialog.chooseName(shell, "Rename SQL script [" + file.getName() + "]", file.getName());
    if (newName == null) {
        return null;
    }
    if (newName.indexOf('.') == -1) {
        int divPos = file.getName().lastIndexOf('.');
        if (divPos != -1) {
            newName += file.getName().substring(divPos);
        }
    }
    if (!newName.equals(file.getName())) {
        NullProgressMonitor monitor = new NullProgressMonitor();
        editor.doSave(monitor);
        try {
            file.move(file.getParent().getFullPath().append(newName), true, monitor);
        } catch (CoreException e) {
            UIUtils.showErrorDialog(shell, "Rename", "Error renaming file '" + file.getName() + "'", e);
        }
    }
    //file.set
    return null;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) SQLEditor(org.jkiss.dbeaver.ui.editors.sql.SQLEditor) Shell(org.eclipse.swt.widgets.Shell) IFile(org.eclipse.core.resources.IFile) CoreException(org.eclipse.core.runtime.CoreException)

Example 84 with NullProgressMonitor

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

the class NewTermDbBaseInfoPage method executeCreateDB.

/**
	 * 创建数据库
	 * @return ;
	 */
public String executeCreateDB(SystemDBOperator dbOp, IProgressMonitor monitor) {
    if (monitor == null) {
        monitor = new NullProgressMonitor();
    }
    monitor.beginTask("", 3);
    monitor.setTaskName(Messages.getString("wizard.NewTermDbBaseInfoPage.task2"));
    String message = null;
    try {
        if (Constants.FAILURE == dbOp.createDB()) {
            message = Messages.getString("wizard.NewTermDbBaseInfoPage.msg8");
        } else {
            if (!dbOp.getDBConfig().getDefaultType().equals(Constants.DBTYPE_SQLITE)) {
                // 更新系统库
                dbOp.updataSysDb(Constants.DB_TYPE_TB);
                // 处理本地服务器列表
                saveToServerConfigFile(dbOp);
            }
        }
        monitor.worked(3);
    } catch (SQLException e) {
        logger.error("", e);
        e.printStackTrace();
        message = Messages.getString("wizard.NewTermDbBaseInfoPage.msg10") + e.getMessage();
        return message;
    } finally {
        if (message != null) {
            final String _message = message;
            Display.getDefault().asyncExec(new Runnable() {

                public void run() {
                    setErrorMessage(_message);
                }
            });
        }
        monitor.done();
    }
    return message;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) SQLException(java.sql.SQLException)

Example 85 with NullProgressMonitor

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

the class NewTermDbImportPage method executeImport.

/**
	 * 执行导入
	 * @param tmxFile
	 * @param tbxFile
	 * @param dbMetaData
	 * @param monitor
	 *            ;
	 */
public void executeImport(String tbxFile, MetaData dbMetaData, IProgressMonitor monitor) {
    if (monitor == null) {
        monitor = new NullProgressMonitor();
    }
    monitor.setTaskName(Messages.getString("wizard.NewTermDbImportPage.task2"));
    monitor.beginTask("", 1);
    int tbxResult = -10;
    String message = "";
    if (tbxFile != null) {
        try {
            tbxResult = DatabaseService.importTbxWithFile(tbxFile, new SubProgressMonitor(monitor, 100), dbMetaData, getTbxImportStrategy());
        } catch (ImportException e) {
            message = e.getMessage();
        }
        if (!message.equals("")) {
            final String _message = message;
            Display.getDefault().asyncExec(new Runnable() {

                public void run() {
                    setErrorMessage(_message);
                }
            });
        }
    }
    StringBuffer resultMessage = new StringBuffer();
    if (tbxResult != DatabaseService.SUCCESS) {
        if (tbxResult == DatabaseService.FAILURE_1) {
            resultMessage.append(Messages.getString("wizard.NewTermDbImportPage.msg1"));
        } else if (tbxResult == DatabaseService.FAILURE_2) {
            resultMessage.append(Messages.getString("wizard.NewTermDbImportPage.msg2"));
        } else if (tbxResult == DatabaseService.FAILURE_3) {
            resultMessage.append(Messages.getString("wizard.NewTermDbImportPage.msg3"));
        } else if (tbxResult == DatabaseService.FAILURE_4) {
            resultMessage.append(Messages.getString("wizard.NewTermDbImportPage.msg4"));
        } else if (tbxResult == DatabaseService.FAILURE) {
            resultMessage.append(Messages.getString("wizard.NewTermDbImportPage.msg5"));
        } else if (tbxResult == DatabaseService.CANCEL) {
            resultMessage.append(Messages.getString("wizard.NewTermDbImportPage.msg6"));
        }
        if (!resultMessage.toString().equals("")) {
            final String _message = resultMessage.toString();
            Display.getDefault().asyncExec(new Runnable() {

                public void run() {
                    setErrorMessage(_message);
                }
            });
        }
    }
    monitor.done();
}
Also used : ImportException(net.heartsome.cat.common.core.exception.ImportException) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor)

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