use of com.cubrid.common.ui.spi.model.DefaultSchemaNode in project cubrid-manager by CUBRID.
the class AddBackupPlanAction method run.
public void run() {
Object[] obj = this.getSelectedObj();
CubridDatabase database = null;
DefaultSchemaNode selection = null;
if (obj.length > 0 && obj[0] instanceof DefaultSchemaNode) {
selection = (DefaultSchemaNode) obj[0];
database = selection.getDatabase();
}
if (database == null) {
CommonUITool.openErrorBox(Messages.msgSelectDB);
return;
}
run(database);
}
use of com.cubrid.common.ui.spi.model.DefaultSchemaNode 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.DefaultSchemaNode in project cubrid-manager by CUBRID.
the class DeleteBackupPlanAction method isSupported.
/**
* Sets this action support this object
*
* @see org.eclipse.jface.action.IAction.ISelectionAction
* @param obj Object
* @return boolean
*/
public boolean isSupported(Object obj) {
if (obj instanceof ISchemaNode) {
ISchemaNode node = (ISchemaNode) obj;
CubridDatabase database = node.getDatabase();
if (CubridNodeType.BACKUP_PLAN.equals(node.getType()) && database != null && database.isLogined()) {
DbUserInfo dbUserInfo = database.getDatabaseInfo().getAuthLoginedDbUserInfo();
if (dbUserInfo != null && dbUserInfo.isDbaAuthority()) {
return true;
}
}
} else if (obj instanceof Object[]) {
Object[] objArr = (Object[]) obj;
CubridDatabase database = null;
for (Object object : objArr) {
DefaultSchemaNode node = (DefaultSchemaNode) object;
CubridDatabase db = node.getDatabase();
if (database == null) {
database = db;
} else if (!database.getId().equals(db.getId())) {
return false;
}
}
return true;
}
return false;
}
use of com.cubrid.common.ui.spi.model.DefaultSchemaNode 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.DefaultSchemaNode in project cubrid-manager by CUBRID.
the class DeleteQueryPlanAction method isSupported.
/**
* Sets this action support this object
*
* @see org.eclipse.jface.action.IAction.ISelectionAction
* @param obj Object
* @return boolean
*/
public boolean isSupported(Object obj) {
if (obj instanceof ISchemaNode) {
ISchemaNode node = (ISchemaNode) obj;
CubridDatabase database = node.getDatabase();
if (CubridNodeType.QUERY_PLAN.equals(node.getType()) && database != null && database.isLogined()) {
DbUserInfo dbUserInfo = database.getDatabaseInfo().getAuthLoginedDbUserInfo();
if (dbUserInfo != null && dbUserInfo.isDbaAuthority()) {
return true;
}
}
} else if (obj instanceof Object[]) {
Object[] objArr = (Object[]) obj;
CubridDatabase database = null;
for (Object object : objArr) {
DefaultSchemaNode node = (DefaultSchemaNode) object;
CubridDatabase db = node.getDatabase();
if (database == null) {
database = db;
} else if (!database.getId().equals(db.getId())) {
return false;
}
}
return true;
}
return false;
}
Aggregations