Search in sources :

Example 66 with DefaultSchemaNode

use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.

the class ImportSettingTxtPage method handlePageLeaving.

protected void handlePageLeaving(PageChangingEvent event) {
    if ((event.getTargetPage() instanceof ImportTypePage)) {
        if (!CommonUITool.openConfirmBox(Messages.importWizardBackConfirmMsg)) {
            event.doit = false;
        } else {
            clearOptions();
        }
        return;
    }
    ImportConfig importConfig = getImportDataWizard().getImportConfig();
    /*NULL setting*/
    importConfig.getNullValueList().clear();
    if (nullOneButton.getSelection()) {
        importConfig.getNullValueList().add("NULL");
    }
    if (nullTwoButton.getSelection()) {
        importConfig.getNullValueList().add("\\N");
    }
    if (nullThreeButton.getSelection()) {
        importConfig.getNullValueList().add("(NULL)");
    }
    if (otherButton.getSelection() && otherText.getText().length() > 0) {
        String[] others = otherText.getText().split(",");
        for (String value : others) {
            if (importConfig.getNullValueList().indexOf(value) < 0) {
                importConfig.getNullValueList().add(value);
            }
        }
    }
    /*Error handle*/
    if (breakButton.getSelection()) {
        importConfig.setErrorHandle(ImportConfig.ERROR_HANDLE_BREAK);
    }
    if (ignoreButton.getSelection()) {
        importConfig.setErrorHandle(ImportConfig.ERROR_HANDLE_IGNORE);
    }
    importConfig.setFilesCharset(fileCharsetCombo.getText());
    importConfig.setRowDelimiter(getRowdelimeter());
    importConfig.setColumnDelimiter(getColumnDelimeter());
    importConfig.setThreadCount(threadCountSpinner.getSelection());
    importConfig.setCommitLine(commitCountSpinner.getSelection());
    importConfig.setImportCLobData(importClobButton.getSelection());
    importConfig.setImportBLobData(importBlobButton.getSelection());
    /*Update the selected table*/
    List<DefaultSchemaNode> selectedNodeList = mappingComposite.getSelectedTableNode();
    List<String> removedList = new ArrayList<String>();
    for (String tableName : importConfig.getSelectedMap().keySet()) {
        boolean isChecked = false;
        for (DefaultSchemaNode node : selectedNodeList) {
            if (tableName.equals(node.getName())) {
                isChecked = true;
                break;
            }
        }
        if (!isChecked) {
            removedList.add(tableName);
        }
    }
    for (String tableName : removedList) {
        importConfig.deleteTableConfig(tableName);
    }
}
Also used : ArrayList(java.util.ArrayList) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode)

Example 67 with DefaultSchemaNode

use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.

the class ImportSettingTxtPage method validate.

public boolean validate() {
    setErrorMessage(null);
    setPageComplete(false);
    ImportConfig importConfig = getImportDataWizard().getImportConfig();
    List<DefaultSchemaNode> result = mappingComposite.getSelectedTableNode();
    if (result.size() == 0) {
        setErrorMessage(Messages.errNoSelectedTable);
        return false;
    }
    for (DefaultSchemaNode node : result) {
        Object value = node.getData(ImportObjectLabelProvider.IS_MAPPED);
        if (value == null || !Boolean.parseBoolean(value.toString())) {
            setErrorMessage(Messages.bind(Messages.errTableSetting, node.getName()));
            return false;
        }
        TableConfig tableConfig = importConfig.getTableConfig(node.getName());
        if (tableConfig != null) {
            String filePath = tableConfig.getFilePath();
            if (!StringUtil.isEmpty(filePath)) {
                File file = new File(filePath);
                if (!file.exists()) {
                    setErrorMessage(Messages.bind(Messages.errFileNotExist, filePath));
                    return false;
                }
            }
        }
    }
    setPageComplete(true);
    return true;
}
Also used : DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) File(java.io.File)

Example 68 with DefaultSchemaNode

use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.

the class ImportSettingExcelPage method handlePageLeaving.

protected void handlePageLeaving(PageChangingEvent event) {
    if ((event.getTargetPage() instanceof ImportTypePage)) {
        if (!CommonUITool.openConfirmBox(Messages.importWizardBackConfirmMsg)) {
            event.doit = false;
        } else {
            clearOptions();
        }
        return;
    }
    ImportConfig importConfig = getImportDataWizard().getImportConfig();
    /*NULL setting*/
    importConfig.getNullValueList().clear();
    if (nullOneButton.getSelection()) {
        importConfig.getNullValueList().add("NULL");
    }
    if (nullTwoButton.getSelection()) {
        importConfig.getNullValueList().add("\\N");
    }
    if (nullThreeButton.getSelection()) {
        importConfig.getNullValueList().add("(NULL)");
    }
    if (otherButton.getSelection() && otherText.getText().length() > 0) {
        String[] others = otherText.getText().split(",");
        for (String value : others) {
            if (importConfig.getNullValueList().indexOf(value) < 0) {
                importConfig.getNullValueList().add(value);
            }
        }
    }
    /*Error handle*/
    if (breakButton.getSelection()) {
        importConfig.setErrorHandle(ImportConfig.ERROR_HANDLE_BREAK);
    }
    if (ignoreButton.getSelection()) {
        importConfig.setErrorHandle(ImportConfig.ERROR_HANDLE_IGNORE);
    }
    importConfig.setFilesCharset(fileCharsetCombo.getText());
    importConfig.setThreadCount(threadCountSpinner.getSelection());
    importConfig.setCommitLine(commitCountSpinner.getSelection());
    importConfig.setImportCLobData(importClobButton.getSelection());
    importConfig.setImportBLobData(importBlobButton.getSelection());
    /*Update the selected table*/
    List<DefaultSchemaNode> selectedNodeList = mappingComposite.getSelectedTableNode();
    List<String> removedList = new ArrayList<String>();
    for (String tableName : importConfig.getSelectedMap().keySet()) {
        boolean isChecked = false;
        for (DefaultSchemaNode node : selectedNodeList) {
            if (tableName.equals(node.getName())) {
                isChecked = true;
                break;
            }
        }
        if (!isChecked) {
            removedList.add(tableName);
        }
    }
    for (String tableName : removedList) {
        importConfig.deleteTableConfig(tableName);
    }
}
Also used : ArrayList(java.util.ArrayList) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode)

Example 69 with DefaultSchemaNode

use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.

the class TableToJavaCodeAction method doRun.

/**
	 * Do run
	 *
	 * @param objects
	 */
private void doRun(final Object[] objects) {
    final File filepath = TableUtil.getSavedDirForCreateCodes(getShell(), null);
    if (filepath == null) {
        return;
    }
    if (!CommonUITool.openConfirmBox(Messages.msgConfirmTableToCode)) {
        return;
    }
    final Map<CubridDatabase, Connection> connections = new HashMap<CubridDatabase, Connection>();
    try {
        final Display display = PlatformUI.getWorkbench().getDisplay();
        BusyIndicator.showWhile(display, new Runnable() {

            public void run() {
                // FIXME move this logic to core module
                StringBuilder notExportedList = new StringBuilder();
                for (int i = 0; i < objects.length; i++) {
                    DefaultSchemaNode table = (DefaultSchemaNode) objects[i];
                    Connection connection = connections.get(table.getDatabase());
                    if (connection == null) {
                        try {
                            connection = JDBCConnectionManager.getConnection(table.getDatabase().getDatabaseInfo(), true);
                            connections.put(table.getDatabase(), connection);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                    if (connection == null) {
                        if (notExportedList.length() > 0) {
                            notExportedList.append(", ");
                        }
                        notExportedList.append(table.getName());
                        continue;
                    }
                    String pojoClassFileName = getPojoFileName(table);
                    String pojoClassData = getPojoString(connection, table);
                    String pojoClassPath = filepath.getAbsolutePath() + File.separator + pojoClassFileName;
                    boolean result = FileUtil.writeToFile(pojoClassPath, pojoClassData, //TODO: error handling
                    "utf-8");
                    if (!result) {
                        if (notExportedList.length() > 0) {
                            notExportedList.append(", ");
                        }
                        notExportedList.append(table.getName());
                    }
                }
                finishNotice(notExportedList.toString());
            }
        });
    } finally {
        Collection<Connection> items = connections.values();
        for (Connection conn : items) {
            QueryUtil.freeQuery(conn);
        }
    }
}
Also used : HashMap(java.util.HashMap) Connection(java.sql.Connection) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) File(java.io.File) Display(org.eclipse.swt.widgets.Display)

Example 70 with DefaultSchemaNode

use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.

the class CombinedQueryEditorComposite method fireSchemaNodeChanged.

/**
	 * Fire the schema node changed
	 *
	 * @param schemaNode
	 */
public void fireSchemaNodeChanged(DefaultSchemaNode schemaNode) {
    CTabItem[] tabItems = resultTabFolder.getItems();
    for (CTabItem tabItem : tabItems) {
        if (!isObjectInfoTab(tabItem)) {
            continue;
        }
        ObjectInfoComposite infoCom = (ObjectInfoComposite) tabItem.getControl();
        DefaultSchemaNode node = infoCom.getSchemaNode();
        /* If the schema node is equal, then close the tabitem */
        if (schemaNode != null && node != null && schemaNode.getDatabase() != null && schemaNode.getDatabase().equals(node.getDatabase()) && schemaNode.equals(node)) {
            tabItem.dispose();
        }
    }
}
Also used : DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) CTabItem(org.eclipse.swt.custom.CTabItem)

Aggregations

DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)88 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)62 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)33 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)22 ICubridNodeLoader (com.cubrid.common.ui.spi.model.ICubridNodeLoader)21 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)18 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)17 ArrayList (java.util.ArrayList)15 TreeViewer (org.eclipse.jface.viewers.TreeViewer)10 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)9 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)9 Display (org.eclipse.swt.widgets.Display)9 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)8 ClassInfo (com.cubrid.cubridmanager.core.cubrid.table.model.ClassInfo)7 File (java.io.File)5 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)4 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)4 DbSpaceInfoList (com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList)4 GetAllClassListTask (com.cubrid.cubridmanager.core.cubrid.table.task.GetAllClassListTask)4 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)4