use of com.cubrid.common.ui.spi.model.ICubridNode in project cubrid-manager by CUBRID.
the class OpenJobAutomationInfoAction method run.
public void run() {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return;
}
final Object[] obj = this.getSelectedObj();
if (!isSupported(obj) || obj.length == 0) {
setEnabled(false);
return;
}
ICubridNode node = (ICubridNode) obj[0];
if (node.getType().equals(CubridNodeType.JOB_FOLDER)) {
CubridNavigatorView 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);
}
}
openJobsDetailInfoEditor(NodeUtil.getCubridDatabase(node));
}
}
use of com.cubrid.common.ui.spi.model.ICubridNode in project cubrid-manager by CUBRID.
the class AddBackupPlanAction method run.
/**
* Creates a Dialog which is the instance of EditBackupPlanDialog to add a backup plan
*
* @param database
*/
public void run(CubridDatabase database) {
TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
ICubridNode jobAutoFolderNode = database.getChild(database.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridDatabaseLoader.JOB_AUTO_FOLDER_ID);
DefaultSchemaNode buckupPlanFolderNode = (DefaultSchemaNode) jobAutoFolderNode.getChild(jobAutoFolderNode.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridJobAutoFolderLoader.BACKUP_PLAN_FOLDER_ID);
EditBackupPlanDialog editBackupPlanDlg = new EditBackupPlanDialog(getShell(), true);
editBackupPlanDlg.setOperation(AddEditType.ADD);
editBackupPlanDlg.initPara(buckupPlanFolderNode);
if (editBackupPlanDlg.open() == Dialog.OK) {
BackupPlanInfo backupPlanInfo = editBackupPlanDlg.getBackupPlanInfo();
String newBackupId = backupPlanInfo.getBackupid();
DefaultSchemaNode newNode = new DefaultSchemaNode(newBackupId, newBackupId, ICON_PATH);
newNode.setContainer(false);
newNode.setType(CubridNodeType.BACKUP_PLAN);
newNode.setModelObj(backupPlanInfo);
buckupPlanFolderNode.addChild(newNode);
treeViewer.add(buckupPlanFolderNode, newNode);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(newNode, CubridNodeChangedEventType.NODE_ADD));
} else {
canceledTask = true;
}
}
use of com.cubrid.common.ui.spi.model.ICubridNode in project cubrid-manager by CUBRID.
the class DeleteBackupPlanAction method run.
/**
* Deletes the selected backup plan
*
*/
public void run(ISchemaNode[] nodeArray) {
List<String> nodeNames = new ArrayList<String>();
for (Object obj : nodeArray) {
ICubridNode selection = (ICubridNode) obj;
nodeNames.add(selection.getLabel());
}
if (!CommonUITool.openConfirmBox(Messages.bind(Messages.delBackupPlanConfirmContent, nodeNames))) {
return;
}
String taskName = Messages.bind(Messages.delBackupPlanTaskName, nodeNames);
CommonTaskExec taskExecutor = new CommonTaskExec(taskName);
for (Object obj : nodeArray) {
CubridDatabase database = null;
if (obj instanceof DefaultSchemaNode) {
database = ((DefaultSchemaNode) obj).getDatabase();
}
if (database == null) {
CommonUITool.openErrorBox(Messages.msgSelectDB);
return;
}
ServerInfo serverInfo = database.getServer().getServerInfo();
DelBackupPlanTask delBackupPlanTask = new DelBackupPlanTask(serverInfo);
delBackupPlanTask.setDbname(database.getName());
String backupid = ((DefaultSchemaNode) obj).getLabel();
delBackupPlanTask.setBackupid(backupid);
taskExecutor.addTask(delBackupPlanTask);
}
new ExecTaskWithProgress(taskExecutor).exec();
if (!taskExecutor.isSuccess()) {
return;
}
for (Object obj : nodeArray) {
TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
DefaultSchemaNode delNode = ((DefaultSchemaNode) obj);
ICubridNode parentNode = delNode.getParent();
parentNode.removeChild(delNode);
treeViewer.remove(delNode);
}
}
use of com.cubrid.common.ui.spi.model.ICubridNode in project cubrid-manager by CUBRID.
the class VolumeFolderInfoEditor method nodeChanged.
/**
*
* @see com.cubrid.common.ui.spi.event.ICubridNodeChangedListener#nodeChanged(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)
* @param event the CubridNodeChangedEvent object
*/
public void nodeChanged(CubridNodeChangedEvent event) {
ICubridNode eventNode = event.getCubridNode();
if (!(eventNode instanceof ISchemaNode) || event.getType() != CubridNodeChangedEventType.CONTAINER_NODE_REFRESH || cubridNode == null) {
return;
}
if (!CubridNodeType.DBSPACE_FOLDER.equals(eventNode.getType())) {
return;
}
ISchemaNode eventSchemaNode = (ISchemaNode) eventNode;
ISchemaNode schemaNode = (ISchemaNode) cubridNode;
if (!eventSchemaNode.getDatabase().getId().equals(schemaNode.getDatabase().getId())) {
return;
}
synchronized (this) {
if (database.getDatabaseInfo().getDbSpaceInfoList() == null) {
loadData();
}
}
}
use of com.cubrid.common.ui.spi.model.ICubridNode in project cubrid-manager by CUBRID.
the class DBSpaceLabelProvider method nodeChanged.
/**
* Perform node change event
*/
public void nodeChanged(CubridNodeChangedEvent event) {
ICubridNode cubridNode = event.getCubridNode();
CubridNodeChangedEventType eventType = event.getType();
if (cubridNode == null || eventType == null) {
return;
}
if (NodeType.SERVER.equals(cubridNode.getType())) {
if (CubridNodeChangedEventType.SERVER_DISCONNECTED.equals(eventType) || CubridNodeChangedEventType.NODE_REMOVE.equals(eventType)) {
if (serverInfo != null && StringUtil.isEqualNotIgnoreNull(cubridNode.getName(), serverInfo.getServerName())) {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return;
}
window.getActivePage().closeEditor(this, true);
}
}
}
}
Aggregations