Example usage for org.eclipse.jface.viewers BaseLabelProvider BaseLabelProvider

List of usage examples for org.eclipse.jface.viewers BaseLabelProvider BaseLabelProvider

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers BaseLabelProvider BaseLabelProvider.

Prototype

BaseLabelProvider

Source Link

Usage

From source file:org.eclipse.eatop.examples.explorer.properties.ExpandedTransactionalAdvancedPropertySection.java

License:Open Source License

protected ResourceSetListenerImpl createSelectedObjectChangedListener(Object selectedObject) {
    Assert.isNotNull(selectedObject);// www  .  j  av  a 2s.co  m

    return new ResourceSetListenerImpl(NotificationFilter.createNotifierFilter(selectedObject)) {
        /*
         * @see org.eclipse.emf.transaction.ResourceSetListenerImpl#resourceSetChanged(ResourceSetChangeEvent)
         */
        @Override
        public void resourceSetChanged(ResourceSetChangeEvent event) {
            if (tabbedPropertySheetPage != null) {
                IPageSite site = tabbedPropertySheetPage.getSite();
                if (site != null) {
                    site.getShell().getDisplay().asyncExec(new Runnable() {
                        @Override
                        public void run() {
                            // Refresh property section content
                            if (pages.size() > 0) {
                                refresh();
                                // Refresh property sheet title through this indirect call to private
                                // TabbedPropertySheetPage#refreshTitleBar() method
                                tabbedPropertySheetPage.labelProviderChanged(
                                        new LabelProviderChangedEvent(new BaseLabelProvider()));
                            }

                        }
                    });
                }
            }
        }
    };
}

From source file:org.eclipse.gef4.cloudio.tests.TagCloudViewerTests.java

License:Open Source License

@Test(expected = IllegalArgumentException.class)
public void testInvalidLabelProvider2() {
    TagCloudViewer viewer = new TagCloudViewer(cloud);
    viewer.setLabelProvider(new BaseLabelProvider());
}

From source file:org.eclipse.wst.server.ui.internal.viewers.ModuleArtifactComposite.java

License:Open Source License

private void createContent(Composite parent) {
    Composite contentComposite = new Composite(parent, SWT.NONE | SWT.RESIZE);
    GridLayout layout = new GridLayout();
    layout.marginWidth = 10;/*from   w  w  w. j  av  a2 s  .  c  om*/
    layout.verticalSpacing = 5;
    layout.numColumns = 1;

    GridData data = new GridData(GridData.FILL_BOTH);

    contentComposite.setLayout(layout);
    contentComposite.setLayoutData(data);
    contentComposite.setFont(parent.getFont());

    Label tableTitle = new Label(contentComposite, SWT.None);
    tableTitle.setText(Messages.wizModuleArtifactsAvailableList);

    listViewer = new ListViewer(contentComposite, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    data = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL);
    listViewer.getList().setLayoutData(data);
    listViewer.getList().setFocus();

    listViewer.setContentProvider(new BaseContentProvider() {
        public Object[] getElements(Object inputElement) {
            return moduleArtifacts;
        }
    });

    listViewer.setLabelProvider(new BaseLabelProvider() {
        public String getText(Object element) {
            if (element instanceof ModuleArtifactDelegate) {
                // Try to display the object using its name 
                ModuleArtifactDelegate moduleArtifact = (ModuleArtifactDelegate) element;
                String artifactName = moduleArtifact.getName();
                if (artifactName != null && artifactName.length() >= 0) {
                    int classNameIndex = artifactName.lastIndexOf(".");
                    String packageName = artifactName.substring(0, classNameIndex);
                    String className = artifactName.substring(classNameIndex + 1);
                    if (packageName != null && (packageName.length() <= 0) == false) {
                        return className + " (" + moduleArtifact.getName() + ")";
                    }
                    return moduleArtifact.getName();
                }

                // If the name is empty we can then use the module artifact class name  
                return moduleArtifact.getClass().getName();
            }
            return Messages.elementUnknownName;
        }
    });

    listViewer.addDoubleClickListener(new IDoubleClickListener() {
        public void doubleClick(DoubleClickEvent event) {
            buttonPressed(IDialogConstants.OK_ID);
        }
    });

    listViewer.setInput(AbstractTreeContentProvider.ROOT);
}