private void handleAdd() { IStructuredSelection ssel = (IStructuredSelection) fAvailableListViewer.getSelection(); if (ssel.size() > 0) { Table table = fAvailableListViewer.getTable(); int index = table.getSelectionIndices()[0]; doAdd(ssel.toList()); table.setSelection(index < table.getItemCount() ? index : table.getItemCount() - 1); pageChanged(true, false); } }
private void handleRemove() { IStructuredSelection ssel = (IStructuredSelection) fImportListViewer.getSelection(); if (ssel.size() > 0) { Table table = fImportListViewer.getTable(); int index = table.getSelectionIndices()[0]; doRemove(ssel.toList()); table.setSelection(index < table.getItemCount() ? index : table.getItemCount() - 1); pageChanged(false, true); } }
/* (non-Javadoc) * @see org.eclipse.pde.internal.ui.editor.PDESection#modelChanged(org.eclipse.pde.core.IModelChangedEvent) */ public void modelChanged(IModelChangedEvent e) { // No need to call super, handling world changed event here if (e.getChangeType() == IModelChangedEvent.WORLD_CHANGED) { handleModelEventWorldChanged(e); return; } Object[] objects = e.getChangedObjects(); if (e.getChangeType() == IModelChangedEvent.INSERT) { for (int i = 0; i < objects.length; i++) { if (objects[i] instanceof IProductPlugin) fPluginTable.add(objects[i]); } } else if (e.getChangeType() == IModelChangedEvent.REMOVE) { Table table = fPluginTable.getTable(); int index = table.getSelectionIndex(); for (int i = 0; i < objects.length; i++) { if (objects[i] instanceof IProductPlugin) fPluginTable.remove(objects[i]); } // Update Selection int count = table.getItemCount(); if (count == 0) { // Nothing to select } else if (index < count) { table.setSelection(index); } else { table.setSelection(count - 1); } } else if (e.getChangeType() == IModelChangedEvent.CHANGE) { fPluginTable.refresh(); } updateRemoveButtons(false, true); }