use of org.eclipse.ui.IViewPart in project cubrid-manager by CUBRID.
the class WorkbenchContrItem method openEditorOrView.
/**
* Open and reopen the editor or view part of this cubrid node
*
* @param cubridNode the ICubridNode object
*/
public void openEditorOrView(ICubridNode cubridNode) {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return;
}
if (cubridNode instanceof ISchemaNode) {
ISchemaNode schemaNode = (ISchemaNode) cubridNode;
if (schemaNode.getDatabase() != null && !schemaNode.getDatabase().isLogined()) {
return;
}
}
//close the editor part that has been open
String editorId = cubridNode.getEditorId();
String viewId = cubridNode.getViewId();
if (editorId != null && editorId.trim().length() > 0) {
IEditorPart editorPart = LayoutUtil.getEditorPart(cubridNode, editorId);
if (editorPart != null) {
window.getActivePage().closeEditor(editorPart, false);
}
} else if (viewId != null && viewId.trim().length() > 0) {
IViewPart viewPart = LayoutUtil.getViewPart(cubridNode, viewId);
if (viewPart != null) {
window.getActivePage().hideView(viewPart);
}
}
if (editorId != null && editorId.trim().length() > 0) {
try {
//if open the table schema editor,firstly load the schema
if (editorId.equals(SchemaInfoEditorPart.ID) && cubridNode instanceof ISchemaNode) {
CubridDatabase database = ((ISchemaNode) cubridNode).getDatabase();
SchemaInfo newSchema = database.getDatabaseInfo().getSchemaInfo(cubridNode.getName());
if (null == newSchema) {
CommonUITool.openErrorBox(database.getDatabaseInfo().getErrorMessage());
return;
}
}
window.getActivePage().openEditor(cubridNode, editorId, true, IWorkbenchPage.MATCH_ID & IWorkbenchPage.MATCH_INPUT);
} catch (PartInitException e) {
LOGGER.error(e.getMessage());
}
} else if (viewId != null && viewId.trim().length() > 0) {
try {
window.getActivePage().showView(viewId);
} catch (PartInitException e) {
LOGGER.error(e.getMessage());
}
}
}
use of org.eclipse.ui.IViewPart in project cubrid-manager by CUBRID.
the class LayoutUtil method closeAllCubridEditorAndView.
/**
*
* Close all opened editor and view part related with CUBRID Manager,not
* include query editor
*
*/
public static void closeAllCubridEditorAndView() {
IWorkbench workbench = PlatformUI.getWorkbench();
if (workbench == null) {
return;
}
IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
if (window == null) {
return;
}
IWorkbenchPage page = window.getActivePage();
if (page == null) {
return;
}
IEditorReference[] editorRefArr = page.getEditorReferences();
if (editorRefArr != null && editorRefArr.length > 0) {
for (IEditorReference editorRef : editorRefArr) {
try {
IEditorInput editorInput = editorRef.getEditorInput();
if (editorInput instanceof ICubridNode) {
window.getActivePage().closeEditor(editorRef.getEditor(false), true);
}
} catch (PartInitException e) {
LOGGER.error(e.getMessage());
}
}
}
IViewReference[] viewRefArr = page.getViewReferences();
if (viewRefArr != null && viewRefArr.length > 0) {
for (IViewReference viewRef : viewRefArr) {
IViewPart viewPart = viewRef.getView(false);
if (viewPart instanceof CubridViewPart) {
page.hideView(viewPart);
}
}
}
}
use of org.eclipse.ui.IViewPart in project gfm_viewer by satyagraha.
the class ViewManager method activateView.
/**
* Activate a view by id.
*
* @param event
* @param viewId
* @throws ExecutionException
*/
public static void activateView(ExecutionEvent event, String viewId) throws ExecutionException {
try {
IViewPart view = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().showView(viewId);
HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().activate(view);
} catch (PartInitException e) {
throw new ExecutionException("failed to show view", e);
}
}
use of org.eclipse.ui.IViewPart in project cubrid-manager by CUBRID.
the class MonitorReplicationPerfAction method run.
/**
* monitor replication performance
*/
public void run() {
Object[] obj = this.getSelectedObj();
if (obj == null || obj.length == 0 || !isSupported(obj[0])) {
return;
}
ICubridNode cubridNode = (ICubridNode) obj[0];
try {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IViewPart viewPart = LayoutUtil.getViewPart(cubridNode, ReplicationMonitorViewPart.ID);
if (viewPart == null) {
IWorkbenchPage page = window.getActivePage();
String secondId = cubridNode.getServer().getLabel() + "_" + cubridNode.getLabel();
viewPart = page.showView(ReplicationMonitorViewPart.ID, secondId, IWorkbenchPage.VIEW_CREATE);
window.getActivePage().bringToTop(viewPart);
} else {
window.getActivePage().bringToTop(viewPart);
}
if (viewPart != null) {
LayoutManager.getInstance().getTitleLineContrItem().changeTitleForViewOrEditPart(cubridNode, viewPart);
LayoutManager.getInstance().getStatusLineContrItem().changeStuatusLineForViewOrEditPart(cubridNode, viewPart);
}
} catch (PartInitException e) {
LOGGER.error(e.getMessage(), e);
}
}
use of org.eclipse.ui.IViewPart in project cubrid-manager by CUBRID.
the class CubridWorkbenchContrItem 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();
String type = schemaNode.getType();
boolean isDbSpaceEditor = NodeType.contains(type, new String[] { CubridNodeType.DATABASE, CubridNodeType.DBSPACE_FOLDER, CubridNodeType.GENERIC_VOLUME_FOLDER, CubridNodeType.GENERIC_VOLUME, CubridNodeType.DATA_VOLUME_FOLDER, CubridNodeType.DATA_VOLUME, CubridNodeType.INDEX_VOLUME_FOLDER, CubridNodeType.INDEX_VOLUME, CubridNodeType.TEMP_VOLUME_FOLDER, CubridNodeType.TEMP_VOLUME, CubridNodeType.LOG_VOLUEM_FOLDER, CubridNodeType.ACTIVE_LOG_FOLDER, CubridNodeType.ACTIVE_LOG, CubridNodeType.ARCHIVE_LOG_FOLDER, CubridNodeType.ARCHIVE_LOG });
boolean isClose = true;
if (isDbSpaceEditor) {
isClose = !databaseNode.isLogined() || CubridNodeChangedEventType.NODE_REMOVE == eventType || CubridNodeChangedEventType.DATABASE_LOGOUT == eventType;
}
if (!isClose) {
continue;
}
if (dbNode.getId().equals(databaseNode.getId())) {
page.closeEditor(editorRef.getEditor(false), true);
}
} catch (Exception e) {
LOGGER.error("", e);
}
}
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);
}
}
}
Aggregations