use of org.eclipse.ui.IWorkbenchWindow 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 org.eclipse.ui.IWorkbenchWindow in project cubrid-manager by CUBRID.
the class RunSQLFileDialog method buttonPressed.
/**
* When press button,call it
*
* @param buttonId the button id
*/
protected void buttonPressed(int buttonId) {
if (buttonId == IDialogConstants.OK_ID) {
if (!validate()) {
return;
}
for (CubridDatabase database : cubridDatabases) {
RunSQLFileEditorInput input = new RunSQLFileEditorInput(database, filesList, fileCharsetCombo.getText(), threadCountSpinner.getSelection(), commitCountSpinner.getSelection(), saveErrExcelPath.getText());
try {
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
workbenchWindow.getActivePage().openEditor(input, RunSQLFileViewPart.ID);
} catch (Exception e) {
LOGGER.error("", e);
}
}
}
setReturnCode(buttonId);
close();
}
use of org.eclipse.ui.IWorkbenchWindow in project cubrid-manager by CUBRID.
the class FavoriteQueryNavigatorView method getInstance.
public static FavoriteQueryNavigatorView getInstance() {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return null;
}
IWorkbenchPage page = window.getActivePage();
if (page == null) {
return null;
}
IViewReference viewReference = page.findViewReference(ID);
if (viewReference != null) {
IViewPart viewPart = viewReference.getView(false);
return viewPart instanceof FavoriteQueryNavigatorView ? (FavoriteQueryNavigatorView) viewPart : null;
}
return null;
}
use of org.eclipse.ui.IWorkbenchWindow in project cubrid-manager by CUBRID.
the class FavoriteQueryNavigatorView method setFocus.
public void setFocus() {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return;
}
IWorkbenchPage page = window.getActivePage();
if (page == null) {
return;
}
IViewReference viewReference = page.findViewReference(ID);
if (viewReference != null) {
IViewPart viewPart = viewReference.getView(false);
getSite().getPage().activate(viewPart);
}
}
use of org.eclipse.ui.IWorkbenchWindow in project cubrid-manager by CUBRID.
the class CubridDdlNavigatorView method getInstance.
public static CubridDdlNavigatorView getInstance() {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return null;
}
IWorkbenchPage page = window.getActivePage();
if (page == null) {
return null;
}
IViewReference viewReference = page.findViewReference(ID);
if (viewReference != null) {
IViewPart viewPart = viewReference.getView(false);
return viewPart instanceof CubridDdlNavigatorView ? (CubridDdlNavigatorView) viewPart : null;
}
return null;
}
Aggregations