1 11 package org.eclipse.jdt.internal.debug.ui.actions; 12 13 14 import java.util.Iterator ; 15 16 import org.eclipse.jdt.core.IClasspathEntry; 17 import org.eclipse.jdt.internal.debug.ui.launcher.RuntimeClasspathViewer; 18 import org.eclipse.jdt.launching.IRuntimeClasspathEntry; 19 import org.eclipse.jdt.ui.wizards.BuildPathDialogAccess; 20 import org.eclipse.jface.viewers.IStructuredSelection; 21 import org.eclipse.swt.SWT; 22 23 26 public class AttachSourceAction extends RuntimeClasspathAction { 27 28 private IRuntimeClasspathEntry[] fEntries; 29 30 36 public AttachSourceAction(RuntimeClasspathViewer viewer, int style) { 37 super((style == SWT.RADIO) ? ActionMessages.AttachSourceAction_2 : ActionMessages.AttachSourceAction_3, viewer); } 39 40 45 public void run() { 46 IClasspathEntry classpathEntry = BuildPathDialogAccess.configureSourceAttachment(getShell(), fEntries[0].getClasspathEntry()); 47 if (classpathEntry != null) { 48 for (int i = 0; i < fEntries.length; i++) { 49 IRuntimeClasspathEntry entry = fEntries[i]; 50 entry.setSourceAttachmentPath(classpathEntry.getSourceAttachmentPath()); 51 entry.setSourceAttachmentRootPath(classpathEntry.getSourceAttachmentRootPath()); 52 getViewer().refresh(entry); 53 } 54 getViewer().notifyChanged(); 55 } 56 } 57 58 61 protected boolean updateSelection(IStructuredSelection selection) { 62 fEntries = new IRuntimeClasspathEntry[selection.size()]; 63 Iterator iterator = selection.iterator(); 64 int i = 0; 65 while (iterator.hasNext()) { 66 Object selected= iterator.next(); 67 if (selected instanceof IRuntimeClasspathEntry) { 68 IRuntimeClasspathEntry entry = (IRuntimeClasspathEntry)selected; 69 int type = entry.getType(); 70 switch (type) { 71 case IRuntimeClasspathEntry.VARIABLE: 72 case IRuntimeClasspathEntry.ARCHIVE: 73 fEntries[i] = entry; 74 i++; 75 break; 76 default: 77 return false; 78 } 79 } else { 80 return false; 81 } 82 } 83 return selection.size() > 0; 84 } 85 } 86 | Popular Tags |