source: trunk/greenstone3-extensions/vishnu/src/vishnu/builder/IndexerGUI.java@ 8290

Last change on this file since 8290 was 8290, checked in by kjdon, 20 years ago

some mods, not sure what they are. will tidy them up soon, but didn't want to leave the package uncompilable so committing this now

  • Property svn:keywords set to Author Date Id Revision
File size: 4.6 KB
Line 
1package vishnu.builder;
2
3import java.awt.event.*;
4import java.awt.*;
5import javax.swing.*;
6import javax.swing.SpringLayout;
7import java.io.File;
8import vishnu.util.SpringUtilities;
9
10public class IndexerGUI {
11 public final static boolean RIGHT_TO_LEFT = false;
12 public Toolkit toolkit = Toolkit.getDefaultToolkit();
13 private static JTextField[] textFields;
14 private static JTextArea ja;
15
16 public static void addComponentsToPane(Container pane)
17 {
18 //String[] labels = {"Top directory of Vishnu: ", "Name of Collection: ", "Directory of Collection: ", "Source directory: ", "Indexer (\"mg\" or \"luc\"): ", "Collection Description: "};
19 String [] labels = {"Collections directory: ", "Collection id (directory name): ", "Collection name: ","Collection description: ", "Indexer (\"mg\" or \"luc\"): "};
20 int numPairs = labels.length;
21 textFields = new JTextField[numPairs];
22
23 pane.setLayout(new BoxLayout(pane,BoxLayout.Y_AXIS));
24
25 JPanel p = new JPanel(new SpringLayout());
26
27 for (int i = 0; i < numPairs; i++) {
28 JLabel l = new JLabel(labels[i], JLabel.TRAILING);
29 p.add(l);
30 textFields[i] = new JTextField(30);
31 l.setLabelFor(textFields[i]);
32 p.add(textFields[i]);
33 }
34
35 SpringUtilities.makeCompactGrid(p,numPairs, 2, 6, 6, //initX, initY
36 6, 6); //xPad, yPad
37
38 pane.add(p);
39
40 JPanel butPan = new JPanel();
41 butPan.setLayout(new BoxLayout(butPan,BoxLayout.X_AXIS));
42
43 Dimension minSize = new Dimension(10, 50);
44 Dimension prefSize = new Dimension(10, 50);
45 Dimension maxSize = new Dimension(Short.MAX_VALUE, 50);
46 butPan.add(new Box.Filler(minSize, prefSize, maxSize));
47
48 JButton button = new JButton(" Start indexing ");
49 button.setBorder(BorderFactory.createBevelBorder(0));
50 button.addActionListener(new ActionListener(){
51 public void actionPerformed(ActionEvent e){
52 build();
53 }
54 });
55 butPan.add(button);
56
57 butPan.add(new Box.Filler(minSize, prefSize, maxSize));
58
59// button = new JButton(" Options ");
60// button.setBorder(BorderFactory.createBevelBorder(0));
61// butPan.add(button);
62
63 butPan.add(new Box.Filler(minSize, prefSize, maxSize));
64
65// button = new JButton(" Help ");
66// button.setBorder(BorderFactory.createBevelBorder(0));
67// butPan.add(button);
68
69 pane.add(butPan);
70
71 butPan.add(new Box.Filler(minSize, prefSize, maxSize));
72
73 ja = new JTextArea(5,5);
74 JScrollPane scrollingArea = new JScrollPane(ja);
75 scrollingArea.setBorder(BorderFactory.createBevelBorder(1));
76 pane.add(scrollingArea);
77 }
78
79 private static void build()
80 {
81 // get data
82 //String source = textFields[3].getText();
83 //String dir = textFields[2].getText();
84 //String name = textFields[1].getText();
85 //String home = textFields[0].getText();
86 String colls_home = textFields[0].getText();
87 String coll_id = textFields[1].getText();
88 String coll_name = textFields[2].getText();
89 String coll_desc = textFields[3].getText();
90 String indexer = textFields[4].getText();
91 String coll_home = colls_home;
92 if (!coll_home.endsWith(File.separator)) {
93 coll_home += File.separator;
94 }
95 coll_home += coll_id + File.separator;
96 //String del = "";
97 //String description = textFields[5].getText();
98 //String output = "Launching Collection Builder with \n source = " + source + "\n dir = " + dir + "\n name = " + name + "\n home = " + home + "\n indexer = " + indexer + "\n description = " + description;
99 String output = "Launching Collection Builder with \n collections home = "+colls_home + "\n collection id = "+coll_name+"\n indexer = "+indexer;
100 ja.setText(output);
101
102 //CollectionBuilder builder = new CollectionBuilder(dir,name,home,indexer);
103 CollectionBuilder builder = new CollectionBuilder(coll_home, coll_id, coll_name, coll_desc, indexer, false); // no views for now - change this
104 output += "\n Indexing Finished";
105 ja.setText(output);
106 }
107
108 private static void createAndShowGUI() {
109 JFrame.setDefaultLookAndFeelDecorated(true);
110 JFrame frame = new JFrame("Indexing Tool");
111 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
112 addComponentsToPane(frame.getContentPane());
113
114 frame.pack();
115
116 Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
117 int w = frame.getSize().width;
118 int h = frame.getSize().height;
119 int x = (dim.width-w)/2;
120 int y = (dim.height-h)/2;
121 frame.setLocation(x,y);
122
123 frame.setVisible(true);
124 }
125
126 public static void main(String[] args) {
127 //javax.swing.SwingUtilities.invokeLater(new Runnable() {
128 // public void run() {
129 createAndShowGUI();
130 // }
131 //});
132 }
133}
Note: See TracBrowser for help on using the repository browser.