use of com.cubrid.common.ui.spi.model.ISchemaNode in project cubrid-manager by CUBRID.
the class OIDNavigatorAction method run.
public void run() {
Object[] obj = this.getSelectedObj();
if (!isSupported(obj)) {
this.setEnabled(false);
return;
}
ISchemaNode node = (ISchemaNode) obj[0];
CubridDatabase database = node.getDatabase();
Connection conn = null;
try {
conn = JDBCConnectionManager.getConnection(database.getDatabaseInfo(), true);
OIDNavigatorDialog dialog = new OIDNavigatorDialog(getShell(), conn, null);
dialog.open();
} catch (SQLException e) {
LOGGER.error("Can not request oid information by jdbc.", e);
//TODO: error message localizing
String message = Messages.bind(Messages.errCommonTip, e.getErrorCode(), e.getMessage());
CommonUITool.openErrorBox(message);
} finally {
QueryUtil.freeQuery(conn);
}
}
use of com.cubrid.common.ui.spi.model.ISchemaNode in project cubrid-manager by CUBRID.
the class FavoriteQueryNavigatorView method getCurrentDatabase.
/**
* Return current selected database from the navigation tree.
* @return CubridDatabase
*/
private CubridDatabase getCurrentDatabase() {
CubridDatabase cubridDatabase = null;
CubridNavigatorView nav = CubridNavigatorView.findNavigationView();
if (nav != null) {
TreeItem[] items = nav.getSelectedItems();
if (items.length > 0 && items[0] != null && items[0].getData() instanceof ISchemaNode) {
ISchemaNode node = (ISchemaNode) items[0].getData();
CubridDatabase tempDatabase = node.getDatabase();
if (tempDatabase != null && tempDatabase.isLogined()) {
cubridDatabase = tempDatabase;
}
}
}
return cubridDatabase;
}
use of com.cubrid.common.ui.spi.model.ISchemaNode in project cubrid-manager by CUBRID.
the class BackupDatabaseAction 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 BackupDatabaseDialog dialog = new BackupDatabaseDialog(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.loadDbBackupInfoTaskName, 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 GetDbBackupInfoTask) {
GetDbBackupInfoTask getDbBackupInfoTask = (GetDbBackupInfoTask) task;
dialog.setDbBackupInfo(getDbBackupInfoTask.getDbBackupInfo());
} else if (task instanceof GetCubridConfParameterTask) {
GetCubridConfParameterTask getCubridConfParameterTask = (GetCubridConfParameterTask) task;
Map<String, Map<String, String>> confParas = getCubridConfParameterTask.getConfParameters();
Map<String, String> commonParas = confParas.get(ConfConstants.COMMON_SECTION_NAME);
Map<String, String> dbParas = confParas.get("[@" + database.getLabel() + "]");
String str = dbParas == null ? null : dbParas.get(ConfConstants.REPLICATION);
boolean isReplication = "yes".equals(str);
if (!isReplication) {
str = commonParas == null ? null : commonParas.get(ConfConstants.REPLICATION);
isReplication = "yes".equals(str);
}
dialog.setReplication(isReplication);
}
}
return true;
}
};
ServerInfo serverInfo = database.getServer().getServerInfo();
GetCubridConfParameterTask getCubridConfParameterTask = new GetCubridConfParameterTask(serverInfo);
taskExcutor.addTask(getCubridConfParameterTask);
GetDbBackupInfoTask getDbBackupInfoTask = new GetDbBackupInfoTask(serverInfo);
getDbBackupInfoTask.setDbName(database.getLabel());
taskExcutor.addTask(getDbBackupInfoTask);
new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
if (taskExcutor.isSuccess()) {
dialog.open();
}
}
use of com.cubrid.common.ui.spi.model.ISchemaNode in project cubrid-manager by CUBRID.
the class SpaceInfoViewAction method isSupported.
/**
* Return whether this action support this object,if not support,this action
* will be disabled
*
* @see com.cubrid.common.ui.spi.action.ISelectionAction#isSupported(java
* .lang.Object)
* @param obj the Object
* @return <code>true</code> if support this obj;<code>false</code>
* otherwise
*/
public boolean isSupported(Object obj) {
if (obj instanceof ISchemaNode) {
ISchemaNode node = (ISchemaNode) obj;
CubridDatabase database = node.getDatabase();
DbUserInfo dbUserInfo = database.getDatabaseInfo().getAuthLoginedDbUserInfo();
String type = node.getType();
if ((CubridNodeType.GENERIC_VOLUME.equals(type) || CubridNodeType.DATA_VOLUME.equals(type) || CubridNodeType.INDEX_VOLUME.equals(type) || CubridNodeType.TEMP_VOLUME.equals(type)) && (dbUserInfo != null && database.isLogined())) {
return true;
}
}
return false;
}
use of com.cubrid.common.ui.spi.model.ISchemaNode 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;
}
Aggregations