Notes testet jetzt den Bearbeitungsstatus (Ticket #119)
git-svn-id: https://svn.libreccm.org/ccm/trunk@1587 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
fccc6ba631
commit
21dfb7fec1
|
|
@ -1,19 +1,18 @@
|
|||
/*
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public License
|
||||
as published by the Free Software Foundation; either version 2.1 of
|
||||
the License, or (at your option) any later version.
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public License
|
||||
as published by the Free Software Foundation; either version 2.1 of
|
||||
the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
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
|
||||
*/
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
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
|
||||
*/
|
||||
package com.arsdigita.cms.contentassets.ui;
|
||||
|
||||
import com.arsdigita.bebop.PageState;
|
||||
|
|
@ -31,133 +30,134 @@ import com.arsdigita.web.RedirectSignal;
|
|||
import com.arsdigita.xml.Element;
|
||||
|
||||
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 org.apache.log4j.Logger;
|
||||
|
||||
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 EDIT = "edit";
|
||||
private static final String UP = "up";
|
||||
private static final String DOWN = "down";
|
||||
|
||||
private NotesStep m_step;
|
||||
private ACSObjectSelectionModel m_noteModel;
|
||||
|
||||
public NotesDisplay( NotesStep step,
|
||||
ACSObjectSelectionModel noteModel ) {
|
||||
public NotesDisplay(NotesStep step,
|
||||
ACSObjectSelectionModel noteModel) {
|
||||
super();
|
||||
|
||||
m_step = step;
|
||||
m_noteModel = noteModel;
|
||||
}
|
||||
|
||||
public void respond( PageState ps ) {
|
||||
public void respond(PageState ps) {
|
||||
String name = ps.getControlEventName();
|
||||
String value = ps.getControlEventValue();
|
||||
|
||||
if( s_log.isDebugEnabled() ) {
|
||||
s_log.debug( "Action " + name + " on note " + value );
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("Action " + name + " on note " + value);
|
||||
}
|
||||
|
||||
OID oid = OID.valueOf( value );
|
||||
Note note = (Note) DomainObjectFactory.newInstance( oid );
|
||||
OID oid = OID.valueOf(value);
|
||||
Note note = (Note) DomainObjectFactory.newInstance(oid);
|
||||
|
||||
if( DELETE.equals( name ) ) {
|
||||
if (DELETE.equals(name)) {
|
||||
note.delete();
|
||||
}
|
||||
|
||||
else if( EDIT.equals( name ) ) {
|
||||
m_noteModel.setSelectedObject( ps, note );
|
||||
m_step.showComponent( ps, NotesStep.EDIT );
|
||||
}
|
||||
|
||||
else if( UP.equals( name ) ) {
|
||||
note.setRank( note.getRank() - 1 );
|
||||
}
|
||||
|
||||
else if( DOWN.equals( name ) ) {
|
||||
note.setRank( note.getRank() + 1 );
|
||||
} else if (EDIT.equals(name)) {
|
||||
m_noteModel.setSelectedObject(ps, note);
|
||||
m_step.showComponent(ps, NotesStep.EDIT);
|
||||
} else if (UP.equals(name)) {
|
||||
note.setRank(note.getRank() - 1);
|
||||
} else if (DOWN.equals(name)) {
|
||||
note.setRank(note.getRank() + 1);
|
||||
}
|
||||
|
||||
ps.clearControlEvent();
|
||||
try {
|
||||
throw new RedirectSignal( ps.stateAsURL(), true );
|
||||
} catch( IOException ex ) {
|
||||
throw new UncheckedWrapperException( ex );
|
||||
throw new RedirectSignal(ps.stateAsURL(), true);
|
||||
} catch (IOException ex) {
|
||||
throw new UncheckedWrapperException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void generateXML( PageState ps, Element parent ) {
|
||||
Element root = parent.newChildElement( "cms:notesDisplay",
|
||||
CMS.CMS_XML_NS );
|
||||
public void generateXML(PageState ps, Element parent) {
|
||||
Element root = parent.newChildElement("cms:notesDisplay",
|
||||
CMS.CMS_XML_NS);
|
||||
|
||||
ContentItem item = m_step.getItem( ps );
|
||||
DataCollection notes = Note.getNotes( item );
|
||||
ContentItem item = m_step.getItem(ps);
|
||||
DataCollection notes = Note.getNotes(item);
|
||||
|
||||
if( s_log.isDebugEnabled() ) {
|
||||
s_log.debug( "NotesDisplay.generateXML" );
|
||||
if (s_log.isDebugEnabled()) {
|
||||
s_log.debug("NotesDisplay.generateXML");
|
||||
}
|
||||
|
||||
DomainObjectXMLRenderer xr = new DomainObjectXMLRenderer( root );
|
||||
xr.setWrapRoot( true );
|
||||
xr.setWrapAttributes( true );
|
||||
xr.setWrapObjects( true );
|
||||
DomainObjectXMLRenderer xr = new DomainObjectXMLRenderer(root);
|
||||
xr.setWrapRoot(true);
|
||||
xr.setWrapAttributes(true);
|
||||
xr.setWrapObjects(true);
|
||||
|
||||
while( notes.next() ) {
|
||||
Note note = new Note( notes.getDataObject() );
|
||||
while (notes.next()) {
|
||||
Note note = new Note(notes.getDataObject());
|
||||
String oid = note.getOID().toString();
|
||||
|
||||
Element edit = root.newChildElement( "cms:notesAction",
|
||||
CMS.CMS_XML_NS );
|
||||
edit.addAttribute( "action", EDIT );
|
||||
edit.addAttribute( "oid", oid );
|
||||
ps.setControlEvent( this, EDIT, oid );
|
||||
try {
|
||||
edit.addAttribute( "href", ps.stateAsURL() );
|
||||
} catch( IOException ex ) {
|
||||
throw new UncheckedWrapperException( ex );
|
||||
}
|
||||
if (CMS.getSecurityManager(ps).canAccess(ps.getRequest(),
|
||||
SecurityConstants.EDIT_ITEM,
|
||||
item)) {
|
||||
Element edit = root.newChildElement("cms:notesAction",
|
||||
CMS.CMS_XML_NS);
|
||||
edit.addAttribute("action", EDIT);
|
||||
edit.addAttribute("oid", oid);
|
||||
ps.setControlEvent(this, EDIT, oid);
|
||||
try {
|
||||
edit.addAttribute("href", ps.stateAsURL());
|
||||
} catch (IOException ex) {
|
||||
throw new UncheckedWrapperException(ex);
|
||||
}
|
||||
|
||||
Element delete = root.newChildElement( "cms:notesAction",
|
||||
CMS.CMS_XML_NS );
|
||||
delete.addAttribute( "action", DELETE );
|
||||
delete.addAttribute( "oid", oid );
|
||||
ps.setControlEvent( this, DELETE, oid );
|
||||
try {
|
||||
delete.addAttribute( "href", ps.stateAsURL() );
|
||||
} catch( IOException ex ) {
|
||||
throw new UncheckedWrapperException( ex );
|
||||
}
|
||||
Element delete = root.newChildElement("cms:notesAction",
|
||||
CMS.CMS_XML_NS);
|
||||
delete.addAttribute("action", DELETE);
|
||||
delete.addAttribute("oid", oid);
|
||||
ps.setControlEvent(this, DELETE, oid);
|
||||
try {
|
||||
delete.addAttribute("href", ps.stateAsURL());
|
||||
} catch (IOException ex) {
|
||||
throw new UncheckedWrapperException(ex);
|
||||
}
|
||||
|
||||
Element up = root.newChildElement( "cms:notesAction",
|
||||
CMS.CMS_XML_NS );
|
||||
up.addAttribute( "action", UP );
|
||||
up.addAttribute( "oid", oid );
|
||||
ps.setControlEvent( this, UP, oid );
|
||||
try {
|
||||
up.addAttribute( "href", ps.stateAsURL() );
|
||||
} catch( IOException ex ) {
|
||||
throw new UncheckedWrapperException( ex );
|
||||
}
|
||||
Element up = root.newChildElement("cms:notesAction",
|
||||
CMS.CMS_XML_NS);
|
||||
up.addAttribute("action", UP);
|
||||
up.addAttribute("oid", oid);
|
||||
ps.setControlEvent(this, UP, oid);
|
||||
try {
|
||||
up.addAttribute("href", ps.stateAsURL());
|
||||
} catch (IOException ex) {
|
||||
throw new UncheckedWrapperException(ex);
|
||||
}
|
||||
|
||||
Element down = root.newChildElement( "cms:notesAction",
|
||||
CMS.CMS_XML_NS );
|
||||
down.addAttribute( "action", DOWN );
|
||||
down.addAttribute( "oid", oid );
|
||||
ps.setControlEvent( this, DOWN, oid );
|
||||
try {
|
||||
down.addAttribute( "href", ps.stateAsURL() );
|
||||
} catch( IOException ex ) {
|
||||
throw new UncheckedWrapperException( ex );
|
||||
Element down = root.newChildElement("cms:notesAction",
|
||||
CMS.CMS_XML_NS);
|
||||
down.addAttribute("action", DOWN);
|
||||
down.addAttribute("oid", oid);
|
||||
ps.setControlEvent(this, DOWN, oid);
|
||||
try {
|
||||
down.addAttribute("href", ps.stateAsURL());
|
||||
} catch (IOException ex) {
|
||||
throw new UncheckedWrapperException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
ps.clearControlEvent();
|
||||
|
||||
xr.walk( note, SimpleXMLGenerator.ADAPTER_CONTEXT );
|
||||
xr.walk(note, SimpleXMLGenerator.ADAPTER_CONTEXT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ public class NotesStep extends SecurityPropertyEditor {
|
|||
return m_itemModel.getSelectedItem( ps );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register( Page p ) {
|
||||
super.register( p );
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue