use of com.cubrid.common.ui.common.navigator.CubridNavigatorView in project cubrid-manager by CUBRID.
the class PasteHostAction method isSupported.
/**
*
* Return whether this action support this object,if not support,this action
* will be disabled
*
* @param obj the Object
* @return <code>true</code> if support this obj;<code>false</code>
* otherwise
*/
public boolean isSupported(Object obj) {
CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
if (navigatorView == null) {
return false;
}
boolean isShowGroup = navigatorView.isShowGroup();
if (isShowGroup && !(obj instanceof CubridServer) && !(obj instanceof CubridGroupNode)) {
return false;
}
if (!isShowGroup && obj != null && !(obj instanceof CubridServer)) {
return false;
}
Object[] 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 false;
}
if (!(objs[0] instanceof CubridServer)) {
return false;
}
return true;
}
use of com.cubrid.common.ui.common.navigator.CubridNavigatorView in project cubrid-manager by CUBRID.
the class ServiceDashboardEditor method loadAllData.
/**
* Load all data
*/
public void loadAllData() {
ServiceDashboardInfoMap.clear();
CubridNavigatorView navigatorView = CubridNavigatorView.findNavigationView();
if (navigatorView != null && navigatorView.savedIsShowGroup()) {
inputList = CMGroupNodePersistManager.getInstance().getAllGroupNodes();
List<CubridGroupNode> groupList = loadCubridGroupData(inputList);
serviceTreeViewer.setInput(groupList);
} else {
inputList = CMHostNodePersistManager.getInstance().getAllServers();
loadServerDashboardInfo(inputList);
serviceTreeViewer.setInput(ServiceDashboardInfoMap);
}
serviceTreeViewer.expandAll();
}
use of com.cubrid.common.ui.common.navigator.CubridNavigatorView in project cubrid-manager by CUBRID.
the class StartServiceAction method doRun.
/**
* Perform do run
*
* @param servers
*/
public void doRun(CubridServer[] servers) {
CubridNavigatorView view = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
final TreeViewer viewer = view.getViewer();
if (servers.length > 0) {
CubridServer server = servers[0];
if (isSupported(server)) {
final JobFamily jobFamily = new JobFamily();
final String serverName = server.getName();
String dbName = JobFamily.ALL_DB;
jobFamily.setServerName(serverName);
jobFamily.setDbName(dbName);
Job[] jobs = Job.getJobManager().find(jobFamily);
if (jobs.length > 0) {
CommonUITool.openWarningBox(Messages.bind(Messages.msgStartServiceWithJob, serverName));
return;
}
TaskExecutor taskExcutor = new StartServiceExecutor(server, getShell(), viewer);
ServerInfo serverInfo = server.getServerInfo();
GetCubridConfParameterTask task = new GetCubridConfParameterTask(serverInfo);
taskExcutor.addTask(task);
new ExecTaskWithProgress(taskExcutor).exec();
}
}
// for(CubridServer server : servers) {
// final JobFamily jobFamily = new JobFamily();
// final String serverName = server.getName();
// String dbName = JobFamily.ALL_DB;
// jobFamily.setServerName(serverName);
// jobFamily.setDbName(dbName);
// Job[] jobs = Job.getJobManager().find(jobFamily);
// if (jobs.length > 0) {
// CommonUITool.openWarningBox(Messages.bind(
// Messages.msgStartServiceWithJob, serverName));
// return;
// }
//
// TaskExecutor taskExcutor = new StartServiceExecutor(server, getShell(),
// viewer);
// ServerInfo serverInfo = server.getServerInfo();
// GetCubridConfParameterTask task = new GetCubridConfParameterTask(
// serverInfo);
// taskExcutor.addTask(task);
// new ExecTaskWithProgress(taskExcutor).exec();
// }
}
use of com.cubrid.common.ui.common.navigator.CubridNavigatorView in project cubrid-manager by CUBRID.
the class CMDatabaseNavigatorMenu method loadNavigatorMenu.
/**
* load all database on all server. if not login or database not started,
* the item disabled.
*
* @param dbSelectionMenu
*/
public void loadNavigatorMenu(Menu dbSelectionMenu) {
setSelectedImage(CubridManagerUIPlugin.getImage("/icons/navigator/eclipse_dot.png"));
CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
boolean isShowGroup = navigatorView == null ? false : navigatorView.isShowGroup();
List<CubridGroupNode> groupList = CMGroupNodePersistManager.getInstance().getAllGroupNodes();
if (groupList == null || groupList.isEmpty()) {
return;
}
Collections.sort(groupList, new Comparator<CubridGroupNode>() {
public int compare(CubridGroupNode o1, CubridGroupNode o2) {
if (o1 == null || o2 == null || o1.getLabel() == null || o2.getLabel() == null) {
return 0;
}
return o1.getLabel().compareToIgnoreCase(o2.getLabel());
}
});
int count = 0;
for (CubridGroupNode groupNode : groupList) {
// if (NodeFilterManager.getInstance().isHidden(groupNode)) {
// continue;
// }
List<ICubridNode> nodeList = groupNode.getChildren();
if (nodeList == null || nodeList.isEmpty()) {
continue;
}
DatabaseMenuItem groupMenuItem = null;
Menu groupSub = null;
String groupName = null;
if (isShowGroup) {
groupName = groupNode.getLabel();
groupMenuItem = new DatabaseMenuItem(groupNode.getId(), dbSelectionMenu, SWT.CASCADE);
groupMenuItem.setImage(CubridManagerUIPlugin.getImage("/icons/navigator/group.png"));
groupMenuItem.setText(groupName);
groupSub = new Menu(dbSelectionMenu);
groupMenuItem.setMenu(groupSub);
}
Collections.sort(nodeList, new Comparator<ICubridNode>() {
public int compare(ICubridNode o1, ICubridNode o2) {
if (o1 == null || o2 == null || o1.getLabel() == null || o2.getLabel() == null) {
return 0;
}
return o1.getLabel().compareToIgnoreCase(o2.getLabel());
}
});
int itemCountInGroup = 0;
for (ICubridNode node : nodeList) {
// }
if (node instanceof CubridServer) {
CubridServer server = (CubridServer) node;
ICubridNode databaseFolderNode = server.getChild(server.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridServerLoader.DATABASE_FOLDER_ID);
if (databaseFolderNode == null) {
continue;
}
// if (NodeFilterManager.getInstance().isHidden(databaseFolderNode)) {
// continue;
// }
ICubridNode[] dbs = databaseFolderNode.getChildren(new NullProgressMonitor());
if (dbs == null || dbs.length == 0) {
continue;
}
String serverName = server.getLabel();
DatabaseMenuItem serverMenuItem = null;
Menu serverSub = null;
if (isShowGroup) {
serverMenuItem = new DatabaseMenuItem(server.getId(), groupSub, SWT.CASCADE);
serverMenuItem.setImage(CubridManagerUIPlugin.getImage("/icons/navigator/host.png"));
serverMenuItem.setText(serverName);
serverSub = new Menu(groupSub);
serverMenuItem.setMenu(serverSub);
} else {
serverMenuItem = new DatabaseMenuItem(server.getId(), dbSelectionMenu, SWT.CASCADE);
serverMenuItem.setImage(CubridManagerUIPlugin.getImage("/icons/navigator/host.png"));
serverMenuItem.setText(serverName);
serverSub = new Menu(dbSelectionMenu);
serverMenuItem.setMenu(serverSub);
}
count++;
for (ICubridNode database : dbs) {
// if (NodeFilterManager.getInstance().isHidden(database)) {
// continue;
// }
CubridDatabase db = (CubridDatabase) database;
if (!db.isLogined()) {
continue;
}
itemCountInGroup++;
DatabaseMenuItem dbItem = new DatabaseMenuItem(database.getId(), serverSub, SWT.RADIO);
dbItem.setText(database.getLabel());
dbItem.setDatabase((CubridDatabase) database);
dbItem.setEnabled(db.isLogined() && db.getRunningType() == DbRunningType.CS);
dbItem.setGroupName(groupName);
count++;
}
}
}
if (itemCountInGroup <= 0 && groupSub != null && groupMenuItem != null) {
groupSub.dispose();
groupMenuItem.dispose();
continue;
}
}
if (count > 0) {
new MenuItem(dbSelectionMenu, SWT.SEPARATOR);
}
}
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 cubridNavigatorView = CubridNavigatorView.findNavigationView();
if (cubridNavigatorView != null) {
cubridNavigatorView.setFocus();
}
}
Aggregations