Bug 4155 Source Attachment wizard for variable classpath entries not correct (1GJ6X9P)
(1) Create a directory containing a .jar file and a .zip source archive for the jar The .zip archive should have a non-null root path to the source. (2) create a classpath variable which points to this directory (3) place this .jar file in your classpath using the variable (4) use the Java Source Attachment wizard to set the source archive Attempt to use the "root variable path". The "browse..." button is inactive unless the text field is non-empty. If the text field is non-empty, pressing the browse... button shows the source archive no matter what is in the field. If you make a selection in the paths shown that are relative to the archive, any path that is deeper than the first is entered without the intervening path variables. For example, suppose the archive resolves to c:\blort\blort.zip. I can type "junk" in the root variable path field to activate the "browse..." button. Pressing "browse..." shows the structure of "c:\blort\blort.zip". If I select work/src/main as the source root directory in blort.zip for blort.jar and press OK the text field for "root variable path" now reads: junk/main. NOTES:
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/buildpaths/SourceAttachmentBlock.java
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.ui.model.WorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.dialogs.ElementTreeSelectionDialog;
import org.eclipse.jdt.internal.ui.dialogs.ISelectionValidator;
import org.eclipse.jdt.internal.ui.dialogs.StatusInfo;
import org.eclipse.jdt.internal.ui.dialogs.StatusUtil;
import org.eclipse.jdt.internal.ui.util.SWTUtil;
import org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener;
import org.eclipse.jdt.internal.ui.wizards.NewWizardMessages;
import org.eclipse.jdt.internal.ui.wizards.TypedElementSelectionValidator;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.IStringButtonAdapter;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.SelectionButtonDialogField;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.StringButtonDialogField;
import org.eclipse.jdt.internal.ui.wizards.swt.MGridData;
import org.eclipse.jdt.internal.ui.wizards.swt.MGridLayout;
/**
 * UI to set the source attachment archive and root.
 * Same implementation for both setting attachments for libraries from
 * variable entries and for normal (internal or external) jar.
 */
public class SourceAttachmentBlock {