@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 setTreeInput(GradleProject project) { if (taskSelectionTreeViewer != null) { taskSelectionTreeViewer.setInput(project); Tree tree = taskSelectionTreeViewer.getTree(); for (TreeColumn col : tree.getColumns()) { col.pack(); } } }
/** @see org.eclipse.epf.ui.wizards.BaseWizardPage#onEnterPage(Object) */ public void onEnterPage(Object obj) { if (obj != null && obj instanceof String) { String configName = (String) obj; config = LibraryServiceUtil.getMethodConfiguration( LibraryService.getInstance().getCurrentMethodLibrary(), configName); if (config != null) { processViewer.setInput(config); initControls(); processViewer.expandAll(); } else { // For config free process publishing config = ConfigFreeProcessPublishUtil.getInstance().getMethodConfigurationForConfigFreeProcess(); processViewer.setInput(LibraryService.getInstance().getCurrentMethodLibrary()); initControls(); processViewer.expandAll(); } } }
@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; }
/** * @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; }
@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; }
/** * Creates the tree viewer. * * @param parent the parent composite * @return the tree viewer */ protected CheckboxTreeViewer createTreeViewer(Composite parent) { fViewer = new CheckboxTreeViewer(parent, SWT.BORDER); fViewer.setContentProvider(fContentProvider); fViewer.setLabelProvider(fLabelProvider); fViewer.addCheckStateListener( new ICheckStateListener() { public void checkStateChanged(CheckStateChangedEvent event) { updateOKStatus(); } }); fViewer.setComparator(new ResourceComparator(ResourceComparator.NAME)); if (fFilters != null) { for (int i = 0; i != fFilters.size(); i++) fViewer.addFilter(fFilters.get(i)); } fViewer.setInput(fInput); return fViewer; }
/** * Creates the tree viewer. * * @param parent the parent composite * @return the tree viewer */ protected CheckboxTreeViewer createTreeViewer(Composite parent) { if (fContainerMode) { fViewer = new ContainerCheckedTreeViewer(parent, this.fStyle); } else { fViewer = new CheckboxTreeViewer(parent, this.fStyle); } fViewer.setContentProvider(fContentProvider); fViewer.setLabelProvider(fLabelProvider); fViewer.addCheckStateListener( new ICheckStateListener() { public void checkStateChanged(CheckStateChangedEvent event) { updateOKStatus(); } }); fViewer.setComparator(fComparator); if (fFilters != null) { for (int i = 0; i != fFilters.size(); i++) { fViewer.addFilter((ViewerFilter) fFilters.get(i)); } } fViewer.setInput(fInput); return fViewer; }
@Override public void createPartControl(Composite parent) { detailsViewerFlyout = new FlyoutControlComposite(parent, SWT.NONE, detailsViewerFlyoutPreferences); detailsViewerFlyout.setTitleText("Details / Filters"); detailsViewerFlyout.setValidDockLocations(IFlyoutPreferences.DOCK_EAST); patternsViewerFlyout = new FlyoutControlComposite( detailsViewerFlyout.getClientParent(), SWT.NONE, patternsViewerFlyoutPreferences); patternsViewerFlyout.setTitleText("Pattern registry"); patternsViewerFlyout.setValidDockLocations(IFlyoutPreferences.DOCK_WEST); matcherTreeViewer = new TreeViewer(patternsViewerFlyout.getClientParent()); detailsTableViewer = new TableViewer(detailsViewerFlyout.getFlyoutParent(), SWT.FULL_SELECTION); // matcherTreeViewer configuration matcherTreeViewer.setContentProvider( new ObservableListTreeContentProvider( new QueryExplorerObservableFactory(), new QueryExplorerTreeStructureAdvisor())); matcherTreeViewer.setLabelProvider(new QueryExplorerLabelProvider()); matcherTreeViewer.setInput(treeViewerRootContent); treeViewerRootContent.setViewer(matcherTreeViewer); ColumnViewerToolTipSupport.enableFor(matcherTreeViewer); matcherTreeViewer.setComparator(null); IObservableValue selection = ViewersObservables.observeSingleSelection(matcherTreeViewer); selection.addValueChangeListener(new RootContentSelectionChangeListener()); DoubleClickListener listener = new DoubleClickListener(); injector.injectMembers(listener); matcherTreeViewer.addDoubleClickListener(listener); // patternsViewer configuration patternsTreeViewer = new CheckboxTreeViewer( patternsViewerFlyout.getFlyoutParent(), SWT.CHECK | SWT.BORDER | SWT.MULTI); patternsTreeViewer.addCheckStateListener(new CheckStateListener()); setPackagePresentation(mementoPackagePresentation, false); patternsTreeViewer.setInput(patternsViewerInput); // Create menu manager. MenuManager matcherTreeViewerMenuManager = new MenuManager(); matcherTreeViewerMenuManager.setRemoveAllWhenShown(true); matcherTreeViewerMenuManager.addMenuListener( new IMenuListener() { @Override public void menuAboutToShow(IMenuManager mgr) { fillContextMenu(mgr); } }); // Create menu for tree viewer Menu matcherTreeViewerMenu = matcherTreeViewerMenuManager.createContextMenu(matcherTreeViewer.getControl()); matcherTreeViewer.getControl().setMenu(matcherTreeViewerMenu); getSite() .registerContextMenu( "org.eclipse.incquery.tooling.ui.queryexplorer.QueryExplorer.treeViewerMenu", matcherTreeViewerMenuManager, matcherTreeViewer); MenuManager patternsViewerMenuManager = new MenuManager(); patternsViewerMenuManager.setRemoveAllWhenShown(true); patternsViewerMenuManager.addMenuListener( new IMenuListener() { @Override public void menuAboutToShow(IMenuManager mgr) { fillContextMenu(mgr); } }); // Create menu for patterns viewer Menu patternsViewerMenu = patternsViewerMenuManager.createContextMenu(patternsTreeViewer.getControl()); patternsTreeViewer.getControl().setMenu(patternsViewerMenu); getSite() .registerContextMenu( "org.eclipse.incquery.tooling.ui.queryexplorer.QueryExplorer.patternsViewerMenu", patternsViewerMenuManager, patternsTreeViewer); // tableView configuration Table table = detailsTableViewer.getTable(); table.setHeaderVisible(true); table.setLinesVisible(true); GridData gridData = new GridData(); gridData.verticalAlignment = GridData.FILL; gridData.horizontalSpan = 2; gridData.grabExcessHorizontalSpace = true; gridData.grabExcessVerticalSpace = true; gridData.horizontalAlignment = GridData.FILL; detailsTableViewer.getControl().setLayoutData(gridData); // Focus listening and selection providing getSite().setSelectionProvider(matcherTreeViewer); // removed listener due to new attach feature in // https://bugs.eclipse.org/bugs/show_bug.cgi?id=429858 // initFileListener(); initPatternsViewerWithGeneratedPatterns(); }
@Override protected Control createExtendedContentArea(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); GridLayoutFactory.fillDefaults().applyTo(composite); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).applyTo(composite); Label label = new Label(composite, SWT.NONE); label.setText("Select the connections to be searched for opening pages:"); CheckboxTreeViewer dataManagerTreeViewers = new CheckboxTreeViewer(composite, SWT.BORDER); GridDataFactory.fillDefaults() .align(SWT.FILL, SWT.CENTER) .grab(true, false) .applyTo(dataManagerTreeViewers.getControl()); dataManagerTreeViewers.setContentProvider( new ITreeContentProvider() { public Object[] getChildren(Object parentElement) { // TODO Auto-generated method stub return null; } public Object getParent(Object element) { // TODO Auto-generated method stub return null; } public boolean hasChildren(Object element) { // TODO Auto-generated method stub return false; } public Object[] getElements(Object inputElement) { return DataManagerRegistry.getDefault().getDataManagers().toArray(); } public void dispose() { // TODO Auto-generated method stub } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { // TODO Auto-generated method stub } }); dataManagerTreeViewers.setLabelProvider(new WorkbenchLabelProvider()); dataManagerTreeViewers.setInput(this); for (DataManager dataManager : targetDataManagers) dataManagerTreeViewers.setChecked(dataManager, true); dataManagerTreeViewers.addCheckStateListener( new ICheckStateListener() { public void checkStateChanged(CheckStateChangedEvent event) { if (event.getChecked()) targetDataManagers.add((DataManager) event.getElement()); else targetDataManagers.remove(event.getElement()); } }); return composite; }
/** Initializes this group's viewers after they have been laid out. */ protected void initialize() { fTreeViewer.setInput(fRoot); }
/* * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite) */ public void createControl(Composite parent) { initializeDialogUnits(parent); Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout()); composite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); setControl(composite); Label label = new Label(composite, SWT.WRAP); label.setText(WorkingSetMessages.ScriptWorkingSetPage_workingSet_name); GridData gd = new GridData( GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER); label.setLayoutData(gd); fWorkingSetName = new Text(composite, SWT.SINGLE | SWT.BORDER); fWorkingSetName.setLayoutData( new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL)); fWorkingSetName.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { validateInput(); } }); fWorkingSetName.setFocus(); label = new Label(composite, SWT.WRAP); label.setText(WorkingSetMessages.ScriptWorkingSetPage_workingSet_content); gd = new GridData( GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER); label.setLayoutData(gd); fTree = new CheckboxTreeViewer(composite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); gd = new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL); gd.heightHint = convertHeightInCharsToPixels(15); fTree.getControl().setLayoutData(gd); fTreeContentProvider = new ScriptWorkingSetPageContentProvider(); fTree.setContentProvider(fTreeContentProvider); AppearanceAwareLabelProvider fScriptElementLabelProvider = new AppearanceAwareLabelProvider( AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS | ScriptElementLabels.P_COMPRESSED, AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS | ScriptElementImageProvider.SMALL_ICONS, DLTKUIPlugin.getDefault().getPreferenceStore()); fTree.setLabelProvider(new DecoratingModelLabelProvider(fScriptElementLabelProvider)); fTree.setSorter(new ModelElementSorter()); if (DLTKCore.DEBUG) { System.err.println("Add empty inner package filter support here..."); // $NON-NLS-1$ } // fTree.addFilter(new EmptyInnerPackageFilter()); fTree.setUseHashlookup(true); fTree.setInput(DLTKCore.create(ResourcesPlugin.getWorkspace().getRoot())); fTree.addCheckStateListener( new ICheckStateListener() { public void checkStateChanged(CheckStateChangedEvent event) { handleCheckStateChange(event); } }); fTree.addTreeListener( new ITreeViewerListener() { public void treeCollapsed(TreeExpansionEvent event) {} public void treeExpanded(TreeExpansionEvent event) { final Object element = event.getElement(); if (fTree.getGrayed(element) == false) BusyIndicator.showWhile( getShell().getDisplay(), new Runnable() { public void run() { setSubtreeChecked(element, fTree.getChecked(element), false); } }); } }); // Add select / deselect all buttons for bug 46669 Composite buttonComposite = new Composite(composite, SWT.NONE); GridLayout layout = new GridLayout(2, false); layout.marginWidth = 0; layout.marginHeight = 0; buttonComposite.setLayout(layout); buttonComposite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); Button selectAllButton = new Button(buttonComposite, SWT.PUSH); selectAllButton.setText(WorkingSetMessages.ScriptWorkingSetPage_selectAll_label); selectAllButton.setToolTipText(WorkingSetMessages.ScriptWorkingSetPage_selectAll_toolTip); selectAllButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent selectionEvent) { fTree.setCheckedElements(fTreeContentProvider.getElements(fTree.getInput())); validateInput(); } }); selectAllButton.setLayoutData(new GridData()); SWTUtil.setButtonDimensionHint(selectAllButton); Button deselectAllButton = new Button(buttonComposite, SWT.PUSH); deselectAllButton.setText(WorkingSetMessages.ScriptWorkingSetPage_deselectAll_label); deselectAllButton.setToolTipText(WorkingSetMessages.ScriptWorkingSetPage_deselectAll_toolTip); deselectAllButton.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent selectionEvent) { fTree.setCheckedElements(new Object[0]); validateInput(); } }); deselectAllButton.setLayoutData(new GridData()); SWTUtil.setButtonDimensionHint(deselectAllButton); if (fWorkingSet != null) fWorkingSetName.setText(fWorkingSet.getName()); initializeCheckedState(); validateInput(); Dialog.applyDialogFont(composite); // Set help for the page if (DLTKCore.DEBUG) { System.err.println("Add help support here..."); // $NON-NLS-1$ } // ScriptUIHelp.setHelp(fTree, IScriptHelpContextIds.Script_WORKING_SET_PAGE); }
private void createProjectsList(final Composite workArea) { final Label projectsLabel = new Label(workArea, SWT.NULL); projectsLabel.setText("Projects:"); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(projectsLabel); Composite projectListGroup = new Composite(workArea, SWT.NULL); GridDataFactory.fillDefaults().grab(true, true).applyTo(projectListGroup); GridLayoutFactory.fillDefaults().numColumns(2).applyTo(projectListGroup); projectList = new CheckboxTreeViewer(projectListGroup); PixelConverter pc = new PixelConverter(projectList.getControl()); GridDataFactory.fillDefaults() .grab(true, true) .align(SWT.FILL, SWT.FILL) .hint(pc.convertWidthInCharsToPixels(25), pc.convertHeightInCharsToPixels(10)) .applyTo(projectList.getControl()); projectList.setLabelProvider(new ProjectCandidateLabelProvider()); projectList.setContentProvider( new ITreeContentProvider() { @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {} @Override public void dispose() {} @Override public boolean hasChildren(Object element) { return false; } @Override public Object getParent(Object element) { return null; } @Override public Object[] getElements(Object inputElement) { if (candidates == null) return new ProjectCandidate[0]; return candidates; } @Override public Object[] getChildren(Object parentElement) { return null; } }); projectList.addCheckStateListener( new ICheckStateListener() { @Override public void checkStateChanged(CheckStateChangedEvent event) { ProjectCandidate candidate = (ProjectCandidate) event.getElement(); // Cancel out existing projects if (candidate.exists()) { projectList.setChecked(candidate, false); return; } // Update conflicts for (ProjectCandidate elem : candidates) { Widget w1 = elem.getWidget(); Widget w2 = candidate.getWidget(); if (w1.getId().equals(w2.getId()) && w1.getName().equals(w2.getName()) && !elem.configLocation.equals(candidate.configLocation)) { if (projectList.getChecked(elem)) { projectList.setChecked(candidate, false); } else { elem.conflicts = event.getChecked(); } } } projectList.refresh(true); setPageComplete(projectList.getCheckedElements().length > 0); } }); final Composite selectButtonGroup = new Composite(projectListGroup, SWT.NULL); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.BEGINNING).applyTo(selectButtonGroup); GridLayoutFactory.fillDefaults().applyTo(selectButtonGroup); Button selectAll = new Button(selectButtonGroup, SWT.PUSH); selectAll.setText("Select All"); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(selectAll); Button deselectAll = new Button(selectButtonGroup, SWT.PUSH); deselectAll.setText("Deselect All"); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(deselectAll); Button refresh = new Button(selectButtonGroup, SWT.PUSH); refresh.setText("Refresh"); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(refresh); selectAll.addListener( SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { if (candidates != null) { for (ProjectCandidate candie : candidates) { projectList.setChecked(candie, true); } } setPageComplete(projectList.getCheckedElements().length > 0); } }); deselectAll.addListener( SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { projectList.setCheckedElements(new Object[0]); setPageComplete(false); } }); refresh.addListener( SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { updateProjectsList(directoryPathField.getText()); } }); projectList.setInput(this); }
@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; }