use of org.eclipse.ui.IViewPart in project cubrid-manager by CUBRID.
the class CubridWorkbenchContrItem method reopenEditorOrView.
/**
* ReOpen the editor or view part of this CUBRID node
*
* @param cubridNode the ICubridNode object
*/
public void reopenEditorOrView(ICubridNode cubridNode) {
if (cubridNode == null) {
return;
}
String editorId = cubridNode.getEditorId();
String viewId = cubridNode.getViewId();
if (editorId != null && editorId.trim().length() > 0) {
IEditorPart editorPart = LayoutUtil.getEditorPart(cubridNode, editorId);
if (editorPart != null) {
openEditorOrView(cubridNode);
}
} else if (viewId != null && viewId.trim().length() > 0) {
IViewPart viewPart = LayoutUtil.getViewPart(cubridNode, viewId);
if (viewPart != null) {
openEditorOrView(cubridNode);
}
}
}
use of org.eclipse.ui.IViewPart in project cubrid-manager by CUBRID.
the class LayoutUtil method getViewPart.
/**
*
* Get the view part of this cubrid node and viewId
*
* @param cubridNode the ICubridNode object
* @param viewId the view id
* @return the IViewPart object
*/
public static IViewPart getViewPart(ICubridNode cubridNode, String viewId) {
IWorkbenchPage page = getActivePage();
if (page == null) {
return null;
}
IViewReference[] viewRefArr = page.getViewReferences();
if (viewRefArr == null || viewRefArr.length == 0) {
return null;
}
for (IViewReference viewRef : viewRefArr) {
IViewPart viewPart = viewRef.getView(false);
String id = viewRef.getId();
if (viewPart instanceof CubridViewPart) {
CubridViewPart cubridViewPart = (CubridViewPart) viewPart;
ICubridNode node = cubridViewPart.getCubridNode();
if (node != null && node.getId().equals(cubridNode.getId()) && viewId.equals(id)) {
return viewPart;
}
}
}
return null;
}
use of org.eclipse.ui.IViewPart in project cubrid-manager by CUBRID.
the class LayoutUtil method getViewParts.
/**
*
* Get the view parts of this CUBRID node
*
* @param cubridNode the ICubridNode object
* @return List<IViewPart>
*/
public static List<IViewPart> getViewParts(ICubridNode cubridNode) {
List<IViewPart> viewPartList = new ArrayList<IViewPart>();
IWorkbenchPage page = getActivePage();
if (page == null) {
return viewPartList;
}
IViewReference[] viewRefArr = page.getViewReferences();
if (viewRefArr == null || viewRefArr.length == 0) {
return viewPartList;
}
for (IViewReference viewRef : viewRefArr) {
IViewPart viewPart = viewRef.getView(false);
if (viewPart instanceof CubridViewPart) {
CubridViewPart cubridViewPart = (CubridViewPart) viewPart;
ICubridNode node = cubridViewPart.getCubridNode();
if (node != null && node.getId().equals(cubridNode.getId())) {
viewPartList.add(viewPart);
}
}
}
return viewPartList;
}
use of org.eclipse.ui.IViewPart in project cubrid-manager by CUBRID.
the class LayoutUtil method closeEditorAndView.
/**
*
* Close the editor or view part relating to this given CUBIRD node, but the
* query editor is not included.
*
* @param cubridNode the ICubridNode object
*/
public static void closeEditorAndView(ICubridNode cubridNode) {
IWorkbenchPage page = getActivePage();
if (page == null) {
return;
}
String editorId = cubridNode.getEditorId();
if (editorId != null) {
IEditorPart editorPart = getEditorPart(cubridNode, editorId);
if (editorPart != null) {
page.closeEditor(editorPart, false);
}
}
String viewId = cubridNode.getViewId();
if (viewId != null) {
IViewPart viewPart = getViewPart(cubridNode, viewId);
if (null != viewPart) {
page.hideView(viewPart);
}
}
}
use of org.eclipse.ui.IViewPart in project cubrid-manager by CUBRID.
the class BrokerMonitorPart method performRequest.
/**
* @see org.eclipse.gef.editparts.AbstractEditPart#performRequest(org.eclipse.gef.Request)
* @param req Request
*/
public void performRequest(Request req) {
if (req.getType() == RequestConstants.REQ_OPEN) {
BrokerNode bn = (BrokerNode) getModel();
String brokerName = bn.getBrokerName();
HostNode hn = bn.getParent();
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return;
}
IWorkbenchPage page = window.getActivePage();
if (page == null) {
return;
}
String secondaryId = new StringBuffer(brokerName + "@" + hn.getUserName()).append("&").append(hn.getIp()).append("&").append(hn.getPort()).toString();
IViewReference viewReference = page.findViewReference(BrokerDashboardViewPart.ID, secondaryId);
if (viewReference == null) {
try {
IViewPart viewPart = page.showView(BrokerDashboardViewPart.ID, secondaryId, IWorkbenchPage.VIEW_ACTIVATE);
((BrokerDashboardViewPart) viewPart).init((BrokerNode) getModel());
} catch (PartInitException ex) {
viewReference = null;
}
} else {
IViewPart viewPart = viewReference.getView(false);
window.getActivePage().bringToTop(viewPart);
((BrokerDashboardViewPart) viewPart).init((BrokerNode) getModel());
}
}
}
Aggregations