use of com.cubrid.common.ui.cubrid.table.dialog.CreateViewDialog in project cubrid-manager by CUBRID.
the class PropertyViewAction method run.
/**
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
Object[] obj = this.getSelectedObj();
if (!isSupported(obj)) {
setEnabled(false);
return;
}
ISchemaNode node = (ISchemaNode) obj[0];
CubridDatabase database = node.getDatabase();
CreateViewDialog dialog = new CreateViewDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), database, false);
GetAllClassListTask getAllClassListTask = new GetAllClassListTask(database.getDatabaseInfo());
getAllClassListTask.setTableName(node.getName());
GetViewAllColumnsTask getAllDBVclassTask = new GetViewAllColumnsTask(database.getDatabaseInfo());
getAllDBVclassTask.setClassName(node.getName());
GetAllAttrTask getAllAttrTask = new GetAllAttrTask(database.getDatabaseInfo());
getAllAttrTask.setClassName(node.getName());
JDBCGetAllDbUserTask getAllDbUserTask = new JDBCGetAllDbUserTask(database.getDatabaseInfo());
dialog.execTask(-1, new ITask[] { getAllClassListTask, getAllDBVclassTask, getAllAttrTask, getAllDbUserTask }, true, getShell());
if (getAllClassListTask.getErrorMsg() != null || getAllDBVclassTask.getErrorMsg() != null || getAllAttrTask.getErrorMsg() != null || getAllDbUserTask.getErrorMsg() != null || getAllClassListTask.isCancel() || getAllDBVclassTask.isCancel() || getAllAttrTask.isCancel() || getAllDbUserTask.isCancel()) {
return;
}
ClassInfo classInfo = getAllClassListTask.getClassInfo();
List<String> vclassList = getAllDBVclassTask.getAllVclassList();
List<DBAttribute> attrList = getAllAttrTask.getAllAttrList();
List<String> dbUserList = getAllDbUserTask.getDbUserList();
dialog.setAttrList(attrList);
dialog.setClassInfo(classInfo);
dialog.setVclassList(vclassList);
dialog.setDbUserList(dbUserList);
dialog.setPropertyQuery(true);
dialog.open();
}
use of com.cubrid.common.ui.cubrid.table.dialog.CreateViewDialog in project cubrid-manager by CUBRID.
the class CreateViewAction method run.
public void run(CubridDatabase database) {
TaskExecutor taskExcutor = new CommonTaskExec(null);
DatabaseInfo databaseInfo = database.getDatabaseInfo();
JDBCGetAllDbUserTask task = new JDBCGetAllDbUserTask(databaseInfo);
taskExcutor.addTask(task);
new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
if (!taskExcutor.isSuccess()) {
return;
}
List<String> dbUserList = task.getDbUserList();
CreateViewDialog dialog = new CreateViewDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), database, true);
dialog.setDbUserList(dbUserList);
ISelectionProvider provider = getSelectionProvider();
if (dialog.open() == IDialogConstants.OK_ID && (provider instanceof TreeViewer)) {
TreeViewer treeViewer = (TreeViewer) provider;
ICubridNode folderNode = database.getChild(database.getId() + ICubridNodeLoader.NODE_SEPARATOR + CubridViewsFolderLoader.VIEWS_FOLDER_ID);
if (folderNode == null || !folderNode.getLoader().isLoaded()) {
return;
}
String viewName = dialog.getNewViewName();
String owner = dialog.getOwner();
String id = folderNode.getId() + ICubridNodeLoader.NODE_SEPARATOR + viewName;
ClassInfo newClassInfo = new ClassInfo(viewName, owner, ClassType.VIEW, false, false);
ICubridNode newNode = CubridViewsFolderLoader.createUserViewNode(id, newClassInfo);
CommonUITool.addNodeToTree(treeViewer, folderNode, newNode);
CommonUITool.updateFolderNodeLabelIncludingChildrenCount(treeViewer, folderNode);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(newNode, CubridNodeChangedEventType.NODE_ADD));
} else {
canceledTask = true;
}
}
use of com.cubrid.common.ui.cubrid.table.dialog.CreateViewDialog in project cubrid-manager by CUBRID.
the class EditViewAction method run.
/**
* run edit view
* @param ISchemaNode viewNode
* @param database CubridDatabase
*/
public int run(CubridDatabase database, ISchemaNode node) {
CreateViewDialog dialog = new CreateViewDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), database, false);
GetAllClassListTask getAllClassListTask = new GetAllClassListTask(database.getDatabaseInfo());
getAllClassListTask.setTableName(node.getName());
GetViewAllColumnsTask getAllDBVclassTask = new GetViewAllColumnsTask(database.getDatabaseInfo());
getAllDBVclassTask.setClassName(node.getName());
GetAllAttrTask getAllAttrTask = new GetAllAttrTask(database.getDatabaseInfo());
getAllAttrTask.setClassName(node.getName());
JDBCGetAllDbUserTask getAllDbUserTask = new JDBCGetAllDbUserTask(database.getDatabaseInfo());
dialog.execTask(-1, new ITask[] { getAllClassListTask, getAllDBVclassTask, getAllAttrTask, getAllDbUserTask }, true, getShell());
if (getAllClassListTask.getErrorMsg() != null || getAllDBVclassTask.getErrorMsg() != null || getAllAttrTask.getErrorMsg() != null || getAllDbUserTask.getErrorMsg() != null || getAllClassListTask.isCancel() || getAllDBVclassTask.isCancel() || getAllAttrTask.isCancel() || getAllDbUserTask.isCancel()) {
return IDialogConstants.CANCEL_ID;
}
ClassInfo classInfo = getAllClassListTask.getClassInfo();
List<String> vclassList = getAllDBVclassTask.getAllVclassList();
List<DBAttribute> attrList = getAllAttrTask.getAllAttrList();
List<String> dbUserList = getAllDbUserTask.getDbUserList();
dialog.setAttrList(attrList);
dialog.setClassInfo(classInfo);
dialog.setVclassList(vclassList);
dialog.setDbUserList(dbUserList);
if (dialog.open() == IDialogConstants.OK_ID) {
String viewName = node.getName();
String newViewName = dialog.getNewViewName();
String owner = dialog.getOwner();
node.getDatabase().getDatabaseInfo().removeSchema(viewName);
ISelectionProvider provider = getSelectionProvider();
TreeViewer treeViewer = (TreeViewer) provider;
if (!viewName.equals(newViewName)) {
ClassInfo newClassInfo = (ClassInfo) node.getAdapter(ClassInfo.class);
newClassInfo.setClassName(newViewName);
newClassInfo.setOwnerName(owner);
node.setId(node.getParent().getId() + ICubridNodeLoader.NODE_SEPARATOR + newViewName);
node.setLabel(newViewName);
treeViewer.refresh(node, true);
}
CommonUITool.updateFolderNodeLabelIncludingChildrenCount(treeViewer, node.getParent());
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(node, CubridNodeChangedEventType.NODE_REFRESH));
ActionManager.getInstance().fireSelectionChanged(getSelection());
/*Broadcast the view changed*/
QueryEditorUtil.fireSchemaNodeChanged(node);
return IDialogConstants.OK_ID;
}
return IDialogConstants.CANCEL_ID;
}
Aggregations