Skip to content

Commit

Permalink
Changes:
Browse files Browse the repository at this point in the history
1. Actually save the dealt with date, which is handled by adding a property changed listener on the dealt with property.

2. If a project has been deleted for a message then show a warning instead of offering to show the message.
  • Loading branch information
garybentley committed Nov 11, 2016
1 parent 13f585d commit 5b0f69f
Show file tree
Hide file tree
Showing 13 changed files with 946 additions and 352 deletions.
7 changes: 7 additions & 0 deletions src/com/quollwriter/data/Note.java
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ public AbstractProjectMessage (Project project,

}

public abstract Project createProject ()
throws Exception;


@Override
public void fillToStringProperties (Map<String, Object> props)
{
Expand Down
5 changes: 5 additions & 0 deletions src/com/quollwriter/editors/messages/NewProjectMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Chapter> 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 ());
Expand Down
31 changes: 30 additions & 1 deletion src/com/quollwriter/editors/messages/ProjectCommentsMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
import java.util.*;

import com.quollwriter.*;
import com.quollwriter.events.*;
import com.quollwriter.text.*;
import com.quollwriter.data.*;
import com.quollwriter.data.editors.*;
import com.quollwriter.editors.*;

/**
*/
public class ProjectCommentsMessage extends EditorMessage
public class ProjectCommentsMessage extends EditorMessage implements PropertyChangedListener
{

public static final String MESSAGE_TYPE = "project-comments";
Expand Down Expand Up @@ -186,6 +187,32 @@ public Set<Note> 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
{
Expand Down Expand Up @@ -296,6 +323,8 @@ protected void doInit (Map data,

Note n = TypeEncoder.decodeToNote (cm);

n.addPropertyChangedListener (this);

comments.add (n);

}
Expand Down
70 changes: 70 additions & 0 deletions src/com/quollwriter/editors/messages/UpdateProjectMessage.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Chapter> 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<String, Object> props)
{
Expand Down
Loading

0 comments on commit 5b0f69f

Please sign in to comment.