Notes testet jetzt den Bearbeitungsstatus (Ticket #119)

git-svn-id: https://svn.libreccm.org/ccm/trunk@1587 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2012-04-12 10:01:39 +00:00
parent fccc6ba631
commit 21dfb7fec1
2 changed files with 95 additions and 94 deletions

View File

@ -1,19 +1,18 @@
/* /*
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public License modify it under the terms of the GNU Lesser General Public License
as published by the Free Software Foundation; either version 2.1 of as published by the Free Software Foundation; either version 2.1 of
the License, or (at your option) any later version. the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details. Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package com.arsdigita.cms.contentassets.ui; package com.arsdigita.cms.contentassets.ui;
import com.arsdigita.bebop.PageState; import com.arsdigita.bebop.PageState;
@ -31,133 +30,134 @@ import com.arsdigita.web.RedirectSignal;
import com.arsdigita.xml.Element; import com.arsdigita.xml.Element;
import com.arsdigita.cms.contentassets.Note; import com.arsdigita.cms.contentassets.Note;
import com.arsdigita.cms.util.SecurityConstants;
import com.arsdigita.kernel.Kernel;
import com.arsdigita.kernel.User;
import com.arsdigita.workflow.simple.Workflow;
import java.io.IOException; import java.io.IOException;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
public class NotesDisplay extends SimpleComponent { public class NotesDisplay extends SimpleComponent {
private static final Logger s_log = Logger.getLogger( NotesDisplay.class );
private static final Logger s_log = Logger.getLogger(NotesDisplay.class);
private static final String DELETE = "delete"; private static final String DELETE = "delete";
private static final String EDIT = "edit"; private static final String EDIT = "edit";
private static final String UP = "up"; private static final String UP = "up";
private static final String DOWN = "down"; private static final String DOWN = "down";
private NotesStep m_step; private NotesStep m_step;
private ACSObjectSelectionModel m_noteModel; private ACSObjectSelectionModel m_noteModel;
public NotesDisplay( NotesStep step, public NotesDisplay(NotesStep step,
ACSObjectSelectionModel noteModel ) { ACSObjectSelectionModel noteModel) {
super(); super();
m_step = step; m_step = step;
m_noteModel = noteModel; m_noteModel = noteModel;
} }
public void respond( PageState ps ) { public void respond(PageState ps) {
String name = ps.getControlEventName(); String name = ps.getControlEventName();
String value = ps.getControlEventValue(); String value = ps.getControlEventValue();
if( s_log.isDebugEnabled() ) { if (s_log.isDebugEnabled()) {
s_log.debug( "Action " + name + " on note " + value ); s_log.debug("Action " + name + " on note " + value);
} }
OID oid = OID.valueOf( value ); OID oid = OID.valueOf(value);
Note note = (Note) DomainObjectFactory.newInstance( oid ); Note note = (Note) DomainObjectFactory.newInstance(oid);
if( DELETE.equals( name ) ) { if (DELETE.equals(name)) {
note.delete(); note.delete();
} } else if (EDIT.equals(name)) {
m_noteModel.setSelectedObject(ps, note);
else if( EDIT.equals( name ) ) { m_step.showComponent(ps, NotesStep.EDIT);
m_noteModel.setSelectedObject( ps, note ); } else if (UP.equals(name)) {
m_step.showComponent( ps, NotesStep.EDIT ); note.setRank(note.getRank() - 1);
} } else if (DOWN.equals(name)) {
note.setRank(note.getRank() + 1);
else if( UP.equals( name ) ) {
note.setRank( note.getRank() - 1 );
}
else if( DOWN.equals( name ) ) {
note.setRank( note.getRank() + 1 );
} }
ps.clearControlEvent(); ps.clearControlEvent();
try { try {
throw new RedirectSignal( ps.stateAsURL(), true ); throw new RedirectSignal(ps.stateAsURL(), true);
} catch( IOException ex ) { } catch (IOException ex) {
throw new UncheckedWrapperException( ex ); throw new UncheckedWrapperException(ex);
} }
} }
public void generateXML( PageState ps, Element parent ) { public void generateXML(PageState ps, Element parent) {
Element root = parent.newChildElement( "cms:notesDisplay", Element root = parent.newChildElement("cms:notesDisplay",
CMS.CMS_XML_NS ); CMS.CMS_XML_NS);
ContentItem item = m_step.getItem( ps ); ContentItem item = m_step.getItem(ps);
DataCollection notes = Note.getNotes( item ); DataCollection notes = Note.getNotes(item);
if( s_log.isDebugEnabled() ) { if (s_log.isDebugEnabled()) {
s_log.debug( "NotesDisplay.generateXML" ); s_log.debug("NotesDisplay.generateXML");
} }
DomainObjectXMLRenderer xr = new DomainObjectXMLRenderer( root ); DomainObjectXMLRenderer xr = new DomainObjectXMLRenderer(root);
xr.setWrapRoot( true ); xr.setWrapRoot(true);
xr.setWrapAttributes( true ); xr.setWrapAttributes(true);
xr.setWrapObjects( true ); xr.setWrapObjects(true);
while( notes.next() ) { while (notes.next()) {
Note note = new Note( notes.getDataObject() ); Note note = new Note(notes.getDataObject());
String oid = note.getOID().toString(); String oid = note.getOID().toString();
Element edit = root.newChildElement( "cms:notesAction", if (CMS.getSecurityManager(ps).canAccess(ps.getRequest(),
CMS.CMS_XML_NS ); SecurityConstants.EDIT_ITEM,
edit.addAttribute( "action", EDIT ); item)) {
edit.addAttribute( "oid", oid ); Element edit = root.newChildElement("cms:notesAction",
ps.setControlEvent( this, EDIT, oid ); CMS.CMS_XML_NS);
try { edit.addAttribute("action", EDIT);
edit.addAttribute( "href", ps.stateAsURL() ); edit.addAttribute("oid", oid);
} catch( IOException ex ) { ps.setControlEvent(this, EDIT, oid);
throw new UncheckedWrapperException( ex ); try {
} edit.addAttribute("href", ps.stateAsURL());
} catch (IOException ex) {
throw new UncheckedWrapperException(ex);
}
Element delete = root.newChildElement( "cms:notesAction", Element delete = root.newChildElement("cms:notesAction",
CMS.CMS_XML_NS ); CMS.CMS_XML_NS);
delete.addAttribute( "action", DELETE ); delete.addAttribute("action", DELETE);
delete.addAttribute( "oid", oid ); delete.addAttribute("oid", oid);
ps.setControlEvent( this, DELETE, oid ); ps.setControlEvent(this, DELETE, oid);
try { try {
delete.addAttribute( "href", ps.stateAsURL() ); delete.addAttribute("href", ps.stateAsURL());
} catch( IOException ex ) { } catch (IOException ex) {
throw new UncheckedWrapperException( ex ); throw new UncheckedWrapperException(ex);
} }
Element up = root.newChildElement( "cms:notesAction", Element up = root.newChildElement("cms:notesAction",
CMS.CMS_XML_NS ); CMS.CMS_XML_NS);
up.addAttribute( "action", UP ); up.addAttribute("action", UP);
up.addAttribute( "oid", oid ); up.addAttribute("oid", oid);
ps.setControlEvent( this, UP, oid ); ps.setControlEvent(this, UP, oid);
try { try {
up.addAttribute( "href", ps.stateAsURL() ); up.addAttribute("href", ps.stateAsURL());
} catch( IOException ex ) { } catch (IOException ex) {
throw new UncheckedWrapperException( ex ); throw new UncheckedWrapperException(ex);
} }
Element down = root.newChildElement( "cms:notesAction", Element down = root.newChildElement("cms:notesAction",
CMS.CMS_XML_NS ); CMS.CMS_XML_NS);
down.addAttribute( "action", DOWN ); down.addAttribute("action", DOWN);
down.addAttribute( "oid", oid ); down.addAttribute("oid", oid);
ps.setControlEvent( this, DOWN, oid ); ps.setControlEvent(this, DOWN, oid);
try { try {
down.addAttribute( "href", ps.stateAsURL() ); down.addAttribute("href", ps.stateAsURL());
} catch( IOException ex ) { } catch (IOException ex) {
throw new UncheckedWrapperException( ex ); throw new UncheckedWrapperException(ex);
}
} }
ps.clearControlEvent(); ps.clearControlEvent();
xr.walk( note, SimpleXMLGenerator.ADAPTER_CONTEXT ); xr.walk(note, SimpleXMLGenerator.ADAPTER_CONTEXT);
} }
} }
} }

View File

@ -55,6 +55,7 @@ public class NotesStep extends SecurityPropertyEditor {
return m_itemModel.getSelectedItem( ps ); return m_itemModel.getSelectedItem( ps );
} }
@Override
public void register( Page p ) { public void register( Page p ) {
super.register( p ); super.register( p );