diff --git a/Mage.Plugins/Mage.Rating.Plugin/MANIFEST.MF b/Mage.Plugins/Mage.Rating.Plugin/MANIFEST.MF new file mode 100644 index 0000000000..98d46b93d1 --- /dev/null +++ b/Mage.Plugins/Mage.Rating.Plugin/MANIFEST.MF @@ -0,0 +1,7 @@ +Manifest-Version: 1.0 +Archiver-Version: Plexus Archiver +Created-By: Apache Maven +Built-By: natfullina +Build-Jdk: 1.6.0_16 +Main-Class: org.mage.plugins.rating.RateFrame +Class-Path: lib/mage-sets.jar \ No newline at end of file diff --git a/Mage.Plugins/Mage.Rating.Plugin/executable/lib/mage-sets.jar b/Mage.Plugins/Mage.Rating.Plugin/executable/lib/mage-sets.jar new file mode 100644 index 0000000000..332139f3b5 Binary files /dev/null and b/Mage.Plugins/Mage.Rating.Plugin/executable/lib/mage-sets.jar differ diff --git a/Mage.Plugins/Mage.Rating.Plugin/executable/mage-rate-executable.jar b/Mage.Plugins/Mage.Rating.Plugin/executable/mage-rate-executable.jar new file mode 100644 index 0000000000..698df2ad97 Binary files /dev/null and b/Mage.Plugins/Mage.Rating.Plugin/executable/mage-rate-executable.jar differ diff --git a/Mage.Plugins/Mage.Rating.Plugin/pom.xml b/Mage.Plugins/Mage.Rating.Plugin/pom.xml index 38ab09278a..849e76b41f 100644 --- a/Mage.Plugins/Mage.Rating.Plugin/pom.xml +++ b/Mage.Plugins/Mage.Rating.Plugin/pom.xml @@ -65,6 +65,20 @@ + + maven-assembly-plugin + + + + org.mage.plugins.rating.RateFrame + + + + jar-with-dependencies + + + + mage-card-plugin diff --git a/Mage.Plugins/Mage.Rating.Plugin/src/main/java/org/mage/plugins/rating/RateFrame.java b/Mage.Plugins/Mage.Rating.Plugin/src/main/java/org/mage/plugins/rating/RateFrame.java index 5f232727f5..01ab569159 100644 --- a/Mage.Plugins/Mage.Rating.Plugin/src/main/java/org/mage/plugins/rating/RateFrame.java +++ b/Mage.Plugins/Mage.Rating.Plugin/src/main/java/org/mage/plugins/rating/RateFrame.java @@ -3,6 +3,8 @@ package org.mage.plugins.rating; import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; import javax.swing.BorderFactory; import javax.swing.JButton; @@ -20,7 +22,7 @@ public class RateFrame extends JFrame { private static Logger log = Logger.getLogger(RateFrame.class); private BigCard bigCard; - + public RateFrame() { setTitle("Mage Rate Cards, version 0.1"); @@ -30,24 +32,34 @@ public class RateFrame extends JFrame { log.error(ex.getMessage(), ex); } + addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + if (JOptionPane.showConfirmDialog(null, "Do you want to save recent compares?", "Save before exit", JOptionPane.YES_NO_OPTION) == JOptionPane.OK_OPTION) { + RateThread.getInstance().forceSave(); + } + } + }); + int width = 621; int height = 384; setSize(width, height); + setResizable(false); int w = getGraphicsConfiguration().getBounds().width; int h = getGraphicsConfiguration().getBounds().height; - setLocation((w - width)/2, (h - height)/2); + setLocation((w - width) / 2, (h - height) / 2); setDefaultCloseOperation(DISPOSE_ON_CLOSE); setLayout(null); - + bigCard = new BigCard(); bigCard.setBounds(20, 10, RateThread.bigCardDimension.frameWidth, RateThread.bigCardDimension.frameHeight); bigCard.setBorder(BorderFactory.createLineBorder(Color.gray)); add(bigCard); - + JLabel label = new JLabel("The results are stored for every 10 compare."); label.setBounds(290, 270, 300, 30); add(label); - + JButton rate = new JButton("Create results.txt"); rate.setBounds(340, 230, 120, 25); rate.addActionListener(new ActionListener() { @@ -63,8 +75,10 @@ public class RateFrame extends JFrame { } }); add(rate); + + System.out.println("test"); } - + public void startRating() { RateThread.getInstance().start(this, this.bigCard); } diff --git a/Mage.Plugins/Mage.Rating.Plugin/src/main/java/org/mage/plugins/rating/RateThread.java b/Mage.Plugins/Mage.Rating.Plugin/src/main/java/org/mage/plugins/rating/RateThread.java index 9fee2c1463..82bfa79c6f 100644 --- a/Mage.Plugins/Mage.Rating.Plugin/src/main/java/org/mage/plugins/rating/RateThread.java +++ b/Mage.Plugins/Mage.Rating.Plugin/src/main/java/org/mage/plugins/rating/RateThread.java @@ -96,6 +96,13 @@ public class RateThread extends Thread { generateNext(); } + public void forceSave() { + if (results.size() > 0) { + ResultHandler.getInstance().save(results); + results.clear(); + } + } + private void removeCard(Component component) { if (component != null) { frame.remove(component);