protected void newFolderButtonPressed() { Object createdFolder = createFolder(fSelectedContainer); if (createdFolder != null) { CheckboxTreeViewer treeViewer = fViewer; treeViewer.refresh(fSelectedContainer); treeViewer.reveal(createdFolder); treeViewer.setChecked(createdFolder, true); treeViewer.setSelection(new StructuredSelection(createdFolder)); updateOKStatus(); } }
protected void forceExistingChecked(CheckStateChangedEvent event) { if (fExisting != null) { Object elem = event.getElement(); if (fExisting.contains(elem)) { fViewer.setChecked(elem, true); } } }
private void updateNewFolderButtonState() { IStructuredSelection selection = (IStructuredSelection) fViewer.getSelection(); fSelectedContainer = null; if (selection.size() == 1) { Object first = selection.getFirstElement(); if (first instanceof IContainer) { fSelectedContainer = (IContainer) first; } } fNewFolderButton.setEnabled(fSelectedContainer != null); }
/* * @see SelectionStatusDialog#computeResult() */ protected void computeResult() { Object[] checked = fViewer.getCheckedElements(); if (fExisting == null) { if (checked.length == 0) { checked = null; } } else { ArrayList res = new ArrayList(); for (int i = 0; i < checked.length; i++) { Object elem = checked[i]; if (!fExisting.contains(elem)) { res.add(elem); } } if (!res.isEmpty()) { checked = res.toArray(); } else { checked = null; } } setSelectionResult(checked); }
/* * (non-Javadoc) * * @see * org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets * .Composite) */ 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()); Button button = new Button(composite, SWT.PUSH); button.setText(NewWizardMessages.MultipleFolderSelectionDialog_button); button.addSelectionListener( new SelectionAdapter() { 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 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((ViewerFilter) fFilters.get(i)); } fViewer.setInput(fInput); return fViewer; }