use of org.eclipse.ui.IWorkbenchPartSite in project translationstudio8 by heartsome.
the class ConcordanceSearchHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
if (!isEnabled()) {
return null;
}
IEditorPart editor = HandlerUtil.getActiveEditor(event);
if (editor instanceof IXliffEditor) {
IXliffEditor xliffEditor = (IXliffEditor) editor;
String XLIFF_EDITOR_ID = "net.heartsome.cat.ts.ui.xliffeditor.nattable.editor";
IEditorPart editorRefer = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (editorRefer.getSite().getId().equals(XLIFF_EDITOR_ID)) {
// IProject project = ((FileEditorInput) editorRefer.getEditorInput()).getFile().getProject();
IFile file = ((FileEditorInput) editorRefer.getEditorInput()).getFile();
ProjectConfiger projectConfig = ProjectConfigerFactory.getProjectConfiger(file.getProject());
List<DatabaseModelBean> lstDatabase = projectConfig.getAllTmDbs();
if (lstDatabase.size() == 0) {
MessageDialog.openInformation(HandlerUtil.getActiveShell(event), Messages.getString("handler.ConcordanceSearchHandler.msgTitle"), Messages.getString("handler.ConcordanceSearchHandler.msg"));
return null;
}
String selectText = xliffEditor.getSelectPureText();
if ((selectText == null || selectText.equals("")) && xliffEditor.getSelectedRowIds().size() == 1) {
selectText = xliffEditor.getXLFHandler().getSrcPureText(xliffEditor.getSelectedRowIds().get(0));
} else if (selectText == null) {
selectText = "";
}
String srcLang = xliffEditor.getSrcColumnName();
String tgtLang = xliffEditor.getTgtColumnName();
ConcordanceSearchDialog dialog = new ConcordanceSearchDialog(editorRefer.getSite().getShell(), file, srcLang, tgtLang, selectText.trim());
Language srcLangL = LocaleService.getLanguageConfiger().getLanguageByCode(srcLang);
Language tgtLangL = LocaleService.getLanguageConfiger().getLanguageByCode(tgtLang);
dialog.open();
if (srcLangL.isBidi() || tgtLangL.isBidi()) {
dialog.getShell().setOrientation(SWT.RIGHT_TO_LEFT);
}
if (selectText != null && !selectText.trim().equals("")) {
dialog.initGroupIdAndSearch();
IWorkbenchPartSite site = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor().getSite();
ICommandService commandService = (ICommandService) site.getService(ICommandService.class);
Command command = commandService.getCommand(ActionFactory.COPY.getCommandId());
IEvaluationService evalService = (IEvaluationService) site.getService(IEvaluationService.class);
IEvaluationContext currentState = evalService.getCurrentState();
ExecutionEvent executionEvent = new ExecutionEvent(command, Collections.EMPTY_MAP, this, currentState);
try {
command.executeWithChecks(executionEvent);
} catch (Exception e1) {
}
}
}
}
return null;
}
use of org.eclipse.ui.IWorkbenchPartSite in project xtext-eclipse by eclipse.
the class HierarchyTreeContentProvider method inputChanged.
@Override
public void inputChanged(final Viewer viewer, final Object oldInput, final Object newInput) {
if ((viewer instanceof AbstractTreeViewer)) {
IWorkbenchPartSite _site = this.viewPart.getSite();
DeferredTreeContentManager _deferredTreeContentManager = new DeferredTreeContentManager(((AbstractTreeViewer) viewer), _site);
this.deferredTreeContentManager = _deferredTreeContentManager;
}
}
use of org.eclipse.ui.IWorkbenchPartSite in project xtext-eclipse by eclipse.
the class ImportsAwareClipboardAction method getShell.
private Shell getShell() {
ITextEditor editor = getTextEditor();
if (editor != null) {
IWorkbenchPartSite site = editor.getSite();
Shell shell = site.getShell();
if (shell != null && !shell.isDisposed()) {
return shell;
}
}
return null;
}
use of org.eclipse.ui.IWorkbenchPartSite in project xtext-eclipse by eclipse.
the class HighlightingReconciler method getDisplay.
private Display getDisplay() {
XtextEditor editor = this.editor;
if (editor == null) {
if (sourceViewer != null)
return sourceViewer.getControl().getDisplay();
return null;
}
IWorkbenchPartSite site = editor.getSite();
if (site == null)
return null;
Shell shell = site.getShell();
if (shell == null || shell.isDisposed())
return null;
Display display = shell.getDisplay();
if (display == null || display.isDisposed())
return null;
return display;
}
use of org.eclipse.ui.IWorkbenchPartSite in project cubrid-manager by CUBRID.
the class CUBRIDTextEditor method createPartControl.
/**
* Create Part Controls.
*
* @param parent composite.
*/
public void createPartControl(Composite parent) {
final Composite composite = new Composite(parent, SWT.NONE);
composite.setLayout(new FillLayout());
composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
initTextViewer(composite);
undoManager.connect(textViewer);
createActions();
updateActions();
//create context menu
MenuManager contextMenuManager = new MenuManager("#PopupMenu", "CUBRIDTExtEditorContextMenu");
contextMenuManager.setRemoveAllWhenShown(true);
contextMenuManager.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
createContextMenu(manager);
}
});
Menu contextMenu = contextMenuManager.createContextMenu(textViewer.getTextWidget());
textViewer.getTextWidget().setMenu(contextMenu);
IWorkbenchPartSite site = getSite();
site.registerContextMenu(contextMenuManager, textViewer);
site.setSelectionProvider(textViewer);
textViewer.getTextWidget().addFocusListener(new FocusListener() {
public void focusGained(FocusEvent event) {
hookRetargetActions();
}
public void focusLost(FocusEvent event) {
unHookRetargetActions();
}
});
}
Aggregations