Search in sources :

Example 56 with IViewReference

use of org.eclipse.ui.IViewReference in project org.csstudio.display.builder by kasemir.

the class RuntimeViewPart method open.

/**
 * Open a runtime display
 *
 *  <p>Either opens a new display, or if there is already an existing view
 *  for that input, "activate" it, which pops a potentially hidden view to the top.
 *
 *  @param page Page to use. <code>null</code> for 'active' page
 *  @param close_handler Code to call when part is closed
 *  @param info DisplayInfo (to compare with currently open displays)
 *  @return {@link RuntimeViewPart}
 *  @throws Exception on error
 */
public static RuntimeViewPart open(IWorkbenchPage page, final Consumer<DisplayModel> close_handler, final DisplayInfo info) throws Exception {
    if (page == null)
        page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    if (info != null)
        for (IViewReference view_ref : page.getViewReferences()) if (view_ref.getId().startsWith(ID)) {
            final IViewPart view = view_ref.getView(true);
            if (view instanceof RuntimeViewPart) {
                final RuntimeViewPart runtime_view = (RuntimeViewPart) view;
                if (// Allow for runtime_view.getDisplayInfo() == null
                info.equals(runtime_view.getDisplayInfo())) {
                    page.showView(view_ref.getId(), view_ref.getSecondaryId(), IWorkbenchPage.VIEW_ACTIVATE);
                    return runtime_view;
                }
            }
        }
    final RuntimeViewPart part = (RuntimeViewPart) page.showView(ID, UUID.randomUUID().toString(), IWorkbenchPage.VIEW_ACTIVATE);
    part.close_handler = close_handler;
    return part;
}
Also used : IViewPart(org.eclipse.ui.IViewPart) IViewReference(org.eclipse.ui.IViewReference)

Example 57 with IViewReference

use of org.eclipse.ui.IViewReference in project jbosstools-openshift by jbosstools.

the class UIUtils method getVisibleViewParts.

/**
 * Returns the visible workbench parts which match the given ids. If no ids
 * are given all visible parts are returned.
 *
 * @param partIds
 * @return
 *
 * @see IWorkbenchPart
 */
public static List<IViewPart> getVisibleViewParts(String... partIds) {
    IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    IWorkbenchPage page = workbenchWindow.getActivePage();
    final List<String> partIdsList = new ArrayList<>();
    List<IViewPart> parts = null;
    if (partIds != null) {
        parts = new ArrayList<>(partIds.length);
    }
    for (IViewReference viewReference : page.getViewReferences()) {
        String partId = viewReference.getId();
        if (partIdsList == null || partIdsList.isEmpty() || partIdsList.contains(partId)) {
            IViewPart part = viewReference.getView(false);
            if (part != null && page.isPartVisible(part)) {
                parts.add(part);
            }
        }
    }
    parts.stream().sorted((part1, part2) -> {
        int indexPart1 = partIdsList.indexOf(part1.getSite().getId());
        int indexPart2 = partIdsList.indexOf(part1.getSite().getId());
        if (indexPart1 > indexPart2) {
            return 1;
        } else {
            return -1;
        }
    });
    return parts;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IViewPart(org.eclipse.ui.IViewPart) IViewReference(org.eclipse.ui.IViewReference) ArrayList(java.util.ArrayList) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage)

Example 58 with IViewReference

use of org.eclipse.ui.IViewReference in project hale by halestudio.

the class InstanceValidationReportDetailsPage method showSelectionInDataView.

/**
 * Shows the current selection (if valid) in the transformed data view.
 */
private void showSelectionInDataView() {
    InstanceSelection selection = getValidSelection();
    if (selection != null) {
        IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        // pin the property sheet if possible
        IViewReference ref = page.findViewReference(IPageLayout.ID_PROP_SHEET);
        if (ref != null) {
            IViewPart part = ref.getView(true);
            if (part instanceof PropertySheet)
                ((PropertySheet) part).setPinned(true);
        }
        // show transformed data view with selection if possible
        try {
            TransformedDataView transformedDataView = (TransformedDataView) page.showView(TransformedDataView.ID);
            transformedDataView.showSelection(selection, reportImage);
        } catch (PartInitException e) {
        // if it's not there, we cannot do anything
        }
    }
}
Also used : IViewPart(org.eclipse.ui.IViewPart) PropertySheet(org.eclipse.ui.views.properties.PropertySheet) IViewReference(org.eclipse.ui.IViewReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) InstanceSelection(eu.esdihumboldt.hale.ui.selection.InstanceSelection) DefaultInstanceSelection(eu.esdihumboldt.hale.ui.selection.impl.DefaultInstanceSelection) PartInitException(org.eclipse.ui.PartInitException) TransformedDataView(eu.esdihumboldt.hale.ui.views.data.TransformedDataView)

Example 59 with IViewReference

use of org.eclipse.ui.IViewReference in project hale by halestudio.

the class OpenPropertiesHandler method unpinAndOpenPropertiesView.

/**
 * Unpin and open the porperties view.
 *
 * @param activeWindow the active workbench window
 */
public static void unpinAndOpenPropertiesView(IWorkbenchWindow activeWindow) {
    try {
        // unpin the property sheet if possible
        IViewReference ref = activeWindow.getActivePage().findViewReference(IPageLayout.ID_PROP_SHEET);
        if (ref != null) {
            IViewPart part = ref.getView(false);
            if (part instanceof PropertySheet) {
                PropertySheet sheet = (PropertySheet) part;
                if (sheet.isPinned()) {
                    sheet.setPinned(false);
                    IWorkbenchPart activePart = activeWindow.getActivePage().getActivePart();
                    /*
						 * Feign the part has been activated (cause else the
						 * PropertySheet will only take a selection from the
						 * last part it was displaying properties about)
						 */
                    sheet.partActivated(activePart);
                    // get the current selection
                    ISelection sel = activePart.getSite().getSelectionProvider().getSelection();
                    // Update the properties view with the current selection
                    sheet.selectionChanged(activePart, sel);
                }
            }
        }
        // show the view
        activeWindow.getActivePage().showView(IPageLayout.ID_PROP_SHEET);
    } catch (PartInitException e) {
        log.error("Error opening properties view", e);
    }
}
Also used : IViewPart(org.eclipse.ui.IViewPart) PropertySheet(org.eclipse.ui.views.properties.PropertySheet) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) IViewReference(org.eclipse.ui.IViewReference) ISelection(org.eclipse.jface.viewers.ISelection) PartInitException(org.eclipse.ui.PartInitException)

Example 60 with IViewReference

use of org.eclipse.ui.IViewReference in project gfm_viewer by satyagraha.

the class ViewManager method findViewImplementing.

/**
 * Find a view implementing a specified interface.
 *
 * @param type
 *            the interface
 * @return the view (or null)
 */
@SuppressWarnings("unchecked")
public static <T> T findViewImplementing(Class<T> type) {
    IWorkbenchPage workbenchPage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    IViewReference[] viewReferences = workbenchPage.getViewReferences();
    IWorkbenchPart part = with(viewReferences).extract(on(IViewReference.class).getPart(false)).first(Matchers.instanceOf(type));
    return (T) part;
}
Also used : IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) IViewReference(org.eclipse.ui.IViewReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage)

Aggregations

IViewReference (org.eclipse.ui.IViewReference)66 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)48 IViewPart (org.eclipse.ui.IViewPart)37 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)23 PartInitException (org.eclipse.ui.PartInitException)23 IFile (org.eclipse.core.resources.IFile)10 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)8 ArrayList (java.util.ArrayList)8 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)8 TechnicalException (org.eclipse.titan.log.viewer.exceptions.TechnicalException)8 CubridViewPart (com.cubrid.common.ui.spi.part.CubridViewPart)7 UserException (org.eclipse.titan.log.viewer.exceptions.UserException)7 IOException (java.io.IOException)6 IEditorInput (org.eclipse.ui.IEditorInput)6 IEditorReference (org.eclipse.ui.IEditorReference)6 HostNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode)4 ParseException (java.text.ParseException)4 IProject (org.eclipse.core.resources.IProject)4 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)4 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)4