001: /*
002: * Copyright 2001-2006 C:1 Financial Services GmbH
003: *
004: * This software is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License Version 2.1, as published by the Free Software Foundation.
007: *
008: * This software is distributed in the hope that it will be useful,
009: * but WITHOUT ANY WARRANTY; without even the implied warranty of
010: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
011: * Lesser General Public License for more details.
012: *
013: * You should have received a copy of the GNU Lesser General Public
014: * License along with this library; if not, write to the Free Software
015: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
016: */
017:
018: package de.finix.contelligent.client.wizard;
019:
020: import java.util.Map;
021:
022: import javax.swing.JComponent;
023: import javax.swing.JDialog;
024: import javax.swing.JLabel;
025: import javax.swing.JPanel;
026:
027: import de.finix.contelligent.client.ContelligentClient;
028: import de.finix.contelligent.client.i18n.Resources;
029: import de.finix.contelligent.client.util.JTextUtil;
030: import de.finix.contelligent.client.util.TableLayout;
031:
032: public class DescriptionWizard extends AbstractWizard {
033: private Map descriptions;
034:
035: public DescriptionWizard(Map descriptions) {
036: super ();
037: this .descriptions = descriptions;
038: }
039:
040: public int startWizard(int step) {
041: int currentStep = 0;
042: int totalSteps = 1;
043: int option;
044: do {
045: option = NEXT_OPTION;
046: if (currentStep == 0) {
047: option = showDescriptionDialog(step);
048: }
049: if (option == NEXT_OPTION) {
050: currentStep++;
051: } else if (option == BACK_OPTION) {
052: currentStep--;
053: } else {
054: currentStep = -1;
055: }
056: } while (currentStep != -1 && currentStep < totalSteps);
057: return option;
058: }
059:
060: public Map getDescriptions() {
061: return descriptions;
062: }
063:
064: private int showDescriptionDialog(int step) {
065: JPanel panel = new JPanel(new TableLayout(new double[][] {
066: { 250 },
067: { TableLayout.PREFERRED, 5, TableLayout.PREFERRED, 10,
068: TableLayout.FILL } }));
069: JLabel title = JTextUtil.createTitle(Resources
070: .getLocalString("description_wizard_title"));
071: panel.add(title, "0,0");
072: JComponent info = JTextUtil.createMessageArea(Resources
073: .getLocalString("description_wizard_description"));
074: info.setOpaque(false);
075: panel.add(info, "0,2");
076: DescriptionPane descriptionPane = new DescriptionPane(
077: descriptions);
078: panel.add(descriptionPane, "0,4");
079: if (step == FIRST_STEP) {
080: setOptions(new String[] { CANCEL, NEXT });
081: } else if (step == MIDDLE_STEP) {
082: setOptions(new String[] { CANCEL, BACK, NEXT });
083: } else if (step == LAST_STEP) {
084: setOptions(new String[] { CANCEL, BACK, FINISH });
085: }
086: setMessage(panel);
087: JDialog dialog = createDialog(ContelligentClient
088: .getActiveFrame(), Resources
089: .getLocalString("description_wizard_title"));
090: dialog.setVisible(true);
091: if (getValue() == NEXT || getValue() == BACK
092: || getValue() == FINISH) {
093: descriptions = descriptionPane.getDescriptions();
094: if (getValue() == BACK)
095: return BACK_OPTION;
096: return NEXT_OPTION;
097: }
098: return CANCEL_OPTION;
099: }
100:
101: }
|