Search in sources :

Example 1 with RenameConnectionDialog

use of com.cubrid.cubridquery.ui.connection.dialog.RenameConnectionDialog in project cubrid-manager by CUBRID.

the class RenameConnectionAction method doRun.

/**
	 * Perform rename Table
	 *
	 * @param cubridDatabase
	 * @param table
	 */
private void doRun(CubridDatabase database) {
    RenameConnectionDialog dlg = new RenameConnectionDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), database);
    int ret = dlg.open();
    if (ret == IDialogConstants.OK_ID) {
        /*Fire the database logout*/
        try {
            CubridDatabase orignDatabase = database.clone();
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(orignDatabase, CubridNodeChangedEventType.DATABASE_LOGOUT));
        } catch (CloneNotSupportedException e) {
            LOGGER.error(e.getMessage());
        }
        database.setLabel(dlg.getNewName());
        database.setLogined(false);
        CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridQueryNavigatorView.ID);
        TreeViewer treeViewer = navigatorView == null ? null : navigatorView.getViewer();
        if (treeViewer == null) {
            LOGGER.error("Error: Can't find the navigator view:" + CubridQueryNavigatorView.ID);
            return;
        }
        // Refresh the tree view
        database.removeAllChild();
        treeViewer.refresh(database, true);
        treeViewer.expandToLevel(database, 1);
        setEnabled(false);
        // Save the data
        ServerInfo preServerInfo = (database == null || database.getServer() == null) ? null : database.getServer().getServerInfo();
        QueryOptions.removePref(preServerInfo);
        CQBGroupNodePersistManager.getInstance().saveAllGroupNode();
        CQBDBNodePersistManager.getInstance().saveDatabases();
        ActionManager.getInstance().fireSelectionChanged(getSelection());
        LayoutManager.getInstance().fireSelectionChanged(getSelection());
    }
}
Also used : CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) RenameConnectionDialog(com.cubrid.cubridquery.ui.connection.dialog.RenameConnectionDialog) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Aggregations

CubridNavigatorView (com.cubrid.common.ui.common.navigator.CubridNavigatorView)1 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)1 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)1 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)1 RenameConnectionDialog (com.cubrid.cubridquery.ui.connection.dialog.RenameConnectionDialog)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1