Search in sources :

Example 11 with CubridDatabase

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

the class RunSQLFileDialog method buttonPressed.

/**
	 * When press button,call it
	 * 
	 * @param buttonId the button id
	 */
protected void buttonPressed(int buttonId) {
    if (buttonId == IDialogConstants.OK_ID) {
        if (!validate()) {
            return;
        }
        for (CubridDatabase database : cubridDatabases) {
            RunSQLFileEditorInput input = new RunSQLFileEditorInput(database, filesList, fileCharsetCombo.getText(), threadCountSpinner.getSelection(), commitCountSpinner.getSelection(), saveErrExcelPath.getText());
            try {
                IWorkbench workbench = PlatformUI.getWorkbench();
                IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
                workbenchWindow.getActivePage().openEditor(input, RunSQLFileViewPart.ID);
            } catch (Exception e) {
                LOGGER.error("", e);
            }
        }
    }
    setReturnCode(buttonId);
    close();
}
Also used : IWorkbench(org.eclipse.ui.IWorkbench) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) RunSQLFileEditorInput(com.cubrid.common.ui.common.sqlrunner.part.RunSQLFileEditorInput) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 12 with CubridDatabase

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

the class NavigatorViewSorter method compare.

/**
	 * @see <code>ViewerSorter</code>
	 *
	 * @param viewer
	 *            Viewer
	 * @param e1
	 *            Object
	 * @param e2
	 *            Object
	 *
	 * @return int
	 */
public int compare(Viewer viewer, Object e1, Object e2) {
    if (e1 == null && e2 == null) {
        return 0;
    }
    if (e1 == null) {
        return -1;
    }
    if (e2 == null) {
        return -1;
    }
    if (!(e1 instanceof ICubridNode) || !(e2 instanceof ICubridNode)) {
        return 0;
    }
    ICubridNode node1 = (ICubridNode) e1;
    ICubridNode node2 = (ICubridNode) e2;
    // If group node, not sorting
    if (node1 instanceof CubridGroupNode) {
        return 0;
    } else // If cubrid group node ,use the list's order
    if ((node1 instanceof CubridServer) || (node1 instanceof CubridDatabase)) {
        return order * node1.getLabel().compareTo(node2.getLabel());
    }
    int cat1 = category(node1);
    int cat2 = category(node2);
    if (cat1 > 0 && cat2 > 0) {
        return cat1 - cat2;
    }
    if (cat1 != cat2) {
        return cat1 - cat2;
    }
    return node1.compareTo(node2);
}
Also used : CubridGroupNode(com.cubrid.common.ui.spi.model.CubridGroupNode) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 13 with CubridDatabase

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

the class EditProcedureAction method run.

/**
	 * Open the EditProcedureDialog and edit procedure
	 */
public void run() {
    // FIXME logic code move to core module
    Object[] objArr = this.getSelectedObj();
    if (!isSupported(objArr)) {
        this.setEnabled(false);
        return;
    }
    Shell shell = getShell();
    CubridDatabase database = null;
    ISchemaNode node = null;
    if (objArr[0] instanceof ISchemaNode && NodeType.STORED_PROCEDURE_PROCEDURE.equals(((ISchemaNode) objArr[0]).getType())) {
        node = (ISchemaNode) objArr[0];
        database = node.getDatabase();
    }
    if (database == null || node == null) {
        CommonUITool.openErrorBox(shell, Messages.errSelectProcedure);
        return;
    }
    final GetSPInfoListTask task = new GetSPInfoListTask(database.getDatabaseInfo());
    task.setSpName(node.getName());
    TaskExecutor taskExcutor = new CommonTaskExec(null);
    taskExcutor.addTask(task);
    new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
    if (!taskExcutor.isSuccess()) {
        return;
    }
    List<SPInfo> list = task.getSPInfoList();
    if (list.size() > 1) {
        CommonUITool.openErrorBox(shell, Messages.errDuplicateName);
        return;
    }
    if (list.isEmpty()) {
        CommonUITool.openErrorBox(shell, Messages.errNotExistName);
        return;
    }
    EditProcedureDialog dlg = new EditProcedureDialog(shell);
    dlg.setDatabase(database);
    dlg.setNewFlag(false);
    dlg.setSpInfo(list.get(0));
    if (dlg.open() == IDialogConstants.OK_ID) {
        ActionManager.getInstance().fireSelectionChanged(getSelection());
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) EditProcedureDialog(com.cubrid.common.ui.cubrid.procedure.dialog.EditProcedureDialog) Shell(org.eclipse.swt.widgets.Shell) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) SPInfo(com.cubrid.cubridmanager.core.cubrid.sp.model.SPInfo) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) GetSPInfoListTask(com.cubrid.cubridmanager.core.cubrid.sp.task.GetSPInfoListTask)

Example 14 with CubridDatabase

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

the class ImportERwinAction method createCompareModel.

/**
	 *
	 * @param tableSchema
	 * @param schemaInfos
	 */
private void createCompareModel(final String modelName, final Map<String, TableSchema> tableSchema, final Map<String, ERWinSchemaInfo> schemaInfos) {
    final List<TableSchemaCompareModelInputLazy> input = new ArrayList<TableSchemaCompareModelInputLazy>();
    ITask reportBugTask = new AbstractUITask() {

        private boolean success = false;

        public void cancel() {
        }

        public void finish() {
        }

        public boolean isCancel() {
            return false;
        }

        public boolean isSuccess() {
            return success;
        }

        public void execute(IProgressMonitor monitor) {
            List<TableDetailInfo> leftDbTableInfoList = TableSchemaCompareUtil.getTableInfoList(database);
            final CubridDatabase virtualDb = new CubridDatabase(modelName, modelName);
            virtualDb.setVirtual(true);
            DatabaseInfo info = database.getDatabaseInfo();
            virtualDb.setDatabaseInfo(info);
            WrappedDatabaseInfo wrappedDatabaseInfo = new WrappedDatabaseInfo(info);
            Map<String, SchemaInfo> dbSchemaInfos = new HashMap<String, SchemaInfo>();
            Collection<ERWinSchemaInfo> erwinSchemas = schemaInfos.values();
            for (ERWinSchemaInfo erwinSchema : erwinSchemas) {
                SchemaInfo schemaInfo = (SchemaInfo) erwinSchema;
                dbSchemaInfos.put(schemaInfo.getClassname(), schemaInfo);
            }
            wrappedDatabaseInfo.addSchemaInfos(dbSchemaInfos);
            wrappedDatabaseInfo.addTableSchemas(tableSchema);
            ERXmlDatabaseInfoMapper.addWrappedDatabaseInfo(info, wrappedDatabaseInfo);
            TableSchemaModel leftModel = TableSchemaCompareUtil.createTableSchemaModel(leftDbTableInfoList);
            TableSchemaModel rightModel = new TableSchemaModel();
            rightModel.getTableSchemaMap().putAll(tableSchema);
            TableSchemaComparator comparator = new TableSchemaComparator(database, virtualDb);
            TableSchemaCompareModel model = comparator.compare(leftModel, rightModel);
            model.setSourceDB(database);
            model.setTargetDB(virtualDb);
            // TODO rename class to ErwinCompareModelInput
            input.add(new TableSchemaCompareModelInputLazy(model));
            success = true;
        }
    };
    TaskExecutor taskExecutor = new CommonTaskExec(Messages.titleSchemaComparison);
    taskExecutor.addTask(reportBugTask);
    new ExecTaskWithProgress(taskExecutor).exec();
    if (taskExecutor.isSuccess()) {
        try {
            PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input.get(0), TableSchemaCompareInfoPart.ID);
        } catch (Exception e) {
        }
    }
}
Also used : TableSchemaCompareModelInputLazy(com.cubrid.common.ui.compare.schema.control.TableSchemaCompareModelInputLazy) CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) AbstractUITask(com.cubrid.common.core.task.AbstractUITask) ITask(com.cubrid.common.core.task.ITask) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) WrappedDatabaseInfo(com.cubrid.common.ui.cubrid.database.erwin.WrappedDatabaseInfo) HashMap(java.util.HashMap) TableSchemaComparator(com.cubrid.common.ui.compare.schema.TableSchemaComparator) ArrayList(java.util.ArrayList) TableDetailInfo(com.cubrid.common.core.common.model.TableDetailInfo) TableSchemaModel(com.cubrid.common.ui.compare.schema.model.TableSchemaModel) WrappedDatabaseInfo(com.cubrid.common.ui.cubrid.database.erwin.WrappedDatabaseInfo) TableSchemaCompareModel(com.cubrid.common.ui.compare.schema.model.TableSchemaCompareModel) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) AbstractUITask(com.cubrid.common.core.task.AbstractUITask) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) ERWinSchemaInfo(com.cubrid.common.ui.cubrid.database.erwin.model.ERWinSchemaInfo) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) SchemaInfo(com.cubrid.common.core.common.model.SchemaInfo) ERWinSchemaInfo(com.cubrid.common.ui.cubrid.database.erwin.model.ERWinSchemaInfo)

Example 15 with CubridDatabase

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

the class SchemaCompareDialog method createDialogArea.

/**
	 * Create the dialog area
	 *
	 * @param parent
	 *            Composite
	 * @return Control
	 */
protected Control createDialogArea(Composite parent) {
    Composite parentComp = (Composite) super.createDialogArea(parent);
    Composite composite = new Composite(parentComp, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
    layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
    layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
    layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
    composite.setLayout(layout);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    if (selections == null) {
        return parentComp;
    }
    Label lblLeft = new Label(composite, SWT.None);
    lblLeft.setText(Messages.lblSchemaComparisonBase);
    Label lblRight = new Label(composite, SWT.None);
    lblRight.setText(Messages.lblSchemaComparisonTarget);
    leftCombo = new org.eclipse.swt.widgets.List(composite, SWT.BORDER | SWT.V_SCROLL);
    leftCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    rightCombo = new org.eclipse.swt.widgets.List(composite, SWT.BORDER | SWT.V_SCROLL);
    rightCombo.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    for (Object obj : selections) {
        CubridDatabase db = (CubridDatabase) obj;
        if (db == null) {
            LOGGER.warn("The cubridDatabase is a null.");
            continue;
        }
        DatabaseInfo dbInfo = db.getDatabaseInfo();
        if (dbInfo == null) {
            LOGGER.warn("The databaseInfo is a null.");
            continue;
        }
        leftCombo.add(db.getLabel() + " - " + dbInfo.getBrokerIP() + "@" + dbInfo.getDbName());
    }
    for (Object obj : selections) {
        CubridDatabase db = (CubridDatabase) obj;
        if (db == null) {
            LOGGER.warn("The cubridDatabase is a null.");
            continue;
        }
        DatabaseInfo dbInfo = db.getDatabaseInfo();
        if (dbInfo == null) {
            LOGGER.warn("The databaseInfo is a null.");
            continue;
        }
        rightCombo.add(db.getLabel() + " - " + dbInfo.getBrokerIP() + "@" + dbInfo.getDbName());
    }
    //setTitle(Messages.titleSchemaComparison);
    setMessage(Messages.msgSchemaComparison);
    leftCombo.setSelection(0);
    rightCombo.setSelection(1);
    return parentComp;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Aggregations

CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)278 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)104 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)79 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)67 ArrayList (java.util.ArrayList)45 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)43 TreeViewer (org.eclipse.jface.viewers.TreeViewer)42 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)36 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)33 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)30 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)29 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)28 CubridNavigatorView (com.cubrid.common.ui.common.navigator.CubridNavigatorView)25 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)22 Shell (org.eclipse.swt.widgets.Shell)22 DatabaseEditorConfig (com.cubrid.common.ui.spi.model.DatabaseEditorConfig)19 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)18 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)18 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)18 ITask (com.cubrid.common.core.task.ITask)17