1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 package org.openoffice.setup.Panel; 25 26 import org.openoffice.setup.PanelHelper.PanelLabel; 27 import org.openoffice.setup.PanelHelper.PanelTitle; 28 import org.openoffice.setup.ResourceManager; 29 import org.openoffice.setup.SetupActionListener; 30 import java.awt.BorderLayout; 31 import java.awt.ComponentOrientation; 32 import java.awt.Container; 33 import java.awt.Insets; 34 import javax.swing.Box; 35 import javax.swing.JButton; 36 import javax.swing.JPanel; 37 import javax.swing.JProgressBar; 38 import javax.swing.border.EmptyBorder; 39 import org.openoffice.setup.InstallData; 40 41 public class InstallationOngoing extends JPanel { 42 43 private PanelLabel currentProgress; 44 private JProgressBar progressBar; 45 private JButton mStopButton; 46 private String mTitle = ""; 47 private PanelTitle mTitlebox; 48 InstallationOngoing()49 public InstallationOngoing() { 50 51 InstallData data = InstallData.getInstance(); 52 53 setLayout(new java.awt.BorderLayout()); 54 setBorder(new EmptyBorder(new Insets(10, 10, 10, 10))); 55 56 // String titleText = ResourceManager.getString("String_InstallationOngoing1"); 57 // PanelTitle titlebox = new PanelTitle(titleText); 58 // PanelTitle titlebox = new PanelTitle(mTitle); 59 mTitlebox = new PanelTitle(mTitle); 60 mTitlebox.addVerticalStrut(20); 61 add(mTitlebox, BorderLayout.NORTH); 62 63 Container contentbox = Box.createVerticalBox(); 64 if ( data.useRtl() ) { contentbox.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); } 65 66 // String progressText = ResourceManager.getString("String_InstallationOngoing2"); 67 String progressText = ""; 68 currentProgress = new PanelLabel(progressText); 69 70 Container innerbox = Box.createHorizontalBox(); 71 if ( data.useRtl() ) { innerbox.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); } 72 progressBar = new JProgressBar(0, 100); 73 if ( data.useRtl() ) { progressBar.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); } 74 mStopButton = new JButton(); 75 String progressButtonText = ResourceManager.getString("String_InstallationOngoing3"); 76 mStopButton.setText(progressButtonText); 77 mStopButton.setEnabled(true); 78 if ( data.useRtl() ) { mStopButton.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT); } 79 80 innerbox.add(progressBar); 81 innerbox.add(Box.createHorizontalStrut(10)); 82 innerbox.add(mStopButton); 83 84 contentbox.add(currentProgress); 85 contentbox.add(Box.createVerticalStrut(10)); 86 contentbox.add(innerbox); 87 contentbox.add(Box.createVerticalStrut(20)); 88 89 add(contentbox, BorderLayout.SOUTH); 90 } 91 setProgressText(String s)92 public void setProgressText(String s) { 93 currentProgress.setText(s); 94 } 95 setProgressValue(int i)96 public void setProgressValue(int i) { 97 progressBar.setValue(i); 98 } 99 setTitle(String title)100 public void setTitle(String title) { 101 mTitlebox.setTitle(title); 102 mTitle = title; 103 } 104 setStopButtonActionCommand(String actionCommand)105 public void setStopButtonActionCommand(String actionCommand) { 106 mStopButton.setActionCommand(actionCommand); 107 } 108 addStopButtonActionListener(SetupActionListener actionListener)109 public void addStopButtonActionListener(SetupActionListener actionListener) { 110 mStopButton.addActionListener(actionListener); 111 } 112 setStopButtonEnabled(boolean enabled)113 public void setStopButtonEnabled(boolean enabled) { 114 mStopButton.setEnabled(enabled); 115 } 116 117 } 118