/** * Returns a new drill down viewer for this dialog. * * @param heightHint height hint for the drill down composite */ private void createTreeViewer(int heightHint) { // Create drill down. DrillDownComposite drillDown = new DrillDownComposite(this, SWT.BORDER); GridData spec = new GridData(SWT.FILL, SWT.FILL, true, true); spec.widthHint = SIZING_SELECTION_PANE_WIDTH; spec.heightHint = heightHint; drillDown.setLayoutData(spec); // Create tree viewer inside drill down. treeViewer = new TreeViewer(drillDown, SWT.NONE); drillDown.setChildTree(treeViewer); ChangeLogContainerContentProvider cp = new ChangeLogContainerContentProvider(); cp.showClosedProjects(showClosedProjects); treeViewer.setContentProvider(cp); treeViewer.setLabelProvider(WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider()); treeViewer.setComparator(new ViewerComparator()); treeViewer.setUseHashlookup(true); treeViewer.addSelectionChangedListener( new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); containerSelectionChanged((IContainer) selection.getFirstElement()); // allow null } }); treeViewer.addDoubleClickListener( new IDoubleClickListener() { @Override public void doubleClick(DoubleClickEvent event) { ISelection selection = event.getSelection(); if (selection instanceof IStructuredSelection) { Object item = ((IStructuredSelection) selection).getFirstElement(); if (item == null) { return; } if (treeViewer.getExpandedState(item)) { treeViewer.collapseToLevel(item, 1); } else { treeViewer.expandToLevel(item, 1); } } } }); /* * This helps in displaying all folders under the document * root as well as the actual root itself. */ ChangeLogRootContainer root = new ChangeLogRootContainer(this.initialSelection.getProject()); // This has to be done after the viewer has been laid out treeViewer.setInput(root); }
protected Object createWSILStructure(Composite parent) { // Add WSIL option to button bar fBtnWSIL = createRadioButton( fKindButtonComposite, Messages.SchemaImportDialog_WSIL_Button, BID_BROWSE_WSIL, fImportSource == BID_BROWSE_WSIL); // create WSIL section fWSILComposite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginWidth = 0; fWSILComposite.setLayout(layout); GridData data = new GridData(); data.grabExcessVerticalSpace = true; data.grabExcessHorizontalSpace = true; data.horizontalAlignment = GridData.FILL; data.verticalAlignment = GridData.FILL; data.minimumHeight = 220; fWSILComposite.setLayoutData(data); Label location = new Label(fWSILComposite, SWT.NONE); location.setText(Messages.SchemaImportDialog_Filter_Name_Label); data = new GridData(); data.grabExcessHorizontalSpace = true; data.horizontalAlignment = SWT.LEFT; location.setLayoutData(data); filterText = new Text(fWSILComposite, SWT.BORDER); data = new GridData(GridData.FILL_HORIZONTAL); filterText.setLayoutData(data); filterText.addKeyListener( new KeyListener() { public void keyPressed(KeyEvent e) {} public void keyReleased(KeyEvent e) { // set the value of the filter. fFilter = filterText.getText().trim().toLowerCase(); if (fFilter.length() > 0) { /* for the time being, only filter 3 levels deep * since link references within WSIL are rare at * this time. when adoption of WSIL directories * take off, this needs to be rehashed */ fWSILTreeViewer.expandToLevel(3); } fWSILTreeViewer.refresh(); e.doit = false; } }); DrillDownComposite wsilTreeComposite = new DrillDownComposite(fWSILComposite, SWT.BORDER); layout = new GridLayout(); layout.marginWidth = 0; layout.marginHeight = 0; layout.verticalSpacing = 0; wsilTreeComposite.setLayout(layout); data = new GridData(); data.grabExcessVerticalSpace = true; data.grabExcessHorizontalSpace = true; data.horizontalAlignment = GridData.FILL; data.verticalAlignment = GridData.FILL; wsilTreeComposite.setLayoutData(data); // Tree viewer for variable structure ... fWSILTree = new Tree(wsilTreeComposite, SWT.NONE); data = new GridData(); data.grabExcessVerticalSpace = true; data.grabExcessHorizontalSpace = true; data.horizontalAlignment = GridData.FILL; data.verticalAlignment = GridData.FILL; data.minimumHeight = 200; fWSILTree.setLayoutData(data); fWSILTreeViewer = new TreeViewer(fWSILTree); fWSILTreeViewer.setContentProvider(new WSILContentProvider()); fWSILTreeViewer.setLabelProvider(new ModelLabelProvider()); Object wsilDoc = attemptLoad(URI.createURI(fBasePath), "wsil"); // $NON-NLS-1$ fWSILTreeViewer.setInput(wsilDoc); if (wsilDoc == null || wsilDoc instanceof Throwable) { // fBtnWSIL.setEnabled(false); // that's always available. // delete fImportSource = BID_BROWSE_WORKSPACE; by Grid.Qian // because if not, the dialog always display the resource Control // regardless last time if user choose the resource button /*// that's always available. fImportSource = BID_BROWSE_WORKSPACE;*/ } // set default tree expansion to the 2nd level fWSILTreeViewer.expandToLevel(2); fWSILTreeViewer.addFilter(new TreeFilter()); fWSILTreeViewer.setComparator(new WSILViewerComparator()); wsilTreeComposite.setChildTree(fWSILTreeViewer); fWSILTreeViewer.addSelectionChangedListener( new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection sel = (IStructuredSelection) event.getSelection(); if (sel.getFirstElement() instanceof Service) { Service serv = (Service) sel.getFirstElement(); Description descr = serv.getDescription().get(0); attemptLoad(descr.getLocation()); } else { markEmptySelection(); } } }); // end tree viewer for variable structure return fWSILComposite; }