use of com.cubrid.common.ui.spi.model.DefaultCubridNode in project cubrid-manager by CUBRID.
the class CubridStatusMonitorFolderLoader method createTempStatusNode.
/**
* Create temp status node
*
* @param parent the parent node
*/
private void createTempStatusNode(ICubridNode parent) {
CubridStatusMonitorInstance instance = CubridStatusMonitorInstance.getInstance();
ServerInfo serverInfo = parent.getServer().getServerInfo();
String[] keys = QueryOptions.getAllStatusMonitorKey(serverInfo);
for (String key : keys) {
StatusMonInstanceData data = instance.loadSetting(key);
instance.addData(key, data);
}
Map<String, StatusMonInstanceData> map = instance.getDataMap();
for (Map.Entry<String, StatusMonInstanceData> entry : map.entrySet()) {
String key = entry.getKey();
String prefix = QueryOptions.getPrefix(serverInfo);
if (!key.startsWith(prefix)) {
continue;
}
String label = key.substring(key.lastIndexOf(".") + 1);
StatusMonInstanceData monInstaceData = entry.getValue();
String statusId = parent.getId() + NODE_SEPARATOR + label;
ICubridNode stautsNode = new DefaultCubridNode(statusId, label, "icons/navigator/status_item.png");
stautsNode.setType(CubridNodeType.STATUS_MONITOR_TEMPLATE);
stautsNode.setModelObj(monInstaceData);
String viewId = "";
switch(monInstaceData.getMonitorType()) {
case BROKER:
viewId = BrokerStatusMonitorViewPart.ID;
break;
case DATABASE:
viewId = DbStatusDumpMonitorViewPart.ID;
break;
default:
}
if ("".equals(viewId)) {
return;
}
stautsNode.setViewId(viewId);
stautsNode.setContainer(false);
parent.addChild(stautsNode);
}
}
use of com.cubrid.common.ui.spi.model.DefaultCubridNode in project cubrid-manager by CUBRID.
the class StopBrokerAction method run.
/**
* Override the run method in order to complete stopping broker environment
*/
public void run() {
if (!CommonUITool.openConfirmBox(CONFIRM_CONTENT)) {
return;
}
final Object[] obj = this.getSelectedObj();
DefaultCubridNode selection = (DefaultCubridNode) obj[0];
ServerInfo serverInfo = selection.getServer().getServerInfo();
StopBrokerTask task = new StopBrokerTask(serverInfo);
task.setBrokerName(selection.getLabel());
final String taskName = Messages.bind(Messages.stopBrokerTaskName, selection.getLabel());
TaskExecutor taskExecutor = new CommonTaskExec(taskName);
taskExecutor.addTask(task);
new ExecTaskWithProgress(taskExecutor).exec();
if (!taskExecutor.isSuccess()) {
return;
}
TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
CommonUITool.refreshNavigatorTree(treeViewer, selection.getParent());
ActionManager.getInstance().fireSelectionChanged(getSelection());
}
use of com.cubrid.common.ui.spi.model.DefaultCubridNode in project cubrid-manager by CUBRID.
the class RemoveAllScriptLogAction method run.
/**
* Delete all script logs
*/
public void run() {
if (!CommonUITool.openConfirmBox(Messages.warningRemoveLog)) {
return;
}
Object[] selected = this.getSelectedObj();
DelAllLogTask delAllLogTask = new DelAllLogTask(((DefaultCubridNode) selected[0]).getServer().getServerInfo());
String[] path = new String[((DefaultCubridNode) selected[0]).getChildren().size()];
for (int i = 0, len = path.length; i < len; i++) {
path[i] = ((LogInfo) (((DefaultCubridNode) selected[0]).getChildren().get(i).getAdapter(LogInfo.class))).getPath();
}
delAllLogTask.setPath(path);
TaskExecutor taskExecutor = new CommonTaskExec(Messages.removeLogTaskName);
taskExecutor.addTask(delAllLogTask);
new ExecTaskWithProgress(taskExecutor).busyCursorWhile();
if (taskExecutor.isSuccess()) {
TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
DefaultCubridNode delNode = ((DefaultCubridNode) selected[0]);
ICubridNode parentNode = delNode.getParent().getParent();
parentNode.removeChild(delNode);
treeViewer.remove(delNode);
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage activePage = window.getActivePage();
for (int i = 0, len = path.length; i < len; i++) {
IEditorPart editor = activePage.findEditor(((DefaultCubridNode) selected[0]).getChildren().get(i));
if (null != editor) {
activePage.closeEditor(editor, true);
}
}
}
}
use of com.cubrid.common.ui.spi.model.DefaultCubridNode in project cubrid-manager by CUBRID.
the class RemoveLogAction method run.
/**
* Delete log file
*/
public void run() {
if (!CommonUITool.openConfirmBox(Messages.warningRemoveLog)) {
return;
}
Object[] selected = this.getSelectedObj();
if (selected == null || selected.length == 0) {
return;
}
List<String> logPathList = new ArrayList<String>();
for (int i = 0; i < selected.length; i++) {
ICubridNode node = (ICubridNode) selected[i];
if (isLastDbServerLog(node)) {
continue;
}
LogInfo logInfo = (LogInfo) node.getAdapter(LogInfo.class);
if (logInfo != null && logInfo.getPath() != null && logInfo.getPath().trim().length() > 0) {
logPathList.add(logInfo.getPath());
}
}
DelAllLogTask delLogTask = new DelAllLogTask(((DefaultCubridNode) selected[0]).getServer().getServerInfo());
String[] paths = new String[logPathList.size()];
delLogTask.setPath(logPathList.toArray(paths));
TaskExecutor taskExecutor = new CommonTaskExec(Messages.removeLogTaskName);
taskExecutor.addTask(delLogTask);
new ExecTaskWithProgress(taskExecutor).busyCursorWhile();
if (taskExecutor.isSuccess()) {
TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
for (int i = 0; i < selected.length; i++) {
ICubridNode delNode = (ICubridNode) selected[i];
if (isLastDbServerLog(delNode)) {
continue;
}
ICubridNode parentNode = delNode.getParent();
parentNode.removeChild(delNode);
treeViewer.remove(delNode);
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage activePage = window.getActivePage();
IEditorPart editor = activePage.findEditor(delNode);
if (null != editor) {
activePage.closeEditor(editor, true);
}
}
}
}
use of com.cubrid.common.ui.spi.model.DefaultCubridNode in project cubrid-manager by CUBRID.
the class RemoveAllAccessLogAction method run.
/**
* Remove all access log
*/
public void run() {
if (!CommonUITool.openConfirmBox(Messages.warningRemoveLog)) {
return;
}
Object[] selected = this.getSelectedObj();
DelAllLogTask delAllLogTask = new DelAllLogTask(((DefaultCubridNode) selected[0]).getServer().getServerInfo());
String[] path = new String[((DefaultCubridNode) selected[0]).getChildren().size()];
for (int i = 0, len = path.length; i < len; i++) {
path[i] = ((LogInfo) (((DefaultCubridNode) selected[0]).getChildren().get(i).getAdapter(LogInfo.class))).getPath();
}
delAllLogTask.setPath(path);
TaskExecutor taskExecutor = new CommonTaskExec(Messages.removeLogTaskName);
taskExecutor.addTask(delAllLogTask);
new ExecTaskWithProgress(taskExecutor).busyCursorWhile();
if (taskExecutor.isSuccess()) {
TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
DefaultCubridNode delNode = ((DefaultCubridNode) selected[0]);
ICubridNode parentNode = delNode.getParent().getParent();
parentNode.removeChild(delNode);
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return;
}
IWorkbenchPage activePage = window.getActivePage();
for (int i = 0, len = path.length; i < len; i++) {
IEditorPart editor = activePage.findEditor(((DefaultCubridNode) selected[0]).getChildren().get(i));
treeViewer.remove(((DefaultCubridNode) selected[0]).getChildren().get(i));
if (null != editor) {
activePage.closeEditor(editor, true);
}
}
}
}
Aggregations