use of org.eclipse.ui.IEditorSite in project webtools.sourceediting by eclipse.
the class XMLTableTreeActionBarContributor method setActiveEditor.
public void setActiveEditor(IEditorPart targetEditor) {
editorPart = targetEditor;
// IStructuredModel model = getModelForEditorPart(targetEditor);
/* reloadGrammarAction.setModel(model);
toggleAction.setModelQuery(ModelQueryUtil.getModelQuery(model));
XMLTableTreeViewer tableTreeViewer = getTableTreeViewerForEditorPart(editorPart);
if (tableTreeViewer != null) {
expandAction.setViewer(tableTreeViewer);
collapseAction.setViewer(tableTreeViewer);
xmlMenuExpandAction.setViewer(tableTreeViewer);
xmlMenuCollapseAction.setViewer(tableTreeViewer);
}
*/
ITextEditor textEditor = null;
if (editorPart instanceof XMLMultiPageEditorPart) {
IWorkbenchPartSite site = editorPart.getSite();
if (site instanceof IEditorSite) {
textEditor = ((XMLMultiPageEditorPart) editorPart).getTextEditor();
}
}
actionBars.setGlobalActionHandler(ITextEditorActionConstants.UNDO, getAction(textEditor, ITextEditorActionConstants.UNDO));
actionBars.setGlobalActionHandler(ITextEditorActionConstants.REDO, getAction(textEditor, ITextEditorActionConstants.REDO));
// TODO... uncomment this and investigate NPE
//
// add the cut/copy/paste for text fields
// ActionHandlerPlugin.connectPart(editorPart);
}
use of org.eclipse.ui.IEditorSite in project webtools.sourceediting by eclipse.
the class CommonSelectionManager method setSelection.
public void setSelection(ISelection selection, ISelectionProvider source) {
if (enableNotify) {
currentSelection = selection;
enableNotify = false;
try {
SelectionChangedEvent event = new SelectionChangedEvent(source, selection);
List copyOfListenerList = new ArrayList(listenerList);
for (Iterator i = copyOfListenerList.iterator(); i.hasNext(); ) {
ISelectionChangedListener listener = (ISelectionChangedListener) i.next();
listener.selectionChanged(event);
}
// Bug 338126 Properties view not synced with XSD and WSDL design views
// PropertySheet was changed to be a post selection listener
// We need to fire off a post selection change event in order for the properties view to update.
IEditorSite site = getMultiPageEditor().getEditorSite();
if (site != null) {
ISelectionProvider selectionProvider = site.getSelectionProvider();
if (selectionProvider instanceof MultiPageSelectionProvider) {
((MultiPageSelectionProvider) selectionProvider).firePostSelectionChanged(event);
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
enableNotify = true;
}
}
}
use of org.eclipse.ui.IEditorSite in project liferay-ide by liferay.
the class AbstractKaleoEditorHelper method openEditor.
public void openEditor(ISapphirePart sapphirePart, Element modelElement, ValueProperty valueProperty) {
try {
Object content = modelElement.property(valueProperty).content();
if (content == null) {
content = "";
}
IProject project = sapphirePart.adapt(IProject.class);
IEditorInput editorInput = modelElement.adapt(IEditorInput.class);
String name = editorInput.getName();
Node node = modelElement.nearest(Node.class);
String nodeName = node.getName().content();
HiddenFileEditorInput hiddenFileEditorInput = _getHiddenFileEditorInput(project, name, nodeName, content.toString());
IEditorSite editorSite = sapphirePart.adapt(IEditorSite.class);
IWorkbenchWindow wbWindow = editorSite.getWorkbenchWindow();
IEditorPart editorPart = wbWindow.getActivePage().openEditor(hiddenFileEditorInput, _editorId);
ITextEditor textEditor = (ITextEditor) editorPart.getAdapter(ITextEditor.class);
IDocumentListener documentListener = new IDocumentListener() {
public void documentAboutToBeChanged(DocumentEvent event) {
}
public void documentChanged(DocumentEvent event) {
String contents = event.getDocument().get();
modelElement.property(valueProperty).write(contents);
}
};
IDocumentProvider documentProvider = textEditor.getDocumentProvider();
documentProvider.getDocument(hiddenFileEditorInput).addDocumentListener(documentListener);
IWorkbenchPartSite wbPartSite = editorPart.getSite();
IPartListener partListener = new IPartListener() {
public void partActivated(IWorkbenchPart part) {
}
public void partBroughtToTop(IWorkbenchPart part) {
}
public void partClosed(IWorkbenchPart part) {
if ((part != null) && part.equals(editorPart)) {
new WorkspaceJob("delete temp editor file") {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
try {
IFile file = hiddenFileEditorInput.getFile();
file.getParent().delete(true, null);
} catch (CoreException ce) {
}
return Status.OK_STATUS;
}
}.schedule(100);
}
}
public void partDeactivated(IWorkbenchPart part) {
}
public void partOpened(IWorkbenchPart part) {
}
};
wbPartSite.getPage().addPartListener(partListener);
} catch (Exception e) {
KaleoUI.logError("Error opening editor.", e);
}
}
use of org.eclipse.ui.IEditorSite in project usbdm-eclipse-plugins by podonoghue.
the class DeviceEditor method contributeToActionBars.
@SuppressWarnings("unused")
private void contributeToActionBars() {
IEditorSite site = getEditorSite();
if (site == null) {
System.err.println("site is null");
return;
}
IActionBars bars = site.getActionBars();
fillLocalPullDown(bars.getMenuManager());
fillLocalToolBar(bars.getToolBarManager());
}
use of org.eclipse.ui.IEditorSite in project xtext-xtend by eclipse.
the class OpenEditorTest method assertActiveEditor.
protected void assertActiveEditor(String expectedEditorID, String expectedEditorTitle, final String expectedSelection) {
IEditorPart editorPart = workbench.getActiveWorkbenchWindow().getActivePage().getActiveEditor();
assertEquals(expectedEditorTitle, editorPart.getTitle());
IEditorSite editorSite = editorPart.getEditorSite();
assertEquals(expectedEditorID, editorSite.getId());
final ISelectionProvider selectionProvider = editorSite.getSelectionProvider();
assertTrue(selectionProvider.getSelection() instanceof ITextSelection);
// The selection may be updated asynchronously, so we may have to wait until the selection changes
workbenchTestHelper.awaitUIUpdate(new Functions.Function0<Boolean>() {
@Override
public Boolean apply() {
return expectedSelection.equals(((ITextSelection) selectionProvider.getSelection()).getText());
}
}, SELECTION_TIMEOUT);
assertEquals(expectedSelection, ((ITextSelection) selectionProvider.getSelection()).getText());
}
Aggregations