1 11 package org.eclipse.pde.internal.ui.editor.plugin; 12 13 import java.io.ByteArrayInputStream ; 14 import java.util.ArrayList ; 15 import java.util.HashSet ; 16 import java.util.Iterator ; 17 import java.util.Vector ; 18 19 import org.eclipse.core.resources.IFile; 20 import org.eclipse.core.resources.IProject; 21 import org.eclipse.core.resources.IResource; 22 import org.eclipse.core.resources.ProjectScope; 23 import org.eclipse.core.runtime.CoreException; 24 import org.eclipse.core.runtime.NullProgressMonitor; 25 import org.eclipse.core.runtime.preferences.IEclipsePreferences; 26 import org.eclipse.jface.action.Action; 27 import org.eclipse.jface.action.IAction; 28 import org.eclipse.jface.action.IMenuManager; 29 import org.eclipse.jface.action.Separator; 30 import org.eclipse.jface.action.ToolBarManager; 31 import org.eclipse.jface.util.IPropertyChangeListener; 32 import org.eclipse.jface.util.PropertyChangeEvent; 33 import org.eclipse.jface.viewers.ISelection; 34 import org.eclipse.jface.viewers.IStructuredSelection; 35 import org.eclipse.jface.viewers.ITableLabelProvider; 36 import org.eclipse.jface.viewers.TableViewer; 37 import org.eclipse.jface.window.Window; 38 import org.eclipse.pde.core.IBaseModel; 39 import org.eclipse.pde.core.IModelChangedEvent; 40 import org.eclipse.pde.core.IModelChangedListener; 41 import org.eclipse.pde.core.build.IBuild; 42 import org.eclipse.pde.core.build.IBuildEntry; 43 import org.eclipse.pde.core.build.IBuildModel; 44 import org.eclipse.pde.core.plugin.IPluginModel; 45 import org.eclipse.pde.core.plugin.IPluginModelBase; 46 import org.eclipse.pde.core.plugin.PluginRegistry; 47 import org.eclipse.pde.internal.core.ICoreConstants; 48 import org.eclipse.pde.internal.core.IPluginModelListener; 49 import org.eclipse.pde.internal.core.PDECore; 50 import org.eclipse.pde.internal.core.PluginModelDelta; 51 import org.eclipse.pde.internal.core.ibundle.IBundlePluginModel; 52 import org.eclipse.pde.internal.core.ibundle.IBundlePluginModelBase; 53 import org.eclipse.pde.internal.core.plugin.ExternalPluginModel; 54 import org.eclipse.pde.internal.core.plugin.WorkspacePluginModel; 55 import org.eclipse.pde.internal.ui.PDEPlugin; 56 import org.eclipse.pde.internal.ui.PDEPluginImages; 57 import org.eclipse.pde.internal.ui.PDEUIMessages; 58 import org.eclipse.pde.internal.ui.editor.FormLayoutFactory; 59 import org.eclipse.pde.internal.ui.editor.PDEFormEditor; 60 import org.eclipse.pde.internal.ui.editor.PDEFormPage; 61 import org.eclipse.pde.internal.ui.editor.TableSection; 62 import org.eclipse.pde.internal.ui.editor.actions.SortAction; 63 import org.eclipse.pde.internal.ui.editor.build.BuildInputContext; 64 import org.eclipse.pde.internal.ui.editor.context.InputContext; 65 import org.eclipse.pde.internal.ui.elements.DefaultTableProvider; 66 import org.eclipse.pde.internal.ui.parts.TablePart; 67 import org.eclipse.pde.internal.ui.search.dependencies.AddNewDependenciesAction; 68 import org.eclipse.pde.internal.ui.util.SharedLabelProvider; 69 import org.eclipse.pde.internal.ui.wizards.PluginSelectionDialog; 70 import org.eclipse.swt.SWT; 71 import org.eclipse.swt.events.DisposeEvent; 72 import org.eclipse.swt.events.DisposeListener; 73 import org.eclipse.swt.events.SelectionAdapter; 74 import org.eclipse.swt.events.SelectionEvent; 75 import org.eclipse.swt.graphics.Cursor; 76 import org.eclipse.swt.graphics.Image; 77 import org.eclipse.swt.layout.GridData; 78 import org.eclipse.swt.layout.GridLayout; 79 import org.eclipse.swt.widgets.Button; 80 import org.eclipse.swt.widgets.Composite; 81 import org.eclipse.swt.widgets.Control; 82 import org.eclipse.swt.widgets.Display; 83 import org.eclipse.swt.widgets.Table; 84 import org.eclipse.swt.widgets.ToolBar; 85 import org.eclipse.ui.actions.ActionFactory; 86 import org.eclipse.ui.forms.events.HyperlinkAdapter; 87 import org.eclipse.ui.forms.events.HyperlinkEvent; 88 import org.eclipse.ui.forms.widgets.ExpandableComposite; 89 import org.eclipse.ui.forms.widgets.FormText; 90 import org.eclipse.ui.forms.widgets.FormToolkit; 91 import org.eclipse.ui.forms.widgets.Section; 92 import org.eclipse.ui.part.FileEditorInput; 93 import org.osgi.service.prefs.BackingStoreException; 94 95 public class DependencyManagementSection extends TableSection implements IModelChangedListener, IPluginModelListener, IPropertyChangeListener { 96 97 private TableViewer fAdditionalTable; 98 private Vector fAdditionalBundles; 99 private Action fNewAction; 100 private Action fRemoveAction; 101 private Action fOpenAction; 102 private Action fSortAction; 103 private Button fRequireBundleButton; 104 private Button fImportPackageButton; 105 private IProject fProject; 106 107 private static final int ADD_INDEX = 0; 108 private static final int REMOVE_INDEX = 1; 109 private static final int UP_INDEX = 2; 110 private static final int DOWN_INDEX = 3; 111 112 private static String ADD = PDEUIMessages.RequiresSection_add; 113 private static String REMOVE = PDEUIMessages.RequiresSection_delete; 114 private static String OPEN = PDEUIMessages.RequiresSection_open; 115 private static String UP = PDEUIMessages.RequiresSection_up; 116 private static String DOWN = PDEUIMessages.RequiresSection_down; 117 118 class ContentProvider extends DefaultTableProvider { 119 120 123 public Object [] getElements(Object inputElement) { 124 if (fAdditionalBundles == null) 125 return createAdditionalBundles(); 126 return fAdditionalBundles.toArray(); 127 } 128 129 private IBuildEntry getBuildInfo() { 130 IBuildEntry entry = null; 131 IBuildModel model = getBuildModel(false); 132 if (model == null) 133 return null; 134 IBuild buildObject = model.getBuild(); 135 entry = buildObject.getEntry(IBuildEntry.SECONDARY_DEPENDENCIES); 136 return entry; 137 } 138 139 private Object [] createAdditionalBundles() { 140 IBuildEntry entry = getBuildInfo(); 141 try { 142 if (entry != null) { 143 String [] tokens = entry.getTokens(); 144 fAdditionalBundles = new Vector (tokens.length); 145 for (int i = 0; i < tokens.length; i++) { 146 fAdditionalBundles.add(tokens[i].trim()); 147 } 148 return fAdditionalBundles.toArray(); 149 } 150 return new Object [0]; 151 } catch (Exception e) { 152 PDEPlugin.logException( e ); 153 return new Object [0]; } 155 } 156 } 157 158 class SecondaryTableLabelProvider extends SharedLabelProvider 159 implements ITableLabelProvider { 160 public String getColumnText(Object obj, int index) { 161 return obj.toString(); 162 } 163 164 public Image getColumnImage(Object obj, int index) { 165 String pluginID = obj.toString(); 166 IPluginModelBase model = PluginRegistry.findModel(pluginID); 167 if (model == null) 168 { 169 return get(PDEPluginImages.DESC_REQ_PLUGIN_OBJ, F_ERROR); 170 } 171 else if (model instanceof IBundlePluginModel || model instanceof WorkspacePluginModel) 172 { 173 return get(PDEPluginImages.DESC_REQ_PLUGIN_OBJ); 174 } 175 else if (model instanceof ExternalPluginModel) 176 { 177 return get(PDEPluginImages.DESC_PLUGIN_OBJ, F_EXTERNAL); 178 } 179 return null; 180 } 181 } 182 183 public DependencyManagementSection(PDEFormPage formPage, Composite parent) { 184 super(formPage, parent, ExpandableComposite.TWISTIE|ExpandableComposite.COMPACT, new String [] { ADD, REMOVE, UP, DOWN}); 185 IBuildModel model = getBuildModel(false); 186 if (model != null) { 187 IBuildEntry entry = model.getBuild().getEntry(IBuildEntry.SECONDARY_DEPENDENCIES); 188 if (entry != null && entry.getTokens().length > 0) 189 getSection().setExpanded(true); 190 } 191 } 192 193 protected void createClient(Section section, FormToolkit toolkit) { 194 FormText text = toolkit.createFormText(section, true); 195 text.setText(PDEUIMessages.SecondaryBundlesSection_desc, false, false); 196 section.setDescriptionControl(text); 197 198 Composite container = createClientContainer(section, 2, toolkit); 199 createViewerPartControl(container, SWT.MULTI, 2, toolkit); 200 TablePart tablePart = getTablePart(); 201 fAdditionalTable = tablePart.getTableViewer(); 202 203 fAdditionalTable.setContentProvider(new ContentProvider()); 204 fAdditionalTable.setLabelProvider(new SecondaryTableLabelProvider()); 205 GridData gd = (GridData)fAdditionalTable.getTable().getLayoutData(); 206 gd.heightHint = 150; 207 fAdditionalTable.getTable().setLayoutData(gd); 208 209 gd = new GridData(); 210 gd.horizontalSpan = 2; 211 FormText resolveText = toolkit.createFormText(container, true); 212 resolveText.setText(PDEUIMessages.SecondaryBundlesSection_resolve, true, true); 213 resolveText.setLayoutData(gd); 214 resolveText.addHyperlinkListener(new HyperlinkAdapter() { 215 public void linkActivated(HyperlinkEvent e) { 216 doAddDependencies(); 217 } 218 }); 219 220 Composite comp = toolkit.createComposite(container); 221 comp.setLayout(new GridLayout(2, false)); 222 gd = new GridData(); 223 gd.horizontalSpan = 2; 224 comp.setLayoutData(gd); 225 226 fRequireBundleButton = toolkit.createButton(comp, "Require-Bundle", SWT.RADIO); gd = new GridData(); 228 gd.horizontalIndent = 20; 229 fRequireBundleButton.setLayoutData(gd); 230 fRequireBundleButton.addSelectionListener(new SelectionAdapter() { 231 public void widgetSelected(SelectionEvent e) { 232 savePreferences(); 233 } 234 }); 235 236 fImportPackageButton = toolkit.createButton(comp, "Import-Package", SWT.RADIO); gd = new GridData(); 238 gd.horizontalIndent = 20; 239 fImportPackageButton.setLayoutData(gd); 240 241 toolkit.paintBordersFor(container); 242 makeActions(); 243 section.setClient(container); 244 section.setLayout(FormLayoutFactory.createClearGridLayout(false, 1)); 245 section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 246 section.setText(PDEUIMessages.SecondaryBundlesSection_title); 247 createSectionToolbar(section, toolkit); 248 initialize(); 249 } 250 251 private void createSectionToolbar(Section section, FormToolkit toolkit) { 252 ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT); 253 ToolBar toolbar = toolBarManager.createControl(section); 254 final Cursor handCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND); 255 toolbar.setCursor(handCursor); 256 toolbar.addDisposeListener(new DisposeListener() { 258 public void widgetDisposed(DisposeEvent e) { 259 if ((handCursor != null) && 260 (handCursor.isDisposed() == false)) { 261 handCursor.dispose(); 262 } 263 } 264 }); 265 266 fSortAction = new SortAction(getTablePart().getTableViewer(), 268 PDEUIMessages.RequiresSection_sortAlpha, null, null, this); 269 toolBarManager.add(fSortAction); 270 271 toolBarManager.update(true); 272 273 section.setTextClient(toolbar); 274 } 275 276 private void savePreferences() { 277 if (fProject == null) { 278 IPluginModelBase model = (IPluginModelBase) getPage().getModel(); 279 IResource resource = model.getUnderlyingResource(); 280 if (resource == null) 281 return; 282 fProject = resource.getProject(); 283 } 284 IEclipsePreferences pref = new ProjectScope(fProject).getNode(PDECore.PLUGIN_ID); 285 286 if (fImportPackageButton.getSelection()) 287 pref.putBoolean(ICoreConstants.RESOLVE_WITH_REQUIRE_BUNDLE, false); 288 else 289 pref.remove(ICoreConstants.RESOLVE_WITH_REQUIRE_BUNDLE); 290 try { 291 pref.flush(); 292 } catch (BackingStoreException e) { 293 PDEPlugin.logException(e); 294 } 295 } 296 297 private void initialize() { 298 try { 299 IPluginModelBase model = (IPluginModelBase) getPage().getModel(); 300 fAdditionalTable.setInput(model.getPluginBase()); 301 TablePart part = getTablePart(); 302 part.setButtonEnabled(0, model.isEditable()); 303 part.setButtonEnabled(1, false); 304 part.setButtonEnabled(2, false); 305 part.setButtonEnabled(3, false); 306 307 IBuildModel build = getBuildModel(false); 308 if (build != null) 309 build.addModelChangedListener(this); 310 311 IResource resource = model.getUnderlyingResource(); 312 if (resource == null) 313 return; 314 fProject = resource.getProject(); 315 IEclipsePreferences pref = new ProjectScope(fProject).getNode(PDECore.PLUGIN_ID); 316 if (pref != null) { 317 boolean useRequireBundle = pref.getBoolean(ICoreConstants.RESOLVE_WITH_REQUIRE_BUNDLE, true); 318 fRequireBundleButton.setSelection(useRequireBundle); 319 fImportPackageButton.setSelection(!useRequireBundle); 320 } 321 PDECore.getDefault().getModelManager().addPluginModelListener(this); 322 } catch (Exception e){ 323 PDEPlugin.logException(e); 324 } 325 } 326 327 protected void fillContextMenu(IMenuManager manager) { 328 ISelection selection = fAdditionalTable.getSelection(); 329 manager.add(fNewAction); 330 manager.add(fOpenAction); 331 manager.add(new Separator()); 332 333 if (!selection.isEmpty()) 334 manager.add(fRemoveAction); 335 336 getPage().getPDEEditor().getContributor().contextMenuAboutToShow(manager); 338 } 339 340 public void refresh() { 341 fAdditionalBundles = null; 342 if (!fAdditionalTable.getControl().isDisposed()) 343 fAdditionalTable.refresh(); 344 super.refresh(); 345 } 346 347 protected void buttonSelected(int index) { 348 switch (index){ 349 case ADD_INDEX: 350 handleNew(); 351 break; 352 case REMOVE_INDEX: 353 handleRemove(); 354 break; 355 case UP_INDEX: 356 handleUp(); 357 break; 358 case DOWN_INDEX: 359 handleDown(); 360 break; 361 } 362 } 363 364 protected void handleDoubleClick(IStructuredSelection sel) { 365 handleOpen(sel); 366 } 367 368 private void handleOpen(ISelection sel) { 369 if (sel instanceof IStructuredSelection) { 370 IStructuredSelection ssel = (IStructuredSelection) sel; 371 if (ssel.size() == 1) { 372 Object obj = ssel.getFirstElement(); 373 IPluginModelBase base = PluginRegistry.findModel((String )obj); 374 if (base != null) 375 ManifestEditor.open(base.getPluginBase(), false); 376 } 377 } 378 } 379 380 private IBuildModel getBuildModel(boolean createIfMissing) { 381 InputContext context = getPage().getPDEEditor().getContextManager() 382 .findContext(BuildInputContext.CONTEXT_ID); 383 if (context == null) { 384 if (createIfMissing) { 385 IFile buildFile = getPage().getPDEEditor().getCommonProject().getFile("build.properties"); try { 387 buildFile.create(new ByteArrayInputStream (new byte[0]), true, new NullProgressMonitor()); 388 } catch (CoreException e ) { 389 return null; 390 } 391 FileEditorInput in = new FileEditorInput(buildFile); 392 PDEFormEditor editor = getPage().getPDEEditor(); 393 context = new BuildInputContext(getPage().getPDEEditor(), in, 394 false); 395 editor.getContextManager().putContext(in, context); 396 } else 397 return null; 398 } 399 return (IBuildModel) context.getModel(); 400 } 401 402 private void makeActions() { 403 fNewAction = new Action( ADD ){ 404 public void run() { 405 handleNew(); 406 } 407 }; 408 409 fOpenAction = new Action( OPEN ) { 410 public void run() { 411 handleOpen(fAdditionalTable.getSelection()); 412 } 413 }; 414 415 fRemoveAction = new Action (REMOVE) { 416 public void run() { 417 handleRemove(); 418 } 419 }; 420 } 421 422 private void handleNew(){ 423 PluginSelectionDialog dialog = 424 new PluginSelectionDialog( 425 PDEPlugin.getActiveWorkbenchShell(), 426 getAvailablePlugins(), 427 true); 428 dialog.create(); 429 if (dialog.open() == Window.OK) { 430 IBuildModel model = getBuildModel(true); 431 IBuild build = model.getBuild(); 432 IBuildEntry entry = build.getEntry(IBuildEntry.SECONDARY_DEPENDENCIES); 433 try { 434 if (entry == null) { 435 entry = model.getFactory().createEntry(IBuildEntry.SECONDARY_DEPENDENCIES); 436 build.add(entry); 437 } 438 Object [] models = dialog.getResult(); 439 440 for (int i = 0; i < models.length; i++) { 441 IPluginModel pmodel = (IPluginModel) models[i]; 442 entry.addToken(pmodel.getPlugin().getId()); 443 } 444 markDirty(); 445 }catch (CoreException e) { 446 PDEPlugin.logException( e ); 447 } 448 } 449 } 450 451 private IPluginModelBase[] getAvailablePlugins() { 452 IPluginModelBase[] plugins = PluginRegistry.getActiveModels(false); 453 HashSet currentPlugins = new HashSet ( 454 (fAdditionalBundles == null) ? new Vector (1) : fAdditionalBundles); 455 IProject currentProj = getPage().getPDEEditor().getCommonProject(); 456 IPluginModelBase model = PluginRegistry.findModel(currentProj); 457 if (model != null) { 458 currentPlugins.add(model.getPluginBase().getId()); 459 } 460 461 ArrayList result = new ArrayList (); 462 for (int i = 0; i < plugins.length; i++){ 463 if (!currentPlugins.contains(plugins[i].getPluginBase().getId())) 464 result.add(plugins[i]); 465 } 466 return (IPluginModelBase []) result.toArray(new IPluginModelBase[result.size()]); 467 } 468 469 private void handleRemove(){ 470 IStructuredSelection ssel = (IStructuredSelection) fAdditionalTable.getSelection(); 471 472 IBuild build = getBuildModel(false).getBuild(); 473 IBuildEntry entry = build.getEntry(IBuildEntry.SECONDARY_DEPENDENCIES); 474 Iterator it = ssel.iterator(); 475 try { 476 while (it.hasNext()) { 477 String pluginName = (String ) it.next(); 478 entry.removeToken(pluginName); 479 } 480 if (entry.getTokens().length == 0) 481 build.remove(entry); 482 } catch (CoreException e){ 483 PDEPlugin.logException( e ); 484 } 485 refresh(); 486 markDirty(); 487 } 488 489 492 protected void selectionChanged(IStructuredSelection sel) { 493 getPage().getPDEEditor().setSelection(sel); 495 updateButtons(); 496 } 497 498 private void updateButtons() { 499 TablePart part = getTablePart(); 500 Table table = fAdditionalTable.getTable(); 501 int index = table.getSelectionIndex(); 502 part.setButtonEnabled(1, index != -1); 503 updateUpDownButtons(); 504 } 505 506 public void modelChanged(IModelChangedEvent event) { 507 if (event.getChangeType() == IModelChangedEvent.WORLD_CHANGED) { 508 markStale(); 509 return; 510 } 511 Object changedObject = event.getChangedObjects()[0]; 512 if ((changedObject instanceof IBuildEntry && 513 ((IBuildEntry) changedObject).getName().equals(IBuildEntry.SECONDARY_DEPENDENCIES))) { 514 refresh(); 515 } 516 } 517 518 521 public boolean doGlobalAction(String actionId) { 522 523 if (!isEditable()) { return false; } 524 525 if (actionId.equals(ActionFactory.DELETE.getId())) { 526 handleRemove(); 527 return true; 528 } 529 if (actionId.equals(ActionFactory.CUT.getId())) { 530 handleRemove(); 533 return false; 534 } 535 if (actionId.equals(ActionFactory.PASTE.getId())) { 536 doPaste(); 537 return true; 538 } 539 return false; 540 541 } 542 543 546 protected boolean canPaste(Object targetObject, Object [] sourceObjects) { 547 HashSet secondaryDepSet = null; 548 for (int i = 0; i < sourceObjects.length; i++) { 551 if ((sourceObjects[i] instanceof String ) == false) { 553 return false; 554 } 555 if (secondaryDepSet == null) { 558 secondaryDepSet = createSecondaryDepSet(); 559 } 560 String secondaryDep = (String )sourceObjects[i]; 562 if (secondaryDepSet.contains(secondaryDep)) { 563 return false; 564 } 565 } 566 return true; 567 } 568 569 572 private HashSet createSecondaryDepSet() { 573 HashSet secondaryDepSet = new HashSet (); 574 IBuildModel buildModel = getBuildModel(true); 576 if (buildModel == null) { 578 return secondaryDepSet; 579 } 580 IBuild build = buildModel.getBuild(); 582 IBuildEntry entry = build.getEntry(IBuildEntry.SECONDARY_DEPENDENCIES); 584 if (entry == null) { 586 return secondaryDepSet; 587 } 588 String [] tokens = entry.getTokens(); 590 if (tokens.length == 0) { 592 return secondaryDepSet; 593 } 594 for (int i = 0; i < tokens.length; i++) { 596 secondaryDepSet.add(tokens[i]); 597 } 598 return secondaryDepSet; 599 } 600 601 604 protected void doPaste(Object targetObject, Object [] sourceObjects) { 605 IBuildModel buildModel = getBuildModel(true); 607 if (buildModel == null) { 609 return; 610 } 611 IBuild build = buildModel.getBuild(); 613 IBuildEntry entry = build.getEntry(IBuildEntry.SECONDARY_DEPENDENCIES); 615 try { 616 for (int i = 0; i < sourceObjects.length; i++) { 618 Object sourceObject = sourceObjects[i]; 619 if (sourceObject instanceof String ) { 620 if (entry == null) { 622 entry = buildModel.getFactory().createEntry(IBuildEntry.SECONDARY_DEPENDENCIES); 623 build.add(entry); 624 } 625 entry.addToken((String )sourceObject); 627 } 628 } 629 } catch (CoreException e) { 630 PDEPlugin.logException(e); 631 } 632 } 633 634 protected void doAddDependencies() { 635 IBaseModel model = getPage().getModel(); 636 if (model instanceof IBundlePluginModelBase) { 637 IProject proj = getPage().getPDEEditor().getCommonProject(); 638 IBundlePluginModelBase bmodel = ((IBundlePluginModelBase)model); 639 AddNewDependenciesAction action = new AddNewDependenciesAction(proj, bmodel); 640 action.run(); 641 } 642 } 643 644 public void dispose() { 645 IPluginModelBase model = (IPluginModelBase) getPage().getModel(); 646 if (model!=null) 647 model.removeModelChangedListener(this); 648 PDECore.getDefault().getModelManager().removePluginModelListener(this); 649 super.dispose(); 650 } 651 652 public void modelsChanged(PluginModelDelta delta) { 653 fAdditionalBundles = null; 654 final Control control = fAdditionalTable.getControl(); 655 if (!control.isDisposed()) { 656 control.getDisplay().asyncExec(new Runnable () { 657 public void run() { 658 if (!control.isDisposed()) 659 fAdditionalTable.refresh(); 660 } 661 }); 662 } 663 } 664 665 private void handleUp() { 666 movePlugins(-1); 667 } 668 669 private void handleDown() { 670 movePlugins(1); 671 } 672 673 private void updateUpDownButtons() { 674 TablePart tablePart = getTablePart(); 675 if (fSortAction.isChecked()) { 676 tablePart.setButtonEnabled(UP_INDEX, false); 677 tablePart.setButtonEnabled(DOWN_INDEX, false); 678 return; 679 } 680 Table table = fAdditionalTable.getTable(); 681 int index = table.getSelectionIndex(); 682 int totalElems = table.getItemCount(); 683 boolean canMove = totalElems > 1 && table.getSelectionCount() == 1; 684 tablePart.setButtonEnabled(2, canMove && index > 0); 685 tablePart.setButtonEnabled(3, canMove && index >= 0 && index < totalElems - 1); 686 } 687 688 private void movePlugins(int newOffset) { 689 int index = fAdditionalTable.getTable().getSelectionIndex(); 690 if (index == -1) 691 return; IBuildModel model = getBuildModel(false); 693 if (model != null) { 694 IBuild build = model.getBuild(); 695 IBuildEntry entry = build.getEntry(IBuildEntry.SECONDARY_DEPENDENCIES); 696 if (entry instanceof org.eclipse.pde.internal.core.text.build.BuildEntry) 697 ((org.eclipse.pde.internal.core.text.build.BuildEntry)entry).swap(index, index + newOffset); 698 } 699 updateButtons(); 700 } 701 702 public void propertyChange(PropertyChangeEvent event) { 703 if (fSortAction.equals(event.getSource()) && IAction.RESULT.equals(event.getProperty())) { 704 updateUpDownButtons(); 705 } 706 } 707 708 protected boolean createCount() { return true; } 709 } 710 | Popular Tags |