1 /* 
2  * Copyright 2005 Paul Hinds
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of 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,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.tp23.antinstaller.antmod;
17
18import java.util.ResourceBundle;
19
20import org.apache.tools.ant.BuildEvent;
21import org.apache.tools.ant.BuildListener;
22import org.tp23.antinstaller.renderer.swing.SwingInstallerContext;
23/**
24 *
25 * <p>Reports a message in the swing UI this mesage is reported in the
26 * top of the window. </p>
27 * <p>The Listeners should apparently never uses System.out or System.err</p>
28 * This class is not really an Ant modification since it simply implements
29 * a public interface but is here on the offchance that one day Ant changes
30 * it's APIs
31 * @author Paul Hinds
32 * @version $Id: FeedbackListener.java,v 1.1.1.1 2005/10/18 18:20:52 teknopaul Exp $
33 */
34public class FeedbackListener implements BuildListener{
35
36    private final SwingInstallerContext swingCtx;
37    private static final ResourceBundle res = ResourceBundle.getBundle("org.tp23.antinstaller.renderer.Res");
38
39    public FeedbackListener(SwingInstallerContext swingCtx) {
40        this.swingCtx=swingCtx;
41    }
42
43    /**
44     * buildStarted This event results in User notification
45     *
46     * @param buildEvent BuildEvent
47     */
48    public void buildStarted(BuildEvent buildEvent) {
49        //swingCtx.provideAntFeedBack(buildEvent.getMessage());
50        swingCtx.buildStarted(buildEvent);
51    }
52
53    /**
54     * buildFinished This event results in User notification
55     *
56     * @param buildEvent BuildEvent
57     */
58    public void buildFinished(BuildEvent buildEvent) {
59        swingCtx.provideAntFeedBack(res.getString("installFinished"));
60        swingCtx.buildFinished(buildEvent);
61    }
62
63    /**
64     * targetStarted This event results in User notification
65     *
66     * @param buildEvent BuildEvent
67     */
68    public void targetStarted(BuildEvent buildEvent) {
69        swingCtx.provideAntFeedBack(res.getString("running")+buildEvent.getTarget());
70        swingCtx.targetStarted(buildEvent);
71    }
72
73    /**
74     * targetFinished This event is ignored
75     * @param buildEvent BuildEvent
76     */
77    public void targetFinished(BuildEvent buildEvent) {
78        swingCtx.targetFinished(buildEvent);
79    }
80
81    /**
82     * taskStarted This event is ignored
83     * @param buildEvent BuildEvent
84     */
85    public void taskStarted(BuildEvent buildEvent) {
86        //swingCtx.provideAntFeedBack(buildEvent.getMessage());
87    }
88
89    /**
90     * taskFinished This event is ignored
91     * @param buildEvent BuildEvent
92     */
93    public void taskFinished(BuildEvent buildEvent) {
94        //swingCtx.provideAntFeedBack(buildEvent.getMessage());
95    }
96
97    /**
98     * messageLogged This event is ignored
99     * @param buildEvent BuildEvent
00     */
01    public void messageLogged(BuildEvent buildEvent) {
02        //swingCtx.provideAntFeedBack(buildEvent.getMessage());
03    }
04}
05