*** empty log message ***

This commit is contained in:
janna
2004-08-13 09:28:24 +00:00
parent f05b87e21d
commit 5eb8d24629

View File

@@ -14,11 +14,11 @@ import java.util.*;
public class GFEditor2 extends JFrame implements ActionListener, CaretListener, public class GFEditor2 extends JFrame implements ActionListener, CaretListener,
KeyListener, FocusListener { KeyListener, FocusListener {
private int[] sizes = {10,12,16,20,25,30,36}; private int[] sizes = {14,16,20,25,30,36};
private String[] envfonts; private String[] envfonts;
private Font font; private Font font;
Font[] fontObjs; Font[] fontObjs;
private static int DEFAULT_FONT_SIZE = 20; private static int DEFAULT_FONT_SIZE = 14;
private JComboBox fontList; private JComboBox fontList;
private JLabel fontLabel = new JLabel(" Font: "); private JLabel fontLabel = new JLabel(" Font: ");
private JComboBox sizeList; private JComboBox sizeList;
@@ -31,7 +31,7 @@ public class GFEditor2 extends JFrame implements ActionListener, CaretListener,
public MouseEvent m2; public MouseEvent m2;
public static String selectedText=""; public static String selectedText="";
public static boolean debug = true; public static boolean debug = false;
public static boolean debug3 = false; public static boolean debug3 = false;
public static boolean debug2 = false; public static boolean debug2 = false;
public static boolean selectionCheck = false; public static boolean selectionCheck = false;
@@ -101,8 +101,9 @@ public class GFEditor2 extends JFrame implements ActionListener, CaretListener,
private JButton alpha = new JButton("Alpha"); private JButton alpha = new JButton("Alpha");
private JButton random = new JButton("Random"); private JButton random = new JButton("Random");
private JButton undo = new JButton("Undo"); private JButton undo = new JButton("Undo");
private JPanel coverPanel = new JPanel();
private JPanel inputPanel = new JPanel(); private JPanel inputPanel = new JPanel();
private JPanel inputPanel2 = new JPanel(); private JPanel inputPanel2 = new JPanel();
private JPanel inputPanel3 = new JPanel(); private JPanel inputPanel3 = new JPanel();
private JButton ok = new JButton("OK"); private JButton ok = new JButton("OK");
@@ -268,7 +269,9 @@ public class GFEditor2 extends JFrame implements ActionListener, CaretListener,
modeMenu.add(rbMenuItemUnTyped); modeMenu.add(rbMenuItemUnTyped);
cp = getContentPane(); cp = getContentPane();
cp.setLayout(new BorderLayout()); JScrollPane cpPanelScroll = new JScrollPane(coverPanel);
cp.add(cpPanelScroll);
coverPanel.setLayout(new BorderLayout());
output.setToolTipText("Linearizations' display area"); output.setToolTipText("Linearizations' display area");
output.addCaretListener(this); output.addCaretListener(this);
output.setEditable(false); output.setEditable(false);
@@ -277,7 +280,7 @@ public class GFEditor2 extends JFrame implements ActionListener, CaretListener,
output.setSelectionColor(Color.green); output.setSelectionColor(Color.green);
// output.setSelectionColor(Color.white); // output.setSelectionColor(Color.white);
// output.setFont(new Font("Arial Unicode MS", Font.PLAIN, 17)); // output.setFont(new Font("Arial Unicode MS", Font.PLAIN, 17));
font = new Font(null, Font.PLAIN, 20); font = new Font(null, Font.BOLD, DEFAULT_FONT_SIZE);
output.setFont(font); output.setFont(font);
field.setFont(font); field.setFont(font);
field.setFocusable(true); field.setFocusable(true);
@@ -339,7 +342,10 @@ public class GFEditor2 extends JFrame implements ActionListener, CaretListener,
} }
fontList = new JComboBox(envfonts); fontList = new JComboBox(envfonts);
fontList.addActionListener(this); fontList.addActionListener(this);
fontList.setToolTipText("Changing font type");
sizeList = new JComboBox(); sizeList = new JComboBox();
sizeList.setToolTipText("Changing font size");
for (int i = 0; i<sizes.length; i++) for (int i = 0; i<sizes.length; i++)
{ {
sizeList.addItem(new Integer(sizes[i])); sizeList.addItem(new Integer(sizes[i]));
@@ -371,13 +377,15 @@ public class GFEditor2 extends JFrame implements ActionListener, CaretListener,
centerPanelDown.setLayout(new BorderLayout()); centerPanelDown.setLayout(new BorderLayout());
centerPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT, centerPanel = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
treePanel, centerPanelDown); treePanel, centerPanelDown);
centerPanel.setDividerSize(5);
centerPanel.setDividerLocation(350);
centerPanel.addKeyListener(tree); centerPanel.addKeyListener(tree);
centerPanel.setOneTouchExpandable(true); centerPanel.setOneTouchExpandable(true);
centerPanelDown.add(middlePanel, BorderLayout.NORTH); centerPanelDown.add(middlePanel, BorderLayout.NORTH);
centerPanelDown.add(outputPanelDown, BorderLayout.CENTER); centerPanelDown.add(outputPanelDown, BorderLayout.CENTER);
cp.add(centerPanel, BorderLayout.CENTER); coverPanel.add(centerPanel, BorderLayout.CENTER);
cp.add(upPanel, BorderLayout.NORTH); coverPanel.add(upPanel, BorderLayout.NORTH);
cp.add(downPanel, BorderLayout.SOUTH); coverPanel.add(downPanel, BorderLayout.SOUTH);
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
@@ -439,7 +447,7 @@ public class GFEditor2 extends JFrame implements ActionListener, CaretListener,
undo.setFocusable(false); undo.setFocusable(false);
output.addKeyListener(tree); output.addKeyListener(tree);
setSize(800,730); setSize(1040,800);
outputPanelUp.setPreferredSize(new Dimension(500,300)); outputPanelUp.setPreferredSize(new Dimension(500,300));
treePanel.setDividerLocation(0.3); treePanel.setDividerLocation(0.3);
nodeTable.put(new TreePath(DynamicTree2.rootNode.getPath()), new Integer(0)); nodeTable.put(new TreePath(DynamicTree2.rootNode.getPath()), new Integer(0));
@@ -573,8 +581,8 @@ public class GFEditor2 extends JFrame implements ActionListener, CaretListener,
// extProc.getInputStream()); // extProc.getInputStream());
fromProc = new BufferedReader (isr); fromProc = new BufferedReader (isr);
String defaultEncoding = isr.getEncoding(); String defaultEncoding = isr.getEncoding();
System.out.println("encoding "+defaultEncoding); if (debug) System.out.println("encoding "+defaultEncoding);
toProc = new BufferedWriter(new OutputStreamWriter(extProc.getOutputStream(),"UTF8")); toProc = new BufferedWriter(new OutputStreamWriter(extProc.getOutputStream(),"UTF8"));
/* try { /* try {
UIManager.setLookAndFeel( UIManager.setLookAndFeel(
@@ -756,7 +764,7 @@ System.out.println("encoding "+defaultEncoding);
languageGroup.add(rbMenuItem); languageGroup.add(rbMenuItem);
if ((result.substring(4)).equals(selectedMenuLanguage)) if ((result.substring(4)).equals(selectedMenuLanguage))
{ {
System.out.println("Selecting "+selectedMenuLanguage); if (debug) System.out.println("Selecting "+selectedMenuLanguage);
rbMenuItem.setSelected(true); rbMenuItem.setSelected(true);
} }
@@ -1005,7 +1013,7 @@ System.out.println("encoding "+defaultEncoding);
{ {
item.setFont(font); item.setFont(font);
String name = item.getClass().getName(); String name = item.getClass().getName();
System.out.println(name); if (debug) System.out.println(name);
} }
} }
} }
@@ -1016,12 +1024,16 @@ System.out.println("encoding "+defaultEncoding);
Object obj = ae.getSource(); Object obj = ae.getSource();
if ( obj == fontList ) { if ( obj == fontList ) {
font = new Font((String)fontList.getSelectedItem(), Font.PLAIN, ((Integer)sizeList.getSelectedItem()).intValue()); font = new Font((String)fontList.getSelectedItem(), Font.BOLD, ((Integer)sizeList.getSelectedItem()).intValue());
output.setFont(font); //output.setFont(font);
fontEveryWhere(font);
cbMenuItem.setFont(font);
rbMenuItem.setFont(font);
fileMenuItem.setFont(font);
} }
if ( obj == sizeList ) { if ( obj == sizeList ) {
font = new Font((String)fontList.getSelectedItem(), Font.PLAIN, ((Integer)sizeList.getSelectedItem()).intValue()); font = new Font((String)fontList.getSelectedItem(), Font.BOLD, ((Integer)sizeList.getSelectedItem()).intValue());
fontEveryWhere(font); fontEveryWhere(font);
cbMenuItem.setFont(font); cbMenuItem.setFont(font);
rbMenuItem.setFont(font); rbMenuItem.setFont(font);
@@ -1108,13 +1120,15 @@ System.out.println("encoding "+defaultEncoding);
if (group.getSelection().getActionCommand().equals("term")) { if (group.getSelection().getActionCommand().equals("term")) {
if (end !=-1) if (end !=-1)
if (abs) { if (abs) {
writeOutput(fileString+text.substring(0, end), file.getPath()); // writeOutput(fileString+text.substring(0, end), file.getPath());
writeOutput(text.substring(0, end), file.getPath());
abs=true; abs=true;
} }
else { else {
int i = linearization.indexOf('\n'); int i = linearization.indexOf('\n');
int j = linearization.indexOf("/lin"); int j = linearization.indexOf("/lin");
writeOutput(fileString+linearization.substring(i+1, j-1), file.getPath()); //writeOutput(fileString+linearization.substring(i+1, j-1), file.getPath());
writeOutput(linearization.substring(i+1, j-1), file.getPath());
} }
else else
JOptionPane.showMessageDialog(this, "No term to save"); JOptionPane.showMessageDialog(this, "No term to save");
@@ -1124,11 +1138,13 @@ System.out.println("encoding "+defaultEncoding);
// abstract syntax is shown: // abstract syntax is shown:
if (abs){ if (abs){
end = text.indexOf('\n', end); end = text.indexOf('\n', end);
writeOutput(fileString+text.substring(end), file.getPath()); //writeOutput(fileString+text.substring(end), file.getPath());
writeOutput(text.substring(end), file.getPath());
abs = true; abs = true;
} }
else else
writeOutput(fileString+text, file.getPath()); //writeOutput(fileString+text, file.getPath());
writeOutput(text, file.getPath());
} }
} }
@@ -1162,10 +1178,10 @@ System.out.println("encoding "+defaultEncoding);
e.hasMoreElements() ;) e.hasMoreElements() ;)
{ {
ab = (AbstractButton)e.nextElement(); ab = (AbstractButton)e.nextElement();
System.out.println("more to remove ! "+ab.getText()); if (debug) System.out.println("more to remove ! "+ab.getText());
languageGroup.remove(ab); languageGroup.remove(ab);
} }
System.out.println("languageGroupElement after import removal "+ if (debug) System.out.println("languageGroupElement after import removal "+
languageGroup.getButtonCount()); languageGroup.getButtonCount());
} }
submenu.removeAll(); submenu.removeAll();
@@ -1213,7 +1229,7 @@ System.out.println("encoding "+defaultEncoding);
submenu.removeAll(); submenu.removeAll();
while (1< menu.getItemCount()) while (1< menu.getItemCount())
menu.removeItemAt(1); menu.removeItemAt(1);
System.out.println("importing: "+ file.getPath().replace('\\','/')); if (debug) System.out.println("importing: "+ file.getPath().replace('\\','/'));
fileString =""; fileString ="";
send("i "+ file.getPath().replace('\\','/')); send("i "+ file.getPath().replace('\\','/'));
@@ -1248,10 +1264,10 @@ System.out.println("encoding "+defaultEncoding);
e.hasMoreElements() ;) e.hasMoreElements() ;)
{ {
ab = (AbstractButton)e.nextElement(); ab = (AbstractButton)e.nextElement();
System.out.println("more to remove ! "+ab.getText()); if (debug) System.out.println("more to remove ! "+ab.getText());
languageGroup.remove(ab); languageGroup.remove(ab);
} }
System.out.println("languageGroupElement after import removal "+ if (debug) System.out.println("languageGroupElement after import removal "+
languageGroup.getButtonCount()); languageGroup.getButtonCount());
} }
@@ -1273,7 +1289,7 @@ System.out.println("encoding "+defaultEncoding);
parseInput = s; parseInput = s;
//s = "gf "+s; This is for debugging, otherwise shift the comment to the next line. //s = "gf "+s; This is for debugging, otherwise shift the comment to the next line.
treeChanged = true; treeChanged = true;
System.out.println("sending: "+ s); if (debug) System.out.println("sending: "+ s);
send(s); send(s);
} }
} }
@@ -1296,10 +1312,10 @@ System.out.println("encoding "+defaultEncoding);
e.hasMoreElements() ;) e.hasMoreElements() ;)
{ {
ab = (AbstractButton)e.nextElement(); ab = (AbstractButton)e.nextElement();
System.out.println("more to remove ! "+ab.getText()); if (debug) System.out.println("more to remove ! "+ab.getText());
languageGroup.remove(ab); languageGroup.remove(ab);
} }
System.out.println("languageGroupElement after import removal "+ if (debug) System.out.println("languageGroupElement after import removal "+
languageGroup.getButtonCount()); languageGroup.getButtonCount());
} }
@@ -1355,7 +1371,7 @@ System.out.println("encoding "+defaultEncoding);
termInput = inputField.getText(); termInput = inputField.getText();
if (termInput.indexOf('/')==-1){ if (termInput.indexOf('/')==-1){
send("g "+termInput); send("g "+termInput);
System.out.println("sending term string"); if (debug) System.out.println("sending term string");
} }
else { else {
send("tfile "+termInput); send("tfile "+termInput);
@@ -1366,11 +1382,11 @@ System.out.println("encoding "+defaultEncoding);
parseInput = inputField.getText(); parseInput = inputField.getText();
if (parseInput.indexOf('/')==-1){ if (parseInput.indexOf('/')==-1){
send("p "+parseInput); send("p "+parseInput);
System.out.println("sending parse string: "+parseInput); if (debug) System.out.println("sending parse string: "+parseInput);
} }
else { else {
send("pfile "+parseInput); send("pfile "+parseInput);
System.out.println("sending file parse string: "+parseInput); if (debug) System.out.println("sending file parse string: "+parseInput);
} }
} }
dialog.hide(); dialog.hide();
@@ -1483,7 +1499,7 @@ System.out.println("encoding "+defaultEncoding);
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
String action = e.getActionCommand(); String action = e.getActionCommand();
if (action.equals("split") ) { if (action.equals("split") ) {
cp.remove(centerPanel); coverPanel.remove(centerPanel);
centerPanel2.add(middlePanelUp, BorderLayout.SOUTH); centerPanel2.add(middlePanelUp, BorderLayout.SOUTH);
if (((JCheckBoxMenuItem)viewMenu.getItem(0)).isSelected()) { if (((JCheckBoxMenuItem)viewMenu.getItem(0)).isSelected()) {
centerPanel2.add(treePanel, BorderLayout.CENTER); centerPanel2.add(treePanel, BorderLayout.CENTER);
@@ -1491,14 +1507,14 @@ System.out.println("encoding "+defaultEncoding);
else { else {
centerPanel2.add(outputPanelUp, BorderLayout.CENTER); centerPanel2.add(outputPanelUp, BorderLayout.CENTER);
} }
cp.add(centerPanel2, BorderLayout.CENTER); coverPanel.add(centerPanel2, BorderLayout.CENTER);
gui2.getContentPane().add(outputPanelDown); gui2.getContentPane().add(outputPanelDown);
gui2.setVisible(true); gui2.setVisible(true);
pack(); pack();
repaint(); repaint();
} }
if (action.equals("combine") ) { if (action.equals("combine") ) {
cp.remove(centerPanel2); coverPanel.remove(centerPanel2);
middlePanel.add(middlePanelUp, BorderLayout.NORTH); middlePanel.add(middlePanelUp, BorderLayout.NORTH);
if (((JCheckBoxMenuItem)viewMenu.getItem(0)).isSelected()) { gui2.setVisible(false); if (((JCheckBoxMenuItem)viewMenu.getItem(0)).isSelected()) { gui2.setVisible(false);
centerPanel.setLeftComponent(treePanel); centerPanel.setLeftComponent(treePanel);
@@ -1507,11 +1523,12 @@ System.out.println("encoding "+defaultEncoding);
centerPanel.setLeftComponent(outputPanelUp); centerPanel.setLeftComponent(outputPanelUp);
gui2.setVisible(false); gui2.setVisible(false);
} }
cp.add(centerPanel, BorderLayout.CENTER); coverPanel.add(centerPanel, BorderLayout.CENTER);
centerPanelDown.add(outputPanelDown, BorderLayout.CENTER); centerPanelDown.add(outputPanelDown, BorderLayout.CENTER);
pack(); pack();
repaint(); repaint();
} }
if (action.equals("showTree") ) { if (action.equals("showTree") ) {
if (!((JCheckBoxMenuItem)e.getSource()).isSelected()){ if (!((JCheckBoxMenuItem)e.getSource()).isSelected()){
if (debug) System.out.println("was selected"); if (debug) System.out.println("was selected");
@@ -1550,11 +1567,11 @@ System.out.println("encoding "+defaultEncoding);
if (debug) if (debug)
System.out.println("language option has changed "+((JCheckBoxMenuItem)e.getSource()).getText()); System.out.println("language option has changed "+((JCheckBoxMenuItem)e.getSource()).getText());
if (((JCheckBoxMenuItem)e.getSource()).isSelected()){ if (((JCheckBoxMenuItem)e.getSource()).isSelected()){
System.out.println("turning on"); if (debug) System.out.println("turning on");
send("on "+((JCheckBoxMenuItem)e.getSource()).getText()); send("on "+((JCheckBoxMenuItem)e.getSource()).getText());
} }
else{ else{
System.out.println("turning off"); if (debug) System.out.println("turning off");
send("off "+((JCheckBoxMenuItem)e.getSource()).getText()); send("off "+((JCheckBoxMenuItem)e.getSource()).getText());
} }
} }
@@ -1579,7 +1596,7 @@ System.out.println("encoding "+defaultEncoding);
else else
if (!action.equals("split")&&!action.equals("combine")&&!action.equals("showTree")) if (!action.equals("split")&&!action.equals("combine")&&!action.equals("showTree"))
{ {
System.out.println("sending "+action); if (debug) System.out.println("sending "+action);
send("ml " + action); send("ml " + action);
} }
} }
@@ -1599,7 +1616,7 @@ System.out.println("encoding "+defaultEncoding);
getLayeredPane().remove(field); getLayeredPane().remove(field);
treeChanged = true; treeChanged = true;
send("p "+field.getText()); send("p "+field.getText());
System.out.println("sending parse string: "+field.getText()); if (debug) System.out.println("sending parse string: "+field.getText());
repaint(); repaint();
} }
// Processing Escape: // Processing Escape: