use of org.eclipse.ui.IWorkbenchPage 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.IWorkbenchPage in project cubrid-manager by CUBRID.
the class LayoutUtil method checkAllQueryEditor.
/**
*
* When server disconnect or delete,check query editor whether some
* transaction are not commit
*
* @param cubridServer the CubridServer object
* @return <code>true</code> if transaction is commited;<code>false</code>
* otherwise
*/
public static boolean checkAllQueryEditor(CubridServer cubridServer) {
IWorkbenchPage page = getActivePage();
if (page == null) {
return true;
}
IEditorReference[] editorRefArr = page.getEditorReferences();
if (editorRefArr == null || editorRefArr.length == 0) {
return true;
}
boolean isContinue = 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.getServer() != null && db.getServer().getId().equals(cubridServer.getId())) {
isContinue = queryEditor.resetJDBCConnection();
}
}
}
return isContinue;
}
use of org.eclipse.ui.IWorkbenchPage 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.IWorkbenchPage in project cubrid-manager by CUBRID.
the class LayoutUtil method getEditorPart.
/**
*
* Get the editor part of this CUBRID node and this editorId
*
* @param cubridNode the ICubridNode object
* @param editorId the editor id
* @return the IEditorPart object
*/
public static IEditorPart getEditorPart(ICubridNode cubridNode, String editorId) {
IWorkbenchPage page = getActivePage();
if (page == null) {
return null;
}
IEditorReference[] editorRefArr = page.getEditorReferences();
if (editorRefArr == null || editorRefArr.length == 0) {
return null;
}
for (IEditorReference editorRef : editorRefArr) {
try {
IEditorInput editorInput = editorRef.getEditorInput();
String id = editorRef.getId();
if (editorInput instanceof ICubridNode) {
ICubridNode node = (ICubridNode) editorInput;
if (node.getId().equals(cubridNode.getId()) && editorId.equals(id)) {
return editorRef.getEditor(false);
}
}
} catch (PartInitException e) {
LOGGER.error(e.getMessage());
}
}
return null;
}
use of org.eclipse.ui.IWorkbenchPage in project cubrid-manager by CUBRID.
the class LayoutUtil method getEditorParts.
/**
*
* Get the editor parts of this CUBRID node
*
* @param cubridNode the ICubridNode object
* @return List<IEditorPart>
*/
public static List<IEditorPart> getEditorParts(ICubridNode cubridNode) {
List<IEditorPart> partList = new ArrayList<IEditorPart>();
IWorkbenchPage page = getActivePage();
if (page == null) {
return partList;
}
IEditorReference[] editorRefArr = page.getEditorReferences();
if (editorRefArr == null || editorRefArr.length == 0) {
return partList;
}
for (IEditorReference editorRef : editorRefArr) {
try {
IEditorInput editorInput = editorRef.getEditorInput();
if (editorInput instanceof ICubridNode) {
ICubridNode node = (ICubridNode) editorInput;
if (node.getId().equals(cubridNode.getId())) {
partList.add(editorRef.getEditor(false));
}
}
} catch (PartInitException e) {
LOGGER.error(e.getMessage());
}
}
return partList;
}
Aggregations