Search in sources :

Example 21 with LabelProvider

use of org.eclipse.jface.viewers.LabelProvider in project tdi-studio-se by Talend.

the class SaveChartSetAsDialog method createChartSetViewer.

/**
     * Creates the chart set viewer.
     * 
     * @param parent The parent composite
     * @return The chart set viewer
     */
private TableViewer createChartSetViewer(Composite parent) {
    TableViewer viewer = new TableViewer(parent, SWT.BORDER | SWT.FULL_SELECTION);
    GridData gridData = new GridData(GridData.FILL_BOTH);
    gridData.heightHint = 300;
    viewer.getTable().setLayoutData(gridData);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new LabelProvider());
    viewer.setInput(chartSets.toArray(new String[chartSets.size()]));
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            if (ignoreSelection) {
                return;
            }
            ISelection selection = event.getSelection();
            if (selection instanceof StructuredSelection) {
                Object element = ((StructuredSelection) selection).getFirstElement();
                if (element != null) {
                    chartSetText.setText(element.toString());
                    deleteButton.setEnabled(true);
                }
            }
        }
    });
    return viewer;
}
Also used : ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) ISelection(org.eclipse.jface.viewers.ISelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) TableViewer(org.eclipse.jface.viewers.TableViewer) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Example 22 with LabelProvider

use of org.eclipse.jface.viewers.LabelProvider in project tdi-studio-se by Talend.

the class SelectDeleteProjectDialog method createTreeViewer.

private void createTreeViewer(Composite parent) {
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginWidth = 0;
    layout.makeColumnsEqualWidth = false;
    parent.setLayout(layout);
    parent.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH));
    GridData listData = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH);
    treeViewer = new ContainerCheckedTreeViewer(parent);
    treeViewer.getControl().setLayoutData(listData);
    // treeViewer.setContentProvider(getResourceProvider(IResource.FOLDER | IResource.PROJECT));
    treeViewer.setContentProvider(getResourceProvider(IResource.PROJECT));
    // treeViewer.setLabelProvider(WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider());
    treeViewer.setLabelProvider(new LabelProvider() {

        @Override
        public final String getText(Object element) {
            // query the element for its label
            //$NON-NLS-1$
            String label = "";
            if (element instanceof IProject) {
                IProject project = (IProject) element;
                label = getLabel(project.getName());
            } else if (element instanceof IFolder) {
                IFolder folder = (IFolder) element;
                label = getLabel(folder.getName());
            }
            return label;
        }

        private String getLabel(String name) {
            List<Project> proItem = getProjectItem();
            for (int i = 0; i < proItem.size(); i++) {
                Project p = proItem.get(i);
                String proName = p.getTechnicalLabel();
                if (proName.equals(name)) {
                    return ProjectManager.getProjectDisplayLabel(p.getEmfProject());
                }
            }
            return name;
        }

        @Override
        public final Image getImage(Object element) {
            if (element instanceof IProject) {
                return ImageProvider.getImage(ERepositoryImages.PROJECT_ICON);
            } else if (element instanceof IFolder) {
                return ImageProvider.getImage(ERepositoryImages.FOLDER_ICON);
            }
            return null;
        }
    });
    treeViewer.setInput(projectItemList);
    treeViewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
    addTreeListener();
    createButtons(parent);
}
Also used : IProject(org.eclipse.core.resources.IProject) Project(org.talend.core.model.general.Project) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) ContainerCheckedTreeViewer(org.eclipse.ui.dialogs.ContainerCheckedTreeViewer) ArrayList(java.util.ArrayList) List(java.util.List) Image(org.eclipse.swt.graphics.Image) LabelProvider(org.eclipse.jface.viewers.LabelProvider) IProject(org.eclipse.core.resources.IProject) IFolder(org.eclipse.core.resources.IFolder)

Example 23 with LabelProvider

use of org.eclipse.jface.viewers.LabelProvider in project tdi-studio-se by Talend.

the class ImportItemWizardPage method createTreeViewer.

private TreeViewer createTreeViewer(Composite listComposite) {
    filteredCheckboxTree = new FilteredCheckboxTree(listComposite, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI);
    CheckboxTreeViewer viewer = filteredCheckboxTree.getViewer();
    viewer.setContentProvider(new ITreeContentProvider() {

        @Override
        public Object[] getChildren(Object parentElement) {
            if (parentElement instanceof IContainerNode) {
                return ((IContainerNode) parentElement).getChildren().toArray();
            }
            return null;
        }

        @Override
        public Object[] getElements(Object inputElement) {
            // return getValidItems();
            return repositoryUtil.getTreeViewInput().toArray();
        }

        @Override
        public boolean hasChildren(Object element) {
            if (element instanceof IContainerNode) {
                return ((IContainerNode) element).hasChildren();
            }
            return false;
        }

        @Override
        public Object getParent(Object element) {
            return null;
        }

        @Override
        public void dispose() {
        }

        @Override
        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }
    });
    viewer.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            if (element instanceof IContainerNode) {
                if (element instanceof ProjectNode) {
                    Project project = ((ProjectNode) element).getProject();
                    return ProjectManager.getProjectDisplayLabel(project);
                }
                return ((IContainerNode) element).getLabel();
            } else if (element instanceof ItemRecord) {
                return ((ItemRecord) element).getLabel();
            }
            return super.getText(element);
        }

        @Override
        public Image getImage(Object element) {
            if (element instanceof IContainerNode) {
                return ((IContainerNode) element).getImage();
            } else if (element instanceof ItemRecord) {
                return ((ItemRecord) element).getImage();
            }
            return super.getImage(element);
        }
    });
    viewer.setSorter(TreeBuilder.createSorter());
    viewer.setInput(this);
    viewer.addCheckStateListener(new ICheckStateListener() {

        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            filteredCheckboxTree.calculateCheckedLeafNodes();
            updateFinishStatus();
        }
    });
    filteredCheckboxTree.getViewer().addFilter(new ViewerFilter() {

        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            return selectRepositoryNode(viewer, element);
        }
    });
    return viewer;
}
Also used : ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) FilteredCheckboxTree(org.talend.core.ui.advanced.composite.FilteredCheckboxTree) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) TableViewer(org.eclipse.jface.viewers.TableViewer) TreeViewer(org.eclipse.jface.viewers.TreeViewer) Viewer(org.eclipse.jface.viewers.Viewer) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) Image(org.eclipse.swt.graphics.Image) IContainerNode(org.talend.repository.imports.TreeBuilder.IContainerNode) CheckboxTreeViewer(org.eclipse.jface.viewers.CheckboxTreeViewer) Project(org.talend.core.model.properties.Project) RepositoryViewObject(org.talend.core.model.repository.RepositoryViewObject) ProjectNode(org.talend.repository.imports.TreeBuilder.ProjectNode) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Example 24 with LabelProvider

use of org.eclipse.jface.viewers.LabelProvider in project bndtools by bndtools.

the class RunFrameworkPart method createSection.

final void createSection(Section section, FormToolkit tk) {
    section.setText("Core Runtime");
    Composite composite = tk.createComposite(section);
    section.setClient(composite);
    Label lblFramework = new Label(composite, SWT.NONE);
    tk.adapt(lblFramework, true, true);
    lblFramework.setText("OSGi Framework:");
    cmbFramework = new Combo(composite, SWT.DROP_DOWN);
    tk.adapt(cmbFramework);
    tk.paintBordersFor(cmbFramework);
    cmbFramework.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
    frameworkViewer = new ComboViewer(cmbFramework);
    frameworkViewer.setUseHashlookup(true);
    frameworkViewer.setContentProvider(fwkContentProvider);
    Label lblExecEnv = tk.createLabel(composite, "Execution Env.:");
    cmbExecEnv = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
    ControlDecoration eeDecor = new ControlDecoration(cmbExecEnv, SWT.LEFT | SWT.TOP, composite);
    eeDecor.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage());
    eeDecor.setDescriptionText("The runtime Java Virtual Machine will be required/assumed " + "\nto support this Execution Environment");
    eeViewer = new ComboViewer(cmbExecEnv);
    eeViewer.setContentProvider(ArrayContentProvider.getInstance());
    eeViewer.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            return ((EE) element).getEEName();
        }
    });
    eeViewer.setInput(EE.values());
    // Listeners
    cmbFramework.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            lock.ifNotModifying(new Runnable() {

                @Override
                public void run() {
                    markDirty();
                    selectedFramework = cmbFramework.getText();
                }
            });
        }
    });
    frameworkViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            lock.ifNotModifying(new Runnable() {

                @Override
                public void run() {
                    Object element = ((IStructuredSelection) frameworkViewer.getSelection()).getFirstElement();
                    if (element instanceof LoadingContentElement) {
                        return;
                    }
                    markDirty();
                    if (element == null)
                        selectedFramework = null;
                    else
                        selectedFramework = element.toString();
                }
            });
        }
    });
    eeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            lock.ifNotModifying(new Runnable() {

                @Override
                public void run() {
                    markDirty();
                    selectedEE = (EE) ((IStructuredSelection) event.getSelection()).getFirstElement();
                }
            });
        }
    });
    GridLayout layout = new GridLayout(2, false);
    layout.horizontalSpacing = 10;
    composite.setLayout(layout);
    lblFramework.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
    GridData gd;
    gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
    gd.widthHint = 20;
    gd.heightHint = 20;
    cmbFramework.setLayoutData(gd);
    lblExecEnv.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
    gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
    gd.widthHint = 20;
    gd.heightHint = 20;
    cmbExecEnv.setLayoutData(gd);
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) LoadingContentElement(bndtools.model.repo.LoadingContentElement) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ModifyEvent(org.eclipse.swt.events.ModifyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) ComboViewer(org.eclipse.jface.viewers.ComboViewer) GridData(org.eclipse.swt.layout.GridData) ControlDecoration(org.eclipse.jface.fieldassist.ControlDecoration) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Example 25 with LabelProvider

use of org.eclipse.jface.viewers.LabelProvider in project bndtools by bndtools.

the class NewDSComponentWizardPage method createLifecycleMethodStubControls.

protected void createLifecycleMethodStubControls(Composite composite, int nColumns) {
    fLifecycleMethodDialogField.doFillIntoGrid(composite, nColumns - 1);
    DialogField.createEmptySpace(composite);
    Combo cmbActivateStub = fLifecycleMethodDialogField.getComboControl(composite);
    vwrActivateStub = new ComboViewer(cmbActivateStub);
    vwrActivateStub.setContentProvider(ArrayContentProvider.getInstance());
    vwrActivateStub.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            return ((ActivateSignature) element).label;
        }
    });
    vwrActivateStub.setInput(EnumSet.allOf(ActivateSignature.class));
    vwrActivateStub.setSelection(new StructuredSelection(activateSignature), true);
    vwrActivateStub.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            ISelection sel = event.getSelection();
            if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
                activateSignature = (ActivateSignature) ((IStructuredSelection) sel).getFirstElement();
            } else {
                activateSignature = ActivateSignature.NoActivate;
            }
            activateSignatureStatus = activateSignatureChanged();
            handleFieldChanged("activateSignature");
        }
    });
}
Also used : ComboViewer(org.eclipse.jface.viewers.ComboViewer) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ISelection(org.eclipse.jface.viewers.ISelection) Combo(org.eclipse.swt.widgets.Combo) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Aggregations

LabelProvider (org.eclipse.jface.viewers.LabelProvider)25 GridData (org.eclipse.swt.layout.GridData)17 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)12 GridLayout (org.eclipse.swt.layout.GridLayout)11 Composite (org.eclipse.swt.widgets.Composite)11 ComboViewer (org.eclipse.jface.viewers.ComboViewer)10 SelectionEvent (org.eclipse.swt.events.SelectionEvent)10 Label (org.eclipse.swt.widgets.Label)10 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)8 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)7 Button (org.eclipse.swt.widgets.Button)7 Combo (org.eclipse.swt.widgets.Combo)7 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)6 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)6 Text (org.eclipse.swt.widgets.Text)6 ArrayList (java.util.ArrayList)5 ISelection (org.eclipse.jface.viewers.ISelection)5 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)5 Image (org.eclipse.swt.graphics.Image)5 List (java.util.List)4