Blame view

src/osp/ui/OSPE_QuickSplitSlitsPanel.java 2.5 KB
fe0fb87e   Elodie Bourrec   First push to cre...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
package osp.ui;


import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;

import osp.Mask;

public class OSPE_QuickSplitSlitsPanel extends JDialog
{
  private static final long serialVersionUID = 1L;

  BorderLayout borderLayout = new BorderLayout();
  JComboBox<String> startSlit = new JComboBox<String>();
  JComboBox<String> stopSlit = new JComboBox<String>();
  
  JButton jButtonOK = new JButton("OK");
  JButton jButtonCancel = new JButton("Cancel");
  
  Mask currentMask;
  
  public OSPE_QuickSplitSlitsPanel(Mask msk, int n, int m)
  {
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    setAlwaysOnTop(true);
    
    currentMask = msk;
    
    for (int i=0 ; i<Mask._NBRSLITS_; i++)
    {
      String texte = new String();
      texte = ""+(i+1);
      startSlit.addItem(texte);
      stopSlit.addItem(texte);
    }
    startSlit.setSelectedIndex(n);
    stopSlit.setSelectedIndex(m);
    
    JPanel firstPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    firstPanel.add(new JLabel("Split Slits from"));
    firstPanel.add(startSlit);
    firstPanel.add(new JLabel("to"));
    firstPanel.add(stopSlit);
    this.getContentPane().add(firstPanel, BorderLayout.NORTH);
    
    jButtonOK.addActionListener( new ActionOK() );
    jButtonCancel.addActionListener( new ActionCancel() );
    
    JPanel thirdPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    thirdPanel.add(jButtonOK);
    thirdPanel.add(jButtonCancel);
    this.getContentPane().add(thirdPanel, BorderLayout.SOUTH);
    
    pack();
    setVisible(true);
  }
  
  class ActionOK  extends AbstractAction
  {
    private static final long serialVersionUID = 1L;

    @Override
	public void actionPerformed(ActionEvent e)
    {
      currentMask.getHistory().addEntry("Split slits");
      currentMask.getHistory().addAction( "joinSlits " + startSlit.getSelectedIndex() + " " + stopSlit.getSelectedIndex(), null );
      
      currentMask.splitSlits(startSlit.getSelectedIndex(),
                            stopSlit.getSelectedIndex());
      dispose();
    }
  }

  class ActionCancel  extends AbstractAction
  {
    private static final long serialVersionUID = 1L;

    @Override
	public void actionPerformed(ActionEvent e)
    {
      dispose();
    }
  }
}