use of com.cubrid.common.ui.common.navigator.CubridNavigatorView in project cubrid-manager by CUBRID.
the class CubridStatusLineContrItem method changeStuatusLineForNavigator.
/**
*
* Change status line for navigator selection
*
* @param selection the ISelection object
*/
public void changeStuatusLineForNavigator(ISelection selection) {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return;
}
//window.setStatus("");
clearStatusLine();
updateStatusLineForRestoreQueryEditor();
if (selection == null || selection.isEmpty()) {
return;
}
Object obj = ((IStructuredSelection) selection).getFirstElement();
if (!(obj instanceof ICubridNode)) {
return;
}
CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridQueryNavigatorView.ID);
boolean isShowGroup = false;
if (navigatorView != null) {
isShowGroup = navigatorView.isShowGroup();
}
ICubridNode cubridNode = (ICubridNode) obj;
String nodePath = cubridNode.getLabel();
ICubridNode parent = cubridNode.getParent();
while (parent != null) {
if (!isShowGroup && NodeType.GROUP.equals(parent.getType())) {
break;
}
nodePath = parent.getLabel() + "/" + nodePath;
parent = parent.getParent();
}
//window.setStatus(nodePath);
if (window instanceof WorkbenchWindow) {
StatusLineManager statusLineManager = ((WorkbenchWindow) window).getStatusLineManager();
if (statusLineManager != null) {
updateStatusLine(statusLineManager, cubridNode);
}
}
}
use of com.cubrid.common.ui.common.navigator.CubridNavigatorView in project cubrid-manager by CUBRID.
the class PasteQueryConnAction method run.
/**
* Paste the query connection
*/
public void run() {
Object[] objs = this.getSelectedObj();
if (!isSupported(objs[0])) {
setEnabled(false);
return;
}
objs = null;
ISelection selection = LocalSelectionTransfer.getTransfer().getSelection();
if (selection instanceof IStructuredSelection) {
IStructuredSelection strSelection = (IStructuredSelection) selection;
objs = strSelection.toArray();
}
if (objs == null || objs.length == 0) {
return;
}
if (!(objs[0] instanceof CubridDatabase)) {
return;
}
CubridDatabase pastedDb = (CubridDatabase) objs[0];
QueryConnDialog dialog = new QueryConnDialog(getShell(), pastedDb, true);
int returnCode = dialog.open();
if (returnCode == QueryConnDialog.CONNECT_ID || returnCode == QueryConnDialog.SAVE_ID) {
CubridDatabase database = dialog.getDatabase();
CQBDBNodePersistManager.getInstance().addDatabase(database, false);
CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridQueryNavigatorView.ID);
TreeViewer treeViewer = navigatorView == null ? null : navigatorView.getViewer();
if (treeViewer == null) {
return;
}
Tree tree = treeViewer.getTree();
TreeItem item;
CubridGroupNode parent = getParentGroupNode();
if (navigatorView.isShowGroup()) {
item = new TreeItem(navigatorView.getTreeItemByData(parent), SWT.NONE);
} else {
item = new TreeItem(tree, SWT.NONE);
}
parent.addChild(database);
CQBGroupNodePersistManager.getInstance().saveAllGroupNode();
item.setText(database.getLabel());
item.setData(database);
treeViewer.refresh(database, true);
treeViewer.expandToLevel(database, 1);
treeViewer.setSelection(new StructuredSelection(database), true);
if (returnCode == QueryConnDialog.CONNECT_ID) {
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_LOGIN));
}
}
}
use of com.cubrid.common.ui.common.navigator.CubridNavigatorView 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());
}
}
use of com.cubrid.common.ui.common.navigator.CubridNavigatorView in project cubrid-manager by CUBRID.
the class CreateConnectionByUrlWizard method performFinish.
/**
* Perform finish
*/
public boolean performFinish() {
List<CubridDatabase> parsedDatabaseList = connectionPriviewPage.getParsedConnection();
/*Add the database list to the tree*/
CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridQueryNavigatorView.ID);
TreeViewer treeViewer = navigatorView == null ? null : navigatorView.getViewer();
if (treeViewer == null) {
return false;
}
for (CubridDatabase database : parsedDatabaseList) {
CQBDBNodePersistManager.getInstance().addDatabase(database, false);
Tree tree = treeViewer.getTree();
TreeItem item;
CubridGroupNode parent = CQBGroupNodePersistManager.getInstance().getDefaultGroup();
if (navigatorView.isShowGroup()) {
item = new TreeItem(navigatorView.getTreeItemByData(parent), SWT.NONE);
} else {
item = new TreeItem(tree, SWT.NONE);
}
parent.addChild(database);
item.setText(database.getLabel());
item.setData(database);
treeViewer.refresh(database, true);
treeViewer.expandToLevel(database, 1);
treeViewer.setSelection(new StructuredSelection(database), true);
}
CQBGroupNodePersistManager.getInstance().saveAllGroupNode();
return true;
}
use of com.cubrid.common.ui.common.navigator.CubridNavigatorView in project cubrid-manager by CUBRID.
the class PerspectiveChangedListener method showPerspective.
public void showPerspective(PerspectiveChangeEvent event) {
WorkbenchWindow window = (WorkbenchWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window != null) {
ICoolBarManager coolBarManager = window.getCoolBarManager2();
IMenuManager menuManager = window.getMenuBarManager();
ActionAdvisor.getInstance().showToolbar(coolBarManager);
ActionAdvisor.getInstance().showMenu(menuManager);
}
ActionManager.getInstance().setMenuProvider(menuProvider);
LayoutManager.getInstance().setStatusLineContrItem(cubridStatusLineContrItem);
LayoutManager.getInstance().setTitleLineContrItem(cubridTitleLineContrItem);
cubridTitleLineContrItem.changeTitleForNavigator(null);
LayoutManager.getInstance().setWorkbenchContrItem(cubridWorkbenchContrItem);
CubridNavigatorView navigatorView = CubridNavigatorView.findNavigationView();
if (navigatorView != null) {
navigatorView.setFocus();
if (navigatorView.getViewer() != null) {
navigatorView.getViewer().refresh(true);
}
}
}
Aggregations