Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: javax/ide/extension/PlatformInfo.java


1   package javax.ide.extension;
2   import java.util.ArrayList;
3   import java.util.Collection;
4   
5   /**
6    * Encapsulates platform specific information required for an extension to
7    * work properly.
8    */
9   public final class PlatformInfo
10  {
11    /**
12     * GUI toolkit identifier for Swing.
13     */
14    public static final String SWING = "swing";
15  
16    /**
17     * GUI toolkit identifier for SWT.
18     */
19    public static final String SWT = "swt";
20  
21    private final Collection _toolkits;
22    
23    /**
24     * Create a <tt>PlatformInfo</tt> object for the specified toolkits.
25     * 
26     * @param toolkits all toolkits supported by this extension. The first toolkit
27     *    in the collection should be the preferred toolkit. Must not be null
28     *    or empty.
29     */
30    public PlatformInfo( Collection toolkits )
31    {
32      if ( toolkits == null )
33      {
34        throw new NullPointerException( "Null toolkits" ); 
35      }
36      if ( toolkits.isEmpty() )
37      {
38        throw new IllegalArgumentException( "Empty toolkits" );
39      }
40      // Clone for safety.
41      _toolkits = new ArrayList( toolkits );
42    }
43  
44    /**
45     * Get the preferred toolkit for this extension.
46     * 
47     * @return the preferred toolkit for this extension.
48     */
49    public String getPreferredToolkit()
50    {
51      return (String)_toolkits.iterator().next();
52    }
53  
54  
55    /**
56     * Gets whether a specific toolkit is supported.
57     *
58     * @param toolkit to the toolkit to check for support. Either SWING or SWT.
59     * @return true if the specified toolkit is supported.
60     */
61    public boolean isToolkitSupported( String toolkit )
62    {
63      return _toolkits.contains( toolkit );
64    }
65  }