use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.
the class DropTriggerAction method run.
public void run(ISchemaNode[] nodeArray) {
// FIXME move this logic to core module
if (nodeArray == null) {
LOGGER.error("The nodeArray is a null.");
return;
}
List<String> triggerNameList = new ArrayList<String>();
StringBuffer bf = new StringBuffer();
for (int i = 0; nodeArray != null && i < nodeArray.length; i++) {
DefaultSchemaNode trigger = (DefaultSchemaNode) nodeArray[i];
triggerNameList.add(trigger.getName());
if (i == 0) {
bf.append(trigger.getName());
}
}
if (nodeArray.length > 1) {
bf.append(", ...");
}
String cfmMsg = Messages.bind(Messages.dropTriggerWarnMSG1, nodeArray.length, bf.toString());
boolean ret = CommonUITool.openConfirmBox(cfmMsg);
if (!ret) {
return;
}
ISchemaNode triggerNode = (ISchemaNode) nodeArray[0];
CommonSQLExcuterTask task = new CommonSQLExcuterTask(triggerNode.getDatabase().getDatabaseInfo());
for (String triggerName : triggerNameList) {
String sql = "DROP TRIGGER " + QuerySyntax.escapeKeyword(triggerName);
task.addSqls(sql);
}
String taskName = Messages.bind(Messages.dropTriggerTaskName, bf.toString());
TaskExecutor taskExecutor = new CommonTaskExec(taskName);
taskExecutor.addTask(task);
new ExecTaskWithProgress(taskExecutor).busyCursorWhile();
if (!taskExecutor.isSuccess()) {
return;
}
String title = com.cubrid.common.ui.common.Messages.titleSuccess;
String msg = Messages.dropTriggerSuccessMsg;
CommonUITool.openInformationBox(title, msg);
ISelectionProvider provider = this.getSelectionProvider();
ICubridNode parent = triggerNode.getParent();
if (provider instanceof TreeViewer) {
TreeViewer viewer = (TreeViewer) provider;
for (int i = 0; nodeArray != null && i < nodeArray.length; i++) {
parent.removeChild((ISchemaNode) nodeArray[i]);
}
viewer.remove(parent, nodeArray);
viewer.setSelection(new StructuredSelection(parent), true);
CommonUITool.updateFolderNodeLabelIncludingChildrenCount(viewer, parent);
}
}
use of com.cubrid.common.ui.spi.model.DefaultSchemaNode 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.DefaultSchemaNode 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();
}
use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.
the class CubridNavigatorView method addListener.
/**
*
* Add listener
*
*/
protected void addListener() {
tv.getTree().addMouseListener(new MouseAdapter() {
public void mouseDown(MouseEvent event) {
if (toolTip.isVisible()) {
toolTip.setVisible(false);
}
}
public void mouseUp(MouseEvent event) {
if (event.button == 1 && LayoutManager.getInstance().isUseClickOnce()) {
ISelection selection = tv.getSelection();
if (selection == null || selection.isEmpty()) {
return;
}
Object obj = ((IStructuredSelection) selection).getFirstElement();
if (!(obj instanceof ICubridNode)) {
return;
}
ICubridNode cubridNode = (ICubridNode) obj;
LayoutManager.getInstance().getWorkbenchContrItem().openEditorOrView(cubridNode);
}
}
});
tv.getTree().addMouseTrackListener(new MouseTrackAdapter() {
public void mouseHover(MouseEvent event) {
if (toolTip.isVisible()) {
toolTip.setVisible(false);
}
int x = event.x;
int y = event.y;
TreeItem item = tv.getTree().getItem(new Point(x, y));
if (item == null) {
return;
}
showToolTip(item);
}
});
tv.getTree().addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent event) {
widgetSelected(event);
}
public void widgetSelected(SelectionEvent event) {
if (toolTip.isVisible()) {
toolTip.setVisible(false);
}
TreeItem[] items = tv.getTree().getSelection();
if (items == null || items.length == 0) {
return;
}
showToolTip(items[0]);
if (items.length == 1) {
showSchemaInfo(items[0]);
} else {
showSchemaInfo(null);
}
}
});
addDragDropSupport(tv.getTree());
tv.getTree().addKeyListener(new KeyListener() {
public void keyReleased(KeyEvent e) {
}
public void keyPressed(KeyEvent e) {
// prevent to make events by key press for a long time
if (e.character == ' ') {
TreeItem[] items = tv.getTree().getSelection();
if (items == null || items.length == 0) {
return;
}
if (items.length == 1) {
showSchemaInfo(items[0]);
} else {
showSchemaInfo(null);
}
}
lastKeyInputTimestamp = System.currentTimeMillis();
// by showing object information tab on the query editor.
if (e.keyCode == SWT.F2) {
TreeItem[] items = tv.getTree().getSelection();
if (items == null || items.length == 0) {
return;
}
for (TreeItem item : items) {
Object obj = item.getData();
if (obj instanceof ICubridNode) {
ICubridNode node = (ICubridNode) obj;
if (NodeType.USER_TABLE.equals(node.getType()) || NodeType.SYSTEM_TABLE.equals(node.getType()) || NodeType.USER_VIEW.equals(node.getType()) || NodeType.SYSTEM_VIEW.equals(node.getType())) {
DefaultSchemaNode table = (DefaultSchemaNode) obj;
OpenTargetAction action = new OpenTargetAction();
action.showObjectInfo(table);
} else if (NodeType.TABLE_FOLDER.equals(node.getType())) {
CubridNavigatorView view = CubridNavigatorView.getNavigatorView(ID_CQB);
if (view == null) {
view = CubridNavigatorView.getNavigatorView(ID_CM);
}
if (view == null) {
return;
}
TreeViewer treeViewer = view.getViewer();
//if not expand ,expand the node and wait until all children be added
if (!treeViewer.getExpandedState(node)) {
treeViewer.expandToLevel(node, 1);
while (node.getChildren().size() == 0) {
try {
Thread.sleep(500);
} catch (Exception ignored) {
}
}
}
CubridDatabase database = (CubridDatabase) node.getParent();
OpenTargetAction action = new OpenTargetAction();
action.showTableDashboard(database);
}
}
}
}
}
});
}
use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.
the class DatabaseDashboardEditor method createVolumnComposite.
/**
* create volumn information composite
*
* @param bar ExpandBar
* @param bar index
*
*/
public void createVolumnComposite(ExpandBar bar, int index) {
ExpandItem volumnItem = new ExpandItem(bar, SWT.NONE, index);
volumnItem.setText(Messages.exportDashboardVolumnTableTitle);
Composite volumnComposite = new Composite(bar, SWT.NONE);
volumnComposite.setLayout(new FillLayout());
volumnInfoTableViewer = new TableViewer(volumnComposite, SWT.BORDER | SWT.FULL_SELECTION);
volumnInfoTableViewer.getTable().setHeaderVisible(true);
volumnInfoTableViewer.getTable().setLinesVisible(true);
final TableViewerColumn columnVolumn = new TableViewerColumn(volumnInfoTableViewer, SWT.CENTER);
columnVolumn.getColumn().setWidth(140);
columnVolumn.getColumn().setText(Messages.volumnTableVolumnNameColumnLabel);
columnVolumn.getColumn().setToolTipText(Messages.volumnTableVolumnNameColumnLabel);
final TableViewerColumn columnType = new TableViewerColumn(volumnInfoTableViewer, SWT.CENTER);
columnType.getColumn().setWidth(90);
columnType.getColumn().setText(Messages.volumnTableVolumnTypeColumnLabel);
columnType.getColumn().setToolTipText(Messages.volumnTableVolumnTypeColumnLabel);
final TableViewerColumn columnFreeSize = new TableViewerColumn(volumnInfoTableViewer, SWT.RIGHT);
columnFreeSize.getColumn().setWidth(90);
columnFreeSize.getColumn().setText(Messages.volumnTableFreesizeColumnLabel);
columnFreeSize.getColumn().setToolTipText(Messages.volumnTableFreesizeColumnLabel);
final TableViewerColumn columnTotalSize = new TableViewerColumn(volumnInfoTableViewer, SWT.RIGHT);
columnTotalSize.getColumn().setWidth(90);
columnTotalSize.getColumn().setText(Messages.volumnTableTotalsizeColumnLabel);
columnTotalSize.getColumn().setToolTipText(Messages.volumnTableTotalsizeColumnLabel);
final TableViewerColumn lastModifyDate = new TableViewerColumn(volumnInfoTableViewer, SWT.CENTER);
lastModifyDate.getColumn().setWidth(90);
lastModifyDate.getColumn().setText(Messages.volumnTableLastModifyTimeColumnLabel);
lastModifyDate.getColumn().setToolTipText(Messages.volumnTableLastModifyTimeColumnLabel);
final TableViewerColumn columnLocation = new TableViewerColumn(volumnInfoTableViewer, SWT.LEFT);
columnLocation.getColumn().setWidth(300);
columnLocation.getColumn().setText(Messages.tblColumnVolPath);
columnLocation.getColumn().setToolTipText(Messages.tblColumnVolPath);
volumnInfoTableViewer.setContentProvider(new TableContentProvider());
volumnInfoTableViewer.setLabelProvider(new TableLabelProvider());
Table table = volumnInfoTableViewer.getTable();
table.setLinesVisible(true);
table.setHeaderVisible(true);
volumnInfoTableViewer.setInput(volumnInfoListData);
volumnItem.setControl(volumnComposite);
volumnItem.setHeight(130);
volumnItem.setExpanded(true);
Menu menu = new Menu(this.getSite().getShell(), SWT.POP_UP);
final MenuItem itemAddVolumn = new MenuItem(menu, SWT.PUSH);
itemAddVolumn.setText(com.cubrid.cubridmanager.ui.spi.Messages.setAddVolumeActionName);
itemAddVolumn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
DefaultSchemaNode node = null;
for (ICubridNode cubridNode : database.getChildren()) {
if (cubridNode.getType().equals(CubridNodeType.DBSPACE_FOLDER)) {
node = (DefaultSchemaNode) cubridNode;
}
}
if (node == null) {
return;
}
// Gets the status of adding volume
GetAddVolumeStatusInfo getAddVolumeStatusInfo = new GetAddVolumeStatusInfo();
final CommonQueryTask<GetAddVolumeStatusInfo> statusTask = new CommonQueryTask<GetAddVolumeStatusInfo>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), getAddVolumeStatusInfo);
statusTask.setDbName(database.getLabel());
TaskExecutor taskExecutor = new CommonTaskExec(com.cubrid.cubridmanager.ui.cubrid.dbspace.Messages.getVolumeInfoTaskName);
taskExecutor.addTask(statusTask);
CommonQueryTask<DbSpaceInfoList> spaceInfoTask = null;
DatabaseInfo databaseInfo = database.getDatabaseInfo();
DbSpaceInfoList dbSpaceInfoList = databaseInfo.getDbSpaceInfoList();
int pageSize = 0;
if (null == dbSpaceInfoList) {
dbSpaceInfoList = new DbSpaceInfoList();
spaceInfoTask = new CommonQueryTask<DbSpaceInfoList>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), dbSpaceInfoList);
spaceInfoTask.setDbName(database.getLabel());
taskExecutor.addTask(spaceInfoTask);
}
new ExecTaskWithProgress(taskExecutor).busyCursorWhile();
if (spaceInfoTask == null) {
pageSize = dbSpaceInfoList.getPagesize();
} else {
final DbSpaceInfoList model = ((CommonQueryTask<DbSpaceInfoList>) spaceInfoTask).getResultModel();
pageSize = model.getPagesize();
}
getAddVolumeStatusInfo = statusTask.getResultModel();
//open add volumn dialog
AddVolumeDialog addVolumeDialog = new AddVolumeDialog(getSite().getShell());
addVolumeDialog.setGetAddVolumeStatusInfo(getAddVolumeStatusInfo);
addVolumeDialog.initPara(node);
addVolumeDialog.setTreeViewer(CubridNavigatorView.getNavigatorView("com.cubrid.cubridmanager.host.navigator").getViewer());
addVolumeDialog.setPageSize(pageSize);
int returnCode = addVolumeDialog.open();
//if add volumn refresh table
if (returnCode == IDialogConstants.OK_ID) {
volumnInfoListData.clear();
loadVolumnsInfo();
volumnInfoTableViewer.refresh();
}
}
});
volumnInfoTableViewer.getTable().setMenu(menu);
tableViewOnBarIndexMap.put(volumnInfoTableViewer, index);
}
Aggregations