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

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

Introduction

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

Prototype

public LabelProvider() 

Source Link

Document

Creates a new label provider.

Usage

From source file:com.nokia.sdt.series60.component.ChoiceListTextEditorFactory.java

License:Open Source License

@Override
public ILabelProvider createElementLabelProvider(EObject object, Object propertyID) {
    return new LabelProvider() {
        @Override/* www  .j  av a2 s.  c  o m*/
        public String getText(Object element) {
            String result = null;
            if (element instanceof IPropertySource) {
                IPropertySource ps = (IPropertySource) element;
                result = ps.getPropertyValue(SETTING_ITEM_TEXT_PROPERTY).toString();
            } else {
                result = super.getText(element);
            }
            if (result != null) {
                result = TextUtils.escape(result, QUOTE_CHAR);
            }
            return result;
        }
    };
}

From source file:com.nokia.sdt.series60.component.LayoutConfigEditorFactory.java

License:Open Source License

@Override
public ILabelProvider createLabelProvider(final EObject object, String propertyId) {
    if (labelProvider == null) {
        initDisplayModel(object);//from w  w w.  j  av a 2 s . c  om
        labelProvider = new LabelProvider() {
            public String getText(Object element) {
                String text = VARIABLE;
                LayoutAreaConfiguration config = null;
                if (element instanceof String) {
                    config = getConfigFromId((String) element);
                }
                if (config != null)
                    text = config.getDisplayName();

                return text;
            }
        };
    }

    return labelProvider;
}

From source file:com.nokia.sdt.series60.component.listCustomizer.ListCustomizerComposite.java

License:Open Source License

/**
 * @param parent/*from   w w  w .  ja  va 2 s  . c  o  m*/
 * @param style
 * @param instance 
 */
public ListCustomizerComposite(Composite parent, int style, EObject instance) {
    super(parent, style);
    IComponentInstance componentInstance = (IComponentInstance) EcoreUtil.getRegisteredAdapter(instance,
            IComponentInstance.class);
    component = componentInstance.getComponent();

    String[] styles = ListLayoutData.getComponentListBoxStyles(component);
    initData(styles);

    getThumbnailViewer().addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            if (!selection.isEmpty()) {
                ThumbData thumbData = dataMap.get(selection.getFirstElement());
                getDescriptionText().setText(thumbData.description);
                theValue = thumbData.value;
            }
        }
    });
    getThumbnailViewer().setContentProvider(new ArrayContentProvider());
    getThumbnailViewer().setLabelProvider(new LabelProvider() {
        public Image getImage(Object element) {
            ThumbData data = dataMap.get(element.toString());
            return data.image;
        }

        public String getText(Object element) {
            ThumbData data = dataMap.get(element.toString());
            return data.caption;
        }
    });
    getThumbnailViewer().setInput(dataMap.keySet());
    getThumbnailViewer().getComposite().setFocus();

    setViewerTitle(Messages.getString("ListCustomizerComposite.ViewerTitle")); //$NON-NLS-1$
    setDescriptionTitle(Messages.getString("ListCustomizerComposite.DescriptionTitle")); //$NON-NLS-1$
}

From source file:com.nokia.sdt.series60.component.MultiLineQueryTypeEditorFactory.java

License:Open Source License

public CellEditor createCellEditor(Composite parent, EObject object, String propertyId) {
    return new ModelObjectComboBoxCellEditor(parent, getValues(object, propertyId), new LabelProvider() {
        public String getText(Object element) {
            String string = "MultiLineQueryTypeEditorFactory."; //$NON-NLS-1$
            string += element;//from  w ww . jav a2 s  .  co m
            return Messages.getString(string);
        }
    });
}

From source file:com.nokia.sdt.symbian.ui.appeditor.LanguagesPage.java

License:Open Source License

protected void createFormContent(IManagedForm managedForm) {
    FormToolkit toolkit = managedForm.getToolkit();
    final ScrolledForm form = managedForm.getForm();
    form.setText(Messages.getString("LanguagesPage.2")); //$NON-NLS-1$
    Composite body = form.getBody();
    body.setLayout(new TableWrapLayout());
    toolkit.paintBordersFor(body);//from   w ww .  j a va 2s.  c  o  m
    String href = null;

    SymbianModelUtils.SDKType sdkType = SymbianModelUtils.getModelSDK(editorContext.getRootDataModel());
    switch (sdkType) {
    case S60:
        href = "/com.nokia.sdt.uidesigner.help/html/reference/app_editor/ref_languages.htm";//$NON-NLS-1$
        break;
    case UIQ:
        href = "/com.nokia.carbide.cpp.uiq.help/html/reference/app_editor/ref_languages.htm";//$NON-NLS-1$
        break;
    }

    FormUtilities.addHelpToolbarItem(form.getForm(), href, Messages.getString("LanguagesPage.4")); //$NON-NLS-1$

    Section includedLanguagesSection = toolkit.createSection(body, Section.DESCRIPTION | Section.TITLE_BAR);
    includedLanguagesSectionPart = new SectionPart(includedLanguagesSection);
    managedForm.addPart(includedLanguagesSectionPart);

    final TableWrapData tableWrapData_1 = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP);
    tableWrapData_1.heightHint = 294;
    tableWrapData_1.grabHorizontal = true;
    includedLanguagesSection.setLayoutData(tableWrapData_1);
    includedLanguagesSection.setDescription(Messages.getString("LanguagesPage.5")); //$NON-NLS-1$
    includedLanguagesSection.setText(Messages.getString("LanguagesPage.6")); //$NON-NLS-1$

    final Composite composite = toolkit.createComposite(includedLanguagesSection, SWT.NONE);
    toolkit.adapt(composite);
    composite.setLayout(new FormLayout());
    includedLanguagesSection.setClient(composite);
    toolkit.paintBordersFor(composite);

    final Table table = toolkit.createTable(composite, SWT.CHECK);
    final FormData formData = new FormData();
    formData.bottom = new FormAttachment(100, -9);
    formData.left = new FormAttachment(0, 7);
    formData.right = new FormAttachment(0, 230);
    formData.top = new FormAttachment(0, 6);
    table.setLayoutData(formData);
    table.addKeyListener(new KeyAdapter() {
        public void keyPressed(KeyEvent e) {
            if (e.character == SWT.DEL) {
                removeLanguage();
            }
        }
    });

    viewer = new CheckboxTableViewer(table);
    viewer.addCheckStateListener(new ICheckStateListener() {
        public void checkStateChanged(CheckStateChangedEvent event) {
            SymbianLanguage language = (SymbianLanguage) event.getElement();
            if (viewer.getChecked(language)) {
                performSetDisplayLanguage(language);
            } else {
                // enforce radio-button-like behavior, keep one
                // item checked at all times.
                viewer.setChecked(language, true);
            }
        }
    });
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new LabelProvider());
    viewer.setSorter(new ViewerSorter() {
        @Override
        public int compare(Viewer viewer, Object e1, Object e2) {
            SymbianLanguage l1 = (SymbianLanguage) e1;
            SymbianLanguage l2 = (SymbianLanguage) e2;
            return l1.code - l2.code;
        }
    });
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            updateButtons();
        }
    });

    final Composite composite_1 = toolkit.createComposite(composite, SWT.NONE);
    toolkit.adapt(composite_1);
    final RowLayout rowLayout_1 = new RowLayout(SWT.VERTICAL);
    rowLayout_1.justify = true;
    rowLayout_1.fill = true;
    composite_1.setLayout(rowLayout_1);
    final FormData formData_1 = new FormData();
    formData_1.bottom = new FormAttachment(0, 70);
    formData_1.top = new FormAttachment(0, 6);
    formData_1.right = new FormAttachment(0, 295);
    formData_1.left = new FormAttachment(table, 5, SWT.DEFAULT);
    composite_1.setLayoutData(formData_1);
    toolkit.paintBordersFor(composite_1);

    addButton = toolkit.createButton(composite_1, Messages.getString("LanguagesPage.8"), SWT.NONE); //$NON-NLS-1$
    addButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            addLanguages();
        }
    });

    removeButton = toolkit.createButton(composite_1, Messages.getString("LanguagesPage.removeButton.text"), //$NON-NLS-1$
            SWT.NONE);
    removeButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            removeLanguage();
        }
    });

    Section localizationFormatSection = toolkit.createSection(body, Section.DESCRIPTION | Section.TITLE_BAR);
    localizationFormatSectionPart = new SectionPart(localizationFormatSection);
    localizationFormatSection.setDescription(Messages.getString("LanguagesPage.10")); //$NON-NLS-1$
    final TableWrapData tableWrapData_2 = new TableWrapData(TableWrapData.FILL, TableWrapData.TOP);
    tableWrapData_2.heightHint = 89;
    tableWrapData_2.grabHorizontal = true;
    localizationFormatSection.setLayoutData(tableWrapData_2);
    localizationFormatSection.setText(Messages.getString("LanguagesPage.11")); //$NON-NLS-1$

    final Composite composite_2 = toolkit.createComposite(localizationFormatSection, SWT.NONE);
    final RowLayout rowLayout = new RowLayout(SWT.VERTICAL);
    rowLayout.marginTop = 8;
    composite_2.setLayout(rowLayout);
    toolkit.paintBordersFor(composite_2);
    localizationFormatSection.setClient(composite_2);

    dotLocButton = toolkit.createButton(composite_2, Messages.getString("LanguagesPage.13"), SWT.RADIO); //$NON-NLS-1$
    dotLocButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            if (dotLocButton.getSelection()) {
                performSetLocalizationFormat(SymbianModelUtils.LocalizationFileFormat.LOC);
            }
        }
    });

    dotRlsButton = toolkit.createButton(composite_2, Messages.getString("LanguagesPage.12"), SWT.RADIO); //$NON-NLS-1$
    dotRlsButton.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            if (dotRlsButton.getSelection()) {
                performSetLocalizationFormat(SymbianModelUtils.LocalizationFileFormat.RLS);
            }
        }
    });

    refresh();
}

From source file:com.nokia.sdt.symbian.ui.appeditor.ViewMasterDetailsBlock.java

License:Open Source License

private void importViews() {
    String message = Messages.getString("ViewMasterDetailsBlock.importDesignsPrompt"); //$NON-NLS-1$
    IDesignerDataModelSpecifier importableModels[] = model.getImportableModels();
    ListSelectionDialog dialog = new ListSelectionDialog(editorContext.getEditorSite().getShell(),
            importableModels, new ArrayContentProvider(), new LabelProvider(), message);
    dialog.setTitle(Messages.getString("ViewMasterDetailsBlock.importDesignsDialogTitle")); //$NON-NLS-1$
    int dlgResult = dialog.open();
    if (dlgResult == ListSelectionDialog.OK) {
        Object[] entriesToImport = dialog.getResult();
        if (entriesToImport != null) {

            CompoundCommand cc = new CompoundCommand();
            cc.setLabel(Messages.getString("ViewMasterDetailsBlock.importUndoLabel")); //$NON-NLS-1$
            for (int i = 0; i < entriesToImport.length; i++) {
                IDesignerDataModelSpecifier specifier = (IDesignerDataModelSpecifier) entriesToImport[i];
                Command emfCommand = SymbianModelUtils.addViewReference(editorContext.getRootDataModel(),
                        specifier);/*from w  ww .ja va  2 s.c  o  m*/
                if (emfCommand != null) {
                    cc.append(emfCommand);
                }
            }
            // Wrap the command as a GEF command, and the editing context for undo
            StructuredSelection selection = new StructuredSelection(entriesToImport);
            FormEditorEditingContext editingContext = new FormEditorEditingContext(null,
                    editorContext.getFormEditor(), selection);
            EditingContextCommand wrappedCommand = new EditingContextCommand(cc, true, editingContext);
            editorContext.addAndExecuteCommand(wrappedCommand);
        }
    }
}

From source file:com.nokia.sdt.symbian.ui.editors.MinusOneIntEditorFactory.java

License:Open Source License

public ILabelProvider createLabelProvider(EObject object, String propertyPath) {
    return new LabelProvider() {
        public Image getImage(Object element) {
            return TypeDescriptors.getImage(TypeDescriptors.INTEGER_IMAGE);
        }/*from  w  ww  .  java2 s.c o  m*/

        public String getText(Object element) {
            if (element instanceof Integer) {
                Integer integer = (Integer) element;
                int plusOneVal = integer.intValue() + 1;
                return "" + plusOneVal; //$NON-NLS-1$
            }

            return "" + element; //$NON-NLS-1$
        }
    };
}

From source file:com.nokia.sdt.symbian.ui.editors.ReadOnlySummaryEditorFactory.java

License:Open Source License

public ILabelProvider createLabelProvider(EObject obj, String propertyId) {
    return new LabelProvider() {

        public String getText(Object element) {
            String result = null;
            if (element instanceof IPropertySource) {
                result = summarizePropertySource((IPropertySource) element);
            } else if (element != null) {
                result = element.toString();
            }/* www . ja va  2  s . c o m*/
            return result;
        }

    };
}

From source file:com.nokia.tools.screen.ui.propertysheet.tabbed.AdvancedPropertyDescriptor.java

License:Open Source License

@Override
public ILabelProvider getLabelProvider() {
    if (value instanceof Rectangle) {
        return new LabelProvider() {
            public String getText(Object element) {
                Rectangle rect = (Rectangle) element;
                StringBuffer sbuf = new StringBuffer();
                sbuf.append(rect.x);//  www . j  a v  a2 s  . com
                sbuf.append(',');
                sbuf.append(rect.y);
                sbuf.append(',');
                sbuf.append(rect.width);
                sbuf.append(',');
                sbuf.append(rect.height);
                return sbuf.toString();
            }
        };
    }
    return super.getLabelProvider();
}

From source file:com.nokia.tools.theme.s60.editing.providers.realtime.RealTimeTreeDataProvider.java

License:Open Source License

public ILabelProvider getTreeLabelProvider() {
    return new LabelProvider() {

        public String getText(Object element) {
            if (element instanceof ILayer) {
                return ((ILayer) element).getName();
            }/*from w  ww.java  2s . c  o  m*/
            if (element instanceof ILayerEffect) {
                return ((ILayerEffect) element).getName();
            }
            return "BAD!";
        }
    };
}