Search in sources :

Example 1 with TalendPaletteLabelProvider

use of org.talend.core.ui.component.preference.provider.TalendPaletteLabelProvider in project tdi-studio-se by Talend.

the class PaletteSettingPage method addTreeViewer.

/**
     * qwei Comment method "addViewer".
     * 
     * @param parent
     */
private void addTreeViewer(ThreeCompositesSashForm parent) {
    ViewerSorter sorter = new ViewerSorter() {

        /*
             * (non-Javadoc)
             * 
             * @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer,
             * java.lang.Object, java.lang.Object)
             */
        @Override
        public int compare(Viewer viewer, Object e1, Object e2) {
            if (e1 instanceof ComponentPaletteItem && e2 instanceof ComponentPaletteItem) {
                return super.compare(viewer, ((IPaletteItem) e1).getLabel(), ((IPaletteItem) e2).getLabel());
            } else if (e1 instanceof FolderPaletteItem && e2 instanceof FolderPaletteItem) {
                return super.compare(viewer, ((IPaletteItem) e1).getLabel(), ((IPaletteItem) e2).getLabel());
            } else if (e1 instanceof ComponentPaletteItem && e2 instanceof FolderPaletteItem) {
                return 1;
            } else if (e1 instanceof FolderPaletteItem && e2 instanceof ComponentPaletteItem) {
                return -1;
            } else if (e1 instanceof RootPaletteItem && e2 instanceof RootPaletteItem) {
                if (((IPaletteItem) e1).getPaletteType() == ComponentCategory.CATEGORY_4_DI) {
                    // up
                    return -1;
                } else if (((IPaletteItem) e2).getPaletteType() == ComponentCategory.CATEGORY_4_DI) {
                    // down
                    return 1;
                } else if (((IPaletteItem) e1).getPaletteType() == ComponentCategory.CATEGORY_4_CAMEL && ((IPaletteItem) e2).getPaletteType() == ComponentCategory.CATEGORY_4_MAPREDUCE) {
                    // up
                    return -1;
                } else if (((IPaletteItem) e1).getPaletteType() == ComponentCategory.CATEGORY_4_MAPREDUCE && ((IPaletteItem) e2).getPaletteType() == ComponentCategory.CATEGORY_4_CAMEL) {
                    // down
                    return 1;
                } else if (((IPaletteItem) e1).getPaletteType() == ComponentCategory.CATEGORY_4_MAPREDUCE && ((IPaletteItem) e2).getPaletteType() == ComponentCategory.CATEGORY_4_STORM) {
                    // up
                    return -1;
                } else if (((IPaletteItem) e1).getPaletteType() == ComponentCategory.CATEGORY_4_STORM && ((IPaletteItem) e2).getPaletteType() == ComponentCategory.CATEGORY_4_MAPREDUCE) {
                    // down
                    return 1;
                } else if (((IPaletteItem) e1).getPaletteType() == ComponentCategory.CATEGORY_4_CAMEL && ((IPaletteItem) e2).getPaletteType() == ComponentCategory.CATEGORY_4_STORM) {
                    // up
                    return -1;
                } else if (((IPaletteItem) e1).getPaletteType() == ComponentCategory.CATEGORY_4_STORM && ((IPaletteItem) e2).getPaletteType() == ComponentCategory.CATEGORY_4_CAMEL) {
                    // down
                    return 1;
                }
            }
            return super.compare(viewer, e1, e2);
        }
    };
    List<IPaletteItem> input = getViewerInput();
    Composite leftComposite = parent.getLeftComposite();
    Label label = new Label(leftComposite, SWT.NONE);
    label.setText("Hide");
    hiddenViewer = new TreeViewer(leftComposite);
    hiddenViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
    hiddenViewer.setContentProvider(new TalendPaletteTreeProvider());
    hiddenViewer.setLabelProvider(new TalendPaletteLabelProvider());
    hiddenViewer.addFilter(getFilterForComponent(false));
    hiddenViewer.setSorter(sorter);
    hiddenViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            displayComponentsButton.setEnabled(!event.getSelection().isEmpty());
        }
    });
    createButtons(parent.getMidComposite());
    Composite rightComposite = parent.getRightComposite();
    label = new Label(rightComposite, SWT.NONE);
    label.setText("Show");
    displayViewer = new TreeViewer(rightComposite);
    displayViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
    displayViewer.setContentProvider(new TalendPaletteTreeProvider());
    displayViewer.setLabelProvider(new TalendPaletteLabelProvider());
    displayViewer.addFilter(getFilterForComponent(true));
    displayViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            hideCompnentsButton.setEnabled(!event.getSelection().isEmpty());
        }
    });
    displayViewer.setSorter(sorter);
    getComponentsFromProject(project);
    hiddenViewer.setInput(input);
    displayViewer.setInput(input);
    if (!input.isEmpty()) {
        displayViewer.expandToLevel(input.get(0), 1);
    }
    if (!input.isEmpty()) {
        hiddenViewer.expandToLevel(input.get(0), 1);
    }
}
Also used : ComponentPaletteItem(org.talend.repository.preference.palettesettings.ComponentPaletteItem) Composite(org.eclipse.swt.widgets.Composite) IPaletteItem(org.talend.core.ui.component.preference.provider.IPaletteItem) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) ViewerSorter(org.eclipse.jface.viewers.ViewerSorter) Label(org.eclipse.swt.widgets.Label) TreeViewer(org.eclipse.jface.viewers.TreeViewer) Viewer(org.eclipse.jface.viewers.Viewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) FolderPaletteItem(org.talend.repository.preference.palettesettings.FolderPaletteItem) TalendPaletteTreeProvider(org.talend.core.ui.component.preference.provider.TalendPaletteTreeProvider) RootPaletteItem(org.talend.repository.preference.palettesettings.RootPaletteItem) GridData(org.eclipse.swt.layout.GridData) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) TalendPaletteLabelProvider(org.talend.core.ui.component.preference.provider.TalendPaletteLabelProvider)

Example 2 with TalendPaletteLabelProvider

use of org.talend.core.ui.component.preference.provider.TalendPaletteLabelProvider in project tdi-studio-se by Talend.

the class PaletteSettingsDialog method addTreeViewer.

/**
     * qwei Comment method "addViewer".
     * 
     * @param parent
     */
private void addTreeViewer(ThreeCompositesSashForm parent) {
    hiddenViewer = new TreeViewer(parent.getLeftComposite());
    hiddenViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
    hiddenViewer.setContentProvider(new TalendPaletteTreeProvider());
    hiddenViewer.setLabelProvider(new TalendPaletteLabelProvider());
    hiddenViewer.addFilter(getFilterForComponent(false));
    hiddenViewer.expandToLevel(2);
    hiddenViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            rightButton.setEnabled(!event.getSelection().isEmpty());
        }
    });
    createButtons(parent.getMidComposite());
    displayViewer = new TreeViewer(parent.getRightComposite());
    displayViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
    displayViewer.setContentProvider(new TalendPaletteTreeProvider());
    displayViewer.setLabelProvider(new TalendPaletteLabelProvider());
    displayViewer.addFilter(getFilterForComponent(true));
    displayViewer.expandToLevel(2);
    displayViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            leftButton.setEnabled(!event.getSelection().isEmpty());
        }
    });
    PaletteRoot input = getViewerInput();
    hiddenViewer.setInput(input);
    displayViewer.setInput(input);
}
Also used : PaletteRoot(org.eclipse.gef.palette.PaletteRoot) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) GridData(org.eclipse.swt.layout.GridData) TalendPaletteLabelProvider(org.talend.core.ui.component.preference.provider.TalendPaletteLabelProvider) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) TalendPaletteTreeProvider(org.talend.core.ui.component.preference.provider.TalendPaletteTreeProvider)

Aggregations

ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)2 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)2 TreeViewer (org.eclipse.jface.viewers.TreeViewer)2 GridData (org.eclipse.swt.layout.GridData)2 TalendPaletteLabelProvider (org.talend.core.ui.component.preference.provider.TalendPaletteLabelProvider)2 TalendPaletteTreeProvider (org.talend.core.ui.component.preference.provider.TalendPaletteTreeProvider)2 PaletteRoot (org.eclipse.gef.palette.PaletteRoot)1 Viewer (org.eclipse.jface.viewers.Viewer)1 ViewerSorter (org.eclipse.jface.viewers.ViewerSorter)1 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)1 IPaletteItem (org.talend.core.ui.component.preference.provider.IPaletteItem)1 ComponentPaletteItem (org.talend.repository.preference.palettesettings.ComponentPaletteItem)1 FolderPaletteItem (org.talend.repository.preference.palettesettings.FolderPaletteItem)1 RootPaletteItem (org.talend.repository.preference.palettesettings.RootPaletteItem)1