diff --git a/src/com/quollwriter/data/Note.java b/src/com/quollwriter/data/Note.java index 415084fa..58ad8229 100644 --- a/src/com/quollwriter/data/Note.java +++ b/src/com/quollwriter/data/Note.java @@ -9,6 +9,7 @@ public class Note extends ChapterItem { + public static final String DEALT_WITH = "dealtWith"; public static final String EDIT_NEEDED_NOTE_TYPE = "Edit Needed"; public static final String OBJECT_TYPE = "note"; @@ -84,8 +85,14 @@ public Date getDealtWith () public void setDealtWith (Date d) { + Date oldd = this.dealtWith; + this.dealtWith = d; + this.firePropertyChangedEvent (Note.DEALT_WITH, + oldd, + this.dealtWith); + } public void getChanges (NamedObject old, diff --git a/src/com/quollwriter/editors/messages/AbstractProjectMessage.java b/src/com/quollwriter/editors/messages/AbstractProjectMessage.java index 2f85c518..26f3c821 100644 --- a/src/com/quollwriter/editors/messages/AbstractProjectMessage.java +++ b/src/com/quollwriter/editors/messages/AbstractProjectMessage.java @@ -78,6 +78,10 @@ public AbstractProjectMessage (Project project, } + public abstract Project createProject () + throws Exception; + + @Override public void fillToStringProperties (Map props) { diff --git a/src/com/quollwriter/editors/messages/NewProjectMessage.java b/src/com/quollwriter/editors/messages/NewProjectMessage.java index ee4cf1b6..0f664cb9 100644 --- a/src/com/quollwriter/editors/messages/NewProjectMessage.java +++ b/src/com/quollwriter/editors/messages/NewProjectMessage.java @@ -355,19 +355,24 @@ private boolean hasChapterText () /** * Creates a new Project object from the data held within the message. */ + @Override public Project createProject () throws Exception { Set chaps = this.chapters; + /* if (!this.hasChapterText ()) { chaps = this.getChaptersWithText (); } + */ + chaps = this.getChaptersWithText (); + Project proj = new Project (); proj.setType (Project.EDITOR_PROJECT_TYPE); proj.setId (this.getForProjectId ()); diff --git a/src/com/quollwriter/editors/messages/ProjectCommentsMessage.java b/src/com/quollwriter/editors/messages/ProjectCommentsMessage.java index 844f37a4..18022b80 100644 --- a/src/com/quollwriter/editors/messages/ProjectCommentsMessage.java +++ b/src/com/quollwriter/editors/messages/ProjectCommentsMessage.java @@ -3,6 +3,7 @@ import java.util.*; import com.quollwriter.*; +import com.quollwriter.events.*; import com.quollwriter.text.*; import com.quollwriter.data.*; import com.quollwriter.data.editors.*; @@ -10,7 +11,7 @@ /** */ -public class ProjectCommentsMessage extends EditorMessage +public class ProjectCommentsMessage extends EditorMessage implements PropertyChangedListener { public static final String MESSAGE_TYPE = "project-comments"; @@ -186,6 +187,32 @@ public Set getComments () } + @Override + public void propertyChanged (PropertyChangedEvent ev) + { + + if (ev.getChangeType ().equals (Note.DEALT_WITH)) + { + + Note n = (Note) ev.getSource (); + + try + { + + this.setCommentDealtWith (n.getId (), + (Date) ev.getNewValue ()); + + } catch (Exception e) { + + Environment.logError ("Unable to set comment as dealt with: " + + n, + e); + + } + } + + } + protected void fillMap (Map data) throws GeneralException { @@ -296,6 +323,8 @@ protected void doInit (Map data, Note n = TypeEncoder.decodeToNote (cm); + n.addPropertyChangedListener (this); + comments.add (n); } diff --git a/src/com/quollwriter/editors/messages/UpdateProjectMessage.java b/src/com/quollwriter/editors/messages/UpdateProjectMessage.java index 17afa5ef..b750acbc 100644 --- a/src/com/quollwriter/editors/messages/UpdateProjectMessage.java +++ b/src/com/quollwriter/editors/messages/UpdateProjectMessage.java @@ -72,6 +72,76 @@ public UpdateProjectMessage (Project project, */ } + private boolean hasChapterText () + { + + for (Chapter c : this.chapters) + { + + if (c.getText () != null) + { + + return true; + + } + + } + + return false; + + } + + /** + * Creates a new Project object from the data held within the message. + */ + @Override + public Project createProject () + throws Exception + { + + Set chaps = this.chapters; + + /* + if (!this.hasChapterText ()) + { + + chaps = this.getChaptersWithText (); + + } + */ + chaps = this.getChaptersWithText (); + + Project proj = new Project (); + proj.setType (Project.EDITOR_PROJECT_TYPE); + proj.setId (this.getForProjectId ()); + proj.setName (this.getForProjectName ()); + proj.setForEditor (this.getEditor ().getEmail ()); + + proj.setProjectVersion (this.getProjectVersion ()); + + if (this.responseMessage != null) + { + + proj.setEditResponseMessage (this.responseMessage); + + } + + Book b = new Book (proj, + proj.getName ()); + + proj.addBook (b); + + for (Chapter c : chaps) + { + + b.addChapter (c); + + } + + return proj; + + } + @Override public void fillToStringProperties (Map props) { diff --git a/src/com/quollwriter/editors/ui/EditorsUIUtils.java b/src/com/quollwriter/editors/ui/EditorsUIUtils.java index ba6a61f5..f82c7f8a 100644 --- a/src/com/quollwriter/editors/ui/EditorsUIUtils.java +++ b/src/com/quollwriter/editors/ui/EditorsUIUtils.java @@ -4996,9 +4996,12 @@ public static void showProjectComments (final ProjectCommentsMessage message, public void actionPerformed (ActionEvent ev) { - String pwd = ev.getActionCommand (); + String pwd = _proj.getFilePassword (); - if (pwd.equals ("")) + if ((pwd != null) + && + (pwd.equals ("")) + ) { pwd = null; @@ -5088,12 +5091,12 @@ public void actionPerformed (ActionEvent ev) // Need to prevent an O^n performance hit here. Map kchaps = new HashMap (); - + for (Chapter c : chaps) { b.addChapter (c); - + kchaps.put (c.getId (), c); @@ -5129,7 +5132,7 @@ public void actionPerformed (ActionEvent ev) pcv.init (); pcv.showViewer (); - + if (onShow != null) { @@ -6358,362 +6361,640 @@ public void actionPerformed (ActionEvent ev) if (message.isSentByMe ()) { - - JLabel viewProj = UIUtils.createClickableLabel ("Click to view what you sent", - Environment.getIcon (Constants.VIEW_ICON_NAME, - Constants.ICON_CLICKABLE_LABEL), - new ActionListener () - { - - public void actionPerformed (ActionEvent ev) + + JLabel viewProj = null; + + if (proj == null) { - - AbstractViewer childViewer = parentMessageBox.getChildViewer (); - - if (childViewer != null) - { - - childViewer.setExtendedState (JFrame.NORMAL); - childViewer.toFront (); - - return; - - } - - // Load up the project with the specific text. - // See if we have a project viewer for the project. - ProjectInfo proj = null; - - try - { - - proj = Environment.getProjectById (message.getForProjectId (), - Project.NORMAL_PROJECT_TYPE); - - } catch (Exception e) { - - Environment.logError ("Unable to get project for: " + - message.getForProjectId (), - e); - - UIUtils.showErrorMessage (viewer, - "Unable to show the {project}, please contact Quoll Writer support for assistance."); - - return; - - } - - final ProjectInfo _proj = proj; - - ActionListener open = new ActionListener () + + viewProj = UIUtils.createErrorLabel ("{Project} has been deleted"); + + } else { + + viewProj = UIUtils.createClickableLabel ("Click to view what you sent", + Environment.getIcon (Constants.VIEW_ICON_NAME, + Constants.ICON_CLICKABLE_LABEL), + new ActionListener () + { + + public void actionPerformed (ActionEvent ev) { - - public void actionPerformed (ActionEvent ev) + /* + Project np = null; + + try { - - String pwd = ev.getActionCommand (); - - if (pwd.equals ("")) + + np = message.createProject (); + + } catch (Exception e) { + + Environment.logError ("Unable to get project from message: " + + message, + e); + + UIUtils.showErrorMessage (viewer, + "Unable to view message"); + + return; + + } + + ProjectSentReceivedViewer pcv = new ProjectSentReceivedViewer (np, + message) + { + + public ProjectSentReceivedSideBar getSideBar () { - - pwd = null; - + + return new ProjectSentReceivedSideBar (this, + this.message) + { + + @Override + public void onShow () + { + + } + + @Override + public void onHide () + { + + } + + @Override + public String getTitle () + { + + return "Sent to"; + + } + + @Override + public String getItemsIconType () + { + + return Chapter.OBJECT_TYPE; + + } + + @Override + public String getItemsTitle () + { + + return "{Chapters}"; + + } + + @Override + public int getItemCount () + { + + return this.viewer.getProject ().getBook (0).getChapters ().size (); + + } + + @Override + public JComponent getMessageDetails (AbstractProjectMessage message) + { + + final ProjectSentReceivedSideBar _this = this; + + String rows = "p"; + + ProjectVersion projVer = message.getProjectVersion (); + + String verName = projVer.getName (); + + if (verName != null) + { + + rows += ", 6px, p"; + + } + + final String notes = (projVer.getDescription () != null ? projVer.getDescription ().getText () : null); + + if (notes != null) + { + + rows += ", 6px, top:p"; + + } + + FormLayout fl = new FormLayout ("right:p, 6px, fill:100px:grow", + rows); + + fl.setHonorsVisibility (true); + PanelBuilder builder = new PanelBuilder (fl); + + CellConstraints cc = new CellConstraints (); + + int row = 1; + + builder.addLabel (Environment.replaceObjectNames ("{Sent}"), + cc.xy (1, + row)); + + builder.addLabel ("" + Environment.formatDateTime (message.getWhen ()) + "", + cc.xy (3, + row)); + + row += 2; + + if (verName != null) + { + + builder.addLabel (Environment.replaceObjectNames ("{Version}"), + cc.xy (1, + row)); + builder.addLabel (String.format ("%s", + verName), + cc.xy (3, + row)); + + row += 2; + + } + + if (notes != null) + { + + builder.addLabel (Environment.replaceObjectNames ("{Notes}"), + cc.xy (1, + row)); + + String commText = notes; + + TextIterator ti = new TextIterator (commText); + + if (ti.getSentenceCount () > 1) + { + + commText = ti.getFirstSentence ().getText (); + + commText += "
More, click to view all."; + + } + + JComponent mess = UIUtils.createHelpTextPane (commText, + this.viewer); + + mess.addMouseListener (new MouseEventHandler () + { + + @Override + public void handlePress (MouseEvent ev) + { + + UIUtils.showMessage ((PopupsSupported) _this.getViewer (), + "Notes", + notes); + + } + + }); + + mess.setBorder (null); + + builder.add (mess, + cc.xy (3, + row)); + + } + + JPanel bp = builder.getPanel (); + bp.setAlignmentX (Component.LEFT_ALIGNMENT); + bp.setOpaque (false); + + return bp; + + } + + }; + } - - Set chaps = null; - - try + + @Override + public void init () + throws Exception { - - chaps = Environment.getVersionedChapters (_proj, - message.getChapters (), - pwd); - - } catch (Exception e) { - - Environment.logError ("Unable to get versioned chapters for project: " + - _proj, - e); - - UIUtils.showErrorMessage (viewer, - "Unable to show {comments}, please contact Quoll Writer support for assistance."); - - return; - + + super.init (); + + this.viewObject (this.proj.getBook (0).getChapters ().get (0)); + } - - try + + @Override + public String getViewerIcon () { - - // Need to "fill up" the project with the chapters and comments. - // Create a new project object just to be safe (in case the getProjectById call changes in the future). - Project np = new Project (); - np.setName (_proj.getName ()); - - np.setType (Project.EDITOR_PROJECT_TYPE); - np.setId (message.getForProjectId ()); - np.setName (message.getForProjectName ()); - - Book b = new Book (np, - np.getName ()); - - np.addBook (b); - - for (Chapter c : chaps) + + return Constants.PROJECT_ICON_NAME; + + } + + @Override + public String getViewerTitle () + { + + return "{Project} sent: " + this.proj.getName (); + + } + + }; + + try + { + + pcv.init (); + + } catch (Exception e) { + + Environment.logError ("Unable to view message: " + + message, + e); + + UIUtils.showErrorMessage (viewer, + "Unable to show message."); + + return; + + } + + parentMessageBox.setChildViewer (pcv); + + pcv.addWindowListener (new WindowAdapter () + { + + public void windowClosed (WindowEvent ev) + { + + parentMessageBox.setChildViewer (null); + + } + + }); + + pcv.showViewer (); + + // XXX Orig + if (true) + { + + return; + + } + */ + AbstractViewer childViewer = parentMessageBox.getChildViewer (); + + if (childViewer != null) + { + + childViewer.setExtendedState (JFrame.NORMAL); + childViewer.toFront (); + + return; + + } + + // Load up the project with the specific text. + // See if we have a project viewer for the project. + ProjectInfo proj = null; + + try + { + + proj = Environment.getProjectById (message.getForProjectId (), + Project.NORMAL_PROJECT_TYPE); + + } catch (Exception e) { + + Environment.logError ("Unable to get project for: " + + message.getForProjectId (), + e); + + UIUtils.showErrorMessage (viewer, + "Unable to show the {project}, please contact Quoll Writer support for assistance."); + + return; + + } + + final ProjectInfo _proj = proj; + + ActionListener open = new ActionListener () + { + + public void actionPerformed (ActionEvent ev) + { + + String pwd = ev.getActionCommand (); + + if (pwd.equals ("")) { - - b.addChapter (c); - + + pwd = null; + } - - final int chapterCount = chaps.size (); - - ProjectSentReceivedViewer pcv = new ProjectSentReceivedViewer (np, - message) + + Set chaps = null; + + try { - - public ProjectSentReceivedSideBar getSideBar () + + chaps = Environment.getVersionedChapters (_proj, + message.getChapters (), + pwd); + + } catch (Exception e) { + + Environment.logError ("Unable to get versioned chapters for project: " + + _proj, + e); + + UIUtils.showErrorMessage (viewer, + "Unable to show {comments}, please contact Quoll Writer support for assistance."); + + return; + + } + + try + { + + // Need to "fill up" the project with the chapters and comments. + // Create a new project object just to be safe (in case the getProjectById call changes in the future). + Project np = new Project (); + np.setName (_proj.getName ()); + + np.setType (Project.EDITOR_PROJECT_TYPE); + np.setId (message.getForProjectId ()); + np.setName (message.getForProjectName ()); + + Book b = new Book (np, + np.getName ()); + + np.addBook (b); + + for (Chapter c : chaps) { - - return new ProjectSentReceivedSideBar (this, - this.message) + + b.addChapter (c); + + } + + final int chapterCount = chaps.size (); + + ProjectSentReceivedViewer pcv = new ProjectSentReceivedViewer (np, + message) + { + + public ProjectSentReceivedSideBar getSideBar () { - - @Override - public void onShow () - { - - } - - @Override - public void onHide () - { - - } - - @Override - public String getTitle () - { - - return "Sent to"; - - } - - @Override - public String getItemsIconType () - { - - return Chapter.OBJECT_TYPE; - - } - - @Override - public String getItemsTitle () - { - - return "{Chapters}"; - - } - - @Override - public int getItemCount () + + return new ProjectSentReceivedSideBar (this, + this.message) { - - return chapterCount; - - } - - @Override - public JComponent getMessageDetails (AbstractProjectMessage message) - { - - final ProjectSentReceivedSideBar _this = this; - - String rows = "p"; - - ProjectVersion projVer = message.getProjectVersion (); - - String verName = projVer.getName (); - - if (verName != null) + + @Override + public void onShow () { - - rows += ", 6px, p"; - + } - - final String notes = (projVer.getDescription () != null ? projVer.getDescription ().getText () : null); - - if (notes != null) + + @Override + public void onHide () { - - rows += ", 6px, top:p"; - + } - - FormLayout fl = new FormLayout ("right:p, 6px, fill:100px:grow", - rows); - - fl.setHonorsVisibility (true); - PanelBuilder builder = new PanelBuilder (fl); - - CellConstraints cc = new CellConstraints (); - - int row = 1; - - builder.addLabel (Environment.replaceObjectNames ("{Sent}"), - cc.xy (1, - row)); - - builder.addLabel ("" + Environment.formatDateTime (message.getWhen ()) + "", - cc.xy (3, - row)); - - row += 2; - - if (verName != null) + + @Override + public String getTitle () { - - builder.addLabel (Environment.replaceObjectNames ("{Version}"), + + return "Sent to"; + + } + + @Override + public String getItemsIconType () + { + + return Chapter.OBJECT_TYPE; + + } + + @Override + public String getItemsTitle () + { + + return "{Chapters}"; + + } + + @Override + public int getItemCount () + { + + return chapterCount; + + } + + @Override + public JComponent getMessageDetails (AbstractProjectMessage message) + { + + final ProjectSentReceivedSideBar _this = this; + + String rows = "p"; + + ProjectVersion projVer = message.getProjectVersion (); + + String verName = projVer.getName (); + + if (verName != null) + { + + rows += ", 6px, p"; + + } + + final String notes = (projVer.getDescription () != null ? projVer.getDescription ().getText () : null); + + if (notes != null) + { + + rows += ", 6px, top:p"; + + } + + FormLayout fl = new FormLayout ("right:p, 6px, fill:100px:grow", + rows); + + fl.setHonorsVisibility (true); + PanelBuilder builder = new PanelBuilder (fl); + + CellConstraints cc = new CellConstraints (); + + int row = 1; + + builder.addLabel (Environment.replaceObjectNames ("{Sent}"), cc.xy (1, row)); - builder.addLabel (String.format ("%s", - verName), + + builder.addLabel ("" + Environment.formatDateTime (message.getWhen ()) + "", cc.xy (3, row)); - + row += 2; - - } - - if (notes != null) - { - - builder.addLabel (Environment.replaceObjectNames ("{Notes}"), - cc.xy (1, - row)); - - String commText = notes; - - TextIterator ti = new TextIterator (commText); - - if (ti.getSentenceCount () > 1) + + if (verName != null) { - - commText = ti.getFirstSentence ().getText (); - - commText += "
More, click to view all."; - + + builder.addLabel (Environment.replaceObjectNames ("{Version}"), + cc.xy (1, + row)); + builder.addLabel (String.format ("%s", + verName), + cc.xy (3, + row)); + + row += 2; + } - - JComponent mess = UIUtils.createHelpTextPane (commText, - this.viewer); - - mess.addMouseListener (new MouseEventHandler () + + if (notes != null) { - - @Override - public void handlePress (MouseEvent ev) + + builder.addLabel (Environment.replaceObjectNames ("{Notes}"), + cc.xy (1, + row)); + + String commText = notes; + + TextIterator ti = new TextIterator (commText); + + if (ti.getSentenceCount () > 1) { - - UIUtils.showMessage ((PopupsSupported) _this.getViewer (), - "Notes", - notes); - + + commText = ti.getFirstSentence ().getText (); + + commText += "
More, click to view all."; + } - - }); - - mess.setBorder (null); - - builder.add (mess, - cc.xy (3, - row)); - + + JComponent mess = UIUtils.createHelpTextPane (commText, + this.viewer); + + mess.addMouseListener (new MouseEventHandler () + { + + @Override + public void handlePress (MouseEvent ev) + { + + UIUtils.showMessage ((PopupsSupported) _this.getViewer (), + "Notes", + notes); + + } + + }); + + mess.setBorder (null); + + builder.add (mess, + cc.xy (3, + row)); + + } + + JPanel bp = builder.getPanel (); + bp.setAlignmentX (Component.LEFT_ALIGNMENT); + bp.setOpaque (false); + + return bp; + } - - JPanel bp = builder.getPanel (); - bp.setAlignmentX (Component.LEFT_ALIGNMENT); - bp.setOpaque (false); - - return bp; - - } - - }; - - } - - @Override - public void init () - throws Exception - { - - super.init (); - - this.viewObject (this.proj.getBook (0).getChapters ().get (0)); - - } - - @Override - public String getViewerIcon () - { - - return Constants.PROJECT_ICON_NAME; - - } - - @Override - public String getViewerTitle () - { - - return "{Project} sent: " + this.proj.getName (); - - } - - }; - - pcv.init (); - - parentMessageBox.setChildViewer (pcv); - - pcv.addWindowListener (new WindowAdapter () - { - - public void windowClosed (WindowEvent ev) + + }; + + } + + @Override + public void init () + throws Exception + { + + super.init (); + + this.viewObject (this.proj.getBook (0).getChapters ().get (0)); + + } + + @Override + public String getViewerIcon () + { + + return Constants.PROJECT_ICON_NAME; + + } + + @Override + public String getViewerTitle () + { + + return "{Project} sent: " + this.proj.getName (); + + } + + }; + + pcv.init (); + + parentMessageBox.setChildViewer (pcv); + + pcv.addWindowListener (new WindowAdapter () { - - parentMessageBox.setChildViewer (null); - - } - - }); - - pcv.showViewer (); - - } catch (Exception e) { - - Environment.logError ("Unable to view project: " + - _proj, - e); - - UIUtils.showErrorMessage (viewer, - "Unable to show {project}, please contact Quoll Writer support for assistance."); - - return; - + + public void windowClosed (WindowEvent ev) + { + + parentMessageBox.setChildViewer (null); + + } + + }); + + pcv.showViewer (); + + } catch (Exception e) { + + Environment.logError ("Unable to view project: " + + _proj, + e); + + UIUtils.showErrorMessage (viewer, + "Unable to show {project}, please contact Quoll Writer support for assistance."); + + return; + + } + } - - } - - }; - - UIUtils.askForPasswordForProject (proj, - null, - open, - viewer); - - }}); + + }; + + UIUtils.askForPasswordForProject (proj, + null, + open, + viewer); + + }}); + + } viewProj.setBorder (UIUtils.createPadding (0, 10, 0, 0)); diff --git a/src/com/quollwriter/editors/ui/ProjectCommentsChaptersAccordionItem.java b/src/com/quollwriter/editors/ui/ProjectCommentsChaptersAccordionItem.java index 4f26b842..86ba8fcd 100644 --- a/src/com/quollwriter/editors/ui/ProjectCommentsChaptersAccordionItem.java +++ b/src/com/quollwriter/editors/ui/ProjectCommentsChaptersAccordionItem.java @@ -6,6 +6,7 @@ import java.awt.dnd.*; import java.util.Date; +import java.util.Set; import java.util.List; import java.util.ArrayList; import java.util.Enumeration; @@ -119,13 +120,13 @@ public void fillTreePopupMenu (JPopupMenu m, final AbstractProjectViewer pv = this.viewer; + final DefaultMutableTreeNode node = (DefaultMutableTreeNode) tp.getLastPathComponent (); + JMenuItem mi = null; if (tp != null) { - final DefaultMutableTreeNode node = (DefaultMutableTreeNode) tp.getLastPathComponent (); - final DataObject d = (DataObject) node.getUserObject (); if (d instanceof Note) @@ -133,22 +134,28 @@ public void fillTreePopupMenu (JPopupMenu m, final Note n = (Note) d; - m.add (UIUtils.createMenuItem (String.format ("Set %s with", - (n.isDealtWith () ? "Undealt" : "Dealt")), - Constants.VIEW_ICON_NAME, - new ActionAdapter () - { - - public void actionPerformed (ActionEvent ev) - { - - n.setDealtWith (n.isDealtWith () ? null : new Date ()); - - _this.update (); - - } - - })); + // Is this a project we have sent? + if (!this.viewer.getMessage ().isSentByMe ()) + { + + m.add (UIUtils.createMenuItem (String.format ("Set %s with", + (n.isDealtWith () ? "undealt" : "dealt")), + Constants.VIEW_ICON_NAME, + new ActionAdapter () + { + + public void actionPerformed (ActionEvent ev) + { + + n.setDealtWith (n.isDealtWith () ? null : new Date ()); + + _this.update (); + + } + + })); + + } m.add (UIUtils.createMenuItem ("View", Constants.VIEW_ICON_NAME, @@ -173,6 +180,84 @@ public void actionPerformed (ActionEvent ev) final String chapterObjTypeName = Environment.getObjectTypeName (c); + // Is this a project we have sent? + if (!this.viewer.getMessage ().isSentByMe ()) + { + + int nc = 0; + + final Set notes = c.getNotes (); + + for (Note n : notes) + { + + if (n.isDealtWith ()) + { + + nc++; + + } + + } + + if (nc > 0) + { + + m.add (UIUtils.createMenuItem ("Set all undealt with", + Constants.SET_UNDEALT_WITH_ICON_NAME, + new ActionListener () + { + + @Override + public void actionPerformed (ActionEvent ev) + { + + for (Note n : notes) + { + + n.setDealtWith (null); + + } + + _this.update (); + + } + + })); + + } + + if (nc != notes.size ()) + { + + m.add (UIUtils.createMenuItem ("Set all dealt with", + Constants.SET_DEALT_WITH_ICON_NAME, + new ActionListener () + { + + @Override + public void actionPerformed (ActionEvent ev) + { + + Date d = new Date (); + + for (Note n : notes) + { + + n.setDealtWith (d); + + } + + _this.update (); + + } + + })); + + } + + } + m.add (UIUtils.createMenuItem ("View {Chapter}", Constants.EDIT_ICON_NAME, pv.getAction (ProjectViewer.EDIT_CHAPTER_ACTION, diff --git a/src/com/quollwriter/editors/ui/ProjectSentReceivedViewer.java b/src/com/quollwriter/editors/ui/ProjectSentReceivedViewer.java index 00bbddfa..9fa643b2 100644 --- a/src/com/quollwriter/editors/ui/ProjectSentReceivedViewer.java +++ b/src/com/quollwriter/editors/ui/ProjectSentReceivedViewer.java @@ -165,7 +165,8 @@ public Set getTools (Note item, final JButton but = UIUtils.createButton ((item.isDealtWith () ? Constants.SET_UNDEALT_WITH_ICON_NAME : Constants.SET_DEALT_WITH_ICON_NAME), Constants.ICON_MENU, - "Click to mark the {comment} as dealt with", + String.format ("Click to mark the {comment} as %s with", + (item.isDealtWith () ? "undealt" : "dealt")), null); ActionListener aa = new ActionListener () @@ -186,6 +187,8 @@ public void actionPerformed (ActionEvent ev) item.setDealtWith (d); + but.setToolTipText (String.format ("Click to mark the {comment} as %s with", + (item.isDealtWith () ? "undealt" : "dealt"))); but.setIcon (Environment.getIcon ((item.isDealtWith () ? Constants.SET_UNDEALT_WITH_ICON_NAME : Constants.SET_DEALT_WITH_ICON_NAME), Constants.ICON_MENU)); @@ -231,7 +234,14 @@ public ImageIcon getIcon (String name, this.sideBar = this.getSideBar (); } + + public E getMessage () + { + + return this.message; + } + public abstract ProjectSentReceivedSideBar getSideBar (); public void close () diff --git a/src/com/quollwriter/editors/ui/panels/ChapterCommentsPanel.java b/src/com/quollwriter/editors/ui/panels/ChapterCommentsPanel.java index 8e231abe..96ed3d68 100644 --- a/src/com/quollwriter/editors/ui/panels/ChapterCommentsPanel.java +++ b/src/com/quollwriter/editors/ui/panels/ChapterCommentsPanel.java @@ -19,6 +19,8 @@ import javax.swing.undo.*; import java.awt.datatransfer.*; +//import org.incava.util.diff.*; + import com.gentlyweb.properties.*; import com.jgoodies.forms.builder.*; @@ -97,6 +99,87 @@ public void scrollCaretIntoView () } + /* + public void showDifferences (Chapter c) + { + + BlockPainter newp = new BlockPainter (Color.GREEN); + BlockPainter modp = new BlockPainter (Color.YELLOW); + BlockPainter oldp = new BlockPainter (Color.RED); + + String ot = TextUtilities.stripNonValidXMLCharacters (this.editor.getTextWithMarkup ().getText ()); + + String nt = TextUtilities.stripNonValidXMLCharacters (c.getText ().getText ()); + + this.editor.setTextWithMarkup (c.getText ()); + + String[] oldText = ot.split ("\\n"); + String[] newText = nt.split ("\\n"); +System.out.println ("OT: " + ot); +System.out.println ("NT: " + nt); +//LinkedList +diff_match_patch dmp = new diff_match_patch (); + System.out.println ("DIFF2: " + dmp.patch_make(ot, nt)); + + List diffs = new Diff (oldText, + newText).diff (); +System.out.println ("DIFF: " + diffs); + for (int i = 0; i < diffs.size (); i++) + { + + Difference d = (Difference) diffs.get (i); + + if (d.getDeletedEnd () == Difference.NONE) + { + + // This is an addition. + for (int k = d.getAddedStart (); k < (d.getAddedEnd () + 1); k++) + { + + this.editor.addHighlight (d.getAddedStart (), + d.getAddedEnd (), + newp, + false); + + } + + continue; + + } + + if (d.getAddedEnd () == Difference.NONE) + { + + // This is a deletion. + for (int k = d.getDeletedStart (); k < (d.getDeletedEnd () + 1); k++) + { + + this.editor.addHighlight (d.getDeletedStart (), + d.getDeletedEnd (), + oldp, + false); + + } + + continue; + + } + + // This is a modification. + for (int k = d.getAddedStart (); k < (d.getAddedEnd () + 1); k++) + { + + this.editor.addHighlight (d.getAddedStart (), + d.getAddedEnd (), + modp, + false); + + } + + } + + } + */ @Override public void setState (final Map s, boolean hasFocus) diff --git a/src/com/quollwriter/editors/ui/sidebars/ProjectCommentsSideBar.java b/src/com/quollwriter/editors/ui/sidebars/ProjectCommentsSideBar.java index e7b68be6..af2378bf 100644 --- a/src/com/quollwriter/editors/ui/sidebars/ProjectCommentsSideBar.java +++ b/src/com/quollwriter/editors/ui/sidebars/ProjectCommentsSideBar.java @@ -55,7 +55,8 @@ public void onShow () public String getTitle () { - return "{Comments} from"; + return String.format ("{Comments} %s", + (this.message.isSentByMe () ? "to" : "from")); } @@ -127,7 +128,8 @@ public JComponent getMessageDetails (ProjectCommentsMessage message) int row = 1; - builder.addLabel (Environment.replaceObjectNames ("{Received}"), + builder.addLabel (Environment.replaceObjectNames (String.format ("{%s}", + (this.message.isSentByMe () ? "Sent" : "Received"))), cc.xy (1, row)); diff --git a/src/com/quollwriter/editors/ui/sidebars/ProjectSentReceivedSideBar.java b/src/com/quollwriter/editors/ui/sidebars/ProjectSentReceivedSideBar.java index ab5eda19..13514180 100644 --- a/src/com/quollwriter/editors/ui/sidebars/ProjectSentReceivedSideBar.java +++ b/src/com/quollwriter/editors/ui/sidebars/ProjectSentReceivedSideBar.java @@ -96,6 +96,14 @@ public void init () this.chapters = new ProjectCommentsChaptersAccordionItem (this.viewer) { + @Override + public boolean isAllowObjectPreview () + { + + return false; + + } + @Override public int getItemCount () { @@ -105,7 +113,7 @@ public int getItemCount () } }; - + this.chapters.setIconType (this.getItemsIconType ()); this.chapters.setTitle (this.getItemsTitle ()); diff --git a/src/com/quollwriter/ui/NamedObjectPreviewPopup.java b/src/com/quollwriter/ui/NamedObjectPreviewPopup.java index 2ade7a84..3041aff8 100644 --- a/src/com/quollwriter/ui/NamedObjectPreviewPopup.java +++ b/src/com/quollwriter/ui/NamedObjectPreviewPopup.java @@ -91,6 +91,14 @@ public JComponent getContent () null, this.viewer); + if (t == null) + { + + // May be a fake chapter, return null. + return null; + + } + t.setSize (new Dimension (300, Short.MAX_VALUE)); diff --git a/src/com/quollwriter/ui/UIUtils.java b/src/com/quollwriter/ui/UIUtils.java index 6ff7bb15..0ecf2c38 100644 --- a/src/com/quollwriter/ui/UIUtils.java +++ b/src/com/quollwriter/ui/UIUtils.java @@ -9159,6 +9159,8 @@ public static void askForPasswordForProject (final ProjectInfo proj, AbstractProjectViewer pv = Environment.getProjectViewer (proj); if ((pv == null) + && + (proj != null) && (proj.isEncrypted ()) )