protected void initializeViewer() { Object[] elems = fSelection.toArray(); ArrayList checked = new ArrayList(elems.length); for (int i = 0; i < elems.length; i++) { Object elem = elems[i]; IProject project = null; if (elem instanceof IFile) { IFile file = (IFile) elem; project = file.getProject(); } else if (elem instanceof IProject) { project = (IProject) elem; } else if (elem instanceof IJavaProject) { project = ((IJavaProject) elem).getProject(); } if (project != null) { IModel model = findModelFor(project); if (model != null && !checked.contains(model)) { checked.add(model); } } } fExportPart.setSelection(checked.toArray()); if (checked.size() > 0) fExportPart.getTableViewer().reveal(checked.get(0)); }
protected void createViewer(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.numColumns = 3; layout.marginHeight = 0; layout.marginWidth = 0; composite.setLayout(layout); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); fExportPart.createControl(composite); GridData gd = (GridData) fExportPart.getControl().getLayoutData(); gd.heightHint = 125; gd.widthHint = 150; gd.horizontalSpan = 2; TableViewer viewer = fExportPart.getTableViewer(); viewer.setContentProvider(new ExportListProvider()); viewer.setLabelProvider(PDEPlugin.getDefault().getLabelProvider()); viewer.setComparator(ListUtil.PLUGIN_COMPARATOR); viewer.addDoubleClickListener( new IDoubleClickListener() { public void doubleClick(DoubleClickEvent event) { if (event.getSource() instanceof CheckboxTableViewer) { IStructuredSelection selection = (IStructuredSelection) event.getSelection(); ((CheckboxTableViewer) event.getSource()) .setChecked( selection.getFirstElement(), !((CheckboxTableViewer) event.getSource()) .getChecked(selection.getFirstElement())); fExportPart.updateCounter( ((CheckboxTableViewer) event.getSource()).getCheckedElements().length); } } }); fExportPart.getTableViewer().setInput(getInput()); }