Search in sources :

Example 51 with IWorkbenchPartSite

use of org.eclipse.ui.IWorkbenchPartSite in project tmdm-studio-se by Talend.

the class RenameViewAction method getRenameDialog.

private RenameViewDialog getRenameDialog(String oldName) {
    RenameViewDialog dialog = null;
    IWorkbenchPartSite site = commonViewer.getCommonNavigator().getSite();
    if (RepositoryTransformUtil.getInstance().getViewType(oldName) == TYPE_WEBFILTER) {
        dialog = new RenameViewDialog(getShell(), Messages.RenameObjectAction_rename, Messages.Common_rename, oldName.substring(PREFIX_VIEW_UPPER.length()), getInputValidator(), site);
    } else {
        dialog = new RenameViewDialog2(getShell(), Messages.RenameObjectAction_rename, Messages.Common_rename, oldName, getInputValidator(), site);
    }
    return dialog;
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) RenameViewDialog2(org.talend.mdm.repository.ui.dialogs.RenameViewDialog2) RenameViewDialog(org.talend.mdm.repository.ui.dialogs.RenameViewDialog)

Example 52 with IWorkbenchPartSite

use of org.eclipse.ui.IWorkbenchPartSite in project eclipse-integration-commons by spring-projects.

the class DashboardMainPage method displayFeeds.

private void displayFeeds(final Composite composite, final ScrolledComposite scrolled, final PageBook pagebook, final Control disclaimer, Map<String, String> map, String feedName, final Section section) {
    final AggregateFeedJob job = new AggregateFeedJob(map, feedName);
    job.addJobChangeListener(new JobChangeAdapter() {

        @Override
        public void done(IJobChangeEvent event) {
            unfinishedJobs.remove(job);
            IWorkbenchPartSite site = getSite();
            if (site != null && site.getShell() != null && !site.getShell().isDisposed() && site.getShell().getDisplay() != null && !site.getShell().getDisplay().isDisposed()) {
                site.getShell().getDisplay().asyncExec(new Runnable() {

                    public void run() {
                        Map<SyndEntry, SyndFeed> entryToFeed = job.getFeedReader().getFeedsWithEntries();
                        Set<SyndEntry> entries = entryToFeed.keySet();
                        if (!getManagedForm().getForm().isDisposed()) {
                            displayFeeds(entries, composite, scrolled, pagebook, disclaimer, section);
                        }
                    }
                });
            }
        }
    });
    unfinishedJobs.add(job);
    job.schedule();
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) SyndFeed(com.sun.syndication.feed.synd.SyndFeed) SyndEntry(com.sun.syndication.feed.synd.SyndEntry) JobChangeAdapter(org.eclipse.core.runtime.jobs.JobChangeAdapter) IJobChangeEvent(org.eclipse.core.runtime.jobs.IJobChangeEvent)

Example 53 with IWorkbenchPartSite

use of org.eclipse.ui.IWorkbenchPartSite 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 54 with IWorkbenchPartSite

use of org.eclipse.ui.IWorkbenchPartSite in project webtools.sourceediting by eclipse.

the class XSDRefactorGroupActionDelegate method fillMenu.

/**
 * Fills the menu with applicable refactor sub-menues
 * @param menu The menu to fill
 */
protected void fillMenu(Menu menu) {
    if (fSelection == null) {
        return;
    }
    if (workbenchPart != null) {
        IWorkbenchPartSite site = workbenchPart.getSite();
        if (site == null)
            return;
        IEditorPart editor = site.getPage().getActiveEditor();
        if (editor != null) {
            XSDSchema schema = (XSDSchema) editor.getAdapter(XSDSchema.class);
            ISelectionMapper mapper = (ISelectionMapper) editor.getAdapter(ISelectionMapper.class);
            if (schema != null) {
                ISelection selection = mapper != null ? mapper.mapSelection(fSelection) : fSelection;
                RefactorActionGroup refactorMenuGroup = new XSDRefactorActionGroup(selection, schema);
                RefactorGroupSubMenu subMenu = new RefactorGroupSubMenu(refactorMenuGroup);
                subMenu.fill(menu, -1);
            }
        }
    }
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) RefactorActionGroup(org.eclipse.wst.xsd.ui.internal.refactor.wizard.RefactorActionGroup) XSDRefactorActionGroup(org.eclipse.wst.xsd.ui.internal.refactor.actions.XSDRefactorActionGroup) ISelectionMapper(org.eclipse.wst.xsd.ui.internal.editor.ISelectionMapper) ISelection(org.eclipse.jface.viewers.ISelection) IEditorPart(org.eclipse.ui.IEditorPart) RefactorGroupSubMenu(org.eclipse.wst.xsd.ui.internal.refactor.wizard.RefactorGroupSubMenu) XSDRefactorActionGroup(org.eclipse.wst.xsd.ui.internal.refactor.actions.XSDRefactorActionGroup) XSDSchema(org.eclipse.xsd.XSDSchema)

Example 55 with IWorkbenchPartSite

use of org.eclipse.ui.IWorkbenchPartSite 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)

Aggregations

IWorkbenchPartSite (org.eclipse.ui.IWorkbenchPartSite)73 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)13 ISelection (org.eclipse.jface.viewers.ISelection)12 IEditorPart (org.eclipse.ui.IEditorPart)12 ArrayList (java.util.ArrayList)10 MenuManager (org.eclipse.jface.action.MenuManager)9 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)9 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)9 Composite (org.eclipse.swt.widgets.Composite)9 Display (org.eclipse.swt.widgets.Display)9 Shell (org.eclipse.swt.widgets.Shell)9 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)9 Menu (org.eclipse.swt.widgets.Menu)7 IEditorSite (org.eclipse.ui.IEditorSite)7 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)7 SWT (org.eclipse.swt.SWT)6 PartInitException (org.eclipse.ui.PartInitException)6 List (java.util.List)5 IToolBarManager (org.eclipse.jface.action.IToolBarManager)4 Separator (org.eclipse.jface.action.Separator)4