View Javadoc

1   /*
2    * $Id: KazukiContainerPage.java,v 1.6 2004/09/20 03:51:50 jlerner Exp $
3    *
4    * Copyright (c) 1999-2004, BBN Technologies, LLC.
5    * All rights reserved.
6    * http://www.daml.org/legal/opensource/bbn_license.html
7    */
8   package com.bbn.swede.library.kazuki;
9   
10  import org.eclipse.core.runtime.IPath;
11  import org.eclipse.core.runtime.Path;
12  import org.eclipse.jdt.core.IClasspathEntry;
13  import org.eclipse.jdt.core.JavaCore;
14  import org.eclipse.jdt.ui.wizards.IClasspathContainerPage;
15  import org.eclipse.jface.wizard.WizardPage;
16  import org.eclipse.swt.SWT;
17  import org.eclipse.swt.widgets.Composite;
18  import org.eclipse.swt.widgets.Label;
19  
20  /***
21   * Adds "Kazuki" to the "Add Library..." list for Java Projects.  The 
22   * wizard page itself provides no customization, it is just a placeholder to 
23   * make Kazuki appear in the Library list.
24   * @author jlerner
25   */
26  public class KazukiContainerPage
27     extends WizardPage
28     implements IClasspathContainerPage
29  {
30     private IClasspathEntry _entry;
31  
32     /***
33      * Creates a new KazukiContainerPage with the name "Kazuki Library".
34      */
35     public KazukiContainerPage()
36     {
37        super("Kazuki Library");
38     }
39  
40     /*
41      *  (non-Javadoc)
42      * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
43      */
44     public void createControl(Composite parent)
45     {
46        initializeDialogUnits(parent);
47        Label label = new Label(parent, SWT.NONE);
48        label.setText(
49           "Click Finish to add the Kazuki library to your classpath.");
50        label.setFont(parent.getFont());
51        setControl(label);
52     }
53  
54     /*
55      *  (non-Javadoc)
56      * @see org.eclipse.jdt.ui.wizards.IClasspathContainerPage#finish()
57      */
58     public boolean finish()
59     {
60        if (_entry == null)
61        {
62           IPath path = new Path("com.bbn.swede.library.kazuki.kazukiContainer");
63           _entry = JavaCore.newContainerEntry(path);
64        }
65        return true;
66     }
67  
68     /*
69      *  (non-Javadoc)
70      * @see org.eclipse.jdt.ui.wizards.IClasspathContainerPage#getSelection()
71      */
72     public IClasspathEntry getSelection()
73     {
74        return _entry;
75     }
76  
77     /*
78      *  (non-Javadoc)
79      * @see org.eclipse.jdt.ui.wizards.IClasspathContainerPage#setSelection(org.eclipse.jdt.core.IClasspathEntry)
80      */
81     public void setSelection(IClasspathEntry containerEntry)
82     {
83        if (containerEntry == null)
84        {
85           IPath path = new Path("com.bbn.swede.library.kazuki.kazukiContainer");
86           _entry = JavaCore.newContainerEntry(path);
87        }
88        else
89        {
90           _entry = containerEntry;
91        }
92     }
93  
94  }