Package jsynoptic.plugins.merge.ui

Source Code of jsynoptic.plugins.merge.ui.MCWizardPageName

/* ========================
* JSynoptic : a free Synoptic editor
* ========================
*
* Project Info:  http://jsynoptic.sourceforge.net/index.html
*
* This program is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* (C) Copyright 2001-2005, by :
*     Corporate:
*         EADS Astrium SAS
*         EADS CRC
*     Individual:
*         Claude Cazenave
*
* $Id: MCWizardPageName.java,v 1.3 2008/04/08 11:53:41 ogor Exp $
*
* Changes
* -------
* 25 february 2008 : Initial public release (CC);
*
*//* ========================
* JSynoptic : a free Synoptic editor
* ========================
*
* Project Info:  http://jsynoptic.sourceforge.net/index.html
*
* This program is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* (C) Copyright 2001-2005, by :
*     Corporate:
*         EADS Astrium SAS
*         EADS CRC
*     Individual:
*         Claude Cazenave
*
* $Id: MCWizardPageName.java,v 1.3 2008/04/08 11:53:41 ogor Exp $
*
* Changes
* -------
* 25 february 2008 : Initial public release (CC);
*
*/
package jsynoptic.plugins.merge.ui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.util.HashMap;
import java.util.Map;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import jsynoptic.plugins.merge.JSMergeCollectionPlugin;

import simtools.ui.MenuResourceBundle;
import simtools.ui.ResourceFinder;
import simtools.ui.WizardPage;

/**
* Type
* <br><b>Summary:</b><br>
* A wizard page dedicated to get collection name and the kind of merge, the kind of interpolation
*/
public class MCWizardPageName extends WizardPage{

  public static MenuResourceBundle resources = ResourceFinder.getMenu(MCWizardManager.class);

  JButton synchronousCollection, asynchronousCollection;
  JTextField collectionname;
 
  JPanel helpPanel;
  JLabel helpText;
  JLabel helpImage;
 
  boolean isAsynchronous;
 
  public MCWizardPageName(){
    super(resources.getString("pageNameTitle"), resources.getString("pageNameDescription"));
 
   
        // Help panel
        helpPanel = new JPanel(new GridLayout(1,2));
        helpPanel.setBorder(BorderFactory.createTitledBorder(resources.getString("syncPageNameHelpTitle")));
        helpText = new JLabel(resources.getString("syncPageNameHelpText"));
        helpText.setFont(new Font("Dialog", Font.PLAIN,12));
        helpImage = new JLabel(resources.getIcon("syncPageNameHelpImage"));
        helpPanel.add(helpText);
        helpPanel.add(helpImage);
       
       
        //
    JLabel cn= new JLabel(resources.getString("collectionName"));
    cn.setFont(new Font("Dialog", Font.PLAIN,12));
    add(cn, gbc);
    gbc.gridy++;
   
    collectionname = new JTextField(JSMergeCollectionPlugin.getADefaultName());
    add(collectionname, gbc);
    collectionname.addActionListener(this);
    gbc.gridy++;
   
    JLabel kindOfMerge= new JLabel(resources.getString("kindOfMerge"));
    kindOfMerge.setFont(new Font("Dialog", Font.PLAIN,12));
 
    add(kindOfMerge, gbc);
    gbc.gridy = gbc.gridy + 5;
   
    synchronousCollection = resources.getBox("synchronousMergeCollection", this);
    asynchronousCollection = resources.getBox("asynchronousMergeCollection", this);
   
    synchronousCollection.setBackground(Color.RED)// by default
    isAsynchronous=false;
   
   
    JPanel synchronousCollectionPanel = new JPanel(new BorderLayout());
    JLabel synchronousCollectionlabel= new JLabel(resources.getString("synchronousCollection"));
    synchronousCollectionlabel.setFont(new Font("Dialog", Font.PLAIN,12));
    synchronousCollectionPanel.add(synchronousCollection, BorderLayout.WEST);
    synchronousCollectionPanel.add(synchronousCollectionlabel, BorderLayout.CENTER);
   
    JPanel asynchronousCollectionPanel = new JPanel(new BorderLayout());
    JLabel asynchronousCollectionlabel= new JLabel(resources.getString("asynchronousCollection"));
    asynchronousCollectionlabel.setFont(new Font("Dialog", Font.PLAIN,12));
    asynchronousCollectionPanel.add(asynchronousCollection, BorderLayout.WEST);
    asynchronousCollectionPanel.add(asynchronousCollectionlabel, BorderLayout.CENTER);
 
 
    add(synchronousCollectionPanel, gbc);
        gbc.gridy++;
        add(asynchronousCollectionPanel, gbc);
   
    gbc.insets = new Insets(20, 5, 5, 150);
    gbc.gridy++;
    add(helpPanel, gbc);  
  }

  public String getProblem(){
    if (collectionname.getText().equals(""))
      return resources.getString("collectionNameError");
   
    return  null;
  }


  public void actionPerformed(ActionEvent e){
    Object source = e.getSource();
    if (source==synchronousCollection){
      synchronousCollection.setBackground(Color.RED);
      asynchronousCollection.setBackground(Color.WHITE);
      isAsynchronous = false;
     
      helpPanel.setBorder(BorderFactory.createTitledBorder(resources.getString("syncPageNameHelpTitle")));
      helpText.setText(resources.getString("syncPageNameHelpText"));
      helpImage.setIcon(resources.getIcon("syncPageNameHelpImage"));
     
    }else if (source==asynchronousCollection){
      asynchronousCollection.setBackground(Color.RED);
      synchronousCollection.setBackground(Color.WHITE);
      isAsynchronous = true;
     
      helpPanel.setBorder(BorderFactory.createTitledBorder(resources.getString("asyncPageNameHelpTitle")));
      helpText.setText(resources.getString("asyncPageNameHelpText"));
      helpImage.setIcon(resources.getIcon("asyncPageNameHelpImage"));
     
    }else {
      super.actionPerformed(e);
    }
  }

  
  public Map getInformation(){
    HashMap ret = new HashMap();
    ret.put(MCWizardManager.COLLECTION_NAME, collectionname.getText());
    ret.put(MCWizardManager.IS_ASYNCHRONOUS, new Boolean(isAsynchronous));
   
    return ret;
  }
}
TOP

Related Classes of jsynoptic.plugins.merge.ui.MCWizardPageName

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.