[14982] | 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 int MESSAGE_PANEL_HEIGHT = 30;
|
---|
| 50 |
|
---|
| 51 | private JPanel contentPanel = new JPanel();
|
---|
| 52 |
|
---|
| 53 | private JTabbedPane jTabbedPane = new JTabbedPane();
|
---|
| 54 | private JPanel messagesPanel = new JPanel();
|
---|
| 55 | private BorderLayout borderLayout1 = new BorderLayout();
|
---|
| 56 | private JToggleButton jToggleButton = new JToggleButton();
|
---|
| 57 | private JLabel feedBackLabel = new JLabel();
|
---|
| 58 |
|
---|
| 59 | private SystemOutJTextArea outPanel = new SystemOutJTextArea();
|
---|
| 60 | private SystemOutJTextArea errPanel = new SystemOutJTextArea();
|
---|
| 61 |
|
---|
| 62 | private boolean showTargets = true;
|
---|
| 63 | private JScrollPane progressScrollPane = new JScrollPane();;
|
---|
| 64 | private ProgressPanel progressPanel;
|
---|
| 65 |
|
---|
| 66 | public ProgressPageRenderer() {
|
---|
| 67 | errPanel.setAsSystemErr();
|
---|
| 68 | outPanel.setAsSystemOut();
|
---|
| 69 | }
|
---|
| 70 | /**
|
---|
| 71 | * getErr
|
---|
| 72 | * @return PrintStream
|
---|
| 73 | */
|
---|
| 74 | public PrintStream getErr() {
|
---|
| 75 | return errPanel.getOut();
|
---|
| 76 | }
|
---|
| 77 | /**
|
---|
| 78 | * getOut
|
---|
| 79 | * @return PrintStream
|
---|
| 80 | */
|
---|
| 81 | public PrintStream getOut() {
|
---|
| 82 | return outPanel.getOut();
|
---|
| 83 | }
|
---|
| 84 |
|
---|
| 85 | /**
|
---|
| 86 | * instanceInit
|
---|
| 87 | */
|
---|
[17517] | 88 | public void reInstanceInit() {
|
---|
| 89 | feedBackLabel.setText(org.tp23.antinstaller.Installer.langPack.getString("click")+" "+ctx.getInstaller().getFinishButtonText()+" "+org.tp23.antinstaller.Installer.langPack.getString("toContinue"));
|
---|
| 90 | jToggleButton.setText(org.tp23.antinstaller.Installer.langPack.getString("showDetails"));
|
---|
| 91 |
|
---|
| 92 | jTabbedPane.removeAll();
|
---|
| 93 | jTabbedPane.add(org.tp23.antinstaller.Installer.langPack.getString("output"), outPanel);
|
---|
| 94 | jTabbedPane.add(org.tp23.antinstaller.Installer.langPack.getString("errors"), errPanel);
|
---|
| 95 | }
|
---|
| 96 |
|
---|
[14982] | 97 | public void instanceInit() {
|
---|
| 98 | showTargets = ((ProgressPage)page).isShowTargets();
|
---|
| 99 | contentPanel.setLayout(borderLayout1);
|
---|
| 100 | this.add(contentPanel,BorderLayout.CENTER);
|
---|
| 101 |
|
---|
| 102 | messagesPanel.setLayout(null);
|
---|
| 103 | Dimension messPanelSize = new Dimension(SizeConstants.PAGE_WIDTH,MESSAGE_PANEL_HEIGHT);
|
---|
| 104 | messagesPanel.setSize(messPanelSize);
|
---|
| 105 | messagesPanel.setPreferredSize(messPanelSize);
|
---|
| 106 | messagesPanel.setMaximumSize(messPanelSize);
|
---|
| 107 | messagesPanel.setMinimumSize(messPanelSize);
|
---|
| 108 |
|
---|
| 109 | //FIXME not i18n properly since the sentence is not correct ordering in German
|
---|
[17514] | 110 | feedBackLabel.setText(org.tp23.antinstaller.Installer.langPack.getString("click")+" "+ctx.getInstaller().getFinishButtonText()+" "+org.tp23.antinstaller.Installer.langPack.getString("toContinue"));
|
---|
[14982] | 111 | feedBackLabel.setBounds(new Rectangle(115, 7, 272, 22));
|
---|
[17514] | 112 | jToggleButton.setText(org.tp23.antinstaller.Installer.langPack.getString("showDetails"));
|
---|
[14982] | 113 | jToggleButton.setBounds(new Rectangle(5, 7, 104, 22));
|
---|
| 114 | jToggleButton.setMargin(new Insets(0,0,0,0));
|
---|
| 115 | messagesPanel.add(jToggleButton, null);
|
---|
| 116 | messagesPanel.add(feedBackLabel, null);
|
---|
| 117 | jToggleButton.addActionListener(new ActionListener(){
|
---|
| 118 | public void actionPerformed(ActionEvent e) {
|
---|
| 119 | if(jToggleButton.isSelected()){
|
---|
| 120 | if(showTargets){
|
---|
| 121 | contentPanel.remove(progressScrollPane);
|
---|
| 122 | }
|
---|
| 123 | contentPanel.add(jTabbedPane, BorderLayout.CENTER);
|
---|
| 124 | contentPanel.doLayout();
|
---|
| 125 | contentPanel.repaint();
|
---|
| 126 | }
|
---|
| 127 | else {
|
---|
| 128 | contentPanel.remove(jTabbedPane);
|
---|
| 129 | if(showTargets){
|
---|
| 130 | contentPanel.add(progressScrollPane, BorderLayout.CENTER);
|
---|
| 131 | progressScrollPane.revalidate();
|
---|
| 132 | }
|
---|
| 133 | contentPanel.doLayout();
|
---|
| 134 | contentPanel.repaint();
|
---|
| 135 | }
|
---|
| 136 | }
|
---|
| 137 | });
|
---|
[17569] | 138 |
|
---|
[14982] | 139 | jToggleButton.setIcon(getImage("/resources/icons/showdetails.png"));
|
---|
| 140 | contentPanel.add(messagesPanel, BorderLayout.NORTH);
|
---|
| 141 |
|
---|
[17569] | 142 |
|
---|
[14982] | 143 | if(showTargets){
|
---|
| 144 | progressScrollPane.setBorder(BorderFactory.createEmptyBorder(10,5,5,5));
|
---|
| 145 | contentPanel.add(progressScrollPane, BorderLayout.CENTER);
|
---|
| 146 | }
|
---|
[17514] | 147 | jTabbedPane.add(org.tp23.antinstaller.Installer.langPack.getString("output"), outPanel);
|
---|
| 148 | jTabbedPane.add(org.tp23.antinstaller.Installer.langPack.getString("errors"), errPanel);
|
---|
[14982] | 149 | // if(OutputField.isTrue( ctx.getInstaller().getAntialiased())){
|
---|
| 150 | // outPanel.setAntialiased(true);
|
---|
| 151 | // errPanel.setAntialiased(true);
|
---|
| 152 | // }
|
---|
| 153 |
|
---|
| 154 | //jTabbedPane.setVisible(false);
|
---|
| 155 | jTabbedPane.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
|
---|
| 156 | contentPanel.setMaximumSize(new Dimension(SizeConstants.PAGE_WIDTH, Integer.MAX_VALUE));
|
---|
| 157 | contentPanel.setMinimumSize(new Dimension(SizeConstants.PAGE_WIDTH, 100));
|
---|
| 158 | contentPanel.setPreferredSize(new Dimension(SizeConstants.PAGE_WIDTH, SizeConstants.PAGE_HEIGHT-100));
|
---|
| 159 | //contentPanel.add(jTabbedPane, null);
|
---|
| 160 | //jTabbedPane.setBounds(new Rectangle(4, MESSAGE_PANEL_HEIGHT, PAGE_WIDTH-12, 214));
|
---|
| 161 |
|
---|
[17569] | 162 |
|
---|
[17517] | 163 | this.getNextButton().setVisible(false);
|
---|
[14982] | 164 | this.getFinishButton().setText(ctx.getInstaller().getFinishButtonText());
|
---|
[17517] | 165 | this.getFinishButton().setVisible(true);
|
---|
[14982] | 166 | }
|
---|
| 167 |
|
---|
| 168 | public void setContext(SwingInstallerContext swingCtx){
|
---|
| 169 | super.setContext(swingCtx);
|
---|
| 170 | if(showTargets){
|
---|
| 171 | progressPanel = new ProgressPanel(swingCtx.getInstallerContext());
|
---|
| 172 | progressScrollPane.getViewport().add(progressPanel);
|
---|
| 173 | this.swingCtx.setProgressPanel(progressPanel);
|
---|
| 174 | }
|
---|
| 175 | this.swingCtx.setFeedBackLabel(feedBackLabel);
|
---|
| 176 | }
|
---|
| 177 |
|
---|
| 178 |
|
---|
| 179 | /**
|
---|
| 180 | * updateInputFields
|
---|
| 181 | */
|
---|
| 182 | public void updateInputFields() {
|
---|
| 183 |
|
---|
| 184 | }
|
---|
| 185 |
|
---|
| 186 |
|
---|
| 187 |
|
---|
| 188 | /**
|
---|
| 189 | * validateFields
|
---|
| 190 | *
|
---|
| 191 | * @return boolean
|
---|
| 192 | */
|
---|
| 193 | public boolean validateFields() {
|
---|
| 194 | return true;
|
---|
| 195 | }
|
---|
| 196 |
|
---|
| 197 |
|
---|
| 198 |
|
---|
| 199 | /**
|
---|
| 200 | * updateDefaultValues
|
---|
| 201 | */
|
---|
| 202 | public void updateDefaultValues() {
|
---|
| 203 | }
|
---|
| 204 | }
|
---|