source: release-kits/lirk3/bin/ant-installer/web/java2html/antinstaller/org/tp23/antinstaller/runtime/exe/CreateUIFilter.java.html@ 14982

Last change on this file since 14982 was 14982, checked in by oranfry, 16 years ago

initial import of LiRK3

File size: 16.5 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
2<HTML>
3<HEAD>
4<LINK REL=STYLESHEET TYPE="text/css" HREF="../../../../../stylesheet.css" TITLE="Style">
5<META NAME="GENERATOR" CONTENT="Java2HTML Version 1.4">
6<TITLE>org.tp23.antinstaller.runtime.exe.CreateUIFilter (Java2HTML)</TITLE>
7</HEAD>
8<BODY><TABLE id="Header" border="0" cellpadding="0" cellspacing="0" width="100%">
9<tr>
10<td colspan="2" width="33%">&nbsp;</td>
11<td align="center" colspan="2" width="33%">
12<font size="4" class="ClassName">CreateUIFilter.java</font>
13</td>
14<td align="right" colspan="2" width="33%">&nbsp;</td>
15</tr>
16</TABLE>
17<pre CLASS="Classes">
18<FONT CLASS="LN">1 </FONT><A NAME="1"></A><FONT CLASS="MultiLineComment">/*
19<FONT CLASS="LN">2 </FONT><A NAME="2"></A> * Copyright 2005 Paul Hinds
20<FONT CLASS="LN">3 </FONT><A NAME="3"></A> *
21<FONT CLASS="LN">4 </FONT><A NAME="4"></A> * Licensed under the Apache License, Version 2.0 (the "License");
22<FONT CLASS="LN">5 </FONT><A NAME="5"></A> * you may not use this file except in compliance with the License.
23<FONT CLASS="LN">6 </FONT><A NAME="6"></A> * You may obtain a copy of the License at
24<FONT CLASS="LN">7 </FONT><A NAME="7"></A> *
25<FONT CLASS="LN">8 </FONT><A NAME="8"></A> * http://www.apache.org/licenses/LICENSE-2.0
26<FONT CLASS="LN">9 </FONT><A NAME="9"></A> *
27<FONT CLASS="LN">10</FONT><A NAME="10"></A> * Unless required by applicable law or agreed to in writing, software
28<FONT CLASS="LN">11</FONT><A NAME="11"></A> * distributed under the License is distributed on an "AS IS" BASIS,
29<FONT CLASS="LN">12</FONT><A NAME="12"></A> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
30<FONT CLASS="LN">13</FONT><A NAME="13"></A> * See the License for the specific language governing permissions and
31<FONT CLASS="LN">14</FONT><A NAME="14"></A> * limitations under the License.
32<FONT CLASS="LN">15</FONT><A NAME="15"></A> */</FONT>
33<FONT CLASS="LN">16</FONT><A NAME="16"></A><FONT CLASS="Package">package</FONT> <A HREF="../../../../../org.tp23.antinstaller.runtime.exe.index.html" target="packageFrame">org.tp23.antinstaller.runtime.exe</A>;
34<FONT CLASS="LN">17</FONT><A NAME="17"></A>
35<FONT CLASS="LN">18</FONT><A NAME="18"></A><FONT CLASS="Import">import</FONT> java.io.IOException;
36<FONT CLASS="LN">19</FONT><A NAME="19"></A><FONT CLASS="Import">import</FONT> java.util.StringTokenizer;
37<FONT CLASS="LN">20</FONT><A NAME="20"></A>
38<FONT CLASS="LN">21</FONT><A NAME="21"></A><FONT CLASS="Import">import</FONT> <A HREF="../../../../../org/tp23/antinstaller/InstallException.java.html">org.tp23.antinstaller.InstallException</A>;
39<FONT CLASS="LN">22</FONT><A NAME="22"></A><FONT CLASS="Import">import</FONT> <A HREF="../../../../../org/tp23/antinstaller/InstallerContext.java.html">org.tp23.antinstaller.InstallerContext</A>;
40<FONT CLASS="LN">23</FONT><A NAME="23"></A><FONT CLASS="Import">import</FONT> <A HREF="../../../../../org/tp23/antinstaller/renderer/swing/plaf/LookAndFeelFactory.java.html">org.tp23.antinstaller.renderer.swing.plaf.LookAndFeelFactory</A>;
41<FONT CLASS="LN">24</FONT><A NAME="24"></A><FONT CLASS="Import">import</FONT> <A HREF="../../../../../org/tp23/antinstaller/runtime/AutoSwingRunner.java.html">org.tp23.antinstaller.runtime.AutoSwingRunner</A>;
42<FONT CLASS="LN">25</FONT><A NAME="25"></A><FONT CLASS="Import">import</FONT> <A HREF="../../../../../org/tp23/antinstaller/runtime/AutoTextRunner.java.html">org.tp23.antinstaller.runtime.AutoTextRunner</A>;
43<FONT CLASS="LN">26</FONT><A NAME="26"></A><FONT CLASS="Import">import</FONT> <A HREF="../../../../../org/tp23/antinstaller/runtime/Runner.java.html">org.tp23.antinstaller.runtime.Runner</A>;
44<FONT CLASS="LN">27</FONT><A NAME="27"></A><FONT CLASS="Import">import</FONT> <A HREF="../../../../../org/tp23/antinstaller/runtime/SwingRunner.java.html">org.tp23.antinstaller.runtime.SwingRunner</A>;
45<FONT CLASS="LN">28</FONT><A NAME="28"></A><FONT CLASS="Import">import</FONT> <A HREF="../../../../../org/tp23/antinstaller/runtime/TextRunner.java.html">org.tp23.antinstaller.runtime.TextRunner</A>;
46<FONT CLASS="LN">29</FONT><A NAME="29"></A>
47<FONT CLASS="LN">30</FONT><A NAME="30"></A>
48<FONT CLASS="LN">31</FONT><A NAME="31"></A><FONT CLASS="FormalComment">/**
49<FONT CLASS="LN">32</FONT><A NAME="32"></A> * Creates the Runner instance for the execution UI and sets up an appropriate
50<FONT CLASS="LN">33</FONT><A NAME="33"></A> * message renderer.
51<FONT CLASS="LN">34</FONT><A NAME="34"></A> * @author Paul Hinds
52<FONT CLASS="LN">35</FONT><A NAME="35"></A> * @version $Id: CreateUIFilter.java,v 1.7 2007/01/28 17:49:15 teknopaul Exp $
53<FONT CLASS="LN">36</FONT><A NAME="36"></A> */</FONT>
54<FONT CLASS="LN">37</FONT><A NAME="37"></A><FONT CLASS="Public">public</FONT> <FONT CLASS="Class">class</FONT> CreateUIFilter <FONT CLASS="Implements">implements</FONT> <A HREF="../../../../../org/tp23/antinstaller/runtime/exe/ExecuteFilter.java.html">ExecuteFilter</A> {
55<FONT CLASS="LN">38</FONT><A NAME="38"></A>
56<FONT CLASS="LN">39</FONT><A NAME="39"></A> <FONT CLASS="FormalComment">/**
57<FONT CLASS="LN">40</FONT><A NAME="40"></A> * @see org.tp23.antinstaller.runtime.exe.ExecuteFilter#exec(org.tp23.antinstaller.InstallerContext)
58<FONT CLASS="LN">41</FONT><A NAME="41"></A> */</FONT>
59<FONT CLASS="LN">42</FONT><A NAME="42"></A> <FONT CLASS="Public">public</FONT> <FONT CLASS="Void">void</FONT> exec(<A HREF="../../../../../org/tp23/antinstaller/InstallerContext.java.html">InstallerContext</A> ctx) <FONT CLASS="Throws">throws</FONT> <A HREF="../../../../../org/tp23/antinstaller/InstallException.java.html">InstallException</A> {
60<FONT CLASS="LN">43</FONT><A NAME="43"></A> <FONT CLASS="Try">try</FONT> {
61<FONT CLASS="LN">44</FONT><A NAME="44"></A> <FONT CLASS="If">if</FONT>(ctx.getInstaller().isVerbose()){
62<FONT CLASS="LN">45</FONT><A NAME="45"></A> ctx.log(<FONT CLASS="StringLiteral">"Creating UI classes"</FONT>);
63<FONT CLASS="LN">46</FONT><A NAME="46"></A> }
64<FONT CLASS="LN">47</FONT><A NAME="47"></A> ctx.setRunner(getRunner(ctx));
65<FONT CLASS="LN">48</FONT><A NAME="48"></A> ctx.log(<FONT CLASS="StringLiteral">"Created UI classes"</FONT>);
66<FONT CLASS="LN">49</FONT><A NAME="49"></A> }
67<FONT CLASS="LN">50</FONT><A NAME="50"></A> <FONT CLASS="Catch">catch</FONT> (IOException e) {
68<FONT CLASS="LN">51</FONT><A NAME="51"></A> <FONT CLASS="Throw">throw</FONT> <FONT CLASS="New">new</FONT> <A HREF="../../../../../org/tp23/antinstaller/InstallException.java.html">InstallException</A>(<FONT CLASS="StringLiteral">"Unable to create the user interface"</FONT>, e);
69<FONT CLASS="LN">52</FONT><A NAME="52"></A> }
70<FONT CLASS="LN">53</FONT><A NAME="53"></A> <FONT CLASS="Catch">catch</FONT> (<A HREF="../../../../../org/tp23/antinstaller/InstallException.java.html">InstallException</A> e) {
71<FONT CLASS="LN">54</FONT><A NAME="54"></A> <FONT CLASS="Throw">throw</FONT> <FONT CLASS="New">new</FONT> <A HREF="../../../../../org/tp23/antinstaller/InstallException.java.html">InstallException</A>(e.getMessage(), e);
72<FONT CLASS="LN">55</FONT><A NAME="55"></A> }
73<FONT CLASS="LN">56</FONT><A NAME="56"></A> }
74<FONT CLASS="LN">57</FONT><A NAME="57"></A> <FONT CLASS="FormalComment">/**
75<FONT CLASS="LN">58</FONT><A NAME="58"></A> * Determines which Runner to use text or swing or "auto" UIs which skip past the properties sreens.
76<FONT CLASS="LN">59</FONT><A NAME="59"></A> * @param override String if this paramter is not null it will be used. If
77<FONT CLASS="LN">60</FONT><A NAME="60"></A> * swing and there is no graphics environment the install will fail, if it is left
78<FONT CLASS="LN">61</FONT><A NAME="61"></A> * as null a check is made to see if there is a Graphics Environment and swing is used
79<FONT CLASS="LN">62</FONT><A NAME="62"></A> * if there are no errors, if there are errors the system falls back to the text console
80<FONT CLASS="LN">63</FONT><A NAME="63"></A> *
81<FONT CLASS="LN">64</FONT><A NAME="64"></A> * @throws IOException
82<FONT CLASS="LN">65</FONT><A NAME="65"></A> * @return Runner
83<FONT CLASS="LN">66</FONT><A NAME="66"></A> */</FONT>
84<FONT CLASS="LN">67</FONT><A NAME="67"></A> <FONT CLASS="Private">private</FONT> <A HREF="../../../../../org/tp23/antinstaller/runtime/AutoSwingRunner.java.html">Runner</A> getRunner(<A HREF="../../../../../org/tp23/antinstaller/InstallerContext.java.html">InstallerContext</A> ctx) <FONT CLASS="Throws">throws</FONT> IOException, <A HREF="../../../../../org/tp23/antinstaller/InstallException.java.html">InstallException</A> {
85<FONT CLASS="LN">68</FONT><A NAME="68"></A>
86<FONT CLASS="LN">69</FONT><A NAME="69"></A> <FONT CLASS="If">if</FONT>(ctx.getUIOverride() != <FONT CLASS="Null">null</FONT>){
87<FONT CLASS="LN">70</FONT><A NAME="70"></A> <FONT CLASS="If">if</FONT> (ctx.getUIOverride().equalsIgnoreCase(<FONT CLASS="StringLiteral">"swing"</FONT>)){
88<FONT CLASS="LN">71</FONT><A NAME="71"></A> <FONT CLASS="If">if</FONT>(isUi(<FONT CLASS="StringLiteral">"swing"</FONT>, ctx.getInstaller().getUi())){
89<FONT CLASS="LN">72</FONT><A NAME="72"></A> <FONT CLASS="New">new</FONT> <A HREF="../../../../../org/tp23/antinstaller/renderer/swing/plaf/LookAndFeelFactory.java.html">LookAndFeelFactory</A>(ctx).setLAF();
90<FONT CLASS="LN">73</FONT><A NAME="73"></A> <FONT CLASS="Return">return</FONT> <FONT CLASS="New">new</FONT> <A HREF="../../../../../org/tp23/antinstaller/runtime/AutoSwingRunner.java.html">SwingRunner</A>(ctx);
91<FONT CLASS="LN">74</FONT><A NAME="74"></A> }<FONT CLASS="Else">else</FONT>{
92<FONT CLASS="LN">75</FONT><A NAME="75"></A> <FONT CLASS="Throw">throw</FONT> <FONT CLASS="New">new</FONT> <A HREF="../../../../../org/tp23/antinstaller/InstallException.java.html">InstallException</A>(<FONT CLASS="StringLiteral">"Not a permited UI override, swing is not allowed"</FONT>);
93<FONT CLASS="LN">76</FONT><A NAME="76"></A> }
94<FONT CLASS="LN">77</FONT><A NAME="77"></A> }
95<FONT CLASS="LN">78</FONT><A NAME="78"></A>
96<FONT CLASS="LN">79</FONT><A NAME="79"></A> <FONT CLASS="If">if</FONT> (ctx.getUIOverride().equalsIgnoreCase(<FONT CLASS="StringLiteral">"text"</FONT>)){
97<FONT CLASS="LN">80</FONT><A NAME="80"></A> <FONT CLASS="If">if</FONT>(isUi(<FONT CLASS="StringLiteral">"text"</FONT>, ctx.getInstaller().getUi())){
98<FONT CLASS="LN">81</FONT><A NAME="81"></A> <FONT CLASS="Return">return</FONT> <FONT CLASS="New">new</FONT> <A HREF="../../../../../org/tp23/antinstaller/runtime/AutoTextRunner.java.html">TextRunner</A>(ctx);
99<FONT CLASS="LN">82</FONT><A NAME="82"></A> }<FONT CLASS="Else">else</FONT>{
100<FONT CLASS="LN">83</FONT><A NAME="83"></A> <FONT CLASS="Throw">throw</FONT> <FONT CLASS="New">new</FONT> <A HREF="../../../../../org/tp23/antinstaller/InstallException.java.html">InstallException</A>(<FONT CLASS="StringLiteral">"Not a permited UI override, text is not allowed"</FONT>);
101<FONT CLASS="LN">84</FONT><A NAME="84"></A> }
102<FONT CLASS="LN">85</FONT><A NAME="85"></A> }
103<FONT CLASS="LN">86</FONT><A NAME="86"></A>
104<FONT CLASS="LN">87</FONT><A NAME="87"></A> <FONT CLASS="If">if</FONT> (ctx.getUIOverride().equalsIgnoreCase(<FONT CLASS="StringLiteral">"swing-auto"</FONT>)){
105<FONT CLASS="LN">88</FONT><A NAME="88"></A> <FONT CLASS="If">if</FONT>(isUi(<FONT CLASS="StringLiteral">"swing-auto"</FONT>, ctx.getInstaller().getUi())){
106<FONT CLASS="LN">89</FONT><A NAME="89"></A> <FONT CLASS="New">new</FONT> <A HREF="../../../../../org/tp23/antinstaller/renderer/swing/plaf/LookAndFeelFactory.java.html">LookAndFeelFactory</A>(ctx).setLAF();
107<FONT CLASS="LN">90</FONT><A NAME="90"></A> <FONT CLASS="Return">return</FONT> <FONT CLASS="New">new</FONT> <A HREF="../../../../../org/tp23/antinstaller/runtime/AutoSwingRunner.java.html">AutoSwingRunner</A>(ctx);
108<FONT CLASS="LN">91</FONT><A NAME="91"></A> }<FONT CLASS="Else">else</FONT>{
109<FONT CLASS="LN">92</FONT><A NAME="92"></A> <FONT CLASS="Throw">throw</FONT> <FONT CLASS="New">new</FONT> <A HREF="../../../../../org/tp23/antinstaller/InstallException.java.html">InstallException</A>(<FONT CLASS="StringLiteral">"Not a permited UI override, swing-auto is not allowed"</FONT>);
110<FONT CLASS="LN">93</FONT><A NAME="93"></A> }
111<FONT CLASS="LN">94</FONT><A NAME="94"></A> }
112<FONT CLASS="LN">95</FONT><A NAME="95"></A>
113<FONT CLASS="LN">96</FONT><A NAME="96"></A> <FONT CLASS="If">if</FONT> (ctx.getUIOverride().equalsIgnoreCase(<FONT CLASS="StringLiteral">"text-auto"</FONT>)){
114<FONT CLASS="LN">97</FONT><A NAME="97"></A> <FONT CLASS="If">if</FONT>(isUi(<FONT CLASS="StringLiteral">"text-auto"</FONT>, ctx.getInstaller().getUi())){
115<FONT CLASS="LN">98</FONT><A NAME="98"></A> <FONT CLASS="Return">return</FONT> <FONT CLASS="New">new</FONT> <A HREF="../../../../../org/tp23/antinstaller/runtime/AutoTextRunner.java.html">AutoTextRunner</A>(ctx);
116<FONT CLASS="LN">99</FONT><A NAME="99"></A> }<FONT CLASS="Else">else</FONT>{
117<FONT CLASS="LN">00</FONT><A NAME="100"></A> <FONT CLASS="Throw">throw</FONT> <FONT CLASS="New">new</FONT> <A HREF="../../../../../org/tp23/antinstaller/InstallException.java.html">InstallException</A>(<FONT CLASS="StringLiteral">"Not a permited UI override, text-auto is not allowed"</FONT>);
118<FONT CLASS="LN">01</FONT><A NAME="101"></A> }
119<FONT CLASS="LN">02</FONT><A NAME="102"></A> }
120<FONT CLASS="LN">03</FONT><A NAME="103"></A>
121<FONT CLASS="LN">04</FONT><A NAME="104"></A> }
122<FONT CLASS="LN">05</FONT><A NAME="105"></A> <FONT CLASS="SingleLineComment">//else do stuff to work out if there is a graphics context
123<FONT CLASS="LN">06</FONT><A NAME="106"></A></FONT> <FONT CLASS="Try">try</FONT>{
124<FONT CLASS="LN">07</FONT><A NAME="107"></A> java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment();
125<FONT CLASS="LN">08</FONT><A NAME="108"></A> <FONT CLASS="MultiLineComment">/*
126<FONT CLASS="LN">09</FONT><A NAME="109"></A> * Above test is not enough to be sure that we can use the graphics env
127<FONT CLASS="LN">10</FONT><A NAME="110"></A> * so do remaining setup within try/catch block
128<FONT CLASS="LN">11</FONT><A NAME="111"></A> */</FONT>
129<FONT CLASS="LN">12</FONT><A NAME="112"></A> <FONT CLASS="New">new</FONT> <A HREF="../../../../../org/tp23/antinstaller/renderer/swing/plaf/LookAndFeelFactory.java.html">LookAndFeelFactory</A>(ctx).setLAF();
130<FONT CLASS="LN">13</FONT><A NAME="113"></A> <FONT CLASS="Return">return</FONT> <FONT CLASS="New">new</FONT> <A HREF="../../../../../org/tp23/antinstaller/runtime/AutoSwingRunner.java.html">SwingRunner</A>(ctx);
131<FONT CLASS="LN">14</FONT><A NAME="114"></A> } <FONT CLASS="Catch">catch</FONT> (Throwable e){
132<FONT CLASS="LN">15</FONT><A NAME="115"></A> System.out.println(<FONT CLASS="StringLiteral">"No graphics environment available, reverting to text"</FONT>);
133<FONT CLASS="LN">16</FONT><A NAME="116"></A> System.out.println();
134<FONT CLASS="LN">17</FONT><A NAME="117"></A> <FONT CLASS="Return">return</FONT> <FONT CLASS="New">new</FONT> <A HREF="../../../../../org/tp23/antinstaller/runtime/AutoTextRunner.java.html">TextRunner</A>(ctx);
135<FONT CLASS="LN">18</FONT><A NAME="118"></A> }
136<FONT CLASS="LN">19</FONT><A NAME="119"></A> }
137<FONT CLASS="LN">20</FONT><A NAME="120"></A>
138<FONT CLASS="LN">21</FONT><A NAME="121"></A>
139<FONT CLASS="LN">22</FONT><A NAME="122"></A> <FONT CLASS="Private">private</FONT> <FONT CLASS="Boolean">boolean</FONT> isUi(String ui, String commaSeparatedUiList){
140<FONT CLASS="LN">23</FONT><A NAME="123"></A> StringTokenizer st = <FONT CLASS="New">new</FONT> StringTokenizer(commaSeparatedUiList, <FONT CLASS="StringLiteral">","</FONT>);
141<FONT CLASS="LN">24</FONT><A NAME="124"></A> <FONT CLASS="While">while</FONT>(st.hasMoreTokens()){
142<FONT CLASS="LN">25</FONT><A NAME="125"></A> <FONT CLASS="If">if</FONT>(st.nextToken().equals(ui)){
143<FONT CLASS="LN">26</FONT><A NAME="126"></A> <FONT CLASS="Return">return</FONT> <FONT CLASS="True">true</FONT>;
144<FONT CLASS="LN">27</FONT><A NAME="127"></A> }
145<FONT CLASS="LN">28</FONT><A NAME="128"></A> }
146<FONT CLASS="LN">29</FONT><A NAME="129"></A> <FONT CLASS="Return">return</FONT> <FONT CLASS="False">false</FONT>;
147<FONT CLASS="LN">30</FONT><A NAME="130"></A> }
148<FONT CLASS="LN">31</FONT><A NAME="131"></A>
149<FONT CLASS="LN">32</FONT><A NAME="132"></A>}
150<FONT CLASS="LN">33</FONT><A NAME="133"></A></pre>
151</BODY>
152</HTML>
Note: See TracBrowser for help on using the repository browser.