use of com.cubrid.common.ui.common.navigator.CubridNavigatorView in project cubrid-manager by CUBRID.
the class JdbcManageComposite method isJdbcDriverUsing.
/**
*
* Return whether the JDBC driver is using
*
* @param jdbcVersion String
* @return boolean
*/
private boolean isJdbcDriverUsing(String jdbcVersion) {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return false;
}
IWorkbenchPage page = window.getActivePage();
if (page == null) {
return false;
}
IViewReference[] viewReference = page.getViewReferences();
for (int i = 0; viewReference != null && i < viewReference.length; i++) {
IViewPart viewPart = viewReference[i].getView(false);
if (!(viewPart instanceof CubridNavigatorView)) {
continue;
}
CubridNavigatorView navigatorView = (CubridNavigatorView) viewPart;
List<ICubridNode> list = getUsingJdbcNodeList(navigatorView);
if (list == null) {
continue;
}
for (ICubridNode node : list) {
if (NodeType.SERVER.equals(node.getType())) {
CubridServer server = (CubridServer) node;
ServerInfo serverInfo = server.getServerInfo();
if (serverInfo == null) {
continue;
}
if (serverInfo.isConnected() && serverInfo.getJdbcDriverVersion().equals(jdbcVersion)) {
CommonUITool.openErrorBox(Messages.bind(Messages.errDeleteJdbcServer, new Object[] { serverInfo.getServerName(), jdbcVersion }));
return true;
}
} else if (NodeType.DATABASE.equals(node.getType())) {
CubridDatabase database = (CubridDatabase) node;
if (database == null || database.getServer() == null || database.getServer().getServerInfo() == null) {
continue;
}
ServerInfo serverInfo = database.getServer().getServerInfo();
if (serverInfo == null) {
LOGGER.error("The serverInfo is a null.");
return false;
}
boolean isSameVersion = StringUtil.isEqual(serverInfo.getJdbcDriverVersion(), jdbcVersion);
if (isSameVersion && database.isLogined()) {
CommonUITool.openErrorBox(Messages.bind(Messages.errDeleteJdbcConn, new Object[] { database.getName(), jdbcVersion }));
return true;
}
}
}
}
IEditorReference[] editorReference = page.getEditorReferences();
for (int i = 0; editorReference != null && i < editorReference.length; i++) {
IEditorPart editorPart = editorReference[i].getEditor(false);
if (!(editorPart instanceof QueryEditorPart)) {
continue;
}
QueryEditorPart queryEditorPart = (QueryEditorPart) editorPart;
CubridServer server = queryEditorPart.getSelectedServer();
ServerInfo serverInfo = server == null ? null : server.getServerInfo();
String partName = queryEditorPart.getPartName();
if (serverInfo != null && serverInfo.getJdbcDriverVersion().equals(jdbcVersion)) {
CommonUITool.openErrorBox(Messages.bind(Messages.errDeleteJdbcQuery, new Object[] { partName, jdbcVersion }));
return true;
}
}
return false;
}
use of com.cubrid.common.ui.common.navigator.CubridNavigatorView in project cubrid-manager by CUBRID.
the class OpenJobAutomationInfoAction method run.
public void run() {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return;
}
final Object[] obj = this.getSelectedObj();
if (!isSupported(obj) || obj.length == 0) {
setEnabled(false);
return;
}
ICubridNode node = (ICubridNode) obj[0];
if (node.getType().equals(CubridNodeType.JOB_FOLDER)) {
CubridNavigatorView view = CubridNavigatorView.getNavigatorView("com.cubrid.cubridmanager.host.navigator");
if (view == null) {
return;
}
//if not expand ,expand the node and wait until all children be added
TreeViewer treeViewer = view.getViewer();
if (!treeViewer.getExpandedState(node)) {
treeViewer.expandToLevel(node, 1);
while (node.getChildren().size() == 0) {
ThreadUtil.sleep(500);
}
}
openJobsDetailInfoEditor(NodeUtil.getCubridDatabase(node));
}
}
use of com.cubrid.common.ui.common.navigator.CubridNavigatorView in project cubrid-manager by CUBRID.
the class NewMultiHostConnectionDialog method editHost.
public void editHost(FailedHostServerInfo multiHostConnectionFailedServerInfo) {
// get selected dbdata
if (multiHostConnectionFailedServerInfo == null || multiHostConnectionFailedServerInfo.getCubridServer().isConnected()) {
return;
}
HostDialog dialog = new HostDialog(getShell(), false, false);
ServerInfo oldServerInfo = multiHostConnectionFailedServerInfo.getCubridServer().getServerInfo();
dialog.setServer(multiHostConnectionFailedServerInfo.getCubridServer());
if (dialog.open() != HostDialog.CONNECT_ID) {
return;
}
ServerInfo serverInfo = dialog.getServerInfo();
if (!serverInfo.getServerName().equals(multiHostConnectionFailedServerInfo.getCubridServer().getLabel())) {
QueryOptions.removePref(multiHostConnectionFailedServerInfo.getCubridServer().getServerInfo());
BrokerIntervalSettingManager.getInstance().removeAllBrokerIntervalSettingInServer(multiHostConnectionFailedServerInfo.getCubridServer().getLabel());
}
if (oldServerInfo.isConnected() && !oldServerInfo.equals(serverInfo)) {
HostUtils.processHostDisconnected(multiHostConnectionFailedServerInfo.getCubridServer());
}
multiHostConnectionFailedServerInfo.getCubridServer().setId(serverInfo.getServerName());
multiHostConnectionFailedServerInfo.getCubridServer().setLabel(serverInfo.getServerName());
multiHostConnectionFailedServerInfo.getCubridServer().setServerInfo(serverInfo);
multiHostConnectionFailedServerInfo.getCubridServer().setAutoSavePassword(dialog.isSavePassword());
CMHostNodePersistManager.getInstance().addServer(serverInfo.getHostAddress(), serverInfo.getHostMonPort(), serverInfo.getUserName(), serverInfo);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(multiHostConnectionFailedServerInfo.getCubridServer(), CubridNodeChangedEventType.SERVER_CONNECTED));
multiHostConnectionFailedServerInfo.getCubridServer().getLoader().setLoaded(false);
CubridNavigatorView view = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
TreeViewer treeViewer = view.getViewer();
treeViewer.refresh(multiHostConnectionFailedServerInfo.getCubridServer(), true);
treeViewer.expandToLevel(multiHostConnectionFailedServerInfo.getCubridServer(), 1);
ActionManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
LayoutManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
multiHostConnectionFailedServerInfo.setErrConnectionMsg("");
serverTable.refresh();
}
use of com.cubrid.common.ui.common.navigator.CubridNavigatorView in project cubrid-manager by CUBRID.
the class StopServiceAction method doRun.
/**
* Perform do run
*
* @param servers
*/
public void doRun(CubridServer[] servers) {
CubridNavigatorView view = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
final TreeViewer viewer = view.getViewer();
if (servers.length > 0) {
CubridServer server = servers[0];
if (isSupported(server)) {
final JobFamily jobFamily = new JobFamily();
final String serverName = server.getName();
String dbName = JobFamily.ALL_DB;
jobFamily.setServerName(serverName);
jobFamily.setDbName(dbName);
Job[] jobs = Job.getJobManager().find(jobFamily);
if (jobs.length > 0) {
CommonUITool.openWarningBox(Messages.bind(Messages.msgStopServiceWithJob, serverName));
return;
}
TaskExecutor taskExcutor = new StopServiceExecutor(server, getShell(), viewer);
ServerInfo serverInfo = server.getServerInfo();
GetCubridConfParameterTask task = new GetCubridConfParameterTask(serverInfo);
taskExcutor.addTask(task);
new ExecTaskWithProgress(taskExcutor).exec();
}
}
// for(CubridServer server : servers) {
// final JobFamily jobFamily = new JobFamily();
// final String serverName = server.getName();
// String dbName = JobFamily.ALL_DB;
// jobFamily.setServerName(serverName);
// jobFamily.setDbName(dbName);
// Job[] jobs = Job.getJobManager().find(jobFamily);
// if (jobs.length > 0) {
// CommonUITool.openWarningBox(Messages.bind(
// Messages.msgStopServiceWithJob, serverName));
// return;
// }
//
// TaskExecutor taskExcutor = new StopServiceExecutor(server, getShell(),
// viewer);
// ServerInfo serverInfo = server.getServerInfo();
// GetCubridConfParameterTask task = new GetCubridConfParameterTask(
// serverInfo);
// taskExcutor.addTask(task);
// new ExecTaskWithProgress(taskExcutor).exec();
// }
}
use of com.cubrid.common.ui.common.navigator.CubridNavigatorView in project cubrid-manager by CUBRID.
the class MultiDatabaseLoginFailedDialog method editHost.
public void editHost(MultiDatabaseloginFailedInfo multiDatabaseloginFailedInfo) {
if (multiDatabaseloginFailedInfo == null) {
return;
}
CubridDatabase database = multiDatabaseloginFailedInfo.getCubridDatabase();
//if login ,can't edit
if (database.isLogined()) {
return;
}
// CubridDatabase oldDatabase = null;
// try {
// oldDatabase = database.clone();
// } catch (CloneNotSupportedException e) {
// //Ignore
// }
LoginDatabaseDialog dialog = new LoginDatabaseDialog(getShell(), database);
int returnVal = dialog.open();
if (returnVal == IDialogConstants.OK_ID) {
CubridNavigatorView view = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
TreeViewer treeViewer = view.getViewer();
database.removeAllChild();
if (database.getLoader() != null) {
database.getLoader().setLoaded(false);
}
treeViewer.refresh(database, true);
treeViewer.expandToLevel(database, 1);
/*Save the data*/
DatabaseEditorConfig editorConfig = QueryOptions.getEditorConfig(database, true);
if (editorConfig == null) {
editorConfig = new DatabaseEditorConfig();
}
editorConfig.setBackGround(dialog.getSelectedColor());
CMDBNodePersistManager.getInstance().addDatabase(database, editorConfig);
ActionManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
LayoutManager.getInstance().fireSelectionChanged(treeViewer.getSelection());
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(database, CubridNodeChangedEventType.DATABASE_LOGIN));
multiDatabaseloginFailedInfo.setErrMsg("");
}
databaseTable.refresh();
}
Aggregations