Package gui

Source Code of gui.TwoSetItemSelectionFrame

package gui;


import java.awt.*;




import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;


import javax.swing.JFrame;


import javax.swing.JPanel;




import javax.swing.ImageIcon;
import javax.swing.JButton;


import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Component;


import helper.Helper;

import guicomponents.ComputeReportAndReportOptionsPanel;
import guicomponents.ReturnValuesPanel;
import guicomponents.TwoSetSelectionPanel;
import dao.RObject;
import dao.RObjectViewportTable;
import dao.TableSweaveTag;



public class TwoSetItemSelectionFrame extends JFrame {
 
    /**
   *
   */
  private static final long serialVersionUID = 1L;
  /**
     * Class variables
     *
     */
    private JButton cancel;
    private JButton ok;
  
    private GridBagLayout gbl;
   
    private TwoSetSelectionPanel tsSelPanel;
    private ReturnValuesPanel rvPanel;
    private ComputeReportAndReportOptionsPanel compRepAndRepOptPanel;


    public TwoSetItemSelectionFrame() {
      super.setTitle("Two-Set-MV-G Test");
        this.setIconImage(
                new ImageIcon("./images/i16x16/isop_favicon.png").getImage());
      
      tsSelPanel = new TwoSetSelectionPanel();
      rvPanel = new ReturnValuesPanel();
      compRepAndRepOptPanel = new ComputeReportAndReportOptionsPanel("isop2set");
   
        // leftList.setFixedCellHeight(10);
        // leftList.setFixedCellWidth(10);

        cancel = new JButton("Cancel");
        ok = new JButton("OK");
       
/*       set Tooltips for each component
        leftLabel.setToolTipText("This is only a test.");
        rightLabel.setToolTipText("This is only a test.");
        fuellLabel1.setToolTipText("This is only a test.");
      fuellLabel2.setToolTipText("This is only a test.");
      fuellLabel3.setToolTipText("This is only a test.");
      fuellLabel4.setToolTipText("This is only a test.");
      toRight.setToolTipText("This is only a test.");
        toLeft.setToolTipText("This is only a test.");
        onlyCompute.setToolTipText("This is only a test.");
        computeAndReport.setToolTipText("This is only a test.");
        onlyReport.setToolTipText("This is only a test.");
        cancel.setToolTipText("This is only a test.");
        rightList.setToolTipText("This is only a test.");
        leftList.setToolTipText("This is only a testtest.");
        sep.setToolTipText("This is only a test.");
        chkLatex.setToolTipText("This is only a test.");
        chkVerbose.setToolTipText("Das ist Verbose");
        chk_n.setToolTipText("This is only a test.");
        chk_p.setToolTipText("This is only a test.");
        chk_g.setToolTipText("This is only a test.");
        chk_s.setToolTipText("This is only a test.");
        chk_ubas.setToolTipText("This is only a test.");
        chk_i.setToolTipText("This is only a test.");
        chk_c.setToolTipText("This is only a test.");
        chk_nsq.setToolTipText("This is only a test.");
        chk_z.setToolTipText("This is only a test."); */
      
        gbl = new GridBagLayout();
        this.setLayout(gbl);
       
                                // Z  Z  Z  Z  F
                                // e  e  e  e  ü
                                // l  l  l  l  l
                                // l  l  l  l  l
                                // s  z  w  h  v
                                // p  e  e  o  e
                                // a  i  i  e  r
                                // l  l  t  h  h
                                // t  e  e  e  a
                                // e           l
                                // t
                                // e
                                // n
                                                                                                                                                
                                // g  g  g  g  f                  i  i  i  a                    w  w 
                                // r  r  r  r  i                  p  p  n  n                    e  e
                                // i  i  i  i  l                  a  a  s  c                    i  i
                                // d  d  d  d  l                  d  d  e  h                    g  g
                                // x  y  w  h                       x  y  t  o                    h  h
                                //       i  e                                 s  r                    t  t
                                //       d  i                                                    x  y
                                //       t  g
                                //       h  h
                                //          t                     
   
        addComponent(this, gbl, tsSelPanel,             0, 0, 4, 4, GridBagConstraints.HORIZONTAL,   0, 0, GridBagConstraints.CENTER, 0,0);               
        addComponent(this, gbl, rvPanel,                  0, 4, 4, 3, GridBagConstraints.HORIZONTAL,   0, 0, GridBagConstraints.LINE_START, 0,0);               
       
        addComponent(this, gbl, compRepAndRepOptPanel, 0,10, 3, 6, GridBagConstraints.HORIZONTAL,   0, 0, GridBagConstraints.CENTER, 0,0);               
       
       
    
        addComponent(this, gbl, cancel,             3, 16,1, 1, GridBagConstraints.VERTICAL,    0, 0, GridBagConstraints.EAST, 0, 0);
        addComponent(this, gbl, ok,               0, 16,1, 1, GridBagConstraints.VERTICAL, 0, 0, GridBagConstraints.CENTER, 0, 0);

        cancel.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent event) {
                btncancelClicked();
            }
        });
       
        ok.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent event) {
                btnOkClicked();
            }
        });
       
    }
   
 
 
    private void btncancelClicked() {
        this.setVisible(false);   
    }

    private void btnOkClicked() {

        String jRightListLine = "";
        String dataFileName ="";
        String leftSideOfSeperator = "";
        String rightSideOfSeperator = "";



      if ( rvPanel.getReturnValuesAlaZdenko().equals("c( )") ){
        Helper.ok("Error - No result value is selected.");
        return;       
      }
     
     
      if (tsSelPanel.tsiSelPanel.rightList.getModel().getSize()>0){
        ;
      }else{
        Helper.ok("Error - No Items are selected or uncomplete Selection.");
        return;
      }
       
     
      if (tsSelPanel.tsiSelPanel.rightList.getModel().getElementAt(tsSelPanel.tsiSelPanel.rightList.getModel().getSize() - 1).toString().indexOf(
        ";") > 0){
        ;
     
    else{
      Helper.ok("Error - No Items are selected or uncomplete Selection.");
      return;         
    }
   
   
        for (int i = 0; i < tsSelPanel.tsiSelPanel.rightList.getModel().getSize(); i++) {       
            jRightListLine = tsSelPanel.tsiSelPanel.rightList.getModel().getElementAt(i).toString();
            dataFileName  = jRightListLine.substring(0 , jRightListLine.indexOf(":"));
            leftSideOfSeperator = jRightListLine.substring(jRightListLine.indexOf(":")+2 , jRightListLine.indexOf(";"));
            leftSideOfSeperator = leftSideOfSeperator.replace('V', ' ');
            rightSideOfSeperator = jRightListLine.substring(jRightListLine.indexOf(";") + 2 , jRightListLine.length())
            rightSideOfSeperator = rightSideOfSeperator.replace('V', ' ');
                       
//            Helper.ok("dataFileName istgleich" + dataFileName );       
//            Helper.ok("leftSideOfSeperator istgleich" + leftSideOfSeperator );
//            Helper.ok("rightSideOfSeperator istgleich" + rightSideOfSeperator );       
  
            String rVarName = dao.Controller.fitRVarName("isop2set");
            String command = "" + "isop.calc2set(raw = "+dataFileName +", set1=c("+leftSideOfSeperator+"), set2=c("+rightSideOfSeperator+")"+")[" + rvPanel.getReturnIndices() +"]" ;
            Helper.ok(command);
            RObject isop2set = new RObject(rVarName, command);
           
            if (compRepAndRepOptPanel.getTablePanel().isSelected()) {
             
                RObjectViewportTable isop2settab = new RObjectViewportTable(compRepAndRepOptPanel.getTablePanel().getLabel(),
                    isop2set);
               
                TableSweaveTag tabswvtag;
          if (compRepAndRepOptPanel.isInReport()) {
            tabswvtag = new TableSweaveTag(isop2settab);
           
            tabswvtag.setLabel(compRepAndRepOptPanel.getTablePanel().getLabel());
            tabswvtag.setCaption(compRepAndRepOptPanel.getTablePanel().getCaption());
            tabswvtag.setDigits(compRepAndRepOptPanel.getTablePanel().getDigits());
          } else tabswvtag = null;
                 
                dao.Controller.addTable(isop2settab, compRepAndRepOptPanel.isEvaled(), compRepAndRepOptPanel.isEvaled(),
                    tabswvtag);
            }
                   
      } //endOfFor-schleife
        this.setVisible(false)
     
    }
   
   private void addComponent( Container cont,
           GridBagLayout gbl,
           Component c,
           int gridx, int gridy,
           int gridwidth, int gridheight,
           int fill,
           int ipadx, int ipady,
     /*      Insets insets, */
           int anchor,
           double weightx, double weighty )
  {
    GridBagConstraints gbc = new GridBagConstraints()
    gbc.gridx = gridx; gbc.gridy = gridy;          //Spalte/Reihe mit ganz links = 0 und ganz oben = 0
    gbc.gridwidth = gridwidth; gbc.gridheight = gridheight; //Anzahl Spalten/Reihen, die Komponente nutzt - DEFAULT = 1;
    gbc.fill = fill;                    //entscheidet howto resize the component, wenn sie vergrößert wird = NONE , HORIZONTAL, VERTICAL, BOTH
    gbc.ipadx = ipadx; gbc.ipady = ipady;          // interne Füllung (howmuch to add to the minimum weight/height of the component
//    gbc.insets = insets;                  // externe Füllung (howmuch is the minimum space between component and the edges of its display area)
    gbc.anchor = anchor;                  // used if component kleiner als seine display area (verschiedene Konstanten)
    gbc.weightx = weightx; gbc.weighty = weighty;      // determines howto distribute space among columns and rows
    gbl.setConstraints( c, gbc );
    cont.add( c );
  }

}

//package gui;
//
//
//import java.awt.*;
//
//
//import java.awt.event.ActionListener;
//import java.awt.event.ActionEvent;
//
//import javax.swing.JFrame;
//
//import javax.swing.JPanel;
//
//
//import javax.swing.ImageIcon;
//import javax.swing.JButton;
//
//
//
//
//import java.awt.GridBagLayout;
//import java.awt.GridBagConstraints;
//import java.awt.Component;
//import java.util.Enumeration;
//
//
//
//import guicomponents.ComputeReportAndReportOptionsPanel;
//
//import guicomponents.TwoSetSelectionPanel;
//
//
//import guicomponents.ReturnValuesPanel;
//
//import dao.RObject;
//
//import dao.RObjectViewportTable;
//import dao.TableSweaveTag;
//import datastructures.ItemSet;
//
//
//
//
//
//public class TwoSetItemSelectionFrame extends JFrame {
// 
//    /**
//   *
//   */
//  private static final long serialVersionUID = 1L;
//
//  /**
//     * Class variables
//     *
//     */
//
//
// 
//    private JButton cancel;
//    private JButton ok;
//  
//    private GridBagLayout gbl;
//   
//    private TwoSetSelectionPanel tsSelPanel;
//    private ReturnValuesPanel rvPanel;
//
//    private ComputeReportAndReportOptionsPanel compRepAndRepOptPanel;
//  
//   
//
//
//    public TwoSetItemSelectionFrame() {
//        super("Test item selection");
//        this.setIconImage(
//                new ImageIcon("./images/i16x16/isop_favicon.png").getImage());
//       
//        JPanel panel = new JPanel();
//
//        this.add(panel);
//        this.pack();
//        initComponents();
//    }
// 
//    void initComponents() {
//
//      tsSelPanel = new TwoSetSelectionPanel();
//      rvPanel = new ReturnValuesPanel();
//      compRepAndRepOptPanel = new ComputeReportAndReportOptionsPanel("isop1set");
//   
//        // leftList.setFixedCellHeight(10);
//        // leftList.setFixedCellWidth(10);
//
//        cancel = new JButton("Cancel");
//        ok = new JButton("OK");
//       
//
//       
//       
//        /* set Tooltips for each component
//         leftLabel.setToolTipText("This is only a test.");
//         rightLabel.setToolTipText("This is only a test.");
//         fuellLabel1.setToolTipText("This is only a test.");
//         fuellLabel2.setToolTipText("This is only a test.");
//         fuellLabel3.setToolTipText("This is only a test.");
//         fuellLabel4.setToolTipText("This is only a test.");
//         toRight.setToolTipText("This is only a test.");
//         toLeft.setToolTipText("This is only a test.");
//         onlyCompute.setToolTipText("This is only a test.");
//         computeAndReport.setToolTipText("This is only a test.");
//         onlyReport.setToolTipText("This is only a test.");
//         cancel.setToolTipText("This is only a test.");
//         rightList.setToolTipText("This is only a test.");
//         leftList.setToolTipText("This is only a testtest.");
//         sep.setToolTipText("This is only a test.");
//         chkLatex.setToolTipText("This is only a test.");
//         chkVerbose.setToolTipText("Das ist Verbose");
//         chk_n.setToolTipText("This is only a test.");
//         chk_p.setToolTipText("This is only a test.");
//         chk_g.setToolTipText("This is only a test.");
//         chk_s.setToolTipText("This is only a test.");
//         chk_ubas.setToolTipText("This is only a test.");
//         chk_i.setToolTipText("This is only a test.");
//         chk_c.setToolTipText("This is only a test.");
//         chk_nsq.setToolTipText("This is only a test.");
//         chk_z.setToolTipText("This is only a test."); */
//      
//        gbl = new GridBagLayout();
//        this.setLayout(gbl);
//       
//                              // Z  Z  Z  Z  F
//                              // e  e  e  e  ü
//                              // l  l  l  l  l
//                              // l  l  l  l  l
//                              // s  z  w  h  v
//                              // p  e  e  o  e
//                              // a  i  i  e  r
//                              // l  l  t  h  h
//                              // t  e  e  e  a
//                              // e           l
//                              // t
//                              // e
//                              // n
//                                                                                                                                              
//                              // g  g  g  g  f                  i  i  i  a                    w  w 
//                              // r  r  r  r  i                  p  p  n  n                    e  e
//                              // i  i  i  i  l                  a  a  s  c                    i  i
//                              // d  d  d  d  l                  d  d  e  h                    g  g
//                              // x  y  w  h                       x  y  t  o                    h  h
//                              //       i  e                                 s  r                    t  t
//                              //       d  i                                                    x  y
//                              //       t  g
//                              //       h  h
//                              //          t                     
//
//        addComponent(this, gbl, tsSelPanel,             0, 0, 4, 4, GridBagConstraints.HORIZONTAL,   0, 0, GridBagConstraints.CENTER, 0,0);               
//        addComponent(this, gbl, rvPanel,                  0, 4, 4, 3, GridBagConstraints.HORIZONTAL,   0, 0, GridBagConstraints.LINE_START, 0,0);               
//       
//        addComponent(this, gbl, compRepAndRepOptPanel, 0,10, 3, 6, GridBagConstraints.HORIZONTAL,   0, 0, GridBagConstraints.CENTER, 0,0);               
//       
//       
//    
//        addComponent(this, gbl, cancel,             3, 26,1, 1, GridBagConstraints.VERTICAL,    0, 0, GridBagConstraints.EAST, 0, 0);
//        addComponent(this, gbl, ok,               0, 26,1, 1, GridBagConstraints.VERTICAL, 0, 0, GridBagConstraints.CENTER, 0, 0);
//
//       
//                 
//
//        super.setTitle("Two-Set-MV-G Test");
//           
//
//
//       
//       
//       
//        cancel.addActionListener(new ActionListener() {
//            public void actionPerformed(ActionEvent event) {
//                btncancelClicked();
//            }
//        });
//       
//        ok.addActionListener(new ActionListener() {
//            public void actionPerformed(ActionEvent event) {
//                btnOkClicked();
//            }
//        });
//       
//    }
// 
//
//
//    /**
//     * @param computeEnabled
//     * @param reportEnabled
//     */
//   
//    private void btncancelClicked() {
//        this.setVisible(false);   
//    }
//
//    private void btnOkClicked() {
////        for (Enumeration<ItemSet> eis = tsSelPanel.getItemSets(); eis.hasMoreElements(); ) {
////          ItemSet is = eis.nextElement();
////         
////          String rVarName = dao.Controller.fitRVarName("isop2set");
////               
////            RObject isop1set = new RObject(rVarName, "isop.calc2set(" + is.getRString() +" , "+ rvPanel.getReturnValues()+" , verbose=FALSE"+ ")");
////
////            if (compRepAndRepOptPanel.getTablePanel().isSelected()) {
////             
////                RObjectViewportTable isop1settab = new RObjectViewportTable(compRepAndRepOptPanel.getTablePanel().getLabel(),
////                    isop1set);
////               
////                TableSweaveTag tabswvtag;
////        if (compRepAndRepOptPanel.isInReport()) {
////          tabswvtag = new TableSweaveTag(isop1settab);
////         
////          tabswvtag.setCaption(compRepAndRepOptPanel.getTablePanel().getCaption());
////        } else tabswvtag = null;
////                 
////                dao.Controller.addTable(isop1settab, compRepAndRepOptPanel.isEvaled(), compRepAndRepOptPanel.isEvaled(),
////                    tabswvtag);
////            }
////           
////      }
//     
//        this.setVisible(false); 
//    }
//   
//    private void addComponent(Container cont,
//            GridBagLayout gbl,
//            Component c,
//            int gridx, int gridy,
//            int gridwidth, int gridheight,
//            int fill,
//            int ipadx, int ipady,
//
//            /* Insets insets, */
//            int anchor,
//            double weightx, double weighty) {
//        GridBagConstraints gbc = new GridBagConstraints(); 
//
//        gbc.gridx = gridx;
//        gbc.gridy = gridy; // Spalte/Reihe mit ganz links = 0 und ganz oben = 0
//        gbc.gridwidth = gridwidth;
//        gbc.gridheight = gridheight; // Anzahl Spalten/Reihen, die Komponente nutzt - DEFAULT = 1;
//        gbc.fill = fill; // entscheidet howto resize the component, wenn sie vergrößert wird = NONE , HORIZONTAL, VERTICAL, BOTH
//        gbc.ipadx = ipadx;
//        gbc.ipady = ipady; // interne Füllung (howmuch to add to the minimum weight/height of the component
//        // gbc.insets = insets;                  // externe Füllung (howmuch is the minimum space between component and the edges of its display area)
//        gbc.anchor = anchor; // used if component kleiner als seine display area (verschiedene Konstanten)
//        gbc.weightx = weightx;
//        gbc.weighty = weighty; // determines howto distribute space among columns and rows
//        gbl.setConstraints(c, gbc);
//        cont.add(c);
//    }  
//}
//
TOP

Related Classes of gui.TwoSetItemSelectionFrame

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.