private void createImpTable(Composite container) { fElementViewer = new TableViewer(container, SWT.MULTI | SWT.V_SCROLL | SWT.BORDER); GridData gd = new GridData(GridData.FILL_BOTH); gd.heightHint = 250; fElementViewer.getControl().setLayoutData(gd); fElementViewer.getControl().setFont(container.getFont()); fElementViewer.setContentProvider( new DefaultTableProvider() { public Object[] getElements(Object inputElement) { ITargetDefinition target = getTargetDefinition(); if (target != null) { NameVersionDescriptor[] bundles = target.getImplicitDependencies(); if (bundles != null) { return bundles; } } return new NameVersionDescriptor[0]; } }); fElementViewer.setLabelProvider(new StyledBundleLabelProvider(false, false)); fElementViewer.setInput(PDEPlugin.getDefault()); fElementViewer.setComparator( new ViewerComparator() { public int compare(Viewer viewer, Object e1, Object e2) { NameVersionDescriptor bundle1 = (NameVersionDescriptor) e1; NameVersionDescriptor bundle2 = (NameVersionDescriptor) e2; return super.compare(viewer, bundle1.getId(), bundle2.getId()); } }); fElementViewer.addSelectionChangedListener( new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { updateImpButtons(); } }); fElementViewer .getTable() .addKeyListener( new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.character == SWT.DEL && e.stateMask == 0) { handleRemove(); } } }); }
private void addViewerListeners() { fAvailableListViewer.addDoubleClickListener( new IDoubleClickListener() { @Override public void doubleClick(DoubleClickEvent event) { handleAdd(); } }); fImportListViewer.addDoubleClickListener( new IDoubleClickListener() { @Override public void doubleClick(DoubleClickEvent event) { handleRemove(); } }); fAvailableListViewer.addSelectionChangedListener( new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { updateSelectionBasedEnablement(event.getSelection(), true); } }); fImportListViewer.addSelectionChangedListener( new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { updateSelectionBasedEnablement(event.getSelection(), false); } }); fFilterText.addModifyListener( new ModifyListener() { @Override public void modifyText(ModifyEvent e) { fFilterJob.cancel(); fFilterJob.schedule(200); } }); }