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 | */
|
---|
16 | package org.tp23.antinstaller.renderer.swing;
|
---|
17 |
|
---|
18 | import java.awt.BorderLayout;
|
---|
19 | import java.awt.Dimension;
|
---|
20 | import java.awt.Insets;
|
---|
21 | import java.awt.Rectangle;
|
---|
22 | import java.awt.event.ActionEvent;
|
---|
23 | import java.awt.event.ActionListener;
|
---|
24 | import java.io.PrintStream;
|
---|
25 | import java.util.ResourceBundle;
|
---|
26 |
|
---|
27 | import javax.swing.BorderFactory;
|
---|
28 | import javax.swing.JLabel;
|
---|
29 | import javax.swing.JPanel;
|
---|
30 | import javax.swing.JScrollPane;
|
---|
31 | import javax.swing.JTabbedPane;
|
---|
32 | import javax.swing.JToggleButton;
|
---|
33 |
|
---|
34 | import org.tp23.antinstaller.page.ProgressPage;
|
---|
35 | import org.tp23.antinstaller.renderer.AntOutputRenderer;
|
---|
36 | import org.tp23.gui.widget.SystemOutJTextArea;
|
---|
37 | /**
|
---|
38 | *
|
---|
39 | * <p>Copyright: Copyright (c) 2004</p>
|
---|
40 | * <p>Company: tp23</p>
|
---|
41 | * @todo change absolute to Border layout and panels
|
---|
42 | * @author Paul Hinds
|
---|
43 | * @version $Id: ProgressPageRenderer.java,v 1.4 2006/12/21 00:03:00 teknopaul Exp $
|
---|
44 | */
|
---|
45 | public class ProgressPageRenderer
|
---|
46 | extends SwingPageRenderer
|
---|
47 | implements AntOutputRenderer {
|
---|
48 |
|
---|
49 | private static final ResourceBundle res = ResourceBundle.getBundle("org.tp23.antinstaller.renderer.Res");
|
---|
50 | private static final int MESSAGE_PANEL_HEIGHT = 30;
|
---|
51 |
|
---|
52 | private JPanel contentPanel = new JPanel();
|
---|
53 |
|
---|
54 | private JTabbedPane jTabbedPane = new JTabbedPane();
|
---|
55 | private JPanel messagesPanel = new JPanel();
|
---|
56 | private BorderLayout borderLayout1 = new BorderLayout();
|
---|
57 | private JToggleButton jToggleButton = new JToggleButton();
|
---|
58 | private JLabel feedBackLabel = new JLabel();
|
---|
59 |
|
---|
60 | private SystemOutJTextArea outPanel = new SystemOutJTextArea();
|
---|
61 | private SystemOutJTextArea errPanel = new SystemOutJTextArea();
|
---|
62 |
|
---|
63 | private boolean showTargets = true;
|
---|
64 | private JScrollPane progressScrollPane = new JScrollPane();;
|
---|
65 | private ProgressPanel progressPanel;
|
---|
66 |
|
---|
67 | public ProgressPageRenderer() {
|
---|
68 | errPanel.setAsSystemErr();
|
---|
69 | outPanel.setAsSystemOut();
|
---|
70 | }
|
---|
71 | /**
|
---|
72 | * getErr
|
---|
73 | * @return PrintStream
|
---|
74 | */
|
---|
75 | public PrintStream getErr() {
|
---|
76 | return errPanel.getOut();
|
---|
77 | }
|
---|
78 | /**
|
---|
79 | * getOut
|
---|
80 | * @return PrintStream
|
---|
81 | */
|
---|
82 | public PrintStream getOut() {
|
---|
83 | return outPanel.getOut();
|
---|
84 | }
|
---|
85 |
|
---|
86 |
|
---|
87 | /**
|
---|
88 | * instanceInit
|
---|
89 | */
|
---|
90 | public void instanceInit() {
|
---|
91 | showTargets = ((ProgressPage)page).isShowTargets();
|
---|
92 | contentPanel.setLayout(borderLayout1);
|
---|
93 | this.add(contentPanel,BorderLayout.CENTER);
|
---|
94 |
|
---|
95 | //progressScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
|
---|
96 |
|
---|
97 | messagesPanel.setLayout(null);
|
---|
98 | Dimension messPanelSize = new Dimension(SizeConstants.PAGE_WIDTH,MESSAGE_PANEL_HEIGHT);
|
---|
99 | messagesPanel.setSize(messPanelSize);
|
---|
100 | messagesPanel.setPreferredSize(messPanelSize);
|
---|
101 | messagesPanel.setMaximumSize(messPanelSize);
|
---|
102 | messagesPanel.setMinimumSize(messPanelSize);
|
---|
103 |
|
---|
104 | //FIXME not i18n properly since the sentence is not correct ordering in German
|
---|
105 | feedBackLabel.setText(res.getString("click")+" "+ctx.getInstaller().getFinishButtonText()+" "+res.getString("toContinue"));
|
---|
106 | feedBackLabel.setBounds(new Rectangle(115, 7, 272, 22));
|
---|
107 | jToggleButton.setText(res.getString("showDetails"));
|
---|
108 | jToggleButton.setBounds(new Rectangle(5, 7, 104, 22));
|
---|
109 | jToggleButton.setMargin(new Insets(0,0,0,0));
|
---|
110 | messagesPanel.add(jToggleButton, null);
|
---|
111 | messagesPanel.add(feedBackLabel, null);
|
---|
112 | jToggleButton.addActionListener(new ActionListener(){
|
---|
113 | public void actionPerformed(ActionEvent e) {
|
---|
114 | if(jToggleButton.isSelected()){
|
---|
115 | if(showTargets){
|
---|
116 | contentPanel.remove(progressScrollPane);
|
---|
117 | }
|
---|
118 | contentPanel.add(jTabbedPane, BorderLayout.CENTER);
|
---|
119 | contentPanel.doLayout();
|
---|
120 | contentPanel.repaint();
|
---|
121 | }
|
---|
122 | else {
|
---|
123 | contentPanel.remove(jTabbedPane);
|
---|
124 | if(showTargets){
|
---|
125 | contentPanel.add(progressScrollPane, BorderLayout.CENTER);
|
---|
126 | progressScrollPane.revalidate();
|
---|
127 | }
|
---|
128 | contentPanel.doLayout();
|
---|
129 | contentPanel.repaint();
|
---|
130 | }
|
---|
131 | }
|
---|
132 | });
|
---|
133 | jToggleButton.setIcon(getImage("/resources/icons/showdetails.png"));
|
---|
134 | contentPanel.add(messagesPanel, BorderLayout.NORTH);
|
---|
135 |
|
---|
136 | if(showTargets){
|
---|
137 | progressScrollPane.setBorder(BorderFactory.createEmptyBorder(10,5,5,5));
|
---|
138 | contentPanel.add(progressScrollPane, BorderLayout.CENTER);
|
---|
139 | }
|
---|
140 | jTabbedPane.add(res.getString("output"), outPanel);
|
---|
141 | jTabbedPane.add(res.getString("errors"), errPanel);
|
---|
142 | // if(OutputField.isTrue( ctx.getInstaller().getAntialiased())){
|
---|
143 | // outPanel.setAntialiased(true);
|
---|
144 | // errPanel.setAntialiased(true);
|
---|
145 | // }
|
---|
146 |
|
---|
147 | //jTabbedPane.setVisible(false);
|
---|
148 | jTabbedPane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
|
---|
149 | contentPanel.setMaximumSize(new Dimension(SizeConstants.PAGE_WIDTH, Integer.MAX_VALUE));
|
---|
150 | contentPanel.setMinimumSize(new Dimension(SizeConstants.PAGE_WIDTH, 100));
|
---|
151 | contentPanel.setPreferredSize(new Dimension(SizeConstants.PAGE_WIDTH, SizeConstants.PAGE_HEIGHT-100));
|
---|
152 | //contentPanel.add(jTabbedPane, null);
|
---|
153 | //jTabbedPane.setBounds(new Rectangle(4, MESSAGE_PANEL_HEIGHT, PAGE_WIDTH-12, 214));
|
---|
154 |
|
---|
155 | this.getNextButton().setEnabled(false);
|
---|
156 | this.getFinishButton().setText(ctx.getInstaller().getFinishButtonText());
|
---|
157 | this.getFinishButton().setEnabled(true);
|
---|
158 | }
|
---|
159 |
|
---|
160 | public void setContext(SwingInstallerContext swingCtx){
|
---|
161 | super.setContext(swingCtx);
|
---|
162 | if(showTargets){
|
---|
163 | progressPanel = new ProgressPanel(swingCtx.getInstallerContext());
|
---|
164 | progressScrollPane.getViewport().add(progressPanel);
|
---|
165 | this.swingCtx.setProgressPanel(progressPanel);
|
---|
166 | }
|
---|
167 | this.swingCtx.setFeedBackLabel(feedBackLabel);
|
---|
168 | }
|
---|
169 |
|
---|
170 |
|
---|
171 | /**
|
---|
172 | * updateInputFields
|
---|
173 | */
|
---|
174 | public void updateInputFields() {
|
---|
175 |
|
---|
176 | }
|
---|
177 |
|
---|
178 |
|
---|
179 |
|
---|
180 | /**
|
---|
181 | * validateFields
|
---|
182 | *
|
---|
183 | * @return boolean
|
---|
184 | */
|
---|
185 | public boolean validateFields() {
|
---|
186 | return true;
|
---|
187 | }
|
---|
188 |
|
---|
189 |
|
---|
190 |
|
---|
191 | /**
|
---|
192 | * updateDefaultValues
|
---|
193 | */
|
---|
194 | public void updateDefaultValues() {
|
---|
195 | }
|
---|
196 | }
|
---|