@Override protected Control createDialogArea(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); composite.setLayout(new GridLayout(1, false)); treeViewer = new CheckboxTreeViewer(composite, SWT.CHECK | SWT.BORDER); treeViewer.setContentProvider( new ReferenceTreeContentProvider(DatabasePackage.Literals.TABLE_RESOURCE_DATA__COLUMNS)); treeViewer.getTree().setHeaderVisible(true); treeViewer.getTree().setLinesVisible(true); createColumns(treeViewer); // treeViewer.addCheckStateListener(new ICheckStateListener() { // @Override // public void checkStateChanged(CheckStateChangedEvent event) { // Object[] objects = treeViewer.getCheckedElements(); // List<TableColumn> columnList = new ArrayList<TableColumn>(); // for (Object obj : objects) { // if (obj instanceof TableColumn) { // columnList.add((TableColumn) obj); // } // } // result = columnList.toArray(new TableColumn[0]); // } // }); treeViewer.setInput(input); GridDataFactory.fillDefaults().hint(-1, 300).applyTo(treeViewer.getTree()); return composite; }
private void createTaskTree(Composite parent) { PatternFilter filter = new PatternFilter(); FilteredTree filteredTree = new FilteredTree(parent, SWT.CHECK | SWT.BORDER, filter, true) { @Override protected TreeViewer doCreateTreeViewer(Composite parent, int style) { return new ContainerCheckedTreeViewer(parent, style); } }; taskSelectionTreeViewer = (CheckboxTreeViewer) filteredTree.getViewer(); filteredTree.setLayoutData(new GridData(GridData.FILL_BOTH)); // Add multi column support Tree tree = taskSelectionTreeViewer.getTree(); tree.setHeaderVisible(true); TreeColumn column1 = new TreeColumn(tree, SWT.LEFT); column1.setText("Project/Task"); TreeColumn column2 = new TreeColumn(tree, SWT.LEFT); column2.setText("Description"); column1.pack(); column2.pack(); taskSelectionTreeViewer.setLabelProvider(new GradleTaskTreeLabelProvider()); taskSelectionTreeViewer.setContentProvider( new GradleTaskTreeContentProvider(taskSelectionTreeViewer, true)); taskSelectionTreeViewer.setCheckStateProvider(tasksChecked); taskSelectionTreeViewer.addCheckStateListener(tasksChecked); if (project != null) { setTreeInput(project); } }
private boolean hasCheckedElement() { TreeItem[] items = fTree.getTree().getItems(); for (int i = 0; i < items.length; i++) { if (items[i].getChecked()) return true; } return false; }
/** @see org.eclipse.jface.dialogs.IDialogPage#createControl(Composite) */ public void createControl(Composite parent) { Composite composite = createGridLayoutComposite(parent, 1); publishConfigRadioButton = createRadioButton(composite, PublishingUIResources.publishConfigRadioButton_text, 1, true); publishProcessesRadioButton = createRadioButton( composite, PublishingUIResources.publishProcessesRadioButton_text, 1, false); Composite processComposite = createChildGridLayoutComposite(composite, 1); processViewer = new CheckboxTreeViewer(processComposite); GridData gridData = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL); gridData.heightHint = 300; processViewer.getTree().setLayoutData(gridData); // processViewer.setContentProvider(new ProcessViewerContentProvider()); processViewer.setLabelProvider(new ProcessTreeLabelProvider()); includeBaseProcessesCheckbox = createCheckbox( processComposite, PublishingUIResources.includeBaseProcessesCheckboxLabel_text); initControls(); addListeners(); setControl(composite); }
@Override protected Control createDialogArea(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); composite.setLayout(new GridLayout(1, false)); treeViewer = new CheckboxTreeViewer(composite, SWT.CHECK | SWT.BORDER); treeViewer.setContentProvider( new ReferenceTreeContentProvider(DatabasePackage.Literals.TABLE_RESOURCE_DATA__INDEXES)); treeViewer.getTree().setHeaderVisible(true); treeViewer.getTree().setLinesVisible(true); createColumns(treeViewer); treeViewer.setInput(input); GridDataFactory.fillDefaults().hint(-1, 300).applyTo(treeViewer.getTree()); return composite; }
private void setTreeInput(GradleProject project) { if (taskSelectionTreeViewer != null) { taskSelectionTreeViewer.setInput(project); Tree tree = taskSelectionTreeViewer.getTree(); for (TreeColumn col : tree.getColumns()) { col.pack(); } } }
/** * Enable/selects widgets depending on the group specified. * * @param group - group to enable. */ private void setKernelEnablements(KernelGroupEnum group) { fTracepointsActivateButton.setSelection(group == KernelGroupEnum.TRACEPOINTS); fTracepointsViewer.getTree().setEnabled(group == KernelGroupEnum.TRACEPOINTS); fSysCallsActivateButton.setSelection(group == KernelGroupEnum.SYSCALLS); fProbeActivateButton.setSelection(group == KernelGroupEnum.PROBE); fProbeEventNameText.setEnabled(group == KernelGroupEnum.PROBE); fProbeText.setEnabled(group == KernelGroupEnum.PROBE); fFunctionActivateButton.setSelection(group == KernelGroupEnum.FUNCTION); fFunctionEventNameText.setEnabled(group == KernelGroupEnum.FUNCTION); fFunctionText.setEnabled(group == KernelGroupEnum.FUNCTION); }
@Override protected Control createDialogArea(Composite top) { top.getShell().setText(Messages.EventTreeDialog_PapiEventSelection); final Composite parent = (Composite) super.createDialogArea(top); final GridLayout gl = new GridLayout(); parent.setLayout(gl); final GridData gd = new GridData(GridData.FILL_BOTH); gd.heightHint = 500; gd.widthHint = 350; treeV = new CheckboxTreeViewer(parent, SWT.BORDER); ColumnViewerToolTipSupport.enableFor(treeV); // et=new EventTree(); cSelect = new PapiCSelect(toolPath, utilBlob); // "E:\\PAPIProject\\ptest2.xml");// et = cSelect.getEventTree(); treeV.setContentProvider(et); // tree=treeV.getTree(); treeV.getTree().setLayoutData(gd); // tree.setLayoutData(gd); treeV.setLabelProvider(new ETreeCellLabelProvider()); treeV.setInput(et); treeV.setGrayedElements(new Object[0]); treeV.expandToLevel(3); treeV.addCheckStateListener( new ICheckStateListener() { public void checkStateChanged(CheckStateChangedEvent event) { final Object element = event.getElement(); if (treeV.getGrayed(element)) { treeV.setChecked(element, true); return; } if (element instanceof ETItem) { doCheck((ETItem) element, event.getChecked()); } } }); return parent; }
private void checkAllStates(String comment, CheckboxTreeViewer ctv, int shift) { List items = new ArrayList(); List elements = new ArrayList(); collectElementsInBranch(ctv.getTree().getItem(0), items, elements); // Check that actual states were set properly for (Iterator i = items.iterator(), j = elements.iterator(); i.hasNext(); ) { TreeItem item = (TreeItem) i.next(); TestElement element = (TestElement) j.next(); checkState(comment, element, item, shift); // check in Tree checkState(comment, element, ctv, shift); // check in Viewer } }
/* * (non-Javadoc) * * @see * org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets * .Composite) */ @Override protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); createMessageArea(composite); CheckboxTreeViewer treeViewer = createTreeViewer(composite); GridData data = new GridData(GridData.FILL_BOTH); data.widthHint = convertWidthInCharsToPixels(60); data.heightHint = convertHeightInCharsToPixels(18); Tree treeWidget = treeViewer.getTree(); treeWidget.setLayoutData(data); treeWidget.setFont(composite.getFont()); if (hasNewFolderButton) { Button button = new Button(composite, SWT.PUSH); button.setText(TernUIMessages.Button_newFolder); button.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent event) { newFolderButtonPressed(); } }); button.setFont(composite.getFont()); fNewFolderButton = button; } treeViewer.addSelectionChangedListener(this); if (fExisting != null) { Object[] existing = fExisting.toArray(); treeViewer.setGrayedElements(existing); setInitialSelections(existing); } if (fFocusElement != null) { treeViewer.setSelection(new StructuredSelection(fFocusElement), true); } treeViewer.addCheckStateListener( new ICheckStateListener() { public void checkStateChanged(CheckStateChangedEvent event) { forceExistingChecked(event); } }); applyDialogFont(composite); return composite; }
/** * @see * org.suggs.sandbox.swt.treesntables.treeviewer.FileTree#createContents(org.eclipse.swt.widgets.Composite) */ @Override protected Control createContents(Composite parent) { Composite comp = new Composite(parent, SWT.NONE); comp.setLayout(new GridLayout(1, false)); Button preserveCase = new Button(comp, SWT.CHECK); preserveCase.setSelection(true); preserveCase.setText("&Preserve Case"); final CheckboxTreeViewer tv = new CheckboxTreeViewer(comp); tv.getTree().setLayoutData(new GridData(GridData.FILL_BOTH)); tv.setContentProvider(new FileTreeContentProvider()); tv.setLabelProvider(new FileTreeLabelProvider()); tv.setInput("root"); // now add the listener preserveCase.addSelectionListener( new SelectionAdapter() { /** * @see * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent) */ @Override public void widgetSelected(SelectionEvent event) { boolean pc = ((Button) event.widget).getSelection(); FileTreeLabelProvider ftlp = (FileTreeLabelProvider) tv.getLabelProvider(); ftlp.setPreserveCase(pc); } }); tv.addCheckStateListener( new ICheckStateListener() { /** * @see * org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged(org.eclipse.jface.viewers.CheckStateChangedEvent) */ @Override public void checkStateChanged(CheckStateChangedEvent event) { if (event.getChecked()) { tv.setSubtreeChecked(event.getElement(), true); } } }); return comp; }
/* * (non-Javadoc) * * @see * org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets * .Composite) */ @Override protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); Label messageLabel = createMessageArea(composite); CheckboxTreeViewer treeViewer = createTreeViewer(composite); Control buttonComposite = createSelectionButtons(composite); GridData data = new GridData(GridData.FILL_BOTH); data.widthHint = convertWidthInCharsToPixels(fWidth); data.heightHint = convertHeightInCharsToPixels(fHeight); Tree treeWidget = treeViewer.getTree(); treeWidget.setLayoutData(data); treeWidget.setFont(parent.getFont()); if (fIsEmpty) { messageLabel.setEnabled(false); treeWidget.setEnabled(false); buttonComposite.setEnabled(false); } return composite; }
public void updateTreeCheckboxesForAncestor(Object element) { ICheckboxTreeContentProvider contentProvider = contentProvider(); if (element != null) { treeViewer.setChecked(element, contentProvider.isChecked(element)); } if (element == null) { TreeItem[] items = treeViewer.getTree().getItems(); for (int i = 0, count = items.length; i < count; i++) { updateTreeCheckboxesForItem(items[i]); } } else { TreeItem item = ((TreeViewerAccess) treeViewer).itemForElement(element); updateTreeCheckboxesForItem(item); } }
private void testSpecificState(final boolean isChecked, final boolean isGrayed) { CheckboxTreeViewer ctv = (CheckboxTreeViewer) fViewer; ctv.setCheckStateProvider( new ICheckStateProvider() { public boolean isChecked(Object element) { return isChecked; } public boolean isGrayed(Object element) { return isGrayed; } }); TreeItem item = ctv.getTree().getItem(0); assertEquals(item.getChecked(), isChecked); assertEquals(item.getGrayed(), isGrayed); }
/* * @see PreferencePage#createContents(Composite) */ @Override protected Control createContents(final Composite parent) { // create composite final Composite comp = parent; final GridLayout topLayout = new GridLayout(); comp.setLayout(topLayout); final Group tracedModulesGroup = new Group(comp, SWT.NONE); tracedModulesGroup.setText("Traced modules"); final GridData gd_interpretedModulesGroup = new GridData(); tracedModulesGroup.setLayoutData(gd_interpretedModulesGroup); tracedModulesGroup.setLayout(new GridLayout()); checkboxTreeViewer = new CheckboxTreeViewer(tracedModulesGroup, SWT.BORDER); checkboxTreeViewer.addCheckStateListener( new ICheckStateListener() { @SuppressWarnings("synthetic-access") public void checkStateChanged(final CheckStateChangedEvent event) { final DebugTab.DebugTreeItem dti = (DebugTreeItem) event.getElement(); checkboxTreeViewer.setGrayed(dti, false); final boolean checked = event.getChecked(); setSubtreeChecked(dti, checked, tracedModules, checkboxTreeViewer); DebugTab.checkUpwards(checkboxTreeViewer, dti, checked, false); } }); checkboxTreeViewer.setLabelProvider(new TreeLabelProvider()); checkboxTreeViewer.setContentProvider(new TreeContentProvider()); final Tree tree = checkboxTreeViewer.getTree(); final GridData gd_tree = new GridData(SWT.FILL, SWT.FILL, true, true); gd_tree.minimumWidth = 250; gd_tree.minimumHeight = 120; gd_tree.widthHint = 256; gd_tree.heightHint = 220; tree.setLayoutData(gd_tree); applyDialogFont(comp); return comp; }
/** * Gets the tree that displays the list for a folder * * @return the tree used to show the folders */ public Tree getTree() { return fTreeViewer.getTree(); }
@Override protected Control createDialogArea(Composite parent) { Composite compLayout = (Composite) super.createDialogArea(parent); Composite container = new Composite(compLayout, SWT.NONE); container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); GridLayout layout = new GridLayout(); layout.verticalSpacing = 10; layout.marginTop = 10; container.setLayout(layout); Label lbl = new Label(container, SWT.NONE); lbl.setText("Select Resources from:"); GridData gd; gd = new GridData(); gd.grabExcessHorizontalSpace = true; gd.horizontalAlignment = SWT.FILL; lbl.setLayoutData(gd); Group resourceGroup = new Group(container, SWT.NONE); Color color = Display.getDefault().getSystemColor(SWT.COLOR_WHITE); resourceGroup.setLayout(new GridLayout()); gd = new GridData(); gd.grabExcessHorizontalSpace = true; gd.horizontalAlignment = SWT.FILL; gd.heightHint = 300; gd.horizontalSpan = 2; resourceGroup.setLayoutData(gd); treeViewer = new CheckboxTreeViewer(resourceGroup); treeViewer.getTree().setBackground(color); gd = new GridData(); gd.grabExcessHorizontalSpace = true; gd.horizontalAlignment = SWT.FILL; gd.grabExcessVerticalSpace = true; gd.verticalAlignment = SWT.FILL; // gd.heightHint = 300; treeViewer.getTree().setLayoutData(gd); treeViewer.setContentProvider(new TreeContentProvider()); treeViewer.setLabelProvider(new TreeLabelProvider()); treeViewer.setInput(new Object()); treeViewer.addCheckStateListener( new ICheckStateListener() { @Override public void checkStateChanged(CheckStateChangedEvent e) { Device dev = (Device) e.getElement(); if (null != dev) { if (e.getChecked()) { selectedDeviceList.add(dev); System.out.println("Checked" + dev.getDeviceName()); } else { selectedDeviceList.remove(dev); System.out.println("Unchecked:" + dev.getDeviceName()); } } } }); return compLayout; }