Search in sources :

Example 16 with IEditorSite

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);
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) ITextEditor(org.eclipse.ui.texteditor.ITextEditor) IEditorSite(org.eclipse.ui.IEditorSite)

Example 17 with IEditorSite

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;
        }
    }
}
Also used : ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) MultiPageSelectionProvider(org.eclipse.ui.part.MultiPageSelectionProvider) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) List(java.util.List) ArrayList(java.util.ArrayList) IEditorSite(org.eclipse.ui.IEditorSite)

Example 18 with IEditorSite

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);
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IStatus(org.eclipse.core.runtime.IStatus) ITextEditor(org.eclipse.ui.texteditor.ITextEditor) IFile(org.eclipse.core.resources.IFile) IPartListener(org.eclipse.ui.IPartListener) Node(com.liferay.ide.kaleo.core.model.Node) IDocumentListener(org.eclipse.jface.text.IDocumentListener) WorkspaceJob(org.eclipse.core.resources.WorkspaceJob) IEditorPart(org.eclipse.ui.IEditorPart) DocumentEvent(org.eclipse.jface.text.DocumentEvent) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) HiddenFileEditorInput(com.liferay.ide.kaleo.ui.editor.HiddenFileEditorInput) IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IDocumentProvider(org.eclipse.ui.texteditor.IDocumentProvider) CoreException(org.eclipse.core.runtime.CoreException) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) IEditorInput(org.eclipse.ui.IEditorInput) IEditorSite(org.eclipse.ui.IEditorSite)

Example 19 with IEditorSite

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());
}
Also used : IEditorSite(org.eclipse.ui.IEditorSite) IActionBars(org.eclipse.ui.IActionBars)

Example 20 with IEditorSite

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());
}
Also used : ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) Functions(org.eclipse.xtext.xbase.lib.Functions) IEditorPart(org.eclipse.ui.IEditorPart) IEditorSite(org.eclipse.ui.IEditorSite) ITextSelection(org.eclipse.jface.text.ITextSelection)

Aggregations

IEditorSite (org.eclipse.ui.IEditorSite)26 IWorkbenchPartSite (org.eclipse.ui.IWorkbenchPartSite)7 List (java.util.List)5 Control (org.eclipse.swt.widgets.Control)5 IEditorPart (org.eclipse.ui.IEditorPart)5 PartInitException (org.eclipse.ui.PartInitException)5 IDocumentProvider (org.eclipse.ui.texteditor.IDocumentProvider)5 ITextEditor (org.eclipse.ui.texteditor.ITextEditor)5 InputStream (java.io.InputStream)4 ArrayList (java.util.ArrayList)4 StyledText (org.eclipse.swt.custom.StyledText)4 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)4 SelectionEvent (org.eclipse.swt.events.SelectionEvent)4 FillLayout (org.eclipse.swt.layout.FillLayout)4 GridData (org.eclipse.swt.layout.GridData)4 Composite (org.eclipse.swt.widgets.Composite)4 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)4 DBPDataSource (org.jkiss.dbeaver.model.DBPDataSource)4 DBPDataSourceContainer (org.jkiss.dbeaver.model.DBPDataSourceContainer)4 DBPIdentifierCase (org.jkiss.dbeaver.model.DBPIdentifierCase)4