use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent in project cubrid-manager by CUBRID.
the class LoginDatabaseAction method doRun.
public void doRun(CubridDatabase[] databaseArray) {
if (databaseArray == null || databaseArray.length == 0) {
return;
}
CubridNavigatorView navigationView = CubridNavigatorView.findNavigationView();
if (navigationView != null && databaseArray.length > 0) {
final TreeViewer treeViewer = navigationView.getViewer();
if (databaseArray.length > 1) {
List<MultiDatabaseloginFailedInfo> failedDatabaseList = new ArrayList<MultiDatabaseloginFailedInfo>();
for (CubridDatabase object : databaseArray) {
CubridDatabase database = (CubridDatabase) object;
String errMsg = null;
if (database.isAutoSavePassword()) {
errMsg = CubridWorkbenchContrItem.connectDatabaseWithErrMsg(database.getDatabaseInfo(), false);
} else {
errMsg = "Incorrect or missing password.";
}
if (errMsg == null) {
database.getLoader().setLoaded(false);
database.setLogined(true);
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));
// open database dashboard
if (GeneralPreference.isUseDatabaseDashboard()) {
LayoutManager.getInstance().getWorkbenchContrItem().openEditorOrView(database);
}
} else {
failedDatabaseList.add(new MultiDatabaseloginFailedInfo(database, errMsg));
}
}
if (failedDatabaseList.size() > 0) {
MultiDatabaseLoginFailedDialog dialog = new MultiDatabaseLoginFailedDialog(getShell(), failedDatabaseList);
dialog.open();
}
return;
} else {
CubridDatabase database = databaseArray[0];
if (DbRunningType.STANDALONE.equals(database.getRunningType()) && ActionSupportUtil.hasAdminPermissionOnStopState(database)) {
if (CommonUITool.openConfirmBox(Messages.bind(Messages.msgWhetherStartDB, database.getName()))) {
StartDatabaseAction startDatabaseAction = (StartDatabaseAction) ActionManager.getInstance().getAction(StartDatabaseAction.ID);
startDatabaseAction.doRun(new CubridDatabase[] { database });
}
}
if (!database.isLogined() && database.isAutoSavePassword()) {
DatabaseEditorConfig editorConfig = QueryOptions.getEditorConfig(database, true);
if (EditorConstance.isNeedSetBackground(editorConfig)) {
new ShortSetEditorConfigAction(database).run();
}
}
if (!database.isLogined() && database.isAutoSavePassword() && CubridWorkbenchContrItem.connectDatabase(database.getDatabaseInfo(), true)) {
database.getLoader().setLoaded(false);
database.setLogined(true);
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));
// open database dashboard
if (GeneralPreference.isUseDatabaseDashboard()) {
LayoutManager.getInstance().getWorkbenchContrItem().openEditorOrView(database);
}
} else if (!database.isLogined()) {
EditDatabaseLoginAction editDatabaseLoginAction = (EditDatabaseLoginAction) ActionManager.getInstance().getAction(EditDatabaseLoginAction.ID);
editDatabaseLoginAction.doRun(databaseArray);
}
}
}
}
use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent 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 com.cubrid.common.ui.spi.event.CubridNodeChangedEvent in project cubrid-manager by CUBRID.
the class EditDatabaseLoginAction method doRun.
public void doRun(CubridDatabase[] databaseArray) {
if (databaseArray == null || databaseArray.length == 0) {
return;
}
CubridNavigatorView navigationView = CubridNavigatorView.findNavigationView();
if (navigationView != null) {
final TreeViewer treeViewer = navigationView.getViewer();
CubridDatabase database = (CubridDatabase) databaseArray[0];
LoginDatabaseDialog dialog = new LoginDatabaseDialog(getShell(), database);
int returnVal = dialog.open();
if (returnVal == IDialogConstants.OK_ID && provider instanceof TreeViewer) {
database.removeAllChild();
if (database.getLoader() != null) {
database.getLoader().setLoaded(false);
}
treeViewer.refresh(database, true);
treeViewer.expandToLevel(database, 1);
ActionManager.getInstance().fireSelectionChanged(getSelection());
LayoutManager.getInstance().fireSelectionChanged(getSelection());
if (dialog.isFireLogoutEvent()) {
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_LOGOUT));
}
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_LOGIN));
} else if (returnVal == LoginDatabaseDialog.SAVE_ID && provider instanceof TreeViewer) {
treeViewer.refresh(database, true);
treeViewer.expandToLevel(database, 1);
}
}
}
use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent in project cubrid-manager by CUBRID.
the class AddMonitorStatisticPageAction method run.
/**
* Override the run method in order to open an instance of status monitor
* dialog
*
*/
public void run() {
Object[] obj = this.getSelectedObj();
ICubridNode node = null;
if (obj.length > 0) {
node = (ICubridNode) obj[0];
}
String hostId = null;
boolean isSingleHost = node != null && CubridNodeType.MONITOR_FOLDER.equals(node.getType());
if (isSingleHost) {
ServerInfo serverInfo = node.getServer().getServerInfo();
hostId = serverInfo.getServerName();
if (!serverInfo.isSupportMonitorStatistic()) {
CommonUITool.openWarningBox(Messages.needEnableMonitorStatisticMsg);
return;
}
}
AddStatisticPageDialog dialog = new AddStatisticPageDialog(getShell());
dialog.setCubridServerId(hostId);
if (dialog.open() == Dialog.OK) {
final String iconPath = "icons/navigator/status_item.png";
String labelName = dialog.getName();
String pageName = labelName;
if (hostId != null) {
pageName += "@" + hostId;
}
MonitorStatistic monitorStatisticNode = new MonitorStatistic(pageName, labelName, iconPath);
monitorStatisticNode.setType(CubridNodeType.MONITOR_STATISTIC_PAGE);
monitorStatisticNode.setEditorId(MonitorStatisticEditor.ID);
if (isSingleHost) {
monitorStatisticNode.setMultiHost(false);
ServerInfo serverInfo = node.getServer().getServerInfo();
monitorStatisticNode.setIp(serverInfo.getHostAddress());
monitorStatisticNode.setPort(serverInfo.getHostMonPort());
} else {
monitorStatisticNode.setMultiHost(true);
}
MonitorStatisticPersistManager persistManager = MonitorStatisticPersistManager.getInstance();
persistManager.addMonitorStatistic(monitorStatisticNode, hostId);
persistManager.saveStatistic();
//refresh TreeViewer
TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
if (isSingleHost) {
node.addChild(monitorStatisticNode);
treeViewer.add(node, monitorStatisticNode);
} else {
/*TOOLS-3665 Refresh the input of TreeViewer*/
treeViewer.setInput(CubridMonitorNavigatorView.getTreeViewerInput());
}
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(monitorStatisticNode, CubridNodeChangedEventType.NODE_ADD));
try {
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
workbenchWindow.getActivePage().openEditor(monitorStatisticNode, MonitorStatisticEditor.ID);
} catch (Exception ignore) {
}
} else {
//TODO
}
}
use of com.cubrid.common.ui.spi.event.CubridNodeChangedEvent in project cubrid-manager by CUBRID.
the class DeleteMonitorStatisticPageAction method run.
/**
* Override the run method in order to open an instance of status monitor
* dialog
*
*/
public void run() {
Object[] obj = this.getSelectedObj();
ICubridNode node = (ICubridNode) obj[0];
String message = Messages.bind(Messages.confirmStatisticPageDeleteWarn, node.getId());
if (!CommonUITool.openConfirmBox(message)) {
return;
}
ICubridNode parent = node.getParent();
boolean isSingHost = parent != null && CubridNodeType.MONITOR_FOLDER.equals(parent.getType());
String hostId = null;
if (isSingHost) {
hostId = node.getServer().getServerName();
hostId = parent.getServer().getServerName();
}
MonitorStatisticPersistManager persistManager = MonitorStatisticPersistManager.getInstance();
persistManager.removeMonitorStatistic((MonitorStatistic) node, hostId);
persistManager.saveStatistic();
TreeViewer treeViewer = (TreeViewer) this.getSelectionProvider();
LayoutUtil.closeEditorAndView(node);
if (isSingHost) {
parent.removeChild(node);
treeViewer.remove(node);
} else {
/*TOOLS-3666 Refresh the input of TreeViewer*/
treeViewer.setInput(CubridMonitorNavigatorView.getTreeViewerInput());
}
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(node, CubridNodeChangedEventType.NODE_REMOVE));
}
Aggregations