KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > google > gwt > sample > kitchensink > client > Sink


1 /*
2  * Copyright 2007 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5  * use this file except in compliance with the License. You may obtain a copy of
6  * the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13  * License for the specific language governing permissions and limitations under
14  * the License.
15  */

16 package com.google.gwt.sample.kitchensink.client;
17
18 import com.google.gwt.user.client.ui.AbstractImagePrototype;
19 import com.google.gwt.user.client.ui.Composite;
20 import com.google.gwt.user.client.ui.ImageBundle;
21 import com.google.gwt.user.client.ui.TreeImages;
22
23 /**
24  * A 'sink' is a single panel of the kitchen sink. They are meant to be lazily
25  * instantiated so that the application doesn't pay for all of them on startup.
26  */

27 public abstract class Sink extends Composite {
28
29   /**
30    * An image provider to make available images to Sinks.
31    */

32   public interface Images extends ImageBundle, TreeImages {
33     AbstractImagePrototype gwtLogo();
34   }
35
36   /**
37    * Encapsulated information about a sink. Each sink is expected to have a
38    * static <code>init()</code> method that will be called by the kitchen sink
39    * on startup.
40    */

41   public abstract static class SinkInfo {
42     private Sink instance;
43     private String JavaDoc name, description;
44
45     public SinkInfo(String JavaDoc name, String JavaDoc desc) {
46       this.name = name;
47       description = desc;
48     }
49
50     public abstract Sink createInstance();
51
52     public String JavaDoc getColor() {
53       return "#2a8ebf";
54     }
55
56     public String JavaDoc getDescription() {
57       return description;
58     }
59
60     public final Sink getInstance() {
61       if (instance != null) {
62         return instance;
63       }
64       return (instance = createInstance());
65     }
66
67     public String JavaDoc getName() {
68       return name;
69     }
70   }
71
72   /**
73    * Called just before this sink is hidden.
74    */

75   public void onHide() {
76   }
77
78   /**
79    * Called just after this sink is shown.
80    */

81   public void onShow() {
82   }
83 }
84
Popular Tags