Bump for 4.0-11
[LibreOffice.git] / scripting / workben / installer / NavPanel.java
blobb1738ddad4f78764b72c0a211b95e936739298af
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package installer;
21 import javax.swing.*;
22 import java.awt.*;
23 import java.awt.event.*;
24 public class NavPanel extends JPanel implements ActionListener {
26 NavPanel(InstallWizard wizard, boolean bBack, boolean bNext, boolean bCancel, String prev, String next) {
27 setBackground(Color.white);
28 setBorder(new javax.swing.border.EtchedBorder(javax.swing.border.EtchedBorder.LOWERED));
29 this.wizard = wizard;
30 this.next = next;
31 this.prev = prev;
32 navBack = new javax.swing.JButton("<< Back");
33 navNext = new javax.swing.JButton("Next >>");
34 navCancel = new javax.swing.JButton("Cancel");
35 setLayout(new GridBagLayout());
37 gridBagConstraints1 = new java.awt.GridBagConstraints();
38 gridBagConstraints1.insets = new java.awt.Insets(1, 1, 1, 1);
39 gridBagConstraints1.anchor = gridBagConstraints1.WEST;
41 gridBagConstraints2 = new java.awt.GridBagConstraints();
42 gridBagConstraints2.gridx = 2;
43 gridBagConstraints2.gridy = 0;
45 gridBagConstraints3 = new java.awt.GridBagConstraints();
46 gridBagConstraints3.gridx = 6;
47 gridBagConstraints3.gridy = 0;
49 navNext.setEnabled(bNext);
50 navBack.setEnabled(bBack);
51 navCancel.setEnabled(bCancel);
52 navNext.addActionListener(this);
53 navBack.addActionListener(this);
54 navCancel.addActionListener(this);
55 add(navBack, gridBagConstraints1);
56 add(navNext, gridBagConstraints2);
57 add(navCancel, gridBagConstraints3);
60 public void enableNext(boolean bEnable) {
61 navNext.setEnabled(bEnable);
64 public void enableBack(boolean bEnable) {
65 navBack.setEnabled(bEnable);
68 public void enableCancel(boolean bEnable) {
69 navCancel.setEnabled(bEnable);
72 public void enableIDE(boolean bEnable) {
73 ideDetected = bEnable;
76 public void actionPerformed(ActionEvent ev) {
77 if ((ev.getSource() == navNext) && (next.length() != 0)) {
78 wizard.show(next);
80 if ((ev.getSource() == navBack) && (prev.length() != 0)) {
81 wizard.show(prev);
83 if (ev.getSource() == navCancel) {
84 if( ideDetected ) {
85 wizard.show(InstallWizard.IDEWELCOME);
87 else {
88 wizard.exitForm(null);
90 enableIDE(false);
94 public void setNextListener(ActionListener listener) {
95 navNext.addActionListener(listener);
98 public void setBackListener(ActionListener listener) {
99 navBack.addActionListener(listener);
102 public void setCancelListener(ActionListener listener) {
103 navCancel.addActionListener(listener);
106 public void removeNextListener(ActionListener listener)
108 navNext.removeActionListener(listener);
111 public void removeBackListener(ActionListener listener)
113 navBack.removeActionListener(listener);
116 public void removeCancelListener(ActionListener listener)
118 navCancel.removeActionListener(listener);
121 public JButton navBack;
122 public JButton navNext;
123 public JButton navCancel;
124 private GridBagConstraints gridBagConstraints1;
125 private GridBagConstraints gridBagConstraints2;
126 private GridBagConstraints gridBagConstraints3;
127 private InstallWizard wizard;
128 private String next;
129 private String prev;
130 private boolean ideDetected = false;