use of com.cubrid.common.ui.spi.model.ICubridNode in project cubrid-manager by CUBRID.
the class OpenTargetAction method run.
public void run() {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return;
}
final Object[] obj = this.getSelectedObj();
if (!isSupported(obj)) {
setEnabled(false);
return;
}
for (int i = 0; i < obj.length; i++) {
if (!NodeUtil.isCubridNode(obj[i])) {
continue;
}
ICubridNode node = (ICubridNode) obj[i];
if (NodeUtil.isTableViewNode(node)) {
DefaultSchemaNode table = (DefaultSchemaNode) obj[i];
showObjectInfo(table);
} else if (NodeUtil.isTableFolderNode(node)) {
CubridNavigatorView view = CubridNavigatorView.findNavigationView();
if (view == null) {
return;
}
//if not expand ,expand the node and wait until all children be added
TreeViewer treeViewer = view.getViewer();
if (!treeViewer.getExpandedState(node)) {
treeViewer.expandToLevel(node, 1);
while (node.getChildren().size() == 0) {
ThreadUtil.sleep(500);
}
}
showTableDashboard(NodeUtil.getCubridDatabase(node));
} else if (NodeUtil.isViewFolderNode(node)) {
CubridNavigatorView view = CubridNavigatorView.getNavigatorView("com.cubrid.cubridquery.connection.navigator");
if (view == null) {
view = CubridNavigatorView.getNavigatorView("com.cubrid.cubridmanager.host.navigator");
}
if (view == null) {
return;
}
//if not expand ,expand the node and wait until all children be added
TreeViewer treeViewer = view.getViewer();
if (!treeViewer.getExpandedState(node)) {
treeViewer.expandToLevel(node, 1);
while (node.getChildren().size() == 0) {
ThreadUtil.sleep(500);
}
}
openViewsDetailInfoEditor(NodeUtil.getCubridDatabase(node));
} else if (NodeUtil.isSerialFolderNode(node)) {
CubridNavigatorView view = CubridNavigatorView.findNavigationView();
if (view == null) {
return;
}
//if not expand ,expand the node and wait until all children be added
TreeViewer treeViewer = view.getViewer();
if (!treeViewer.getExpandedState(node)) {
treeViewer.expandToLevel(node, 1);
while (node.getChildren().size() == 0) {
ThreadUtil.sleep(500);
}
}
openSerialsDetailInfoEditor(NodeUtil.getCubridDatabase(node), null);
} else if (NodeUtil.isTriggerFolderNode(node)) {
CubridNavigatorView view = CubridNavigatorView.findNavigationView();
if (view == null) {
return;
}
//if not expand ,expand the node and wait until all children be added
TreeViewer treeViewer = view.getViewer();
if (!treeViewer.getExpandedState(node)) {
treeViewer.expandToLevel(node, 1);
while (node.getChildren().size() == 0) {
ThreadUtil.sleep(500);
}
}
openTriggersDetailInfoEditor(NodeUtil.getCubridDatabase(node));
} else if (NodeUtil.isUserFolderNode(node)) {
CubridNavigatorView view = CubridNavigatorView.findNavigationView();
if (view == null) {
return;
}
//if not expand ,expand the node and wait until all children be added
TreeViewer treeViewer = view.getViewer();
if (!treeViewer.getExpandedState(node)) {
treeViewer.expandToLevel(node, 1);
while (node.getChildren().size() == 0) {
ThreadUtil.sleep(500);
}
}
openUsersDetailInfoEditor(NodeUtil.getCubridDatabase(node));
}
}
}
use of com.cubrid.common.ui.spi.model.ICubridNode in project cubrid-manager by CUBRID.
the class JdbcManageComposite method isJdbcDriverUsing.
/**
*
* Return whether the JDBC driver is using
*
* @param jdbcVersion String
* @return boolean
*/
private boolean isJdbcDriverUsing(String jdbcVersion) {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return false;
}
IWorkbenchPage page = window.getActivePage();
if (page == null) {
return false;
}
IViewReference[] viewReference = page.getViewReferences();
for (int i = 0; viewReference != null && i < viewReference.length; i++) {
IViewPart viewPart = viewReference[i].getView(false);
if (!(viewPart instanceof CubridNavigatorView)) {
continue;
}
CubridNavigatorView navigatorView = (CubridNavigatorView) viewPart;
List<ICubridNode> list = getUsingJdbcNodeList(navigatorView);
if (list == null) {
continue;
}
for (ICubridNode node : list) {
if (NodeType.SERVER.equals(node.getType())) {
CubridServer server = (CubridServer) node;
ServerInfo serverInfo = server.getServerInfo();
if (serverInfo == null) {
continue;
}
if (serverInfo.isConnected() && serverInfo.getJdbcDriverVersion().equals(jdbcVersion)) {
CommonUITool.openErrorBox(Messages.bind(Messages.errDeleteJdbcServer, new Object[] { serverInfo.getServerName(), jdbcVersion }));
return true;
}
} else if (NodeType.DATABASE.equals(node.getType())) {
CubridDatabase database = (CubridDatabase) node;
if (database == null || database.getServer() == null || database.getServer().getServerInfo() == null) {
continue;
}
ServerInfo serverInfo = database.getServer().getServerInfo();
if (serverInfo == null) {
LOGGER.error("The serverInfo is a null.");
return false;
}
boolean isSameVersion = StringUtil.isEqual(serverInfo.getJdbcDriverVersion(), jdbcVersion);
if (isSameVersion && database.isLogined()) {
CommonUITool.openErrorBox(Messages.bind(Messages.errDeleteJdbcConn, new Object[] { database.getName(), jdbcVersion }));
return true;
}
}
}
}
IEditorReference[] editorReference = page.getEditorReferences();
for (int i = 0; editorReference != null && i < editorReference.length; i++) {
IEditorPart editorPart = editorReference[i].getEditor(false);
if (!(editorPart instanceof QueryEditorPart)) {
continue;
}
QueryEditorPart queryEditorPart = (QueryEditorPart) editorPart;
CubridServer server = queryEditorPart.getSelectedServer();
ServerInfo serverInfo = server == null ? null : server.getServerInfo();
String partName = queryEditorPart.getPartName();
if (serverInfo != null && serverInfo.getJdbcDriverVersion().equals(jdbcVersion)) {
CommonUITool.openErrorBox(Messages.bind(Messages.errDeleteJdbcQuery, new Object[] { partName, jdbcVersion }));
return true;
}
}
return false;
}
use of com.cubrid.common.ui.spi.model.ICubridNode 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);
}
use of com.cubrid.common.ui.spi.model.ICubridNode in project cubrid-manager by CUBRID.
the class CubridNavigatorView method addDragDropSupport.
/**
* Add the drag drop support of tree.
*
* @param tree the tree need to drag and drop.
*/
protected void addDragDropSupport(final Tree tree) {
// Define 'Transfer Type', 'Operation'
Transfer[] types = new Transfer[] { TextTransfer.getInstance() };
int operations = DND.DROP_MOVE | DND.DROP_COPY;
// DragSource
final DragSource source = new DragSource(tree, operations);
source.setTransfer(types);
source.addDragListener(new DragSourceListener() {
public void dragStart(DragSourceEvent event) {
event.doit = false;
if (!dataSupportDND(tree.getSelection())) {
return;
}
event.doit = true;
}
public void dragSetData(DragSourceEvent event) {
event.data = ((ICubridNode) tree.getSelection()[0].getData()).getLabel();
}
public void dragFinished(DragSourceEvent event) {
}
});
addTreeDropTarget(tree);
String perspectiveId = PerspectiveManager.getInstance().getCurrentPerspectiveId();
// DropTarget for query editor.
QueryEditorDNDController.registerDragSource(perspectiveId, tv);
// DropTarget for multiple query
MultiDBQueryDNDController.registerDragSource(perspectiveId, tv);
// DropTarget for Run SQL file
RunSQLFileDialogDNDController.registerDragSource(perspectiveId, tv);
//DropTarget for ERD
ERDNDController.registerDragSource(perspectiveId, tv);
}
use of com.cubrid.common.ui.spi.model.ICubridNode in project cubrid-manager by CUBRID.
the class CubridNavigatorView method showSchemaInfo.
private void showSchemaInfo(TreeItem item) {
if (System.currentTimeMillis() - lastKeyInputTimestamp <= 50) {
return;
}
boolean isAutoShowSchemaInfo = GeneralPreference.isAutoShowSchemaInfo();
if (!isAutoShowSchemaInfo) {
return;
}
Object obj = null;
if (item != null) {
obj = item.getData();
}
DefaultSchemaNode table = null;
if (obj != null) {
if ((obj instanceof ICubridNode)) {
ICubridNode node = (ICubridNode) obj;
if (NodeType.USER_TABLE.equals(node.getType()) || NodeType.USER_VIEW.equals(node.getType()) || NodeType.USER_PARTITIONED_TABLE_FOLDER.equals(node.getType()) || NodeType.SYSTEM_TABLE.equals(node.getType()) || NodeType.SYSTEM_VIEW.equals(node.getType())) {
table = (DefaultSchemaNode) node;
}
}
}
final CubridDatabase database = table == null ? null : table.getDatabase();
currentDatabaseInfo = database == null ? null : database.getDatabaseInfo();
final String schemaName = table == null ? null : table.getName();
boolean isTable = (ActionSupportUtil.isSupportSingleSelection(table, new String[] { NodeType.USER_TABLE, NodeType.SYSTEM_TABLE, NodeType.USER_PARTITIONED_TABLE_FOLDER }));
showQuickView(currentDatabaseInfo, schemaName, isTable);
lastKeyInputTimestamp = System.currentTimeMillis();
}
Aggregations