use of org.eclipse.ui.IViewPart 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;
}
use of org.eclipse.ui.IViewPart in project cubrid-manager by CUBRID.
the class CubridColumnNavigatorView method getInstance.
public static CubridColumnNavigatorView 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 CubridColumnNavigatorView ? (CubridColumnNavigatorView) viewPart : null;
}
return null;
}
use of org.eclipse.ui.IViewPart in project cubrid-manager by CUBRID.
the class DbDashboardHistoryAction method run.
/**
* Open monitor host detail windows.
*/
public void run() {
if (getSelectedObj() == null || getSelectedObj().length == 0) {
return;
}
Object obj = getSelectedObj()[0];
if (!(obj instanceof DatabaseMonitorPart)) {
return;
}
DatabaseMonitorPart part = (DatabaseMonitorPart) obj;
DatabaseNode dn = (DatabaseNode) part.getModel();
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return;
}
IWorkbenchPage page = window.getActivePage();
if (page == null) {
return;
}
HostNode hn = dn.getParent();
String secondaryId = new StringBuffer(dn.getDbName()).append("&").append(hn.getUserName()).append("&").append(hn.getIp()).append("&").append(hn.getPort()).toString();
IViewReference viewReference = page.findViewReference(DbDashboardHistoryViewPart.ID, secondaryId);
if (viewReference == null) {
try {
IViewPart viewPart = page.showView(DbDashboardHistoryViewPart.ID, secondaryId, IWorkbenchPage.VIEW_ACTIVATE);
((DbDashboardHistoryViewPart) viewPart).init((DatabaseNode) part.getModel());
} catch (PartInitException ex) {
viewReference = null;
}
} else {
IViewPart viewPart = viewReference.getView(false);
window.getActivePage().bringToTop(viewPart);
((DbDashboardHistoryViewPart) viewPart).init((DatabaseNode) part.getModel());
}
}
use of org.eclipse.ui.IViewPart in project cubrid-manager by CUBRID.
the class WorkbenchContrItem method closeAllEditorAndViewInDatabase.
/**
* Close all editor and view part related with this CUBRID Manager database
* node,not include query editor
*
* @param databaseNode the CubridDatabase object
* @param eventType CubridNodeChangedEventType
*/
public void closeAllEditorAndViewInDatabase(CubridDatabase databaseNode, CubridNodeChangedEventType eventType) {
IWorkbenchPage page = LayoutUtil.getActivePage();
if (page == null) {
return;
}
IEditorReference[] editorRefArr = page.getEditorReferences();
for (int i = 0; editorRefArr != null && i < editorRefArr.length; i++) {
IEditorReference editorRef = editorRefArr[i];
try {
IEditorInput editorInput = editorRef.getEditorInput();
if (!(editorInput instanceof ISchemaNode)) {
continue;
}
ISchemaNode schemaNode = ((ISchemaNode) editorInput);
ISchemaNode dbNode = schemaNode.getDatabase();
if (dbNode.getId().equals(databaseNode.getId())) {
page.closeEditor(editorRef.getEditor(false), true);
}
} catch (PartInitException e) {
LOGGER.error(e.getMessage());
}
}
IViewReference[] viewRefArr = page.getViewReferences();
if (viewRefArr == null || viewRefArr.length == 0) {
return;
}
for (IViewReference viewRef : viewRefArr) {
IViewPart viewPart = viewRef.getView(false);
if (!(viewPart instanceof CubridViewPart)) {
continue;
}
CubridViewPart cubridViewPart = (CubridViewPart) viewPart;
ICubridNode cubridNode = cubridViewPart.getCubridNode();
if (!(cubridNode instanceof ISchemaNode)) {
continue;
}
ICubridNode cubridDatabaseNode = ((ISchemaNode) cubridNode).getDatabase();
if (cubridDatabaseNode.getId().equals(databaseNode.getId())) {
page.hideView(viewPart);
}
}
}
use of org.eclipse.ui.IViewPart in project cubrid-manager by CUBRID.
the class WorkbenchContrItem method processNodeRemove.
/**
* When node remove, close this node's editor or view part
*
* @param eventNode ICubridNode
* @param page IWorkbenchPage
*/
protected void processNodeRemove(ICubridNode eventNode, IWorkbenchPage page) {
List<IEditorPart> editorParts = LayoutUtil.getEditorParts(eventNode);
for (IEditorPart part : editorParts) {
if (part != null) {
page.closeEditor(part, false);
}
}
List<IViewPart> viewParts = LayoutUtil.getViewParts(eventNode);
for (IViewPart part : viewParts) {
if (part != null) {
page.hideView(part);
}
}
}
Aggregations