Search in sources :

Example 16 with DatabaseEditorConfig

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

the class MultiDatabaseLoginFailedDialog method editHost.

/**
	 *
	 * @param multiDatabaseloginFailedInfo
	 */
public void editHost(MultiDatabaseloginFailedInfo multiDatabaseloginFailedInfo) {
    if (multiDatabaseloginFailedInfo == null) {
        return;
    }
    CubridDatabase database = multiDatabaseloginFailedInfo.getCubridDatabase();
    //if login ,can't edit
    if (database.isLogined()) {
        return;
    }
    String preName = (database == null || database.getServer() == null) ? "" : database.getServer().getName();
    ServerInfo preServerInfo = (database == null || database.getServer() == null) ? null : database.getServer().getServerInfo();
    QueryConnDialog dialog = new QueryConnDialog(getShell(), database, false);
    int returnCode = dialog.open();
    if (returnCode == QueryConnDialog.CONNECT_ID) {
        database.removeAllChild();
        CubridNavigatorView view = CubridNavigatorView.getNavigatorView(CubridQueryNavigatorView.ID);
        TreeViewer treeViewer = view.getViewer();
        if (database != null) {
            DatabaseEditorConfig editorConfig = QueryOptions.getEditorConfig(database, false);
            if (editorConfig == null) {
                editorConfig = new DatabaseEditorConfig();
            }
            editorConfig.setBackGround(dialog.getSelectedBackground());
            QueryOptions.putEditorConfig(database, editorConfig, false);
        }
        CQBGroupNodePersistManager.getInstance().saveAllGroupNode();
        CQBDBNodePersistManager.getInstance().saveDatabases();
        if (!preName.equals(database.getServer().getName())) {
            QueryOptions.removePref(preServerInfo);
        }
        treeViewer.refresh(database, true);
        treeViewer.expandToLevel(database, 1);
        ActionManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
        LayoutManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_LOGIN));
        multiDatabaseloginFailedInfo.setErrMsg("");
    }
    databaseTable.refresh();
}
Also used : CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) TreeViewer(org.eclipse.jface.viewers.TreeViewer) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) DatabaseEditorConfig(com.cubrid.common.ui.spi.model.DatabaseEditorConfig)

Example 17 with DatabaseEditorConfig

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

the class QueryConnDialog method createDialogArea.

/**
	 * @see org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
	 * @param parent The parent composite to contain the dialog area
	 * @return the dialog area control
	 */
protected Control createDialogArea(Composite parent) {
    Composite parentComp = (Composite) super.createDialogArea(parent);
    Composite composite = new Composite(parentComp, SWT.NONE);
    {
        composite.setLayoutData(new GridData(GridData.FILL_BOTH));
        GridLayout layout = new GridLayout();
        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 connectionNameComp = new Composite(composite, SWT.NONE);
    {
        connectionNameComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        GridLayout layout = new GridLayout(4, false);
        connectionNameComp.setLayout(layout);
        Label queryConnNameLabel = new Label(connectionNameComp, SWT.LEFT);
        queryConnNameLabel.setText(Messages.lblConnName);
        queryConnNameLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
        queryConnNameText = new Text(connectionNameComp, SWT.LEFT | SWT.BORDER);
        queryConnNameText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
        Label backgroundLabel = new Label(connectionNameComp, SWT.None);
        backgroundLabel.setText(Messages.lblBackground);
        backgroundLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
        DatabaseEditorConfig editorConfig = QueryOptions.getEditorConfig(database, false);
        RGB selectedColor = null;
        if (editorConfig != null) {
            selectedColor = editorConfig.getBackGround();
        } else {
            selectedColor = EditorConstance.getDefaultBackground();
        }
        selectColorCombo = new SelectColorCombo(connectionNameComp, SWT.BORDER, selectedColor);
        selectColorCombo.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_END, 1, 1, -1, -1));
        Label commentLabel = new Label(connectionNameComp, SWT.None);
        commentLabel.setText(Messages.lblComment);
        commentLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
        commentText = new Text(connectionNameComp, SWT.BORDER);
        commentText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
        commentText.setTextLimit(64);
        if (editorConfig != null && editorConfig.getDatabaseComment() != null) {
            commentText.setText(editorConfig.getDatabaseComment());
        }
    }
    connectionComp = new ConnectionComposite(composite, true, false);
    initial();
    if (isNewQueryConn) {
        setTitle(Messages.titleNewQueryConnDialog);
        setMessage(Messages.msgNewQueryConnDialog);
        queryConnNameText.setFocus();
    } else {
        setTitle(Messages.titleLoginQueryConnDialog);
        setMessage(Messages.msgLoginQueryConnDialog);
        connectionComp.getPasswordText().setFocus();
    }
    if (isNewQueryConn && database != null) {
        queryConnNameText.selectAll();
    }
    return parentComp;
}
Also used : SelectColorCombo(com.cubrid.common.ui.common.control.SelectColorCombo) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) ConnectionComposite(com.cubrid.common.ui.common.control.ConnectionComposite) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) ConnectionComposite(com.cubrid.common.ui.common.control.ConnectionComposite) Text(org.eclipse.swt.widgets.Text) RGB(org.eclipse.swt.graphics.RGB) DatabaseEditorConfig(com.cubrid.common.ui.spi.model.DatabaseEditorConfig)

Example 18 with DatabaseEditorConfig

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

the class CubridWorkbenchContrItem method processDoubleClickNavigatorEvent.

/**
	 * @see
	 *      WorkbenchContrItem.processDoubleClickNavigatorEvent(DoubleClickEvent)
	 * @param event DoubleClickEvent
	 */
public void processDoubleClickNavigatorEvent(DoubleClickEvent event) {
    ISelection selection = event.getSelection();
    if (selection == null || selection.isEmpty()) {
        return;
    }
    Object obj = ((IStructuredSelection) selection).getFirstElement();
    if (!(obj instanceof ICubridNode)) {
        return;
    }
    ICubridNode cubridNode = (ICubridNode) obj;
    if (NodeType.DATABASE.equals(cubridNode.getType())) {
        CubridDatabase database = (CubridDatabase) cubridNode;
        if (!database.isLogined() && database.isAutoSavePassword()) {
            DatabaseEditorConfig editorConfig = QueryOptions.getEditorConfig(database, false);
            if (EditorConstance.isNeedSetBackground(editorConfig)) {
                new ShortSetEditorConfigAction(database).run();
            }
        }
        if (database.isLogined()) {
            ActionManager.getInstance().getAction(EditQueryConnAction.ID).run();
        } else if (database.isAutoSavePassword() && connectDatabase(database.getDatabaseInfo())) {
            try {
                CommonUITool.openQueryEditor(database, true);
            } catch (PartInitException e) {
                LOGGER.error(e.getMessage(), e);
            }
            CQBGroupNodePersistManager.getInstance().fix();
            database.getLoader().setLoaded(false);
            CubridNavigatorView view = CubridNavigatorView.getNavigatorView(CubridQueryNavigatorView.ID);
            TreeViewer treeViewer = view.getViewer();
            treeViewer.refresh(database, true);
            treeViewer.expandToLevel(database, 1);
            ActionManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
            LayoutManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_LOGIN));
        } else {
            ActionManager.getInstance().getAction(EditQueryConnAction.ID).run();
        }
    }
    if (cubridNode.getType() == NodeType.TABLE_FOLDER || cubridNode.getType() == NodeType.TABLE_FOLDER || cubridNode.getType() == NodeType.VIEW_FOLDER || cubridNode.getType() == NodeType.TRIGGER_FOLDER || cubridNode.getType() == NodeType.SERIAL_FOLDER || cubridNode.getType() == NodeType.USER_FOLDER) {
        CubridDatabase database = (CubridDatabase) cubridNode.getParent();
        CubridNavigatorView view = CubridNavigatorView.getNavigatorView(CubridQueryNavigatorView.ID);
        //if not expand ,expand the node and wait until all children be added
        TreeViewer treeViewer = view.getViewer();
        if (cubridNode.getType() == NodeType.TABLE_FOLDER) {
            if (!treeViewer.getExpandedState(cubridNode)) {
                treeViewer.expandToLevel(cubridNode, 1);
                int sleepCount = 0;
                while (cubridNode.getChildren().size() == 0) {
                    try {
                        Thread.sleep(500);
                        sleepCount++;
                        if (sleepCount > 5) {
                            break;
                        }
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
            openTablesDetailInfoPart(database);
        } else if (cubridNode.getType() == NodeType.VIEW_FOLDER) {
            //if not open child node ,edit serial from dashboard can not open edit dialog
            if (!treeViewer.getExpandedState(cubridNode)) {
                treeViewer.expandToLevel(cubridNode, 1);
            }
            openViewsDetailInfoPart(database);
        } else if (cubridNode.getType() == NodeType.TRIGGER_FOLDER) {
            //if not open child node ,edit serial from dashboard can not open edit dialog
            if (!treeViewer.getExpandedState(cubridNode)) {
                treeViewer.expandToLevel(cubridNode, 1);
            }
            openTriggersDetailInfoPart(database);
        } else if (cubridNode.getType() == NodeType.SERIAL_FOLDER) {
            //if not open child node ,edit trigger from dashboard can not open edit dialog
            if (!treeViewer.getExpandedState(cubridNode)) {
                treeViewer.expandToLevel(cubridNode, 1);
            }
            openSerialsDetailInfoPart(database);
        } else if (StringUtil.isEqual(cubridNode.getType(), NodeType.USER_FOLDER)) {
            if (!treeViewer.getExpandedState(cubridNode)) {
                treeViewer.expandToLevel(cubridNode, 1);
            }
            openUsersDetailInfoPart(database);
        }
    }
    if (cubridNode.getType() == NodeType.SERIAL) {
        CubridDatabase database = (CubridDatabase) cubridNode.getParent().getParent();
        openSerialsDetailInfoPart(database, cubridNode.getName());
    }
    if (!LayoutManager.getInstance().isUseClickOnce()) {
        if (ActionSupportUtil.isSupportMultiSelection(obj, new String[] { NodeType.USER_TABLE, NodeType.USER_VIEW, NodeType.SYSTEM_TABLE, NodeType.SYSTEM_VIEW, NodeType.USER_PARTITIONED_TABLE_FOLDER }, false)) {
            openSelectQuery(selection);
        } else {
            openEditorOrView(cubridNode);
        }
    }
}
Also used : TreeViewer(org.eclipse.jface.viewers.TreeViewer) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) SQLException(java.sql.SQLException) PartInitException(org.eclipse.ui.PartInitException) CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) ISelection(org.eclipse.jface.viewers.ISelection) ShortSetEditorConfigAction(com.cubrid.cubridquery.ui.common.action.ShortSetEditorConfigAction) PartInitException(org.eclipse.ui.PartInitException) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) DatabaseEditorConfig(com.cubrid.common.ui.spi.model.DatabaseEditorConfig)

Example 19 with DatabaseEditorConfig

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

the class OpenQueryConnAction method run.

/**
	 * Open the query connection
	 */
public void run() {
    // TODO remove later
    CQBGroupNodePersistManager.getInstance().fix();
    Object[] obj = this.getSelectedObj();
    if (!isSupported(obj[0])) {
        setEnabled(false);
        return;
    }
    ISelectionProvider provider = getSelectionProvider();
    if (!(provider instanceof TreeViewer)) {
        return;
    }
    CubridDatabase[] cubridDatabases = handleSelectionObj(obj);
    if (cubridDatabases.length > 1) {
        List<MultiDatabaseloginFailedInfo> failedDatabaseList = new ArrayList<MultiDatabaseloginFailedInfo>();
        for (CubridDatabase object : cubridDatabases) {
            CubridDatabase database = (CubridDatabase) object;
            String errMsg = null;
            if (database.isAutoSavePassword()) {
                errMsg = CubridWorkbenchContrItem.connectDatabaseWithErrMsg(database.getDatabaseInfo());
            } else {
                errMsg = "Incorrect or missing password.";
            }
            if (errMsg == null) {
                database.getLoader().setLoaded(false);
                database.setLogined(true);
                CubridNavigatorView view = CubridNavigatorView.getNavigatorView(CubridQueryNavigatorView.ID);
                TreeViewer treeViewer = view.getViewer();
                treeViewer.refresh(database, true);
                treeViewer.expandToLevel(database, 1);
                ActionManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
                LayoutManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
                CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_LOGIN));
            } else {
                failedDatabaseList.add(new MultiDatabaseloginFailedInfo(database, errMsg));
            }
        }
        if (failedDatabaseList.size() > 0) {
            MultiDatabaseLoginFailedDialog dialog = new MultiDatabaseLoginFailedDialog(getShell(), failedDatabaseList);
            dialog.open();
        }
        return;
    }
    CubridDatabase database = cubridDatabases[0];
    if (!database.isLogined() && database.isAutoSavePassword()) {
        DatabaseEditorConfig editorConfig = QueryOptions.getEditorConfig(database, false);
        if (EditorConstance.isNeedSetBackground(editorConfig)) {
            new ShortSetEditorConfigAction(database).run();
        }
    }
    if (database.isAutoSavePassword() && CubridWorkbenchContrItem.connectDatabase(database.getDatabaseInfo())) {
        database.getLoader().setLoaded(false);
        CubridNavigatorView view = CubridNavigatorView.getNavigatorView(CubridQueryNavigatorView.ID);
        TreeViewer treeViewer = view.getViewer();
        treeViewer.refresh(database, true);
        treeViewer.expandToLevel(database, 1);
        ActionManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
        LayoutManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_LOGIN));
    } else {
        ActionManager.getInstance().getAction(EditQueryConnAction.ID).run();
    }
}
Also used : TreeViewer(org.eclipse.jface.viewers.TreeViewer) ArrayList(java.util.ArrayList) MultiDatabaseloginFailedInfo(com.cubrid.cubridquery.ui.connection.dialog.MultiDatabaseloginFailedInfo) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ShortSetEditorConfigAction(com.cubrid.cubridquery.ui.common.action.ShortSetEditorConfigAction) MultiDatabaseLoginFailedDialog(com.cubrid.cubridquery.ui.connection.dialog.MultiDatabaseLoginFailedDialog) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) DatabaseEditorConfig(com.cubrid.common.ui.spi.model.DatabaseEditorConfig)

Example 20 with DatabaseEditorConfig

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

the class NavigatorTreeLabelProvider method getText.

public String getText(Object element) {
    if (element instanceof ICubridNode) {
        if (element instanceof CubridDatabase) {
            CubridDatabase database = (CubridDatabase) element;
            StringBuffer sbLabel = new StringBuffer();
            sbLabel.append(((ICubridNode) element).getLabel());
            DatabaseEditorConfig editorConfig = QueryOptions.getEditorConfig(database, true);
            if (editorConfig != null && editorConfig.getDatabaseComment() != null && editorConfig.getDatabaseComment().length() > 0) {
                sbLabel.append("(").append(editorConfig.getDatabaseComment()).append(")");
                return sbLabel.toString();
            }
        } else if (element instanceof CubridBroker) {
            CubridBroker broker = (CubridBroker) element;
            BrokerInfo brokerInfo = broker.getBrokerInfo();
            if (brokerInfo == null || brokerInfo.getAccess_mode() == null) {
                return broker.getName();
            }
            return broker.getName() + " (" + brokerInfo.getPort() + "," + brokerInfo.getAccess_mode() + ")";
        } else if (element instanceof CubridServer) {
            CubridServer server = (CubridServer) element;
            return decorateServerText(server.getLabel(), server);
        }
        return ((ICubridNode) element).getLabel();
    } else if (element instanceof PendingUpdateAdapter) {
        return com.cubrid.common.ui.common.Messages.msgLoading;
    }
    return element == null ? "" : element.toString();
}
Also used : PendingUpdateAdapter(org.eclipse.ui.progress.PendingUpdateAdapter) CubridBroker(com.cubrid.cubridmanager.ui.spi.model.CubridBroker) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) DatabaseEditorConfig(com.cubrid.common.ui.spi.model.DatabaseEditorConfig) BrokerInfo(com.cubrid.cubridmanager.core.broker.model.BrokerInfo)

Aggregations

DatabaseEditorConfig (com.cubrid.common.ui.spi.model.DatabaseEditorConfig)28 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)19 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)12 RGB (org.eclipse.swt.graphics.RGB)11 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)9 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)6 IXMLMemento (com.cubrid.cubridmanager.core.common.xml.IXMLMemento)6 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)6 TreeViewer (org.eclipse.jface.viewers.TreeViewer)6 CubridNavigatorView (com.cubrid.common.ui.common.navigator.CubridNavigatorView)5 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)5 CubridNodeLoader (com.cubrid.common.ui.spi.model.CubridNodeLoader)3 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)3 ICubridNodeLoader (com.cubrid.common.ui.spi.model.ICubridNodeLoader)3 XMLMemento (com.cubrid.cubridmanager.core.common.xml.XMLMemento)3 FileOutputStream (java.io.FileOutputStream)3 ArrayList (java.util.ArrayList)3 SelectColorCombo (com.cubrid.common.ui.common.control.SelectColorCombo)2 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)2 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)2