Search in sources :

Example 6 with ICubridNode

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

the class ExportSettingForLoadDBPage method createControl.

/**
	 * Create the page content
	 *
	 * @param parent Composite
	 */
public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NONE);
    container.setLayout(new FormLayout());
    Composite leftComposite = new Composite(container, SWT.NONE);
    leftComposite.setLayout(new GridLayout());
    FormData leftData = new FormData();
    leftData.top = new FormAttachment(0, 5);
    leftData.bottom = new FormAttachment(100, 0);
    leftData.left = new FormAttachment(0, 5);
    leftData.right = new FormAttachment(45, 0);
    leftComposite.setLayoutData(leftData);
    Composite rightComposite = new Composite(container, SWT.NONE);
    FormData rightData = new FormData();
    rightData.top = new FormAttachment(0, 5);
    rightData.bottom = new FormAttachment(100, 0);
    rightData.left = new FormAttachment(45, 0);
    rightData.right = new FormAttachment(100, -5);
    rightComposite.setLayoutData(rightData);
    GridLayout rightCompositeLayout = new GridLayout();
    rightCompositeLayout.verticalSpacing = 10;
    rightComposite.setLayout(rightCompositeLayout);
    Label tableInfoLabel = new Label(leftComposite, SWT.None);
    tableInfoLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    tableInfoLabel.setText(Messages.exportWizardSourceTableLable);
    ctv = new CheckboxTreeViewer(leftComposite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
    ctv.getTree().setLayoutData(CommonUITool.createGridData(GridData.FILL_BOTH, 1, 1, -1, -1));
    ctv.setContentProvider(new FilterTreeContentProvider());
    ctv.addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            updateDialogStatus();
        }
    });
    final TreeViewerColumn dbObjectCol = new TreeViewerColumn(ctv, SWT.NONE);
    dbObjectCol.setLabelProvider(new ExportObjectLabelProvider());
    final TreeViewerColumn whereCnd = new TreeViewerColumn(ctv, SWT.NONE);
    whereCnd.setLabelProvider(new ExportObjectLabelProvider());
    whereCnd.setEditingSupport(new EditingSupport(ctv) {

        TextCellEditor textCellEditor;

        protected boolean canEdit(Object element) {
            if (element instanceof ICubridNode) {
                ICubridNode node = (ICubridNode) element;
                if (node.getType() == NodeType.TABLE_COLUMN_FOLDER) {
                    return true;
                }
            }
            return false;
        }

        protected CellEditor getCellEditor(Object element) {
            if (textCellEditor == null) {
                textCellEditor = new TextCellEditor(ctv.getTree());
            }
            return textCellEditor;
        }

        protected Object getValue(Object element) {
            final ICubridNode node = (ICubridNode) element;
            String condition = (String) node.getData(ExportObjectLabelProvider.CONDITION);
            if (condition == null) {
                return "";
            } else {
                return condition;
            }
        }

        protected void setValue(Object element, Object value) {
            final ICubridNode node = (ICubridNode) element;
            node.setData(ExportObjectLabelProvider.CONDITION, value);
            ctv.refresh();
        }
    });
    dbObjectCol.getColumn().setWidth(160);
    dbObjectCol.getColumn().setText(Messages.tableLabel);
    whereCnd.getColumn().setWidth(120);
    whereCnd.getColumn().setText(Messages.conditionLabel);
    final Button selectAllBtn = new Button(leftComposite, SWT.CHECK);
    {
        selectAllBtn.setText(Messages.btnSelectAll);
        GridData gridData = new GridData();
        gridData.grabExcessHorizontalSpace = true;
        gridData.horizontalIndent = 0;
        gridData.horizontalSpan = 3;
        selectAllBtn.setLayoutData(gridData);
    }
    selectAllBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            boolean selection = selectAllBtn.getSelection();
            for (ICubridNode node : tablesOrViewLst) {
                ctv.setGrayed(node, false);
                ctv.setChecked(node, selection);
            }
            updateDialogStatus();
        }
    });
    Group fileOptionGroup = new Group(rightComposite, SWT.None);
    fileOptionGroup.setText(Messages.exportWizardWhereExport);
    fileOptionGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    fileOptionGroup.setLayout(new GridLayout(3, false));
    schemaButton = new Button(fileOptionGroup, SWT.CHECK);
    schemaButton.setText("Schema");
    schemaButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    schemaButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            if (schemaButton.getSelection()) {
                schemaPathText.setEnabled(true);
                schemaBrowseButton.setEnabled(true);
                startValueButton.setEnabled(true);
            } else {
                schemaPathText.setEnabled(false);
                schemaBrowseButton.setEnabled(false);
                startValueButton.setEnabled(false);
            }
            updateDialogStatus();
        }
    });
    schemaPathText = new Text(fileOptionGroup, SWT.BORDER);
    schemaPathText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    schemaPathText.setEnabled(true);
    schemaPathText.setEditable(false);
    schemaPathText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent event) {
            updateDialogStatus();
        }
    });
    schemaBrowseButton = new Button(fileOptionGroup, SWT.None);
    schemaBrowseButton.setText(Messages.btnBrowse);
    schemaBrowseButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    schemaBrowseButton.setEnabled(true);
    schemaBrowseButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            DatabaseInfo databaseInfo = getDatabase().getDatabaseInfo();
            String databaseName = databaseInfo.getDbName();
            String fileNameForLoaddbSchema = databaseName + "_schema";
            File savedFile = TableUtil.getSavedFile(getShell(), new String[] { "*.*" }, new String[] { "All Files" }, fileNameForLoaddbSchema, null, null);
            if (savedFile != null) {
                schemaPathText.setText(savedFile.getAbsolutePath());
            }
            updateDialogStatus();
        }
    });
    indexButton = new Button(fileOptionGroup, SWT.CHECK);
    indexButton.setText("Index");
    indexButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    indexButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            if (indexButton.getSelection()) {
                indexPathText.setEnabled(true);
                indexBrowseButton.setEnabled(true);
            } else {
                indexPathText.setEnabled(false);
                indexBrowseButton.setEnabled(false);
            }
            updateDialogStatus();
        }
    });
    indexPathText = new Text(fileOptionGroup, SWT.BORDER);
    indexPathText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    indexPathText.setEnabled(true);
    indexPathText.setEditable(false);
    indexPathText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent event) {
            updateDialogStatus();
        }
    });
    indexBrowseButton = new Button(fileOptionGroup, SWT.None);
    indexBrowseButton.setText(Messages.btnBrowse);
    indexBrowseButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    indexBrowseButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            DatabaseInfo databaseInfo = getDatabase().getDatabaseInfo();
            String databaseName = databaseInfo.getDbName();
            String fileNameForLoaddbIndex = databaseName + "_indexes";
            File savedFile = TableUtil.getSavedFile(getShell(), new String[] { "*.*" }, new String[] { "All Files" }, fileNameForLoaddbIndex, null, null);
            if (savedFile != null) {
                indexPathText.setText(savedFile.getAbsolutePath());
            }
            updateDialogStatus();
        }
    });
    dataButton = new Button(fileOptionGroup, SWT.CHECK);
    dataButton.setText("Data");
    dataButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    dataButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            if (dataButton.getSelection()) {
                dataPathText.setEnabled(true);
                dataBrowseButton.setEnabled(true);
            } else {
                dataPathText.setEnabled(false);
                dataBrowseButton.setEnabled(false);
            }
            updateDialogStatus();
        }
    });
    dataPathText = new Text(fileOptionGroup, SWT.BORDER);
    dataPathText.setEditable(false);
    dataPathText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    dataPathText.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent event) {
            updateDialogStatus();
        }
    });
    dataBrowseButton = new Button(fileOptionGroup, SWT.None);
    dataBrowseButton.setText(Messages.btnBrowse);
    dataBrowseButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
    dataBrowseButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            DatabaseInfo databaseInfo = getDatabase().getDatabaseInfo();
            String databaseName = databaseInfo.getDbName();
            String fileNameForLoaddbData = databaseName + "_objects";
            File savedFile = TableUtil.getSavedFile(getShell(), new String[] { "*.*" }, new String[] { "All Files" }, fileNameForLoaddbData, null, null);
            if (savedFile != null) {
                dataPathText.setText(savedFile.getAbsolutePath());
            }
            updateDialogStatus();
        }
    });
    Group enCodingOptionGroup = new Group(rightComposite, SWT.None);
    enCodingOptionGroup.setText(Messages.exportWizardDataOption);
    enCodingOptionGroup.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
    enCodingOptionGroup.setLayout(new GridLayout(4, false));
    Label dbCharsetLabel = new Label(enCodingOptionGroup, SWT.None);
    dbCharsetLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
    dbCharsetLabel.setText(Messages.lblJDBCCharset);
    dbCharsetCombo = new Combo(enCodingOptionGroup, SWT.BORDER);
    dbCharsetCombo.setLayoutData(CommonUITool.createGridData(1, 1, 50, 21));
    dbCharsetCombo.setItems(QueryOptions.getAllCharset(null));
    dbCharsetCombo.setEnabled(false);
    Label fileCharsetLabel = new Label(enCodingOptionGroup, SWT.None);
    fileCharsetLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
    fileCharsetLabel.setText(Messages.lblFileCharset);
    fileCharsetCombo = new Combo(enCodingOptionGroup, SWT.BORDER);
    fileCharsetCombo.setLayoutData(CommonUITool.createGridData(1, 1, 50, 21));
    fileCharsetCombo.setItems(QueryOptions.getAllCharset(null));
    fileCharsetCombo.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent event) {
            updateDialogStatus();
        }
    });
    startValueButton = new Button(enCodingOptionGroup, SWT.CHECK);
    startValueButton.setText(Messages.lblExportTargetStartValue);
    startValueButton.setLayoutData(CommonUITool.createGridData(4, 1, -1, -1));
    startValueButton.setToolTipText(Messages.tipExportTargetStartValue);
    setControl(container);
}
Also used : Group(org.eclipse.swt.widgets.Group) ModifyListener(org.eclipse.swt.events.ModifyListener) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) CellEditor(org.eclipse.jface.viewers.CellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) Label(org.eclipse.swt.widgets.Label) EditingSupport(org.eclipse.jface.viewers.EditingSupport) Combo(org.eclipse.swt.widgets.Combo) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment) FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) TreeViewerColumn(org.eclipse.jface.viewers.TreeViewerColumn) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) FilterTreeContentProvider(com.cubrid.common.ui.common.dialog.FilterTreeContentProvider) ExportObjectLabelProvider(com.cubrid.common.ui.common.navigator.ExportObjectLabelProvider) GridData(org.eclipse.swt.layout.GridData) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) File(java.io.File)

Example 7 with ICubridNode

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

the class ExportSettingForLoadDBPage method initTableColumnInfo.

/**
	 * load tables and columns
	 */
public void initTableColumnInfo() {
    // FIXME move this logic to core module
    try {
        ProgressMonitorDialog progress = new ProgressMonitorDialog(Display.getCurrent().getActiveShell());
        progress.setCancelable(true);
        progress.run(true, true, new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) throws InvocationTargetException {
                monitor.beginTask(Messages.taskLoading, 2);
                tablesOrViewLst = new ArrayList<ICubridNode>();
                List<String> tableNames = new ArrayList<String>();
                Connection conn = null;
                Statement stmt = null;
                ResultSet rs = null;
                StringBuilder sql = new StringBuilder();
                sql.append("SELECT c.class_name, c.class_type ");
                sql.append("FROM db_class c, db_attribute a ");
                sql.append("WHERE c.class_name=a.class_name AND c.is_system_class='NO' ");
                sql.append("AND a.from_class_name IS NULL ");
                sql.append("GROUP BY c.class_name, c.class_type ");
                sql.append("ORDER BY c.class_type, c.class_name");
                String query = sql.toString();
                // [TOOLS-2425]Support shard broker
                if (getDatabase() != null) {
                    query = DatabaseInfo.wrapShardQuery(getDatabase().getDatabaseInfo(), query);
                }
                try {
                    monitor.subTask(Messages.taskLoadingTable);
                    conn = JDBCConnectionManager.getConnection(getDatabase().getDatabaseInfo(), true);
                    stmt = conn.createStatement();
                    rs = stmt.executeQuery(query);
                    while (rs.next()) {
                        //$NON-NLS-1$
                        String tableName = rs.getString(1);
                        //$NON-NLS-1$
                        String tableType = rs.getString(2);
                        if (ConstantsUtil.isExtensionalSystemTable(tableName)) {
                            continue;
                        }
                        String iconPath = "icons/navigator/schema_table_item.png";
                        if ("VCLASS".equalsIgnoreCase(tableType)) {
                            //export all view now so don't need select view node
                            continue;
                        }
                        ICubridNode classNode = new DefaultSchemaNode(tableName, tableName, iconPath);
                        classNode.setContainer(true);
                        classNode.setType(NodeType.TABLE_COLUMN_FOLDER);
                        tablesOrViewLst.add(classNode);
                        tableNames.add(tableName);
                    }
                    QueryUtil.freeQuery(rs);
                    monitor.worked(1);
                } catch (SQLException e) {
                    CommonUITool.openErrorBox(getShell(), e.getErrorCode() + System.getProperty("line.separator") + Messages.importErrorHead + e.getMessage());
                    LOGGER.error("", e);
                } finally {
                    QueryUtil.freeQuery(conn, stmt, rs);
                }
            }
        });
    } catch (Exception e) {
        LOGGER.error("", e);
    }
}
Also used : SQLException(java.sql.SQLException) Statement(java.sql.Statement) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) ArrayList(java.util.ArrayList) Connection(java.sql.Connection) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) SQLException(java.sql.SQLException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ResultSet(java.sql.ResultSet) List(java.util.List) ArrayList(java.util.ArrayList)

Example 8 with ICubridNode

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

the class ExportSettingForLoadDBPage method setOptionsToExportConfigModel.

/**
	 * set page parameter to config model
	 *
	 * @param exportConfig
	 */
public void setOptionsToExportConfigModel(ExportConfig exportConfig) {
    if (schemaButton.getSelection()) {
        exportConfig.setExportSchema(true);
        exportConfig.setSchemaFilePath(schemaPathText.getText().trim());
        exportConfig.setDataFilePath(ExportConfig.LOADDB_SCHEMAFILEKEY, schemaPathText.getText().trim());
    } else {
        exportConfig.setExportSchema(false);
    }
    if (indexButton.getSelection()) {
        exportConfig.setExportIndex(true);
        exportConfig.setIndexFilePath(indexPathText.getText().trim());
        exportConfig.setDataFilePath(ExportConfig.LOADDB_INDEXFILEKEY, indexPathText.getText().trim());
    } else {
        exportConfig.setExportIndex(false);
    }
    if (dataButton.getSelection()) {
        exportConfig.setExportData(true);
        exportConfig.setDataFileFolder(dataPathText.getText().trim());
        exportConfig.setDataFilePath(ExportConfig.LOADDB_DATAFILEKEY, dataPathText.getText().trim());
    } else {
        exportConfig.setExportData(false);
    }
    exportConfig.setExportSerialStartValue(startValueButton.getSelection());
    exportConfig.setFileCharset(fileCharsetCombo.getText());
    List<String> checkedTableList = new ArrayList<String>();
    List<ICubridNode> selectedTableOrViews = new ArrayList<ICubridNode>();
    Object[] objects = ctv.getCheckedElements();
    for (Object object : objects) {
        ICubridNode node = (ICubridNode) object;
        if (node.getType() == NodeType.TABLE_COLUMN_FOLDER) {
            selectedTableOrViews.add(node);
            checkedTableList.add(node.getName());
        }
    }
    exportConfig.setTableNameList(checkedTableList);
    removeUncheckedTablesOnConfig(exportConfig, checkedTableList);
    for (ICubridNode tableOrView : selectedTableOrViews) {
        // FIXME move this logic to core module
        List<ICubridNode> columnNodes = tableOrView.getChildren();
        ArrayList<String> columnNames = new ArrayList<String>();
        for (ICubridNode columnNode : columnNodes) {
            for (Object object : objects) {
                ICubridNode node = (ICubridNode) object;
                if (node.getType() == NodeType.TABLE_COLUMN) {
                    ICubridNode parent = node.getParent();
                    if (parent != null && parent.getId().equalsIgnoreCase(tableOrView.getId()) && columnNode.getName().equalsIgnoreCase(node.getName())) {
                        columnNames.add(columnNode.getName());
                    }
                }
            }
        }
        exportConfig.setColumnNameList(tableOrView.getName(), columnNames);
        Object whereCondition = tableOrView.getData(ExportObjectLabelProvider.CONDITION);
        if (whereCondition != null) {
            String sqlFilterPart = ((String) whereCondition).trim();
            //append "where" if necessary
            if (sqlFilterPart.length() > 0) {
                if (!sqlFilterPart.startsWith("where")) {
                    //TODO: if it has not a lowercase?
                    sqlFilterPart = " where " + sqlFilterPart;
                }
                exportConfig.setWhereCondition(tableOrView.getName(), sqlFilterPart);
            }
        }
    }
    exportConfig.setThreadCount(1);
    exportConfig.setExportType(ExportConfig.EXPORT_TO_LOADDB);
    exportConfig.setExportFileType(ExportConfig.FILE_TYPE_LOADDB);
}
Also used : ArrayList(java.util.ArrayList) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode)

Example 9 with ICubridNode

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

the class ExportSettingPage method initTableColumnInfo.

/**
	 * load tables and columns
	 */
public void initTableColumnInfo() {
    // FIXME move this logic to core module
    tableColumMap.clear();
    try {
        ProgressMonitorDialog progress = new ProgressMonitorDialog(Display.getCurrent().getActiveShell());
        progress.setCancelable(true);
        progress.run(true, true, new IRunnableWithProgress() {

            public void run(IProgressMonitor monitor) throws InvocationTargetException {
                monitor.beginTask(Messages.taskLoading, 2);
                tablesOrViewLst = new ArrayList<ICubridNode>();
                Connection conn = null;
                Statement stmt = null;
                ResultSet rs = null;
                StringBuilder sql = new StringBuilder();
                sql.append("SELECT c.class_name, c.class_type ");
                sql.append("FROM db_class c, db_attribute a ");
                sql.append("WHERE c.class_name=a.class_name AND c.is_system_class='NO' ");
                sql.append("AND a.from_class_name IS NULL ");
                sql.append("GROUP BY c.class_name, c.class_type ");
                sql.append("ORDER BY c.class_type, c.class_name");
                String query = sql.toString();
                // [TOOLS-2425]Support shard broker
                if (CubridDatabase.hasValidDatabaseInfo(getDatabase())) {
                    query = getDatabase().getDatabaseInfo().wrapShardQuery(query);
                }
                try {
                    monitor.subTask(Messages.taskLoadingTable);
                    conn = JDBCConnectionManager.getConnection(getDatabase().getDatabaseInfo(), true);
                    stmt = conn.createStatement();
                    rs = stmt.executeQuery(query);
                    while (rs.next()) {
                        //$NON-NLS-1$
                        String tableName = rs.getString(1);
                        //$NON-NLS-1$
                        String tableType = rs.getString(2);
                        if (ConstantsUtil.isExtensionalSystemTable(tableName)) {
                            continue;
                        }
                        String iconPath = "icons/navigator/schema_table_item.png";
                        if ("VCLASS".equalsIgnoreCase(tableType)) {
                            //export all view now so don't need select view node
                            continue;
                        }
                        ICubridNode classNode = new DefaultSchemaNode(tableName, tableName, iconPath);
                        if ("VCLASS".equalsIgnoreCase(tableType)) {
                            classNode.setData(VIEWNODEFLAG, "true");
                        } else {
                            classNode.setData(VIEWNODEFLAG, "false");
                        }
                        classNode.setContainer(true);
                        classNode.setType(NodeType.TABLE_COLUMN_FOLDER);
                        tablesOrViewLst.add(classNode);
                    }
                    QueryUtil.freeQuery(rs);
                    monitor.worked(1);
                    monitor.subTask(Messages.taskLoadingColumn);
                } catch (SQLException e) {
                    String msg = e.getErrorCode() + StringUtil.NEWLINE + Messages.importErrorHead + e.getMessage();
                    CommonUITool.openErrorBox(getShell(), msg);
                    LOGGER.error("", e);
                } finally {
                    QueryUtil.freeQuery(conn, stmt, rs);
                }
            }
        });
    } catch (Exception e) {
        LOGGER.error("", e);
    }
}
Also used : SQLException(java.sql.SQLException) Statement(java.sql.Statement) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) ArrayList(java.util.ArrayList) Connection(java.sql.Connection) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) DefaultSchemaNode(com.cubrid.common.ui.spi.model.DefaultSchemaNode) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) SQLException(java.sql.SQLException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ResultSet(java.sql.ResultSet)

Example 10 with ICubridNode

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

the class ExportSettingPage method init.

/**
	 * Initials some values.
	 */
private void init() {
    initTableColumnInfo();
    treeViewer.setInput(tablesOrViewLst);
    if (getExportConfig().isHistory()) {
        // history
        ExportConfig exportConfig = getExportConfig();
        for (String table : exportConfig.getTableNameList()) {
            for (ICubridNode node : tablesOrViewLst) {
                if (table.equalsIgnoreCase(node.getName())) {
                    treeViewer.setChecked(node, true);
                    String whereCondition = exportConfig.getWhereCondition(table);
                    if (whereCondition != null) {
                        node.setData(ExportObjectLabelProvider.CONDITION, whereCondition);
                    }
                }
            }
        }
        treeViewer.refresh();
        if (exportConfig.isExportSchema()) {
            schemaButton.setSelection(true);
            indexButton.setEnabled(true);
            serialButton.setEnabled(true);
            viewButton.setEnabled(true);
            startValueButton.setEnabled(true);
            if (exportConfig.isExportIndex()) {
                indexButton.setSelection(true);
            }
            if (exportConfig.isExportSerial()) {
                serialButton.setSelection(true);
            }
            if (exportConfig.isExportView()) {
                viewButton.setSelection(true);
            }
            if (exportConfig.isExportSerialStartValue()) {
                startValueButton.setSelection(true);
            }
        }
        if (exportConfig.isExportData()) {
            dataButton.setSelection(true);
        }
        if (exportConfig.getExportFileType() == ExportConfig.FILE_TYPE_SQL) {
            sqlButton.setSelection(true);
        } else if (exportConfig.getExportFileType() == ExportConfig.FILE_TYPE_CSV) {
            csvButton.setSelection(true);
            useFirstAsColumnBtn.setEnabled(true);
            setNullWidgetStatus(true);
        } else if (exportConfig.getExportFileType() == ExportConfig.FILE_TYPE_XLS) {
            xlsButton.setSelection(true);
            useFirstAsColumnBtn.setEnabled(true);
            setNullWidgetStatus(true);
        } else if (exportConfig.getExportFileType() == ExportConfig.FILE_TYPE_XLSX) {
            xlsxButton.setSelection(true);
            useFirstAsColumnBtn.setEnabled(true);
            setNullWidgetStatus(true);
        } else if (exportConfig.getExportFileType() == ExportConfig.FILE_TYPE_OBS) {
            obsButton.setSelection(true);
        } else if (exportConfig.getExportFileType() == ExportConfig.FILE_TYPE_TXT) {
            txtButton.setSelection(true);
            setNullWidgetStatus(true);
            setDelimiterWidgetStatus(true);
            useFirstAsColumnBtn.setEnabled(true);
        }
        updateExportLobButtonStatus();
        if (exportLobButton.isEnabled()) {
            exportLobButton.setSelection(exportConfig.isExportLob());
        }
        pathText.setText(exportConfig.getDataFileFolder());
        String[] charsets = QueryOptions.getAllCharset(null);
        int index = 0;
        for (int i = 0; i < charsets.length; i++) {
            String charset = charsets[i];
            if (charset.equals(getDatabase().getDatabaseInfo().getCharSet())) {
                index = i;
                break;
            }
        }
        dbCharsetCombo.select(index);
        index = 0;
        for (int i = 0; i < charsets.length; i++) {
            String charset = charsets[i];
            if (charset.equals(exportConfig.getFileCharset())) {
                index = i;
                break;
            }
        }
        fileCharsetCombo.select(index);
        threadCountSpinner.setSelection(exportConfig.getThreadCount());
        useFirstAsColumnBtn.setSelection(exportConfig.isFirstRowAsColumnName());
        setColumnDelimeter(exportConfig.getColumnDelimeter());
        setRowDelimeter(exportConfig.getRowDelimeter());
        if (exportConfig.getNULLValueTranslation() == null || "NULL".equals(exportConfig.getNULLValueTranslation())) {
            nullOneButton.setSelection(true);
        } else if ("\\N".equals(exportConfig.getNULLValueTranslation())) {
            nullTwoButton.setSelection(true);
        } else if ("(NULL)".equals(exportConfig.getNULLValueTranslation())) {
            nullThreeButton.setSelection(true);
        } else {
            otherButton.setSelection(true);
            String nullValueTranslation = exportConfig.getNULLValueTranslation() == null ? "" : exportConfig.getNULLValueTranslation();
            otherText.setText(nullValueTranslation);
        }
    } else {
        // initial check element
        List<String> tableList = getExportDataWizardWizard().getTableNameList();
        for (String table : tableList) {
            for (ICubridNode node : tablesOrViewLst) {
                if (table.equalsIgnoreCase(node.getName())) {
                    treeViewer.setChecked(node, true);
                }
            }
        }
        treeViewer.refresh();
        String[] charsets = QueryOptions.getAllCharset(null);
        int index = 0;
        for (int i = 0; i < charsets.length; i++) {
            String charset = charsets[i];
            if (charset.equals(getDatabase().getDatabaseInfo().getCharSet())) {
                index = i;
                break;
            }
        }
        schemaButton.setSelection(true);
        dataButton.setSelection(true);
        indexButton.setSelection(true);
        serialButton.setSelection(true);
        viewButton.setSelection(true);
        startValueButton.setSelection(true);
        sqlButton.setSelection(true);
        nullOneButton.setSelection(true);
        dbCharsetCombo.select(index);
        rowDelimiterCombo.setEnabled(false);
        fileCharsetCombo.select(index);
        rowDelimiterCombo.select(1);
        columnDelimiterCombo.select(0);
        setDelimiterWidgetStatus(false);
        useFirstAsColumnBtn.setEnabled(false);
        updateExportLobButtonStatus();
    }
}
Also used : ExportConfig(com.cubrid.common.ui.cubrid.table.progress.ExportConfig) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode)

Aggregations

ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)362 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)67 ArrayList (java.util.ArrayList)67 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)62 TreeViewer (org.eclipse.jface.viewers.TreeViewer)62 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)55 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)55 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)41 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)40 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)33 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)32 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)31 ICubridNodeLoader (com.cubrid.common.ui.spi.model.ICubridNodeLoader)27 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)26 CubridGroupNode (com.cubrid.common.ui.spi.model.CubridGroupNode)25 DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)25 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)25 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)25 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)23 CubridNavigatorView (com.cubrid.common.ui.common.navigator.CubridNavigatorView)22