use of org.eclipse.ui.IWorkbenchPage in project cubrid-manager by CUBRID.
the class LayoutUtil method checkAllQueryEditor.
/**
*
* When database logout or stop,check query editor whether some transaction
* are not commit
*
* @param databaseNode the CubridDatabase object
* @return <code>true</code> if transaction is commited;<code>false</code>
* otherwise
*/
public static boolean checkAllQueryEditor(CubridDatabase databaseNode) {
IWorkbenchPage page = getActivePage();
if (page == null) {
return true;
}
boolean isContinue = true;
IEditorReference[] editorRefArr = page.getEditorReferences();
if (editorRefArr == null || editorRefArr.length == 0) {
return true;
}
for (IEditorReference editorRef : editorRefArr) {
String editorId = editorRef.getId();
if (editorId != null && editorId.equals(QueryEditorPart.ID)) {
QueryEditorPart queryEditor = (QueryEditorPart) editorRef.getEditor(false);
CubridDatabase db = queryEditor.getSelectedDatabase();
if (db != null && db.getId().equals(databaseNode.getId())) {
isContinue = queryEditor.resetJDBCConnection();
}
}
}
return isContinue;
}
use of org.eclipse.ui.IWorkbenchPage in project cubrid-manager by CUBRID.
the class CommonUITool method openQueryEditor.
/**
* Open new query editor.
*
* @param database of query editor.
* @param careDBRunType whether care the database running type that only whether donot open the query editor if the running type is not CS.
* @throws PartInitException when open editor error.
*/
public static QueryEditorPart openQueryEditor(CubridDatabase database, boolean careDBRunType) throws PartInitException {
IWorkbenchPage page = LayoutUtil.getActivePage();
if (page == null) {
return null;
}
if (database != null && careDBRunType && database.getRunningType() != DbRunningType.CS) {
return null;
}
QueryUnit input = new QueryUnit();
input.setDatabase(database);
IEditorPart editor = page.openEditor(input, QueryEditorPart.ID);
if (editor != null) {
((QueryEditorPart) editor).connect(database);
}
return (QueryEditorPart) editor;
}
use of org.eclipse.ui.IWorkbenchPage in project gfm_viewer by satyagraha.
the class DIManager method getInjector.
public Injector getInjector(Component.Scope scope) {
if (scope == null) {
throw new IllegalArgumentException("null scope");
}
switch(scope) {
case PLUGIN:
return pluginInjector;
case PAGE:
IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
if (workbenchWindow == null) {
throw new IllegalStateException("no active workbench window");
}
IWorkbenchPage workbenchPage = workbenchWindow.getActivePage();
if (workbenchPage == null) {
throw new IllegalStateException("no active workbench page");
}
Injector pageInjector = pageInjectorMap.get(workbenchPage);
if (pageInjector == null) {
throw new IllegalStateException("unable to locate pageInjector for page: " + workbenchPage);
}
return pageInjector;
default:
throw new IllegalArgumentException("unexpected scope: " + scope);
}
}
use of org.eclipse.ui.IWorkbenchPage in project dbeaver by serge-rider.
the class NavigatorHandlerLinkEditor method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
final IWorkbenchPage activePage = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage();
final IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
if (activeEditor == null) {
return null;
}
NavigatorViewBase navigatorView = NavigatorUtils.getActiveNavigatorView(event);
if (navigatorView == null) {
return null;
}
if (navigatorView instanceof ProjectExplorerView) {
if (activeEditor instanceof SQLEditor) {
IFile file = EditorUtils.getFileFromInput(activeEditor.getEditorInput());
if (file != null) {
showResourceInNavigator(navigatorView, file);
}
} else if (activeEditor.getEditorInput() instanceof ProjectFileEditorInput) {
IFile editorFile = ((ProjectFileEditorInput) activeEditor.getEditorInput()).getFile();
showResourceInNavigator(navigatorView, editorFile);
}
} else if (activeEditor.getEditorInput() instanceof IDatabaseEditorInput) {
IDatabaseEditorInput editorInput = (IDatabaseEditorInput) activeEditor.getEditorInput();
DBNNode dbnNode = editorInput.getNavigatorNode();
if (dbnNode != null) {
navigatorView.showNode(dbnNode);
}
} else if (activeEditor instanceof IDataSourceContainerProvider) {
DBPDataSourceContainer dsContainer = ((IDataSourceContainerProvider) activeEditor).getDataSourceContainer();
@NotNull final DBSObject activeObject;
if (dsContainer != null) {
DBPDataSource dataSource = dsContainer.getDataSource();
if (dataSource != null) {
activeObject = DBUtils.getDefaultOrActiveObject(dataSource);
} else {
activeObject = dsContainer;
}
final NavigatorViewBase view = navigatorView;
DBeaverUI.runInUI(activePage.getWorkbenchWindow(), new DBRRunnableWithProgress() {
@Override
public void run(DBRProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
DBSObject showObject = activeObject;
if (showObject instanceof DBPDataSource) {
showObject = ((DBPDataSource) showObject).getContainer();
}
DBNDatabaseNode objectNode = view.getModel().getNodeByObject(monitor, showObject, true);
if (objectNode != null) {
view.showNode(objectNode);
}
}
});
}
}
activePage.activate(navigatorView);
return null;
}
use of org.eclipse.ui.IWorkbenchPage in project cubrid-manager by CUBRID.
the class MonitorStatisticEditor method openDetailView.
public void openDetailView(StatisticChartItem statisticChartItem, List<StatisticData> statisticDataList) {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return;
}
IWorkbenchPage page = window.getActivePage();
if (page == null) {
return;
}
StringBuilder secondaryIdSb = new StringBuilder(MonitorStatisticDetailViewPart.ID);
secondaryIdSb.append("@").append(this.pageNode.getId());
IViewReference viewReference = page.findViewReference(MonitorStatisticDetailViewPart.ID, secondaryIdSb.toString());
if (viewReference == null) {
try {
MonitorStatisticDetailViewPart viewPart = (MonitorStatisticDetailViewPart) page.showView(MonitorStatisticDetailViewPart.ID, secondaryIdSb.toString(), IWorkbenchPage.VIEW_ACTIVATE);
viewPart.setMultiHost(isMultiHost);
viewPart.init(this.pageNode, this);
viewPart.setStatisticChartItem(statisticChartItem);
viewPart.setStatisticDataList(statisticDataList);
viewPart.reloadChart();
} catch (PartInitException ex) {
viewReference = null;
}
} else {
MonitorStatisticDetailViewPart viewPart = (MonitorStatisticDetailViewPart) viewReference.getView(false);
window.getActivePage().bringToTop(viewPart);
viewPart.setStatisticChartItem(statisticChartItem);
viewPart.setStatisticDataList(statisticDataList);
viewPart.reloadChart();
}
}
Aggregations