Changeset 1111 for oranda_4-14-08

Show
Ignore:
Timestamp:
04/17/08 00:03:23 (4 years ago)
Author:
oranda
Message:

--

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • oranda_4-14-08/descent.ui/.classpath

    r152 r1111  
    11<?xml version="1.0" encoding="UTF-8"?> 
    22<classpath> 
    3     <classpathentry kind="src" path="src"/> 
     3    <classpathentry excluding="descent/internal/debug/ui/jres/LibraryStandin.java" kind="src" path="src"/> 
    44    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> 
    55    <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> 
  • oranda_4-14-08/descent.ui/src/descent/internal/corext/util/JavaModelUtil.java

    r1080 r1111  
    6363import descent.internal.corext.ValidateEditException; 
    6464import descent.internal.ui.JavaUIStatus; 
    65 import descent.launching.IVMInstall; 
     65import descent.launching.ICompilerInstall; 
    6666 
    6767/** 
     
    829829    /* TODO JDT UI jdk 
    830830    public static boolean is50OrHigherJRE(IJavaProject project) throws CoreException { 
    831         IVMInstall vmInstall= JavaRuntime.getVMInstall(project); 
     831        ICompilerInstall vmInstall= JavaRuntime.getVMInstall(project); 
    832832        if (!(vmInstall instanceof IVMInstall2)) 
    833833            return true; // assume 5.0. 
     
    10181018    } 
    10191019     
    1020     public static String getCompilerCompliance(IVMInstall vMInstall, String defaultCompliance) { 
    1021         String version= vMInstall.getJavaVersion(); 
     1020    public static String getCompilerCompliance(ICompilerInstall compilerInstall, String defaultCompliance) { 
     1021        String version= compilerInstall.getJavaVersion(); 
    10221022        if (version == null) { 
    10231023            return defaultCompliance; 
  • oranda_4-14-08/descent.ui/src/descent/internal/debug/ui/jres/AddCompilerDialog.java

    r1029 r1111  
    11package descent.internal.debug.ui.jres; 
    2  
    32 
    43import java.io.File; 
     
    2221import org.eclipse.swt.widgets.Label; 
    2322import org.eclipse.swt.widgets.Shell; 
     23import org.eclipse.swt.widgets.TabFolder; 
     24import org.eclipse.swt.widgets.TabItem; 
    2425import org.eclipse.swt.widgets.Text; 
    2526import org.eclipse.ui.PlatformUI; 
     
    3738import descent.internal.ui.wizards.dialogfields.StringDialogField; 
    3839import descent.launching.AbstractVMInstallType; 
    39 import descent.launching.IVMInstall; 
    40 import descent.launching.IVMInstallType; 
     40import descent.launching.ICompilerInstall; 
     41import descent.launching.ICompilerInstallType; 
    4142import descent.launching.VMStandin; 
    4243 
    43 public class AddVMDialog extends StatusDialog { 
    44  
    45     private IAddVMDialogRequestor fRequestor; 
    46      
    47     private IVMInstall fEditedVM; 
    48  
    49     private IVMInstallType[] fVMTypes; 
    50     private IVMInstallType fSelectedVMType; 
    51      
    52     private ComboDialogField fVMTypeCombo; 
    53     private VMLibraryBlock fLibraryBlock; 
    54      
    55     private StringButtonDialogField fJRERoot; 
    56     private StringDialogField fVMName; 
    57  
    58     // the VM install's javadoc location 
    59     private URL fJavadocLocation = null; 
    60     private boolean fAutoDetectJavadocLocation = false; 
    61      
    62     private IStatus[] fStati; 
    63     private int fPrevIndex = -1; 
    64          
    65     public AddVMDialog(IAddVMDialogRequestor requestor, Shell shell, IVMInstallType[] vmInstallTypes, IVMInstall editedVM) { 
    66         super(shell); 
    67         setShellStyle(getShellStyle() | SWT.RESIZE); 
    68         fRequestor= requestor; 
    69         fStati= new IStatus[5]; 
    70         for (int i= 0; i < fStati.length; i++) { 
    71             fStati[i]= new StatusInfo(); 
     44/** 
     45 * Dialog that allows the user to add or edit compiler definitions. 
     46 *  
     47 * @author oranda 
     48 * 
     49 */ 
     50public class AddCompilerDialog extends StatusDialog 
     51
     52    private IAddCompilerDialogRequestor fRequestor; 
     53 
     54    private ICompilerInstall fEditedCompiler; 
     55 
     56    private ICompilerInstallType[] fCompilerTypes; 
     57 
     58    private ICompilerInstallType fSelectedCompilerType; 
     59 
     60    private ComboDialogField fCompilerTypeCombo; 
     61 
     62    private CompilerDirectoryBlock fSourceDirectoryBlock; 
     63     
     64    private CompilerDirectoryBlock fLibraryDirectoryBlock; 
     65     
     66    private CompilerDirectoryBlock fExecutableDirectoryBlock; 
     67     
     68    private TabFolder tabFolder; 
     69 
     70    private StringButtonDialogField fCompilerExecutable; 
     71 
     72    private StringDialogField fCompilerName; 
     73 
     74    // the VM install's javadoc location 
     75    private URL fJavadocLocation = null; 
     76 
     77    private boolean fAutoDetectJavadocLocation = false; 
     78 
     79    private IStatus[] fStati; 
     80 
     81    private int fPrevIndex = -1; 
     82 
     83    public AddCompilerDialog(IAddCompilerDialogRequestor requestor, Shell shell, 
     84        ICompilerInstallType[] compilerInstallTypes, ICompilerInstall editedCompiler) 
     85    { 
     86    super(shell); 
     87    setShellStyle(getShellStyle() | SWT.RESIZE); 
     88    fRequestor = requestor; 
     89    fStati = new IStatus[5]; 
     90    for (int i = 0; i < fStati.length; i++) 
     91    { 
     92        fStati[i] = new StatusInfo(); 
     93    } 
     94 
     95    fCompilerTypes = compilerInstallTypes; 
     96    fSelectedCompilerType = editedCompiler != null ? editedCompiler.getVMInstallType() 
     97        : compilerInstallTypes[0]; 
     98 
     99    fEditedCompiler = editedCompiler; 
     100 
     101    //only detect the javadoc location if not already set 
     102    fAutoDetectJavadocLocation = fEditedCompiler == null 
     103        || fEditedCompiler.getJavadocLocation() == null; 
     104    } 
     105 
     106    /** 
     107     * @see Windows#configureShell 
     108     */ 
     109    protected void configureShell(Shell newShell) 
     110    { 
     111    super.configureShell(newShell); 
     112    PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, 
     113        IJavaDebugHelpContextIds.EDIT_JRE_DIALOG); 
     114    } 
     115 
     116    protected void createDialogFields() 
     117    { 
     118    fCompilerTypeCombo = new ComboDialogField(SWT.READ_ONLY); 
     119    fCompilerTypeCombo.setLabelText("Compiler &type:"); 
     120    fCompilerTypeCombo.setItems(getCompilerTypeNames()); 
     121 
     122    fCompilerName = new StringDialogField(); 
     123    fCompilerName.setLabelText("Compiler &name:"); 
     124 
     125    fCompilerExecutable = new StringButtonDialogField(new IStringButtonAdapter() 
     126    { 
     127        public void changeControlPressed(DialogField field) 
     128        { 
     129        browseForInstallDir(); 
     130        } 
     131    }); 
     132    fCompilerExecutable.setLabelText("&Compiler home directory:"); 
     133    fCompilerExecutable.setButtonLabel("&Browse..."); 
     134    } 
     135 
     136    protected void createFieldListeners() 
     137    { 
     138    fCompilerTypeCombo.setDialogFieldListener(new IDialogFieldListener() 
     139    { 
     140        public void dialogFieldChanged(DialogField field) 
     141        { 
     142        updateCompilerType(); 
     143        } 
     144    }); 
     145 
     146    fCompilerName.setDialogFieldListener(new IDialogFieldListener() 
     147    { 
     148        public void dialogFieldChanged(DialogField field) 
     149        { 
     150        setVMNameStatus(validateCompilerName()); 
     151        updateStatusLine(); 
     152        } 
     153    }); 
     154 
     155    fCompilerExecutable.setDialogFieldListener(new IDialogFieldListener() 
     156    { 
     157        public void dialogFieldChanged(DialogField field) 
     158        { 
     159        setJRELocationStatus(validateCompilerExecutableLocation()); 
     160        updateStatusLine(); 
     161        } 
     162    }); 
     163 
     164    } 
     165 
     166    protected String getVMName() 
     167    { 
     168    return fCompilerName.getText(); 
     169    } 
     170 
     171    protected File getInstallLocation() 
     172    { 
     173    return new File(fCompilerExecutable.getText()); 
     174    } 
     175 
     176    protected Control createDialogArea(Composite ancestor) 
     177    { 
     178    createDialogFields(); 
     179    Composite parent = (Composite) super.createDialogArea(ancestor); 
     180     
     181    //create the general settings area   
     182    ((GridLayout) parent.getLayout()).numColumns = 3; 
     183 
     184    fCompilerTypeCombo.doFillIntoGrid(parent, 3); 
     185    ((GridData) fCompilerTypeCombo.getComboControl(null).getLayoutData()).widthHint = convertWidthInCharsToPixels(50); 
     186 
     187    fCompilerName.doFillIntoGrid(parent, 3); 
     188 
     189    fCompilerExecutable.doFillIntoGrid(parent, 3); 
     190 
     191    //create the tab folder for the directory lists 
     192    tabFolder = new TabFolder(parent, SWT.BORDER); 
     193    GridData gd = new GridData(GridData.FILL_BOTH); 
     194    gd.horizontalSpan = 3; 
     195    tabFolder.setLayoutData(gd); 
     196     
     197    //create the source files directory list 
     198    fSourceDirectoryBlock = new CompilerDirectoryBlock(this); 
     199    Control block = fSourceDirectoryBlock.createControl(tabFolder); 
     200    block.setLayoutData(new GridData(GridData.FILL_BOTH)); 
     201     
     202    TabItem item = new TabItem(tabFolder, SWT.NULL); 
     203    item.setText("Source Dirs"); 
     204    item.setControl(block); 
     205     
     206    //create the library files directory list 
     207    fLibraryDirectoryBlock = new CompilerDirectoryBlock(this); 
     208    block = fLibraryDirectoryBlock.createControl(tabFolder); 
     209    block.setLayoutData(new GridData(GridData.FILL_BOTH)); 
     210     
     211    item = new TabItem(tabFolder, SWT.NULL); 
     212    item.setText("Library Dirs"); 
     213    item.setControl(block); 
     214     
     215    //create the executable files directory list 
     216    fExecutableDirectoryBlock = new CompilerDirectoryBlock(this); 
     217    block = fExecutableDirectoryBlock.createControl(tabFolder); 
     218    block.setLayoutData(new GridData(GridData.FILL_BOTH)); 
     219     
     220    item = new TabItem(tabFolder, SWT.NULL); 
     221    item.setText("Executable Dirs"); 
     222    item.setControl(block); 
     223 
     224    //create stuff below the directories area 
     225    Text t = fCompilerExecutable.getTextControl(parent); 
     226    gd = (GridData) t.getLayoutData(); 
     227    gd.grabExcessHorizontalSpace = true; 
     228    gd.widthHint = convertWidthInCharsToPixels(50); 
     229 
     230    initializeFields(); 
     231    createFieldListeners(); 
     232    applyDialogFont(parent); 
     233    return parent; 
     234    } 
     235 
     236    private void updateCompilerType() 
     237    { 
     238    int selIndex = fCompilerTypeCombo.getSelectionIndex(); 
     239    if (selIndex == fPrevIndex) 
     240    { 
     241        return; 
     242    } 
     243    fPrevIndex = selIndex; 
     244    if (selIndex >= 0 && selIndex < fCompilerTypes.length) 
     245    { 
     246        fSelectedCompilerType = fCompilerTypes[selIndex]; 
     247    } 
     248    setJRELocationStatus(validateCompilerExecutableLocation()); 
     249    fSourceDirectoryBlock.initializeFrom(fEditedCompiler, fSelectedCompilerType); 
     250    updateStatusLine(); 
     251    } 
     252 
     253    public void create() 
     254    { 
     255    super.create(); 
     256    fCompilerName.setFocus(); 
     257    selectCompilerType(); 
     258    } 
     259 
     260    private String[] getCompilerTypeNames() 
     261    { 
     262    String[] names = new String[fCompilerTypes.length]; 
     263    for (int i = 0; i < fCompilerTypes.length; i++) 
     264    { 
     265        names[i] = fCompilerTypes[i].getName(); 
     266    } 
     267    return names; 
     268    } 
     269 
     270    private void selectCompilerType() 
     271    { 
     272    for (int i = 0; i < fCompilerTypes.length; i++) 
     273    { 
     274        if (fSelectedCompilerType == fCompilerTypes[i]) 
     275        { 
     276        fCompilerTypeCombo.selectItem(i); 
     277        return; 
     278        } 
     279    } 
     280    } 
     281 
     282    private void initializeFields() 
     283    { 
     284    fCompilerTypeCombo.setItems(getCompilerTypeNames()); 
     285    if (fEditedCompiler == null) 
     286    { 
     287        fCompilerName.setText(""); 
     288        fCompilerExecutable.setText(""); 
     289        fSourceDirectoryBlock.initializeFrom(null, fSelectedCompilerType); 
     290    } 
     291    else 
     292    { 
     293        fCompilerTypeCombo.setEnabled(false); 
     294        fCompilerName.setText(fEditedCompiler.getName()); 
     295        fCompilerExecutable.setText(fEditedCompiler.getInstallLocation().getAbsolutePath()); 
     296        fSourceDirectoryBlock.initializeFrom(fEditedCompiler, fSelectedCompilerType); 
     297    } 
     298    setVMNameStatus(validateCompilerName()); 
     299    updateStatusLine(); 
     300    } 
     301 
     302    private ICompilerInstallType getVMType() 
     303    { 
     304    return fSelectedCompilerType; 
     305    } 
     306 
     307    private IStatus validateCompilerExecutableLocation() 
     308    { 
     309    String locationName = fCompilerExecutable.getText().trim(); 
     310    IStatus s = null; 
     311    File file = null; 
     312    if (locationName.length() == 0) 
     313    { 
     314        s = new StatusInfo(IStatus.INFO, 
     315            "Enter the location of the compiler."); 
     316    } 
     317    else 
     318    { 
     319        file = new File(locationName); 
     320        if (!file.exists()) 
     321        { 
     322        s = new StatusInfo(IStatus.ERROR, 
     323            "The location does not exist."); 
     324        } 
     325        else 
     326        { 
     327        final IStatus[] temp = new IStatus[1]; 
     328        final File tempFile = file; 
     329        Runnable r = new Runnable() 
     330        { 
     331            /** 
     332             * @see java.lang.Runnable#run() 
     333             */ 
     334            public void run() 
     335            { 
     336            temp[0] = getVMType().validateInstallLocation(tempFile); 
     337            } 
     338        }; 
     339        BusyIndicator.showWhile(getShell().getDisplay(), r); 
     340        s = temp[0]; 
     341        } 
     342    } 
     343    if (s.isOK()) 
     344    { 
     345        fSourceDirectoryBlock.setHomeDirectory(file); 
     346        String name = fCompilerName.getText(); 
     347        if (name == null || name.trim().length() == 0) 
     348        { 
     349        // auto-generate VM name 
     350        fCompilerName.setText(VMInstallTypeUtil.getVMInstallName( 
     351            fSelectedCompilerType, file)); 
     352        } 
     353    } 
     354    else 
     355    { 
     356        fSourceDirectoryBlock.setHomeDirectory(null); 
     357    } 
     358    fSourceDirectoryBlock.restoreDefaultDirectories(); 
     359    detectJavadocLocation(); 
     360    return s; 
     361    } 
     362 
     363    /** 
     364     * Auto-detects the default javadoc location 
     365     */ 
     366    private void detectJavadocLocation() 
     367    { 
     368    if (fAutoDetectJavadocLocation) 
     369    { 
     370        if (getVMType() instanceof AbstractVMInstallType) 
     371        { 
     372        AbstractVMInstallType type = (AbstractVMInstallType) getVMType(); 
     373        fJavadocLocation = type 
     374            .getDefaultJavadocLocation(getInstallLocation()); 
     375        } 
     376    } 
     377    else 
     378    { 
     379        fJavadocLocation = fEditedCompiler.getJavadocLocation(); 
     380    } 
     381    } 
     382 
     383    private IStatus validateCompilerName() 
     384    { 
     385    StatusInfo status = new StatusInfo(); 
     386    String name = fCompilerName.getText(); 
     387    if (name == null || name.trim().length() == 0) 
     388    { 
     389        status.setInfo("Enter a name for the compiler."); 
     390    } 
     391    else 
     392    { 
     393        if (fRequestor.isDuplicateName(name) 
     394            && (fEditedCompiler == null || !name.equals(fEditedCompiler.getName()))) 
     395        { 
     396        status.setError("The name is already used."); 
     397        } 
     398        else 
     399        { 
     400        IStatus s = ResourcesPlugin.getWorkspace().validateName(name, 
     401            IResource.FILE); 
     402        if (!s.isOK()) 
     403        { 
     404            status.setError(MessageFormat.format( 
     405                "Compiler name must be a valid file name: {0}", 
     406                new String[] 
     407                { s.getMessage() })); 
    72408        } 
    73          
    74         fVMTypes= vmInstallTypes; 
    75         fSelectedVMType= editedVM != null ? editedVM.getVMInstallType() : vmInstallTypes[0]; 
    76          
    77         fEditedVM= editedVM; 
    78          
    79         //only detect the javadoc location if not already set 
    80         fAutoDetectJavadocLocation = fEditedVM == null || fEditedVM.getJavadocLocation() == null; 
    81     } 
    82      
    83     /** 
    84      * @see Windows#configureShell 
    85      */ 
    86     protected void configureShell(Shell newShell) { 
    87         super.configureShell(newShell); 
    88         PlatformUI.getWorkbench().getHelpSystem().setHelp(newShell, IJavaDebugHelpContextIds.EDIT_JRE_DIALOG); 
    89     }        
    90      
    91     protected void createDialogFields() { 
    92         fVMTypeCombo= new ComboDialogField(SWT.READ_ONLY); 
    93         fVMTypeCombo.setLabelText(JREMessages.addVMDialog_jreType);  
    94         fVMTypeCombo.setItems(getVMTypeNames()); 
    95          
    96         fVMName= new StringDialogField(); 
    97         fVMName.setLabelText(JREMessages.addVMDialog_jreName);  
    98          
    99         fJRERoot= new StringButtonDialogField(new IStringButtonAdapter() { 
    100             public void changeControlPressed(DialogField field) { 
    101                 browseForInstallDir(); 
    102             } 
    103         }); 
    104         fJRERoot.setLabelText(JREMessages.addVMDialog_jreHome);  
    105         fJRERoot.setButtonLabel(JREMessages.addVMDialog_browse1); 
    106     } 
    107      
    108     protected void createFieldListeners() { 
    109         fVMTypeCombo.setDialogFieldListener(new IDialogFieldListener() { 
    110             public void dialogFieldChanged(DialogField field) { 
    111                 updateVMType(); 
    112             } 
    113         }); 
    114          
    115         fVMName.setDialogFieldListener(new IDialogFieldListener() { 
    116             public void dialogFieldChanged(DialogField field) { 
    117                 setVMNameStatus(validateVMName()); 
    118                 updateStatusLine(); 
    119             } 
    120         }); 
    121          
    122         fJRERoot.setDialogFieldListener(new IDialogFieldListener() { 
    123             public void dialogFieldChanged(DialogField field) { 
    124                 setJRELocationStatus(validateJRELocation()); 
    125                 updateStatusLine(); 
    126             } 
    127         }); 
    128      
    129     } 
    130      
    131     protected String getVMName() { 
    132         return fVMName.getText(); 
    133     } 
    134          
    135     protected File getInstallLocation() { 
    136         return new File(fJRERoot.getText()); 
    137     } 
    138          
    139     protected Control createDialogArea(Composite ancestor) { 
    140         createDialogFields(); 
    141         Composite parent = (Composite)super.createDialogArea(ancestor); 
    142         ((GridLayout)parent.getLayout()).numColumns= 3; 
    143          
    144         fVMTypeCombo.doFillIntoGrid(parent, 3); 
    145         ((GridData)fVMTypeCombo.getComboControl(null).getLayoutData()).widthHint= convertWidthInCharsToPixels(50); 
    146  
    147         fVMName.doFillIntoGrid(parent, 3); 
    148      
    149         fJRERoot.doFillIntoGrid(parent, 3); 
    150          
    151         Label l = new Label(parent, SWT.NONE); 
    152         l.setText(JREMessages.AddVMDialog_JRE_system_libraries__1);  
    153         GridData gd = new GridData(GridData.FILL_HORIZONTAL); 
    154         gd.horizontalSpan = 3; 
    155         l.setLayoutData(gd);     
    156          
    157         fLibraryBlock = new VMLibraryBlock(this); 
    158         Control block = fLibraryBlock.createControl(parent); 
    159         gd = new GridData(GridData.FILL_BOTH); 
    160         gd.horizontalSpan = 3; 
    161         block.setLayoutData(gd); 
    162          
    163         Text t= fJRERoot.getTextControl(parent); 
    164         gd= (GridData)t.getLayoutData(); 
    165         gd.grabExcessHorizontalSpace=true; 
    166         gd.widthHint= convertWidthInCharsToPixels(50); 
    167          
    168         initializeFields(); 
    169         createFieldListeners(); 
    170         applyDialogFont(parent); 
    171         return parent; 
    172     } 
    173      
    174     private void updateVMType() { 
    175         int selIndex= fVMTypeCombo.getSelectionIndex(); 
    176         if (selIndex == fPrevIndex) { 
    177             return; 
    178         } 
    179         fPrevIndex = selIndex; 
    180         if (selIndex >= 0 && selIndex < fVMTypes.length) { 
    181             fSelectedVMType= fVMTypes[selIndex]; 
    182         } 
    183         setJRELocationStatus(validateJRELocation()); 
    184         fLibraryBlock.initializeFrom(fEditedVM, fSelectedVMType); 
    185         updateStatusLine(); 
    186     }    
    187      
    188     public void create() { 
    189         super.create(); 
    190         fVMName.setFocus(); 
    191         selectVMType();   
    192     } 
    193      
    194     private String[] getVMTypeNames() { 
    195         String[] names=  new String[fVMTypes.length]; 
    196         for (int i= 0; i < fVMTypes.length; i++) { 
    197             names[i]= fVMTypes[i].getName(); 
    198         } 
    199         return names; 
    200     } 
    201      
    202     private void selectVMType() { 
    203         for (int i= 0; i < fVMTypes.length; i++) { 
    204             if (fSelectedVMType == fVMTypes[i]) { 
    205                 fVMTypeCombo.selectItem(i); 
    206                 return; 
    207             } 
    208         } 
    209     } 
    210      
    211     private void initializeFields() { 
    212         fVMTypeCombo.setItems(getVMTypeNames()); 
    213         if (fEditedVM == null) { 
    214             fVMName.setText(""); //$NON-NLS-1$ 
    215             fJRERoot.setText(""); //$NON-NLS-1$ 
    216             fLibraryBlock.initializeFrom(null, fSelectedVMType); 
    217         } else { 
    218             fVMTypeCombo.setEnabled(false); 
    219             fVMName.setText(fEditedVM.getName()); 
    220             fJRERoot.setText(fEditedVM.getInstallLocation().getAbsolutePath()); 
    221             fLibraryBlock.initializeFrom(fEditedVM, fSelectedVMType); 
    222         } 
    223         setVMNameStatus(validateVMName()); 
    224         updateStatusLine(); 
    225     } 
    226      
    227     private IVMInstallType getVMType() { 
    228         return fSelectedVMType; 
    229     } 
    230      
    231     private IStatus validateJRELocation() { 
    232         String locationName= fJRERoot.getText().trim(); 
    233         IStatus s = null; 
    234         File file = null; 
    235         if (locationName.length() == 0) { 
    236             s = new StatusInfo(IStatus.INFO, JREMessages.addVMDialog_enterLocation);  
    237         } else { 
    238             file= new File(locationName); 
    239             if (!file.exists()) { 
    240                 s = new StatusInfo(IStatus.ERROR, JREMessages.addVMDialog_locationNotExists);  
    241             } else { 
    242                 final IStatus[] temp = new IStatus[1]; 
    243                 final File tempFile = file;  
    244                 Runnable r = new Runnable() { 
    245                     /** 
    246                      * @see java.lang.Runnable#run() 
    247                      */ 
    248                     public void run() { 
    249                         temp[0] = getVMType().validateInstallLocation(tempFile); 
    250                     } 
    251                 }; 
    252                 BusyIndicator.showWhile(getShell().getDisplay(), r); 
    253                 s = temp[0]; 
    254             } 
    255         } 
    256         if (s.isOK()) { 
    257             fLibraryBlock.setHomeDirectory(file); 
    258             String name = fVMName.getText(); 
    259             if (name == null || name.trim().length() == 0) { 
    260                 // auto-generate VM name 
    261                 fVMName.setText(VMInstallTypeUtil.getVMInstallName(fSelectedVMType, file)); 
    262             } 
    263         } else { 
    264             fLibraryBlock.setHomeDirectory(null); 
    265         } 
    266         fLibraryBlock.restoreDefaultLibraries(); 
    267         detectJavadocLocation(); 
    268         return s; 
    269     } 
    270      
    271     /** 
    272      * Auto-detects the default javadoc location 
    273      */ 
    274     private void detectJavadocLocation() { 
    275         if (fAutoDetectJavadocLocation) { 
    276             if (getVMType() instanceof AbstractVMInstallType) { 
    277                 AbstractVMInstallType type = (AbstractVMInstallType)getVMType(); 
    278                 fJavadocLocation = type.getDefaultJavadocLocation(getInstallLocation()); 
    279             } 
    280         } else { 
    281             fJavadocLocation = fEditedVM.getJavadocLocation(); 
    282         } 
    283     } 
    284  
    285     private IStatus validateVMName() { 
    286         StatusInfo status= new StatusInfo(); 
    287         String name= fVMName.getText(); 
    288         if (name == null || name.trim().length() == 0) { 
    289             status.setInfo(JREMessages.addVMDialog_enterName);  
    290         } else { 
    291             if (fRequestor.isDuplicateName(name) && (fEditedVM == null || !name.equals(fEditedVM.getName()))) { 
    292                 status.setError(JREMessages.addVMDialog_duplicateName);  
    293             } else { 
    294                 IStatus s = ResourcesPlugin.getWorkspace().validateName(name, IResource.FILE); 
    295                 if (!s.isOK()) { 
    296                     status.setError(MessageFormat.format(JREMessages.AddVMDialog_JRE_name_must_be_a_valid_file_name___0__1, new String[]{s.getMessage()}));  
    297                 } 
    298             } 
    299         } 
    300         return status; 
    301     } 
    302      
    303     protected void updateStatusLine() { 
    304         IStatus max= null; 
    305         for (int i= 0; i < fStati.length; i++) { 
    306             IStatus curr= fStati[i]; 
    307             if (curr.matches(IStatus.ERROR)) { 
    308                 updateStatus(curr); 
    309                 return; 
    310             } 
    311             if (max == null || curr.getSeverity() > max.getSeverity()) { 
    312                 max= curr; 
    313             } 
    314         } 
    315         updateStatus(max); 
    316     } 
    317              
    318     private void browseForInstallDir() { 
    319         DirectoryDialog dialog= new DirectoryDialog(getShell()); 
    320         dialog.setFilterPath(fJRERoot.getText()); 
    321         dialog.setMessage(JREMessages.addVMDialog_pickJRERootDialog_message);  
    322         String newPath= dialog.open(); 
    323         if (newPath != null) { 
    324             fJRERoot.setText(newPath); 
    325         } 
    326     } 
    327      
    328     protected URL getURL() { 
    329         return fJavadocLocation; 
    330     } 
    331      
    332     protected void okPressed() { 
    333         doOkPressed(); 
    334         super.okPressed(); 
    335     } 
    336      
    337     private void doOkPressed() { 
    338         if (fEditedVM == null) { 
    339             IVMInstall vm= new VMStandin(fSelectedVMType, createUniqueId(fSelectedVMType)); 
    340             setFieldValuesToVM(vm); 
    341             fRequestor.vmAdded(vm); 
    342         } else { 
    343             setFieldValuesToVM(fEditedVM); 
    344         } 
    345     } 
    346      
    347     private String createUniqueId(IVMInstallType vmType) { 
    348         String id= null; 
    349         do { 
    350             id= String.valueOf(System.currentTimeMillis()); 
    351         } while (vmType.findVMInstall(id) != null); 
    352         return id; 
    353     } 
    354      
    355     protected void setFieldValuesToVM(IVMInstall vm) { 
    356         File dir = new File(fJRERoot.getText()); 
    357         try { 
    358             vm.setInstallLocation(dir.getCanonicalFile()); 
    359         } catch (IOException e) { 
    360             vm.setInstallLocation(dir.getAbsoluteFile()); 
    361         } 
    362         vm.setName(fVMName.getText()); 
    363         vm.setJavadocLocation(getURL()); 
    364  
    365         fLibraryBlock.performApply(vm); 
    366     } 
    367      
    368     protected File getAbsoluteFileOrEmpty(String path) { 
    369         if (path == null || path.length() == 0) { 
    370             return new File(""); //$NON-NLS-1$ 
    371         } 
    372         return new File(path).getAbsoluteFile(); 
    373     } 
    374      
    375     private void setVMNameStatus(IStatus status) { 
    376         fStati[0]= status; 
    377     } 
    378      
    379     private void setJRELocationStatus(IStatus status) { 
    380         fStati[1]= status; 
    381     } 
    382      
    383     protected IStatus getSystemLibraryStatus() { 
    384         return fStati[3]; 
    385     } 
    386      
    387     protected void setSystemLibraryStatus(IStatus status) { 
    388         fStati[3]= status; 
    389     } 
    390      
    391     /** 
    392      * Updates the status of the ok button to reflect the given status. 
    393      * Subclasses may override this method to update additional buttons. 
    394      * @param status the status. 
    395      */ 
    396     protected void updateButtonsEnableState(IStatus status) { 
    397         Button ok = getButton(IDialogConstants.OK_ID); 
    398         if (ok != null && !ok.isDisposed()) 
    399             ok.setEnabled(status.getSeverity() == IStatus.OK); 
    400     }    
    401      
    402     /** 
    403      * @see org.eclipse.jface.dialogs.Dialog#setButtonLayoutData(org.eclipse.swt.widgets.Button) 
    404      */ 
    405     protected void setButtonLayoutData(Button button) { 
    406         super.setButtonLayoutData(button); 
    407     } 
    408      
    409     /** 
    410      * Returns the name of the section that this dialog stores its settings in 
    411      *  
    412      * @return String 
    413      */ 
    414     protected String getDialogSettingsSectionName() { 
    415         return "ADD_VM_DIALOG_SECTION"; //$NON-NLS-1$ 
    416     } 
    417      
    418      /* (non-Javadoc) 
     409        } 
     410    } 
     411    return status; 
     412    } 
     413 
     414    protected void updateStatusLine() 
     415    { 
     416    IStatus max = null; 
     417    for (int i = 0; i < fStati.length; i++) 
     418    { 
     419        IStatus curr = fStati[i]; 
     420        if (curr.matches(IStatus.ERROR)) 
     421        { 
     422        updateStatus(curr); 
     423        return; 
     424        } 
     425        if (max == null || curr.getSeverity() > max.getSeverity()) 
     426        { 
     427        max = curr; 
     428        } 
     429    } 
     430    updateStatus(max); 
     431    } 
     432 
     433    private void browseForInstallDir() 
     434    { 
     435    DirectoryDialog dialog = new DirectoryDialog(getShell()); 
     436    dialog.setFilterPath(fCompilerExecutable.getText()); 
     437    dialog 
     438        .setMessage("Select the root directory of the compiler installation:"); 
     439    String newPath = dialog.open(); 
     440    if (newPath != null) 
     441    { 
     442        fCompilerExecutable.setText(newPath); 
     443    } 
     444    } 
     445 
     446    protected URL getURL() 
     447    { 
     448    return fJavadocLocation; 
     449    } 
     450 
     451    protected void okPressed() 
     452    { 
     453    doOkPressed(); 
     454    super.okPressed(); 
     455    } 
     456 
     457    private void doOkPressed() 
     458    { 
     459    if (fEditedCompiler == null) 
     460    { 
     461        ICompilerInstall vm = new VMStandin(fSelectedCompilerType, 
     462            createUniqueId(fSelectedCompilerType)); 
     463        setFieldValuesToVM(vm); 
     464        fRequestor.compilerAdded(vm); 
     465    } 
     466    else 
     467    { 
     468        setFieldValuesToVM(fEditedCompiler); 
     469    } 
     470    } 
     471 
     472    private String createUniqueId(ICompilerInstallType vmType) 
     473    { 
     474    String id = null; 
     475    do 
     476    { 
     477        id = String.valueOf(System.currentTimeMillis()); 
     478    } while (vmType.findVMInstall(id) != null); 
     479    return id; 
     480    } 
     481 
     482    protected void setFieldValuesToVM(ICompilerInstall vm) 
     483    { 
     484    File dir = new File(fCompilerExecutable.getText()); 
     485    try 
     486    { 
     487        vm.setInstallLocation(dir.getCanonicalFile()); 
     488    } 
     489    catch (IOException e) 
     490    { 
     491        vm.setInstallLocation(dir.getAbsoluteFile()); 
     492    } 
     493    vm.setName(fCompilerName.getText()); 
     494    vm.setJavadocLocation(getURL()); 
     495 
     496    fSourceDirectoryBlock.performApply(vm); 
     497    } 
     498 
     499    protected File getAbsoluteFileOrEmpty(String path) 
     500    { 
     501    if (path == null || path.length() == 0) 
     502    { 
     503        return new File(""); 
     504    } 
     505    return new File(path).getAbsoluteFile(); 
     506    } 
     507 
     508    private void setVMNameStatus(IStatus status) 
     509    { 
     510    fStati[0] = status; 
     511    } 
     512 
     513    private void setJRELocationStatus(IStatus status) 
     514    { 
     515    fStati[1] = status; 
     516    } 
     517 
     518    protected IStatus getSystemLibraryStatus() 
     519    { 
     520    return fStati[3]; 
     521    } 
     522 
     523    protected void setSystemLibraryStatus(IStatus status) 
     524    { 
     525    fStati[3] = status; 
     526    } 
     527 
     528    /** 
     529     * Updates the status of the ok button to reflect the given status. 
     530     * Subclasses may override this method to update additional buttons. 
     531     * @param status the status. 
     532     */ 
     533    protected void updateButtonsEnableState(IStatus status) 
     534    { 
     535    Button ok = getButton(IDialogConstants.OK_ID); 
     536    if (ok != null && !ok.isDisposed()) 
     537        ok.setEnabled(status.getSeverity() == IStatus.OK); 
     538    } 
     539 
     540    /** 
     541     * @see org.eclipse.jface.dialogs.Dialog#setButtonLayoutData(org.eclipse.swt.widgets.Button) 
     542     */ 
     543    protected void setButtonLayoutData(Button button) 
     544    { 
     545    super.setButtonLayoutData(button); 
     546    } 
     547 
     548    /** 
     549     * Returns the name of the section that this dialog stores its settings in 
     550     *  
     551     * @return String 
     552     */ 
     553    protected String getDialogSettingsSectionName() 
     554    { 
     555    return "ADD_VM_DIALOG_SECTION"; 
     556    } 
     557 
     558    /* (non-Javadoc) 
    419559     * @see org.eclipse.jface.dialogs.Dialog#getDialogBoundsSettings() 
    420560     */ 
    421     protected IDialogSettings getDialogBoundsSettings() { 
    422          IDialogSettings settings = JavaPlugin.getDefault().getDialogSettings(); 
    423          IDialogSettings section = settings.getSection(getDialogSettingsSectionName()); 
    424          if (section == null) { 
    425              section = settings.addNewSection(getDialogSettingsSectionName()); 
    426          }  
    427          return section; 
     561    protected IDialogSettings getDialogBoundsSettings() 
     562    { 
     563    IDialogSettings settings = JavaPlugin.getDefault().getDialogSettings(); 
     564    IDialogSettings section = settings 
     565        .getSection(getDialogSettingsSectionName()); 
     566    if (section == null) 
     567    { 
     568        section = settings.addNewSection(getDialogSettingsSectionName()); 
     569    } 
     570    return section; 
    428571    } 
    429572} 
  • oranda_4-14-08/descent.ui/src/descent/internal/debug/ui/jres/CompilerDirectoryBlock.java

    r902 r1111  
    11package descent.internal.debug.ui.jres; 
    2  
    32 
    43import java.io.File; 
     
    2827import org.eclipse.swt.widgets.DirectoryDialog; 
    2928import org.eclipse.swt.widgets.Label; 
     29import org.eclipse.swt.widgets.List; 
    3030 
    3131import descent.core.IClasspathEntry; 
    3232import descent.debug.ui.IJavaDebugUIConstants; 
    33 import descent.internal.debug.ui.jres.LibraryContentProvider.SubElement; 
    3433import descent.internal.ui.JavaPlugin; 
    3534import descent.launching.IRuntimeClasspathEntry; 
    36 import descent.launching.IVMInstall; 
    37 import descent.launching.IVMInstallType; 
     35import descent.launching.ICompilerInstall; 
     36import descent.launching.ICompilerInstallType; 
    3837import descent.launching.JavaRuntime; 
    3938import descent.launching.LibraryLocation; 
    4039import descent.ui.wizards.BuildPathDialogAccess; 
    41   
     40 
    4241/** 
    43  * Control used to edit the libraries associated with a VM install 
     42 * Control used to add remove directories from a list, such as source directories, library directories, etc. 
    4443 */ 
    45 public class VMLibraryBlock implements SelectionListener, ISelectionChangedListener { 
     44public class CompilerDirectoryBlock implements SelectionListener, 
     45    ISelectionChangedListener 
     46
     47 
     48    /** 
     49     * Attribute name for the last path used to open a file/directory chooser 
     50     * dialog. 
     51     */ 
     52    protected static final String LAST_PATH_SETTING = "LAST_PATH_SETTING"; 
     53 
     54    /** 
     55     * the prefix for dialog setting pertaining to this block 
     56     */ 
     57    protected static final String DIALOG_SETTINGS_PREFIX = "DDirectoryBlock"; 
     58 
     59    protected boolean fInCallback = false; 
     60 
     61    protected ICompilerInstall fCompilerInstall; 
     62 
     63    protected ICompilerInstallType fCompilerInstallType; 
     64 
     65    protected File fHome; 
     66 
     67    //widgets 
     68    protected List fDirectoryList; 
     69 
     70    protected AddCompilerDialog fDialog = null; 
     71 
     72    private Button fUpButton; 
     73 
     74    private Button fDownButton; 
     75 
     76    private Button fRemoveButton; 
     77 
     78    private Button fAddButton; 
     79 
     80    protected Button fRemoveAllButton; 
     81 
     82    /** 
     83     * Constructor for CompilerDirectoryBlock. 
     84     */ 
     85    public CompilerDirectoryBlock(AddCompilerDialog dialog) 
     86    { 
     87    fDialog = dialog; 
     88    } 
     89 
     90    /** 
     91     * Creates and returns the source lookup control. 
     92     *  
     93     * @param parent the parent widget of this control 
     94     */ 
     95    public Control createControl(Composite parent) 
     96    { 
     97    Font font = parent.getFont(); 
     98 
     99    Composite comp = new Composite(parent, SWT.NONE); 
     100    GridLayout topLayout = new GridLayout(); 
     101    topLayout.numColumns = 2; 
     102    topLayout.marginHeight = 0; 
     103    topLayout.marginWidth = 0; 
     104    comp.setLayout(topLayout); 
     105    GridData gd = new GridData(GridData.FILL_BOTH); 
     106    comp.setLayoutData(gd); 
     107 
     108    fDirectoryList = new List(comp, SWT.SINGLE); 
     109    gd = new GridData(GridData.FILL_BOTH); 
     110    gd.grabExcessHorizontalSpace = true; 
     111    gd.grabExcessVerticalSpace = true; 
     112    fDirectoryList.setLayoutData(gd); 
     113    fDirectoryList.addSelectionListener(this); 
     114 
     115    Composite pathButtonComp = new Composite(comp, SWT.NONE); 
     116    GridLayout pathButtonLayout = new GridLayout(); 
     117    pathButtonLayout.marginHeight = 0; 
     118    pathButtonLayout.marginWidth = 0; 
     119    pathButtonComp.setLayout(pathButtonLayout); 
     120    gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING 
     121        | GridData.HORIZONTAL_ALIGN_FILL); 
     122    pathButtonComp.setLayoutData(gd); 
     123    pathButtonComp.setFont(font); 
     124 
     125    fAddButton = createPushButton(pathButtonComp, "Add Path..."); 
     126    fAddButton.addSelectionListener(this); 
     127 
     128    fRemoveButton = createPushButton(pathButtonComp, "Re&move"); 
     129    fRemoveButton.addSelectionListener(this); 
     130 
     131    fUpButton = createPushButton(pathButtonComp, "U&p"); 
     132    fUpButton.addSelectionListener(this); 
     133 
     134    fDownButton = createPushButton(pathButtonComp, "&Down"); 
     135    fDownButton.addSelectionListener(this); 
     136 
     137    fRemoveAllButton = createPushButton(pathButtonComp, "&Remove All"); 
     138    fRemoveAllButton.addSelectionListener(this); 
    46139     
    47     /** 
    48      * Attribute name for the last path used to open a file/directory chooser 
    49      * dialog. 
    50      */ 
    51     protected static final String LAST_PATH_SETTING = "LAST_PATH_SETTING"; //$NON-NLS-1$ 
    52      
    53     /** 
    54      * the prefix for dialog setting pertaining to this block 
    55      */ 
    56     protected static final String DIALOG_SETTINGS_PREFIX = "VMLibraryBlock"; //$NON-NLS-1$ 
    57      
    58     protected boolean fInCallback = false; 
    59     protected IVMInstall fVmInstall; 
    60     protected IVMInstallType fVmInstallType; 
    61     protected File fHome; 
    62      
    63     //widgets 
    64     protected LibraryContentProvider fLibraryContentProvider; 
    65     protected AddVMDialog fDialog = null; 
    66     protected TreeViewer fLibraryViewer; 
    67     private Button fUpButton; 
    68     private Button fDownButton; 
    69     private Button fRemoveButton; 
    70     private Button fAddButton; 
    71     private Button fJavadocButton; 
    72     private Button fSourceButton; 
    73     protected Button fDefaultButton; 
    74      
    75     /** 
    76      * Constructor for VMLibraryBlock. 
    77      */ 
    78     public VMLibraryBlock(AddVMDialog dialog) { 
    79         fDialog = dialog; 
    80     } 
    81  
    82     /** 
    83      * Creates and returns the source lookup control. 
    84      *  
    85      * @param parent the parent widget of this control 
    86      */ 
    87     public Control createControl(Composite parent) { 
    88         Font font = parent.getFont(); 
    89          
    90         Composite comp = new Composite(parent, SWT.NONE); 
    91         GridLayout topLayout = new GridLayout(); 
    92         topLayout.numColumns = 2; 
    93         topLayout.marginHeight = 0; 
    94         topLayout.marginWidth = 0; 
    95         comp.setLayout(topLayout);       
    96         GridData gd = new GridData(GridData.FILL_BOTH); 
    97         comp.setLayoutData(gd); 
    98          
    99         fLibraryViewer= new TreeViewer(comp); 
    100         gd = new GridData(GridData.FILL_BOTH); 
    101         gd.heightHint = 6; 
    102         fLibraryViewer.getControl().setLayoutData(gd); 
    103         fLibraryContentProvider= new LibraryContentProvider(); 
    104         fLibraryViewer.setContentProvider(fLibraryContentProvider); 
    105         fLibraryViewer.setLabelProvider(new LibraryLabelProvider()); 
    106         fLibraryViewer.setInput(this); 
    107         fLibraryViewer.addSelectionChangedListener(this); 
    108          
    109         Composite pathButtonComp = new Composite(comp, SWT.NONE); 
    110         GridLayout pathButtonLayout = new GridLayout(); 
    111         pathButtonLayout.marginHeight = 0; 
    112         pathButtonLayout.marginWidth = 0; 
    113         pathButtonComp.setLayout(pathButtonLayout); 
    114         gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_FILL); 
    115         pathButtonComp.setLayoutData(gd); 
    116         pathButtonComp.setFont(font); 
    117          
    118         fAddButton= createPushButton(pathButtonComp, JREMessages.VMLibraryBlock_7); 
    119         fAddButton.addSelectionListener(this); 
    120          
    121         fJavadocButton = createPushButton(pathButtonComp, JREMessages.VMLibraryBlock_3); 
    122         fJavadocButton.addSelectionListener(this); 
    123         fSourceButton = createPushButton(pathButtonComp, JREMessages.VMLibraryBlock_11); 
    124         fSourceButton.addSelectionListener(this); 
    125         fLibraryViewer.addDoubleClickListener(new IDoubleClickListener() { 
    126             public void doubleClick(DoubleClickEvent event) { 
    127                 IStructuredSelection sel = (IStructuredSelection)event.getViewer().getSelection(); 
    128                 Object obj = sel.getFirstElement(); 
    129                 if(obj instanceof SubElement) { 
    130                     edit(sel, ((SubElement)obj).getType()); 
    131                 } 
    132             } 
    133         }); 
    134  
    135         fRemoveButton= createPushButton(pathButtonComp, JREMessages.VMLibraryBlock_6); 
    136         fRemoveButton.addSelectionListener(this); 
    137          
    138         fUpButton= createPushButton(pathButtonComp, JREMessages.VMLibraryBlock_4); 
    139         fUpButton.addSelectionListener(this); 
    140          
    141         fDownButton= createPushButton(pathButtonComp, JREMessages.VMLibraryBlock_5); 
    142         fDownButton.addSelectionListener(this); 
    143  
    144         fDefaultButton= createPushButton(pathButtonComp, JREMessages.VMLibraryBlock_9); 
    145         fDefaultButton.addSelectionListener(this); 
    146          
    147         return comp; 
    148     } 
    149  
    150     /** 
    151      * The "default" button has been toggled 
    152      */ 
    153     public void restoreDefaultLibraries() { 
    154         LibraryLocation[] libs = null; 
    155         File installLocation = getHomeDirectory(); 
    156         if (installLocation == null) { 
    157             libs = new LibraryLocation[0]; 
    158         } else { 
    159             libs = getVMInstallType().getDefaultLibraryLocations(installLocation); 
    160         } 
    161         fLibraryContentProvider.setLibraries(libs); 
    162         update(); 
    163     } 
    164  
    165     /** 
    166      * Creates and returns a button  
    167      *  
    168      * @param parent parent widget 
    169      * @param label label 
    170      * @return Button 
    171      */ 
    172     protected Button createPushButton(Composite parent, String label) { 
    173         Button button = new Button(parent, SWT.PUSH); 
    174         button.setFont(parent.getFont()); 
    175         button.setText(label); 
    176         fDialog.setButtonLayoutData(button); 
    177         return button;   
    178     } 
    179      
    180     /** 
    181      * Create some empty space  
    182      */ 
    183     protected void createVerticalSpacer(Composite comp, int colSpan) { 
    184         Label label = new Label(comp, SWT.NONE); 
    185         GridData gd = new GridData(); 
    186         gd.horizontalSpan = colSpan; 
    187         label.setLayoutData(gd); 
    188     }    
    189      
    190     /** 
    191      * Initializes this control based on the settings in the given 
    192      * vm install and type. 
    193      *  
    194      * @param vm vm or <code>null</code> if none 
    195      * @param type type of vm install 
    196      */ 
    197     public void initializeFrom(IVMInstall vm, IVMInstallType type) { 
    198         fVmInstall = vm; 
    199         fVmInstallType = type; 
    200         if (vm != null) { 
    201             setHomeDirectory(vm.getInstallLocation()); 
    202             fLibraryContentProvider.setLibraries(JavaRuntime.getLibraryLocations(getVMInstall())); 
    203         } 
    204         update(); 
    205     } 
    206      
    207     /** 
    208      * Sets the home directory of the VM Install the user has chosen 
    209      */ 
    210     public void setHomeDirectory(File file) { 
    211         fHome = file; 
    212     } 
    213      
    214     /** 
    215      * Returns the home directory 
    216      */ 
    217     protected File getHomeDirectory() { 
    218         return fHome; 
    219     } 
    220      
    221     /** 
    222      * Updates buttons and status based on current libraries 
    223      */ 
    224     public void update() { 
    225         updateButtons(); 
    226         IStatus status = Status.OK_STATUS; 
    227         if (fLibraryContentProvider.getLibraries().length == 0) { // && !isDefaultSystemLibrary()) { 
    228             status = new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IJavaDebugUIConstants.INTERNAL_ERROR, 
    229                 JREMessages.VMLibraryBlock_Libraries_cannot_be_empty__1, null); 
    230         } 
    231         LibraryStandin[] standins = fLibraryContentProvider.getStandins(); 
    232         for (int i = 0; i < standins.length; i++) { 
    233             IStatus st = standins[i].validate(); 
    234             if (!st.isOK()) { 
    235                 status = st; 
    236                 break; 
    237             } 
    238         } 
    239         fDialog.setSystemLibraryStatus(status); 
    240         fDialog.updateStatusLine(); 
    241     } 
    242      
    243     /** 
    244      * Saves settings in the given working copy 
    245      */ 
    246     public void performApply(IVMInstall vm) {        
    247         if (isDefaultLocations()) { 
    248             vm.setLibraryLocations(null); 
    249         } else { 
    250             LibraryLocation[] libs = fLibraryContentProvider.getLibraries(); 
    251             vm.setLibraryLocations(libs); 
    252         }        
    253     }    
    254      
    255     /** 
    256      * Determines if the present setup is the default location s for this JRE 
    257      * @return true if the current set of locations are the defaults, false otherwise 
    258      */ 
    259     protected boolean isDefaultLocations() { 
    260         LibraryLocation[] libraryLocations = fLibraryContentProvider.getLibraries(); 
    261         IVMInstall install = getVMInstall(); 
    262          
    263         if (install == null || libraryLocations == null) { 
    264             return true; 
    265         } 
    266         File installLocation = install.getInstallLocation(); 
    267         if (installLocation != null) { 
    268             LibraryLocation[] def = getVMInstallType().getDefaultLibraryLocations(installLocation); 
    269             if (def.length == libraryLocations.length) { 
    270                 for (int i = 0; i < def.length; i++) { 
    271                     if (!def[i].equals(libraryLocations[i])) { 
    272                         return false; 
    273                     } 
    274                 } 
    275                 return true; 
    276             } 
    277         } 
    278         return false; 
    279     } 
    280      
    281     /** 
    282      * Returns the vm install associated with this library block. 
    283      *  
    284      * @return vm install 
    285      */ 
    286     protected IVMInstall getVMInstall() { 
    287         return fVmInstall; 
    288     }    
    289      
    290     /** 
    291      * Returns the vm install type associated with this library block. 
    292      *  
    293      * @return vm install 
    294      */ 
    295     protected IVMInstallType getVMInstallType() { 
    296         return fVmInstallType; 
    297     } 
    298  
    299     /* (non-Javadoc) 
    300      * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) 
    301      */ 
    302     public void widgetSelected(SelectionEvent e) { 
    303         Object source= e.getSource(); 
    304         if (source == fUpButton) { 
    305             fLibraryContentProvider.up((IStructuredSelection) fLibraryViewer.getSelection()); 
    306         } else if (source == fDownButton) { 
    307             fLibraryContentProvider.down((IStructuredSelection) fLibraryViewer.getSelection()); 
    308         } else if (source == fRemoveButton) { 
    309             fLibraryContentProvider.remove((IStructuredSelection) fLibraryViewer.getSelection()); 
    310         } else if (source == fAddButton) { 
    311             add((IStructuredSelection) fLibraryViewer.getSelection()); 
    312         }  
    313         else if(source == fJavadocButton) { 
    314             edit((IStructuredSelection) fLibraryViewer.getSelection(), SubElement.JAVADOC_URL); 
    315         } 
    316         else if(source == fSourceButton) { 
    317             edit((IStructuredSelection) fLibraryViewer.getSelection(), SubElement.SOURCE_PATH); 
    318         } 
    319         else if (source == fDefaultButton) { 
    320             restoreDefaultLibraries(); 
    321         } 
    322         update(); 
    323     } 
    324  
    325     /* (non-Javadoc) 
    326      * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent) 
    327      */ 
    328     public void widgetDefaultSelected(SelectionEvent e) {} 
    329  
    330     /** 
    331      * Open the file selection dialog, and add the return jars as libraries. 
    332      */ 
    333     private void add(IStructuredSelection selection) { 
    334         IDialogSettings dialogSettings= JavaPlugin.getDefault().getDialogSettings(); 
    335         String lastUsedPath= dialogSettings.get(LAST_PATH_SETTING); 
    336         if (lastUsedPath == null) { 
    337             lastUsedPath= ""; //$NON-NLS-1$ 
    338         } 
    339          
    340         DirectoryDialog dialog = new DirectoryDialog(fLibraryViewer.getControl().getShell(), SWT.SINGLE); 
    341         //FileDialog dialog= new FileDialog(fLibraryViewer.getControl().getShell(), SWT.MULTI); 
    342         dialog.setText(JREMessages.VMLibraryBlock_10); 
    343         //dialog.setFilterExtensions(new String[] {"*.jar;*.zip"}); //$NON-NLS-1$ 
    344         //dialog.setFilterPath(lastUsedPath); 
    345         String res= dialog.open(); 
    346         if (res == null) { 
    347             return; 
    348         } 
    349         IPath path = new Path(res); 
    350          
    351         LibraryLocation[] libs = new LibraryLocation[] { 
    352             new LibraryLocation(path, Path.EMPTY, Path.EMPTY) 
    353         }; 
    354          
    355         fLibraryContentProvider.add(libs, selection); 
    356     } 
    357  
    358     /** 
    359      * Open the javadoc location dialog or the source location dialog, and set the result 
    360      * to the selected libraries. 
    361      */ 
    362     private void edit(IStructuredSelection selection, int type) { 
    363         Object obj = selection.getFirstElement(); 
    364         LibraryStandin standin = null; 
    365         if(obj instanceof LibraryStandin) { 
    366             standin = (LibraryStandin) obj; 
    367         } 
    368         else if(obj instanceof SubElement){ 
    369             SubElement sub = (SubElement)obj; 
    370             standin = sub.getParent(); 
    371         } 
    372         if(standin != null) { 
    373             LibraryLocation library = standin.toLibraryLocation(); 
    374             if (type == SubElement.JAVADOC_URL) { 
    375                 URL[] urls = BuildPathDialogAccess.configureJavadocLocation(fLibraryViewer.getControl().getShell(), library.getSystemLibraryPath().toOSString(), library.getJavadocLocation()); 
    376                 if (urls != null) { 
    377                     fLibraryContentProvider.setJavadoc(urls[0], selection); 
    378                 } 
    379             }  
    380             else if(type == SubElement.SOURCE_PATH){ 
    381                 IRuntimeClasspathEntry entry = JavaRuntime.newArchiveRuntimeClasspathEntry(library.getSystemLibraryPath()); 
    382                 entry.setSourceAttachmentPath(library.getSystemLibrarySourcePath()); 
    383                 entry.setSourceAttachmentRootPath(library.getPackageRootPath()); 
    384                 IClasspathEntry classpathEntry = BuildPathDialogAccess.configureSourceAttachment(fLibraryViewer.getControl().getShell(), entry.getClasspathEntry());  
    385                 if (classpathEntry != null) { 
    386                     fLibraryContentProvider.setSourcePath(classpathEntry.getSourceAttachmentPath(), classpathEntry.getSourceAttachmentRootPath(), selection); 
    387                 } 
    388             } 
    389         } 
    390     } 
    391  
    392     /* (non-Javadoc) 
    393      * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) 
    394      */ 
    395     public void selectionChanged(SelectionChangedEvent event) { 
    396         updateButtons(); 
    397     } 
    398  
    399     /** 
    400      * Refresh the enable/disable state for the buttons. 
    401      */ 
    402     private void updateButtons() { 
    403         IStructuredSelection selection = (IStructuredSelection) fLibraryViewer.getSelection(); 
    404         fRemoveButton.setEnabled(!selection.isEmpty()); 
    405         boolean enableUp = true,  
    406                 enableDown = true,  
    407                 allSource = true,  
    408                 allJavadoc = true, 
    409                 allRoots = true; 
    410         Object[] libraries = fLibraryContentProvider.getElements(null); 
    411         if (selection.isEmpty() || libraries.length == 0) { 
    412             enableUp = false; 
    413             enableDown = false; 
    414         } else { 
    415             Object first = libraries[0]; 
    416             Object last = libraries[libraries.length - 1]; 
    417             for (Iterator iter= selection.iterator(); iter.hasNext();) { 
    418                 Object element= iter.next(); 
    419                 Object lib; 
    420                 if (element instanceof SubElement) { 
    421                     allRoots = false; 
    422                     SubElement subElement= (SubElement)element; 
    423                     lib = (subElement).getParent().toLibraryLocation(); 
    424                     if (subElement.getType() == SubElement.JAVADOC_URL) { 
    425                         allSource = false; 
    426                     } else { 
    427                         allJavadoc = false; 
    428                     } 
    429                 } else { 
    430                     lib = element; 
    431                     allSource = false; 
    432                     allJavadoc = false; 
    433                 } 
    434                 if (lib == first) { 
    435                     enableUp = false; 
    436                 } 
    437                 if (lib == last) { 
    438                     enableDown = false; 
    439                 } 
    440             } 
    441         } 
    442         fUpButton.setEnabled(enableUp); 
    443         fDownButton.setEnabled(enableDown); 
    444         fJavadocButton.setEnabled(!selection.isEmpty() && (allJavadoc || allRoots)); 
    445         fSourceButton.setEnabled(!selection.isEmpty() && (allSource || allRoots)); 
    446     } 
     140    updateButtons(); 
     141 
     142    return comp; 
     143    } 
     144 
     145    /** 
     146     * The "default" button has been toggled 
     147     */ 
     148    public void restoreDefaultDirectories() 
     149    { 
     150    fDirectoryList.removeAll(); 
     151    update(); 
     152    } 
     153 
     154    /** 
     155     * Creates and returns a button  
     156     *  
     157     * @param parent parent widget 
     158     * @param label label 
     159     * @return Button 
     160     */ 
     161    protected Button createPushButton(Composite parent, String label) 
     162    { 
     163    Button button = new Button(parent, SWT.PUSH); 
     164    button.setFont(parent.getFont()); 
     165    button.setText(label); 
     166    fDialog.setButtonLayoutData(button); 
     167    return button; 
     168    } 
     169 
     170    /** 
     171     * Create some empty space  
     172     */ 
     173    protected void createVerticalSpacer(Composite comp, int colSpan) 
     174    { 
     175    Label label = new Label(comp, SWT.NONE); 
     176    GridData gd = new GridData(); 
     177    gd.horizontalSpan = colSpan; 
     178    label.setLayoutData(gd); 
     179    } 
     180 
     181    /** 
     182     * Initializes this control based on the settings in the given 
     183     * vm install and type. 
     184     *  
     185     * @param vm vm or <code>null</code> if none 
     186     * @param type type of vm install 
     187     */ 
     188    public void initializeFrom(ICompilerInstall vm, ICompilerInstallType type) 
     189    { 
     190    fCompilerInstall = vm; 
     191    fCompilerInstallType = type; 
     192    if (vm != null) 
     193    { 
     194        setHomeDirectory(vm.getInstallLocation()); 
     195        //TODO: 
     196        //fDirectoryContentProvider.setLibraries(JavaRuntime.getLibraryLocations(getVMInstall())); 
     197    } 
     198    update(); 
     199    } 
     200 
     201    /** 
     202     * Sets the home directory of the VM Install the user has chosen 
     203     */ 
     204    public void setHomeDirectory(File file) 
     205    { 
     206    fHome = file; 
     207    } 
     208 
     209    /** 
     210     * Returns the home directory 
     211     */ 
     212    protected File getHomeDirectory() 
     213    { 
     214    return fHome; 
     215    } 
     216 
     217    /** 
     218     * Updates buttons and status based on current libraries 
     219     */ 
     220    public void update() 
     221    { 
     222    updateButtons(); 
     223    IStatus status = Status.OK_STATUS; 
     224    //TODO: 
     225    fDialog.setSystemLibraryStatus(status); 
     226    fDialog.updateStatusLine(); 
     227    } 
     228 
     229    /** 
     230     * Saves settings in the given working copy 
     231     */ 
     232    public void performApply(ICompilerInstall compilerInstall) 
     233    { 
     234    if (isDefaultLocations()) 
     235    { 
     236        compilerInstall.setLibraryLocations(null); 
     237    } 
     238    else 
     239    { 
     240        //TODO: 
     241        //compilerInstall.setLibraryLocations(libs); 
     242    } 
     243    } 
     244 
     245    /** 
     246     * Determines if the present setup is the default location s for this JRE 
     247     * @return true if the current set of locations are the defaults, false otherwise 
     248     */ 
     249    protected boolean isDefaultLocations() 
     250    { 
     251    return fDirectoryList.getItems().length == 0; 
     252    } 
     253 
     254    /** 
     255     * Returns the vm install associated with this library block. 
     256     *  
     257     * @return vm install 
     258     */ 
     259    protected ICompilerInstall getVMInstall() 
     260    { 
     261    return fCompilerInstall; 
     262    } 
     263 
     264    /** 
     265     * Returns the vm install type associated with this library block. 
     266     *  
     267     * @return vm install 
     268     */ 
     269    protected ICompilerInstallType getVMInstallType() 
     270    { 
     271    return fCompilerInstallType; 
     272    } 
     273 
     274    /* (non-Javadoc) 
     275     * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) 
     276     */ 
     277    public void widgetSelected(SelectionEvent e) 
     278    { 
     279    Object source = e.getSource(); 
     280    if (source == fUpButton) 
     281    { 
     282        //TODO: 
     283    } 
     284    else if (source == fDownButton) 
     285    { 
     286        //          //TODO: 
     287    } 
     288    else if (source == fRemoveButton) 
     289    { 
     290        fDirectoryList.remove(fDirectoryList.getSelectionIndex()); 
     291    } 
     292    else if (source == fAddButton) 
     293    { 
     294        DirectoryDialog dialog = new DirectoryDialog(fDirectoryList 
     295            .getShell(), SWT.SINGLE); 
     296        dialog.setText("Include Path Selection"); 
     297 
     298        String res = dialog.open(); 
     299        if (res == null) 
     300        return; 
     301 
     302        IPath path = new Path(res); 
     303 
     304        fDirectoryList.add(path.toString()); 
     305    } 
     306    else if (source == fRemoveAllButton) 
     307    { 
     308        restoreDefaultDirectories(); 
     309    } 
     310    update(); 
     311    } 
     312 
     313    /* (non-Javadoc) 
     314     * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent) 
     315     */ 
     316    public void widgetDefaultSelected(SelectionEvent e) 
     317    { 
     318    updateButtons(); 
     319    } 
     320 
     321    /* (non-Javadoc) 
     322     * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) 
     323     */ 
     324    public void selectionChanged(SelectionChangedEvent event) 
     325    { 
     326    updateButtons(); 
     327    } 
     328 
     329    /** 
     330     * Refresh the enable/disable state for the buttons. 
     331     */ 
     332    private void updateButtons() 
     333    { 
     334    fRemoveButton.setEnabled(fDirectoryList.getSelectionCount() > 0); 
     335    fUpButton.setEnabled(fDirectoryList.getSelectionCount() > 0); 
     336    fDownButton.setEnabled(fDirectoryList.getSelectionCount() > 0); 
     337    } 
    447338} 
  • oranda_4-14-08/descent.ui/src/descent/internal/debug/ui/jres/IAddCompilerDialogRequestor.java

    r559 r1111  
    22 
    33 
    4 import descent.launching.IVMInstall; 
     4import descent.launching.ICompilerInstall; 
    55 
    66/** 
    7  * This interface is implemented by clients of the <code>AddVMDialog</code>. 
     7 * This interface is implemented by clients of the <code>AddCompilerDialog</code>. 
    88 */ 
    9 public interface IAddVMDialogRequestor { 
     9public interface IAddCompilerDialogRequestor { 
    1010 
    1111    /** 
     
    1313     * constitute a duplicate. 
    1414     *  
    15      * @param name the name of a potential new VM 
    16      * @return whether a new VM with the specified name would be a duplicate VM 
     15     * @param name the name of a potential new compiler 
     16     * @return whether a new compiler with the specified name would be a duplicate compiler 
    1717     */ 
    1818    public boolean isDuplicateName(String name); 
    1919     
    2020    /** 
    21      * Notification that a VM has been added from the <code>AddVMDialog</code>. 
     21     * Notification that a compiler has been added from the <code>AddCompilerDialog</code>. 
    2222     *  
    23      * @param vm the added vm 
     23     * @param compiler the added vm 
    2424     */ 
    25     public void vmAdded(IVMInstall vm); 
     25    public void compilerAdded(ICompilerInstall compiler); 
    2626     
    2727} 
  • oranda_4-14-08/descent.ui/src/descent/internal/debug/ui/jres/InstalledCompilersBlock.java

    r598 r1111  
    5959import descent.internal.ui.JavaPlugin; 
    6060import descent.launching.AbstractVMInstallType; 
    61 import descent.launching.IVMInstall; 
    62 import descent.launching.IVMInstallType; 
     61import descent.launching.ICompilerInstall; 
     62import descent.launching.ICompilerInstallType; 
    6363import descent.launching.JavaRuntime; 
    6464import descent.launching.VMStandin; 
     
    6767 
    6868/** 
    69  * A composite that displays installed JRE's in a table. JREs can be  
     69 * A composite that displays installed compilers's in a table. Compilerss can be  
    7070 * added, removed, edited, and searched for. 
    7171 * <p> 
    7272 * This block implements ISelectionProvider - it sends selection change events 
    73  * when the checked JRE in the table changes, or when the "use default" button 
     73 * when the checked compiler in the table changes, or when the "use default" button 
    7474 * check state changes. 
    7575 * </p> 
    7676 */ 
    77 public class InstalledJREsBlock implements IAddVMDialogRequestor, ISelectionProvider { 
    78      
     77public class InstalledCompilersBlock implements IAddCompilerDialogRequestor, 
     78    ISelectionProvider 
     79
     80 
     81    /** 
     82     * This block's control 
     83     */ 
     84    private Composite fControl; 
     85 
     86    /** 
     87     * VMs being displayed 
     88     */ 
     89    private List fCompilers = new ArrayList(); 
     90 
     91    /** 
     92     * The main list control 
     93     */ 
     94    private CheckboxTableViewer fCompilerList; 
     95 
     96    // Action buttons 
     97    private Button fAddButton; 
     98 
     99    private Button fRemoveButton; 
     100 
     101    private Button fEditButton; 
     102 
     103    private Button fCopyButton; 
     104 
     105    private Button fSearchButton; 
     106 
     107    // index of column used for sorting 
     108    private int fSortColumn = 0; 
     109 
     110    /** 
     111     * Selection listeners (checked JRE changes) 
     112     */ 
     113    private ListenerList fSelectionListeners = new ListenerList(); 
     114 
     115    /** 
     116     * Previous selection 
     117     */ 
     118    private ISelection fPrevSelection = new StructuredSelection(); 
     119 
     120    private Table fTable; 
     121 
     122    // Make sure that CompilerStandin ids are unique if multiple calls to System.currentTimeMillis() 
     123    // happen very quickly 
     124    private static String fgLastUsedID; 
     125 
     126    /**  
     127     * Content provider to show a list of JREs 
     128     */ 
     129    class CompilersContentProvider implements IStructuredContentProvider 
     130    { 
     131    public Object[] getElements(Object input) 
     132    { 
     133        return fCompilers.toArray(); 
     134    } 
     135 
     136    public void inputChanged(Viewer viewer, Object oldInput, Object newInput) 
     137    { 
     138    } 
     139 
     140    public void dispose() 
     141    { 
     142    } 
     143    } 
     144 
     145    /** 
     146     * Label provider for installed compilers table. 
     147     */ 
     148    class CompilerLabelProvider extends LabelProvider implements ITableLabelProvider 
     149    { 
     150 
    79151    /** 
    80      * This block's control 
     152     * @see ITableLabelProvider#getColumnText(Object, int) 
    81153     */ 
    82     private Composite fControl; 
    83      
     154    public String getColumnText(Object element, int columnIndex) 
     155    { 
     156        if (element instanceof ICompilerInstall) 
     157        { 
     158        ICompilerInstall vm = (ICompilerInstall) element; 
     159        switch (columnIndex) { 
     160        case 0: 
     161            if (isContributed(vm)) 
     162            { 
     163            return MessageFormat.format( 
     164                JREMessages.InstalledJREsBlock_19, new String[] 
     165                { vm.getName() }); 
     166            } 
     167            return vm.getName(); 
     168        case 1: 
     169            return vm.getInstallLocation().getAbsolutePath(); 
     170        case 2: 
     171            return vm.getVMInstallType().getName(); 
     172        } 
     173        } 
     174        return element.toString(); 
     175    } 
     176 
    84177    /** 
    85      * VMs being displayed 
     178     * @see ITableLabelProvider#getColumnImage(Object, int) 
    86179     */ 
    87     private List fVMs = new ArrayList();  
    88      
    89     /** 
    90      * The main list control 
    91      */  
    92     private CheckboxTableViewer fVMList; 
    93      
    94     // Action buttons 
    95     private Button fAddButton; 
    96     private Button fRemoveButton; 
    97     private Button fEditButton; 
    98     private Button fCopyButton; 
    99     private Button fSearchButton;    
    100      
    101     // index of column used for sorting 
    102     private int fSortColumn = 0; 
    103      
    104     /** 
    105      * Selection listeners (checked JRE changes) 
    106      */ 
    107     private ListenerList fSelectionListeners = new ListenerList(); 
    108      
    109     /** 
    110      * Previous selection 
    111      */ 
    112     private ISelection fPrevSelection = new StructuredSelection(); 
    113  
    114     private Table fTable; 
    115              
    116     // Make sure that VMStandin ids are unique if multiple calls to System.currentTimeMillis() 
    117     // happen very quickly 
    118     private static String fgLastUsedID;  
    119      
    120     /**  
    121      * Content provider to show a list of JREs 
    122      */  
    123     class JREsContentProvider implements IStructuredContentProvider {        
    124         public Object[] getElements(Object input) { 
    125             return fVMs.toArray(); 
    126         } 
    127         public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { 
    128         } 
    129         public void dispose() { 
    130         } 
    131     } 
    132      
    133     /** 
    134      * Label provider for installed JREs table. 
    135      */ 
    136     class VMLabelProvider extends LabelProvider implements ITableLabelProvider { 
    137  
    138         /** 
    139          * @see ITableLabelProvider#getColumnText(Object, int) 
    140          */ 
    141         public String getColumnText(Object element, int columnIndex) { 
    142             if (element instanceof IVMInstall) { 
    143                 IVMInstall vm= (IVMInstall)element; 
    144                 switch(columnIndex) { 
    145                     case 0: 
    146                         if (isContributed(vm)) { 
    147                             return MessageFormat.format(JREMessages.InstalledJREsBlock_19, new String[]{vm.getName()}); 
    148                         } 
    149                         return vm.getName(); 
    150                     case 1: 
    151                         return vm.getInstallLocation().getAbsolutePath(); 
    152                     case 2:  
    153                         return vm.getVMInstallType().getName();                      
    154                 } 
     180    public Image getColumnImage(Object element, int columnIndex) 
     181    { 
     182        if (columnIndex == 0) 
     183        { 
     184        return JavaUI.getSharedImages().getImage( 
     185            ISharedImages.IMG_OBJS_LIBRARY); 
     186        } 
     187        return null; 
     188    } 
     189 
     190    } 
     191 
     192    /* (non-Javadoc) 
     193     * @see org.eclipse.jface.viewers.ISelectionProvider#addSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) 
     194     */ 
     195    public void addSelectionChangedListener(ISelectionChangedListener listener) 
     196    { 
     197    fSelectionListeners.add(listener); 
     198    } 
     199 
     200    /* (non-Javadoc) 
     201     * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection() 
     202     */ 
     203    public ISelection getSelection() 
     204    { 
     205    return new StructuredSelection(fCompilerList.getCheckedElements()); 
     206    } 
     207 
     208    /* (non-Javadoc) 
     209     * @see org.eclipse.jface.viewers.ISelectionProvider#removeSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) 
     210     */ 
     211    public void removeSelectionChangedListener( 
     212        ISelectionChangedListener listener) 
     213    { 
     214    fSelectionListeners.remove(listener); 
     215    } 
     216 
     217    /* (non-Javadoc) 
     218     * @see org.eclipse.jface.viewers.ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection) 
     219     */ 
     220    public void setSelection(ISelection selection) 
     221    { 
     222    if (selection instanceof IStructuredSelection) 
     223    { 
     224        if (!selection.equals(fPrevSelection)) 
     225        { 
     226        fPrevSelection = selection; 
     227        Object jre = ((IStructuredSelection) selection) 
     228            .getFirstElement(); 
     229        if (jre == null) 
     230        { 
     231            fCompilerList.setCheckedElements(new Object[0]); 
     232        } 
     233        else 
     234        { 
     235            fCompilerList.setCheckedElements(new Object[] 
     236            { jre }); 
     237            fCompilerList.reveal(jre); 
     238        } 
     239        fireSelectionChanged(); 
     240        } 
     241    } 
     242    } 
     243 
     244    /** 
     245     * Creates this block's control in the given control. 
     246     *  
     247     * @param ancestor containing control 
     248     * @param useManageButton whether to present a single 'manage...' button to 
     249     *  the user that opens the installed JREs pref page for JRE management, 
     250     *  or to provide 'add, remove, edit, and search' buttons. 
     251     */ 
     252    public void createControl(Composite ancestor) 
     253    { 
     254 
     255    Composite parent = new Composite(ancestor, SWT.NULL); 
     256    GridLayout layout = new GridLayout(); 
     257    layout.numColumns = 2; 
     258    layout.marginHeight = 0; 
     259    layout.marginWidth = 0; 
     260    parent.setLayout(layout); 
     261    Font font = ancestor.getFont(); 
     262    parent.setFont(font); 
     263    fControl = parent; 
     264 
     265    GridData data; 
     266 
     267    Label tableLabel = new Label(parent, SWT.NONE); 
     268    tableLabel.setText(JREMessages.InstalledJREsBlock_15); 
     269    data = new GridData(); 
     270    data.horizontalSpan = 2; 
     271    tableLabel.setLayoutData(data); 
     272    tableLabel.setFont(font); 
     273 
     274    fTable = new Table(parent, SWT.CHECK | SWT.BORDER | SWT.MULTI 
     275        | SWT.FULL_SELECTION); 
     276 
     277    data = new GridData(GridData.FILL_BOTH); 
     278    data.widthHint = 450; 
     279    fTable.setLayoutData(data); 
     280    fTable.setFont(font); 
     281 
     282    fTable.setHeaderVisible(true); 
     283    fTable.setLinesVisible(true); 
     284 
     285    TableColumn column1 = new TableColumn(fTable, SWT.NULL); 
     286    column1.setText(JREMessages.InstalledJREsBlock_0); 
     287    column1.addSelectionListener(new SelectionAdapter() 
     288    { 
     289        public void widgetSelected(SelectionEvent e) 
     290        { 
     291        sortByName(); 
     292        } 
     293    }); 
     294 
     295    TableColumn column2 = new TableColumn(fTable, SWT.NULL); 
     296    column2.setText(JREMessages.InstalledJREsBlock_1); 
     297    column2.addSelectionListener(new SelectionAdapter() 
     298    { 
     299        public void widgetSelected(SelectionEvent e) 
     300        { 
     301        sortByLocation(); 
     302        } 
     303    }); 
     304 
     305    TableColumn column3 = new TableColumn(fTable, SWT.NULL); 
     306    column3.setText(JREMessages.InstalledJREsBlock_2); 
     307    column3.addSelectionListener(new SelectionAdapter() 
     308    { 
     309        public void widgetSelected(SelectionEvent e) 
     310        { 
     311        sortByType(); 
     312        } 
     313    }); 
     314 
     315    fCompilerList = new CheckboxTableViewer(fTable); 
     316    fCompilerList.setLabelProvider(new CompilerLabelProvider()); 
     317    fCompilerList.setContentProvider(new CompilersContentProvider()); 
     318    // by default, sort by name 
     319    sortByName(); 
     320 
     321    fCompilerList.addSelectionChangedListener(new ISelectionChangedListener() 
     322    { 
     323        public void selectionChanged(SelectionChangedEvent evt) 
     324        { 
     325        enableButtons(); 
     326        } 
     327    }); 
     328 
     329    fCompilerList.addCheckStateListener(new ICheckStateListener() 
     330    { 
     331        public void checkStateChanged(CheckStateChangedEvent event) 
     332        { 
     333        if (event.getChecked()) 
     334        { 
     335            setCheckedCompiler((ICompilerInstall) event.getElement()); 
     336        } 
     337        else 
     338        { 
     339            setCheckedCompiler(null); 
     340        } 
     341        } 
     342    }); 
     343 
     344    fCompilerList.addDoubleClickListener(new IDoubleClickListener() 
     345    { 
     346        public void doubleClick(DoubleClickEvent e) 
     347        { 
     348        if (!fCompilerList.getSelection().isEmpty()) 
     349        { 
     350            editVM(); 
     351        } 
     352        } 
     353    }); 
     354    fTable.addKeyListener(new KeyAdapter() 
     355    { 
     356        public void keyPressed(KeyEvent event) 
     357        { 
     358        if (event.character == SWT.DEL && event.stateMask == 0) 
     359        { 
     360            removeVMs(); 
     361        } 
     362        } 
     363    }); 
     364 
     365    Composite buttons = new Composite(parent, SWT.NULL); 
     366    buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); 
     367    layout = new GridLayout(); 
     368    layout.marginHeight = 0; 
     369    layout.marginWidth = 0; 
     370    buttons.setLayout(layout); 
     371    buttons.setFont(font); 
     372 
     373    fAddButton = createPushButton(buttons, JREMessages.InstalledJREsBlock_3); 
     374    fAddButton.addListener(SWT.Selection, new Listener() 
     375    { 
     376        public void handleEvent(Event evt) 
     377        { 
     378        addVM(); 
     379        } 
     380    }); 
     381 
     382    fEditButton = createPushButton(buttons, 
     383        JREMessages.InstalledJREsBlock_4); 
     384    fEditButton.addListener(SWT.Selection, new Listener() 
     385    { 
     386        public void handleEvent(Event evt) 
     387        { 
     388        editVM(); 
     389        } 
     390    }); 
     391 
     392    fCopyButton = createPushButton(buttons, 
     393        JREMessages.InstalledJREsBlock_16); 
     394    fCopyButton.addListener(SWT.Selection, new Listener() 
     395    { 
     396        public void handleEvent(Event evt) 
     397        { 
     398        copyVM(); 
     399        } 
     400    }); 
     401 
     402    fRemoveButton = createPushButton(buttons, 
     403        JREMessages.InstalledJREsBlock_5); 
     404    fRemoveButton.addListener(SWT.Selection, new Listener() 
     405    { 
     406        public void handleEvent(Event evt) 
     407        { 
     408        removeVMs(); 
     409        } 
     410    }); 
     411 
     412    // copied from ListDialogField.CreateSeparator() 
     413    Label separator = new Label(buttons, SWT.NONE); 
     414    separator.setVisible(false); 
     415    GridData gd = new GridData(); 
     416    gd.horizontalAlignment = GridData.FILL; 
     417    gd.verticalAlignment = GridData.BEGINNING; 
     418    gd.heightHint = 4; 
     419    separator.setLayoutData(gd); 
     420 
     421    fSearchButton = createPushButton(buttons, 
     422        JREMessages.InstalledJREsBlock_6); 
     423    fSearchButton.addListener(SWT.Selection, new Listener() 
     424    { 
     425        public void handleEvent(Event evt) 
     426        { 
     427        search(); 
     428        } 
     429    }); 
     430 
     431    fillWithWorkspaceJREs(); 
     432    enableButtons(); 
     433    fAddButton.setEnabled(JavaRuntime.getVMInstallTypes().length > 0); 
     434    } 
     435 
     436    /** 
     437     * Adds a duplicate of the selected VM to the block  
     438     * @since 3.2 
     439     */ 
     440    protected void copyVM() 
     441    { 
     442    IStructuredSelection selection = (IStructuredSelection) fCompilerList 
     443        .getSelection(); 
     444    Iterator it = selection.iterator(); 
     445 
     446    ArrayList newEntries = new ArrayList(); 
     447    while (it.hasNext()) 
     448    { 
     449        ICompilerInstall selectedVM = (ICompilerInstall) it.next(); 
     450 
     451        // duplicate & add vm 
     452        VMStandin standin = new VMStandin(selectedVM, 
     453            createUniqueId(selectedVM.getVMInstallType())); 
     454        standin.setName(generateName(selectedVM.getName())); 
     455        AddCompilerDialog dialog = new AddCompilerDialog(this, getShell(), JavaRuntime 
     456            .getVMInstallTypes(), standin); 
     457        dialog.setTitle(JREMessages.InstalledJREsBlock_18); 
     458        if (dialog.open() != Window.OK) 
     459        { 
     460        return; 
     461        } 
     462        newEntries.add(standin); 
     463        fCompilers.add(standin); 
     464    } 
     465    fCompilerList.refresh(); 
     466    fCompilerList.setSelection(new StructuredSelection(newEntries.toArray())); 
     467    } 
     468 
     469    /** 
     470     * Compares the given name against current names and adds the appropriate numerical  
     471     * suffix to ensure that it is unique. 
     472     * @param name the name with which to ensure uniqueness  
     473     * @return the unique version of the given name 
     474     * @since 3.2 
     475     */ 
     476    public String generateName(String name) 
     477    { 
     478    if (!isDuplicateName(name)) 
     479    { 
     480        return name; 
     481    } 
     482 
     483    if (name.matches(".*\\(\\d*\\)")) { //$NON-NLS-1$ 
     484        int start = name.lastIndexOf('('); 
     485        int end = name.lastIndexOf(')'); 
     486        String stringInt = name.substring(start + 1, end); 
     487        int numericValue = Integer.parseInt(stringInt); 
     488        String newName = name.substring(0, start + 1) + (numericValue + 1) 
     489            + ")"; //$NON-NLS-1$ 
     490        return generateName(newName); 
     491    } 
     492    else 
     493    { 
     494        return generateName(name + " (1)"); //$NON-NLS-1$ 
     495    } 
     496    } 
     497 
     498    /** 
     499     * Fire current selection 
     500     */ 
     501    private void fireSelectionChanged() 
     502    { 
     503    SelectionChangedEvent event = new SelectionChangedEvent(this, 
     504        getSelection()); 
     505    Object[] listeners = fSelectionListeners.getListeners(); 
     506    for (int i = 0; i < listeners.length; i++) 
     507    { 
     508        ISelectionChangedListener listener = (ISelectionChangedListener) listeners[i]; 
     509        listener.selectionChanged(event); 
     510    } 
     511    } 
     512 
     513    /** 
     514     * Sorts by VM type, and name within type. 
     515     */ 
     516    private void sortByType() 
     517    { 
     518    fCompilerList.setSorter(new ViewerSorter() 
     519    { 
     520        public int compare(Viewer viewer, Object e1, Object e2) 
     521        { 
     522        if ((e1 instanceof ICompilerInstall) && (e2 instanceof ICompilerInstall)) 
     523        { 
     524            ICompilerInstall left = (ICompilerInstall) e1; 
     525            ICompilerInstall right = (ICompilerInstall) e2; 
     526            String leftType = left.getVMInstallType().getName(); 
     527            String rightType = right.getVMInstallType().getName(); 
     528            int res = leftType.compareToIgnoreCase(rightType); 
     529            if (res != 0) 
     530            { 
     531            return res; 
     532            } 
     533            return left.getName().compareToIgnoreCase(right.getName()); 
     534        } 
     535        return super.compare(viewer, e1, e2); 
     536        } 
     537 
     538        public boolean isSorterProperty(Object element, String property) 
     539        { 
     540        return true; 
     541        } 
     542    }); 
     543    fSortColumn = 3; 
     544    } 
     545 
     546    /** 
     547     * Sorts by VM name. 
     548     */ 
     549    private void sortByName() 
     550    { 
     551    fCompilerList.setSorter(new ViewerSorter() 
     552    { 
     553        public int compare(Viewer viewer, Object e1, Object e2) 
     554        { 
     555        if ((e1 instanceof ICompilerInstall) && (e2 instanceof ICompilerInstall)) 
     556        { 
     557            ICompilerInstall left = (ICompilerInstall) e1; 
     558            ICompilerInstall right = (ICompilerInstall) e2; 
     559            return left.getName().compareToIgnoreCase(right.getName()); 
     560        } 
     561        return super.compare(viewer, e1, e2); 
     562        } 
     563 
     564        public boolean isSorterProperty(Object element, String property) 
     565        { 
     566        return true; 
     567        } 
     568    }); 
     569    fSortColumn = 1; 
     570    } 
     571 
     572    /** 
     573     * Sorts by VM location. 
     574     */ 
     575    private void sortByLocation() 
     576    { 
     577    fCompilerList.setSorter(new ViewerSorter() 
     578    { 
     579        public int compare(Viewer viewer, Object e1, Object e2) 
     580        { 
     581        if ((e1 instanceof ICompilerInstall) && (e2 instanceof ICompilerInstall)) 
     582        { 
     583            ICompilerInstall left = (ICompilerInstall) e1; 
     584            ICompilerInstall right = (ICompilerInstall) e2; 
     585            return left.getInstallLocation().getAbsolutePath() 
     586                .compareToIgnoreCase( 
     587                    right.getInstallLocation() 
     588                        .getAbsolutePath()); 
     589        } 
     590        return super.compare(viewer, e1, e2); 
     591        } 
     592 
     593        public boolean isSorterProperty(Object element, String property) 
     594        { 
     595        return true; 
     596        } 
     597    }); 
     598    fSortColumn = 2; 
     599    } 
     600 
     601    private void enableButtons() 
     602    { 
     603    IStructuredSelection selection = (IStructuredSelection) fCompilerList 
     604        .getSelection(); 
     605    int selectionCount = selection.size(); 
     606    fEditButton.setEnabled(selectionCount == 1); 
     607    fCopyButton.setEnabled(selectionCount > 0); 
     608    if (selectionCount > 0 
     609        && selectionCount < fCompilerList.getTable().getItemCount()) 
     610    { 
     611        Iterator iterator = selection.iterator(); 
     612        while (iterator.hasNext()) 
     613        { 
     614        ICompilerInstall install = (ICompilerInstall) iterator.next(); 
     615        if (isContributed(install)) 
     616        { 
     617            fRemoveButton.setEnabled(false); 
     618            return; 
     619        } 
     620        } 
     621        fRemoveButton.setEnabled(true); 
     622    } 
     623    else 
     624    { 
     625        fRemoveButton.setEnabled(false); 
     626    } 
     627    } 
     628 
     629    private boolean isContributed(ICompilerInstall install) 
     630    { 
     631    return JavaRuntime.isContributedVMInstall(install.getId()); 
     632    } 
     633 
     634    protected Button createPushButton(Composite parent, String label) 
     635    { 
     636    //return SWTUtil.createPushButton(parent, label, null); 
     637    Button button = new Button(parent, SWT.PUSH); 
     638    button.setFont(parent.getFont()); 
     639    button.setText(label); 
     640    return button; 
     641    } 
     642 
     643    /** 
     644     * Returns this block's control 
     645     *  
     646     * @return control 
     647     */ 
     648    public Control getControl() 
     649    { 
     650    return fControl; 
     651    } 
     652 
     653    /** 
     654     * Sets the JREs to be displayed in this block 
     655     *  
     656     * @param vms JREs to be displayed 
     657     */ 
     658    protected void setJREs(ICompilerInstall[] vms) 
     659    { 
     660    fCompilers.clear(); 
     661    for (int i = 0; i < vms.length; i++) 
     662    { 
     663        fCompilers.add(vms[i]); 
     664    } 
     665    fCompilerList.setInput(fCompilers); 
     666    fCompilerList.refresh(); 
     667    } 
     668 
     669    /** 
     670     * Returns the JREs currently being displayed in this block 
     671     *  
     672     * @return JREs currently being displayed in this block 
     673     */ 
     674    public ICompilerInstall[] getJREs() 
     675    { 
     676    return (ICompilerInstall[]) fCompilers.toArray(new ICompilerInstall[fCompilers.size()]); 
     677    } 
     678 
     679    /** 
     680     * Bring up a dialog that lets the user create a new VM definition. 
     681     */ 
     682    private void addVM() 
     683    { 
     684    AddCompilerDialog dialog = new AddCompilerDialog(this, getShell(), JavaRuntime 
     685        .getVMInstallTypes(), null); 
     686    dialog.setTitle(JREMessages.InstalledJREsBlock_7); 
     687    if (dialog.open() != Window.OK) 
     688    { 
     689        return; 
     690    } 
     691    fCompilerList.refresh(); 
     692    } 
     693 
     694    /** 
     695     * @see IAddCompilerDialogRequestor#compilerAdded(ICompilerInstall) 
     696     */ 
     697    public void compilerAdded(ICompilerInstall vm) 
     698    { 
     699    fCompilers.add(vm); 
     700    fCompilerList.refresh(); 
     701    } 
     702 
     703    /** 
     704     * @see IAddCompilerDialogRequestor#isDuplicateName(String) 
     705     */ 
     706    public boolean isDuplicateName(String name) 
     707    { 
     708    for (int i = 0; i < fCompilers.size(); i++) 
     709    { 
     710        ICompilerInstall vm = (ICompilerInstall) fCompilers.get(i); 
     711        if (vm.getName().equals(name)) 
     712        { 
     713        return true; 
     714        } 
     715    } 
     716    return false; 
     717    } 
     718 
     719    private void editVM() 
     720    { 
     721    IStructuredSelection selection = (IStructuredSelection) fCompilerList 
     722        .getSelection(); 
     723    ICompilerInstall vm = (ICompilerInstall) selection.getFirstElement(); 
     724    if (vm == null) 
     725    { 
     726        return; 
     727    } 
     728    if (isContributed(vm)) 
     729    { 
     730        VMDetailsDialog dialog = new VMDetailsDialog(getShell(), vm); 
     731        dialog.open(); 
     732    } 
     733    else 
     734    { 
     735        AddCompilerDialog dialog = new AddCompilerDialog(this, getShell(), JavaRuntime 
     736            .getVMInstallTypes(), vm); 
     737        dialog.setTitle(JREMessages.InstalledJREsBlock_8); 
     738        if (dialog.open() != Window.OK) 
     739        { 
     740        return; 
     741        } 
     742        fCompilerList.refresh(vm); 
     743    } 
     744    } 
     745 
     746    private void removeVMs() 
     747    { 
     748    IStructuredSelection selection = (IStructuredSelection) fCompilerList 
     749        .getSelection(); 
     750    ICompilerInstall[] vms = new ICompilerInstall[selection.size()]; 
     751    Iterator iter = selection.iterator(); 
     752    int i = 0; 
     753    while (iter.hasNext()) 
     754    { 
     755        vms[i] = (ICompilerInstall) iter.next(); 
     756        i++; 
     757    } 
     758    removeJREs(vms); 
     759    } 
     760 
     761    /** 
     762     * Removes the given VMs from the table. 
     763     *  
     764     * @param vms 
     765     */ 
     766    public void removeJREs(ICompilerInstall[] vms) 
     767    { 
     768    IStructuredSelection prev = (IStructuredSelection) getSelection(); 
     769    for (int i = 0; i < vms.length; i++) 
     770    { 
     771        fCompilers.remove(vms[i]); 
     772    } 
     773    fCompilerList.refresh(); 
     774    IStructuredSelection curr = (IStructuredSelection) getSelection(); 
     775    if (!curr.equals(prev)) 
     776    { 
     777        ICompilerInstall[] installs = getJREs(); 
     778        if (curr.size() == 0 && installs.length == 1) 
     779        { 
     780        // pick a default VM automatically 
     781        setSelection(new StructuredSelection(installs[0])); 
     782        } 
     783        else 
     784        { 
     785        fireSelectionChanged(); 
     786        } 
     787    } 
     788    } 
     789 
     790    /** 
     791     * Search for installed VMs in the file system 
     792     */ 
     793    protected void search() 
     794    { 
     795 
     796    // choose a root directory for the search  
     797    DirectoryDialog dialog = new DirectoryDialog(getShell()); 
     798    dialog.setMessage(JREMessages.InstalledJREsBlock_9); 
     799    dialog.setText(JREMessages.InstalledJREsBlock_10); 
     800    String path = dialog.open(); 
     801    if (path == null) 
     802    { 
     803        return; 
     804    } 
     805 
     806    // ignore installed locations 
     807    final Set exstingLocations = new HashSet(); 
     808    Iterator iter = fCompilers.iterator(); 
     809    while (iter.hasNext()) 
     810    { 
     811        exstingLocations.add(((ICompilerInstall) iter.next()) 
     812            .getInstallLocation()); 
     813    } 
     814 
     815    // search 
     816    final File rootDir = new File(path); 
     817    final List locations = new ArrayList(); 
     818    final List types = new ArrayList(); 
     819 
     820    IRunnableWithProgress r = new IRunnableWithProgress() 
     821    { 
     822        public void run(IProgressMonitor monitor) 
     823        { 
     824        monitor.beginTask(JREMessages.InstalledJREsBlock_11, 
     825            IProgressMonitor.UNKNOWN); 
     826        search(rootDir, locations, types, exstingLocations, monitor); 
     827        monitor.done(); 
     828        } 
     829    }; 
     830 
     831    try 
     832    { 
     833        ProgressMonitorDialog progress = new ProgressMonitorDialog( 
     834            getShell()); 
     835        progress.run(true, true, r); 
     836    } 
     837    catch (InvocationTargetException e) 
     838    { 
     839        JavaPlugin.log(e); 
     840    } 
     841    catch (InterruptedException e) 
     842    { 
     843        // cancelled 
     844        return; 
     845    } 
     846 
     847    if (locations.isEmpty()) 
     848    { 
     849        MessageDialog.openInformation(getShell(), 
     850            JREMessages.InstalledJREsBlock_12, MessageFormat.format( 
     851                JREMessages.InstalledJREsBlock_13, new String[] 
     852                { path })); //  
     853    } 
     854    else 
     855    { 
     856        iter = locations.iterator(); 
     857        Iterator iter2 = types.iterator(); 
     858        while (iter.hasNext()) 
     859        { 
     860        File location = (File) iter.next(); 
     861        ICompilerInstallType type = (ICompilerInstallType) iter2.next(); 
     862        ICompilerInstall vm = new VMStandin(type, createUniqueId(type)); 
     863        String name = VMInstallTypeUtil 
     864            .getVMInstallName(type, location); 
     865        String nameCopy = new String(name); 
     866        int i = 1; 
     867        while (isDuplicateName(nameCopy)) 
     868        { 
     869            nameCopy = name + '(' + i++ + ')'; 
     870        } 
     871        vm.setName(nameCopy); 
     872        vm.setInstallLocation(location); 
     873        if (type instanceof AbstractVMInstallType) 
     874        { 
     875            //set default java doc location 
     876            AbstractVMInstallType abs = (AbstractVMInstallType) type; 
     877            vm.setJavadocLocation(abs 
     878                .getDefaultJavadocLocation(location)); 
     879        } 
     880        compilerAdded(vm); 
     881        } 
     882    } 
     883 
     884    } 
     885 
     886    protected Shell getShell() 
     887    { 
     888    return getControl().getShell(); 
     889    } 
     890 
     891    /** 
     892     * Find a unique VM id.  Check existing 'real' VMs, as well as the last id used for 
     893     * a VMStandin. 
     894     */ 
     895    private String createUniqueId(ICompilerInstallType vmType) 
     896    { 
     897    String id = null; 
     898    do 
     899    { 
     900        id = String.valueOf(System.currentTimeMillis()); 
     901    } while (vmType.findVMInstall(id) != null || id.equals(fgLastUsedID)); 
     902    fgLastUsedID = id; 
     903    return id; 
     904    } 
     905 
     906    /** 
     907     * Searches the specified directory recursively for installed VMs, adding each 
     908     * detected VM to the <code>found</code> list. Any directories specified in 
     909     * the <code>ignore</code> are not traversed. 
     910     *  
     911     * @param directory 
     912     * @param found 
     913     * @param types 
     914     * @param ignore 
     915     */ 
     916    protected void search(File directory, List found, List types, Set ignore, 
     917        IProgressMonitor monitor) 
     918    { 
     919    if (monitor.isCanceled()) 
     920    { 
     921        return; 
     922    } 
     923 
     924    String[] names = directory.list(); 
     925    if (names == null) 
     926    { 
     927        return; 
     928    } 
     929    List subDirs = new ArrayList(); 
     930    for (int i = 0; i < names.length; i++) 
     931    { 
     932        if (monitor.isCanceled()) 
     933        { 
     934        return; 
     935        } 
     936        File file = new File(directory, names[i]); 
     937        try 
     938        { 
     939        monitor.subTask(MessageFormat.format( 
     940            JREMessages.InstalledJREsBlock_14, new String[] 
     941            { Integer.toString(found.size()), 
     942                file.getCanonicalPath() })); 
     943        } 
     944        catch (IOException e) 
     945        { 
     946        } 
     947        ICompilerInstallType[] vmTypes = JavaRuntime.getVMInstallTypes(); 
     948        if (file.isDirectory()) 
     949        { 
     950        if (!ignore.contains(file)) 
     951        { 
     952            boolean validLocation = false; 
     953 
     954            // Take the first VM install type that claims the location as a 
     955            // valid VM install.  VM install types should be smart enough to not 
     956            // claim another type's VM, but just in case... 
     957            for (int j = 0; j < vmTypes.length; j++) 
     958            { 
     959            if (monitor.isCanceled()) 
     960            { 
     961                return; 
    155962            } 
    156             return element.toString(); 
    157         } 
    158  
    159         /** 
    160          * @see ITableLabelProvider#getColumnImage(Object, int) 
    161          */ 
    162         public Image getColumnImage(Object element, int columnIndex) { 
    163             if (columnIndex == 0) { 
    164                 return JavaUI.getSharedImages().getImage(ISharedImages.IMG_OBJS_LIBRARY); 
     963            ICompilerInstallType type = vmTypes[j]; 
     964            IStatus status = type.validateInstallLocation(file); 
     965            if (status.isOK()) 
     966            { 
     967                found.add(file); 
     968                types.add(type); 
     969                validLocation = true; 
     970                break; 
    165971            } 
    166             return null; 
    167         } 
    168  
    169     }    
    170      
    171     /* (non-Javadoc) 
    172      * @see org.eclipse.jface.viewers.ISelectionProvider#addSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) 
    173      */ 
    174     public void addSelectionChangedListener(ISelectionChangedListener listener) { 
    175         fSelectionListeners.add(listener); 
    176     } 
    177  
    178     /* (non-Javadoc) 
    179      * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection() 
    180      */ 
    181     public ISelection getSelection() { 
    182         return new StructuredSelection(fVMList.getCheckedElements()); 
    183     } 
    184  
    185     /* (non-Javadoc) 
    186      * @see org.eclipse.jface.viewers.ISelectionProvider#removeSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) 
    187      */ 
    188     public void removeSelectionChangedListener(ISelectionChangedListener listener) { 
    189         fSelectionListeners.remove(listener); 
    190     } 
    191  
    192     /* (non-Javadoc) 
    193      * @see org.eclipse.jface.viewers.ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection) 
    194      */ 
    195     public void setSelection(ISelection selection) { 
    196         if (selection instanceof IStructuredSelection) { 
    197             if (!selection.equals(fPrevSelection)) { 
    198                 fPrevSelection = selection; 
    199                 Object jre = ((IStructuredSelection)selection).getFirstElement(); 
    200                 if (jre == null) { 
    201                     fVMList.setCheckedElements(new Object[0]); 
    202                 } else { 
    203                     fVMList.setCheckedElements(new Object[]{jre}); 
    204                     fVMList.reveal(jre); 
    205                 } 
    206                 fireSelectionChanged(); 
    207             } 
    208         } 
    209     } 
    210  
    211     /** 
    212      * Creates this block's control in the given control. 
    213      *  
    214      * @param ancestor containing control 
    215      * @param useManageButton whether to present a single 'manage...' button to 
    216      *  the user that opens the installed JREs pref page for JRE management, 
    217      *  or to provide 'add, remove, edit, and search' buttons. 
    218      */ 
    219     public void createControl(Composite ancestor) { 
    220          
    221         Composite parent= new Composite(ancestor, SWT.NULL); 
    222         GridLayout layout= new GridLayout(); 
    223         layout.numColumns= 2; 
    224         layout.marginHeight = 0; 
    225         layout.marginWidth = 0; 
    226         parent.setLayout(layout); 
    227         Font font = ancestor.getFont(); 
    228         parent.setFont(font);    
    229         fControl = parent;   
    230          
    231         GridData data; 
    232                  
    233         Label tableLabel = new Label(parent, SWT.NONE); 
    234         tableLabel.setText(JREMessages.InstalledJREsBlock_15);  
    235         data = new GridData(); 
    236         data.horizontalSpan = 2; 
    237         tableLabel.setLayoutData(data); 
    238         tableLabel.setFont(font); 
    239                  
    240         fTable= new Table(parent, SWT.CHECK | SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION); 
    241          
    242         data= new GridData(GridData.FILL_BOTH); 
    243         data.widthHint = 450; 
    244         fTable.setLayoutData(data); 
    245         fTable.setFont(font); 
    246                  
    247         fTable.setHeaderVisible(true); 
    248         fTable.setLinesVisible(true);        
    249  
    250         TableColumn column1= new TableColumn(fTable, SWT.NULL); 
    251         column1.setText(JREMessages.InstalledJREsBlock_0);  
    252         column1.addSelectionListener(new SelectionAdapter() { 
    253             public void widgetSelected(SelectionEvent e) { 
    254                 sortByName(); 
    255             } 
    256         }); 
    257      
    258         TableColumn column2= new TableColumn(fTable, SWT.NULL); 
    259         column2.setText(JREMessages.InstalledJREsBlock_1);  
    260         column2.addSelectionListener(new SelectionAdapter() { 
    261             public void widgetSelected(SelectionEvent e) { 
    262                 sortByLocation(); 
    263             } 
    264         }); 
    265          
    266         TableColumn column3= new TableColumn(fTable, SWT.NULL); 
    267         column3.setText(JREMessages.InstalledJREsBlock_2);  
    268         column3.addSelectionListener(new SelectionAdapter() { 
    269             public void widgetSelected(SelectionEvent e) { 
    270                 sortByType(); 
    271             } 
    272         }); 
    273  
    274         fVMList= new CheckboxTableViewer(fTable);            
    275         fVMList.setLabelProvider(new VMLabelProvider()); 
    276         fVMList.setContentProvider(new JREsContentProvider()); 
    277         // by default, sort by name 
    278         sortByName(); 
    279          
    280         fVMList.addSelectionChangedListener(new ISelectionChangedListener() { 
    281             public void selectionChanged(SelectionChangedEvent evt) { 
    282                 enableButtons(); 
    283             } 
    284         }); 
    285          
    286         fVMList.addCheckStateListener(new ICheckStateListener() { 
    287             public void checkStateChanged(CheckStateChangedEvent event) { 
    288                 if (event.getChecked()) { 
    289                     setCheckedJRE((IVMInstall)event.getElement()); 
    290                 } else { 
    291                     setCheckedJRE(null); 
    292                 } 
    293             } 
    294         }); 
    295          
    296         fVMList.addDoubleClickListener(new IDoubleClickListener() { 
    297             public void doubleClick(DoubleClickEvent e) { 
    298                 if (!fVMList.getSelection().isEmpty()) { 
    299                     editVM(); 
    300                 } 
    301             } 
    302         }); 
    303         fTable.addKeyListener(new KeyAdapter() { 
    304             public void keyPressed(KeyEvent event) { 
    305                 if (event.character == SWT.DEL && event.stateMask == 0) { 
    306                     removeVMs(); 
    307                 } 
    308             } 
    309         });  
    310          
    311         Composite buttons= new Composite(parent, SWT.NULL); 
    312         buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); 
    313         layout= new GridLayout(); 
    314         layout.marginHeight= 0; 
    315         layout.marginWidth= 0; 
    316         buttons.setLayout(layout); 
    317         buttons.setFont(font); 
    318          
    319         fAddButton = createPushButton(buttons, JREMessages.InstalledJREsBlock_3);  
    320         fAddButton.addListener(SWT.Selection, new Listener() { 
    321             public void handleEvent(Event evt) { 
    322                 addVM(); 
    323             } 
    324         }); 
    325          
    326         fEditButton= createPushButton(buttons, JREMessages.InstalledJREsBlock_4);  
    327         fEditButton.addListener(SWT.Selection, new Listener() { 
    328             public void handleEvent(Event evt) { 
    329                 editVM(); 
    330             } 
    331         }); 
    332          
    333         fCopyButton = createPushButton(buttons, JREMessages.InstalledJREsBlock_16);  
    334         fCopyButton.addListener(SWT.Selection, new Listener() { 
    335             public void handleEvent(Event evt) { 
    336                 copyVM(); 
    337             } 
    338         }); 
    339          
    340         fRemoveButton= createPushButton(buttons, JREMessages.InstalledJREsBlock_5);  
    341         fRemoveButton.addListener(SWT.Selection, new Listener() { 
    342             public void handleEvent(Event evt) { 
    343                 removeVMs(); 
    344             } 
    345         }); 
    346          
    347         // copied from ListDialogField.CreateSeparator() 
    348         Label separator= new Label(buttons, SWT.NONE); 
    349         separator.setVisible(false); 
    350         GridData gd= new GridData(); 
    351         gd.horizontalAlignment= GridData.FILL; 
    352         gd.verticalAlignment= GridData.BEGINNING; 
    353         gd.heightHint= 4; 
    354         separator.setLayoutData(gd); 
    355          
    356         fSearchButton = createPushButton(buttons, JREMessages.InstalledJREsBlock_6);  
    357         fSearchButton.addListener(SWT.Selection, new Listener() { 
    358             public void handleEvent(Event evt) { 
    359                 search(); 
    360             } 
    361         });      
    362          
    363         fillWithWorkspaceJREs(); 
    364         enableButtons(); 
    365         fAddButton.setEnabled(JavaRuntime.getVMInstallTypes().length > 0); 
    366     } 
    367      
    368     /** 
    369      * Adds a duplicate of the selected VM to the block  
    370      * @since 3.2 
    371      */ 
    372     protected void copyVM() { 
    373         IStructuredSelection selection = (IStructuredSelection) fVMList.getSelection(); 
    374         Iterator it = selection.iterator(); 
    375  
    376         ArrayList newEntries = new ArrayList(); 
    377         while (it.hasNext()) { 
    378             IVMInstall selectedVM = (IVMInstall) it.next(); 
    379  
    380             // duplicate & add vm 
    381             VMStandin standin = new VMStandin(selectedVM, createUniqueId(selectedVM.getVMInstallType())); 
    382             standin.setName(generateName(selectedVM.getName())); 
    383             AddVMDialog dialog = new AddVMDialog(this, getShell(), JavaRuntime.getVMInstallTypes(), standin); 
    384             dialog.setTitle(JREMessages.InstalledJREsBlock_18); 
    385             if (dialog.open() != Window.OK) { 
    386                 return; 
    387             } 
    388             newEntries.add(standin); 
    389             fVMs.add(standin); 
    390         } 
    391         fVMList.refresh(); 
    392         fVMList.setSelection(new StructuredSelection(newEntries.toArray())); 
    393     } 
    394  
    395     /** 
    396      * Compares the given name against current names and adds the appropriate numerical  
    397      * suffix to ensure that it is unique. 
    398      * @param name the name with which to ensure uniqueness  
    399      * @return the unique version of the given name 
    400      * @since 3.2 
    401      */ 
    402     public String generateName(String name){ 
    403             if (!isDuplicateName(name)) { 
    404                 return name; 
    405             } 
    406              
    407             if (name.matches(".*\\(\\d*\\)")) { //$NON-NLS-1$ 
    408                 int start = name.lastIndexOf('('); 
    409                 int end = name.lastIndexOf(')'); 
    410                 String stringInt = name.substring(start+1, end); 
    411                 int numericValue = Integer.parseInt(stringInt); 
    412                 String newName = name.substring(0, start+1) + (numericValue+1) + ")"; //$NON-NLS-1$ 
    413                 return generateName(newName); 
    414             } else { 
    415                 return generateName(name + " (1)"); //$NON-NLS-1$ 
    416             } 
    417         } 
    418      
    419     /** 
    420      * Fire current selection 
    421      */ 
    422     private void fireSelectionChanged() { 
    423         SelectionChangedEvent event = new SelectionChangedEvent(this, getSelection()); 
    424         Object[] listeners = fSelectionListeners.getListeners(); 
    425         for (int i = 0; i < listeners.length; i++) { 
    426             ISelectionChangedListener listener = (ISelectionChangedListener)listeners[i]; 
    427             listener.selectionChanged(event); 
    428         }    
    429     } 
    430  
    431     /** 
    432      * Sorts by VM type, and name within type. 
    433      */ 
    434     private void sortByType() { 
    435         fVMList.setSorter(new ViewerSorter() { 
    436             public int compare(Viewer viewer, Object e1, Object e2) { 
    437                 if ((e1 instanceof IVMInstall) && (e2 instanceof IVMInstall)) { 
    438                     IVMInstall left= (IVMInstall)e1; 
    439                     IVMInstall right= (IVMInstall)e2; 
    440                     String leftType= left.getVMInstallType().getName(); 
    441                     String rightType= right.getVMInstallType().getName(); 
    442                     int res= leftType.compareToIgnoreCase(rightType); 
    443                     if (res != 0) { 
    444                         return res; 
    445                     } 
    446                     return left.getName().compareToIgnoreCase(right.getName()); 
    447                 } 
    448                 return super.compare(viewer, e1, e2); 
    449             } 
    450              
    451             public boolean isSorterProperty(Object element, String property) { 
    452                 return true; 
    453             } 
    454         });  
    455         fSortColumn = 3;             
    456     } 
    457      
    458     /** 
    459      * Sorts by VM name. 
    460      */ 
    461     private void sortByName() { 
    462         fVMList.setSorter(new ViewerSorter() { 
    463             public int compare(Viewer viewer, Object e1, Object e2) { 
    464                 if ((e1 instanceof IVMInstall) && (e2 instanceof IVMInstall)) { 
    465                     IVMInstall left= (IVMInstall)e1; 
    466                     IVMInstall right= (IVMInstall)e2; 
    467                     return left.getName().compareToIgnoreCase(right.getName()); 
    468                 } 
    469                 return super.compare(viewer, e1, e2); 
    470             } 
    471              
    472             public boolean isSorterProperty(Object element, String property) { 
    473                 return true; 
    474             } 
    475         });      
    476         fSortColumn = 1;         
    477     } 
    478      
    479     /** 
    480      * Sorts by VM location. 
    481      */ 
    482     private void sortByLocation() { 
    483         fVMList.setSorter(new ViewerSorter() { 
    484             public int compare(Viewer viewer, Object e1, Object e2) { 
    485                 if ((e1 instanceof IVMInstall) && (e2 instanceof IVMInstall)) { 
    486                     IVMInstall left= (IVMInstall)e1; 
    487                     IVMInstall right= (IVMInstall)e2; 
    488                     return left.getInstallLocation().getAbsolutePath().compareToIgnoreCase(right.getInstallLocation().getAbsolutePath()); 
    489                 } 
    490                 return super.compare(viewer, e1, e2); 
    491             } 
    492              
    493             public boolean isSorterProperty(Object element, String property) { 
    494                 return true; 
    495             } 
    496         });      
    497         fSortColumn = 2;         
    498     } 
    499          
    500     private void enableButtons() { 
    501         IStructuredSelection selection = (IStructuredSelection) fVMList.getSelection(); 
    502         int selectionCount= selection.size(); 
    503         fEditButton.setEnabled(selectionCount == 1); 
    504         fCopyButton.setEnabled(selectionCount > 0); 
    505         if (selectionCount > 0 && selectionCount < fVMList.getTable().getItemCount()) { 
    506             Iterator iterator = selection.iterator(); 
    507             while (iterator.hasNext()) { 
    508                 IVMInstall install = (IVMInstall)iterator.next(); 
    509                 if (isContributed(install)) { 
    510                     fRemoveButton.setEnabled(false); 
    511                     return; 
    512                 } 
    513             } 
    514             fRemoveButton.setEnabled(true); 
    515         } else { 
    516             fRemoveButton.setEnabled(false); 
    517         } 
    518     }    
    519      
    520     private boolean isContributed(IVMInstall install) { 
    521         return JavaRuntime.isContributedVMInstall(install.getId()); 
    522     } 
    523      
    524     protected Button createPushButton(Composite parent, String label) { 
    525         //return SWTUtil.createPushButton(parent, label, null); 
    526         Button button = new Button(parent, SWT.PUSH); 
    527         button.setFont(parent.getFont()); 
    528         button.setText(label); 
    529         return button; 
    530     }    
    531      
    532     /** 
    533      * Returns this block's control 
    534      *  
    535      * @return control 
    536      */ 
    537     public Control getControl() { 
    538         return fControl; 
    539     } 
    540      
    541     /** 
    542      * Sets the JREs to be displayed in this block 
    543      *  
    544      * @param vms JREs to be displayed 
    545      */ 
    546     protected void setJREs(IVMInstall[] vms) { 
    547         fVMs.clear(); 
    548         for (int i = 0; i < vms.length; i++) { 
    549             fVMs.add(vms[i]); 
    550         } 
    551         fVMList.setInput(fVMs); 
    552         fVMList.refresh(); 
    553     } 
    554      
    555     /** 
    556      * Returns the JREs currently being displayed in this block 
    557      *  
    558      * @return JREs currently being displayed in this block 
    559      */ 
    560     public IVMInstall[] getJREs() { 
    561         return (IVMInstall[])fVMs.toArray(new IVMInstall[fVMs.size()]); 
    562     } 
    563      
    564     /** 
    565      * Bring up a dialog that lets the user create a new VM definition. 
    566      */ 
    567     private void addVM() { 
    568         AddVMDialog dialog= new AddVMDialog(this, getShell(), JavaRuntime.getVMInstallTypes(), null); 
    569         dialog.setTitle(JREMessages.InstalledJREsBlock_7);  
    570         if (dialog.open() != Window.OK) { 
    571             return; 
    572         } 
    573         fVMList.refresh(); 
    574     } 
    575      
    576     /** 
    577      * @see IAddVMDialogRequestor#vmAdded(IVMInstall) 
    578      */ 
    579     public void vmAdded(IVMInstall vm) { 
    580         fVMs.add(vm); 
    581         fVMList.refresh(); 
    582     } 
    583      
    584     /** 
    585      * @see IAddVMDialogRequestor#isDuplicateName(String) 
    586      */ 
    587     public boolean isDuplicateName(String name) { 
    588         for (int i= 0; i < fVMs.size(); i++) { 
    589             IVMInstall vm = (IVMInstall)fVMs.get(i); 
    590             if (vm.getName().equals(name)) { 
    591                 return true; 
    592             } 
    593         } 
    594         return false; 
    595     }    
    596      
    597     private void editVM() { 
    598         IStructuredSelection selection= (IStructuredSelection)fVMList.getSelection(); 
    599         IVMInstall vm= (IVMInstall)selection.getFirstElement(); 
    600         if (vm == null) { 
    601             return; 
    602         } 
    603         if (isContributed(vm)) { 
    604             VMDetailsDialog dialog= new VMDetailsDialog(getShell(), vm); 
    605             dialog.open(); 
    606         } else { 
    607             AddVMDialog dialog= new AddVMDialog(this, getShell(), JavaRuntime.getVMInstallTypes(), vm); 
    608             dialog.setTitle(JREMessages.InstalledJREsBlock_8);  
    609             if (dialog.open() != Window.OK) { 
    610                 return; 
    611             } 
    612             fVMList.refresh(vm); 
    613         } 
    614     } 
    615      
    616     private void removeVMs() { 
    617         IStructuredSelection selection= (IStructuredSelection)fVMList.getSelection(); 
    618         IVMInstall[] vms = new IVMInstall[selection.size()]; 
    619         Iterator iter = selection.iterator(); 
    620         int i = 0; 
    621         while (iter.hasNext()) { 
    622             vms[i] = (IVMInstall)iter.next(); 
    623             i++; 
    624         } 
    625         removeJREs(vms); 
    626     }    
    627      
    628     /** 
    629      * Removes the given VMs from the table. 
    630      *  
    631      * @param vms 
    632      */ 
    633     public void removeJREs(IVMInstall[] vms) { 
    634         IStructuredSelection prev = (IStructuredSelection) getSelection(); 
    635         for (int i = 0; i < vms.length; i++) { 
    636             fVMs.remove(vms[i]); 
    637         } 
    638         fVMList.refresh(); 
    639         IStructuredSelection curr = (IStructuredSelection) getSelection(); 
    640         if (!curr.equals(prev)) { 
    641             IVMInstall[] installs = getJREs(); 
    642             if (curr.size() == 0 && installs.length == 1) { 
    643                 // pick a default VM automatically 
    644                 setSelection(new StructuredSelection(installs[0])); 
    645             } else { 
    646                 fireSelectionChanged(); 
    647             } 
    648         } 
    649     } 
    650      
    651     /** 
    652      * Search for installed VMs in the file system 
    653      */ 
    654     protected void search() { 
    655          
    656         // choose a root directory for the search  
    657         DirectoryDialog dialog = new DirectoryDialog(getShell()); 
    658         dialog.setMessage(JREMessages.InstalledJREsBlock_9);  
    659         dialog.setText(JREMessages.InstalledJREsBlock_10);  
    660         String path = dialog.open(); 
    661         if (path == null) { 
    662             return; 
    663         } 
    664          
    665         // ignore installed locations 
    666         final Set exstingLocations = new HashSet(); 
    667         Iterator iter = fVMs.iterator(); 
    668         while (iter.hasNext()) { 
    669             exstingLocations.add(((IVMInstall)iter.next()).getInstallLocation()); 
    670         } 
    671          
    672         // search 
    673         final File rootDir = new File(path); 
    674         final List locations = new ArrayList(); 
    675         final List types = new ArrayList(); 
    676  
    677         IRunnableWithProgress r = new IRunnableWithProgress() { 
    678             public void run(IProgressMonitor monitor) { 
    679                 monitor.beginTask(JREMessages.InstalledJREsBlock_11, IProgressMonitor.UNKNOWN);  
    680                 search(rootDir, locations, types, exstingLocations, monitor); 
    681                 monitor.done(); 
    682             } 
    683         }; 
    684          
    685         try { 
    686             ProgressMonitorDialog progress = new ProgressMonitorDialog(getShell()); 
    687             progress.run(true, true, r); 
    688         } catch (InvocationTargetException e) { 
    689             JavaPlugin.log(e); 
    690         } catch (InterruptedException e) { 
    691             // cancelled 
    692             return; 
    693         } 
    694          
    695         if (locations.isEmpty()) { 
    696             MessageDialog.openInformation(getShell(), JREMessages.InstalledJREsBlock_12, MessageFormat.format(JREMessages.InstalledJREsBlock_13, new String[]{path})); //  
    697         } else { 
    698             iter = locations.iterator(); 
    699             Iterator iter2 = types.iterator(); 
    700             while (iter.hasNext()) { 
    701                 File location = (File)iter.next(); 
    702                 IVMInstallType type = (IVMInstallType)iter2.next(); 
    703                 IVMInstall vm = new VMStandin(type, createUniqueId(type)); 
    704                 String name = VMInstallTypeUtil.getVMInstallName(type, location); 
    705                 String nameCopy = new String(name); 
    706                 int i = 1; 
    707                 while (isDuplicateName(nameCopy)) { 
    708                     nameCopy = name + '(' + i++ + ')';  
    709                 } 
    710                 vm.setName(nameCopy); 
    711                 vm.setInstallLocation(location); 
    712                 if (type instanceof AbstractVMInstallType) { 
    713                     //set default java doc location 
    714                     AbstractVMInstallType abs = (AbstractVMInstallType)type; 
    715                     vm.setJavadocLocation(abs.getDefaultJavadocLocation(location)); 
    716                 } 
    717                 vmAdded(vm); 
    718             } 
    719         } 
    720          
    721     } 
    722      
    723     protected Shell getShell() { 
    724         return getControl().getShell(); 
    725     } 
    726  
    727     /** 
    728      * Find a unique VM id.  Check existing 'real' VMs, as well as the last id used for 
    729      * a VMStandin. 
    730      */ 
    731     private String createUniqueId(IVMInstallType vmType) { 
    732         String id= null; 
    733         do { 
    734             id= String.valueOf(System.currentTimeMillis()); 
    735         } while (vmType.findVMInstall(id) != null || id.equals(fgLastUsedID)); 
    736         fgLastUsedID = id; 
    737         return id; 
    738     }    
    739      
    740     /** 
    741      * Searches the specified directory recursively for installed VMs, adding each 
    742      * detected VM to the <code>found</code> list. Any directories specified in 
    743      * the <code>ignore</code> are not traversed. 
    744      *  
    745      * @param directory 
    746      * @param found 
    747      * @param types 
    748      * @param ignore 
    749      */ 
    750     protected void search(File directory, List found, List types, Set ignore, IProgressMonitor monitor) { 
    751         if (monitor.isCanceled()) { 
    752             return; 
    753         } 
    754  
    755         String[] names = directory.list(); 
    756         if (names == null) { 
    757             return; 
    758         } 
    759         List subDirs = new ArrayList(); 
    760         for (int i = 0; i < names.length; i++) { 
    761             if (monitor.isCanceled()) { 
    762                 return; 
    763             } 
    764             File file = new File(directory, names[i]); 
    765             try { 
    766                 monitor.subTask(MessageFormat.format(JREMessages.InstalledJREsBlock_14, new String[]{Integer.toString(found.size()), file.getCanonicalPath()}));  
    767             } catch (IOException e) { 
    768             }        
    769             IVMInstallType[] vmTypes = JavaRuntime.getVMInstallTypes();  
    770             if (file.isDirectory()) { 
    771                 if (!ignore.contains(file)) { 
    772                     boolean validLocation = false; 
    773                      
    774                     // Take the first VM install type that claims the location as a 
    775                     // valid VM install.  VM install types should be smart enough to not 
    776                     // claim another type's VM, but just in case... 
    777                     for (int j = 0; j < vmTypes.length; j++) { 
    778                         if (monitor.isCanceled()) { 
    779                             return; 
    780                         } 
    781                         IVMInstallType type = vmTypes[j]; 
    782                         IStatus status = type.validateInstallLocation(file); 
    783                         if (status.isOK()) { 
    784                             found.add(file); 
    785                             types.add(type); 
    786                             validLocation = true; 
    787                             break; 
    788                         } 
    789                     } 
    790                     if (!validLocation) { 
    791                         subDirs.add(file); 
    792                     } 
    793                 } 
    794             } 
    795         } 
    796         while (!subDirs.isEmpty()) { 
    797             File subDir = (File)subDirs.remove(0); 
    798             search(subDir, found, types, ignore, monitor); 
    799             if (monitor.isCanceled()) { 
    800                 return; 
    801             } 
    802         } 
    803          
    804     }    
    805      
    806     /** 
    807      * Sets the checked JRE, possible <code>null</code> 
    808      *  
    809      * @param vm JRE or <code>null</code> 
    810      */ 
    811     public void setCheckedJRE(IVMInstall vm) { 
    812         if (vm == null) { 
    813             setSelection(new StructuredSelection()); 
    814         } else { 
    815             setSelection(new StructuredSelection(vm)); 
    816         } 
    817     } 
    818      
    819     /** 
    820      * Returns the checked JRE or <code>null</code> if none. 
    821      *  
    822      * @return the checked JRE or <code>null</code> if none 
    823      */ 
    824     public IVMInstall getCheckedJRE() { 
    825         Object[] objects = fVMList.getCheckedElements(); 
    826         if (objects.length == 0) { 
    827             return null; 
    828         } 
    829         return (IVMInstall)objects[0]; 
    830     } 
    831      
    832     /** 
    833      * Persist table settings into the give dialog store, prefixed 
    834      * with the given key. 
    835      *  
    836      * @param settings dialog store 
    837      * @param qualifier key qualifier 
    838      */ 
    839     public void saveColumnSettings(IDialogSettings settings, String qualifier) { 
    840         int columnCount = fTable.getColumnCount(); 
    841         for (int i = 0; i < columnCount; i++) { 
    842             settings.put(qualifier + ".columnWidth" + i, fTable.getColumn(i).getWidth());    //$NON-NLS-1$ 
    843         } 
    844         settings.put(qualifier + ".sortColumn", fSortColumn); //$NON-NLS-1$ 
    845     } 
    846      
    847     /** 
    848      * Restore table settings from the given dialog store using the 
    849      * given key. 
    850      *  
    851      * @param settings dialog settings store 
    852      * @param qualifier key to restore settings from 
    853      */ 
    854     public void restoreColumnSettings(IDialogSettings settings, String qualifier) { 
    855         fVMList.getTable().layout(true); 
    856         restoreColumnWidths(settings, qualifier); 
    857         try { 
    858             fSortColumn = settings.getInt(qualifier + ".sortColumn"); //$NON-NLS-1$ 
    859         } catch (NumberFormatException e) { 
    860             fSortColumn = 1; 
    861         } 
    862         switch (fSortColumn) { 
    863             case 1: 
    864                 sortByName(); 
    865                 break; 
    866             case 2: 
    867                 sortByLocation(); 
    868                 break; 
    869             case 3: 
    870                 sortByType(); 
    871                 break; 
    872         } 
    873     } 
    874      
    875     private void restoreColumnWidths(IDialogSettings settings, String qualifier) { 
    876         int columnCount = fTable.getColumnCount(); 
    877         for (int i = 0; i < columnCount; i++) { 
    878             int width = -1; 
    879              
    880             try { 
    881                 width = settings.getInt(qualifier + ".columnWidth" + i); //$NON-NLS-1$ 
    882             } catch (NumberFormatException e) {} 
    883              
    884             if (width <= 0) { 
    885                 fTable.getColumn(i).pack(); 
    886             } else { 
    887                 fTable.getColumn(i).setWidth(width); 
    888             } 
    889         } 
    890     } 
    891      
    892     /** 
    893      * Populates the JRE table with existing JREs defined in the workspace. 
    894      */ 
    895     protected void fillWithWorkspaceJREs() { 
    896         // fill with JREs 
    897         List standins = new ArrayList(); 
    898         IVMInstallType[] types = JavaRuntime.getVMInstallTypes(); 
    899         for (int i = 0; i < types.length; i++) { 
    900             IVMInstallType type = types[i]; 
    901             IVMInstall[] installs = type.getVMInstalls(); 
    902             for (int j = 0; j < installs.length; j++) { 
    903                 IVMInstall install = installs[j]; 
    904                 standins.add(new VMStandin(install)); 
    905             } 
    906         } 
    907         setJREs((IVMInstall[])standins.toArray(new IVMInstall[standins.size()]));    
    908     } 
    909          
     972            } 
     973            if (!validLocation) 
     974            { 
     975            subDirs.add(file); 
     976            } 
     977        } 
     978        } 
     979    } 
     980    while (!subDirs.isEmpty()) 
     981    { 
     982        File subDir = (File) subDirs.remove(0); 
     983        search(subDir, found, types, ignore, monitor); 
     984        if (monitor.isCanceled()) 
     985        { 
     986        return; 
     987        } 
     988    } 
     989 
     990    } 
     991 
     992    /** 
     993     * Sets the checked Compiler, possible <code>null</code> 
     994     *  
     995     * @param compiler Compiler or <code>null</code> 
     996     */ 
     997    public void setCheckedCompiler(ICompilerInstall compiler) 
     998    { 
     999    if (compiler == null) 
     1000    { 
     1001        setSelection(new StructuredSelection()); 
     1002    } 
     1003    else 
     1004    { 
     1005        setSelection(new StructuredSelection(compiler)); 
     1006    } 
     1007    } 
     1008 
     1009    /** 
     1010     * Returns the checked JRE or <code>null</code> if none. 
     1011     *  
     1012     * @return the checked JRE or <code>null</code> if none 
     1013     */ 
     1014    public ICompilerInstall getCheckedJRE() 
     1015    { 
     1016    Object[] objects = fCompilerList.getCheckedElements(); 
     1017    if (objects.length == 0) 
     1018    { 
     1019        return null; 
     1020    } 
     1021    return (ICompilerInstall) objects[0]; 
     1022    } 
     1023 
     1024    /** 
     1025     * Persist table settings into the give dialog store, prefixed 
     1026     * with the given key. 
     1027     *  
     1028     * @param settings dialog store 
     1029     * @param qualifier key qualifier 
     1030     */ 
     1031    public void saveColumnSettings(IDialogSettings settings, String qualifier) 
     1032    { 
     1033    int columnCount = fTable.getColumnCount(); 
     1034    for (int i = 0; i < columnCount; i++) 
     1035    { 
     1036        settings 
     1037            .put( 
     1038                qualifier + ".columnWidth" + i, fTable.getColumn(i).getWidth()); //$NON-NLS-1$ 
     1039    } 
     1040    settings.put(qualifier + ".sortColumn", fSortColumn); //$NON-NLS-1$ 
     1041    } 
     1042 
     1043    /** 
     1044     * Restore table settings from the given dialog store using the 
     1045     * given key. 
     1046     *  
     1047     * @param settings dialog settings store 
     1048     * @param qualifier key to restore settings from 
     1049     */ 
     1050    public void restoreColumnSettings(IDialogSettings settings, String qualifier) 
     1051    { 
     1052    fCompilerList.getTable().layout(true); 
     1053    restoreColumnWidths(settings, qualifier); 
     1054    try 
     1055    { 
     1056        fSortColumn = settings.getInt(qualifier + ".sortColumn"); //$NON-NLS-1$ 
     1057    } 
     1058    catch (NumberFormatException e) 
     1059    { 
     1060        fSortColumn = 1; 
     1061    } 
     1062    switch (fSortColumn) { 
     1063    case 1: 
     1064        sortByName(); 
     1065        break; 
     1066    case 2: 
     1067        sortByLocation(); 
     1068        break; 
     1069    case 3: 
     1070        sortByType(); 
     1071        break; 
     1072    } 
     1073    } 
     1074 
     1075    private void restoreColumnWidths(IDialogSettings settings, String qualifier) 
     1076    { 
     1077    int columnCount = fTable.getColumnCount(); 
     1078    for (int i = 0; i < columnCount; i++) 
     1079    { 
     1080        int width = -1; 
     1081 
     1082        try 
     1083        { 
     1084        width = settings.getInt(qualifier + ".columnWidth" + i); //$NON-NLS-1$ 
     1085        } 
     1086        catch (NumberFormatException e) 
     1087        { 
     1088        } 
     1089 
     1090        if (width <= 0) 
     1091        { 
     1092        fTable.getColumn(i).pack(); 
     1093        } 
     1094        else 
     1095        { 
     1096        fTable.getColumn(i).setWidth(width); 
     1097        } 
     1098    } 
     1099    } 
     1100 
     1101    /** 
     1102     * Populates the JRE table with existing JREs defined in the workspace. 
     1103     */ 
     1104    protected void fillWithWorkspaceJREs() 
     1105    { 
     1106    // fill with JREs 
     1107    List standins = new ArrayList(); 
     1108    ICompilerInstallType[] types = JavaRuntime.getVMInstallTypes(); 
     1109    for (int i = 0; i < types.length; i++) 
     1110    { 
     1111        ICompilerInstallType type = types[i]; 
     1112        ICompilerInstall[] installs = type.getVMInstalls(); 
     1113        for (int j = 0; j < installs.length; j++) 
     1114        { 
     1115        ICompilerInstall install = installs[j]; 
     1116        standins.add(new VMStandin(install)); 
     1117        } 
     1118    } 
     1119    setJREs((ICompilerInstall[]) standins 
     1120        .toArray(new ICompilerInstall[standins.size()])); 
     1121    } 
     1122 
    9101123} 
  • oranda_4-14-08/descent.ui/src/descent/internal/debug/ui/jres/JREMessages.java

    r559 r1111  
    4747    public static String JREsPreferencePage_13; 
    4848 
    49     public static String addVMDialog_browse1; 
    50     public static String addVMDialog_duplicateName; 
    51     public static String addVMDialog_enterLocation; 
    52     public static String addVMDialog_enterName; 
    53     public static String addVMDialog_jreHome; 
    54     public static String addVMDialog_jreName; 
    55     public static String addVMDialog_jreType; 
    56     public static String addVMDialog_locationNotExists; 
    57     public static String addVMDialog_pickJRERootDialog_message; 
    58     public static String AddVMDialog_JRE_system_libraries__1; 
    59     public static String AddVMDialog_JRE_name_must_be_a_valid_file_name___0__1; 
    6049    public static String AddVMDialog_23; 
    6150    public static String AddVMDialog_0; 
     
    6554    public static String LibraryStandin_1; 
    6655 
    67     public static String VMLibraryBlock_Libraries_cannot_be_empty__1; 
    68  
    6956    public static String JREsUpdater_0; 
    7057    public static String VMLibraryBlock_0; 
    7158    public static String VMLibraryBlock_1; 
    7259    public static String VMLibraryBlock_2; 
    73     public static String VMLibraryBlock_3; 
    74     public static String VMLibraryBlock_4; 
    75     public static String VMLibraryBlock_5; 
    76     public static String VMLibraryBlock_6; 
    77     public static String VMLibraryBlock_7; 
    7860    public static String VMLibraryBlock_8; 
    79     public static String VMLibraryBlock_9; 
    80     public static String VMLibraryBlock_10; 
    81     public static String VMLibraryBlock_11; 
    82  
    8361    static { 
    8462        // load message values from bundle file 
  • oranda_4-14-08/descent.ui/src/descent/internal/debug/ui/jres/JREMessages.properties

    r902 r1111  
    6464JREsPreferencePage_13=Select a default compiler 
    6565 
    66 addVMDialog_browse1=&Browse... 
    67 addVMDialog_duplicateName=The name is already used. 
    68 addVMDialog_enterLocation=Enter the location of the compiler. 
    69 addVMDialog_enterName=Enter a name for the compiler. 
    70 addVMDialog_jreHome=&Compiler home directory: 
    71 addVMDialog_jreName=Compiler &name: 
    72 addVMDialog_jreType=Compiler &type: 
    73 addVMDialog_locationNotExists=The location does not exist. 
    74 addVMDialog_pickJRERootDialog_message=Select the root directory of the compiler installation: 
    75 AddVMDialog_JRE_system_libraries__1=Compiler system libraries: 
    76 AddVMDialog_JRE_name_must_be_a_valid_file_name___0__1=Compiler name must be a valid file name: {0} 
    7766AddVMDialog_23=Default &VM Arguments: 
    7867AddVMDialog_0=Compiler 
    79  
    80 VMLibraryBlock_Libraries_cannot_be_empty__1=Libraries cannot be empty. 
    8168 
    8269JREsUpdater_0=Save VM Definitions 
    8370VMLibraryBlock_0=Source attachment: 
    8471VMLibraryBlock_1=(none) 
    85 VMLibraryBlock_10=Include Path Selection 
    8672VMDetailsDialog_0=Compiler Details 
    8773VMLibraryBlock_2=Ddoc location: 
    88 VMLibraryBlock_11=Source &Attachment... 
    89 VMLibraryBlock_4=U&p 
    90 VMLibraryBlock_5=&Down 
    91 VMLibraryBlock_6=Re&move 
    92 VMLibraryBlock_7=Add Include Path... 
    9374VMLibraryBlock_8=Ed&it... 
    94 VMLibraryBlock_9=&Restore Default 
    95 VMLibraryBlock_3=Ddoc &Location... 
    9675JREProfilesPreferencePage_0=Execution Environments 
    9776JREProfilesPreferencePage_1=This page displays the JREs compatible for each execution environment.\nWhen multiple JREs are compatible with an environment, a default JRE can be specified by checking it. 
  • oranda_4-14-08/descent.ui/src/descent/internal/debug/ui/jres/JREsPreferencePage.java

    r559 r1111  
    2626import descent.internal.debug.ui.IJavaDebugHelpContextIds; 
    2727import descent.internal.ui.JavaPlugin; 
    28 import descent.launching.IVMInstall; 
     28import descent.launching.ICompilerInstall; 
    2929import descent.launching.JavaRuntime; 
    3030import descent.launching.LibraryLocation; 
     
    3838                             
    3939    // JRE Block 
    40     private InstalledJREsBlock fJREBlock;                                  
     40    private InstalledCompilersBlock fJREBlock;                                     
    4141         
    4242    public JREsPreferencePage() { 
     
    5959     */ 
    6060    private void initDefaultVM() { 
    61         IVMInstall realDefault= JavaRuntime.getDefaultVMInstall(); 
     61        ICompilerInstall realDefault= JavaRuntime.getDefaultVMInstall(); 
    6262        if (realDefault != null) { 
    63             IVMInstall[] vms= fJREBlock.getJREs(); 
     63            ICompilerInstall[] vms= fJREBlock.getJREs(); 
    6464            for (int i = 0; i < vms.length; i++) { 
    65                 IVMInstall fakeVM= vms[i]; 
     65                ICompilerInstall fakeVM= vms[i]; 
    6666                if (fakeVM.equals(realDefault)) { 
    6767                    verifyDefaultVM(fakeVM); 
     
    8686        ancestor.setLayout(layout); 
    8787                     
    88         fJREBlock = new InstalledJREsBlock(); 
     88        fJREBlock = new InstalledCompilersBlock(); 
    8989        fJREBlock.createControl(ancestor); 
    9090        Control control = fJREBlock.getControl(); 
     
    9999        fJREBlock.addSelectionChangedListener(new ISelectionChangedListener() { 
    100100            public void selectionChanged(SelectionChangedEvent event) { 
    101                 IVMInstall install = getCurrentDefaultVM(); 
     101                ICompilerInstall install = getCurrentDefaultVM(); 
    102102                if (install == null) { 
    103103                    setValid(false); 
     
    120120        BusyIndicator.showWhile(null, new Runnable() { 
    121121            public void run() { 
    122                 IVMInstall defaultVM = getCurrentDefaultVM(); 
    123                 IVMInstall[] vms = fJREBlock.getJREs(); 
     122                ICompilerInstall defaultVM = getCurrentDefaultVM(); 
     123                ICompilerInstall[] vms = fJREBlock.getJREs(); 
    124124                JREsUpdater updater = new JREsUpdater(); 
    125125                if (!updater.updateJRESettings(vms, defaultVM)) { 
     
    149149     * remove the VM from the table and try to set another default. 
    150150     */ 
    151     private void verifyDefaultVM(IVMInstall vm) { 
     151    private void verifyDefaultVM(ICompilerInstall vm) { 
    152152        if (vm != null) { 
    153153             
     
    162162            // otherwise remove the VM 
    163163            if (exist) { 
    164                 fJREBlock.setCheckedJRE(vm); 
     164                fJREBlock.setCheckedCompiler(vm); 
    165165            } else { 
    166                 fJREBlock.removeJREs(new IVMInstall[]{vm}); 
    167                 IVMInstall def = JavaRuntime.getDefaultVMInstall(); 
     166                fJREBlock.removeJREs(new ICompilerInstall[]{vm}); 
     167                ICompilerInstall def = JavaRuntime.getDefaultVMInstall(); 
    168168                if (def == null) { 
    169                     fJREBlock.setCheckedJRE(null); 
     169                    fJREBlock.setCheckedCompiler(null); 
    170170                } else { 
    171                     fJREBlock.setCheckedJRE(def); 
     171                    fJREBlock.setCheckedCompiler(def); 
    172172                } 
    173173                ErrorDialog.openError(getControl().getShell(), JREMessages.JREsPreferencePage_1, JREMessages.JREsPreferencePage_10, new Status(IStatus.ERROR, IJavaDebugUIConstants.PLUGIN_ID, IJavaDebugUIConstants.INTERNAL_ERROR, JREMessages.JREsPreferencePage_11, null)); //   
     
    175175            } 
    176176        } else { 
    177             fJREBlock.setCheckedJRE(null); 
     177            fJREBlock.setCheckedCompiler(null); 
    178178        } 
    179179    } 
    180180     
    181     private IVMInstall getCurrentDefaultVM() { 
     181    private ICompilerInstall getCurrentDefaultVM() { 
    182182        return fJREBlock.getCheckedJRE(); 
    183183    }    
  • oranda_4-14-08/descent.ui/src/descent/internal/debug/ui/jres/JREsUpdater.java

    r559 r1111  
    1212import descent.internal.launching.VMDefinitionsContainer; 
    1313import descent.internal.ui.JavaPlugin; 
    14 import descent.launching.IVMInstall; 
    15 import descent.launching.IVMInstallType; 
     14import descent.launching.ICompilerInstall; 
     15import descent.launching.ICompilerInstallType; 
    1616import descent.launching.JavaRuntime; 
    1717 
     
    2929    public JREsUpdater() { 
    3030        fOriginalVMs = new VMDefinitionsContainer(); 
    31         IVMInstall def = JavaRuntime.getDefaultVMInstall(); 
     31        ICompilerInstall def = JavaRuntime.getDefaultVMInstall(); 
    3232        if (def != null) { 
    3333            fOriginalVMs.setDefaultVMInstallCompositeID(JavaRuntime.getCompositeIdFromVM(def)); 
    3434        } 
    3535     
    36         IVMInstallType[] types = JavaRuntime.getVMInstallTypes(); 
     36        ICompilerInstallType[] types = JavaRuntime.getVMInstallTypes(); 
    3737        for (int i = 0; i < types.length; i++) { 
    38             IVMInstall[] vms = types[i].getVMInstalls(); 
     38            ICompilerInstall[] vms = types[i].getVMInstalls(); 
    3939            for (int j = 0; j < vms.length; j++) { 
    4040                fOriginalVMs.addVM(vms[j]); 
     
    5050     * @return whether the update was successful 
    5151     */ 
    52     public boolean updateJRESettings(IVMInstall[] jres, IVMInstall defaultJRE) { 
     52    public boolean updateJRESettings(ICompilerInstall[] jres, ICompilerInstall defaultJRE) { 
    5353         
    5454        // Create a VM definition container 
  • oranda_4-14-08/descent.ui/src/descent/internal/debug/ui/jres/VMDetailsDialog.java

    r559 r1111  
    1717import descent.internal.debug.ui.IJavaDebugHelpContextIds; 
    1818import descent.internal.ui.JavaPlugin; 
    19 import descent.launching.IVMInstall; 
     19import descent.launching.ICompilerInstall; 
    2020import descent.launching.JavaRuntime; 
    2121 
     
    2727public class VMDetailsDialog extends Dialog { 
    2828     
    29     private IVMInstall fVM; 
     29    private ICompilerInstall fVM; 
    3030         
    31     public VMDetailsDialog(Shell shell, IVMInstall vm) { 
     31    public VMDetailsDialog(Shell shell, ICompilerInstall vm) { 
    3232        super(shell); 
    3333        setShellStyle(getShellStyle() | SWT.RESIZE);         
     
    5050         
    5151        // type 
    52         createLabel(parent, JREMessages.addVMDialog_jreType); 
     52        createLabel(parent, "Type"); 
    5353        createLabel(parent, fVM.getVMInstallType().getName()); 
    5454 
    5555        // name 
    56         createLabel(parent, JREMessages.addVMDialog_jreName); 
     56        createLabel(parent, "Name"); 
    5757        createLabel(parent, fVM.getName()); 
    5858         
    5959        // home 
    60         createLabel(parent, JREMessages.addVMDialog_jreHome); 
     60        createLabel(parent, "Home"); 
    6161        createLabel(parent, fVM.getInstallLocation().getAbsolutePath()); 
    6262         
     
    8888         
    8989        // libraries 
    90         Label label = createLabel(parent, JREMessages.AddVMDialog_JRE_system_libraries__1); 
     90        Label label = createLabel(parent, "Libraries"); 
    9191        GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_BEGINNING); 
    9292        label.setLayoutData(gd); 
     
    9595        gd.heightHint = 6; 
    9696        libraryViewer.getControl().setLayoutData(gd); 
    97         LibraryContentProvider provider = new LibraryContentProvider(); 
    98         libraryViewer.setContentProvider(provider); 
    99         libraryViewer.setLabelProvider(new LibraryLabelProvider()); 
     97        //TODO: Remove this for real 
     98        //DirectoryContentProvider provider = new DirectoryContentProvider(); 
     99        //libraryViewer.setContentProvider(provider); 
     100        //libraryViewer.setLabelProvider(new LibraryLabelProvider()); 
    100101        libraryViewer.setInput(this); 
    101         provider.setLibraries(JavaRuntime.getLibraryLocations(fVM)); 
     102        //provider.setLibraries(JavaRuntime.getLibraryLocations(fVM)); 
    102103         
    103104        applyDialogFont(parent); 
  • oranda_4-14-08/descent.ui/src/descent/internal/debug/ui/jres/VMInstallTypeUtil.java

    r559 r1111  
    33import java.io.File; 
    44 
    5 import descent.launching.IVMInstall; 
    6 import descent.launching.IVMInstallType; 
     5import descent.launching.ICompilerInstall; 
     6import descent.launching.ICompilerInstallType; 
    77 
    88public class VMInstallTypeUtil { 
    99     
    10     public static String getVMInstallName(IVMInstallType vm, File installLocation) { 
     10    public static String getVMInstallName(ICompilerInstallType vm, File installLocation) { 
    1111        vm.disposeVMInstall(""); //$NON-NLS-1$ 
    12         IVMInstall install = vm.createVMInstall(""); //$NON-NLS-1$ 
     12        ICompilerInstall install = vm.createVMInstall(""); //$NON-NLS-1$ 
    1313        install.setInstallLocation(installLocation); 
    1414        String version = install.getJavaVersion(); 
  • oranda_4-14-08/descent.ui/src/descent/internal/ui/dialogs/TypeInfoViewer.java

    r1026 r1111  
    6868import descent.internal.corext.util.TypeInfo.TypeInfoAdapter; 
    6969 
    70 import descent.launching.IVMInstall; 
    71 import descent.launching.IVMInstallType; 
     70import descent.launching.ICompilerInstall; 
     71import descent.launching.ICompilerInstallType; 
    7272import descent.launching.JavaRuntime; 
    7373import descent.launching.LibraryLocation; 
     
    218218            List locations= new ArrayList(); 
    219219            List labels= new ArrayList(); 
    220             IVMInstallType[] installs= JavaRuntime.getVMInstallTypes(); 
     220            ICompilerInstallType[] installs= JavaRuntime.getVMInstallTypes(); 
    221221            for (int i= 0; i < installs.length; i++) { 
    222222                processVMInstallType(installs[i], locations, labels); 
     
    229229            fFullyQualifyDuplicates= value; 
    230230        } 
    231         private void processVMInstallType(IVMInstallType installType, List locations, List labels) { 
     231        private void processVMInstallType(ICompilerInstallType installType, List locations, List labels) { 
    232232            if (installType != null) { 
    233                 IVMInstall[] installs= installType.getVMInstalls(); 
     233                ICompilerInstall[] installs= installType.getVMInstalls(); 
    234234                boolean isMac= Platform.OS_MACOSX.equals(Platform.getOS()); 
    235235                final String HOME_SUFFIX= "/Home"; //$NON-NLS-1$ 
  • oranda_4-14-08/descent.ui/src/descent/internal/ui/wizards/JavaProjectWizardFirstPage.java

    r559 r1111  
    6363import descent.internal.ui.wizards.dialogfields.StringButtonDialogField; 
    6464import descent.internal.ui.wizards.dialogfields.StringDialogField; 
    65 import descent.launching.IVMInstall; 
    66 import descent.launching.IVMInstallType; 
     65import descent.launching.ICompilerInstall; 
     66import descent.launching.ICompilerInstallType; 
    6767import descent.launching.JavaRuntime; 
    6868import descent.launching.VMStandin; 
     
    328328        private String[] fComplianceData; 
    329329        private final Link fPreferenceLink; 
    330         private IVMInstall[] fInstalledJVMs; 
     330        private ICompilerInstall[] fInstalledJVMs; 
    331331         
    332332        public JREGroup(Composite composite) { 
     
    380380 
    381381                public int compare(Object arg0, Object arg1) { 
    382                     IVMInstall i0= (IVMInstall)arg0; 
    383                     IVMInstall i1= (IVMInstall)arg1; 
     382                    ICompilerInstall i0= (ICompilerInstall)arg0; 
     383                    ICompilerInstall i1= (ICompilerInstall)arg1; 
    384384                    String cc0= JavaModelUtil.getCompilerCompliance(i0, JavaCore.VERSION_1_x); 
    385385                    String cc1= JavaModelUtil.getCompilerCompliance(i1, JavaCore.VERSION_1_x); 
     
    409409        } 
    410410         
    411         private IVMInstall[] getWorkspaceJREs() { 
     411        private ICompilerInstall[] getWorkspaceJREs() { 
    412412            List standins = new ArrayList(); 
    413             IVMInstallType[] types = JavaRuntime.getVMInstallTypes(); 
     413            ICompilerInstallType[] types = JavaRuntime.getVMInstallTypes(); 
    414414            for (int i = 0; i < types.length; i++) { 
    415                 IVMInstallType type = types[i]; 
    416                 IVMInstall[] installs = type.getVMInstalls(); 
     415                ICompilerInstallType type = types[i]; 
     416                ICompilerInstall[] installs = type.getVMInstalls(); 
    417417                for (int j = 0; j < installs.length; j++) { 
    418                     IVMInstall install = installs[j]; 
     418                    ICompilerInstall install = installs[j]; 
    419419                    standins.add(new VMStandin(install)); 
    420420                } 
    421421            } 
    422             return ((IVMInstall[])standins.toArray(new IVMInstall[standins.size()]));  
     422            return ((ICompilerInstall[])standins.toArray(new ICompilerInstall[standins.size()]));  
    423423        } 
    424424 
    425425        private String getDefaultJVMName() { 
    426             IVMInstall defaultVMInstall = JavaRuntime.getDefaultVMInstall(); 
     426            ICompilerInstall defaultVMInstall = JavaRuntime.getDefaultVMInstall(); 
    427427            if (defaultVMInstall == null) { 
    428428                return "(No default compiler)"; 
     
    479479        } 
    480480         
    481         public IVMInstall getSelectedJVM() { 
     481        public ICompilerInstall getSelectedJVM() { 
    482482            if (fUseProjectJRE.isSelected()) { 
    483483                int index= fJRECombo.getSelectionIndex(); 
     
    527527                selectedCompliance= JavaCore.getOption(JavaCore.COMPILER_COMPLIANCE); 
    528528            } 
    529             IVMInstall selectedJVM= fJREGroup.getSelectedJVM(); 
     529            ICompilerInstall selectedJVM= fJREGroup.getSelectedJVM(); 
    530530            if (selectedJVM == null) { 
    531531                selectedJVM= JavaRuntime.getDefaultVMInstall(); 
     
    544544                fHintText.setVisible(false); 
    545545            } 
    546             š*/ 
     546            ᅵ*/ 
    547547        } 
    548548         
     
    804804     * @return the selected JVM, or <code>null</code> iff the default JVM should be used 
    805805     */ 
    806     public IVMInstall getJVM() { 
     806    public ICompilerInstall getJVM() { 
    807807        return fJREGroup.getSelectedJVM(); 
    808808    } 
  • oranda_4-14-08/descent.ui/src/descent/internal/ui/wizards/JavaProjectWizardSecondPage.java

    r974 r1111  
    5353import descent.internal.ui.util.CoreUtility; 
    5454import descent.internal.ui.util.ExceptionHandler; 
    55 import descent.launching.IVMInstall; 
     55import descent.launching.ICompilerInstall; 
    5656import descent.launching.JavaRuntime; 
    5757import descent.ui.JavaUI; 
     
    250250            return defaultJRELibrary; 
    251251        } 
    252         IVMInstall inst= fFirstPage.getJVM(); 
     252        ICompilerInstall inst= fFirstPage.getJVM(); 
    253253        if (inst != null) { 
    254254            IPath newPath= jreContainerPath.append(inst.getVMInstallType().getId()).append(inst.getName());