use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent in project cubrid-manager by CUBRID.
the class EditBackupPlanAction method run.
/**
* Creates a Dialog which is the instance of EditBackupPlanDialog to add a
* query plan
* @param database CubridDatabase
* @param selection DefaultSchemaNode
*/
public int run(CubridDatabase database, DefaultSchemaNode selection) {
boolean isEditAble = false;
if (CubridNodeType.BACKUP_PLAN.equals(selection.getType()) && database != null && database.isLogined()) {
DbUserInfo dbUserInfo = database.getDatabaseInfo().getAuthLoginedDbUserInfo();
if (dbUserInfo != null && dbUserInfo.isDbaAuthority()) {
isEditAble = true;
}
}
EditBackupPlanDialog editBackupPlanDlg = new EditBackupPlanDialog(getShell(), isEditAble);
editBackupPlanDlg.setOperation(AddEditType.EDIT);
editBackupPlanDlg.initPara(selection);
if (editBackupPlanDlg.open() == IDialogConstants.OK_ID) {
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(selection, CubridNodeChangedEventType.NODE_REFRESH));
ActionManager.getInstance().fireSelectionChanged(getSelection());
return IDialogConstants.OK_ID;
}
return IDialogConstants.CANCEL_ID;
}
use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent in project cubrid-manager by CUBRID.
the class EditQueryPlanAction method run.
/**
*
* Creates a Dialog which is the instance of EditBackupPlanDialog to edit a
* query plan
*
*/
public int run(CubridDatabase database, DefaultSchemaNode schemaNode) {
if (database == null) {
CommonUITool.openErrorBox(Messages.msgSelectDB);
return IDialogConstants.CANCEL_ID;
}
boolean withUser = CompatibleUtil.isSupportQueryPlanWithUser(database.getDatabaseInfo());
boolean isEditAble = false;
if (CubridNodeType.QUERY_PLAN.equals(schemaNode.getType()) && database != null && database.isLogined()) {
DbUserInfo dbUserInfo = database.getDatabaseInfo().getAuthLoginedDbUserInfo();
if (dbUserInfo != null && dbUserInfo.isDbaAuthority()) {
isEditAble = true;
}
}
EditQueryPlanDialog editQueryPlanDlg = new EditQueryPlanDialog(getShell(), isEditAble);
editQueryPlanDlg.setOperation(AddEditType.EDIT);
editQueryPlanDlg.initPara(schemaNode);
if (editQueryPlanDlg.open() == Dialog.OK) {
// Sets the data of task
List<ICubridNode> list = schemaNode.getParent().getChildren();
List<String> msgList = new ArrayList<String>();
QueryPlanInfo queryPlan = null;
QueryPlanInfoHelp qHelp = new QueryPlanInfoHelp();
for (ICubridNode icn : list) {
if (!icn.isContainer()) {
queryPlan = (QueryPlanInfo) icn.getAdapter(QueryPlanInfo.class);
qHelp.setQueryPlanInfo(queryPlan);
msgList.add(qHelp.buildMsg(withUser));
}
}
ServerInfo serverInfo = database.getServer().getServerInfo();
SetQueryPlanListTask task = new SetQueryPlanListTask(serverInfo);
task.setDbname(database.getName());
task.buildMsg(msgList);
String taskName = Messages.bind(com.cubrid.cubridmanager.ui.cubrid.jobauto.Messages.editQueryPlanTaskName, schemaNode.getName());
TaskExecutor taskExecutor = new CommonTaskExec(taskName);
taskExecutor.addTask(task);
new ExecTaskWithProgress(taskExecutor).exec();
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(schemaNode, CubridNodeChangedEventType.NODE_REFRESH));
ActionManager.getInstance().fireSelectionChanged(getSelection());
return IDialogConstants.OK_ID;
}
return IDialogConstants.CANCEL_ID;
}
use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent in project cubrid-manager by CUBRID.
the class AddQueryPlanAction method run.
public void run(CubridDatabase database) {
ICubridNode jobAutoFolderNode = database.getChild(database.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridDatabaseLoader.JOB_AUTO_FOLDER_ID);
DefaultSchemaNode queryPlanFolderNode = (DefaultSchemaNode) jobAutoFolderNode.getChild(jobAutoFolderNode.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridJobAutoFolderLoader.QUERY_PLAN_FOLDER_ID);
boolean withUser = false;
if (CompatibleUtil.isSupportQueryPlanWithUser(database.getDatabaseInfo())) {
withUser = true;
}
TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
EditQueryPlanDialog editQueryPlanDlg = new EditQueryPlanDialog(getShell(), true);
editQueryPlanDlg.setDatabase(database);
editQueryPlanDlg.setOperation(AddEditType.ADD);
editQueryPlanDlg.initPara(queryPlanFolderNode);
DefaultSchemaNode newNode = null;
if (editQueryPlanDlg.open() == Dialog.OK) {
// Sets the data of task
QueryPlanInfoHelp queryPlanInfoHelp = editQueryPlanDlg.getQueryPlanInfo();
QueryPlanInfo queryPlanInfo = queryPlanInfoHelp.getQueryPlanInfo();
String newQueryId = queryPlanInfoHelp.getQuery_id();
newNode = new DefaultSchemaNode(newQueryId, newQueryId, ICON_PATH);
newNode.setContainer(false);
newNode.setType(CubridNodeType.QUERY_PLAN);
newNode.setModelObj(queryPlanInfo);
List<ICubridNode> list = queryPlanFolderNode.getChildren();
List<String> msgList = new ArrayList<String>();
QueryPlanInfo queryPlan = null;
QueryPlanInfoHelp qHelp = new QueryPlanInfoHelp();
for (ICubridNode icn : list) {
if (!icn.isContainer()) {
queryPlan = (QueryPlanInfo) icn.getAdapter(QueryPlanInfo.class);
qHelp.setQueryPlanInfo(queryPlan);
msgList.add(qHelp.buildMsg(withUser));
}
}
qHelp.setQueryPlanInfo(queryPlanInfo);
msgList.add(qHelp.buildMsg(withUser));
ServerInfo serverInfo = database.getServer().getServerInfo();
SetQueryPlanListTask task = new SetQueryPlanListTask(serverInfo);
task.setDbname(database.getName());
task.buildMsg(msgList);
String taskName = Messages.bind(com.cubrid.cubridmanager.ui.cubrid.jobauto.Messages.addQueryPlanTaskName, newQueryId);
TaskExecutor taskExecutor = new CommonTaskExec(taskName);
taskExecutor.addTask(task);
new ExecTaskWithProgress(taskExecutor).exec();
if (!taskExecutor.isSuccess()) {
return;
}
} else {
canceledTask = true;
}
if (null != newNode) {
queryPlanFolderNode.addChild(newNode);
treeViewer.add(queryPlanFolderNode, newNode);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(newNode, CubridNodeChangedEventType.NODE_ADD));
}
}
Aggregations