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); } }
/** @param listener */ public TreeViewerBuilder checkStateListener(ICheckStateListener listener) { if (!checkable) { throw new IllegalStateException( "The tree viewer is not a CheckboxTreeViewer!"); //$NON-NLS-1$ } ((CheckboxTreeViewer) viewer).addCheckStateListener(listener); return this; }
@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; }
/* * (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; }
/** * Creates this group's tree viewer. * * @param parent parent composite * @param width the width * @param height the height */ protected void createTreeViewer(Composite parent, int width, int height) { Tree tree = new Tree(parent, SWT.CHECK | SWT.BORDER); GridData data = new GridData(GridData.FILL_BOTH); data.widthHint = width; data.heightHint = height; tree.setLayoutData(data); fTreeViewer = new CheckboxTreeViewer(tree); fTreeViewer.setUseHashlookup(true); fTreeViewer.setContentProvider(fTreeContentProvider); fTreeViewer.setLabelProvider(fTreeLabelProvider); fTreeViewer.addTreeListener(this); fTreeViewer.addCheckStateListener(this); fTreeViewer.addSelectionChangedListener(this); }
/** * @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; }
/** * 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; }
/** Adds event handlers to the wizard page controls. */ protected void addListeners() { publishConfigRadioButton.addListener(SWT.Selection, this); publishProcessesRadioButton.addListener(SWT.Selection, this); includeBaseProcessesCheckbox.addListener(SWT.Selection, this); processViewer.addCheckStateListener( new ICheckStateListener() { public void checkStateChanged(CheckStateChangedEvent event) { Object checkedElement = event.getElement(); boolean checked = event.getChecked(); processViewer.setChecked(checkedElement, checked); processViewer.setSubtreeChecked(checkedElement, checked); if (includeBaseProcessesCheckbox.getSelection()) { selectBaseProcesses(); } updateCheckedStates(); setPageComplete(isPageComplete()); } }); }
/* * @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; }
/** * 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(); }
public void createControl(Composite parent) { final RepositoryUtil util = Activator.getDefault().getRepositoryUtil(); Composite main = new Composite(parent, SWT.NONE); // use zero spacing to save some real estate here GridLayoutFactory.fillDefaults().spacing(0, 0).applyTo(main); final Button internalModeButton = new Button(main, SWT.CHECK); internalModeButton.setText(UIText.ExistingOrNewPage_InternalModeCheckbox); internalModeButton.setToolTipText(UIText.ExistingOrNewPage_CreationInWorkspaceWarningTooltip); internalModeButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { internalMode = internalModeButton.getSelection(); updateControls(); } }); externalComposite = new Composite(main, SWT.NONE); GridDataFactory.fillDefaults().grab(true, true).applyTo(externalComposite); externalComposite.setLayout(new GridLayout(3, false)); new Label(externalComposite, SWT.NONE) .setText(UIText.ExistingOrNewPage_ExistingRepositoryLabel); final Combo existingRepoCombo = new Combo(externalComposite, SWT.READ_ONLY); GridDataFactory.fillDefaults().grab(true, false).applyTo(existingRepoCombo); final ComboViewer v = new ComboViewer(existingRepoCombo); v.setContentProvider(new RepoComboContentProvider()); v.setLabelProvider(new RepoComboLabelProvider()); v.setInput(new Object()); // the default ViewerSorter seems to do the right thing // i.e. sort as String v.setSorter(new ViewerSorter()); existingRepoCombo.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { selectedRepository = null; IStructuredSelection sel = (IStructuredSelection) v.getSelection(); setRepository((Repository) sel.getFirstElement()); updateControls(); } }); Button createRepoWizard = new Button(externalComposite, SWT.PUSH); createRepoWizard.setText(UIText.ExistingOrNewPage_CreateRepositoryButton); createRepoWizard.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { NewRepositoryWizard wiz = new NewRepositoryWizard(true); if (new WizardDialog(getShell(), wiz).open() == Window.OK) { v.refresh(); selectedRepository = wiz.getCreatedRepository(); v.setSelection(new StructuredSelection(selectedRepository)); updateControls(); } } }); new Label(externalComposite, SWT.NONE).setText(UIText.ExistingOrNewPage_WorkingDirectoryLabel); workDir = new Text(externalComposite, SWT.BORDER | SWT.READ_ONLY); GridDataFactory.fillDefaults().grab(true, false).applyTo(workDir); GridDataFactory.fillDefaults().applyTo(workDir); // leave the space between the "Create" and "Browse" buttons empty (i.e. // do not fill to the right border new Label(externalComposite, SWT.NONE); new Label(externalComposite, SWT.NONE).setText(UIText.ExistingOrNewPage_RelativePathLabel); relPath = new Text(externalComposite, SWT.BORDER); relPath.addModifyListener( new ModifyListener() { public void modifyText(ModifyEvent e) { updateControls(); } }); GridDataFactory.fillDefaults().grab(true, false).applyTo(relPath); browseRepository = new Button(externalComposite, SWT.PUSH); browseRepository.setEnabled(false); browseRepository.setText(UIText.ExistingOrNewPage_BrowseRepositoryButton); browseRepository.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { DirectoryDialog dlg = new DirectoryDialog(getShell()); dlg.setFilterPath(selectedRepository.getWorkTree().getPath()); String directory = dlg.open(); if (directory != null) { setRelativePath(directory); updateControls(); } } }); Table projectMoveTable = new Table(externalComposite, SWT.MULTI | SWT.FULL_SELECTION | SWT.CHECK | SWT.BORDER); projectMoveViewer = new CheckboxTableViewer(projectMoveTable); GridDataFactory.fillDefaults().span(3, 1).grab(true, true).applyTo(projectMoveTable); TableColumn tc; tc = new TableColumn(projectMoveTable, SWT.NONE); tc.setText(UIText.ExistingOrNewPage_ProjectNameColumnHeader); tc.setWidth(100); tc = new TableColumn(projectMoveTable, SWT.NONE); tc.setText(UIText.ExistingOrNewPage_CurrentLocationColumnHeader); tc.setWidth(250); tc = new TableColumn(projectMoveTable, SWT.NONE); tc.setText(UIText.ExistingOrNewPage_NewLocationTargetHeader); tc.setWidth(350); projectMoveTable.setHeaderVisible(true); projectMoveViewer.setContentProvider(ArrayContentProvider.getInstance()); projectMoveViewer.setLabelProvider(moveProjectsLabelProvider); projectMoveViewer.setInput(myWizard.projects); projectMoveViewer.addCheckStateListener( new ICheckStateListener() { public void checkStateChanged(CheckStateChangedEvent event) { updateControls(); } }); TableItem[] children = projectMoveViewer.getTable().getItems(); for (int i = 0; i < children.length; i++) { TableItem item = children[i]; IProject data = (IProject) item.getData(); RepositoryFinder repositoryFinder = new RepositoryFinder(data); repositoryFinder.setFindInChildren(false); try { Collection<RepositoryMapping> find = repositoryFinder.find(new NullProgressMonitor()); if (find.size() != 1) item.setChecked(true); } catch (CoreException e1) { item.setText(2, e1.getMessage()); } } parentRepoComposite = new Composite(main, SWT.NONE); parentRepoComposite.setLayout(new GridLayout(3, false)); GridDataFactory.fillDefaults().grab(true, true).applyTo(parentRepoComposite); tree = new Tree(parentRepoComposite, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION | SWT.CHECK); viewer = new CheckboxTreeViewer(tree); tree.setHeaderVisible(true); tree.setLayout(new GridLayout()); tree.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).span(3, 1).create()); viewer.addCheckStateListener( new ICheckStateListener() { public void checkStateChanged(CheckStateChangedEvent event) { if (event.getChecked()) { ProjectAndRepo checkable = (ProjectAndRepo) event.getElement(); for (TreeItem ti : tree.getItems()) { if (ti.getItemCount() > 0 || ((ProjectAndRepo) ti.getData()).getRepo().equals("")) // $NON-NLS-1$ ti.setChecked(false); for (TreeItem subTi : ti.getItems()) { IProject project = ((ProjectAndRepo) subTi.getData()).getProject(); if (checkable.getProject() != null && !subTi.getData().equals(checkable) && checkable.getProject().equals(project)) subTi.setChecked(false); } } } } }); TreeColumn c1 = new TreeColumn(tree, SWT.NONE); c1.setText(UIText.ExistingOrNewPage_HeaderProject); c1.setWidth(100); TreeColumn c2 = new TreeColumn(tree, SWT.NONE); c2.setText(UIText.ExistingOrNewPage_HeaderLocation); c2.setWidth(400); TreeColumn c3 = new TreeColumn(tree, SWT.NONE); c3.setText(UIText.ExistingOrNewPage_HeaderRepository); c3.setWidth(200); boolean allProjectsInExistingRepos = true; for (IProject project : myWizard.projects) { RepositoryFinder repositoryFinder = new RepositoryFinder(project); repositoryFinder.setFindInChildren(false); try { Collection<RepositoryMapping> mappings; mappings = repositoryFinder.find(new NullProgressMonitor()); Iterator<RepositoryMapping> mi = mappings.iterator(); RepositoryMapping m = mi.hasNext() ? mi.next() : null; if (m == null) { // no mapping found, enable repository creation TreeItem treeItem = new TreeItem(tree, SWT.NONE); updateProjectTreeItem(treeItem, project); treeItem.setText(1, project.getLocation().toOSString()); treeItem.setText(2, ""); // $NON-NLS-1$ treeItem.setData(new ProjectAndRepo(project, "")); // $NON-NLS-1$ allProjectsInExistingRepos = false; } else if (!mi.hasNext()) { // exactly one mapping found TreeItem treeItem = new TreeItem(tree, SWT.NONE); updateProjectTreeItem(treeItem, project); treeItem.setText(1, project.getLocation().toOSString()); fillTreeItemWithGitDirectory(m, treeItem, false); treeItem.setData(new ProjectAndRepo(project, m.getGitDirAbsolutePath().toOSString())); treeItem.setChecked(true); } else { TreeItem treeItem = new TreeItem(tree, SWT.NONE); updateProjectTreeItem(treeItem, project); treeItem.setText(1, project.getLocation().toOSString()); treeItem.setData(new ProjectAndRepo(project, "")); // $NON-NLS-1$ TreeItem treeItem2 = new TreeItem(treeItem, SWT.NONE); updateProjectTreeItem(treeItem2, project); fillTreeItemWithGitDirectory(m, treeItem2, true); treeItem2.setData(new ProjectAndRepo(project, m.getGitDirAbsolutePath().toOSString())); while (mi.hasNext()) { // fill in additional mappings m = mi.next(); treeItem2 = new TreeItem(treeItem, SWT.NONE); updateProjectTreeItem(treeItem2, project); fillTreeItemWithGitDirectory(m, treeItem2, true); treeItem2.setData( new ProjectAndRepo( m.getContainer().getProject(), m.getGitDirAbsolutePath().toOSString())); } treeItem.setExpanded(true); allProjectsInExistingRepos = false; } } catch (CoreException e) { TreeItem treeItem2 = new TreeItem(tree, SWT.BOLD | SWT.ITALIC); treeItem2.setText(e.getMessage()); } } createRepo = new Button(parentRepoComposite, SWT.PUSH); createRepo.setLayoutData(GridDataFactory.fillDefaults().create()); createRepo.setText(UIText.ExistingOrNewPage_CreateButton); createRepo.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { File gitDir = new File(repositoryToCreate.getText(), Constants.DOT_GIT); try { Repository repository = FileRepositoryBuilder.create(gitDir); repository.create(); for (IProject project : getProjects(false).keySet()) { // If we don't refresh the project directories right // now we won't later know that a .git directory // exists within it and we won't mark the .git // directory as a team-private member. Failure // to do so might allow someone to delete // the .git directory without us stopping them. // (Half lie, we should optimize so we do not // refresh when the .git is not within the project) // if (!gitDir.toString().contains("..")) // $NON-NLS-1$ project.refreshLocal(IResource.DEPTH_ONE, new NullProgressMonitor()); } util.addConfiguredRepository(gitDir); } catch (IOException e1) { String msg = NLS.bind( UIText.ExistingOrNewPage_ErrorFailedToCreateRepository, gitDir.toString()); org.eclipse.egit.ui.Activator.handleError(msg, e1, true); } catch (CoreException e2) { String msg = NLS.bind(UIText.ExistingOrNewPage_ErrorFailedToRefreshRepository, gitDir); org.eclipse.egit.ui.Activator.handleError(msg, e2, true); } for (TreeItem ti : tree.getSelection()) { IPath projectPath = new Path(ti.getText(1)); IPath gitPath = new Path(gitDir.toString()); IPath relative = gitPath.makeRelativeTo(projectPath); ti.setText(2, relative.toOSString()); ((ProjectAndRepo) ti.getData()).repo = gitDir.toString(); ti.setChecked(true); } updateControls(); } }); repositoryToCreate = new Text(parentRepoComposite, SWT.SINGLE | SWT.BORDER); repositoryToCreate.setLayoutData( GridDataFactory.fillDefaults().grab(true, false).span(1, 1).create()); repositoryToCreate.addListener( SWT.Modify, new Listener() { public void handleEvent(Event e) { if (repositoryToCreate.getText().equals("")) { // $NON-NLS-1$ createRepo.setEnabled(false); return; } IPath fromOSString = Path.fromOSString(repositoryToCreate.getText()); createRepo.setEnabled( minumumPath.matchingFirstSegments(fromOSString) == fromOSString.segmentCount()); } }); dotGitSegment = new Label(parentRepoComposite, SWT.NONE); dotGitSegment.setEnabled(false); dotGitSegment.setText(File.separatorChar + Constants.DOT_GIT); dotGitSegment.setLayoutData( GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).create()); tree.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { tree.select((TreeItem) e.item); updateControls(); } }); Dialog.applyDialogFont(main); setControl(main); if (allProjectsInExistingRepos) { internalMode = true; internalModeButton.setSelection(true); updateControls(); } }
@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; }
/* * @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; }