use of org.eclipse.jface.viewers.TreeViewer in project cubrid-manager by CUBRID.
the class HiddenElementAction method run.
/**
* Hidden the elements
*/
public void run() {
Object[] objArr = this.getSelectedObj();
if (!isSupported(objArr)) {
setEnabled(false);
return;
}
ISelectionProvider provider = this.getSelectionProvider();
if (!(provider instanceof TreeViewer)) {
return;
}
List<String> idGrayList = new ArrayList<String>();
List<String> idList = new ArrayList<String>();
for (Object obj : objArr) {
if (obj instanceof ICubridNode) {
ICubridNode node = (ICubridNode) obj;
idList.add(node.getId());
addParentToGrayFilter(idGrayList, node.getParent());
}
}
NodeFilterManager.getInstance().addIdFilterList(idList);
NodeFilterManager.getInstance().addIdGrayFilterList(idGrayList);
TreeViewer viewer = (TreeViewer) provider;
viewer.setFilters(NodeFilterManager.getInstance().getViewerFilter());
}
use of org.eclipse.jface.viewers.TreeViewer 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 org.eclipse.jface.viewers.TreeViewer 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 org.eclipse.jface.viewers.TreeViewer in project azure-tools-for-java by Microsoft.
the class ServiceExplorerView method createPartControl.
/**
* This is a callback that will allow us
* to create the viewer and initialize it.
*/
public void createPartControl(Composite parent) {
viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
viewer.setContentProvider(new ViewContentProvider());
viewer.setLabelProvider(new ViewLabelProvider());
viewer.setSorter(new NameSorter());
viewer.setInput(getViewSite());
// Create the help context id for the viewer's control
PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), "com.microsoft.azuretools.azureexplorer.viewer");
makeActions();
hookContextMenu();
hookMouseActions();
contributeToActionBars();
}
use of org.eclipse.jface.viewers.TreeViewer in project cubrid-manager by CUBRID.
the class AddVolumeAction method run.
/**
*
* Creates a Dialog which is the instance of AddVolumeDialog to add a query
* plan
*
*/
public void run() {
Object[] obj = this.getSelectedObj();
CubridDatabase database = null;
if (obj.length > 0 && obj[0] instanceof DefaultSchemaNode) {
selection = (DefaultSchemaNode) obj[0];
database = selection.getDatabase();
}
if (database == null) {
CommonUITool.openErrorBox(Messages.msgSelectDB);
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();
TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
AddVolumeDialog addVolumeDialog = new AddVolumeDialog(getShell());
addVolumeDialog.setGetAddVolumeStatusInfo(getAddVolumeStatusInfo);
addVolumeDialog.initPara(selection);
addVolumeDialog.setTreeViewer(treeViewer);
addVolumeDialog.setPageSize(pageSize);
addVolumeDialog.open();
}
Aggregations