Added new frame
This commit is contained in:
@@ -83,23 +83,28 @@ public class GraphPanel extends JPanel {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
String filename = "img." + name.toLowerCase() + ".png";
|
||||
File file = new File("export/" + filename);
|
||||
BackgroundWorker.instance().addWorker(new BackgroundWorker.Worker() {
|
||||
@Override
|
||||
public void execute() {
|
||||
String filename = "img." + name.toLowerCase() + ".png";
|
||||
File file = new File("export/" + filename);
|
||||
|
||||
if(file.exists()){
|
||||
int reply = JOptionPane.showConfirmDialog(null, "The file " + filename + "already exists. Do you want to overwrite it?", "File exists", JOptionPane.YES_NO_OPTION);
|
||||
if (reply != JOptionPane.YES_OPTION) {
|
||||
StatusPanel.Instance().setStatus("Cancelled export");
|
||||
return;
|
||||
if(file.exists()){
|
||||
int reply = JOptionPane.showConfirmDialog(GraphPanel.this, "The file " + filename + "already exists. Do you want to overwrite it?", "File exists", JOptionPane.YES_NO_OPTION);
|
||||
if (reply != JOptionPane.YES_OPTION) {
|
||||
StatusPanel.Instance().setStatus("Cancelled export");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
FileUtils.copyFile(f, file);
|
||||
StatusPanel.Instance().setStatus("Success: " + filename);
|
||||
} catch (IOException e1) {
|
||||
StatusPanel.Instance().setStatus("Something went wrong while exporting the file");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
FileUtils.copyFile(f, file);
|
||||
StatusPanel.Instance().setStatus("Success: " + filename);
|
||||
} catch (IOException e1) {
|
||||
StatusPanel.Instance().setStatus("Something went wrong while exporting the file");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -64,10 +64,6 @@ public class InputPanel extends JPanel {
|
||||
StatusPanel.Instance().setStatus("Converting REGEX to NDFA", 40);
|
||||
|
||||
NDFA<String> ndfa = ThompsonConverter.convert(regex);
|
||||
try {
|
||||
Thread.sleep(500);
|
||||
} catch (InterruptedException e1) {
|
||||
}
|
||||
|
||||
StatusPanel.Instance().setStatus("Generating image for NDFA", 70);
|
||||
|
||||
@@ -75,6 +71,10 @@ public class InputPanel extends JPanel {
|
||||
|
||||
TabPanel.Instance().addGraph("REGEX: " + name, new File("images/" + name + ".png"), ndfa);
|
||||
|
||||
StatusPanel.Instance().setStatus("Generating taal", 90);
|
||||
|
||||
new PopupFrame(name, regex.getTaal(10, 3).toString());
|
||||
|
||||
StatusPanel.Instance().setStatus("Done", 100);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.imegumii.ui;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* Created by kenny on 12-6-2017.
|
||||
*/
|
||||
public class PopupFrame extends JFrame {
|
||||
|
||||
public PopupFrame(String name, String content)
|
||||
{
|
||||
super(name);
|
||||
|
||||
this.setSize(300, 800);
|
||||
//this.setResizable(false);
|
||||
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||
|
||||
JPanel container = new JPanel(new BorderLayout());
|
||||
JTextArea textArea = new JTextArea(content);
|
||||
|
||||
container.add(textArea, BorderLayout.CENTER);
|
||||
|
||||
this.setContentPane(container);
|
||||
|
||||
this.setVisible(true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user