use of com.cubrid.common.ui.spi.model.ISchemaNode in project cubrid-manager by CUBRID.
the class CreateLikeTableAction method run.
/**
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
Object[] objArr = this.getSelectedObj();
if (objArr == null || !isSupported(objArr)) {
setEnabled(false);
return;
}
ISchemaNode node = (ISchemaNode) objArr[0];
if (node == null) {
return;
}
doRun(node);
}
use of com.cubrid.common.ui.spi.model.ISchemaNode in project cubrid-manager by CUBRID.
the class QueryEditorDNDController method fillInSelectedNode.
/**
*
* Fill in the selected node
*
* @param schemaNodeList all table nodes
* @param columnNodeMap all columns node
* @return boolean
*/
private boolean fillInSelectedNode(List<ISchemaNode> schemaNodeList, Map<String, List<ISchemaNode>> columnNodeMap) {
TreeViewer treeViewer = perspectiveTreeviewerMap.get(PerspectiveManager.getInstance().getCurrentPerspectiveId());
if (treeViewer == null) {
return false;
}
ISelection selection = treeViewer.getSelection();
if (!(selection instanceof TreeSelection)) {
return false;
}
TreeSelection ts = (TreeSelection) selection;
Object[] objs = ts.toArray();
String dbId = null;
for (Object obj : objs) {
if (obj instanceof ISchemaNode) {
ISchemaNode node = (ISchemaNode) obj;
CubridDatabase database = node.getDatabase();
if (dbId == null) {
dbId = database.getId();
}
if (!dbId.equals(database.getId())) {
return false;
}
String type = node.getType();
if (NodeType.SYSTEM_TABLE.equals(type) || NodeType.SYSTEM_VIEW.equals(type) || NodeType.USER_TABLE.equals(type) || NodeType.USER_PARTITIONED_TABLE.equals(type) || NodeType.USER_VIEW.equals(type) || NodeType.USER_PARTITIONED_TABLE_FOLDER.equals(type)) {
schemaNodeList.add(node);
} else if (NodeType.TABLE_COLUMN.equals(type)) {
String name = node.getParent().getParent().getName();
List<ISchemaNode> columnNodeList = columnNodeMap.get(name);
if (columnNodeList == null) {
columnNodeList = new ArrayList<ISchemaNode>();
columnNodeMap.put(name, columnNodeList);
}
columnNodeList.add(node);
}
}
}
return true;
}
use of com.cubrid.common.ui.spi.model.ISchemaNode in project cubrid-manager by CUBRID.
the class CubridTablesFolderLoader method createUserTableNodes.
/**
* Create user table node
*
* @param parent ICubridNode
* @param allClassInfoList A list includes all the class info
* @param level The load level
* @param monitor The IProgressMonitor
*/
private void createUserTableNodes(ICubridNode parent, List<ClassInfo> allClassInfoList, int level, IProgressMonitor monitor) {
List<String> tables = new ArrayList<String>();
for (ClassInfo classInfo : allClassInfoList) {
String id = parent.getId() + NODE_SEPARATOR + classInfo.getClassName();
ICubridNode classNode = new DefaultSchemaNode(id, classInfo.getClassName(), "icons/navigator/schema_table_item.png");
classNode.setEditorId(SchemaInfoEditorPart.ID);
classNode.setContainer(true);
classNode.setModelObj(classInfo);
classNode.setType(NodeType.USER_TABLE);
parent.addChild(classNode);
ICubridNodeLoader loader = null;
if (classInfo.isPartitionedClass()) {
classNode.setType(NodeType.USER_PARTITIONED_TABLE_FOLDER);
classNode.setIconPath("icons/navigator/schema_table_partition.png");
classNode.setContainer(true);
loader = new CubridPartitionedTableLoader();
} else {
loader = new CubridUserTableLoader();
}
loader.setLevel(level);
classNode.setLoader(loader);
tables.add(classInfo.getClassName());
}
if (level == DEFINITE_LEVEL) {
CubridDatabase database = ((ISchemaNode) parent).getDatabase();
DatabaseInfo databaseInfo = database.getDatabaseInfo();
final GetUserClassColumnsTask task = new GetUserClassColumnsTask(databaseInfo);
monitorCancel(monitor, new ITask[] { task });
Map<String, List<TableColumn>> columnsOfTable = task.getColumns(tables);
final String errorMsg = task.getErrorMsg();
if (!monitor.isCanceled() && !task.isInTransation() && errorMsg != null && errorMsg.trim().length() > 0) {
Display display = Display.getDefault();
display.syncExec(new Runnable() {
public void run() {
CommonUITool.openErrorBox(errorMsg);
}
});
parent.removeAllChild();
setLoaded(true);
return;
}
if (monitor.isCanceled()) {
setLoaded(true);
return;
}
for (ClassInfo classInfo : allClassInfoList) {
String tableId = parent.getId() + NODE_SEPARATOR + classInfo.getClassName();
ICubridNode node = parent.getChild(tableId);
CubridUserTableLoader tableLoader = (CubridUserTableLoader) node.getLoader();
tableLoader.setColumns(columnsOfTable.get(classInfo.getClassName()));
node.getChildren(monitor);
tableLoader.setLoaded(true);
}
}
}
use of com.cubrid.common.ui.spi.model.ISchemaNode in project cubrid-manager by CUBRID.
the class CubridTriggerFolderLoader method load.
/**
*
* Load children object for parent
*
* @param parent the parent node
* @param monitor the IProgressMonitor object
*/
public void load(ICubridNode parent, final IProgressMonitor monitor) {
synchronized (this) {
if (isLoaded()) {
return;
}
CubridDatabase database = ((ISchemaNode) parent).getDatabase();
if (!database.isLogined() || database.getRunningType() == DbRunningType.STANDALONE) {
database.getDatabaseInfo().setTriggerList(null);
parent.removeAllChild();
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
return;
}
DatabaseInfo databaseInfo = database.getDatabaseInfo();
ITask task = null;
if (ApplicationType.CUBRID_MANAGER.equals(PerspectiveManager.getInstance().getCurrentMode())) {
task = new GetTriggerListTask(parent.getServer().getServerInfo());
((GetTriggerListTask) task).setDbName(database.getLabel());
} else {
task = new JDBCGetTriggerListTask(databaseInfo);
}
monitorCancel(monitor, new ITask[] { task });
task.execute();
final String errorMsg = task.getErrorMsg();
if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
parent.removeAllChild();
openErrorBox(errorMsg);
setLoaded(true);
return;
}
if (monitor.isCanceled()) {
setLoaded(true);
return;
}
parent.removeAllChild();
List<Trigger> triggerList = null;
if (task instanceof GetTriggerListTask) {
triggerList = ((GetTriggerListTask) task).getTriggerInfoList();
} else if (task instanceof JDBCGetTriggerListTask) {
triggerList = ((JDBCGetTriggerListTask) task).getTriggerInfoList();
}
if (triggerList != null && !triggerList.isEmpty()) {
for (Trigger trigger : triggerList) {
String id = parent.getId() + NODE_SEPARATOR + trigger.getName();
ICubridNode triggerNode = createTriggerNode(id, trigger);
parent.addChild(triggerNode);
}
}
databaseInfo.setTriggerList(triggerList);
Collections.sort(parent.getChildren());
setLoaded(true);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
}
}
use of com.cubrid.common.ui.spi.model.ISchemaNode in project cubrid-manager by CUBRID.
the class CubridSystemTableFolderLoader method load.
/**
*
* Load children object for parent
*
* @param parent the parent node
* @param monitor the IProgressMonitor object
*/
public void load(ICubridNode parent, final IProgressMonitor monitor) {
synchronized (this) {
if (isLoaded()) {
return;
}
CubridDatabase database = ((ISchemaNode) parent).getDatabase();
if (!database.isLogined() || database.getRunningType() == DbRunningType.STANDALONE) {
database.getDatabaseInfo().setSysTableInfoList(null);
parent.removeAllChild();
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
return;
}
DatabaseInfo databaseInfo = database.getDatabaseInfo();
final GetAllClassListTask task = new GetAllClassListTask(databaseInfo);
monitorCancel(monitor, new ITask[] { task });
List<ClassInfo> allClassInfoList = task.getSchema(false, true);
final String errorMsg = task.getErrorMsg();
if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
parent.removeAllChild();
openErrorBox(errorMsg);
setLoaded(true);
return;
}
if (monitor.isCanceled()) {
setLoaded(true);
return;
}
parent.removeAllChild();
if (allClassInfoList != null) {
for (ClassInfo classInfo : allClassInfoList) {
String id = parent.getId() + NODE_SEPARATOR + classInfo.getClassName();
ICubridNode classNode = new DefaultSchemaNode(id, classInfo.getClassName(), "icons/navigator/schema_table_item.png");
classNode.setType(NodeType.SYSTEM_TABLE);
classNode.setEditorId(SchemaInfoEditorPart.ID);
classNode.setContainer(false);
classNode.setModelObj(classInfo);
parent.addChild(classNode);
}
}
database.getDatabaseInfo().setSysTableInfoList(allClassInfoList);
Collections.sort(parent.getChildren());
setLoaded(true);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
}
}
Aggregations