use of org.eclipse.jface.viewers.ISelectionProvider in project cubrid-manager by CUBRID.
the class LogoutDatabaseAction method run.
public void run() {
Object[] objArr = this.getSelectedObj();
if (objArr == null || objArr.length <= 0) {
setEnabled(false);
return;
}
ISelectionProvider provider = this.getSelectionProvider();
if (!(provider instanceof TreeViewer)) {
return;
}
StringBuffer dbNames = new StringBuffer();
for (int i = 0; objArr != null && i < objArr.length; i++) {
if (!isSupported(objArr[i])) {
setEnabled(false);
return;
}
ICubridNode node = (ICubridNode) objArr[i];
dbNames.append(node.getLabel());
if (i != objArr.length - 1) {
dbNames.append(",");
}
}
boolean isLogout = CommonUITool.openConfirmBox(getShell(), Messages.bind(Messages.msgConfirmLogoutDatabase, dbNames.toString()));
if (!isLogout) {
return;
}
TreeViewer viewer = (TreeViewer) provider;
for (int i = 0; i < objArr.length; i++) {
CubridDatabase database = (CubridDatabase) objArr[i];
boolean isContinue = DatabaseUtils.processDatabaseLogout(database);
if (isContinue) {
viewer.refresh(database, true);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_LOGOUT));
}
}
ActionManager.getInstance().fireSelectionChanged(getSelection());
}
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);
}
}
Aggregations