Addendum to r20 (missing file)
------------------------------------------------------------------------ r1638 | chrisg23 | 2007-09-17 13:48:34 +0200 (Mo, 17 Sep 2007) | 1 line Sourceforge patch 1796156 - allow notes to be shown on basic properties authoring step files in ccm-cms-assets-notes had been forgotten in commit. git-svn-id: https://svn.libreccm.org/ccm/trunk@20 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
0e8c302c48
commit
909b390f72
|
|
@ -16,12 +16,23 @@ model com.arsdigita.london.notes;
|
|||
|
||||
import com.arsdigita.cms.ContentItem;
|
||||
import com.arsdigita.kernel.ACSObject;
|
||||
import com.arsdigita.auditing.BasicAuditTrail;
|
||||
|
||||
object type Note extends ACSObject {
|
||||
String[0..1] content = ca_notes.content CLOB;
|
||||
Long[1..1] rank = ca_notes.rank;
|
||||
|
||||
reference key ( ca_notes.note_id );
|
||||
|
||||
// Basic auditing info
|
||||
unversioned BasicAuditTrail[0..1] auditing =
|
||||
qualias { filter(all(com.arsdigita.auditing.BasicAuditTrail),
|
||||
id == this.id) };
|
||||
aggressive load(auditing.id,
|
||||
auditing.creationDate,
|
||||
auditing.creationIP,
|
||||
auditing.lastModifiedDate,
|
||||
auditing.lastModifiedIP);
|
||||
}
|
||||
|
||||
association {
|
||||
|
|
|
|||
|
|
@ -7,11 +7,15 @@
|
|||
<!-- First off the adapters for ContentItemPanel -->
|
||||
<xrd:context name="com.arsdigita.cms.dispatcher.SimpleXMLGenerator">
|
||||
<xrd:adapter objectType="com.arsdigita.london.notes.Note">
|
||||
<xrd:attributes rule="exclude">
|
||||
<!-- <xrd:attributes rule="exclude">
|
||||
<xrd:property name="/object/defaultDomainClass"/>
|
||||
<xrd:property name="/object/objectType"/>
|
||||
<xrd:property name="/object/displayName"/>
|
||||
</xrd:attributes>
|
||||
|
||||
-->
|
||||
<xrd:attributes rule="include">
|
||||
</xrd:attributes>
|
||||
</xrd:adapter>
|
||||
</xrd:context>
|
||||
|
||||
|
|
@ -19,12 +23,15 @@
|
|||
<!-- Adapter for search -->
|
||||
<xrd:context name="com.arsdigita.cms.search.ContentPageMetadataProvider">
|
||||
<xrd:adapter objectType="com.arsdigita.london.notes.Note">
|
||||
<xrd:attributes rule="exclude">
|
||||
<!-- <xrd:attributes rule="exclude">
|
||||
<xrd:property name="/object/id"/>
|
||||
<xrd:property name="/object/defaultDomainClass"/>
|
||||
<xrd:property name="/object/displayName"/>
|
||||
<xrd:property name="/object/rank"/>
|
||||
</xrd:attributes> -->
|
||||
<xrd:attributes rule="include">
|
||||
</xrd:attributes>
|
||||
|
||||
</xrd:adapter>
|
||||
</xrd:context>
|
||||
|
||||
|
|
|
|||
|
|
@ -16,11 +16,16 @@
|
|||
|
||||
package com.arsdigita.london.notes;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.arsdigita.auditing.AuditingObserver;
|
||||
import com.arsdigita.auditing.BasicAuditTrail;
|
||||
import com.arsdigita.cms.ContentItem;
|
||||
import com.arsdigita.domain.DomainObject;
|
||||
import com.arsdigita.domain.DomainObjectFactory;
|
||||
import com.arsdigita.domain.DomainObjectInstantiator;
|
||||
import com.arsdigita.kernel.ACSObject;
|
||||
import com.arsdigita.kernel.User;
|
||||
import com.arsdigita.kernel.permissions.PermissionService;
|
||||
import com.arsdigita.persistence.DataCollection;
|
||||
import com.arsdigita.persistence.DataObject;
|
||||
|
|
@ -55,6 +60,11 @@ public class Note extends ACSObject {
|
|||
public static final String RANK = "rank";
|
||||
public static final String OWNER = "owner";
|
||||
public static final String NOTES = "ca_notes";
|
||||
public static final String AUDIT = "auditing";
|
||||
public static final String CREATION_DATE = AUDIT + "." + BasicAuditTrail.CREATION_DATE;
|
||||
|
||||
|
||||
private BasicAuditTrail auditTrail;
|
||||
|
||||
private boolean m_isNew = false;
|
||||
|
||||
|
|
@ -81,6 +91,25 @@ public class Note extends ACSObject {
|
|||
return note;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register auditing observer
|
||||
* (non-Javadoc)
|
||||
* @see com.arsdigita.domain.DomainObject#initialize()
|
||||
*/
|
||||
protected void initialize() {
|
||||
super.initialize();
|
||||
|
||||
DataObject dataObj = (DataObject) get(AUDIT);
|
||||
if (dataObj != null) {
|
||||
auditTrail = new BasicAuditTrail(dataObj);
|
||||
} else {
|
||||
// creates a new one when one doesn't already exist
|
||||
auditTrail = BasicAuditTrail.retrieveForACSObject(this);
|
||||
}
|
||||
|
||||
addObserver(new AuditingObserver(auditTrail));
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return (String) get( CONTENT );
|
||||
}
|
||||
|
|
@ -131,6 +160,14 @@ public class Note extends ACSObject {
|
|||
return (ContentItem) DomainObjectFactory.newInstance( obj );
|
||||
}
|
||||
|
||||
public User getNoteAuthor () {
|
||||
return auditTrail.getCreationUser();
|
||||
}
|
||||
|
||||
public Date getCreationDate () {
|
||||
return auditTrail.getCreationDate();
|
||||
}
|
||||
|
||||
public static DataCollection getNotes( ContentItem item ) {
|
||||
Assert.exists( item, ContentItem.class );
|
||||
|
||||
|
|
|
|||
|
|
@ -16,16 +16,17 @@
|
|||
|
||||
package com.arsdigita.london.notes;
|
||||
|
||||
import com.arsdigita.cms.contenttypes.ContentAssetInitializer;
|
||||
import com.arsdigita.cms.ContentPage;
|
||||
import com.arsdigita.cms.ContentType;
|
||||
import com.arsdigita.cms.contenttypes.ContentAssetInitializer;
|
||||
import com.arsdigita.cms.dispatcher.SimpleXMLGenerator;
|
||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
||||
import com.arsdigita.domain.DomainObjectTraversal;
|
||||
import com.arsdigita.domain.SimpleDomainObjectTraversalAdapter;
|
||||
import com.arsdigita.globalization.GlobalizedMessage;
|
||||
import com.arsdigita.runtime.LegacyInitEvent;
|
||||
|
||||
import com.arsdigita.london.notes.ui.NotesStep;
|
||||
import com.arsdigita.london.notes.ui.NotesSummary;
|
||||
import com.arsdigita.runtime.LegacyInitEvent;
|
||||
|
||||
public class NotesInitializer extends ContentAssetInitializer {
|
||||
public NotesInitializer() {
|
||||
|
|
@ -73,5 +74,6 @@ public class NotesInitializer extends ContentAssetInitializer {
|
|||
DomainObjectTraversal.registerAdapter( Note.BASE_DATA_OBJECT_TYPE,
|
||||
new SimpleDomainObjectTraversalAdapter(),
|
||||
SimpleXMLGenerator.ADAPTER_CONTEXT );
|
||||
SimpleEditStep.addAdditionalDisplayComponent(new NotesSummary());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import com.arsdigita.bebop.form.Submit;
|
|||
import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
||||
import com.arsdigita.bebop.parameters.StringParameter;
|
||||
import com.arsdigita.cms.CMS;
|
||||
import com.arsdigita.cms.ContentSection;
|
||||
import com.arsdigita.kernel.ui.ACSObjectSelectionModel;
|
||||
|
||||
import com.arsdigita.london.notes.Note;
|
||||
|
|
@ -53,7 +54,7 @@ public class NotesEdit extends SimpleContainer {
|
|||
StringParameter contentParam = new StringParameter( "content" );
|
||||
contentParam.addParameterListener( new NotNullValidationListener() );
|
||||
|
||||
final DHTMLEditor content = new DHTMLEditor( contentParam );
|
||||
final DHTMLEditor content = new DHTMLEditor( contentParam,ContentSection.getConfig().getDHTMLEditorConfig() );
|
||||
content.setRows( 20 );
|
||||
|
||||
m_form.add( content );
|
||||
|
|
|
|||
|
|
@ -0,0 +1,135 @@
|
|||
package com.arsdigita.london.notes.ui;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import com.arsdigita.bebop.Component;
|
||||
import com.arsdigita.bebop.Label;
|
||||
import com.arsdigita.bebop.PageState;
|
||||
import com.arsdigita.bebop.Table;
|
||||
import com.arsdigita.bebop.table.TableCellRenderer;
|
||||
import com.arsdigita.bebop.table.TableColumn;
|
||||
import com.arsdigita.bebop.table.TableColumnModel;
|
||||
import com.arsdigita.bebop.table.TableModel;
|
||||
import com.arsdigita.bebop.table.TableModelBuilder;
|
||||
import com.arsdigita.cms.ContentItem;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.ui.authoring.AdditionalDisplayComponent;
|
||||
import com.arsdigita.domain.DomainObjectFactory;
|
||||
import com.arsdigita.kernel.User;
|
||||
import com.arsdigita.london.notes.Note;
|
||||
import com.arsdigita.persistence.DataCollection;
|
||||
import com.arsdigita.util.LockableImpl;
|
||||
|
||||
public class NotesSummary extends Table implements AdditionalDisplayComponent {
|
||||
|
||||
private ItemSelectionModel m_itemSelectionModel;
|
||||
|
||||
public NotesSummary() {
|
||||
super();
|
||||
setModelBuilder(new NotesTableBuilder());
|
||||
TableColumnModel model = getColumnModel();
|
||||
model.add( new TableColumn( 0, "Note" ));
|
||||
model.add( new TableColumn( 1, "Date" ));
|
||||
model.add( new TableColumn( 2, "By" ));
|
||||
setRowSelectionModel(null);
|
||||
setColumnSelectionModel(null);
|
||||
model.get(0).setCellRenderer(new TableCellRenderer() {
|
||||
|
||||
public Component getComponent(Table table, PageState state, Object value, boolean isSelected, Object key, int row, int column) {
|
||||
Label t = new Label((String)value);
|
||||
t.setOutputEscaping(false);
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void setItemSelectionModel(ItemSelectionModel model) {
|
||||
m_itemSelectionModel = model;
|
||||
}
|
||||
|
||||
private class NotesTableBuilder extends LockableImpl implements TableModelBuilder {
|
||||
|
||||
|
||||
public TableModel makeModel(Table t, PageState state) {
|
||||
return new NotesTableModel(m_itemSelectionModel.getSelectedItem(state));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private class NotesTableModel implements TableModel {
|
||||
|
||||
private DataCollection m_notes = null;
|
||||
private Note m_currentNote;
|
||||
|
||||
public NotesTableModel (ContentItem item) {
|
||||
if (item != null) {
|
||||
m_notes = Note.getNotes(item);
|
||||
// cg already ordered by rank m_notes.addOrder(Note.CREATION_DATE + " desc");
|
||||
}
|
||||
}
|
||||
public int getColumnCount() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
public Object getElementAt(int columnIndex) {
|
||||
switch (columnIndex) {
|
||||
case 0:
|
||||
return m_currentNote.getContent();
|
||||
|
||||
|
||||
case 1:
|
||||
String displayDate = "Not recorded";
|
||||
Date creationDate = m_currentNote.getCreationDate();
|
||||
if (creationDate != null) {
|
||||
displayDate = DateFormat.getDateInstance(DateFormat.MEDIUM).format(creationDate);
|
||||
}
|
||||
return displayDate;
|
||||
|
||||
|
||||
case 2:
|
||||
String displayAuthor = "Not recorded";
|
||||
User author = m_currentNote.getNoteAuthor();
|
||||
if (author != null) {
|
||||
displayAuthor = author.getName();
|
||||
}
|
||||
return displayAuthor;
|
||||
|
||||
default :
|
||||
throw new IndexOutOfBoundsException(
|
||||
"Column index " + columnIndex + " not in table model.");
|
||||
}
|
||||
}
|
||||
|
||||
public Object getKeyAt(int columnIndex) {
|
||||
return m_currentNote.getID();
|
||||
}
|
||||
|
||||
public boolean nextRow () {
|
||||
if ( m_notes.next() ) {
|
||||
m_currentNote = (Note)DomainObjectFactory.newInstance(m_notes.getDataObject());
|
||||
return true;
|
||||
} else {
|
||||
m_notes.close();
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue