use of org.eclipse.ui.IViewPart in project translationstudio8 by heartsome.
the class ExecuteGoogleTransHandler method execute.
/**
* (non-Javadoc)
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
final IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
IEditorPart editor = HandlerUtil.getActiveEditor(event);
if (!(editor instanceof IXliffEditor)) {
return null;
}
PrefrenceParameters ps = PrefrenceParameters.getInstance();
if (!ps.isGoogleState()) {
MessageDialog.openError(window.getShell(), Messages.getString("handler.ExecuteGoogleTransHandler.msgTitle"), Messages.getString("handler.ExecuteGoogleTransHandler.msg"));
return null;
}
final IXliffEditor xliffEditor = (IXliffEditor) editor;
final int[] selectedRowIndexs = xliffEditor.getSelectedRows();
if (selectedRowIndexs.length == 0) {
return null;
}
ISimpleMatcher matcher = new SimpleMatcherGoogleImpl();
IViewPart viewPart = window.getActivePage().findView(MatchViewPart.ID);
if (viewPart != null && viewPart instanceof MatchViewPart) {
MatchViewPart matchView = (MatchViewPart) viewPart;
matchView.manualExecSimpleTranslation(selectedRowIndexs[0], xliffEditor, matcher);
}
return null;
}
use of org.eclipse.ui.IViewPart in project cubrid-manager by CUBRID.
the class StatusLineContrItem method changeStuatusLineForViewOrEditPart.
/**
*
* When selection changed,change status line message for view part or editor
* part
*
* @param node the ICubridNode object
* @param workbenchPart the IWorkbenchPart object
*/
public void changeStuatusLineForViewOrEditPart(ICubridNode node, IWorkbenchPart workbenchPart) {
WorkbenchWindow window = (WorkbenchWindow) PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window == null) {
return;
}
String nodePath = "";
if (workbenchPart == null) {
if (null != node.getViewId()) {
IViewPart viewPart = LayoutUtil.getViewPart(node, node.getViewId());
if (viewPart != null) {
nodePath = viewPart.getTitle();
}
}
if (null != node.getEditorId()) {
IEditorPart editorPart = LayoutUtil.getEditorPart(node, node.getEditorId());
if (editorPart != null) {
nodePath = editorPart.getTitle();
}
}
} else {
nodePath = workbenchPart.getTitle();
}
//window.setStatus(nodePath == null ? "" : nodePath);
}
use of org.eclipse.ui.IViewPart in project cubrid-manager by CUBRID.
the class WorkbenchContrItem method processNodeRemoveWhenRefreshContainer.
/**
* When refresh the container node and if this child node is deleted, then
* close it's editor or view part
*
* @param eventNode ICubridNode
* @param page IWorkbenchPage
*/
protected void processNodeRemoveWhenRefreshContainer(ICubridNode eventNode, IWorkbenchPage page) {
synchronized (this) {
IEditorReference[] editorRefArr = page.getEditorReferences();
if (editorRefArr != null && editorRefArr.length > 0) {
for (IEditorReference editorRef : editorRefArr) {
try {
IEditorInput editorInput = editorRef.getEditorInput();
if (editorInput instanceof ICubridNode) {
ICubridNode editorNode = (ICubridNode) editorInput;
ICubridNode parentNode = editorNode.getParent();
if (editorNode != null && parentNode != null && parentNode.getId().equals(eventNode.getId()) && eventNode.getChild(editorNode.getId()) == null) {
processNodeRemove(editorNode, page);
}
}
} catch (PartInitException e1) {
LOGGER.error(e1.getMessage());
}
}
}
IViewReference[] viewRefArr = page.getViewReferences();
if (viewRefArr != null && viewRefArr.length > 0) {
for (IViewReference viewRef : viewRefArr) {
IViewPart viewPart = viewRef.getView(false);
if (viewPart instanceof CubridViewPart) {
ICubridNode viewPartNode = ((CubridViewPart) viewPart).getCubridNode();
if (viewPartNode == null) {
continue;
}
ICubridNode parentNode = viewPartNode.getParent();
if (viewPartNode != null && parentNode != null && parentNode.getId().equals(eventNode.getId()) && eventNode.getChild(viewPartNode.getId()) == null) {
processNodeRemove(viewPartNode, page);
}
}
}
}
}
}
use of org.eclipse.ui.IViewPart in project cubrid-manager by CUBRID.
the class WorkbenchContrItem 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 CubridIndexNavigatorView method getInstance.
public static CubridIndexNavigatorView 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 CubridIndexNavigatorView ? (CubridIndexNavigatorView) viewPart : null;
}
return null;
}
Aggregations