use of org.eclipse.jface.viewers.ISelectionProvider in project cubrid-manager by CUBRID.
the class OptimizeAction 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;
}
OptimizeDialog dlg = new OptimizeDialog();
GetClassListTask task = new GetClassListTask(database.getServer().getServerInfo(), database.getDatabaseInfo().getCharSet());
task.setDbName(database.getName());
if (database.getDatabaseInfo().getRunningType() == DbRunningType.STANDALONE) {
task.setDbStatus(OnOffType.OFF);
} else {
task.setDbStatus(OnOffType.ON);
}
dlg.executeGetClassListTask(-1, task, true, getShell());
if (task.getErrorMsg() != null || task.isCancel()) {
return;
}
dlg.setDatabase(database);
dlg.setUserClassList(task.getDbClassInfo().getUserClassList().getClassList());
if (dlg.open() == DeleteDatabaseDialog.DELETE_ID) {
ISelectionProvider provider = getSelectionProvider();
if (provider instanceof TreeViewer) {
TreeViewer treeViewer = (TreeViewer) provider;
CommonUITool.refreshNavigatorTree(treeViewer, database.getParent());
setEnabled(false);
}
ActionManager.getInstance().fireSelectionChanged(getSelection());
}
}
use of org.eclipse.jface.viewers.ISelectionProvider in project cubrid-manager by CUBRID.
the class CopyDatabaseAction method run.
public void run() {
Object[] obj = this.getSelectedObj();
if (!isSupported(obj[0])) {
setEnabled(false);
return;
}
ISchemaNode schemaNode = (ISchemaNode) obj[0];
final CubridDatabase database = schemaNode.getDatabase();
if (database == null) {
CommonUITool.openErrorBox(getShell(), Messages.msgSelectDB);
return;
}
GetDbSizeTask dbSizeTask = new GetDbSizeTask(database.getServer().getServerInfo());
dbSizeTask.setDbName(database.getName());
final CommonQueryTask<DbSpaceInfoList> dbSpaceInfotask = new CommonQueryTask<DbSpaceInfoList>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoList());
dbSpaceInfotask.setDbName(database.getName());
ISelectionProvider provider = getSelectionProvider();
final TreeViewer viewer = (TreeViewer) provider;
final CopyDatabaseDialog dlg = new CopyDatabaseDialog(getShell(), viewer);
dlg.execTask(-1, new SocketTask[] { dbSizeTask, dbSpaceInfotask }, true, getShell());
if (dbSpaceInfotask.getErrorMsg() != null || dbSizeTask.isCancel() || dbSizeTask.getErrorMsg() != null || dbSpaceInfotask.isCancel()) {
return;
}
dlg.setDbSize(dbSizeTask.getDbSize());
dlg.setDbSpaceInfo(dbSpaceInfotask.getResultModel());
dlg.setDatabase(database);
dlg.open();
}
use of org.eclipse.jface.viewers.ISelectionProvider in project cubrid-manager by CUBRID.
the class DisConnectHostAction method doRun.
public void doRun(Object[] objArr) {
if (CubridNavigatorView.findNavigationView() == null) {
LOGGER.error("CubridNavigatorView.findNavigationView() is null.");
return;
}
ISelectionProvider provider = CubridNavigatorView.findNavigationView().getViewer();
if (!(provider instanceof TreeViewer)) {
return;
}
List<CubridServer> connectedServers = new ArrayList<CubridServer>();
StringBuffer hostNames = new StringBuffer();
for (int i = 0; objArr != null && i < objArr.length; i++) {
if (!isSupported(objArr[i])) {
setEnabled(false);
continue;
}
ICubridNode node = (ICubridNode) objArr[i];
if (node instanceof CubridServer) {
connectedServers.add((CubridServer) node);
hostNames.append(node.getLabel());
if (i != objArr.length - 1) {
hostNames.append(",");
}
}
}
String msg = Messages.bind(Messages.msgConfirmDisconnectHost, hostNames.toString());
boolean isDisconnectHost = CommonUITool.openConfirmBox(getShell(), msg);
if (!isDisconnectHost) {
return;
}
for (CubridServer server : connectedServers) {
boolean isContinue = HostUtils.processHostDisconnected(server);
if (isContinue) {
TreeViewer viewer = (TreeViewer) provider;
viewer.refresh(server, true);
viewer.setSelection(null, true);
viewer.setSelection(new StructuredSelection(server), true);
ActionManager.getInstance().fireSelectionChanged(getSelection());
LayoutManager.getInstance().fireSelectionChanged(getSelection());
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(server, CubridNodeChangedEventType.SERVER_DISCONNECTED));
}
}
}
use of org.eclipse.jface.viewers.ISelectionProvider in project cubrid-manager by CUBRID.
the class RefreshAction method run.
/**
* Reload the selected CUBRID node
*/
public void run() {
final Object[] obj = this.getSelectedObj();
if (obj == null || obj.length == 0 || !isSupported(obj[0])) {
return;
}
ICubridNode cubridNode = (ICubridNode) obj[0];
String nodeType = cubridNode.getType();
if (CubridNodeType.USER_TABLE.equals(nodeType) || CubridNodeType.SYSTEM_TABLE.equals(nodeType) || CubridNodeType.USER_PARTITIONED_TABLE_FOLDER.equals(nodeType) || CubridNodeType.USER_PARTITIONED_TABLE.equals(nodeType) || CubridNodeType.SYSTEM_VIEW.equals(nodeType) || CubridNodeType.USER_VIEW.equals(nodeType)) {
ISchemaNode schemaNode = (ISchemaNode) cubridNode;
schemaNode.getDatabase().getDatabaseInfo().removeSchema(cubridNode.getLabel());
}
LayoutManager.getInstance().getWorkbenchContrItem().reopenEditorOrView(cubridNode);
if (CubridNodeType.GENERIC_VOLUME_FOLDER.equals(nodeType) || CubridNodeType.DATA_VOLUME_FOLDER.equals(nodeType) || CubridNodeType.INDEX_VOLUME_FOLDER.equals(nodeType) || CubridNodeType.TEMP_VOLUME_FOLDER.equals(nodeType)) {
cubridNode = cubridNode.getParent();
} else if (CubridNodeType.ACTIVE_LOG_FOLDER.equals(nodeType) || CubridNodeType.ARCHIVE_LOG_FOLDER.equals(nodeType)) {
cubridNode = cubridNode.getParent() == null ? null : cubridNode.getParent().getParent();
}
ISelectionProvider provider = this.getSelectionProvider();
if ((provider instanceof TreeViewer) && cubridNode != null && cubridNode.isContainer()) {
TreeViewer viewer = (TreeViewer) provider;
CommonUITool.refreshNavigatorTree(viewer, cubridNode);
}
}
use of org.eclipse.jface.viewers.ISelectionProvider in project cubrid-manager by CUBRID.
the class OpenQueryConnAction method run.
/**
* Open the query connection
*/
public void run() {
// TODO remove later
CQBGroupNodePersistManager.getInstance().fix();
Object[] obj = this.getSelectedObj();
if (!isSupported(obj[0])) {
setEnabled(false);
return;
}
ISelectionProvider provider = getSelectionProvider();
if (!(provider instanceof TreeViewer)) {
return;
}
CubridDatabase[] cubridDatabases = handleSelectionObj(obj);
if (cubridDatabases.length > 1) {
List<MultiDatabaseloginFailedInfo> failedDatabaseList = new ArrayList<MultiDatabaseloginFailedInfo>();
for (CubridDatabase object : cubridDatabases) {
CubridDatabase database = (CubridDatabase) object;
String errMsg = null;
if (database.isAutoSavePassword()) {
errMsg = CubridWorkbenchContrItem.connectDatabaseWithErrMsg(database.getDatabaseInfo());
} else {
errMsg = "Incorrect or missing password.";
}
if (errMsg == null) {
database.getLoader().setLoaded(false);
database.setLogined(true);
CubridNavigatorView view = CubridNavigatorView.getNavigatorView(CubridQueryNavigatorView.ID);
TreeViewer treeViewer = view.getViewer();
treeViewer.refresh(database, true);
treeViewer.expandToLevel(database, 1);
ActionManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
LayoutManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_LOGIN));
} else {
failedDatabaseList.add(new MultiDatabaseloginFailedInfo(database, errMsg));
}
}
if (failedDatabaseList.size() > 0) {
MultiDatabaseLoginFailedDialog dialog = new MultiDatabaseLoginFailedDialog(getShell(), failedDatabaseList);
dialog.open();
}
return;
}
CubridDatabase database = cubridDatabases[0];
if (!database.isLogined() && database.isAutoSavePassword()) {
DatabaseEditorConfig editorConfig = QueryOptions.getEditorConfig(database, false);
if (EditorConstance.isNeedSetBackground(editorConfig)) {
new ShortSetEditorConfigAction(database).run();
}
}
if (database.isAutoSavePassword() && CubridWorkbenchContrItem.connectDatabase(database.getDatabaseInfo())) {
database.getLoader().setLoaded(false);
CubridNavigatorView view = CubridNavigatorView.getNavigatorView(CubridQueryNavigatorView.ID);
TreeViewer treeViewer = view.getViewer();
treeViewer.refresh(database, true);
treeViewer.expandToLevel(database, 1);
ActionManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
LayoutManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_LOGIN));
} else {
ActionManager.getInstance().getAction(EditQueryConnAction.ID).run();
}
}
Aggregations