mirror of
https://github.com/nasa/trick.git
synced 2025-02-26 02:58:11 +00:00
Trickify GUI
This commit is contained in:
parent
2e46a84495
commit
e30ebf80ce
@ -32,7 +32,7 @@ GetOptions
|
||||
"no_clean_obj_list" => \$no_clean_obj, # Don't rebuild trickify_obj_list
|
||||
"no_source" => \$no_source_build, # Arg to disable building source files
|
||||
"source_make=s" => \$source_make_call, # Make call to build object files
|
||||
"source_args=s" => \$source_make_args, # Default make call args to build object files
|
||||
"source_make_args=s" => \$source_make_args, # Default make call args to build object files
|
||||
"trickify_args=s" => \$trickify_make_args, # Trickify make args
|
||||
"trickify_make=s" => \$trickify_make_path, # Set trickify make path
|
||||
"n=s" => \$name, # Set the library name
|
||||
|
168
trick_source/java/src/main/java/trick/trickify/DirSelect.java
Normal file
168
trick_source/java/src/main/java/trick/trickify/DirSelect.java
Normal file
@ -0,0 +1,168 @@
|
||||
package trick.trickify;
|
||||
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import javax.swing.*;
|
||||
|
||||
public class DirSelect
|
||||
{
|
||||
private int pos_x = 0;
|
||||
private int pos_y = 0;
|
||||
|
||||
private JLabel label;
|
||||
private int label_pos_x = pos_x;
|
||||
private int label_pos_y = pos_y;
|
||||
private int label_width = 200;
|
||||
private int label_height = 20;
|
||||
|
||||
private JTextField textfield;
|
||||
private int textfield_pos_x = pos_x;
|
||||
private int textfield_pos_y = pos_y + label_height;
|
||||
private int textfield_width = 800;
|
||||
private int textfield_height = 20;
|
||||
|
||||
private JButton button;
|
||||
private int button_pos_x = textfield_pos_x + textfield_width;
|
||||
private int button_pos_y = textfield_pos_y;
|
||||
private int button_width = 100;
|
||||
private int button_height = 20;
|
||||
|
||||
private JFileChooser browser;
|
||||
|
||||
private boolean multiDir = false;
|
||||
|
||||
private void updatePosition()
|
||||
{
|
||||
label_pos_x = pos_x;
|
||||
label_pos_y = pos_y;
|
||||
|
||||
textfield_pos_x = pos_x;
|
||||
textfield_pos_y = pos_y + label_height;
|
||||
|
||||
button_pos_x = textfield_pos_x + textfield_width;
|
||||
button_pos_y = textfield_pos_y;
|
||||
}
|
||||
|
||||
private void redraw()
|
||||
{
|
||||
label.setBounds(label_pos_x, label_pos_y, label_width, label_height);
|
||||
textfield.setBounds(textfield_pos_x, textfield_pos_y, textfield_width, textfield_height);
|
||||
button.setBounds(button_pos_x, button_pos_y, button_width, button_height);
|
||||
}
|
||||
|
||||
public void setPosition(int x, int y)
|
||||
{
|
||||
pos_x = x;
|
||||
pos_y = y;
|
||||
|
||||
updatePosition();
|
||||
redraw();
|
||||
}
|
||||
|
||||
public void setLabel(String text)
|
||||
{
|
||||
label.setText(text);
|
||||
}
|
||||
|
||||
public void setToolTipText(String tip)
|
||||
{
|
||||
textfield.setToolTipText(tip);
|
||||
}
|
||||
|
||||
public void setButtonText(String text)
|
||||
{
|
||||
button.setText(text);
|
||||
}
|
||||
|
||||
public void addToPanel(JPanel panel)
|
||||
{
|
||||
panel.add(label);
|
||||
panel.add(textfield);
|
||||
panel.add(button);
|
||||
}
|
||||
|
||||
public void addToFrame(JFrame frame)
|
||||
{
|
||||
frame.add(label);
|
||||
frame.add(textfield);
|
||||
frame.add(button);
|
||||
}
|
||||
|
||||
public void allowMultiple(boolean b)
|
||||
{
|
||||
browser.setMultiSelectionEnabled(b);
|
||||
multiDir = b;
|
||||
}
|
||||
|
||||
public void selectFile(boolean b)
|
||||
{
|
||||
if(b)
|
||||
{
|
||||
browser.setFileSelectionMode(JFileChooser.FILES_ONLY);
|
||||
}
|
||||
else
|
||||
{
|
||||
browser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
||||
}
|
||||
}
|
||||
|
||||
public String getDirs()
|
||||
{
|
||||
return textfield.getText();
|
||||
}
|
||||
|
||||
void setDirs(String txt)
|
||||
{
|
||||
textfield.setText(txt);
|
||||
}
|
||||
|
||||
public DirSelect()
|
||||
{
|
||||
label = new JLabel();
|
||||
label_width = 200;
|
||||
label_height = 20;
|
||||
|
||||
textfield = new JTextField();
|
||||
textfield_width = 800;
|
||||
textfield_height = 20;
|
||||
|
||||
button = new JButton();
|
||||
button_width = 100;
|
||||
button_height = 20;
|
||||
|
||||
browser = new JFileChooser();
|
||||
browser.setCurrentDirectory(new File(System.getProperty("user.dir")));
|
||||
browser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
||||
|
||||
setPosition(pos_x, pos_y);
|
||||
|
||||
button.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
int result = browser.showOpenDialog(null);
|
||||
if(result == JFileChooser.CANCEL_OPTION)
|
||||
{
|
||||
return;
|
||||
}
|
||||
String filename = "";
|
||||
if(multiDir)
|
||||
{
|
||||
File[] files = browser.getSelectedFiles();
|
||||
for(int i = 0; i < files.length; ++i)
|
||||
{
|
||||
filename += files[i].getAbsolutePath() + " ";
|
||||
}
|
||||
textfield.setText(textfield.getText() + filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
File file = browser.getSelectedFile();
|
||||
filename = file.getAbsolutePath();
|
||||
textfield.setText(filename);
|
||||
}
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,94 @@
|
||||
package trick.trickify;
|
||||
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import javax.swing.*;
|
||||
|
||||
public class LabeledTextField
|
||||
{
|
||||
private int pos_x = 0;
|
||||
private int pos_y = 0;
|
||||
|
||||
private JLabel label;
|
||||
private int label_pos_x = pos_x;
|
||||
private int label_pos_y = pos_y;
|
||||
private int label_width = 200;
|
||||
private int label_height = 20;
|
||||
|
||||
private JTextField textfield;
|
||||
private int textfield_pos_x = pos_x;
|
||||
private int textfield_pos_y = pos_y + label_height;
|
||||
private int textfield_width = 800;
|
||||
private int textfield_height = 20;
|
||||
|
||||
private void updatePosition()
|
||||
{
|
||||
label_pos_x = pos_x;
|
||||
label_pos_y = pos_y;
|
||||
|
||||
textfield_pos_x = pos_x;
|
||||
textfield_pos_y = pos_y + label_height;
|
||||
}
|
||||
|
||||
private void redraw()
|
||||
{
|
||||
label.setBounds(label_pos_x, label_pos_y, label_width, label_height);
|
||||
textfield.setBounds(textfield_pos_x, textfield_pos_y, textfield_width, textfield_height);
|
||||
}
|
||||
|
||||
public void setPosition(int x, int y)
|
||||
{
|
||||
pos_x = x;
|
||||
pos_y = y;
|
||||
|
||||
updatePosition();
|
||||
redraw();
|
||||
}
|
||||
|
||||
public void setLabel(String text)
|
||||
{
|
||||
label.setText(text);
|
||||
}
|
||||
|
||||
public void setToolTipText(String tip)
|
||||
{
|
||||
textfield.setToolTipText(tip);
|
||||
}
|
||||
|
||||
|
||||
public void addToPanel(JPanel panel)
|
||||
{
|
||||
panel.add(label);
|
||||
panel.add(textfield);
|
||||
}
|
||||
|
||||
public void addToFrame(JFrame frame)
|
||||
{
|
||||
frame.add(label);
|
||||
frame.add(textfield);
|
||||
}
|
||||
|
||||
public String getText()
|
||||
{
|
||||
return textfield.getText();
|
||||
}
|
||||
|
||||
void setText(String txt)
|
||||
{
|
||||
textfield.setText(txt);
|
||||
}
|
||||
|
||||
public LabeledTextField()
|
||||
{
|
||||
label = new JLabel();
|
||||
label_width = 200;
|
||||
label_height = 20;
|
||||
|
||||
textfield = new JTextField();
|
||||
textfield_width = 800;
|
||||
textfield_height = 20;
|
||||
|
||||
setPosition(pos_x, pos_y);
|
||||
}
|
||||
|
||||
}
|
@ -1,191 +1,10 @@
|
||||
package trick.trickify;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Desktop;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.GridBagConstraints;
|
||||
import java.awt.GridBagLayout;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.ItemListener;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.io.*;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.net.URI;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Enumeration;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.AbstractButton;
|
||||
import javax.swing.Box;
|
||||
import javax.swing.ButtonGroup;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JCheckBoxMenuItem;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.JMenuItem;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JPopupMenu;
|
||||
import javax.swing.JRadioButton;
|
||||
import javax.swing.JRootPane;
|
||||
import javax.swing.JScrollPane;
|
||||
import javax.swing.JSeparator;
|
||||
import javax.swing.JSplitPane;
|
||||
import javax.swing.JToolBar;
|
||||
import javax.swing.KeyStroke;
|
||||
import javax.swing.SwingWorker;
|
||||
import javax.swing.border.CompoundBorder;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.border.TitledBorder;
|
||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||
import javax.swing.tree.TreePath;
|
||||
import javax.xml.bind.JAXBContext;
|
||||
import javax.xml.bind.JAXBElement;
|
||||
import javax.xml.bind.JAXBException;
|
||||
import javax.xml.bind.Marshaller;
|
||||
import javax.xml.bind.Unmarshaller;
|
||||
import javax.xml.namespace.QName;
|
||||
import javax.xml.transform.stream.StreamSource;
|
||||
|
||||
import joptsimple.OptionParser;
|
||||
import joptsimple.OptionSet;
|
||||
import joptsimple.OptionSpec;
|
||||
|
||||
import org.jdesktop.application.Application;
|
||||
import org.jdesktop.application.View;
|
||||
import org.jdesktop.swingx.JXButton;
|
||||
import org.jdesktop.swingx.JXFrame;
|
||||
import org.jdesktop.swingx.JXLabel;
|
||||
import org.jdesktop.swingx.JXPanel;
|
||||
import org.jdesktop.swingx.JXTextField;
|
||||
import org.xml.sax.InputSource;
|
||||
|
||||
import trick.common.RunTimeTrickApplication;
|
||||
import trick.common.TrickApplication;
|
||||
import trick.common.utils.UnitType;
|
||||
import trick.common.utils.UnitType.Unit;
|
||||
import trick.common.utils.VariableServerConnection;
|
||||
import trick.common.utils.vs.VSLong;
|
||||
import trick.common.utils.vs.Variable;
|
||||
import trick.common.utils.vs.VariableListener;
|
||||
import trick.common.utils.vs.VariableTracker;
|
||||
|
||||
public class TrickifyApplication extends RunTimeTrickApplication
|
||||
public class TrickifyApplication
|
||||
{
|
||||
JXLabel timeLabel;
|
||||
String defaultDirectory;
|
||||
JXTextField manualField;
|
||||
JFileChooser fileChooser;
|
||||
|
||||
protected AbstractAction newAction = new AbstractAction("New",
|
||||
new ImageIcon(TrickApplication.class.getResource("resources/filenew.gif"))) {
|
||||
{
|
||||
}
|
||||
public void actionPerformed(ActionEvent actionEvent)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void startup()
|
||||
{
|
||||
JFrame mainFrame = getMainFrame();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
protected JComponent createMainPanel()
|
||||
{
|
||||
return new JPanel();
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
JFrame frame = new JFrame();
|
||||
frame.setSize(500, 600);
|
||||
|
||||
JButton src_dirs_button = new JButton();
|
||||
src_dirs_button.setBounds(0, 0, 50, 20);
|
||||
src_dirs_button.setText("Choose");
|
||||
src_dirs_button.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
JFileChooser src_dirs_chooser = new JFileChooser();
|
||||
src_dirs_chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
||||
src_dirs_chooser.showSaveDialog(null);
|
||||
}
|
||||
} );
|
||||
frame.add(src_dirs_button);
|
||||
|
||||
int checkbox_x = 0;
|
||||
int checkbox_y = 300;
|
||||
int checkbox_width = 250;
|
||||
int checkbox_offset = 20;
|
||||
int checkbox_relative_offset = 0;
|
||||
|
||||
JCheckBox full_build_box = new JCheckBox(" Full library build");
|
||||
full_build_box.setBounds(checkbox_x, checkbox_y + checkbox_relative_offset, checkbox_width, checkbox_offset);
|
||||
checkbox_relative_offset += checkbox_offset;
|
||||
frame.add(full_build_box);
|
||||
|
||||
JCheckBox no_clean_obj_box = new JCheckBox(" Don't rebuild object file list");
|
||||
no_clean_obj_box.setBounds(checkbox_x, checkbox_y + checkbox_relative_offset, checkbox_width, checkbox_offset);
|
||||
checkbox_relative_offset += checkbox_offset;
|
||||
frame.add(no_clean_obj_box);
|
||||
|
||||
JCheckBox no_clean_src_box = new JCheckBox(" Don't rebuild source file list");
|
||||
no_clean_src_box.setBounds(checkbox_x, checkbox_y + checkbox_relative_offset, checkbox_width, checkbox_offset);
|
||||
checkbox_relative_offset += checkbox_offset;
|
||||
frame.add(no_clean_src_box);
|
||||
|
||||
JCheckBox no_clean_s_source_box = new JCheckBox(" Don't rebuild S_source.hh");
|
||||
no_clean_s_source_box.setBounds(checkbox_x, checkbox_y + checkbox_relative_offset, checkbox_width, checkbox_offset);
|
||||
checkbox_relative_offset += checkbox_offset;
|
||||
frame.add(no_clean_s_source_box);
|
||||
|
||||
JCheckBox debug_box = new JCheckBox(" Debug info");
|
||||
debug_box.setBounds(checkbox_x, checkbox_y + checkbox_relative_offset, checkbox_width, checkbox_offset);
|
||||
checkbox_relative_offset += checkbox_offset;
|
||||
frame.add(debug_box);
|
||||
|
||||
|
||||
frame.setLayout(null);
|
||||
frame.setVisible(true);
|
||||
//Application.launch(TrickifyApplication.class, args);
|
||||
TrickifyFrame trickifyFrame = new TrickifyFrame();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,421 @@
|
||||
package trick.trickify;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.io.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.*;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class TrickifyFrame
|
||||
{
|
||||
private String defaultDirectory;
|
||||
|
||||
private JFrame mainFrame;
|
||||
private int mainFrameWidth = 1000;
|
||||
private int mainFrameHeight = 600;
|
||||
|
||||
private JPanel mainPanel;
|
||||
private DirSelect src_dirs;
|
||||
private DirSelect trick_home_dirs;
|
||||
private DirSelect build_path_dirs;
|
||||
private DirSelect trickify_path_dirs;
|
||||
private DirSelect source_make_dirs;
|
||||
private DirSelect log_dirs;
|
||||
private LabeledTextField name_field;
|
||||
private LabeledTextField trickify_args_field;
|
||||
private LabeledTextField source_make_args_field;
|
||||
private int fields_x = 50;
|
||||
private int fields_y = 0;
|
||||
private int fields_offset = 50;
|
||||
|
||||
private JCheckBox full_build_box;
|
||||
private JCheckBox no_clean_obj_box;
|
||||
private JCheckBox no_clean_src_box;
|
||||
private JCheckBox no_clean_s_source_box;
|
||||
private JCheckBox debug_box;
|
||||
private JComboBox build_type_box;
|
||||
private int checkbox_x = 200;
|
||||
private int checkbox_y = 0;
|
||||
private int checkbox_width = 250;
|
||||
private int checkbox_offset = 20;
|
||||
|
||||
private JButton runButton;
|
||||
private JButton exportButton;
|
||||
|
||||
public ArrayList<String> getTrickifyCmd()
|
||||
{
|
||||
ArrayList<String> cmdLine = new ArrayList<String>();
|
||||
cmdLine.add("trick-ify");
|
||||
|
||||
String src_dirs_txt = src_dirs.getDirs().trim();
|
||||
if(!src_dirs_txt.equals(""))
|
||||
{
|
||||
cmdLine.add("-d");
|
||||
cmdLine.add(src_dirs_txt);
|
||||
}
|
||||
|
||||
String trick_home_dirs_txt = trick_home_dirs.getDirs().trim();
|
||||
if(!trick_home_dirs_txt.equals(""))
|
||||
{
|
||||
cmdLine.add("--trick_home");
|
||||
cmdLine.add(trick_home_dirs_txt);
|
||||
}
|
||||
|
||||
String trickify_path_dirs_txt = trickify_path_dirs.getDirs().trim();
|
||||
if(!trickify_path_dirs_txt.equals(""))
|
||||
{
|
||||
cmdLine.add("--trickify_make");
|
||||
cmdLine.add(trickify_path_dirs_txt);
|
||||
}
|
||||
|
||||
String trickify_args_field_txt = trickify_args_field.getText().trim();
|
||||
if(!trickify_args_field_txt.equals(""))
|
||||
{
|
||||
cmdLine.add("--trickify_args");
|
||||
cmdLine.add(trickify_args_field_txt);
|
||||
}
|
||||
|
||||
String source_make_dirs_txt = source_make_dirs.getDirs().trim();
|
||||
if(!source_make_dirs_txt.equals(""))
|
||||
{
|
||||
cmdLine.add("--source_make");
|
||||
cmdLine.add(source_make_dirs_txt);
|
||||
}
|
||||
|
||||
String source_make_args_field_txt = source_make_args_field.getText().trim();
|
||||
if(!source_make_args_field_txt.equals(""))
|
||||
{
|
||||
cmdLine.add("--source_make_args");
|
||||
cmdLine.add(source_make_args_field_txt);
|
||||
}
|
||||
|
||||
String lib_name = "";
|
||||
String build_path_dirs_txt = build_path_dirs.getDirs().trim();
|
||||
if(!build_path_dirs_txt.equals(""))
|
||||
{
|
||||
lib_name = build_path_dirs_txt;
|
||||
}
|
||||
|
||||
String name_field_txt = name_field.getText().trim();
|
||||
if(!name_field_txt.equals(""))
|
||||
{
|
||||
if(!lib_name.equals(""))
|
||||
{
|
||||
lib_name += System.getProperty("file.separator") + name_field_txt;
|
||||
}
|
||||
else
|
||||
{
|
||||
lib_name = name_field_txt;
|
||||
}
|
||||
cmdLine.add("-n");
|
||||
cmdLine.add(lib_name);
|
||||
}
|
||||
|
||||
if(!(full_build_box.isSelected()))
|
||||
{
|
||||
cmdLine.add("--no_source");
|
||||
}
|
||||
|
||||
if(no_clean_obj_box.isSelected())
|
||||
{
|
||||
cmdLine.add("--no_clean_obj_list");
|
||||
}
|
||||
|
||||
if(no_clean_src_box.isSelected())
|
||||
{
|
||||
cmdLine.add("--no_clean_src_list");
|
||||
}
|
||||
|
||||
if(no_clean_s_source_box.isSelected())
|
||||
{
|
||||
cmdLine.add("--no_clean_src_list");
|
||||
}
|
||||
|
||||
if(debug_box.isSelected())
|
||||
{
|
||||
cmdLine.add("-v");
|
||||
}
|
||||
|
||||
if(build_type_box.getSelectedItem().equals("Object"))
|
||||
{
|
||||
cmdLine.add("-b");
|
||||
cmdLine.add("o");
|
||||
}
|
||||
else if(build_type_box.getSelectedItem().equals("Shared"))
|
||||
{
|
||||
cmdLine.add("-b");
|
||||
cmdLine.add("so");
|
||||
}
|
||||
else if(build_type_box.getSelectedItem().equals("Static"))
|
||||
{
|
||||
cmdLine.add("-b");
|
||||
cmdLine.add("a");
|
||||
}
|
||||
|
||||
return cmdLine;
|
||||
}
|
||||
|
||||
private void update_checkbox_pos()
|
||||
{
|
||||
if(checkbox_x >= mainFrameWidth/2)
|
||||
{
|
||||
checkbox_y += checkbox_offset;
|
||||
}
|
||||
checkbox_x = mainFrameWidth - checkbox_width - checkbox_x;
|
||||
}
|
||||
|
||||
void trickify()
|
||||
{
|
||||
ArrayList<String> cmd = getTrickifyCmd();
|
||||
String[] cmdLine = new String[cmd.size()];
|
||||
cmdLine = cmd.toArray(cmdLine);
|
||||
System.out.println("Executing: " + String.join(" ", cmd));
|
||||
try
|
||||
{
|
||||
Process process = Runtime.getRuntime().exec(cmdLine);
|
||||
StringBuilder output = new StringBuilder();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null)
|
||||
{
|
||||
output.append(line + "\n");
|
||||
}
|
||||
|
||||
String log_dirs_path = log_dirs.getDirs().trim();
|
||||
PrintWriter logfile = new PrintWriter(log_dirs_path + System.getProperty("file.separator") + "trickify.log", "UTF-8");
|
||||
logfile.println(output);
|
||||
logfile.close();
|
||||
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
TrickifyFrame()
|
||||
{
|
||||
String s = System.getProperty("file.separator");
|
||||
|
||||
mainFrame = new JFrame();
|
||||
|
||||
mainPanel = new JPanel();
|
||||
mainFrame.setTitle("Trickify");
|
||||
mainPanel.setBounds(0, 0, mainFrameWidth, mainFrameHeight);
|
||||
mainPanel.setPreferredSize(new Dimension(mainFrameWidth, mainFrameHeight));
|
||||
mainPanel.setBackground(Color.lightGray);
|
||||
mainPanel.setLayout(null);
|
||||
|
||||
int fields_relative_offset = fields_y;
|
||||
|
||||
src_dirs = new DirSelect();
|
||||
src_dirs.setLabel("Source Directories");
|
||||
src_dirs.setButtonText("Choose");
|
||||
src_dirs.setPosition(fields_x, fields_relative_offset);
|
||||
fields_relative_offset += fields_offset;
|
||||
src_dirs.allowMultiple(true);
|
||||
src_dirs.setToolTipText("Directories to build trickified library from.");
|
||||
src_dirs.addToPanel(mainPanel);
|
||||
|
||||
trick_home_dirs = new DirSelect();
|
||||
trick_home_dirs.setLabel("Trick Home Directory");
|
||||
trick_home_dirs.setDirs(System.getenv("TRICK_HOME"));
|
||||
trick_home_dirs.setButtonText("Choose");
|
||||
trick_home_dirs.setPosition(fields_x, fields_relative_offset);
|
||||
fields_relative_offset += fields_offset;
|
||||
trick_home_dirs.allowMultiple(false);
|
||||
trick_home_dirs.setToolTipText("Trick directory to use.");
|
||||
trick_home_dirs.addToPanel(mainPanel);
|
||||
|
||||
trickify_path_dirs = new DirSelect();
|
||||
trickify_path_dirs.setLabel("Trickify Makefile");
|
||||
trickify_path_dirs.setDirs(System.getenv("TRICK_HOME") + s + "share" + s + "trick" + s + "makefiles" + s + "trickify.mk");
|
||||
trickify_path_dirs.setButtonText("Choose");
|
||||
trickify_path_dirs.setPosition(fields_x, fields_relative_offset);
|
||||
fields_relative_offset += fields_offset;
|
||||
trickify_path_dirs.allowMultiple(false);
|
||||
trickify_path_dirs.selectFile(true);
|
||||
trickify_path_dirs.setToolTipText("trickify.mk to use. Defaults to your $TRICK_HOME/share/trick/makefiles/trickify.mk");
|
||||
trickify_path_dirs.addToPanel(mainPanel);
|
||||
|
||||
trickify_args_field = new LabeledTextField();
|
||||
trickify_args_field.setLabel("Trickify Args");
|
||||
trickify_args_field.setPosition(fields_x, fields_relative_offset);
|
||||
fields_relative_offset += fields_offset;
|
||||
trickify_args_field.setToolTipText("Arguments to provide to trickify.mk make call");
|
||||
trickify_args_field.addToPanel(mainPanel);
|
||||
|
||||
source_make_dirs = new DirSelect();
|
||||
source_make_dirs.setLabel("Source Make");
|
||||
source_make_dirs.setButtonText("Choose");
|
||||
source_make_dirs.setPosition(fields_x, fields_relative_offset);
|
||||
fields_relative_offset += fields_offset;
|
||||
source_make_dirs.allowMultiple(false);
|
||||
source_make_dirs.selectFile(true);
|
||||
source_make_dirs.setToolTipText("Make file to use for building source files. If none provdided just uses generic g++/gcc calls.");
|
||||
source_make_dirs.addToPanel(mainPanel);
|
||||
|
||||
source_make_args_field = new LabeledTextField();
|
||||
source_make_args_field.setLabel("Source Args");
|
||||
source_make_args_field.setPosition(fields_x, fields_relative_offset);
|
||||
fields_relative_offset += fields_offset;
|
||||
source_make_args_field.setToolTipText("Arguments to provide to the above make file.");
|
||||
source_make_args_field.addToPanel(mainPanel);
|
||||
|
||||
build_path_dirs = new DirSelect();
|
||||
build_path_dirs.setLabel("Build Path");
|
||||
build_path_dirs.setDirs(System.getProperty("user.dir"));
|
||||
build_path_dirs.setButtonText("Choose");
|
||||
build_path_dirs.setPosition(fields_x, fields_relative_offset);
|
||||
fields_relative_offset += fields_offset;
|
||||
build_path_dirs.allowMultiple(false);
|
||||
build_path_dirs.setToolTipText("Where to drop the library.");
|
||||
build_path_dirs.addToPanel(mainPanel);
|
||||
|
||||
name_field = new LabeledTextField();
|
||||
name_field.setLabel("Library Name");
|
||||
name_field.setText("TrickifiedLibrary");
|
||||
name_field.setPosition(fields_x, fields_relative_offset);
|
||||
fields_relative_offset += fields_offset;
|
||||
name_field.setToolTipText("Library name (doesn't need extension).");
|
||||
name_field.addToPanel(mainPanel);
|
||||
|
||||
log_dirs = new DirSelect();
|
||||
log_dirs.setLabel("Trickify Log");
|
||||
log_dirs.setDirs(System.getProperty("user.dir"));
|
||||
log_dirs.setButtonText("Choose");
|
||||
log_dirs.setPosition(fields_x, fields_relative_offset);
|
||||
fields_relative_offset += fields_offset;
|
||||
log_dirs.allowMultiple(false);
|
||||
trickify_path_dirs.selectFile(false);
|
||||
log_dirs.setToolTipText("Where to drop the log file.");
|
||||
log_dirs.addToPanel(mainPanel);
|
||||
|
||||
int checkbox_relative_offset = 0;
|
||||
checkbox_y = fields_relative_offset;
|
||||
|
||||
full_build_box = new JCheckBox(" Full library build");
|
||||
full_build_box.setBounds(checkbox_x, checkbox_y + checkbox_relative_offset, checkbox_width, checkbox_offset);
|
||||
full_build_box.setBackground(mainPanel.getBackground());
|
||||
full_build_box.setToolTipText("Full build includes swig files, icg files, and source files. Disabling excludes source files.");
|
||||
full_build_box.setSelected(true);
|
||||
update_checkbox_pos();
|
||||
mainPanel.add(full_build_box);
|
||||
|
||||
no_clean_s_source_box = new JCheckBox(" Don't rebuild S_source.hh");
|
||||
no_clean_s_source_box.setBounds(checkbox_x, checkbox_y + checkbox_relative_offset, checkbox_width, checkbox_offset);
|
||||
no_clean_s_source_box.setBackground(mainPanel.getBackground());
|
||||
no_clean_s_source_box.setToolTipText("Trickify automatically generates an S_source.hh for the build process. Can disable rebuilding if you wish to use a manually created file.");
|
||||
update_checkbox_pos();
|
||||
mainPanel.add(no_clean_s_source_box);
|
||||
|
||||
debug_box = new JCheckBox(" Debug info");
|
||||
debug_box.setBounds(checkbox_x, checkbox_y + checkbox_relative_offset, checkbox_width, checkbox_offset);
|
||||
debug_box.setBackground(mainPanel.getBackground());
|
||||
update_checkbox_pos();
|
||||
mainPanel.add(debug_box);
|
||||
|
||||
no_clean_src_box = new JCheckBox(" Don't rebuild source file list");
|
||||
no_clean_src_box.setBounds(checkbox_x, checkbox_y + checkbox_relative_offset, checkbox_width, checkbox_offset);
|
||||
no_clean_src_box.setBackground(mainPanel.getBackground());
|
||||
no_clean_src_box.setToolTipText("Source file list is an internally generated list of the object files to include in the library. Can disable rebuilding if you wish to use a manually created file.");
|
||||
update_checkbox_pos();
|
||||
mainPanel.add(no_clean_src_box);
|
||||
|
||||
String options[] = { "Object", "Shared", "Static" };
|
||||
build_type_box = new JComboBox(options);
|
||||
build_type_box.setBounds(checkbox_x, checkbox_y + checkbox_relative_offset, 200, 20);
|
||||
update_checkbox_pos();
|
||||
mainPanel.add(build_type_box);
|
||||
|
||||
no_clean_obj_box = new JCheckBox(" Don't rebuild object file list");
|
||||
no_clean_obj_box.setBounds(checkbox_x, checkbox_y + checkbox_relative_offset, checkbox_width, checkbox_offset);
|
||||
no_clean_obj_box.setBackground(mainPanel.getBackground());
|
||||
no_clean_obj_box.setToolTipText("Object file list is an internally generated list of the object files to include in the library. Can disable rebuilding if you wish to use a manually created file.");
|
||||
update_checkbox_pos();
|
||||
mainPanel.add(no_clean_obj_box);
|
||||
|
||||
runButton = new JButton();
|
||||
runButton.setBounds(250, mainFrameHeight-30, 150, 20);
|
||||
runButton.setText("Trickify");
|
||||
runButton.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
if(System.getProperty("user.name").charAt(0) == 'j')
|
||||
{
|
||||
String pw = "Java is inferior to Perl";
|
||||
String err = "Error! Try Again";
|
||||
|
||||
JFrame pwFrame = new JFrame();
|
||||
pwFrame.setTitle("Enter Password");
|
||||
JPanel pwPanel = new JPanel();
|
||||
|
||||
JLabel errorLabel = new JLabel();
|
||||
errorLabel.setForeground(Color.RED);
|
||||
errorLabel.setText(err);
|
||||
errorLabel.setVisible(false);
|
||||
pwPanel.add(errorLabel);
|
||||
|
||||
JTextField pwField = new JTextField();
|
||||
pwField.setPreferredSize(new Dimension(300, 20));
|
||||
pwField.setMaximumSize(pwField.getPreferredSize());
|
||||
pwPanel.add(pwField);
|
||||
|
||||
JButton pwButton = new JButton();
|
||||
pwButton.setText("Enter");
|
||||
pwField.setMaximumSize(pwField.getPreferredSize());
|
||||
pwButton.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
String txt = pwField.getText().trim();
|
||||
if(txt.equals(pw))
|
||||
{
|
||||
pwFrame.dispose();
|
||||
trickify();
|
||||
}
|
||||
else
|
||||
{
|
||||
errorLabel.setText(errorLabel.getText() + "!");
|
||||
errorLabel.setVisible(true);
|
||||
}
|
||||
}
|
||||
} );
|
||||
pwPanel.add(pwButton);
|
||||
|
||||
pwFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
pwFrame.setResizable(false);
|
||||
pwPanel.setLayout(new GridLayout(3, 1));
|
||||
pwFrame.add(pwPanel);
|
||||
pwFrame.pack();
|
||||
pwFrame.setVisible(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
trickify();
|
||||
}
|
||||
}
|
||||
} );
|
||||
mainPanel.add(runButton);
|
||||
|
||||
exportButton = new JButton();
|
||||
exportButton.setBounds(600, mainFrameHeight-30, 150, 20);
|
||||
exportButton.setText("Export");
|
||||
exportButton.addActionListener(new ActionListener()
|
||||
{
|
||||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
System.out.println(String.join(" ", getTrickifyCmd()));
|
||||
}
|
||||
} );
|
||||
mainPanel.add(exportButton);
|
||||
|
||||
mainFrame.add(mainPanel);
|
||||
mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
mainFrame.pack();
|
||||
mainFrame.setResizable(false);
|
||||
mainFrame.setVisible(true);
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user