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.io.ByteArrayOutputStream;
|
---|
20 | import java.io.InputStream;
|
---|
21 |
|
---|
22 | import javax.swing.ImageIcon;
|
---|
23 | import javax.swing.JLabel;
|
---|
24 |
|
---|
25 | import org.tp23.antinstaller.ValidationException;
|
---|
26 | import org.tp23.antinstaller.page.SplashPage;
|
---|
27 | import org.tp23.antinstaller.runtime.ConfigurationException;
|
---|
28 | /**
|
---|
29 | * A page containing only a single image.
|
---|
30 | *
|
---|
31 | * @author teknopaul
|
---|
32 | */
|
---|
33 | public class SplashPageRenderer extends SwingPageRenderer{
|
---|
34 |
|
---|
35 | private JLabel imagePanel = new JLabel();
|
---|
36 |
|
---|
37 | public SplashPageRenderer() {
|
---|
38 | }
|
---|
39 | public boolean validateFields()throws ValidationException{
|
---|
40 | return true;
|
---|
41 | }
|
---|
42 |
|
---|
43 | public void reInstanceInit() {}
|
---|
44 |
|
---|
45 | public void instanceInit() throws Exception {
|
---|
46 | String resource = ((SplashPage)page).getSplashResource();
|
---|
47 | ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
---|
48 | InputStream in = this.getClass().getResourceAsStream(resource);
|
---|
49 | if(in == null) {
|
---|
50 | throw new ConfigurationException("Splash page resource is missing: " + resource);
|
---|
51 | }
|
---|
52 | byte[] buffer = new byte[2048];
|
---|
53 | int read = -1;
|
---|
54 | while ( (read = in.read(buffer)) != -1) {
|
---|
55 | baos.write(buffer, 0, read);
|
---|
56 | }
|
---|
57 | ImageIcon icon = new ImageIcon(baos.toByteArray());
|
---|
58 | imagePanel.setHorizontalAlignment(JLabel.CENTER);
|
---|
59 | imagePanel.setIcon(icon);
|
---|
60 | this.add(imagePanel, BorderLayout.CENTER);
|
---|
61 | }
|
---|
62 |
|
---|
63 | public void updateInputFields(){
|
---|
64 | ;
|
---|
65 | }
|
---|
66 |
|
---|
67 | /**
|
---|
68 | * updateDefaultValues
|
---|
69 | */
|
---|
70 | public void updateDefaultValues() {
|
---|
71 | }
|
---|
72 |
|
---|
73 | }
|
---|