use of org.eclipse.jface.viewers.TreeViewer in project cubrid-manager by CUBRID.
the class CubridWorkbenchContrItem method checkConnectionStatus.
/**
* When selection changed,check whether selected server is connected
*
* @param selection the ISelection object
*/
private void checkConnectionStatus(ISelection selection) {
if (selection == null || selection.isEmpty()) {
return;
}
Object obj = ((IStructuredSelection) selection).getFirstElement();
if (!(obj instanceof ICubridNode)) {
return;
}
ICubridNode cubridNode = (ICubridNode) obj;
CubridServer cubridServer = cubridNode.getServer();
if (cubridServer == null) {
return;
}
ServerInfo serverInfo = cubridServer.getServerInfo();
boolean needToCheck = !serverInfo.isConnected() && (!(obj instanceof CubridServer) || (cubridServer.getChildren() != null && cubridServer.getChildren().size() > 0));
if (needToCheck) {
boolean connectAgagin = false;
if (CommonUITool.openConfirmBox(Messages.errCannotConnectServerReconnect)) {
connectAgagin = true;
}
closeAllEditorAndViewInServer(cubridServer, false);
cubridServer.removeAllChild();
TreeViewer viewer = (TreeViewer) LayoutManager.getInstance().getSelectionProvider();
viewer.refresh(cubridServer);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(cubridServer, CubridNodeChangedEventType.SERVER_DISCONNECTED));
if (connectAgagin && connectHost(serverInfo, true)) {
refreshAfterConnected(cubridServer);
}
}
}
use of org.eclipse.jface.viewers.TreeViewer in project cubrid-manager by CUBRID.
the class CQBConnectionChangingObserver method refreshNavigationTree.
/**
* Refresh the navigation tree
*/
private void refreshNavigationTree(CubridDatabase database) {
CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridNavigatorView.ID_CQB);
TreeViewer treeViewer = navigatorView == null ? null : navigatorView.getViewer();
if (treeViewer == null) {
return;
}
if (database != null) {
treeViewer.refresh(database, true);
treeViewer.expandToLevel(database, 1);
} else {
CQBDBNodePersistManager.getInstance().reloadDatabases();
CQBGroupNodePersistManager.getInstance().reloadGroups();
if (treeViewer != null) {
treeViewer.refresh(true);
}
}
}
use of org.eclipse.jface.viewers.TreeViewer 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 org.eclipse.jface.viewers.TreeViewer 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 org.eclipse.jface.viewers.TreeViewer 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;
}
Aggregations