Search in sources :

Example 1 with ILabelProvider

use of org.eclipse.jface.viewers.ILabelProvider in project translationstudio8 by heartsome.

the class WorkingSetSorter method compare.

public int compare(Viewer viewer, Object e1, Object e2) {
    if (viewer instanceof StructuredViewer) {
        ILabelProvider labelProvider = (ILabelProvider) ((StructuredViewer) viewer).getLabelProvider();
        String text1 = labelProvider.getText(e1);
        String text2 = labelProvider.getText(e2);
        if (text1 != null) {
            return text1.compareTo(text2);
        }
    }
    return -1;
}
Also used : StructuredViewer(org.eclipse.jface.viewers.StructuredViewer) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider)

Example 2 with ILabelProvider

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

the class BusinessModelingAssistantProvider method selectElement.

/**
     * @generated NOT
     */
protected EObject selectElement(EObject[] elements) {
    Shell shell = Display.getCurrent().getActiveShell();
    ILabelProvider labelProvider = new AdapterFactoryLabelProvider(BusinessDiagramEditorPlugin.getInstance().getItemProvidersAdapterFactory());
    ElementListSelectionDialog dialog = new ElementListSelectionDialog(shell, labelProvider);
    //$NON-NLS-1$
    dialog.setMessage(Messages.getString("BusinessModelingAssistantProvider.AvaiableDomainModelElements"));
    //$NON-NLS-1$
    dialog.setTitle(Messages.getString("BusinessModelingAssistantProvider.SelectDomainModelElement"));
    dialog.setMultipleSelection(false);
    dialog.setElements(elements);
    EObject selected = null;
    if (dialog.open() == Window.OK) {
        selected = (EObject) dialog.getFirstResult();
    }
    return selected;
}
Also used : Shell(org.eclipse.swt.widgets.Shell) ElementListSelectionDialog(org.eclipse.ui.dialogs.ElementListSelectionDialog) EObject(org.eclipse.emf.ecore.EObject) AdapterFactoryLabelProvider(org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider)

Example 3 with ILabelProvider

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

the class AddResourceAction method run.

/**
     * Prompts for a jar to add.
     * 
     * @see IAction#run()
     */
@Override
public void run() {
    // ViewerFilter filter = new ArchiveFilter(getSelectedJars());
    ILabelProvider lp = new WorkbenchLabelProvider();
    ITreeContentProvider cp = new WorkbenchContentProvider();
    ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(getShell(), lp, cp);
    dialog.setValidator(validator);
    //$NON-NLS-1$
    dialog.setTitle(Messages.getString("AddResourceAction.JARSecection"));
    //$NON-NLS-1$
    dialog.setMessage(Messages.getString("AddResourceAction.ChooseResource"));
    dialog.setInput(ResourcesPlugin.getWorkspace().getRoot().getProject(PluginConstant.COMPONENT_PROJECT));
    dialog.setComparator(new ResourceComparator(ResourceComparator.NAME));
    if (dialog.open() == Window.OK) {
        Object[] elements = dialog.getResult();
        List<ILibEntry> res = new ArrayList<ILibEntry>();
        for (int i = 0; i < elements.length; i++) {
            IResource elem = (IResource) elements[i];
            String name = elem.getName();
            if (name.matches("(?i).*\\.(jar)\\b")) {
                //$NON-NLS-1$
                res.add(new JarLibEntry(elem));
            }
            if (name.matches("(?i).*\\.(pm)\\b")) {
                //$NON-NLS-1$
                res.add(new PmLibEntry(elem));
            }
        }
        if (res.size() > 0) {
            ILibEntry[] entries = new ILibEntry[res.size()];
            getViewer().addEntries(res.toArray(entries));
        }
    }
}
Also used : ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) ResourceComparator(org.eclipse.ui.views.navigator.ResourceComparator) WorkbenchLabelProvider(org.eclipse.ui.model.WorkbenchLabelProvider) JarLibEntry(org.talend.componentdesigner.model.libentry.JarLibEntry) ArrayList(java.util.ArrayList) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider) WorkbenchContentProvider(org.eclipse.ui.model.WorkbenchContentProvider) ElementTreeSelectionDialog(org.eclipse.ui.dialogs.ElementTreeSelectionDialog) ILibEntry(org.talend.componentdesigner.model.ILibEntry) PmLibEntry(org.talend.componentdesigner.model.libentry.PmLibEntry) IResource(org.eclipse.core.resources.IResource)

Example 4 with ILabelProvider

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

the class JobHierarchyViewPart method updateMethodViewer.

private void updateMethodViewer(final IProcess2 input) {
    if (input == dependencyViewer.getInput()) {
        if (input != null) {
            Runnable runnable = new Runnable() {

                public void run() {
                    // refresh
                    dependencyViewer.refresh();
                }
            };
            BusyIndicator.showWhile(getDisplay(), runnable);
        }
    } else {
        if (input != null) {
            ILabelProvider provider = (ILabelProvider) getCurrentViewer().getLabelProvider();
            dependencyViewerPaneLabel.setText(provider.getText(input));
            dependencyViewerPaneLabel.setImage(provider.getImage(input));
        } else {
            //$NON-NLS-1$
            dependencyViewerPaneLabel.setText("");
            dependencyViewerPaneLabel.setImage(null);
        }
        Runnable runnable = new Runnable() {

            public void run() {
                // refresh
                dependencyViewer.setInput(input);
            }
        };
        BusyIndicator.showWhile(getDisplay(), runnable);
    }
}
Also used : ILabelProvider(org.eclipse.jface.viewers.ILabelProvider)

Example 5 with ILabelProvider

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

the class TOSLoginComposite method createTosActionArea.

private void createTosActionArea(Composite parent) {
    tosActionComposite = toolkit.createComposite(parent);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.heightHint = 140;
    tosActionComposite.setLayoutData(gd);
    tosActionComposite.setLayout(new FormLayout());
    tosActionComposite.setBackgroundMode(SWT.INHERIT_DEFAULT);
    // tosActionComposite.setBackground(GREY_COLOR);
    FormData data;
    Label projectLabel = toolkit.createLabel(tosActionComposite, Messages.getString("TOSLoginComposite.projectLabel"));
    projectLabel.setFont(font);
    GC gc = new GC(projectLabel);
    Point labelSize = gc.stringExtent(Messages.getString("TOSLoginComposite.projectLabel"));
    gc.dispose();
    data = new FormData();
    data.top = new FormAttachment(0, 10);
    data.left = new FormAttachment(0, 50);
    // data.right = new FormAttachment(0, 20 + labelSize.x);
    data.bottom = new FormAttachment(0, 30);
    projectLabel.setBackground(tosActionComposite.getBackground());
    projectLabel.setLayoutData(data);
    openButton = toolkit.createButton(tosActionComposite, null, SWT.PUSH);
    data = new FormData();
    data.top = new FormAttachment(projectLabel, 0, SWT.TOP);
    gc = new GC(openButton);
    Point labelSizeOpenButton = gc.stringExtent(Messages.getString("TOSLoginComposite.openButton"));
    gc.dispose();
    int width = OPEN_IMAGE.getBounds().width;
    gc = new GC(openButton);
    Point labelSizeDeleteButton = gc.stringExtent(Messages.getString("TOSLoginComposite.deleteButton"));
    gc.dispose();
    if (labelSizeOpenButton.x + width > labelSizeDeleteButton.x) {
        data.left = new FormAttachment(100, -20 - labelSizeOpenButton.x - width - 10);
    } else {
        data.left = new FormAttachment(100, -20 - labelSizeDeleteButton.x - 10);
    }
    data.right = new FormAttachment(100, -10);
    // if (Platform.getOS().equals(Platform.OS_WIN32)) {
    // data.bottom = new FormAttachment(projectLabel, 0, SWT.BOTTOM);
    // } else if (Platform.getOS().equals(Platform.OS_LINUX)) {
    // data.bottom = new FormAttachment(projectLabel, 5, SWT.BOTTOM);
    // } else {
    // data.bottom = new FormAttachment(projectLabel, 5, SWT.BOTTOM);
    // }
    openButton.setText(Messages.getString("TOSLoginComposite.openButton"));
    openButton.setFont(font);
    openButton.setLayoutData(data);
    openButton.setImage(OPEN_IMAGE);
    Composite projectListViewerContainer = new Composite(tosActionComposite, SWT.NONE);
    projectListViewerContainer.setLayout(new FillLayout());
    this.projectListViewer = new ListViewer(projectListViewerContainer);
    this.projectListViewer.setContentProvider(new TableViewerContentProvider());
    this.projectListViewer.setLabelProvider(new ILabelProvider() {

        @Override
        public void removeListener(ILabelProviderListener listener) {
        }

        @Override
        public boolean isLabelProperty(Object element, String property) {
            return false;
        }

        @Override
        public void dispose() {
        }

        @Override
        public void addListener(ILabelProviderListener listener) {
        }

        @Override
        public String getText(Object element) {
            if (element != null) {
                return element.toString();
            }
            return null;
        }

        @Override
        public Image getImage(Object element) {
            return null;
        }
    });
    this.projectListViewer.setSorter(new ViewerSorter());
    data = new FormData();
    data.top = new FormAttachment(projectLabel, 0, SWT.TOP);
    data.left = new FormAttachment(projectLabel, 10, SWT.RIGHT);
    data.right = new FormAttachment(openButton, -10, SWT.LEFT);
    data.bottom = new FormAttachment(0, 100);
    projectListViewerContainer.setLayoutData(data);
    deleteButton = toolkit.createButton(tosActionComposite, null, SWT.PUSH);
    data = new FormData();
    data.top = new FormAttachment(openButton, 5, SWT.BOTTOM);
    data.left = new FormAttachment(openButton, 0, SWT.LEFT);
    data.right = new FormAttachment(openButton, 0, SWT.RIGHT);
    deleteButton.setText(Messages.getString("TOSLoginComposite.deleteButton"));
    deleteButton.setFont(font);
    deleteButton.setLayoutData(data);
    createButton = toolkit.createButton(tosActionComposite, null, SWT.PUSH);
    data = new FormData();
    data.top = new FormAttachment(projectListViewerContainer, 10, SWT.BOTTOM);
    data.left = new FormAttachment(projectListViewerContainer, 0, SWT.LEFT);
    data.right = new FormAttachment(projectListViewerContainer, 65, SWT.LEFT);
    createButton.setText(Messages.getString("TOSLoginComposite.createButton"));
    createButton.setFont(font);
    createButton.setLayoutData(data);
    importButton = toolkit.createButton(tosActionComposite, null, SWT.PUSH);
    data = new FormData();
    data.top = new FormAttachment(createButton, 0, SWT.TOP);
    data.left = new FormAttachment(createButton, 10, SWT.RIGHT);
    importButton.setText(Messages.getString("TOSLoginComposite.importButton"));
    importButton.setFont(font);
    importButton.setLayoutData(data);
    demoProjectButton = toolkit.createButton(tosActionComposite, null, SWT.PUSH);
    data = new FormData();
    data.top = new FormAttachment(importButton, 0, SWT.TOP);
    data.left = new FormAttachment(importButton, 10, SWT.RIGHT);
    data.right = new FormAttachment(100, -10);
    demoProjectButton.setText(Messages.getString("TOSLoginComposite.demoProjectButton"));
    demoProjectButton.setFont(font);
    demoProjectButton.setLayoutData(data);
    enableOpenAndDelete(false);
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) ListViewer(org.eclipse.jface.viewers.ListViewer) Composite(org.eclipse.swt.widgets.Composite) Label(org.eclipse.swt.widgets.Label) ViewerSorter(org.eclipse.jface.viewers.ViewerSorter) Point(org.eclipse.swt.graphics.Point) FillLayout(org.eclipse.swt.layout.FillLayout) ILabelProvider(org.eclipse.jface.viewers.ILabelProvider) Image(org.eclipse.swt.graphics.Image) Point(org.eclipse.swt.graphics.Point) ILabelProviderListener(org.eclipse.jface.viewers.ILabelProviderListener) GridData(org.eclipse.swt.layout.GridData) GC(org.eclipse.swt.graphics.GC) TableViewerContentProvider(org.talend.metadata.managment.ui.model.TableViewerContentProvider) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Aggregations

ILabelProvider (org.eclipse.jface.viewers.ILabelProvider)5 ArrayList (java.util.ArrayList)1 IResource (org.eclipse.core.resources.IResource)1 EObject (org.eclipse.emf.ecore.EObject)1 AdapterFactoryLabelProvider (org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider)1 ILabelProviderListener (org.eclipse.jface.viewers.ILabelProviderListener)1 ITreeContentProvider (org.eclipse.jface.viewers.ITreeContentProvider)1 ListViewer (org.eclipse.jface.viewers.ListViewer)1 StructuredViewer (org.eclipse.jface.viewers.StructuredViewer)1 ViewerSorter (org.eclipse.jface.viewers.ViewerSorter)1 GC (org.eclipse.swt.graphics.GC)1 Image (org.eclipse.swt.graphics.Image)1 Point (org.eclipse.swt.graphics.Point)1 FillLayout (org.eclipse.swt.layout.FillLayout)1 FormAttachment (org.eclipse.swt.layout.FormAttachment)1 FormData (org.eclipse.swt.layout.FormData)1 FormLayout (org.eclipse.swt.layout.FormLayout)1 GridData (org.eclipse.swt.layout.GridData)1 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1