Author: jflesch
Date: 2007-07-30 14:22:37 +0000 (Mon, 30 Jul 2007)
New Revision: 14442

Modified:
   trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties
   trunk/apps/Thaw/src/thaw/i18n/thaw.properties
   trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties
   trunk/apps/Thaw/src/thaw/plugins/miniFrost/DraftPanel.java
   trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoard.java
   trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKDraft.java
   trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessageParser.java
   trunk/apps/Thaw/src/thaw/plugins/miniFrost/interfaces/Draft.java
Log:
Make the draft panel detachable

Modified: trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties     2007-07-30 
12:25:36 UTC (rev 14441)
+++ trunk/apps/Thaw/src/thaw/i18n/source.thaw_fr.properties     2007-07-30 
14:22:37 UTC (rev 14442)
@@ -587,3 +587,5 @@
 thaw.plugin.miniFrost.messageSent=Message sur la board 'X' envoy?

 thaw.plugin.miniFrost.generateKeys=Generer les clefs
+thaw.plugin.miniFrost.newWindow=Ouvrir une nouvelle fen?tre
+thaw.plugin.miniFrost.draft=Brouillon

Modified: trunk/apps/Thaw/src/thaw/i18n/thaw.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw.properties       2007-07-30 12:25:36 UTC 
(rev 14441)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw.properties       2007-07-30 14:22:37 UTC 
(rev 14442)
@@ -602,3 +602,6 @@
 thaw.plugin.miniFrost.messageSent=Message to the board 'X' sent

 thaw.plugin.miniFrost.generateKeys=Generate keys
+
+thaw.plugin.miniFrost.newWindow=Open a new window
+thaw.plugin.miniFrost.draft=Draft
\ No newline at end of file

Modified: trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties
===================================================================
--- trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties    2007-07-30 12:25:36 UTC 
(rev 14441)
+++ trunk/apps/Thaw/src/thaw/i18n/thaw_fr.properties    2007-07-30 14:22:37 UTC 
(rev 14442)
@@ -166,7 +166,7 @@
 thaw.plugin.insert.SSK=SSK / USK
 thaw.plugin.insert.selectRev=Revision
 thaw.plugin.insert.selectName=Nom
-thaw.plugin.insert.publicKey=Clef public
+thaw.plugin.insert.publicKey=Clef publique
 thaw.plugin.insert.privateKey=Clef priv\u00e9e
 thaw.plugin.insert.insertAction=Inserer
 thaw.plugin.insert.specifyNameAndRev=Veuillez sp\u00e9cifier un nom et une 
r\u00e9vision
@@ -587,3 +587,5 @@
 thaw.plugin.miniFrost.messageSent=Message sur la board 'X' envoy\u00e9

 thaw.plugin.miniFrost.generateKeys=Generer les clefs
+thaw.plugin.miniFrost.newWindow=Ouvrir une nouvelle fen\u00eatre
+thaw.plugin.miniFrost.draft=Brouillon

Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/DraftPanel.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/DraftPanel.java  2007-07-30 
12:25:36 UTC (rev 14441)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/DraftPanel.java  2007-07-30 
14:22:37 UTC (rev 14442)
@@ -10,6 +10,7 @@
 import javax.swing.JLabel;
 import javax.swing.JScrollPane;
 import javax.swing.JButton;
+import javax.swing.JDialog;

 import java.util.Iterator;
 import java.util.Vector;
@@ -42,7 +43,10 @@
        private JButton cancelButton;
        private JButton sendButton;

+       private JButton extractButton;

+       private JDialog dialog;
+
        public DraftPanel(MiniFrostPanel mainPanel) {
                this.mainPanel = mainPanel;

@@ -62,10 +66,13 @@
                textArea.setEditable(true);
                textArea.setLineWrap(true);
                textArea.setWrapStyleWord(true);
+               textArea.setFont(textArea.getFont().deriveFont((float)13.5));

                boardLabel = new JLabel("");
+               extractButton = new JButton(thaw.gui.IconBox.minWindowNew);
+               
extractButton.setToolTipText(I18n.getMessage("thaw.plugin.miniFrost.newWindow"));
+               extractButton.addActionListener(this);

-
                JPanel northPanel = new JPanel(new BorderLayout(5, 5));

                JPanel headersPanel = new JPanel(new GridLayout(3, 1));
@@ -74,7 +81,12 @@
                headersPanel.add(new 
JLabel(I18n.getMessage("thaw.plugin.miniFrost.subject")+": "));

                JPanel valuesPanel = new JPanel(new GridLayout(3, 1));
-               valuesPanel.add(boardLabel);
+
+               JPanel topPanel = new JPanel(new BorderLayout(5, 5));
+               topPanel.add(boardLabel, BorderLayout.CENTER);
+               topPanel.add(extractButton, BorderLayout.EAST);
+
+               valuesPanel.add(topPanel);
                valuesPanel.add(authorBox);
                valuesPanel.add(subjectField);

@@ -97,12 +109,20 @@
                panel.add(southPanel,                BorderLayout.SOUTH );
        }

+       public DraftPanel(MiniFrostPanel mainPanel, JDialog dialog) {
+               this(mainPanel);
+               this.dialog = dialog;
+               extractButton.setEnabled(false);
+       }

+
        public void setDraft(Draft draft) {
                this.draft = draft;

+               /* board */
                boardLabel.setText(draft.getBoard().toString());

+               /* identity */
                Vector ids = new Vector();
                ids.add(I18n.getMessage("thaw.plugin.miniFrost.anonymous"));
                ids.addAll(Identity.getYourIdentities(mainPanel.getDb()));
@@ -112,8 +132,15 @@
                for (Iterator it = ids.iterator(); it.hasNext();)
                        authorBox.addItem(it.next());

+               if (draft.getAuthorIdentity() != null)
+                       authorBox.setSelectedItem(draft.getAuthorIdentity());
+               else if (draft.getAuthorNick() != null)
+                       authorBox.setSelectedItem(draft.getAuthorNick());
+
+               /* subject */
                subjectField.setText(draft.getSubject());

+               /* text */
                String txt = draft.getText();

                textArea.setText(draft.getText());
@@ -140,28 +167,58 @@
                return panel;
        }

+       /**
+        * Don't do the replacements in the text.
+        * Don't call Draft.setDate()
+        */
+       public void fillInDraft() {
+               /* author */

+               if (authorBox.getSelectedItem() instanceof Identity) {
+                       draft.setAuthor(authorBox.getSelectedItem().toString(),
+                                       (Identity)authorBox.getSelectedItem());
+               } else {
+                       String nick = authorBox.getSelectedItem().toString();
+                       nick = nick.replaceAll("@", "_");
+
+                       draft.setAuthor(nick, null);
+               }
+
+               /* subject */
+
+               draft.setSubject(subjectField.getText());
+
+               /* text */
+
+               String txt = textArea.getText();
+               draft.setText(txt);
+       }
+
+
        public void actionPerformed(ActionEvent e) {
-               if (e.getSource() == sendButton) {
-                       Date date = new Date();
-                       SimpleDateFormat dateFormat = new 
SimpleDateFormat("yyyy.MM.dd - HH:mm:ss");
+               if (e.getSource() == extractButton) {
+                       fillInDraft();

-                       /* author */
+                       JDialog newDialog = new 
JDialog(mainPanel.getPluginCore().getCore().getMainWindow().getMainFrame(),
+                                                    
I18n.getMessage("thaw.plugin.miniFrost.draft"));
+                       newDialog.getContentPane().setLayout(new GridLayout(1, 
1));

-                       if (authorBox.getSelectedItem() instanceof Identity) {
-                               
draft.setAuthor(authorBox.getSelectedItem().toString(),
-                                               
(Identity)authorBox.getSelectedItem());
-                       } else {
-                               String nick = 
authorBox.getSelectedItem().toString();
-                               nick = nick.replaceAll("@", "_");
+                       DraftPanel panel = new DraftPanel(mainPanel, newDialog);

-                               draft.setAuthor(nick, null);
-                       }
+                       panel.setDraft(draft);

-                       /* subject */
+                       newDialog.getContentPane().add(panel.getPanel());

-                       draft.setSubject(subjectField.getText());
+                       newDialog.setSize(500, 500);

+                       newDialog.setVisible(true);
+
+               } else if (e.getSource() == sendButton) {
+                       fillInDraft();
+
+                       Date date = new Date();
+                       SimpleDateFormat dateFormat = new 
SimpleDateFormat("yyyy.MM.dd - HH:mm:ss");
+
                        /* text */

                        String txt = textArea.getText();
@@ -185,6 +242,9 @@

                }

-               mainPanel.displayMessageTable();
+               if (dialog == null)
+                       mainPanel.displayMessageTable();
+               else
+                       dialog.setVisible(false);
        }
 }

Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoard.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoard.java   
2007-07-30 12:25:36 UTC (rev 14441)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKBoard.java   
2007-07-30 14:22:37 UTC (rev 14442)
@@ -549,8 +549,6 @@
                                if (msg.isParsable())
                                        newMsgs++;

-                               notifyChange();
-
                                if (msg.getRev() > lastSuccessfulRev)
                                        lastSuccessfulRev = msg.getRev();

@@ -573,10 +571,7 @@
                                for (int i = 0 ; i < toRestart ; i++)
                                        startNewMessageDownload(false);

-                               return;
                        } else {
-                               /* we notify a change anyway because of 
KSKDraft */
-                               notifyChange();

                                /* if not successful, we look if all the other 
failed */
                                /* we look first if we can restart some of the 
failed transfers
@@ -673,6 +668,9 @@

                }

+               /* we notify a change anyway because of KSKDraft */
+               notifyChange();
+
        }

        public void refresh() {

Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKDraft.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKDraft.java   
2007-07-30 12:25:36 UTC (rev 14441)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKDraft.java   
2007-07-30 14:22:37 UTC (rev 14442)
@@ -4,6 +4,8 @@
 import java.util.Observable;
 import java.util.Date;

+import java.util.Vector;
+
 import thaw.fcp.*;
 import thaw.plugins.signatures.Identity;

@@ -81,6 +83,14 @@
                this.identity = identity;
        }

+       public Identity getAuthorIdentity() {
+               return identity;
+       }
+
+       public String getAuthorNick() {
+               return nick;
+       }
+
        public void setDate(Date date) {
                this.date = date;
        }
@@ -101,7 +111,11 @@
                return true;
        }

+       public Vector getAttachments() {
+               return null;
+       }

+
        private java.io.File fileToInsert;
        private FCPQueueManager queueManager;
        private int revUsed;
@@ -150,6 +164,9 @@

                        fileToInsert = generator.generateXML();
                }
+
+               /* first check */
+               update(board, null);
        }



Modified: 
trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessageParser.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessageParser.java   
2007-07-30 12:25:36 UTC (rev 14441)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/frostKSK/KSKMessageParser.java   
2007-07-30 14:22:37 UTC (rev 14442)
@@ -447,8 +447,7 @@

                try {
                        tmpFile = File.createTempFile("thaw-", "-message.xml");
-                       /* don't call deleteOnExit() ... seems to have 
non-wanted side effects */
-                       //tmpFile.deleteOnExit();
+                       tmpFile.deleteOnExit();
                } catch(java.io.IOException e) {
                        Logger.error(this, "Can't create temporary file because 
: "+e.toString());
                        return null;

Modified: trunk/apps/Thaw/src/thaw/plugins/miniFrost/interfaces/Draft.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/miniFrost/interfaces/Draft.java    
2007-07-30 12:25:36 UTC (rev 14441)
+++ trunk/apps/Thaw/src/thaw/plugins/miniFrost/interfaces/Draft.java    
2007-07-30 14:22:37 UTC (rev 14442)
@@ -1,5 +1,7 @@
 package thaw.plugins.miniFrost.interfaces;

+import java.util.Vector;
+
 import thaw.plugins.signatures.Identity;


@@ -14,6 +16,16 @@
         */
        public String getText();

+       /**
+        * @return can return null if unknown
+        */
+       public String getAuthorNick();
+
+       /**
+        * @return can return null if unknown
+        */
+       public Identity getAuthorIdentity();
+
        public boolean allowUnsignedPost();

        public void setSubject(String txt);
@@ -34,6 +46,8 @@
        public boolean removeAttachment(java.io.File file);
        public boolean removeAttachment(Board board);

+       public Vector getAttachments();
+
        /**
         * must notify thaw.plugins.MiniFrostPanel at each change
         */


Reply via email to