List of usage examples for org.eclipse.jface.viewers LabelProvider LabelProvider
public LabelProvider()
From source file:com.nokia.carbide.cpp.internal.project.ui.mmpEditor.MissingSourcesSectionPart.java
License:Open Source License
private void createClient(Section section, FormToolkit toolkit) { section.setText(Messages.MissingSourcesSectionPart_missingSourcesSectionTitle); section.setDescription(Messages.MissingSourcesSectionPart_missingSourcesDescription); Composite container = toolkit.createComposite(section); toolkit.paintBordersFor(container);/*w w w. j av a 2 s . c om*/ container.setLayout(new FormLayout()); // section.setClient(container); final Composite buttonComposite = toolkit.createComposite(container, SWT.NONE); final RowLayout rowLayout = new RowLayout(SWT.VERTICAL); rowLayout.fill = true; rowLayout.wrap = false; rowLayout.marginRight = 1; rowLayout.marginLeft = 1; buttonComposite.setLayout(rowLayout); final FormData formData = new FormData(); formData.bottom = new FormAttachment(100, -5); formData.right = new FormAttachment(100, 0); formData.top = new FormAttachment(0, 0); buttonComposite.setLayoutData(formData); removeButton = toolkit.createButton(buttonComposite, Messages.MissingSourcesSectionPart_removeButton, SWT.NONE); removeButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { removeButtonPressed(); } }); tableViewer = new TableViewer(container, SWT.MULTI); tableViewer.setContentProvider(new ArrayContentProvider()); tableViewer.setLabelProvider(new LabelProvider()); Table table = tableViewer.getTable(); toolkit.adapt(table); final FormData formData_1 = new FormData(); formData_1.bottom = new FormAttachment(100, -9); formData_1.right = new FormAttachment(buttonComposite, -5, SWT.LEFT); formData_1.top = new FormAttachment(0, 3); formData_1.left = new FormAttachment(0, 5); table.setLayoutData(formData_1); toolkit.adapt(table, true, true); tableViewer.setInput(new Object()); table.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.character == SWT.DEL) { removeButtonPressed(); } } }); }
From source file:com.nokia.carbide.cpp.internal.project.ui.mmpEditor.OverviewPage.java
License:Open Source License
/** * Create contents of the form/*from w w w . j a v a 2 s . c om*/ * @param managedForm */ @Override protected void createFormContent(IManagedForm managedForm) { FormToolkit toolkit = managedForm.getToolkit(); ScrolledForm form = managedForm.getForm(); form.setText(Messages.OverviewPage_overviewFormTitle); Composite body = form.getBody(); final TableWrapLayout tableWrapLayout_2 = new TableWrapLayout(); tableWrapLayout_2.rightMargin = 20; tableWrapLayout_2.verticalSpacing = 8; tableWrapLayout_2.numColumns = 2; body.setLayout(tableWrapLayout_2); toolkit.paintBordersFor(body); FormUtilities.addHelpContextToolbarItem(form.getForm(), HelpContexts.OVERVIEW_PAGE, Messages.helpTooltip); FormText formText; formText = toolkit.createFormText(body, false); final TableWrapData tableWrapData_1 = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP); tableWrapData_1.colspan = 2; formText.setLayoutData(tableWrapData_1); formText.setText(Messages.OverviewPage_editorExplanation + Messages.OverviewPage_editorExplanation2 + Messages.OverviewPage_editorExplanation3, false, false); activeBuildInfoComposite = toolkit.createComposite(body, SWT.NONE); final RowLayout rowLayout = new RowLayout(); rowLayout.fill = true; rowLayout.wrap = false; rowLayout.marginLeft = 20; activeBuildInfoComposite.setLayout(rowLayout); final TableWrapData tableWrapData_2 = new TableWrapData(TableWrapData.FILL, TableWrapData.TOP); tableWrapData_2.maxWidth = 288; tableWrapData_2.colspan = 2; activeBuildInfoComposite.setLayoutData(tableWrapData_2); toolkit.paintBordersFor(activeBuildInfoComposite); final Label buildConfigStaticLabel = toolkit.createLabel(activeBuildInfoComposite, Messages.OverviewPage_activeBuildConfigLabel, SWT.NONE); buildConfigStaticLabel.setLocation(27, 10); buildConfigStaticLabel.setFont(SWTResourceManager.getFont("Arial", 8, SWT.BOLD)); //$NON-NLS-1$ activeBuildConfigLabel = toolkit.createLabel(activeBuildInfoComposite, "", SWT.NONE); //$NON-NLS-1$ activeBuildConfigLabel.setToolTipText(Messages.OverviewPage_activeBuildConfigTooltip); activeBuildConfigLabel.setLocation(10, 10); final Section targetInformationSection = toolkit.createSection(body, Section.DESCRIPTION | Section.TITLE_BAR); final TableWrapData tableWrapData_3 = new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP); tableWrapData_3.maxWidth = 250; tableWrapData_3.heightHint = 150; targetInformationSection.setLayoutData(tableWrapData_3); targetInformationSection.setDescription(Messages.OverviewPage_targetInfoDescription); targetInformationSection.setText(Messages.OverviewPage_targetInfoTitle); final Composite composite = toolkit.createComposite(targetInformationSection, SWT.NONE); final GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 2; composite.setLayout(gridLayout); toolkit.adapt(composite); targetInformationSection.setClient(composite); toolkit.paintBordersFor(composite); targetNameLabel = toolkit.createLabel(composite, Messages.OverviewPage_targetNameLabel, SWT.NONE); targetNameText = toolkit.createText(composite, null); targetNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); targetNameText.setToolTipText(Messages.OverviewPage_targetTooltip); toolkit.createLabel(composite, Messages.OverviewPage_targetTypeLabel, SWT.NONE); targetTypeViewer = new ComboViewer(composite, SWT.READ_ONLY); targetTypeViewer.setContentProvider(new ArrayContentProvider()); targetTypeViewer.setLabelProvider(new LabelProvider()); targetTypeViewer.setSorter(new ViewerSorter()); targetTypeViewer.setInput(new Object()); Combo targetTypeCombo = targetTypeViewer.getCombo(); targetTypeCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); targetTypeCombo.setToolTipText(Messages.OverviewPage_targetTypeTooltip); toolkit.adapt(targetTypeCombo, true, true); targetPathLabel = toolkit.createLabel(composite, Messages.OverviewPage_targetPathLabel, SWT.NONE); // set default layout data so we have the exclude flag available later targetPathLabel.setLayoutData(new GridData()); targetPathText = toolkit.createText(composite, null); targetPathText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); targetPathText.setToolTipText(Messages.OverviewPage_targetPathTooltip); uid2Label = toolkit.createLabel(composite, Messages.OverviewPage_uid2Label, SWT.NONE); uid2Text = toolkit.createText(composite, null); uid2Text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); uid2Text.setToolTipText(Messages.OverviewPage_uid2Tooltip); uid3Label = toolkit.createLabel(composite, Messages.OverviewPage_uid3Label, SWT.NONE); uid3Text = toolkit.createText(composite, null); uid3Text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); uid3Text.setToolTipText(Messages.OverviewPage_uid3Tooltip); final Section projectDefinitionSection = toolkit.createSection(body, Section.TITLE_BAR); final TableWrapData tableWrapData_4 = new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP); tableWrapData_4.grabHorizontal = true; tableWrapData_4.heightHint = 140; tableWrapData_4.maxWidth = 276; projectDefinitionSection.setLayoutData(tableWrapData_4); projectDefinitionSection.setText(Messages.OverviewPage_projectDefSectionTitle); final Composite composite_1 = toolkit.createComposite(projectDefinitionSection, SWT.NONE); final TableWrapLayout tableWrapLayout_1 = new TableWrapLayout(); tableWrapLayout_1.numColumns = 2; composite_1.setLayout(tableWrapLayout_1); toolkit.paintBordersFor(composite_1); projectDefinitionSection.setClient(composite_1); sourceFilesImageHyperlink = toolkit.createImageHyperlink(composite_1, SWT.NONE); sourceFilesImageHyperlink .setImage(ResourceManager.getPluginImage(ProjectUIPlugin.getDefault(), "icons/pencil.png")); //$NON-NLS-1$ sourceFilesImageHyperlink.setText(Messages.OverviewPage_sourcesLinkTitle); sourceFilesImageHyperlink.addHyperlinkListener(new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { editorContext.editor.setActivePage(MMPEditorContext.SOURCES_PAGE_ID); } }); toolkit.createLabel(composite_1, Messages.OverviewPage_sourcesLinkDescription, SWT.WRAP); librariesImageHyperlink = toolkit.createImageHyperlink(composite_1, SWT.NONE); librariesImageHyperlink .setImage(ResourceManager.getPluginImage(ProjectUIPlugin.getDefault(), "icons/pencil.png")); //$NON-NLS-1$ librariesImageHyperlink.setText(Messages.OverviewPage_libsLinktitle); librariesImageHyperlink.addHyperlinkListener(new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { editorContext.editor.setActivePage(MMPEditorContext.LIBRARIES_PAGE_ID); } }); toolkit.createLabel(composite_1, Messages.OverviewPage_libsLinkDescription, SWT.WRAP); optionsImageHyperlink = toolkit.createImageHyperlink(composite_1, SWT.NONE); optionsImageHyperlink .setImage(ResourceManager.getPluginImage(ProjectUIPlugin.getDefault(), "icons/pencil.png")); //$NON-NLS-1$ optionsImageHyperlink.setText(Messages.OverviewPage_optionsLinkTitle); optionsImageHyperlink.addHyperlinkListener(new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { editorContext.editor.setActivePage(MMPEditorContext.OPTIONS_PAGE_ID); } }); toolkit.createLabel(composite_1, Messages.OverviewPage_optionsLinkDescription, SWT.WRAP); final Section commonTasksSection = toolkit.createSection(body, Section.TITLE_BAR); final TableWrapData tableWrapData_5 = new TableWrapData(TableWrapData.FILL_GRAB, TableWrapData.TOP); tableWrapData_5.maxWidth = 250; commonTasksSection.setLayoutData(tableWrapData_5); commonTasksSection.setText(Messages.OverviewPage_commonTasksTitle); final Composite composite_2 = toolkit.createComposite(commonTasksSection, SWT.NONE); composite_2.setLayout(new FormLayout()); toolkit.paintBordersFor(composite_2); commonTasksSection.setClient(composite_2); addAUserHyperlink = toolkit.createHyperlink(composite_2, Messages.OverviewPage_addUserPathLink, SWT.NONE); final FormData formData_6 = new FormData(); formData_6.top = new FormAttachment(0, 5); formData_6.left = new FormAttachment(0, 5); addAUserHyperlink.setLayoutData(formData_6); addAUserHyperlink.addHyperlinkListener(new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { doAddInclude(EMMPListSelector.USER_INCLUDES); } }); addASystemHyperlink = toolkit.createHyperlink(composite_2, Messages.OverviewPage_addSysPathLink, SWT.NONE); final FormData formData_7 = new FormData(); formData_7.top = new FormAttachment(addAUserHyperlink, 5, SWT.BOTTOM); formData_7.left = new FormAttachment(addAUserHyperlink, 0, SWT.LEFT); addASystemHyperlink.setLayoutData(formData_7); addASystemHyperlink.addHyperlinkListener(new HyperlinkAdapter() { public void linkActivated(HyperlinkEvent e) { doAddInclude(EMMPListSelector.SYS_INCLUDES); } }); hookControls(); }
From source file:com.nokia.carbide.cpp.internal.project.ui.mmpEditor.RuntimeSectionPart.java
License:Open Source License
/** * Fill the section//from w w w . j av a2 s .c o m */ private void createClient(Section section, FormToolkit toolkit) { section.setText(Messages.RuntimeSectionPart_runtimeSectionTitle); Composite container = toolkit.createComposite(section); toolkit.paintBordersFor(container); final FormLayout formLayout = new FormLayout(); formLayout.marginHeight = 2; formLayout.marginWidth = 2; container.setLayout(formLayout); // section.setClient(container); capabilitiesLabel = toolkit.createLabel(container, Messages.RuntimeSectionPart_capabilitiesLabel, SWT.NONE); final FormData formData = new FormData(); formData.right = new FormAttachment(0, 70); formData.top = new FormAttachment(0, 5); formData.bottom = new FormAttachment(0, 25); capabilitiesLabel.setLayoutData(formData); capabilitiesText = toolkit.createText(container, null, SWT.V_SCROLL | SWT.WRAP); capabilitiesText.setToolTipText(Messages.RuntimeSectionPart_editCapabilitiesTooltip); final FormData formData_1 = new FormData(); formData_1.right = new FormAttachment(0, 245); formData_1.left = new FormAttachment(capabilitiesLabel, 0, SWT.LEFT); capabilitiesText.setLayoutData(formData_1); chooseButton = toolkit.createButton(container, Messages.RuntimeSectionPart_chooseCapabilitiesBtn, SWT.NONE); formData_1.bottom = new FormAttachment(chooseButton, 37, SWT.BOTTOM); formData_1.top = new FormAttachment(chooseButton, 5, SWT.DEFAULT); chooseButton.setToolTipText(Messages.RuntimeSectionPart_chooseCapabilitiesTooltip); final FormData formData_2 = new FormData(); formData_2.bottom = new FormAttachment(capabilitiesLabel, 23, SWT.TOP); formData_2.top = new FormAttachment(capabilitiesLabel, 0, SWT.TOP); formData_2.left = new FormAttachment(0, 130); formData_2.right = new FormAttachment(capabilitiesText, 0, SWT.RIGHT); chooseButton.setLayoutData(formData_2); chooseButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { doChooseCapabilities(); } }); minHeapSizeLabel = toolkit.createLabel(container, Messages.RuntimeSectionPart_minHeapLabel, SWT.NONE); final FormData formData_3 = new FormData(); formData_3.top = new FormAttachment(capabilitiesText, 10, SWT.DEFAULT); formData_3.right = new FormAttachment(0, 130); formData_3.left = new FormAttachment(0, 7); minHeapSizeLabel.setLayoutData(formData_3); minHeapSizeText = toolkit.createText(container, null, SWT.NONE); minHeapSizeText.setToolTipText(Messages.RuntimeSectionPart_minHeapTooltip); final FormData formData_4 = new FormData(); formData_4.top = new FormAttachment(minHeapSizeLabel, -2, SWT.TOP); formData_4.right = new FormAttachment(capabilitiesText, 0, SWT.RIGHT); minHeapSizeText.setLayoutData(formData_4); maxHeapSizeLabel = toolkit.createLabel(container, Messages.RuntimeSectionPart_maxHeapLabel, SWT.NONE); formData_4.left = new FormAttachment(maxHeapSizeLabel, 5, SWT.RIGHT); final FormData formData_5 = new FormData(); formData_5.top = new FormAttachment(minHeapSizeLabel, 12, SWT.DEFAULT); formData_5.right = new FormAttachment(minHeapSizeLabel, 0, SWT.RIGHT); formData_5.left = new FormAttachment(minHeapSizeLabel, 0, SWT.LEFT); maxHeapSizeLabel.setLayoutData(formData_5); maxHeapSizeText = toolkit.createText(container, null, SWT.NONE); maxHeapSizeText.setToolTipText(Messages.RuntimeSectionPart_maxHeapTooltip); final FormData formData_6 = new FormData(); formData_6.left = new FormAttachment(minHeapSizeText, 0, SWT.LEFT); formData_6.top = new FormAttachment(maxHeapSizeLabel, 0, SWT.TOP); formData_6.right = new FormAttachment(minHeapSizeText, 0, SWT.RIGHT); maxHeapSizeText.setLayoutData(formData_6); stackSizeLabel = toolkit.createLabel(container, Messages.RuntimeSectionPart_stackSizeLabel, SWT.NONE); final FormData formData_7 = new FormData(); formData_7.top = new FormAttachment(0, 125); formData_7.right = new FormAttachment(maxHeapSizeLabel, 0, SWT.RIGHT); formData_7.left = new FormAttachment(maxHeapSizeLabel, 0, SWT.LEFT); stackSizeLabel.setLayoutData(formData_7); stackSizeText = toolkit.createText(container, null, SWT.NONE); stackSizeText.setToolTipText(Messages.RuntimeSectionPart_stackSizeTooltip); final FormData formData_8 = new FormData(); formData_8.left = new FormAttachment(maxHeapSizeText, 0, SWT.LEFT); formData_8.top = new FormAttachment(stackSizeLabel, 0, SWT.TOP); formData_8.right = new FormAttachment(maxHeapSizeText, 0, SWT.RIGHT); stackSizeText.setLayoutData(formData_8); Label processPriorityLabel; processPriorityLabel = toolkit.createLabel(container, Messages.RuntimeSectionPart_processPriorityLabel, SWT.NONE); final FormData formData_9 = new FormData(); formData_9.right = new FormAttachment(stackSizeLabel, 83, SWT.LEFT); formData_9.left = new FormAttachment(stackSizeLabel, 0, SWT.LEFT); processPriorityLabel.setLayoutData(formData_9); processPriorityViewer = new ComboViewer(container, SWT.READ_ONLY | SWT.FLAT); processPriorityViewer.setContentProvider(new ArrayContentProvider()); processPriorityViewer.setLabelProvider(new ProcessPriorityLabelProvider()); processPriorityViewer.setInput(PROCESS_PRIORITIES); Combo processPriorityCombo; processPriorityCombo = processPriorityViewer.getCombo(); formData_9.top = new FormAttachment(processPriorityCombo, -18, SWT.TOP); formData_9.bottom = new FormAttachment(processPriorityCombo, -5, SWT.TOP); processPriorityCombo.setToolTipText(Messages.RuntimeSectionPart_processPriorityTooltip); final FormData formData_10 = new FormData(); formData_10.top = new FormAttachment(0, 164); formData_10.bottom = new FormAttachment(0, 185); formData_10.right = new FormAttachment(stackSizeText, 0, SWT.RIGHT); formData_10.left = new FormAttachment(processPriorityLabel, 0, SWT.LEFT); processPriorityCombo.setLayoutData(formData_10); toolkit.adapt(processPriorityCombo, true, true); secureIDLabel = toolkit.createLabel(container, Messages.RuntimeSectionPart_secureIDLabel, SWT.NONE); final FormData formData_11 = new FormData(); formData_11.top = new FormAttachment(0, 200); formData_11.left = new FormAttachment(processPriorityCombo, 0, SWT.LEFT); secureIDLabel.setLayoutData(formData_11); toolkit.adapt(secureIDLabel, true, true); secureIDText = toolkit.createText(container, null, SWT.NONE); secureIDText.setToolTipText(Messages.RuntimeSectionPart_secureIDTooltip); final FormData formData_12 = new FormData(); formData_12.top = new FormAttachment(secureIDLabel, 0, SWT.TOP); formData_12.right = new FormAttachment(processPriorityCombo, 0, SWT.RIGHT); formData_12.left = new FormAttachment(stackSizeText, 0, SWT.LEFT); secureIDText.setLayoutData(formData_12); vendorIDLabel = toolkit.createLabel(container, Messages.RuntimeSectionPart_vendorIDLabel, SWT.NONE); formData.left = new FormAttachment(vendorIDLabel, 0, SWT.LEFT); FormData formData_13; formData_13 = new FormData(); formData_13.top = new FormAttachment(0, 230); formData_13.right = new FormAttachment(secureIDLabel, 54, SWT.LEFT); formData_13.left = new FormAttachment(secureIDLabel, 0, SWT.LEFT); vendorIDLabel.setLayoutData(formData_13); vendorIDText = toolkit.createText(container, null, SWT.NONE); vendorIDText.setToolTipText(Messages.RuntimeSectionPart_vendorIDTooltip); final FormData formData_14 = new FormData(); formData_14.top = new FormAttachment(vendorIDLabel, 0, SWT.TOP); formData_14.left = new FormAttachment(secureIDText, 0, SWT.LEFT); formData_14.right = new FormAttachment(secureIDText, 0, SWT.RIGHT); vendorIDText.setLayoutData(formData_14); debuggableButton = toolkit.createButton(container, Messages.RuntimeSectionPart_debuggableButton, SWT.CHECK); debuggableButton.setToolTipText(Messages.RuntimeSectionPart_debuggableToolTip); final FormData formData_15 = new FormData(); formData_15.top = new FormAttachment(0, 260); formData_15.left = new FormAttachment(vendorIDLabel, 0, SWT.LEFT); debuggableButton.setLayoutData(formData_15); Label demandPagingLabel; demandPagingLabel = toolkit.createLabel(container, Messages.RuntimeSectionPart_pagingModeLabel, SWT.NONE); final FormData formData_16 = new FormData(); formData_16.left = new FormAttachment(stackSizeLabel, 0, SWT.LEFT); demandPagingLabel.setLayoutData(formData_16); pagingModeViewer = new ComboViewer(container, SWT.READ_ONLY | SWT.FLAT); pagingModeViewer.setContentProvider(new ArrayContentProvider()); pagingModeViewer.setLabelProvider(new LabelProvider()); pagingModeViewer.setInput(PAGING_MODE_VALUES); Combo pagingModeCombo; pagingModeCombo = pagingModeViewer.getCombo(); formData_16.top = new FormAttachment(pagingModeCombo, -18, SWT.TOP); formData_16.bottom = new FormAttachment(pagingModeCombo, -5, SWT.TOP); pagingModeCombo.setToolTipText(Messages.RuntimeSectionPart_pagingModeToolTip); final FormData formData_17 = new FormData(); formData_17.top = new FormAttachment(0, 300); formData_17.bottom = new FormAttachment(0, 320); formData_17.right = new FormAttachment(stackSizeText, 0, SWT.RIGHT); formData_17.left = new FormAttachment(demandPagingLabel, 0, SWT.LEFT); pagingModeCombo.setLayoutData(formData_17); toolkit.adapt(pagingModeCombo, true, true); hookControls(); refresh(); }
From source file:com.nokia.carbide.cpp.uiq.component.layoutManager.LayoutManagerSelectorEditorFactory.java
License:Open Source License
public ILabelProvider createLabelProvider(final EObject object, String propertyId) { return labelProvider = new LabelProvider() { public String getText(Object element) { if ((element == null) || (element.toString().length() == 0)) return ""; //$NON-NLS-1$ else { if (element instanceof IPropertySource) { IPropertySource layoutManagerProperty = (IPropertySource) element; if (layoutManagerProperty.getPropertyValue("type") != null) return (String) layoutManagerProperty.getPropertyValue("type"); else return ""; } else if (element instanceof IComponent) { // System.out.println("***labelProvider***getFriendlyName()"); return ((IComponent) element).getFriendlyName(); } else { return element.toString(); }/*www .ja v a 2 s . c om*/ } } }; }
From source file:com.nokia.carbide.cpp.uiq.components.sbbCustomizer.SBBCustomizerComposite.java
License:Open Source License
/** * @param parent/*from w w w . j ava2 s . c o m*/ * @param style * @param instance */ public SBBCustomizerComposite(Composite parent, int style, EObject instance) { super(parent, style); IComponentInstance componentInstance = (IComponentInstance) EcoreUtil.getRegisteredAdapter(instance, IComponentInstance.class); component = componentInstance.getComponent(); String[] styles = SBBLayoutData.getComponentSBBTypes(component); initData(styles); getThumbnailViewer().addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); if (!selection.isEmpty()) { String value = (String) selection.getFirstElement(); ThumbData thumbData = dataMap.get(value); getDescriptionText().setText(thumbData.description); selectedValue = thumbData; } } }); getThumbnailViewer().setContentProvider(new ArrayContentProvider()); getThumbnailViewer().setLabelProvider(new LabelProvider() { public Image getImage(Object element) { String value = (String) element; ThumbData thumbData = dataMap.get(value); return thumbData.image; } public String getText(Object element) { String value = (String) element; ThumbData thumbData = dataMap.get(value); return thumbData.caption; } }); getThumbnailViewer().setInput(dataMap.keySet()); getThumbnailViewer().getComposite().setFocus(); setViewerTitle(Messages.getString("SBBCustomizerComposite.ViewerTitle")); //$NON-NLS-1$ setDescriptionTitle(Messages.getString("SBBCustomizerComposite.DescriptionTitle")); //$NON-NLS-1$ }
From source file:com.nokia.carbide.cpp.uiq.components.sbbCustomizer.SBBLayoutEditorFactory.java
License:Open Source License
public ILabelProvider createLabelProvider(final EObject object, String propertyId) { return labelProvider = new LabelProvider() { public String getText(Object element) { if ((element == null) || (element.toString().length() == 0)) return ""; //$NON-NLS-1$ ensureData(object);/* w ww. j a v a2 s . c om*/ return data.valueToDisplayMap.get(element.toString()); } }; }
From source file:com.nokia.carbide.cpp.uiq.ui.viewwizard.InitialContentPage.java
License:Open Source License
public void createControl(Composite parent) { initializeDialogUnits(parent);//from w w w. j a v a 2 s . c om thumbnailComposite = new ThumbnailWithDescriptionComposite(parent, SWT.NULL); thumbnailComposite.setData(NAME_KEY, "thumbnailComposite"); //$NON-NLS-1$ setControl(thumbnailComposite); setHelpContextId(ViewWizardManager.INITIAL_CONTENT_PAGE); thumbnailComposite.getThumbnailViewer().addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); if (selection.isEmpty()) return; handleInitialContentChanged(selection.getFirstElement()); } }); thumbnailComposite.getThumbnailViewer().setContentProvider(new ArrayContentProvider()); thumbnailComposite.getThumbnailViewer().setLabelProvider(new LabelProvider() { Map<IComponent, Image> thumbnailMap = new HashMap<IComponent, Image>(); @Override public void dispose() { super.dispose(); for (Image image : thumbnailMap.values()) { image.dispose(); } } public Image getImage(Object element) { if (element.equals(NO_CONTENT_ELEMENT)) { return NO_CONTENT_TN; } Check.checkArg(element instanceof IComponent); IComponent component = (IComponent) element; Image image = thumbnailMap.get(component); if (image == null) { IDesignerImages images = (IDesignerImages) component.getAdapter(IDesignerImages.class); if (images != null) { image = images.getThumbnailImage(); image = ImageUtils.copyImage(getShell().getDisplay(), image); thumbnailMap.put(component, image); } } return image; } public String getText(Object element) { if (element.equals(NO_CONTENT_ELEMENT)) { return NO_CONTENT_NAME; } Check.checkArg(element instanceof IComponent); IComponent component = (IComponent) element; return component.getFriendlyName(); } }); thumbnailComposite.setViewerTitle(Messages.getString("InitialContentPage.ListPrompt")); //$NON-NLS-1$ thumbnailComposite.setDescriptionTitle(Messages.getString("InitialContentPage.DescriptionPrompt")); //$NON-NLS-1$ }
From source file:com.nokia.carbide.internal.api.templatewizard.ui.ChooseTemplatePage.java
License:Open Source License
public void createControl(Composite parent) { initializeDialogUnits(parent);//from w w w .j av a 2 s.co m Composite container = new Composite(parent, SWT.NONE); final GridLayout gridLayout = new GridLayout(); gridLayout.makeColumnsEqualWidth = true; container.setLayout(gridLayout); container.setData(UID_KEY, "ChooseTemplatePage"); //$NON-NLS-1$ container.setData("ChooseTemplatePage", this); //$NON-NLS-1$ setControl(container); final Label chooseTemplateLabel = new Label(container, SWT.NONE); chooseTemplateLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, true, false)); chooseTemplateLabel.setText(Messages.getString("ChooseTemplatePage.ChooseTemplateLabel")); //$NON-NLS-1$ final SashForm sashForm = new SashForm(container, SWT.VERTICAL); final GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, true); sashForm.setLayoutData(gridData); templateTreeViewer = new TreeViewer(sashForm, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); templateTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(final SelectionChangedEvent e) { handleTemplateSelectionChanged(); } }); templateTreeViewer.addDoubleClickListener(new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { handleTemplateSelectionChanged(); if (getSelectedLoadedTemplate() != null) getContainer().showPage(getNextPage()); } }); templateTreeViewer.setContentProvider(new TreeNodeContentProvider()); templateTreeViewer.setLabelProvider(new LabelProvider() { @Override public Image getImage(Object element) { Check.checkContract(element instanceof TreeNode); Object value = ((TreeNode) element).getValue(); if (value instanceof String) { if (folderImage == null) folderImage = TemplateWizardPlugin.getImageDescriptor(FOLDER_ICON).createImage(); return folderImage; } if (value instanceof ITemplate) { ITemplate template = (ITemplate) value; if (templateImages == null) templateImages = new HashMap<ITemplate, Image>(); if (!templateImages.containsKey(template)) { Image templateImage = null; ImageDescriptor imageDescriptor = template.getImageDescriptor(); if (imageDescriptor != null) templateImage = imageDescriptor.createImage(); templateImages.put(template, templateImage); } return templateImages.get(template); } return super.getImage(element); } @Override public String getText(Object element) { Check.checkContract(element instanceof TreeNode); Object value = ((TreeNode) element).getValue(); if (value instanceof String) { return value.toString(); } if (value instanceof ITemplate) { return ((ITemplate) value).getDisplayName(); } return ((TreeNode) element).getValue().toString(); } }); templateTreeViewer.getTree().setData(UID_KEY, "templateTree"); //$NON-NLS-1$ templateDescriptionText = new Text(sashForm, SWT.V_SCROLL | SWT.BORDER | SWT.WRAP); templateDescriptionText.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); templateDescriptionText.setEditable(false); templateDescriptionText.setData(UID_KEY, "templateDescription"); //$NON-NLS-1$ sashForm.setWeights(new int[] { 250, 100 }); filterCheckbox = new Button(container, SWT.CHECK); filterCheckbox.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, true, false)); filterCheckbox.setText(filterCheckboxLabel); filterCheckbox.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { initTreeViewer(false); } }); if (hideFilterCheckbox) { filterCheckbox.setVisible(false); } filterCheckbox.setSelection(!hideFilterCheckbox); filterCheckbox.setData(UID_KEY, "filterCheckbox"); //$NON-NLS-1$ String helpContextId = TemplateWizardPlugin.ID + ".choose_template_page"; //$NON-NLS-1$ PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), helpContextId); }
From source file:com.nokia.carbide.remoteconnections.internal.ui.ClientServiceSiteUI2.java
License:Open Source License
public void createComposite(Composite parent) { initializeDialogUnits(parent);// w w w.ja v a 2s .com Group group = new Group(parent, SWT.NONE); group.setText(Messages.getString("ClientServiceSiteUI2.UseConnectionGroupLabel")); //$NON-NLS-1$ group.setLayout(new GridLayout()); group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); group.setData(UID, "useConnectionGroup"); //$NON-NLS-1$ viewer = new ComboViewer(group, SWT.READ_ONLY); viewer.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { Check.checkContract(element instanceof String); String id = (String) element; return connectionNames.get(id); } }); viewer.setContentProvider(new ArrayContentProvider()); GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false); viewer.getCombo().setLayoutData(gd); viewer.getControl().setData(UID, "viewer"); //$NON-NLS-1$ viewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); String connection = (String) selection.getFirstElement(); if (connection != null && !connection.equals(ClientServiceSiteUI2.this.connection)) { ClientServiceSiteUI2.this.connection = connection; fireConnectionSelected(); } } }); final Composite composite = new Composite(group, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 2; layout.makeColumnsEqualWidth = true; layout.marginWidth = Dialog.convertHorizontalDLUsToPixels(fm, IDialogConstants.HORIZONTAL_MARGIN); layout.marginHeight = Dialog.convertVerticalDLUsToPixels(fm, IDialogConstants.VERTICAL_MARGIN); layout.horizontalSpacing = Dialog.convertHorizontalDLUsToPixels(fm, IDialogConstants.HORIZONTAL_SPACING); layout.verticalSpacing = Dialog.convertVerticalDLUsToPixels(fm, IDialogConstants.VERTICAL_SPACING); composite.setLayout(layout); gd = new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.VERTICAL_ALIGN_CENTER); composite.setLayoutData(gd); composite.setFont(parent.getFont()); newButton = new Button(composite, SWT.PUSH); newButton.setText(Messages.getString("ClientServiceSiteUI2.NewButtonLabel")); //$NON-NLS-1$ newButton.setFont(JFaceResources.getDialogFont()); gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); int widthHint = Dialog.convertHorizontalDLUsToPixels(fm, IDialogConstants.BUTTON_WIDTH); Point minSize = newButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); gd.widthHint = Math.max(widthHint, minSize.x); newButton.setLayoutData(gd); newButton.setData(UID, "newButton"); //$NON-NLS-1$ newButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { SettingsWizard wizard = new SettingsWizard(null, service); wizard.open(composite.getShell()); IConnection connection = wizard.getConnectionToEdit(); // note: refresh ASAP so the selection will be valid; but endure a listener event // which will redo this refreshUI(); setViewerInput(connection); } }); editButton = new Button(composite, SWT.PUSH); editButton.setText(Messages.getString("ClientServiceSiteUI2.EditButtonLabel")); //$NON-NLS-1$ editButton.setFont(JFaceResources.getDialogFont()); gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); widthHint = Dialog.convertHorizontalDLUsToPixels(fm, IDialogConstants.BUTTON_WIDTH); minSize = editButton.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); gd.widthHint = Math.max(widthHint, minSize.x); editButton.setLayoutData(gd); editButton.setData(UID, "editButton"); //$NON-NLS-1$ editButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { IStructuredSelection selection = (IStructuredSelection) viewer.getSelection(); Object value = selection.getFirstElement(); if (value instanceof String) { IConnection editConnection = getActualConnection((String) value); SettingsWizard wizard = new SettingsWizard(editConnection, service); wizard.open(composite.getShell()); // leave the viewer the same, callback will refresh anything needed } } }); // attach listeners RemoteConnectionsActivator.getConnectionsManager().addConnectionListener(this); RemoteConnectionsActivator.getConnectionsManager().addConnectionStoreChangedListener(this); // remove listeners on dispose group.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { RemoteConnectionsActivator.getConnectionsManager() .removeConnectionListener(ClientServiceSiteUI2.this); RemoteConnectionsActivator.getConnectionsManager() .removeConnectionStoreChangedListener(ClientServiceSiteUI2.this); } }); setViewerInput(null); }
From source file:com.nokia.carbide.remoteconnections.internal.ui.DeviceDiscoveryPrequisiteErrorDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { initializeDialogUnits(parent);/*from w w w .jav a2s. com*/ Composite container = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(1, true); container.setLayout(layout); container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); // Message at top Text topMessage = new Text(container, SWT.MULTI | SWT.WRAP); topMessage.setText(Messages.getString("DeviceDiscoveryPrequisiteErrorDialog_Description")); //$NON-NLS-1$ topMessage.setEditable(false); topMessage.setDoubleClickEnabled(false); GridData topMsgData = new GridData(SWT.LEFT, SWT.CENTER, true, false); topMsgData.heightHint = 48; topMessage.setLayoutData(topMsgData); topMessage.setToolTipText(Messages.getString("DeviceDiscoveryPrequisiteErrorDialog_ToolTipText")); //$NON-NLS-1$ // next two panes can be resized with a sash form SashForm sashForm = new SashForm(container, SWT.VERTICAL); GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); sashForm.setLayoutData(gridData); // this pane lists all the agent display names agentListViewer = new ListViewer(sashForm, SWT.V_SCROLL | SWT.BORDER); agentListViewer.setContentProvider(new ArrayContentProvider()); agentListViewer.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { return ((AgentItem) element).agentName; } }); agentListViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); AgentItem item = (AgentItem) selection.getFirstElement(); errorText.setText(item.agentErrorText); } }); agentListViewer.setInput(agentList); // pane to view the information about the selected agent errorText = new Link(sashForm, SWT.V_SCROLL | SWT.BORDER | SWT.WRAP); errorText.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_LIST_BACKGROUND)); errorText.setToolTipText(Messages.getString("DeviceDiscoveryPrequisiteErrorDialog_ErrorTextToolTipText")); //$NON-NLS-1$ errorText.addListener(SWT.Selection, new Listener() { public void handleEvent(Event event) { // Launch an external browser String siteText = event.text; IWorkbench workbench = PlatformUI.getWorkbench(); try { IWebBrowser browser = workbench.getBrowserSupport().getExternalBrowser(); browser.openURL(new URL(siteText)); } catch (Exception e) { RemoteConnectionsActivator.logError(e); } } }); // add initial weights to the above two panes sashForm.setWeights(new int[] { 150, 200 }); // now the don't ask again check box dontAskAgainCheckBox = new Button(container, SWT.CHECK); dontAskAgainCheckBox.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, true, false)); dontAskAgainCheckBox.setText(Messages.getString("DeviceDiscoveryPrequisiteErrorDialog_DontAskAgainLabel")); //$NON-NLS-1$ dontAskAgainCheckBox .setToolTipText(Messages.getString("DeviceDiscoveryPrequisiteErrorDialog_DontAskAgainToolTipText")); //$NON-NLS-1$ dontAskAgainCheckBox.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { dontAskAgain = dontAskAgainCheckBox.getSelection(); } }); // now finish by selecting the top most agent in the list // and bringing it into view Object o = agentListViewer.getElementAt(0); if (o != null) agentListViewer.setSelection(new StructuredSelection(o)); ISelection selection = agentListViewer.getSelection(); if (selection != null && !selection.isEmpty()) { agentListViewer.reveal(selection); } return container; }