Search in sources :

Example 11 with DatabaseInfo

use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo 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 12 with DatabaseInfo

use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo in project cubrid-manager by CUBRID.

the class ExportTableDefinitionProgress method getExportSchemaInfoList.

/**
	 *  get exprot schema info
	 * @param conn
	 * @param tableNameList
	 * @return List<SchemaInfo>
	 */
public List<SchemaInfo> getExportSchemaInfoList(Connection conn, List<String> tableNameList) {
    // FIXME move this logic to core module
    List<SchemaInfo> schemaInfoList = new ArrayList<SchemaInfo>();
    DatabaseInfo dbInfo = database.getDatabaseInfo();
    if (dbInfo == null) {
        return schemaInfoList;
    }
    for (String tableName : tableNameList) {
        SchemaInfo schemaInfo = dbInfo.getSchemaInfo(conn, tableName);
        if (schemaInfo == null) {
            continue;
        }
        schemaInfoList.add(schemaInfo);
    }
    return schemaInfoList;
}
Also used : DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ArrayList(java.util.ArrayList) SchemaInfo(com.cubrid.common.core.common.model.SchemaInfo)

Example 13 with DatabaseInfo

use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo in project cubrid-manager by CUBRID.

the class CreateTriggerDialog method addColumns.

/**
	 *
	 * Add columns of this table to combo
	 *
	 * @param tableName the tablename
	 */
private void addColumns(String tableName) {
    triggerTargetColumnCombo.removeAll();
    if (tableName == null || tableName.trim().length() == 0) {
        return;
    }
    CubridDatabase db = database;
    DatabaseInfo dbInfo = db.getDatabaseInfo();
    GetAllAttrTask task = new GetAllAttrTask(dbInfo);
    List<String> attrNameList = task.getAttrNameList(tableName);
    if (task.getErrorMsg() != null) {
        CommonUITool.openErrorBox(task.getErrorMsg());
        return;
    }
    triggerTargetColumnCombo.add("");
    for (String name : attrNameList) {
        triggerTargetColumnCombo.add(name);
    }
}
Also used : DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) GetAllAttrTask(com.cubrid.cubridmanager.core.cubrid.table.task.GetAllAttrTask)

Example 14 with DatabaseInfo

use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo in project cubrid-manager by CUBRID.

the class CreateTriggerDialog method getTableList.

/**
	 *
	 * Get table list
	 *
	 * @return the table string list
	 */
private List<String> getTableList() {
    // FIXME move this logic to core module
    if (null == tableList) {
        CubridDatabase db = database;
        DatabaseInfo dbInfo = db.getDatabaseInfo();
        GetTablesTask task = new GetTablesTask(dbInfo);
        //9.1.0 can't create trigger on sub-partion table
        if (CompatibleUtil.isNotSupportGetSubPartitionTable(database.getServer().getServerInfo())) {
            tableList = task.getUserTablesNotContainSubPartitionTable();
        } else {
            tableList = task.getUserTables();
        }
        if (task.getErrorMsg() != null) {
            CommonUITool.openErrorBox(task.getErrorMsg());
            return tableList;
        }
    }
    return tableList;
}
Also used : DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) GetTablesTask(com.cubrid.cubridmanager.core.cubrid.table.task.GetTablesTask)

Example 15 with DatabaseInfo

use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo in project cubrid-manager by CUBRID.

the class OpenSchemaEditorAction method run.

/**
	 * Open the selected database Schema Editor. If basing on none-database
	 * node, open the ERD by a virtual database
	 */
public void run() {
    // FIXME move this logic to core module
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null) {
        return;
    }
    Object[] obj = this.getSelectedObj();
    CubridDatabase[] cubridDatabases = getDBNodes(obj);
    for (int i = 0; i < cubridDatabases.length; i++) {
        // multi db nodes
        if (cubridDatabases[i].getDatabaseInfo() == null || !cubridDatabases[i].isLogined()) {
            cubridDatabases[i] = ERVirtualDatabase.getInstance();
        }
    }
    if (cubridDatabases.length == 0) {
        // when right-click not database nodes
        cubridDatabases = new CubridDatabase[1];
        cubridDatabases[0] = ERVirtualDatabase.getInstance();
    }
    // Limit max number one time
    if (cubridDatabases.length > LayoutUtil.MAX_OPEN_QUERY_EDITOR_NUM) {
        CommonUITool.openConfirmBox(Messages.bind("SchemaDesigner max...", LayoutUtil.MAX_OPEN_QUERY_EDITOR_NUM));
        List<CubridDatabase> list = new ArrayList<CubridDatabase>(LayoutUtil.MAX_OPEN_QUERY_EDITOR_NUM);
        for (int i = 0; i < LayoutUtil.MAX_OPEN_QUERY_EDITOR_NUM; i++) {
            list.add(cubridDatabases[i]);
        }
        cubridDatabases = new CubridDatabase[LayoutUtil.MAX_OPEN_QUERY_EDITOR_NUM];
        list.toArray(cubridDatabases);
    }
    for (CubridDatabase database : cubridDatabases) {
        SchemaEditorInput schemaEditorInput = new SchemaEditorInput(database, (provider instanceof TreeViewer) ? (TreeViewer) provider : null);
        schemaEditorInput.setDatabase(database);
        DatabaseInfo dbInfo = database.getDatabaseInfo();
        if (dbInfo == null) {
            continue;
        }
        try {
            window.getActivePage().openEditor(schemaEditorInput, ERSchemaEditor.ID);
            if (Util.isMac()) {
                // refresh for low version mac
                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().setEditorAreaVisible(false);
                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().setEditorAreaVisible(true);
            }
        } catch (PartInitException e) {
            LOGGER.error(e.getMessage());
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) TreeViewer(org.eclipse.jface.viewers.TreeViewer) SchemaEditorInput(com.cubrid.common.ui.er.SchemaEditorInput) ArrayList(java.util.ArrayList) PartInitException(org.eclipse.ui.PartInitException) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Aggregations

DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)188 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)79 ArrayList (java.util.ArrayList)45 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)35 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)31 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)30 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)30 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)25 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)24 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)24 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)23 ITask (com.cubrid.common.core.task.ITask)20 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)18 GetDatabaseListTask (com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask)18 Map (java.util.Map)15 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)14 HashMap (java.util.HashMap)14 Composite (org.eclipse.swt.widgets.Composite)14 UpdateCMUserTask (com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask)13 GridLayout (org.eclipse.swt.layout.GridLayout)13