Search in sources :

Example 1 with INavigatorContentService

use of org.eclipse.ui.navigator.INavigatorContentService in project tdi-studio-se by Talend.

the class ExportItemWizardPage method createTreeViewer.

private void createTreeViewer(Composite itemComposite) {
    filteredCheckboxTree = new FilteredCheckboxTree(itemComposite, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI) {

        @Override
        protected CheckboxTreeViewer doCreateTreeViewer(Composite parent, int style) {
            RepoCommonViewerProvider provider = RepoCommonViewerProvider.CHECKBOX;
            if (baseViewId != null) {
                provider.setViewId(baseViewId);
            }
            CheckboxTreeViewer viwer = (CheckboxTreeViewer) provider.createViewer(parent);
            // FIXME this is temp fix for 5.4.2
            INavigatorContentService navigatorContentService = ((INavigatorContentServiceProvider) viwer).getNavigatorContentService();
            if (navigatorContentService != null) {
                IExtensionStateModel findStateModel = navigatorContentService.findStateModel(//$NON-NLS-1$
                "com.oaklandsw.transform.navigatorContent");
                if (findStateModel != null) {
                    //$NON-NLS-1$
                    findStateModel.setBooleanProperty("org.talend.repository.ui.actions.importexport", true);
                }
            }
            return viwer;
        }

        @Override
        protected void refreshCompleted() {
            getViewer().expandToLevel(3);
            restoreCheckedElements();
        }

        @Override
        protected boolean isNodeCollectable(TreeItem item) {
            Object obj = item.getData();
            if (obj instanceof RepositoryNode) {
                RepositoryNode node = (RepositoryNode) obj;
                if (node.getObjectType() == ERepositoryObjectType.METADATA_CONNECTIONS) {
                    return true;
                }
            }
            return false;
        }
    };
    filteredCheckboxTree.getViewer().addFilter(new ViewerFilter() {

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            boolean select = true;
            if (element instanceof RepositoryNode) {
                select = selectRepositoryNode(viewer, (RepositoryNode) element);
            }
            if (select) {
                for (IRepositoryReviewFilter nodeHandler : RepositoryContentManager.getRepositoryReviewFilters()) {
                    //$NON-NLS-1$
                    boolean exportFilter = nodeHandler.filter(viewer, parentElement, element, "repository_review");
                    if (!exportFilter) {
                        return exportFilter;
                    }
                }
            }
            return select;
        }
    });
}
Also used : IExtensionStateModel(org.eclipse.ui.navigator.IExtensionStateModel) FilteredCheckboxTree(org.talend.core.ui.advanced.composite.FilteredCheckboxTree) Composite(org.eclipse.swt.widgets.Composite) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) TreeItem(org.eclipse.swt.widgets.TreeItem) TreeViewer(org.eclipse.jface.viewers.TreeViewer) Viewer(org.eclipse.jface.viewers.Viewer) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) RepoCommonViewerProvider(org.talend.repository.viewer.ui.provider.RepoCommonViewerProvider) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) IRepositoryReviewFilter(org.talend.core.model.repository.IRepositoryReviewFilter) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryObject(org.talend.core.model.repository.RepositoryObject) INavigatorContentService(org.eclipse.ui.navigator.INavigatorContentService)

Example 2 with INavigatorContentService

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

the class MDMNavigatorDecoratingLabelProvider method getToolTipText.

@Override
public String getToolTipText(Object element) {
    if (getViewer() instanceof CommonViewer) {
        CommonViewer viewer = (CommonViewer) getViewer();
        INavigatorContentService contentService = viewer.getNavigatorContentService();
        if (contentService != null && contentService instanceof NavigatorContentService) {
            Collection<?> contentExtensions = ((NavigatorContentService) contentService).findPossibleLabelExtensions(element);
            for (Iterator<?> itr = contentExtensions.iterator(); itr.hasNext(); ) {
                Object extension = itr.next();
                if (extension instanceof NavigatorContentExtension) {
                    ICommonLabelProvider provider = ((NavigatorContentExtension) extension).getLabelProvider();
                    if (provider instanceof CellLabelProvider) {
                        String toolTipText = ((CellLabelProvider) provider).getToolTipText(element);
                        if (toolTipText != null) {
                            return toolTipText;
                        }
                    }
                }
            }
        }
    }
    return super.getToolTipText(element);
}
Also used : INavigatorContentService(org.eclipse.ui.navigator.INavigatorContentService) NavigatorContentService(org.eclipse.ui.internal.navigator.NavigatorContentService) NavigatorContentExtension(org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension) CommonViewer(org.eclipse.ui.navigator.CommonViewer) ICommonLabelProvider(org.eclipse.ui.navigator.ICommonLabelProvider) INavigatorContentService(org.eclipse.ui.navigator.INavigatorContentService) CellLabelProvider(org.eclipse.jface.viewers.CellLabelProvider)

Example 3 with INavigatorContentService

use of org.eclipse.ui.navigator.INavigatorContentService in project liferay-ide by liferay.

the class ProjectExplorerLayoutUtil method _execute.

private static void _execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchPart part = HandlerUtil.getActivePart(event);
    String nestedProjectsContentProviderExtensionId = "org.eclipse.ui.navigator.resources.nested.nestedProjectContentProvider";
    String hideTopLevelProjectIfNested = "org.eclipse.ui.navigator.resources.nested.HideTopLevelProjectIfNested";
    String hideFolderWhenProjectIsShownAsNested = "org.eclipse.ui.navigator.resources.nested.HideFolderWhenProjectIsShownAsNested";
    if (part instanceof CommonNavigator) {
        CommonNavigator navigator = (CommonNavigator) part;
        INavigatorContentService navigatorContentService = navigator.getNavigatorContentService();
        boolean previousNest = navigatorContentService.getActivationService().isNavigatorExtensionActive(nestedProjectsContentProviderExtensionId);
        String newNestParam = event.getParameter(_nestParameter);
        boolean newNest = false;
        if (newNestParam != null) {
            newNest = Boolean.parseBoolean(newNestParam);
        }
        if (newNest != previousNest) {
            ISelection initialSelection = navigator.getCommonViewer().getSelection();
            INavigatorFilterService filterService = navigatorContentService.getFilterService();
            Set<String> filters = new HashSet<>();
            for (ICommonFilterDescriptor desc : filterService.getVisibleFilterDescriptors()) {
                if (filterService.isActive(desc.getId())) {
                    filters.add(desc.getId());
                }
            }
            if (newNest) {
                navigatorContentService.getActivationService().activateExtensions(new String[] { nestedProjectsContentProviderExtensionId }, false);
                filters.add(hideTopLevelProjectIfNested);
                filters.add(hideFolderWhenProjectIsShownAsNested);
            } else {
                navigatorContentService.getActivationService().deactivateExtensions(new String[] { nestedProjectsContentProviderExtensionId }, false);
                filters.remove(hideTopLevelProjectIfNested);
                filters.remove(hideFolderWhenProjectIsShownAsNested);
            }
            filterService.activateFilterIdsAndUpdateViewer(filters.toArray(new String[filters.size()]));
            navigatorContentService.getActivationService().persistExtensionActivations();
            navigator.getCommonViewer().refresh();
            navigator.getCommonViewer().setSelection(initialSelection);
        }
        HandlerUtil.updateRadioState(event.getCommand(), Boolean.toString(newNest));
    }
}
Also used : CommonNavigator(org.eclipse.ui.navigator.CommonNavigator) ICommonFilterDescriptor(org.eclipse.ui.navigator.ICommonFilterDescriptor) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) ISelection(org.eclipse.jface.viewers.ISelection) INavigatorFilterService(org.eclipse.ui.navigator.INavigatorFilterService) INavigatorContentService(org.eclipse.ui.navigator.INavigatorContentService) HashSet(java.util.HashSet)

Example 4 with INavigatorContentService

use of org.eclipse.ui.navigator.INavigatorContentService in project polymap4-core by Polymap4.

the class NavigatorPluginDropAction method run.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.ui.part.IDropActionDelegate#run(java.lang.Object,
	 *      java.lang.Object)
	 */
public boolean run(Object sourceData, Object target) {
    if (Policy.DEBUG_DND) {
        // $NON-NLS-1$
        System.out.println("NavigatorPluginDropAction.run (begin)");
    }
    String sourceViewerId = new String((byte[]) sourceData);
    IStructuredSelection selection = (IStructuredSelection) LocalSelectionTransfer.getTransfer().getSelection();
    INavigatorContentService contentService = NavigatorContentServiceTransfer.getInstance().findService(sourceViewerId);
    if (contentService == null) {
        return false;
    }
    try {
        CommonDropAdapterAssistant[] assistants = contentService.getDnDService().findCommonDropAdapterAssistants(target, selection);
        IStatus valid = null;
        for (int i = 0; i < assistants.length; i++) {
            valid = assistants[i].validatePluginTransferDrop(selection, target);
            if (valid != null && valid.isOK()) {
                valid = assistants[i].handlePluginTransferDrop(selection, target);
                return valid != null && valid.isOK();
            }
        }
    } finally {
        NavigatorContentServiceTransfer.getInstance().unregisterContentService(contentService);
    }
    if (Policy.DEBUG_DND) {
        // $NON-NLS-1$
        System.out.println("NavigatorPluginDropAction.run (exit)");
    }
    return false;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) CommonDropAdapterAssistant(org.eclipse.ui.navigator.CommonDropAdapterAssistant) INavigatorContentService(org.eclipse.ui.navigator.INavigatorContentService)

Aggregations

INavigatorContentService (org.eclipse.ui.navigator.INavigatorContentService)4 HashSet (java.util.HashSet)1 IStatus (org.eclipse.core.runtime.IStatus)1 CellLabelProvider (org.eclipse.jface.viewers.CellLabelProvider)1 CheckboxTreeViewer (org.eclipse.jface.viewers.CheckboxTreeViewer)1 ISelection (org.eclipse.jface.viewers.ISelection)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1 Viewer (org.eclipse.jface.viewers.Viewer)1 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)1 Composite (org.eclipse.swt.widgets.Composite)1 TreeItem (org.eclipse.swt.widgets.TreeItem)1 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)1 NavigatorContentService (org.eclipse.ui.internal.navigator.NavigatorContentService)1 NavigatorContentExtension (org.eclipse.ui.internal.navigator.extensions.NavigatorContentExtension)1 CommonDropAdapterAssistant (org.eclipse.ui.navigator.CommonDropAdapterAssistant)1 CommonNavigator (org.eclipse.ui.navigator.CommonNavigator)1 CommonViewer (org.eclipse.ui.navigator.CommonViewer)1 ICommonFilterDescriptor (org.eclipse.ui.navigator.ICommonFilterDescriptor)1 ICommonLabelProvider (org.eclipse.ui.navigator.ICommonLabelProvider)1