List of usage examples for org.eclipse.jface.viewers TreeViewer TreeViewer
public TreeViewer(Composite parent, int style)
From source file:com.aptana.ide.xul.FirefoxOutline.java
License:Open Source License
/** * @see com.aptana.ide.editors.unified.ContributedOutline#createControl(org.eclipse.swt.widgets.Composite) *//*from w ww . j a v a 2 s . c o m*/ public void createControl(Composite parent) { treeViewer = new TreeViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.SINGLE); treeViewer.getTree().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); treeViewer.getTree().setLayout(new GridLayout(1, true)); treeViewer.setLabelProvider(new DOMLabelProvider()); treeViewer.setAutoExpandLevel(3); treeViewer.setContentProvider(new DOMContentProvider()); treeViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); if (selection.size() == 1) { nsIDOMNode node = (nsIDOMNode) selection.getFirstElement(); browser.highlightElement(node); } } }); treeViewer.addFilter(new InternalNodeFilter()); filter = new PatternFilter() { protected boolean isLeafMatch(Viewer viewer, Object element) { if (element instanceof nsIDOMNode) { if (((nsIDOMNode) element).getNodeType() == nsIDOMNode.ELEMENT_NODE) { nsIDOMElement e = (nsIDOMElement) ((nsIDOMNode) element) .queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID); if (Activator.INTERNAL_ID.equals(e.getAttribute("class"))) //$NON-NLS-1$ { return false; } } DOMLabelProvider prov = (DOMLabelProvider) treeViewer.getLabelProvider(); return this.wordMatches(prov.getText(element)); } return true; } }; treeViewer.addFilter(filter); refreshJob = new WorkbenchJob("Refresh Filter") {//$NON-NLS-1$ /* * (non-Javadoc) * * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor) */ public IStatus runInUIThread(IProgressMonitor monitor) { if (treeViewer.getControl().isDisposed()) { return Status.CANCEL_STATUS; } if (pattern == null) { return Status.OK_STATUS; } filter.setPattern(pattern); try { // don't want the user to see updates that will be made to the tree treeViewer.getControl().setRedraw(false); treeViewer.refresh(true); if (pattern.length() > 0) { /* * Expand elements one at a time. After each is expanded, check to see if the filter text has * been modified. If it has, then cancel the refresh job so the user doesn't have to endure * expansion of all the nodes. */ IStructuredContentProvider provider = (IStructuredContentProvider) treeViewer .getContentProvider(); Object[] elements = provider.getElements(treeViewer.getInput()); for (int i = 0; i < elements.length; i++) { if (monitor.isCanceled()) { return Status.CANCEL_STATUS; } treeViewer.expandToLevel(elements[i], AbstractTreeViewer.ALL_LEVELS); } TreeItem[] items = treeViewer.getTree().getItems(); if (items.length > 0) { // to prevent scrolling treeViewer.getTree().showItem(items[0]); } } } finally { // done updating the tree - set redraw back to true treeViewer.getControl().setRedraw(true); } return Status.OK_STATUS; } }; TreeItem item = new TreeItem(treeViewer.getTree(), SWT.NONE); item.setText(Messages.getString("FirefoxOutline.Select_Tab_To_Load_Outline")); //$NON-NLS-1$ refreshJob.setSystem(true); refresh(); }
From source file:com.aptana.index.core.ui.views.IndexView.java
License:Open Source License
@Override public void createPartControl(Composite parent) { treeViewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); contentProvider = new IndexViewContentProvider(); labelProvider = new IndexViewLabelProvider(); actionProvider = new IndexViewActionProvider(); // set content and label providers treeViewer.setContentProvider(contentProvider); treeViewer.setLabelProvider(labelProvider); treeViewer.setComparator(new ViewerComparator() { @Override/*from w w w. j a v a 2s .c o m*/ public int compare(Viewer viewer, Object e1, Object e2) { String name1 = null; String name2 = null; if (viewer != null && viewer instanceof ContentViewer) { IBaseLabelProvider provider = ((ContentViewer) viewer).getLabelProvider(); if (provider instanceof ILabelProvider) { ILabelProvider labelProvider = (ILabelProvider) provider; name1 = labelProvider.getText(e1); name2 = labelProvider.getText(e2); } } if (name1 == null) { name1 = e1.toString(); } if (name2 == null) { name2 = e2.toString(); } return name1.compareToIgnoreCase(name2); } }); // set input based on the current selection ISelectionService selectionService = getSite().getWorkbenchWindow().getSelectionService(); ISelection selection = selectionService.getSelection(IPageLayout.ID_PROJECT_EXPLORER); setInputFromSelection(selection); // add selection provider this.getSite().setSelectionProvider(treeViewer); // listen to theme changes hookContextMenu(); addListeners(); applyTheme(); }
From source file:com.aptana.php.debug.ui.phpini.PHPIniEditor.java
License:Open Source License
/** * Creates entries viewer.//from w ww . j a va 2 s .com * * @param parent * - parent. * @return viewer parent control. */ private Control createViewer(Composite parent) { // initializing viewer container Composite viewerContainer = new Composite(parent, SWT.NONE); viewerContainer.setLayout(new FillLayout()); // initializing viewer viewer = new TreeViewer(viewerContainer, SWT.FULL_SELECTION | SWT.BORDER); viewer.setColumnProperties(new String[] { NAME_PROPERTY, VALUE_PROPERTY }); viewer.setLabelProvider(new PHPIniLabelProvider()); viewer.getTree().setHeaderVisible(true); viewer.setUseHashlookup(true); // creating columns TreeColumn nameColumn = new TreeColumn(viewer.getTree(), SWT.NULL); nameColumn.setText(Messages.PHPIniEditor_5); TreeColumn valueColumn = new TreeColumn(viewer.getTree(), SWT.NULL); valueColumn.setText(Messages.PHPIniEditor_6); TreeColumn validityColumn = new TreeColumn(viewer.getTree(), SWT.NULL); validityColumn.setText(Messages.PHPIniEditor_21); // creating column layout TableLayout columnLayout = new TableLayout(); // viewerContainer.setLayout(columnLayout); columnLayout.addColumnData(new ColumnWeightData(40)); columnLayout.addColumnData(new ColumnWeightData(50)); columnLayout.addColumnData(new ColumnWeightData(10)); // setting cell editor TextCellEditor valueEditor = new TextCellEditor(viewer.getTree()); viewer.setCellEditors(new CellEditor[] { null, valueEditor, null }); // setting cell modifier viewer.setCellModifier(new PHPIniCellModifier()); // setting selection listener viewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { modifyButtonsStates(); } }); viewer.getTree().addControlListener(new ControlListener() { int times; public void controlMoved(ControlEvent e) { } public void controlResized(ControlEvent e) { // found no way to make correct layouting other then this times++; if (times <= 2) { TableLayout columnLayout = new TableLayout(); columnLayout.addColumnData(new ColumnWeightData(40)); columnLayout.addColumnData(new ColumnWeightData(50)); columnLayout.addColumnData(new ColumnWeightData(10)); viewer.getTree().setLayout(columnLayout); viewer.getTree().layout(true); } } }); // Set the viewer filter, if needed if (isShowingExtensionsOnly) { viewer.addFilter(extensionsOnlyFilter); } // refreshing viewer.getTree().setLayout(columnLayout); viewer.getTree().getParent().layout(true, true); // Add tool-tip support new PHPExtensionsTooltip(viewer.getTree()); return viewerContainer; }
From source file:com.aptana.samples.ui.views.SamplesView.java
License:Open Source License
protected TreeViewer createTreeViewer(Composite parent) { TreeViewer treeViewer = new TreeViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL); treeViewer.setContentProvider(new SamplesViewContentProvider()); treeViewer.setLabelProvider(new SamplesViewLabelProvider()); treeViewer.setInput(getSamplesManager()); treeViewer.setComparator(new ViewerComparator()); ColumnViewerToolTipSupport.enableFor(treeViewer); return treeViewer; }
From source file:com.aptana.scripting.ui.views.BundleView.java
License:Open Source License
/** * createPartControl//from www. j a v a 2 s . c o m */ public void createPartControl(Composite parent) { treeViewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); contentProvider = new BundleViewContentProvider(); labelProvider = new BundleViewLabelProvider(); treeViewer.setContentProvider(contentProvider); treeViewer.setLabelProvider(labelProvider); treeViewer.setInput(BundleManager.getInstance()); treeViewer.setComparator(new ViewerComparator() { /* * (non-Javadoc) * @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer, * java.lang.Object, java.lang.Object) */ @Override public int compare(Viewer viewer, Object e1, Object e2) { String name1 = null; String name2 = null; if (viewer != null && viewer instanceof ContentViewer) { IBaseLabelProvider provider = ((ContentViewer) viewer).getLabelProvider(); if (provider instanceof ILabelProvider) { ILabelProvider labelProvider = (ILabelProvider) provider; name1 = labelProvider.getText(e1); name2 = labelProvider.getText(e2); } } if (name1 == null) { name1 = e1.toString(); } if (name2 == null) { name2 = e2.toString(); } return name1.compareTo(name2); } }); // add selection provider getSite().setSelectionProvider(treeViewer); // listen to theme changes hookContextMenu(); addListeners(); applyTheme(); }
From source file:com.architexa.diagrams.relo.jdt.actions.OpenReloSessionTreeDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { Composite dlgComposite = (Composite) super.createDialogArea(parent); Composite composite = new Composite(dlgComposite, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 2;//from w ww .jav a2 s . c o m composite.setLayout(layout); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); Label lbl = new Label(composite, SWT.NO_FOCUS); lbl.setText("Select path to open in Relo Session:"); ToolBar imgTB = new ToolBar(composite, SWT.FLAT | SWT.HORIZONTAL); ToolItem imgToolItem = new ToolItem(imgTB, SWT.PUSH); try { URL url = ReloPlugin.getDefault().getBundle().getEntry("icons/remove.gif"); imgToolItem.setImage(new Image(Display.getDefault(), url.openStream())); } catch (IOException e) { imgToolItem.setText("x"); } imgToolItem.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { removeSelected(); } }); imgTB.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); treeViewer = new TreeViewer(composite, SWT.BORDER); GridData treeGridData = new GridData(GridData.FILL_BOTH); treeGridData.minimumWidth = convertHorizontalDLUsToPixels(3 * IDialogConstants.BUTTON_WIDTH); treeGridData.minimumHeight = convertVerticalDLUsToPixels(4 * IDialogConstants.BUTTON_BAR_HEIGHT); treeGridData.horizontalSpan = 2; treeViewer.getControl().setLayoutData(treeGridData); treeViewer.setContentProvider(new TreeContentProvider()); treeViewer.setLabelProvider(lblProvider); treeViewer.setInput(rootTNode); treeViewer.getControl().setFocus(); //viewer.setSelection(new StructuredSelection(navPaths[0])); return dlgComposite; }
From source file:com.arm.cmsis.config.editors.ConfigEditor.java
License:Open Source License
private void buildTreeViewer(Composite parent) { fViewer = new TreeViewer(parent, SWT.FULL_SELECTION | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); Tree tree = fViewer.getTree();/*www.j a v a2 s. co m*/ tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1)); tree.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { TreeItem item = (TreeItem) e.item; if (item != null) { IConfigWizardItem configItem = getConfigWizardItem(item.getData()); if (configItem != null) { setCursorAndRevealAt(configItem.getStartLine()); showTooltipText(configItem); } } } }); tree.setLinesVisible(true); tree.setHeaderVisible(true); fColumnAdvisor = new ConfigColumnAdvisor(fViewer); TreeViewerColumn column0 = new TreeViewerColumn(fViewer, SWT.LEFT); column0.getColumn().setText(Messages.ConfigEditor_Option); column0.getColumn().setWidth(320); column0.setLabelProvider(new FirstColumnLabelProvider()); TreeViewerColumn column1 = new TreeViewerColumn(fViewer, SWT.LEFT); column1.getColumn().setText(Messages.ConfigEditor_Value); column1.getColumn().setWidth(100); column1.setEditingSupport(new AdvisedEditingSupport(fViewer, fColumnAdvisor, COLEDIT)); column1.setLabelProvider(new AdvisedCellLabelProvider(fColumnAdvisor, COLEDIT)); // Add an empty column and adjust its width automatically for better looking TreeViewerColumn column2 = new TreeViewerColumn(fViewer, SWT.LEFT); column2.getColumn().setWidth(1); column2.setLabelProvider(new ColumnLabelProvider() { @Override public String getText(Object element) { return ""; //$NON-NLS-1$ } }); if (System.getProperty("os.name").startsWith("Windows")) { //$NON-NLS-1$ //$NON-NLS-2$ parent.addControlListener(new ControlAdapter() { @Override public void controlResized(ControlEvent e) { Tree tree = (Tree) fViewer.getControl(); Rectangle area = parent.getClientArea(); Point preferredSize = tree.computeSize(SWT.DEFAULT, SWT.DEFAULT); int width = area.width - 2 * tree.getBorderWidth(); if (preferredSize.y > tree.getBounds().height) { // Subtract the scrollbar width from the total column width // if a vertical scrollbar will be required Point vBarSize = tree.getVerticalBar().getSize(); width -= vBarSize.x; } Point oldSize = tree.getSize(); if (oldSize.x > area.width) { // tree is getting smaller so make the columns // smaller first and then resize the tree to // match the client area width column2.getColumn().setWidth(Math.max(0, width - column0.getColumn().getWidth() - column1.getColumn().getWidth() - 10)); tree.setSize(area.width, area.height); } else { // tree is getting bigger so make the tree // bigger first and then make the columns wider // to match the client area width tree.setSize(area.width, area.height); column2.getColumn().setWidth(Math.max(0, width - column0.getColumn().getWidth() - column1.getColumn().getWidth() - 10)); } } }); } fViewer.setContentProvider(new ContentProvider()); fViewer.setInput(fParser.getConfigWizardRoot()); ColumnViewerToolTipSupport.enableFor(fViewer); }
From source file:com.arm.cmsis.pack.project.wizards.CmsisCodeTemplateNewWizardPage.java
License:Open Source License
@Override public void createControl(Composite parent) { Composite container = new Composite(parent, SWT.NULL); GridLayout layout = new GridLayout(); container.setLayout(layout);/*w ww. j av a 2s . c o m*/ layout.numColumns = 3; //layout.verticalSpacing = 5; Label label = new Label(container, SWT.NULL); label.setText(Messages.CmsisCodeTemplateNewWizardPage_Project); projectText = new Text(container, SWT.BORDER | SWT.SINGLE); projectText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); projectText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { projectChanged(); } }); projectBrowse = new Button(container, SWT.PUSH); projectBrowse.setText(Messages.CmsisCodeTemplate_Browse); projectBrowse.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { handleProjectBrowse(); } }); fViewer = new TreeViewer(container, SWT.FULL_SELECTION | SWT.BORDER | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL); Tree tree = fViewer.getTree(); GridData gd_tree = new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1); gd_tree.heightHint = 300; tree.setLayoutData(gd_tree); tree.setHeaderVisible(true); tree.setLinesVisible(true); tree.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Object obj = e.item.getData(); if (obj instanceof ICpCodeTemplate) { selectedCodeTemplate = (ICpCodeTemplate) obj; String[] codeTemplates = selectedCodeTemplate.getCodeTemplates(); if (codeTemplates.length == 0) { fileText.setEditable(false); fileText.setText(CmsisConstants.EMPTY_STRING); return; } fileText.setEditable(true); StringBuilder sb = new StringBuilder(Utils.extractFileName(codeTemplates[0])); for (int i = 1; i < codeTemplates.length; i++) { fileText.setEditable(false); sb.append(' '); sb.append(Utils.extractFileName(codeTemplates[i])); } fileText.setText(sb.toString()); } } }); TreeViewerColumn column0 = new TreeViewerColumn(fViewer, SWT.LEFT); column0.getColumn().setText(Messages.CmsisCodeTemplate_Component); column0.getColumn().setWidth(200); column0.setLabelProvider(new ComponentColumnLabelProvider()); TreeViewerColumn column1 = new TreeViewerColumn(fViewer, SWT.LEFT); column1.getColumn().setText(Messages.CmsisCodeTemplate_Name); column1.getColumn().setWidth(320); column1.setLabelProvider(new NameColumnLabelProvider()); fViewer.setContentProvider(new CodeTemplateContentProvider()); IRteProject rteProject = getRteProject(); if (rteProject != null) { ICpCodeTemplate codeTemplate = rteProject.getRteConfiguration().getCmsisCodeTemplate(); fViewer.setInput(codeTemplate); fViewer.getControl().setFocus(); } label = new Label(container, SWT.NULL); label.setText(Messages.CmsisCodeTemplate_Location); containerText = new Text(container, SWT.BORDER | SWT.SINGLE); containerText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); containerText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { dialogChanged(); } }); containerBrowse = new Button(container, SWT.PUSH); containerBrowse.setText(Messages.CmsisCodeTemplate_Browse); containerBrowse.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { handleContainerBrowse(); } }); label = new Label(container, SWT.NULL); label.setText(Messages.CmsisCodeTemplate_FileName); fileText = new Text(container, SWT.BORDER | SWT.SINGLE); fileText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fileText.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { dialogChanged(); } }); initialize(); projectChanged(); setControl(container); new Label(container, SWT.NONE); PlatformUI.getWorkbench().getHelpSystem().setHelp(parent.getParent(), IHelpContextIds.CODE_TEMPLATE_WIZARD); }
From source file:com.arm.cmsis.pack.ui.widgets.RteDeviceInfoWidget.java
License:Open Source License
/** * Create the composite.//from ww w . j av a 2s . co m * @param parent * @param style */ public RteDeviceInfoWidget(Composite parent) { super(parent, SWT.BORDER); GridLayout gridLayout = new GridLayout(6, false); gridLayout.horizontalSpacing = 8; setLayout(gridLayout); Label lblDeviceLabel = new Label(this, SWT.NONE); lblDeviceLabel.setText(CpStringsUI.RteDeviceSelectorWidget_DeviceLabel); lblDevice = new Label(this, SWT.NONE); lblDevice.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); FontDescriptor boldDescriptor = FontDescriptor.createFrom(lblDevice.getFont()).setStyle(SWT.BOLD) .increaseHeight(1); Font boldFont = boldDescriptor.createFont(lblDevice.getDisplay()); lblDevice.setFont(boldFont); btnSelect = new Button(this, SWT.NONE); btnSelect.setText(CpStringsUI.RteDeviceInfoWidget_btnSelect_text); new Label(this, SWT.NONE); new Label(this, SWT.NONE); new Label(this, SWT.NONE); lblFamilyLabel = new Label(this, SWT.NONE); lblFamilyLabel.setText(CpStringsUI.RteDeviceInfoWidget_lblFamily_text); lblFamily = new Label(this, SWT.NONE); lblFamily.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); new Label(this, SWT.NONE); Label lblCpuLabel = new Label(this, SWT.NONE); lblCpuLabel.setText(CpStringsUI.RteDeviceSelectorWidget_CPULabel); lblCpuLabel.setBounds(0, 0, 36, 13); lblCpu = new Label(this, SWT.NONE); lblCpu.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); lblCpu.setBounds(0, 0, 32, 13); new Label(this, SWT.NONE); lblSubfamilyLabel = new Label(this, SWT.NONE); lblSubfamilyLabel.setText(CpStringsUI.RteDeviceInfoWidget_lblSubFamily_text); lblSubfamily = new Label(this, SWT.NONE); lblSubfamily.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); new Label(this, SWT.NONE); Label lblClocklabel = new Label(this, SWT.NONE); lblClocklabel.setText(CpStringsUI.RteDeviceSelectorWidget_lblClocklabel_text); lblClock = new Label(this, SWT.NONE); lblClock.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); new Label(this, SWT.NONE); Label lblVendorLabel = new Label(this, SWT.NONE); lblVendorLabel.setText(CpStringsUI.RteDeviceSelectorWidget_VendorLabel); lblVendor = new Label(this, SWT.NONE); lblVendor.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); new Label(this, SWT.NONE); Label lblMemoryLabel = new Label(this, SWT.NONE); lblMemoryLabel.setText(CpStringsUI.RteDeviceSelectorWidget_lblMemory); lblMemory = new Label(this, SWT.NONE); lblMemory.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); new Label(this, SWT.NONE); Label lblPackLabel = new Label(this, SWT.NONE); lblPackLabel.setText(CpStringsUI.RteDeviceSelectorWidget_lblPack_text); lblPack = new Label(this, SWT.NONE); lblPack.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); new Label(this, SWT.NONE); Label lblFpuLabel = new Label(this, SWT.NONE); lblFpuLabel.setText(CpStringsUI.RteDeviceSelectorWidget_FPULabel); lblFpuLabel.setBounds(0, 0, 38, 13); lblFpu = new Label(this, SWT.NONE); lblFpu.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); new Label(this, SWT.NONE); Label lblUrlLabel = new Label(this, SWT.NONE); lblUrlLabel.setText(CpStringsUI.RteDeviceSelectorWidget_lblUrl); linkUrl = new Link(this, SWT.NONE); linkUrl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); linkUrl.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { OpenURL.open(url, getShell()); } }); new Label(this, SWT.NONE); Label lblEndianLabel = new Label(this, SWT.NONE); lblEndianLabel.setText(CpStringsUI.RteDeviceSelectorWidget_Endian); lblEndianLabel.setBounds(0, 0, 37, 13); lblEndian = new Label(this, SWT.NONE); lblEndian.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); new Label(this, SWT.NONE); Label lblBooks = new Label(this, SWT.NONE); lblBooks.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1)); lblBooks.setText(CpStringsUI.RteDeviceInfoWidget_lblBooks_text); new Label(this, SWT.NONE); lblDescription = new Label(this, SWT.NONE); lblDescription.setText(CpStringsUI.RteDeviceInfoWidget_lblDescription_text); new Label(this, SWT.NONE); new Label(this, SWT.NONE); tableViewer = new TableViewer(this, SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL); table = tableViewer.getTable(); table.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 3, 1)); fBookColumnAdvisor = new RteBookColumnAdvisor(tableViewer); ColumnViewerToolTipSupport.enableFor(tableViewer); tableViewer.setContentProvider(new RteBookContentProvider()); // tableViewer.setLabelProvider(new RteBookLabelProvider()); tableViewer.setLabelProvider(new AdvisedCellLabelProvider(fBookColumnAdvisor, 0)); text = new Text(this, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL); GridData gd_text = new GridData(SWT.FILL, SWT.FILL, true, true, 3, 3); gd_text.widthHint = 240; gd_text.minimumWidth = 200; text.setLayoutData(gd_text); text.setEditable(false); lblBoards = new Label(this, SWT.NONE); lblBoards.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1)); lblBoards.setText(CpStringsUI.RteDeviceInfoWidget_lblBoards_text); new Label(this, SWT.NONE); treeViewer = new TreeViewer(this, SWT.BORDER | SWT.FULL_SELECTION); tree = treeViewer.getTree(); tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1)); treeViewer.setContentProvider(new RteBoardContentProvider()); // treeViewer.setLabelProvider(new RteBoardLabelProvider()); fBoardColumnAdvisor = new RteBookColumnAdvisor(treeViewer); ColumnViewerToolTipSupport.enableFor(treeViewer); treeViewer.setLabelProvider(new AdvisedCellLabelProvider(fBoardColumnAdvisor, 0)); }
From source file:com.arm.cmsis.pack.ui.widgets.RteDeviceSelectorWidget.java
License:Open Source License
/** * Create the composite./*from w w w . j a v a 2 s . co m*/ * @param parent * @param style */ public RteDeviceSelectorWidget(Composite parent) { super(parent, SWT.NONE); GridLayout gridLayout = new GridLayout(6, false); gridLayout.horizontalSpacing = 8; setLayout(gridLayout); Label lblDeviceLabel = new Label(this, SWT.NONE); lblDeviceLabel.setText(CpStringsUI.RteDeviceSelectorWidget_DeviceLabel); lblDevice = new Label(this, SWT.NONE); lblDevice.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); new Label(this, SWT.NONE); Label lblCpuLabel = new Label(this, SWT.NONE); lblCpuLabel.setText(CpStringsUI.RteDeviceSelectorWidget_CPULabel); lblCpuLabel.setBounds(0, 0, 36, 13); lblCpu = new Label(this, SWT.NONE); lblCpu.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); lblCpu.setBounds(0, 0, 32, 13); new Label(this, SWT.NONE); Label lblVendorLabel = new Label(this, SWT.NONE); lblVendorLabel.setText(CpStringsUI.RteDeviceSelectorWidget_VendorLabel); lblVendor = new Label(this, SWT.NONE); lblVendor.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); new Label(this, SWT.NONE); Label lblClocklabel = new Label(this, SWT.NONE); lblClocklabel.setText(CpStringsUI.RteDeviceSelectorWidget_lblClocklabel_text); lblClock = new Label(this, SWT.NONE); lblClock.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); new Label(this, SWT.NONE); Label lblPackLabel = new Label(this, SWT.NONE); lblPackLabel.setText(CpStringsUI.RteDeviceSelectorWidget_lblPack_text); lblPack = new Label(this, SWT.NONE); lblPack.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); new Label(this, SWT.NONE); Label lblMemoryLabel = new Label(this, SWT.NONE); lblMemoryLabel.setText(CpStringsUI.RteDeviceSelectorWidget_lblMemory); lblMemory = new Label(this, SWT.NONE); lblMemory.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); new Label(this, SWT.NONE); Label lblUrlLabel = new Label(this, SWT.NONE); lblUrlLabel.setText(CpStringsUI.RteDeviceSelectorWidget_lblUrl); linkUrl = new Link(this, SWT.NONE); linkUrl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); linkUrl.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { OpenURL.open(url, getShell()); } }); new Label(this, SWT.NONE); Label lblFpuLabel = new Label(this, SWT.NONE); lblFpuLabel.setText(CpStringsUI.RteDeviceSelectorWidget_FPULabel); lblFpuLabel.setBounds(0, 0, 38, 13); comboFpu = new Combo(this, SWT.READ_ONLY); comboFpu.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { if (updatingControls) return; int index = comboFpu.getSelectionIndex(); selectedFpu = fpuIndexToString(index); } }); comboFpu.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); new Label(this, SWT.NONE); Label lblSearch = new Label(this, SWT.NONE); lblSearch.setText(CpStringsUI.RteDeviceSelectorWidget_SearchLabel); txtSearch = new Text(this, SWT.BORDER); txtSearch.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { setSearchText(txtSearch.getText()); } }); txtSearch.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); txtSearch.setToolTipText(CpStringsUI.RteDeviceSelectorWidget_SearchTooltip); new Label(this, SWT.NONE); Label lblEndian = new Label(this, SWT.NONE); lblEndian.setText(CpStringsUI.RteDeviceSelectorWidget_Endian); lblEndian.setBounds(0, 0, 37, 13); comboEndian = new Combo(this, SWT.READ_ONLY); comboEndian.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { if (updatingControls) return; selectedEndian = adjustEndianString(comboEndian.getText()); } }); comboEndian.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); new Label(this, SWT.NONE); treeViewer = new TreeViewer(this, SWT.BORDER); treeViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { handleTreeSelectionChanged(event); } }); Tree tree = treeViewer.getTree(); GridData gd_tree = new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1); gd_tree.minimumWidth = 240; tree.setLayoutData(gd_tree); treeViewer.setContentProvider(new TreeObjectContentProvider()); treeViewer.setLabelProvider(new RteDeviceLabeProvider()); treeViewer.addFilter(new ViewerFilter() { @Override public boolean select(Viewer viewer, Object parentElement, Object element) { if (fSearchString.isEmpty() || fSearchString.equals("*")) { //$NON-NLS-1$ return true; } if (element instanceof IRteDeviceItem) { String s = fSearchString; if (!s.endsWith("*")) //$NON-NLS-1$ s += "*"; //$NON-NLS-1$ IRteDeviceItem deviceItem = (IRteDeviceItem) element; return deviceItem.getFirstItem(s) != null; } return false; } }); text = new Text(this, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL); GridData gd_text = new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1); gd_text.widthHint = 240; gd_text.minimumWidth = 200; text.setLayoutData(gd_text); text.setEditable(false); setTabList(new Control[] { txtSearch, tree, comboFpu, comboEndian }); addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { fSelectedItem = null; fDevices = null; listeners.removeAllListeners(); listeners = null; } }); }