use of com.cubrid.common.ui.spi.model.CubridDatabase in project cubrid-manager by CUBRID.
the class LoginQueryEditDialog method initial.
/**
* initialize some values
*
*/
private void initial() {
//load the register CUBRID server and CUBRID database
List<CubridServer> servers = CMHostNodePersistManager.getInstance().getAllServers();
serverMap = new HashMap<String, CubridServer>();
databaseMap = new HashMap<String, List<CubridDatabase>>();
allHostCombo.removeAll();
for (CubridServer server : servers) {
serverMap.put(server.getName(), server);
allHostCombo.add(server.getName());
List<ICubridNode> children = server.getChildren();
for (ICubridNode child : children) {
if (!NodeType.DATABASE_FOLDER.equals(child.getType())) {
continue;
}
ICubridNode[] dbs = child.getChildren(new NullProgressMonitor());
if (dbs.length == 0) {
continue;
}
List<CubridDatabase> dbList = new ArrayList<CubridDatabase>();
for (ICubridNode database : dbs) {
if (NodeType.DATABASE.equals(database.getType())) {
CubridDatabase db = (CubridDatabase) database;
dbList.add(db);
}
}
databaseMap.put(server.getName(), dbList);
}
}
//load the self defined CUBRID server and CUBRID database
CubridServer selfDefinedServer = DatabaseNavigatorMenu.SELF_DATABASE.getServer();
if (selfDefinedServer == null) {
selfDefinedServer = new CubridServer(DatabaseNavigatorMenu.SELF_DATABASE_ID, DatabaseNavigatorMenu.SELF_DATABASE_SELECTED_LABEL, null, null);
DatabaseNavigatorMenu.SELF_DATABASE.setServer(selfDefinedServer);
}
serverMap.put(selfDefinedServer.getName(), selfDefinedServer);
allHostCombo.add(selfDefinedServer.getName());
List<CubridDatabase> dbList = new ArrayList<CubridDatabase>();
dbList.add(DatabaseNavigatorMenu.SELF_DATABASE);
databaseMap.put(selfDefinedServer.getName(), dbList);
connectionComp.init(null, this);
changeSelection();
}
use of com.cubrid.common.ui.spi.model.CubridDatabase in project cubrid-manager by CUBRID.
the class ShowDatabaseDashboardAction method isSupported.
/**
*
* @see com.cubrid.common.ui.spi.action.ISelectionAction#isSupported(java
* .lang.Object)
* @param obj the object
* @return <code>true</code> if support this object;<code>false</code>
* otherwise
*/
public boolean isSupported(Object obj) {
if (obj instanceof ISchemaNode) {
ISchemaNode node = (ISchemaNode) obj;
CubridDatabase database = node.getDatabase();
if (CubridNodeType.DATABASE.equals(node.getType()) && database.isLogined()) {
return true;
}
}
return false;
}
use of com.cubrid.common.ui.spi.model.CubridDatabase in project cubrid-manager by CUBRID.
the class StartDatabaseAction method doRun.
public void doRun(ISchemaNode[] schemaArray) {
if (schemaArray == null || schemaArray.length == 0) {
return;
}
List<ISchemaNode> startList = new ArrayList<ISchemaNode>();
/*Judge start job is running*/
for (ISchemaNode node : schemaArray) {
if (!isSupported(node)) {
setEnabled(false);
return;
}
CubridDatabase database = node.getDatabase();
final JobFamily jobFamily = new JobFamily();
String serverName = database.getServer().getName();
String dbName = database.getName();
jobFamily.setServerName(serverName);
jobFamily.setDbName(dbName);
Job[] jobs = Job.getJobManager().find(jobFamily);
if (jobs.length > 0) {
CommonUITool.openWarningBox(Messages.bind(Messages.msgStartDbWithJob, dbName));
continue;
}
startList.add(database);
}
CubridNavigatorView navigationView = CubridNavigatorView.findNavigationView();
if (navigationView != null && startList.size() > 0) {
final TreeViewer treeViewer = navigationView.getViewer();
TaskExecutor taskExcutor = new TaskExecutor() {
public boolean exec(final IProgressMonitor monitor) {
Display display = Display.getDefault();
if (monitor.isCanceled()) {
return false;
}
for (int i = 0; i < taskList.size(); i++) {
ITask task = taskList.get(i);
final CubridDatabase database = (CubridDatabase) task.getData("dbName");
if (!isSupported(database)) {
continue;
}
monitor.subTask(Messages.bind(Messages.startDbTaskName, database.getName()));
task.execute();
if (openErrorBox(shell, task.getErrorMsg(), monitor) || monitor.isCanceled()) {
return false;
}
openWarningBox(shell, task.getWarningMsg(), monitor);
if (monitor.isCanceled()) {
return false;
}
database.removeAllChild();
if (database.getLoader() != null) {
database.getLoader().setLoaded(false);
}
database.setRunningType(DbRunningType.CS);
display.syncExec(new Runnable() {
public void run() {
treeViewer.refresh(database, true);
}
});
if (monitor.isCanceled()) {
return false;
}
}
return true;
}
};
for (ISchemaNode schemaNode : startList) {
CubridDatabase database = schemaNode.getDatabase();
if (!isSupported(database)) {
setEnabled(false);
return;
}
ServerInfo serverInfo = database.getServer().getServerInfo();
CommonUpdateTask task = new CommonUpdateTask(CommonTaskName.START_DB_TASK_NAME, serverInfo, CommonSendMsg.getCommonDatabaseSendMsg());
task.setDbName(database.getLabel());
task.putData("dbName", database);
taskExcutor.addTask(task);
}
new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
ActionManager.getInstance().fireSelectionChanged(getSelection());
}
}
use of com.cubrid.common.ui.spi.model.CubridDatabase in project cubrid-manager by CUBRID.
the class TransactionInfoAction method run.
public void run() {
Object[] obj = this.getSelectedObj();
if (!isSupported(obj[0])) {
setEnabled(false);
return;
}
ISchemaNode node = (ISchemaNode) obj[0];
final CubridDatabase database = node.getDatabase();
if (database == null) {
CommonUITool.openErrorBox(getShell(), Messages.msgSelectDB);
return;
}
TransactionInfoDialog dlg = new TransactionInfoDialog(getShell());
dlg.setDatabase(database);
try {
if (dlg.loadData(getShell())) {
dlg.open();
}
} catch (Exception e) {
LOGGER.error(e.getMessage(), e);
}
}
use of com.cubrid.common.ui.spi.model.CubridDatabase in project cubrid-manager by CUBRID.
the class UnloadDatabaseAction method run.
public void run() {
Object[] obj = this.getSelectedObj();
if (!isSupported(obj[0])) {
setEnabled(false);
return;
}
ISchemaNode node = (ISchemaNode) obj[0];
final CubridDatabase database = node.getDatabase();
final UnloadDatabaseDialog dialog = new UnloadDatabaseDialog(getShell());
dialog.setDatabase(database);
final Shell shell = getShell();
TaskExecutor taskExcutor = new TaskExecutor() {
public boolean exec(final IProgressMonitor monitor) {
if (monitor.isCanceled()) {
return false;
}
monitor.beginTask(Messages.loadAllClassTaskName, IProgressMonitor.UNKNOWN);
for (ITask task : taskList) {
task.execute();
final String msg = task.getErrorMsg();
if (openErrorBox(shell, msg, monitor)) {
return false;
}
if (monitor.isCanceled()) {
return false;
}
if (task instanceof GetClassListTask) {
GetClassListTask getClassListTask = (GetClassListTask) task;
List<String> allUserClassList = new ArrayList<String>();
DBClasses dbClasses = getClassListTask.getDbClassInfo();
List<ClassItem> userClassList = dbClasses == null ? null : dbClasses.getUserClassList().getClassList();
if (userClassList != null && !userClassList.isEmpty()) {
for (ClassItem userClass : userClassList) {
allUserClassList.add(userClass.getClassname());
}
}
Collections.sort(allUserClassList);
dialog.setUserClassList(allUserClassList);
}
}
return true;
}
};
ServerInfo serverInfo = database.getServer().getServerInfo();
GetClassListTask task = new GetClassListTask(serverInfo, database.getDatabaseInfo().getCharSet());
task.setDbName(database.getLabel());
task.setDbStatus(OnOffType.OFF);
taskExcutor.addTask(task);
new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
if (taskExcutor.isSuccess()) {
dialog.open();
}
}
Aggregations