Moved content type decision tree from Camden contrib to main trunk. Update script incomplete!
git-svn-id: https://svn.libreccm.org/ccm/trunk@2119 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
f49990cf32
commit
547f1ae848
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="src" path="src"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||||
|
<classpathentry combineaccessrules="false" kind="src" path="/ccm-cms"/>
|
||||||
|
<classpathentry combineaccessrules="false" kind="src" path="/ccm-core"/>
|
||||||
|
<classpathentry kind="output" path="build/Eclipse"/>
|
||||||
|
</classpath>
|
||||||
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>cm-ldn-camden-decisiontree</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?xml version="1.0"?>
|
||||||
|
<ccm:application xmlns:ccm="http://ccm.redhat.com/ccm-project"
|
||||||
|
name="ccm-cms-types-decisiontree"
|
||||||
|
prettyName="Red Hat CCM Content Types"
|
||||||
|
version="6.6.0"
|
||||||
|
release="1"
|
||||||
|
webapp="ROOT">
|
||||||
|
<ccm:dependencies>
|
||||||
|
<ccm:requires name="ccm-core" version="6.2.0" relation="ge"/>
|
||||||
|
<ccm:requires name="ccm-cms" version="6.2.0" relation="ge"/>
|
||||||
|
</ccm:dependencies>
|
||||||
|
<ccm:directories>
|
||||||
|
<ccm:directory name="pdl"/>
|
||||||
|
<ccm:directory name="sql"/>
|
||||||
|
<ccm:directory name="src"/>
|
||||||
|
</ccm:directories>
|
||||||
|
<ccm:contacts>
|
||||||
|
<ccm:contact uri="http://www.redhat.com/software/rhea" type="website"/>
|
||||||
|
<ccm:contact uri="mailto:rhea@redhat.com" type="support"/>
|
||||||
|
</ccm:contacts>
|
||||||
|
<ccm:description>
|
||||||
|
The decision Tree Content Type for the Red Hat CCM CMS, previously part of
|
||||||
|
Camden contributed tree, relocated to main trunk.
|
||||||
|
</ccm:description>
|
||||||
|
</ccm:application>
|
||||||
|
|
@ -0,0 +1,97 @@
|
||||||
|
//
|
||||||
|
// Copyright (C) 2007 Red Hat Inc. All Rights Reserved.
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
//
|
||||||
|
// $Id$
|
||||||
|
|
||||||
|
model com.arsdigita.cms.contenttypes;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.*;
|
||||||
|
|
||||||
|
object type DecisionTree extends ContentPage {
|
||||||
|
|
||||||
|
String[0..1] cancelURL = ct_decisiontrees.cancel_url;
|
||||||
|
DecisionTreeSection[0..1] firstSection =
|
||||||
|
join ct_decisiontrees.first_section to ct_decisiontree_sections.section_id;
|
||||||
|
|
||||||
|
reference key (ct_decisiontrees.tree_id);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
object type DecisionTreeSection extends ContentPage {
|
||||||
|
|
||||||
|
String[1..1] parameterName = ct_decisiontree_sections.parameter_name;
|
||||||
|
component TextAsset[0..1] instructions =
|
||||||
|
join ct_decisiontree_sections.instructions to cms_text.text_id;
|
||||||
|
|
||||||
|
reference key (ct_decisiontree_sections.section_id);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
association {
|
||||||
|
// Association between a tree and its sections
|
||||||
|
|
||||||
|
DecisionTree[1..1] tree =
|
||||||
|
join ct_decisiontree_sections.tree_id to ct_decisiontrees.tree_id;
|
||||||
|
component DecisionTreeSection[0..n] sections =
|
||||||
|
join ct_decisiontrees.tree_id to ct_decisiontree_sections.tree_id;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
object type DecisionTreeSectionOption extends ContentItem {
|
||||||
|
|
||||||
|
Integer[1..1] rank = ct_decisiontree_section_options.rank;
|
||||||
|
String[1..1] label = ct_decisiontree_section_options.label;
|
||||||
|
String[1..1] value = ct_decisiontree_section_options.value;
|
||||||
|
|
||||||
|
reference key (ct_decisiontree_section_options.option_id);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
association {
|
||||||
|
// Association between a section and its options
|
||||||
|
|
||||||
|
composite DecisionTreeSection[1..1] treeSection =
|
||||||
|
join ct_decisiontree_section_options.section_id
|
||||||
|
to ct_decisiontree_sections.section_id;
|
||||||
|
component DecisionTreeSectionOption[0..n] sectionOptions =
|
||||||
|
join ct_decisiontree_sections.section_id
|
||||||
|
to ct_decisiontree_section_options.section_id;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
object type DecisionTreeOptionTarget extends ContentItem {
|
||||||
|
|
||||||
|
String[0..1] targetURL = ct_decisiontree_option_targets.target_url;
|
||||||
|
DecisionTreeSection[0..1] targetSection =
|
||||||
|
join ct_decisiontree_option_targets.target_section
|
||||||
|
to ct_decisiontree_sections.section_id;
|
||||||
|
|
||||||
|
reference key (ct_decisiontree_option_targets.target_id);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
association {
|
||||||
|
// Association between an option and its target
|
||||||
|
|
||||||
|
composite DecisionTreeSectionOption[1..1] matchOption =
|
||||||
|
join ct_decisiontree_option_targets.match_option
|
||||||
|
to ct_decisiontree_section_options.option_id;
|
||||||
|
component DecisionTreeOptionTarget[0..1] optionTarget =
|
||||||
|
join ct_decisiontree_section_options.option_id
|
||||||
|
to ct_decisiontree_option_targets.match_option;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
--
|
||||||
|
-- Copyright (C) 2007 Red Hat Inc. All Rights Reserved.
|
||||||
|
--
|
||||||
|
-- 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
|
||||||
|
--
|
||||||
|
-- $Id: oracle-se-create.sql 1494 2007-03-19 14:58:34Z apevec $
|
||||||
|
|
||||||
|
@@ ddl/oracle-se/create.sql
|
||||||
|
|
||||||
|
@@ ddl/oracle-se/deferred.sql
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
--
|
||||||
|
-- Copyright (C) 2007 Red Hat Inc. All Rights Reserved.
|
||||||
|
--
|
||||||
|
-- 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
|
||||||
|
--
|
||||||
|
-- $Id: postgres-create.sql 1494 2007-03-19 14:58:34Z apevec $
|
||||||
|
|
||||||
|
\i ddl/postgres/create.sql
|
||||||
|
|
||||||
|
\i ddl/postgres/deferred.sql
|
||||||
|
|
@ -0,0 +1,94 @@
|
||||||
|
--
|
||||||
|
-- Copyright (C) 2012 Peter Boy All Rights Reserved.
|
||||||
|
--
|
||||||
|
-- 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
|
||||||
|
--
|
||||||
|
-- $Id: upd_system_tables.sql pboy $
|
||||||
|
|
||||||
|
-- rename ccm-cms-types-contact to ccm-ldn-types-contact
|
||||||
|
-- adjust various system tables to the new name of content type
|
||||||
|
|
||||||
|
-- --------------------------------------------
|
||||||
|
-- !!! REPLACE BY REQUIRED SQL COMMANDS !!!
|
||||||
|
-- --------------------------------------------
|
||||||
|
|
||||||
|
alter table init_requirements drop constraint init_requirements_init_f_cmmdn ;
|
||||||
|
alter table init_requirements drop constraint init_require_requ_init_f_i6rgg ;
|
||||||
|
|
||||||
|
update inits
|
||||||
|
set class_name='com.arsdigita.london.contenttypes.ESDServiceInitializer'
|
||||||
|
where class_name='com.arsdigita.cms.contenttypes.ESDServiceInitializer' ;
|
||||||
|
|
||||||
|
update init_requirements
|
||||||
|
set init='com.arsdigita.london.contenttypes.ESDServiceInitializer'
|
||||||
|
where init='com.arsdigita.cms.contenttypes.ESDServiceInitializer' ;
|
||||||
|
|
||||||
|
ALTER TABLE init_requirements
|
||||||
|
ADD CONSTRAINT init_requirements_init_f_cmmdn FOREIGN KEY (init)
|
||||||
|
REFERENCES inits (class_name) MATCH SIMPLE
|
||||||
|
ON UPDATE NO ACTION ON DELETE NO ACTION;
|
||||||
|
ALTER TABLE init_requirements
|
||||||
|
ADD CONSTRAINT init_require_requ_init_f_i6rgg FOREIGN KEY (required_init)
|
||||||
|
REFERENCES inits (class_name) MATCH SIMPLE
|
||||||
|
ON UPDATE NO ACTION ON DELETE NO ACTION;
|
||||||
|
|
||||||
|
|
||||||
|
update content_types
|
||||||
|
set object_type='com.arsdigita.london.contenttypes.ESDService',
|
||||||
|
label='ESD Service',
|
||||||
|
description='An ESDService',
|
||||||
|
classname='com.arsdigita.london.contenttypes.ESDService'
|
||||||
|
where classname='com.arsdigita.cms.contenttypes.ESDService' ;
|
||||||
|
|
||||||
|
update authoring_steps
|
||||||
|
set label_key='ESD Service Properties',
|
||||||
|
label_bundle='com.arsdigita.london.contenttypes.ESDServiceResources',
|
||||||
|
description_key='Edit the basic ESDService properties',
|
||||||
|
description_bundle='com.arsdigita.london.contenttypes.ESDServiceResources',
|
||||||
|
component='com.arsdigita.london.contenttypes.ui.ESDServicePropertiesStep'
|
||||||
|
where component='com.arsdigita.cms.contenttypes.ui.ESDServicePropertiesStep' ;
|
||||||
|
|
||||||
|
update authoring_steps
|
||||||
|
set label_key='ESD Service Contact',
|
||||||
|
label_bundle='com.arsdigita.london.contenttypes.ESDServiceResources',
|
||||||
|
description_key='Edit/Choose the associated Contact object',
|
||||||
|
description_bundle='com.arsdigita.london.contenttypes.ESDServiceResources',
|
||||||
|
component='com.arsdigita.london.contenttypes.ui.ESDServiceChooseContactStep'
|
||||||
|
where component='com.arsdigita.cms.contenttypes.ui.ESDServiceChooseContactStep' ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
update acs_objects
|
||||||
|
set (object_type,default_domain_class) =
|
||||||
|
('com.arsdigita.london.contenttypes.ESDService' ,
|
||||||
|
'com.arsdigita.london.contenttypes.ESDService' )
|
||||||
|
where default_domain_class like 'com.arsdigita.cms.contenttypes.ESDService' ;
|
||||||
|
|
||||||
|
update lucene_docs
|
||||||
|
set type='com.arsdigita.london.contenttypes.ESDService'
|
||||||
|
where type='com.arsdigita.cms.contenttypes.ESDService' ;
|
||||||
|
|
||||||
|
update vcx_generic_operations
|
||||||
|
set value=replace(value,'cms.contenttypes.ESDService', 'london.contenttypes.ESDService')
|
||||||
|
where value like '%cms.contenttypes.ESDService%';
|
||||||
|
|
||||||
|
update vcx_obj_changes
|
||||||
|
set obj_id=replace(obj_id,'cms.contenttypes.ESDService', 'london.contenttypes.ESDService')
|
||||||
|
where obj_id like '%cms.contenttypes.ESDService%';
|
||||||
|
|
||||||
|
update vcx_tags
|
||||||
|
set tagged_oid=replace(tagged_oid,'cms.contenttypes.ESDService', 'london.contenttypes.ESDService')
|
||||||
|
where tagged_oid like '%cms.contenttypes.ESDService%';
|
||||||
|
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
--
|
||||||
|
-- Copyright (C) 2012 Peter Boy All Rights Reserved.
|
||||||
|
--
|
||||||
|
-- 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
|
||||||
|
--
|
||||||
|
-- $Id: ren_esdservice_table.sql pboy $
|
||||||
|
|
||||||
|
-- rename ct_esdservice table to ct_ldn_esdservice table following
|
||||||
|
-- ccm naming conventions to make maintenance tasks easier
|
||||||
|
|
||||||
|
|
||||||
|
-- --------------------------------------------
|
||||||
|
-- !!! REPLACE BY REQUIRED SQL COMMANDS !!!
|
||||||
|
-- --------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
-- if we could figure out the old names we could rename constraints too
|
||||||
|
-- alter table ct_esdservice drop constraint ... ;
|
||||||
|
-- alter table ct_esdservice drop constraint ... ;
|
||||||
|
-- alter table ct_esdservice drop constraint ... ;
|
||||||
|
|
||||||
|
alter table ct_esdservice RENAME TO ct_ldn_esdservice ;
|
||||||
|
|
||||||
|
-- alter table ct_ldn_esdservice
|
||||||
|
-- add constraint ct_ldn_esdserv_serv_id_p_5dac0 PRIMARY KEY(service_id);
|
||||||
|
-- alter table ct_ldn_esdservice
|
||||||
|
-- add constraint ct_ldn_esdserv_cont_id_f_r4d1z FOREIGN KEY (contact_id)
|
||||||
|
-- references ct_ldn_contacts (contact_id) MATCH SIMPLE
|
||||||
|
-- ON UPDATE NO ACTION ON DELETE NO ACTION;
|
||||||
|
-- alter table ct_ldn_esdservice
|
||||||
|
-- add constraint ct_ldn_esdserv_serv_id_f_tfkqn FOREIGN KEY (service_id)
|
||||||
|
-- references cms_articles (article_id) MATCH SIMPLE
|
||||||
|
-- ON UPDATE NO ACTION ON DELETE NO ACTION;
|
||||||
|
|
||||||
|
|
@ -0,0 +1,94 @@
|
||||||
|
--
|
||||||
|
-- Copyright (C) 2012 Peter Boy All Rights Reserved.
|
||||||
|
--
|
||||||
|
-- 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
|
||||||
|
--
|
||||||
|
-- $Id: ren_domainprovider_table.sql pboy $
|
||||||
|
|
||||||
|
-- rename ct_contact_* tables to ct_ldn_contact_* tables following
|
||||||
|
-- ccm naming conventions to make maintenance tasks easier
|
||||||
|
|
||||||
|
|
||||||
|
-- if we could figure out the old names we could rename constraints too
|
||||||
|
-- alter table ct_contacts drop constraint ... ;
|
||||||
|
-- alter table ct_contacts drop constraint ... ;
|
||||||
|
-- alter table ct_contacts drop constraint ... ;
|
||||||
|
|
||||||
|
alter table ct_contacts RENAME TO ct_ldn_contacts ;
|
||||||
|
|
||||||
|
-- alter table ct_contacts drop constraint ... ;
|
||||||
|
-- alter table ct_contacts drop constraint ... ;
|
||||||
|
-- alter table ct_contacts drop constraint ... ;
|
||||||
|
|
||||||
|
|
||||||
|
-- alter table ct_contacts drop constraint ... ;
|
||||||
|
-- alter table ct_contacts drop constraint ... ;
|
||||||
|
-- alter table ct_contacts drop constraint ... ;
|
||||||
|
|
||||||
|
alter table ct_contact_address RENAME TO ct_ldn_contact_address ;
|
||||||
|
|
||||||
|
-- alter table ct_ldn_contact_address
|
||||||
|
-- add constraint ct_ldn_con_add_addr_id_p_y5yhy PRIMARY KEY (address_id) ;
|
||||||
|
-- alter table ct_ldn_contact_address
|
||||||
|
-- add constraint ct_ldn_con_add_addr_id_f_bfcho FOREIGN KEY (address_id)
|
||||||
|
-- REFERENCES cms_items (item_id) MATCH SIMPLE
|
||||||
|
-- ON UPDATE NO ACTION ON DELETE NO ACTION;
|
||||||
|
|
||||||
|
|
||||||
|
-- alter table ct_contacts drop constraint ... ;
|
||||||
|
-- alter table ct_contacts drop constraint ... ;
|
||||||
|
-- alter table ct_contacts drop constraint ... ;
|
||||||
|
|
||||||
|
alter table ct_contact_phones RENAME TO ct_ldn_contact_phones ;
|
||||||
|
|
||||||
|
-- alter table ct_ldn_contact_address
|
||||||
|
-- add constraint ct_ldn_con_add_addr_id_p_y5yhy PRIMARY KEY (address_id) ;
|
||||||
|
-- alter table ct_ldn_contact_address
|
||||||
|
-- add constraint ct_ldn_con_add_addr_id_f_bfcho FOREIGN KEY (address_id)
|
||||||
|
-- REFERENCES cms_items (item_id) MATCH SIMPLE
|
||||||
|
-- ON UPDATE NO ACTION ON DELETE NO ACTION;
|
||||||
|
|
||||||
|
|
||||||
|
-- alter table ct_contacts drop constraint ... ;
|
||||||
|
-- alter table ct_contacts drop constraint ... ;
|
||||||
|
-- alter table ct_contacts drop constraint ... ;
|
||||||
|
|
||||||
|
alter table ct_contact_types RENAME TO ct_ldn_contact_types ;
|
||||||
|
|
||||||
|
-- alter table ct_ldn_contact_address
|
||||||
|
-- add constraint ct_ldn_con_add_addr_id_p_y5yhy PRIMARY KEY (address_id) ;
|
||||||
|
-- alter table ct_ldn_contact_address
|
||||||
|
-- add constraint ct_ldn_con_add_addr_id_f_bfcho FOREIGN KEY (address_id)
|
||||||
|
-- REFERENCES cms_items (item_id) MATCH SIMPLE
|
||||||
|
-- ON UPDATE NO ACTION ON DELETE NO ACTION;
|
||||||
|
|
||||||
|
|
||||||
|
alter table contact_content_item_map drop constraint cont_con_ite_map_ite_i_p_scqe9 ;
|
||||||
|
alter table contact_content_item_map drop constraint cont_con_ite_map_con_i_f_lanid ;
|
||||||
|
alter table contact_content_item_map drop constraint cont_con_ite_map_ite_i_f_fr0po ;
|
||||||
|
|
||||||
|
alter table contact_content_item_map RENAME TO ct_ldn_contact_content_item_map ;
|
||||||
|
|
||||||
|
alter table ct_ldn_contact_content_item_map
|
||||||
|
add constraint ct_ldn_con_con_ite_map_p_nannu PRIMARY KEY(item_id) ;
|
||||||
|
alter table ct_ldn_contact_content_item_map
|
||||||
|
add constraint ct_ldn_con_con_ite_map_f_g9mgi foreign key (contact_id)
|
||||||
|
references ct_ldn_contacts (contact_id) MATCH SIMPLE
|
||||||
|
ON UPDATE NO ACTION ON DELETE NO ACTION;
|
||||||
|
alter table ct_ldn_contact_content_item_map
|
||||||
|
add constraint ct_ldn_con_con_ite_map_f_a0qiy foreign key (item_id)
|
||||||
|
references cms_items(item_id) MATCH SIMPLE
|
||||||
|
ON UPDATE NO ACTION ON DELETE NO ACTION;
|
||||||
|
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
--
|
||||||
|
-- Copyright (C) 2013 Peter Boy. All Rights Reserved.
|
||||||
|
--
|
||||||
|
-- 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
|
||||||
|
--
|
||||||
|
-- $Id: upd_inits.sql $
|
||||||
|
|
||||||
|
-- Adjust the class name of the Initializer
|
||||||
|
update inits
|
||||||
|
set class_name='com.arsdigita.cms.contenttypes.DecisionTreeInitializer'
|
||||||
|
where class_name='com.arsdigita.camden.cms.contenttypes.DecisionTreeInitializer' ;
|
||||||
|
|
||||||
|
-- Adjust the class name of the Initializer in init-requirements
|
||||||
|
update init_requirements
|
||||||
|
set init='com.arsdigita.cms.contenttypes.DecisionTreeInitializer'
|
||||||
|
where init='com.arsdigita.camden.cms.contenttypes.DecisionTreeInitializer' ;
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
--
|
||||||
|
-- Copyright (C) 2013 Peter Boy. All Rights Reserved.
|
||||||
|
--
|
||||||
|
-- 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
|
||||||
|
--
|
||||||
|
-- $Id: upd_acs_objects.sql $
|
||||||
|
|
||||||
|
-- Adjust the class name in acs-objects for all DecisionTree instances
|
||||||
|
update acs_objects
|
||||||
|
set (object_type,default_domain_class) =
|
||||||
|
('com.arsdigita.cms.contenttypes.DecisionTree' ,
|
||||||
|
'com.arsdigita.cms.contenttypes.DecisionTree' )
|
||||||
|
where default_domain_class
|
||||||
|
like 'com.arsdigita.camden.cms.contenttypes.DecisionTree' ;
|
||||||
|
|
||||||
|
--Adjust content type decisiontree in contenttype directory table
|
||||||
|
update content_types
|
||||||
|
set (object_type,classname) =
|
||||||
|
('com.arsdigita.cms.contenttypes.DecisionTree' ,
|
||||||
|
'com.arsdigita.cms.contenttypes.DecisionTree' )
|
||||||
|
where object_type
|
||||||
|
like 'com.arsdigita.camden.cms.contenttypes.DecisionTree' ;
|
||||||
|
|
||||||
|
--Adjust content type decisiontree in authoring_steps directory table
|
||||||
|
update authoring_steps
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
--
|
||||||
|
-- Copyright (C) 2013 Peter Boy All Rights Reserved.
|
||||||
|
--
|
||||||
|
-- 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
|
||||||
|
--
|
||||||
|
-- $Id: oracle-se-6.6.0-6.6.1.sql 293 2011-01-07 15:10:39Z pboy $
|
||||||
|
|
||||||
|
PROMPT Red Hat Enterprise types-decisiontree 1.0.3 -> 6.6.0 Upgrade Script (Oracle)
|
||||||
|
|
||||||
|
@@ default/1.0.3-6.6.0/drop_constraints_ct_addresses.sql
|
||||||
|
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
--
|
||||||
|
-- Copyright (C) 2011 Peter Boy All Rights Reserved.
|
||||||
|
--
|
||||||
|
-- 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
|
||||||
|
--
|
||||||
|
-- $DateTime: 2013/04/07 23:15:09 $
|
||||||
|
|
||||||
|
\echo Red Hat Enterprise types-decisiontree 1.0.3 -> 6.6.0 Upgrade Script (PostgreSQL)
|
||||||
|
|
||||||
|
begin;
|
||||||
|
|
||||||
|
\i default/1.0.3-6.6.0/drop_constraints_ct_adresses.sql
|
||||||
|
|
||||||
|
|
||||||
|
commit;
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<ctd:content-types xmlns:ctd="http://xmlns.redhat.com/cms/content-types"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://xmlns.redhat.com/cms/content-types content-types.xsd">
|
||||||
|
|
||||||
|
<ctd:content-type label="DecisionTree"
|
||||||
|
description="A content type for Camden Decision Trees."
|
||||||
|
objectType="com.arsdigita.cms.contenttypes.DecisionTree"
|
||||||
|
classname="com.arsdigita.cms.contenttypes.DecisionTree">
|
||||||
|
|
||||||
|
<ctd:authoring-kit createComponent="com.arsdigita.cms.ui.authoring.PageCreate">
|
||||||
|
<ctd:authoring-step
|
||||||
|
labelKey="cms.contenttypes.shared.basic_properties.title"
|
||||||
|
labelBundle="com.arsdigita.cms.ui.CMSResources"
|
||||||
|
descriptionKey="cms.contenttypes.shared.basic_properties.description"
|
||||||
|
descriptionBundle="com.arsdigita.cms.ui.CMSResources"
|
||||||
|
component="com.arsdigita.cms.contenttypes.ui.DecisionTreePropertiesStep"/>
|
||||||
|
|
||||||
|
<ctd:authoring-step
|
||||||
|
labelKey="tree_sections.title"
|
||||||
|
labelBundle="com.arsdigita.cms.contenttypes.DecisionTreeResources"
|
||||||
|
descriptionKey="tree_sections.description"
|
||||||
|
descriptionBundle="com.arsdigita.cms.contenttypes.DecisionTreeResources"
|
||||||
|
component="com.arsdigita.cms.contenttypes.ui.DecisionTreeViewSections"/>
|
||||||
|
|
||||||
|
<ctd:authoring-step
|
||||||
|
labelKey="section_options.title"
|
||||||
|
labelBundle="com.arsdigita.cms.contenttypes.DecisionTreeResources"
|
||||||
|
descriptionKey="section_options.description"
|
||||||
|
descriptionBundle="com.arsdigita.cms.contenttypes.DecisionTreeResources"
|
||||||
|
component="com.arsdigita.cms.contenttypes.ui.DecisionTreeViewOptions"/>
|
||||||
|
|
||||||
|
<ctd:authoring-step
|
||||||
|
labelKey="option_targets.title"
|
||||||
|
labelBundle="com.arsdigita.cms.contenttypes.DecisionTreeResources"
|
||||||
|
descriptionKey="option_targets.description"
|
||||||
|
descriptionBundle="com.arsdigita.cms.contenttypes.DecisionTreeResources"
|
||||||
|
component="com.arsdigita.cms.contenttypes.ui.DecisionTreeViewTargets" />
|
||||||
|
<ctd:include href="/WEB-INF/content-types/assign-categories-step.xml"/>
|
||||||
|
</ctd:authoring-kit>
|
||||||
|
</ctd:content-type>
|
||||||
|
</ctd:content-types>
|
||||||
|
|
@ -0,0 +1,124 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<xrd:adapters xmlns:xrd="http://xmlns.redhat.com/schemas/waf/xml-renderer-rules"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://rhea.redhat.com/schemas/waf/xml-renderer-rules xml-renderer-rules.xsd">
|
||||||
|
<!-- No need to list all the content types here. Only
|
||||||
|
need to list a type if is adds associations that
|
||||||
|
were not in the parent type, or to remove attributes
|
||||||
|
-->
|
||||||
|
|
||||||
|
<xrd:context name="com.arsdigita.cms.dispatcher.SimpleXMLGenerator">
|
||||||
|
<xrd:adapter objectType="com.arsdigita.cms.contenttypes.DecisionTree"
|
||||||
|
extends="com.arsdigita.cms.ContentPage"
|
||||||
|
traversalClass="com.arsdigita.cms.contenttypes.DecisionTreeTraversalAdapter">
|
||||||
|
<xrd:associations rule="include">
|
||||||
|
<xrd:property name="/object/sections"></xrd:property>
|
||||||
|
<xrd:property name="/object/sections/instructions"></xrd:property>
|
||||||
|
<xrd:property name="/object/sections/sectionOptions"></xrd:property>
|
||||||
|
<xrd:property name="/object/sections/sectionOptions/optionTarget"></xrd:property>
|
||||||
|
</xrd:associations>
|
||||||
|
<xrd:attributes rule="exclude">
|
||||||
|
<xrd:property name="/object/version"/>
|
||||||
|
<xrd:property name="/object/name"/>
|
||||||
|
<xrd:property name="/object/language"/>
|
||||||
|
<xrd:property name="/object/ancestors"/>
|
||||||
|
<xrd:property name="/object/isDeleted"/>
|
||||||
|
<xrd:property name="/object/id"/>
|
||||||
|
<xrd:property name="/object/displayName"/>
|
||||||
|
<xrd:property name="/object/defaultDomainClass"/>
|
||||||
|
<xrd:property name="/object/sections/version"/>
|
||||||
|
<xrd:property name="/object/sections/name"/>
|
||||||
|
<xrd:property name="/object/sections/language"/>
|
||||||
|
<xrd:property name="/object/sections/ancestors"/>
|
||||||
|
<xrd:property name="/object/sections/isDeleted"/>
|
||||||
|
<xrd:property name="/object/sections/id"/>
|
||||||
|
<xrd:property name="/object/sections/objectType"/>
|
||||||
|
<xrd:property name="/object/sections/displayName"/>
|
||||||
|
<xrd:property name="/object/sections/defaultDomainClass"/>
|
||||||
|
<xrd:property name="/object/sections/instructions/version"/>
|
||||||
|
<xrd:property name="/object/sections/instructions/name"/>
|
||||||
|
<xrd:property name="/object/sections/instructions/language"/>
|
||||||
|
<xrd:property name="/object/sections/instructions/ancestors"/>
|
||||||
|
<xrd:property name="/object/sections/instructions/isDeleted"/>
|
||||||
|
<xrd:property name="/object/sections/instructions/id"/>
|
||||||
|
<xrd:property name="/object/sections/instructions/objectType"/>
|
||||||
|
<xrd:property name="/object/sections/instructions/displayName"/>
|
||||||
|
<xrd:property name="/object/sections/instructions/defaultDomainClass"/>
|
||||||
|
<xrd:property name="/object/sections/sectionOptions/version"/>
|
||||||
|
<xrd:property name="/object/sections/sectionOptions/name"/>
|
||||||
|
<xrd:property name="/object/sections/sectionOptions/ancestors"/>
|
||||||
|
<xrd:property name="/object/sections/sectionOptions/isDeleted"/>
|
||||||
|
<xrd:property name="/object/sections/sectionOptions/id"/>
|
||||||
|
<xrd:property name="/object/sections/sectionOptions/objectType"/>
|
||||||
|
<xrd:property name="/object/sections/sectionOptions/displayName"/>
|
||||||
|
<xrd:property name="/object/sections/sectionOptions/defaultDomainClass"/>
|
||||||
|
<xrd:property name="/object/sections/sectionOptions/optionTarget/version"/>
|
||||||
|
<xrd:property name="/object/sections/sectionOptions/optionTarget/name"/>
|
||||||
|
<xrd:property name="/object/sections/sectionOptions/optionTarget/ancestors"/>
|
||||||
|
<xrd:property name="/object/sections/sectionOptions/optionTarget/isDeleted"/>
|
||||||
|
<xrd:property name="/object/sections/sectionOptions/optionTarget/id"/>
|
||||||
|
<xrd:property name="/object/sections/sectionOptions/optionTarget/objectType"/>
|
||||||
|
<xrd:property name="/object/sections/sectionOptions/optionTarget/displayName"/>
|
||||||
|
<xrd:property name="/object/sections/sectionOptions/optionTarget/defaultDomainClass"/>
|
||||||
|
</xrd:attributes>
|
||||||
|
</xrd:adapter>
|
||||||
|
</xrd:context>
|
||||||
|
|
||||||
|
<xrd:context name="com.arsdigita.cms.search.ContentPageMetadataProvider">
|
||||||
|
<xrd:adapter
|
||||||
|
objectType="com.arsdigita.cms.contenttypes.DecisionTree"
|
||||||
|
traversalClass="com.arsdigita.cms.contenttypes.ContentItemTraversalAdapter">
|
||||||
|
<xrd:associations rule="include">
|
||||||
|
<xrd:property name="/object/sections"></xrd:property>
|
||||||
|
<xrd:property name="/object/sections/instructions"></xrd:property>
|
||||||
|
<xrd:property name="/object/sections/sectionOptions"></xrd:property>
|
||||||
|
<xrd:property name="/object/sections/sectionOptions/optionTarget"></xrd:property>
|
||||||
|
</xrd:associations>
|
||||||
|
<xrd:attributes rule="exclude">
|
||||||
|
<xrd:property name="/object/version"/>
|
||||||
|
<xrd:property name="/object/name"/>
|
||||||
|
<xrd:property name="/object/language"/>
|
||||||
|
<xrd:property name="/object/ancestors"/>
|
||||||
|
<xrd:property name="/object/isDeleted"/>
|
||||||
|
<xrd:property name="/object/id"/>
|
||||||
|
<xrd:property name="/object/objectType"/>
|
||||||
|
<xrd:property name="/object/displayName"/>
|
||||||
|
<xrd:property name="/object/defaultDomainClass"/>
|
||||||
|
<xrd:property name="/object/sections/version"/>
|
||||||
|
<xrd:property name="/object/sections/name"/>
|
||||||
|
<xrd:property name="/object/sections/language"/>
|
||||||
|
<xrd:property name="/object/sections/ancestors"/>
|
||||||
|
<xrd:property name="/object/sections/isDeleted"/>
|
||||||
|
<xrd:property name="/object/sections/id"/>
|
||||||
|
<xrd:property name="/object/sections/objectType"/>
|
||||||
|
<xrd:property name="/object/sections/displayName"/>
|
||||||
|
<xrd:property name="/object/sections/defaultDomainClass"/>
|
||||||
|
<xrd:property name="/object/sections/instructions/version"/>
|
||||||
|
<xrd:property name="/object/sections/instructions/name"/>
|
||||||
|
<xrd:property name="/object/sections/instructions/language"/>
|
||||||
|
<xrd:property name="/object/sections/instructions/ancestors"/>
|
||||||
|
<xrd:property name="/object/sections/instructions/isDeleted"/>
|
||||||
|
<xrd:property name="/object/sections/instructions/id"/>
|
||||||
|
<xrd:property name="/object/sections/instructions/objectType"/>
|
||||||
|
<xrd:property name="/object/sections/instructions/displayName"/>
|
||||||
|
<xrd:property name="/object/sections/instructions/defaultDomainClass"/>
|
||||||
|
<xrd:property name="/object/sections/sectionOptions/version"/>
|
||||||
|
<xrd:property name="/object/sections/sectionOptions/name"/>
|
||||||
|
<xrd:property name="/object/sections/sectionOptions/ancestors"/>
|
||||||
|
<xrd:property name="/object/sections/sectionOptions/isDeleted"/>
|
||||||
|
<xrd:property name="/object/sections/sectionOptions/id"/>
|
||||||
|
<xrd:property name="/object/sections/sectionOptions/objectType"/>
|
||||||
|
<xrd:property name="/object/sections/sectionOptions/displayName"/>
|
||||||
|
<xrd:property name="/object/sections/sectionOptions/defaultDomainClass"/>
|
||||||
|
<xrd:property name="/object/sections/sectionOptions/optionTarget/version"/>
|
||||||
|
<xrd:property name="/object/sections/sectionOptions/optionTarget/name"/>
|
||||||
|
<xrd:property name="/object/sections/sectionOptions/optionTarget/ancestors"/>
|
||||||
|
<xrd:property name="/object/sections/sectionOptions/optionTarget/isDeleted"/>
|
||||||
|
<xrd:property name="/object/sections/sectionOptions/optionTarget/id"/>
|
||||||
|
<xrd:property name="/object/sections/sectionOptions/optionTarget/objectType"/>
|
||||||
|
<xrd:property name="/object/sections/sectionOptions/optionTarget/displayName"/>
|
||||||
|
<xrd:property name="/object/sections/sectionOptions/optionTarget/defaultDomainClass"/>
|
||||||
|
</xrd:attributes>
|
||||||
|
</xrd:adapter>
|
||||||
|
</xrd:context>
|
||||||
|
</xrd:adapters>
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<registry>
|
||||||
|
<!-- nothing yet -->
|
||||||
|
</registry>
|
||||||
|
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
<load>
|
||||||
|
<requires>
|
||||||
|
<table name="inits"/>
|
||||||
|
<table name="acs_objects"/>
|
||||||
|
<table name="cms_items"/>
|
||||||
|
<initializer class="com.arsdigita.cms.Initializer"/>
|
||||||
|
</requires>
|
||||||
|
<provides>
|
||||||
|
<table name="cam_decision_trees"/>
|
||||||
|
<initializer class="com.arsdigita.cms.contenttypes.DecisionTreeInitializer"/>
|
||||||
|
</provides>
|
||||||
|
<scripts>
|
||||||
|
<schema directory="ccm-cms-types-decisiontree"/>
|
||||||
|
<data class="com.arsdigita.cms.contenttypes.DecisionTreeLoader"/>
|
||||||
|
</scripts>
|
||||||
|
</load>
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
<upgrade>
|
||||||
|
|
||||||
|
<version from="1.0.3" to="6.6.0">
|
||||||
|
<script sql="ccm-cms-types-decisiontree/upgrade/::database::-1.0.3-6.6.0.sql"/>
|
||||||
|
<!-- (just for easy reference in copy'nd'past programming :-) )
|
||||||
|
<script class="com.arsdigita.cms.contenttypes.upgrade.CreateGenericContentTypes"/>
|
||||||
|
-->
|
||||||
|
</version>
|
||||||
|
|
||||||
|
</upgrade>
|
||||||
|
|
@ -0,0 +1,289 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2007 Red Hat Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.contenttypes;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.cms.CMS;
|
||||||
|
import com.arsdigita.cms.ContentItem;
|
||||||
|
import com.arsdigita.cms.ContentPage;
|
||||||
|
import com.arsdigita.cms.CustomCopy;
|
||||||
|
import com.arsdigita.cms.ItemCopier;
|
||||||
|
import com.arsdigita.cms.dispatcher.SimpleXMLGenerator;
|
||||||
|
import com.arsdigita.cms.dispatcher.XMLGenerator;
|
||||||
|
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||||
|
import com.arsdigita.domain.DomainObjectXMLRenderer;
|
||||||
|
import com.arsdigita.persistence.DataCollection;
|
||||||
|
import com.arsdigita.persistence.DataObject;
|
||||||
|
import com.arsdigita.persistence.OID;
|
||||||
|
import com.arsdigita.persistence.Session;
|
||||||
|
import com.arsdigita.persistence.SessionManager;
|
||||||
|
import com.arsdigita.persistence.metadata.Property;
|
||||||
|
import com.arsdigita.web.BaseApplicationServlet;
|
||||||
|
import com.arsdigita.xml.Element;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Decision Tree content type.
|
||||||
|
*
|
||||||
|
* This content type has been contributed by Camden.
|
||||||
|
*
|
||||||
|
* @author Carsten Clasohm
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class DecisionTree extends ContentPage implements XMLGenerator {
|
||||||
|
|
||||||
|
public static final Logger s_log = Logger.getLogger(DecisionTree.class);
|
||||||
|
|
||||||
|
public static final String ADAPTER_CONTEXT = SimpleXMLGenerator.class.getName();
|
||||||
|
|
||||||
|
public static final String BASE_DATA_OBJECT_TYPE =
|
||||||
|
"com.arsdigita.cms.contenttypes.DecisionTree";
|
||||||
|
|
||||||
|
public static final String CANCEL_URL = "cancelURL";
|
||||||
|
public static final String PARAM_RETURN_URL = "return_url";
|
||||||
|
public static final String FIRST_SECTION = "firstSection";
|
||||||
|
public static final String SECTIONS = "sections";
|
||||||
|
public static final String PARAM_SECTION_ID = "section_id";
|
||||||
|
public static final String PARAM_SECTION_OID = "section_oid";
|
||||||
|
public static final String BUTTON_CANCEL = "cancel";
|
||||||
|
public static final String BUTTON_NEXT = "next";
|
||||||
|
|
||||||
|
public DecisionTree() {
|
||||||
|
this(BASE_DATA_OBJECT_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DecisionTree(OID oid) throws DataObjectNotFoundException {
|
||||||
|
super(oid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DecisionTree(BigDecimal id) throws DataObjectNotFoundException {
|
||||||
|
this(new OID(BASE_DATA_OBJECT_TYPE, id));
|
||||||
|
}
|
||||||
|
|
||||||
|
public DecisionTree(DataObject obj) {
|
||||||
|
super(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DecisionTree(String type) {
|
||||||
|
super(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the base PDL object type for this item. Child classes
|
||||||
|
* should override this method to return the correct value.
|
||||||
|
*/
|
||||||
|
public String getBaseDataObjectType() {
|
||||||
|
return BASE_DATA_OBJECT_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCancelURL() {
|
||||||
|
return (String) get(CANCEL_URL);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCancelURL(String value) {
|
||||||
|
set(CANCEL_URL, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DecisionTreeSection getFirstSection() {
|
||||||
|
DataObject dataObject = (DataObject) get(FIRST_SECTION);
|
||||||
|
if (dataObject == null) { return null; }
|
||||||
|
return new DecisionTreeSection(dataObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFirstSection(DecisionTreeSection value) {
|
||||||
|
setAssociation(FIRST_SECTION, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add the specified TreeSection to this object. If there are no other sections,
|
||||||
|
* mark this one as "first", which makes it appear automatically when the
|
||||||
|
* content item is viewed.
|
||||||
|
*
|
||||||
|
* @param section the TreeSection to add
|
||||||
|
*/
|
||||||
|
public void addSection(DecisionTreeSection section) {
|
||||||
|
DecisionTreeSectionCollection sections = getSections();
|
||||||
|
boolean isFirst = sections.isEmpty();
|
||||||
|
add(SECTIONS, section);
|
||||||
|
if (isFirst)
|
||||||
|
setFirstSection(section);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DecisionTreeSectionCollection getSections() {
|
||||||
|
DecisionTreeSectionCollection sections =
|
||||||
|
new DecisionTreeSectionCollection((DataCollection)get(SECTIONS));
|
||||||
|
sections.addOrder(TITLE);
|
||||||
|
return sections;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the given TreeSection from this object.
|
||||||
|
*
|
||||||
|
* @param section the TreeSection to remove
|
||||||
|
*/
|
||||||
|
public void removeSection(DecisionTreeSection section) {
|
||||||
|
section.delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
public DecisionTreeSectionOptionCollection getOptions() {
|
||||||
|
Session ssn = SessionManager.getSession();
|
||||||
|
DataCollection collection = ssn.retrieve(DecisionTreeSectionOption
|
||||||
|
.BASE_DATA_OBJECT_TYPE);
|
||||||
|
|
||||||
|
DecisionTreeSectionOptionCollection options = new DecisionTreeSectionOptionCollection(collection);
|
||||||
|
options.addEqualsFilter("treeSection.tree.id", getID());
|
||||||
|
options.addOrder("treeSection.title, rank, label");
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DecisionTreeOptionTargetCollection getTargets() {
|
||||||
|
Session ssn = SessionManager.getSession();
|
||||||
|
DataCollection collection = ssn.retrieve(DecisionTreeOptionTarget
|
||||||
|
.BASE_DATA_OBJECT_TYPE);
|
||||||
|
|
||||||
|
DecisionTreeOptionTargetCollection options = new
|
||||||
|
DecisionTreeOptionTargetCollection(collection);
|
||||||
|
options.addEqualsFilter("matchOption.treeSection.tree.id", getID());
|
||||||
|
options.addOrder("matchOption.treeSection.title, matchOption.rank, matchOption.label");
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a URL parameter name, determine if that parameter should be included
|
||||||
|
* in the HTTP request for the next section.
|
||||||
|
*
|
||||||
|
* @param parameterName the name of the URL parameter to check
|
||||||
|
* @return true if the parameter is to be included in the next section request
|
||||||
|
*/
|
||||||
|
public static boolean preserveParameter(String parameterName) {
|
||||||
|
return (!PARAM_SECTION_ID.equals(parameterName) &&
|
||||||
|
!PARAM_SECTION_OID.equals(parameterName) &&
|
||||||
|
!PARAM_RETURN_URL.equals(parameterName) &&
|
||||||
|
!BUTTON_CANCEL.equals(parameterName) &&
|
||||||
|
!BUTTON_NEXT.equals(parameterName) &&
|
||||||
|
!BaseApplicationServlet.APPLICATION_ID_PARAMETER.equals(parameterName));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate the XML for a DecisionTree. In addition to what SimpleXMLGenerator does,
|
||||||
|
* this also stores information about the current request in an XML element.
|
||||||
|
*/
|
||||||
|
public void generateXML(PageState state, Element parent, String useContext) {
|
||||||
|
ContentItem item = CMS.getContext().getContentItem();
|
||||||
|
|
||||||
|
Element content = new Element("cms:item", CMS.CMS_XML_NS);
|
||||||
|
if (useContext != null)
|
||||||
|
content.addAttribute("useContext", useContext);
|
||||||
|
|
||||||
|
Element customInfo = new Element("customInfo");
|
||||||
|
customInfo.addAttribute("currentURL", state.getRequestURI());
|
||||||
|
content.addContent(customInfo);
|
||||||
|
|
||||||
|
// Add the URL parameters to the XML output, so we can include
|
||||||
|
// them has hidden form fields.
|
||||||
|
HttpServletRequest request = state.getRequest();
|
||||||
|
Enumeration parameterNames = request.getParameterNames();
|
||||||
|
while (parameterNames.hasMoreElements()) {
|
||||||
|
String name = (String) parameterNames.nextElement();
|
||||||
|
|
||||||
|
// Don't include the section_id parameter - that's
|
||||||
|
// not to be passed from section to section.
|
||||||
|
if (!preserveParameter(name))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Element parameters = new Element("parameters");
|
||||||
|
parameters.addAttribute("name", name);
|
||||||
|
parameters.addAttribute("value", request.getParameter(name));
|
||||||
|
|
||||||
|
content.addContent(parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
DomainObjectXMLRenderer renderer =
|
||||||
|
new DomainObjectXMLRenderer(content);
|
||||||
|
|
||||||
|
renderer.setWrapAttributes(true);
|
||||||
|
renderer.setWrapRoot(false);
|
||||||
|
renderer.setWrapObjects(false);
|
||||||
|
renderer.setRevisitFullObject(true);
|
||||||
|
|
||||||
|
renderer.walk(item, ADAPTER_CONTEXT);
|
||||||
|
|
||||||
|
parent.addContent(content);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Override ContentItem.copyProperty so that firstSection is handled
|
||||||
|
* like a component.
|
||||||
|
*/
|
||||||
|
public boolean copyProperty(CustomCopy source, Property property,
|
||||||
|
ItemCopier copier) {
|
||||||
|
String attribute = property.getName();
|
||||||
|
if (FIRST_SECTION.equals(attribute)) {
|
||||||
|
// We don't copy the FIRST_SECTION property here, because it's not marked
|
||||||
|
// as a component, and would cause a PublishedLink to be created, which
|
||||||
|
// results in performance problems during publication. Instead, we will
|
||||||
|
// set the FIRST_SECTION property as part of the copying of the SECTIONS
|
||||||
|
// property, see below.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SECTIONS.equals(attribute)) {
|
||||||
|
DecisionTree srcTree = (DecisionTree)source;
|
||||||
|
|
||||||
|
// We make sure that all objects we need below exist by copying
|
||||||
|
// the TreeSections associated with the source DecisionTree.
|
||||||
|
// The copier will store the OIDs of the copies, and won't
|
||||||
|
// recreate them when it does its own thing.
|
||||||
|
DecisionTreeSectionCollection srcSections = srcTree.getSections();
|
||||||
|
while (srcSections.next())
|
||||||
|
copier.copy(source, this, srcSections.getSection(), property);
|
||||||
|
|
||||||
|
DecisionTreeSection srcFirstSection = srcTree.getFirstSection();
|
||||||
|
if (srcFirstSection != null) {
|
||||||
|
// At this point, all associated TreeSections have been copied,
|
||||||
|
// so we can be sure that ItemCopier.getCopy() will return the
|
||||||
|
// copied TreeSection object.
|
||||||
|
setFirstSection((DecisionTreeSection)copier.getCopy(srcFirstSection.getOID()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Next, we go through all OptionTargets in the source object
|
||||||
|
// and set the TARGET_SECTION property of the corresponding
|
||||||
|
// destination DecisionTreeOptionTarget. Like FIRST_SECTION, the TARGET_SECTION
|
||||||
|
// property was skipped when the OptionTargets were copied.
|
||||||
|
DecisionTreeOptionTargetCollection srcTargets = srcTree.getTargets();
|
||||||
|
while (srcTargets.next()) {
|
||||||
|
DecisionTreeOptionTarget srcTarget = srcTargets.getTarget();
|
||||||
|
DecisionTreeSection srcSection = srcTarget.getTargetSection();
|
||||||
|
|
||||||
|
if (srcSection == null) continue;
|
||||||
|
|
||||||
|
DecisionTreeOptionTarget dstTarget = (DecisionTreeOptionTarget)copier.getCopy(srcTarget.getOID());
|
||||||
|
dstTarget.setTargetSection((DecisionTreeSection)copier.getCopy(srcSection.getOID()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.copyProperty(source, property, copier);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,109 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2007 Red Hat Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.contenttypes;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.contenttypes.ContentTypeInitializer;
|
||||||
|
import com.arsdigita.cms.search.ContentPageMetadataProvider;
|
||||||
|
import com.arsdigita.domain.DomainObject;
|
||||||
|
import com.arsdigita.domain.DomainObjectFactory;
|
||||||
|
import com.arsdigita.domain.DomainObjectInstantiator;
|
||||||
|
import com.arsdigita.persistence.DataObject;
|
||||||
|
import com.arsdigita.runtime.ContextInitEvent;
|
||||||
|
import com.arsdigita.runtime.DomainInitEvent;
|
||||||
|
import com.arsdigita.search.MetadataProviderRegistry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executes at each system startup and initializes the Decision Tree
|
||||||
|
* content type.
|
||||||
|
*
|
||||||
|
* Defines the content type specific properties and just uses the super class
|
||||||
|
* methods to register the content type with the (transient) content type store
|
||||||
|
* (map). This is done by runtimeRuntime startup method which runs the init()
|
||||||
|
* methods of all initializers (this one just using the parent implementation).
|
||||||
|
*
|
||||||
|
* @author Carsten Clasohm
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class DecisionTreeInitializer extends ContentTypeInitializer {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor, sets the PDL manifest file and object type string.
|
||||||
|
*/
|
||||||
|
public DecisionTreeInitializer() {
|
||||||
|
super("ccm-cms-types-decisiontree.pdl.mf", DecisionTree.BASE_DATA_OBJECT_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(DomainInitEvent evt) {
|
||||||
|
super.init(evt);
|
||||||
|
|
||||||
|
DomainObjectFactory f = evt.getFactory();
|
||||||
|
|
||||||
|
f.registerInstantiator(DecisionTreeSectionOption.BASE_DATA_OBJECT_TYPE
|
||||||
|
, new DomainObjectInstantiator() {
|
||||||
|
protected DomainObject doNewInstance(DataObject dataObject) {
|
||||||
|
return new DecisionTreeSectionOption(dataObject);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
f.registerInstantiator(DecisionTreeOptionTarget.BASE_DATA_OBJECT_TYPE
|
||||||
|
, new DomainObjectInstantiator() {
|
||||||
|
protected DomainObject doNewInstance(DataObject dataObject) {
|
||||||
|
return new DecisionTreeOptionTarget(dataObject);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(ContextInitEvent evt) {
|
||||||
|
super.init(evt);
|
||||||
|
|
||||||
|
MetadataProviderRegistry.registerAdapter(
|
||||||
|
DecisionTree.BASE_DATA_OBJECT_TYPE,
|
||||||
|
new ContentPageMetadataProvider());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves fully qualified traversal adapter file name.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getTraversalXML() {
|
||||||
|
return "WEB-INF/traversal-adapters/com/arsdigita/cms/contenttypes/DecisionTree.xml";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve location of this content type's internal default theme
|
||||||
|
* stylesheet(s) which concomitantly serve as a fallback if a custom theme
|
||||||
|
* is engaged.
|
||||||
|
*
|
||||||
|
* Custom themes usually will provide their own stylesheet(s) and their own
|
||||||
|
* access method, but may not support every content type.
|
||||||
|
*
|
||||||
|
* Overwrites parent method with AgendaItem specific value for use by the
|
||||||
|
* parent class worker methods.
|
||||||
|
*
|
||||||
|
* @return String array of XSL stylesheet files of the internal default theme
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String[] getStylesheets() {
|
||||||
|
return new String[] { INTERNAL_THEME_TYPES_DIR + "DecisionTree.xsl" };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2007 Red Hat Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.contenttypes;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.contenttypes.AbstractContentTypeLoader;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Intializes the database after the Decision Trees data model has been created.
|
||||||
|
*
|
||||||
|
* @author Carsten Clasohm
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class DecisionTreeLoader extends AbstractContentTypeLoader {
|
||||||
|
|
||||||
|
private static final String[] TYPES = {
|
||||||
|
"/WEB-INF/content-types/com/arsdigita/cms/contenttypes/DecisionTree.xml"
|
||||||
|
};
|
||||||
|
|
||||||
|
public String[] getTypes() {
|
||||||
|
return TYPES;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,176 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2007 Red Hat Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.arsdigita.cms.contenttypes;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.ContentItem;
|
||||||
|
import com.arsdigita.cms.CustomCopy;
|
||||||
|
import com.arsdigita.cms.ItemCopier;
|
||||||
|
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||||
|
import com.arsdigita.persistence.DataObject;
|
||||||
|
import com.arsdigita.persistence.OID;
|
||||||
|
import com.arsdigita.persistence.metadata.Property;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A section target of the Camden Decision Tree content type.
|
||||||
|
*
|
||||||
|
* @author Carsten Clasohm
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class DecisionTreeOptionTarget extends ContentItem {
|
||||||
|
|
||||||
|
/** PDL stuff */
|
||||||
|
public static final String BASE_DATA_OBJECT_TYPE =
|
||||||
|
"com.arsdigita.cms.contenttypes.DecisionTreeOptionTarget";
|
||||||
|
|
||||||
|
public static final String MATCH_OPTION = "matchOption";
|
||||||
|
public static final String TARGET_URL = "targetURL";
|
||||||
|
public static final String TARGET_SECTION = "targetSection";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default constructor, just delegates to a parameter constructor.
|
||||||
|
*/
|
||||||
|
public DecisionTreeOptionTarget() {
|
||||||
|
this(BASE_DATA_OBJECT_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param oid
|
||||||
|
* @throws DataObjectNotFoundException
|
||||||
|
*/
|
||||||
|
public DecisionTreeOptionTarget(OID oid)
|
||||||
|
throws DataObjectNotFoundException {
|
||||||
|
super(oid);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
* @param id
|
||||||
|
* @throws DataObjectNotFoundException
|
||||||
|
*/
|
||||||
|
public DecisionTreeOptionTarget(BigDecimal id)
|
||||||
|
throws DataObjectNotFoundException {
|
||||||
|
this(new OID(BASE_DATA_OBJECT_TYPE, id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
* @param obj
|
||||||
|
*/
|
||||||
|
public DecisionTreeOptionTarget(DataObject obj) {
|
||||||
|
super(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
* @param type
|
||||||
|
*/
|
||||||
|
public DecisionTreeOptionTarget(String type) {
|
||||||
|
super(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the base PDL object type for this item. Child classes
|
||||||
|
* should override this method to return the correct value.
|
||||||
|
*/
|
||||||
|
public String getBaseDataObjectType() {
|
||||||
|
return BASE_DATA_OBJECT_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public DecisionTreeSectionOption getMatchOption() {
|
||||||
|
DataObject dataObject = (DataObject) get(MATCH_OPTION);
|
||||||
|
if (dataObject == null) { return null; }
|
||||||
|
return new DecisionTreeSectionOption(dataObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
public void setMatchOption(DecisionTreeSectionOption value) {
|
||||||
|
setAssociation(MATCH_OPTION, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getTargetURL() {
|
||||||
|
return (String) get(TARGET_URL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
public void setTargetURL(String value) {
|
||||||
|
set(TARGET_URL, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public DecisionTreeSection getTargetSection() {
|
||||||
|
DataObject dataObject = (DataObject) get(TARGET_SECTION);
|
||||||
|
if (dataObject == null) { return null; }
|
||||||
|
return new DecisionTreeSection(dataObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param value
|
||||||
|
*/
|
||||||
|
public void setTargetSection(DecisionTreeSection value) {
|
||||||
|
set(TARGET_SECTION, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param source
|
||||||
|
* @param property
|
||||||
|
* @param copier
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean copyProperty(CustomCopy source, Property property,
|
||||||
|
ItemCopier copier) {
|
||||||
|
String attribute = property.getName();
|
||||||
|
if (TARGET_SECTION.equals(attribute)) {
|
||||||
|
// We don't copy the TARGET_SECTION property here, because it's not marked
|
||||||
|
// as a component, and would cause a PublishedLink to be created, which
|
||||||
|
// results in performance problems during publication. Instead, we will
|
||||||
|
// set the TARGET_SECTION property as part of the copying of the SECTIONS
|
||||||
|
// property in DecisionTree.copyProperty().
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.copyProperty(source, property, copier);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,72 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2007 Red Hat Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.contenttypes;
|
||||||
|
|
||||||
|
import com.arsdigita.domain.DomainCollection;
|
||||||
|
import com.arsdigita.domain.DomainObject;
|
||||||
|
import com.arsdigita.persistence.DataCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class contains a collection of TreeSection objects.
|
||||||
|
*
|
||||||
|
* @author Carsten Clasohm
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class DecisionTreeOptionTargetCollection extends DomainCollection {
|
||||||
|
|
||||||
|
public static final String versionId = "$Id$";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
public DecisionTreeOptionTargetCollection(DataCollection dataCollection) {
|
||||||
|
super(dataCollection);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the order of this Collection. This method needs to be called
|
||||||
|
* before <code>next()</code> is called on this collection.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void addOrder(String order) {
|
||||||
|
m_dataCollection.addOrder(order);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a <code>DomainObject</code> for the current position in
|
||||||
|
* the collection.
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public DomainObject getDomainObject() {
|
||||||
|
return new DecisionTreeOptionTarget(m_dataCollection.getDataObject());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a <code>Image</code> for the current position in
|
||||||
|
* the collection.
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
public DecisionTreeOptionTarget getTarget() {
|
||||||
|
return (DecisionTreeOptionTarget) getDomainObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
error.parameter_name_characters=This parameter can only contain letters, digits, or "-_"
|
||||||
|
form.none=-- none --
|
||||||
|
form.please_select=-- please select --
|
||||||
|
form_label.cancel_url=Cancel URL
|
||||||
|
form_label.description=Description
|
||||||
|
form_label.instructions=Instructions
|
||||||
|
form_label.label=Label
|
||||||
|
form_label.match_value=Value to Match
|
||||||
|
form_label.parameter_name=Parameter Name
|
||||||
|
form_label.section=Section
|
||||||
|
form_label.target_section=Target Section
|
||||||
|
form_label.target_url=Target URL
|
||||||
|
form_label.title=Title
|
||||||
|
form_label.value=Value
|
||||||
|
form_validation.target_required=Either a target URL or a target section is required.
|
||||||
|
form_validation.duplicate_target=Please enter a target URL or a target section, but not both.
|
||||||
|
properties.cancel_url=Cancel URL:
|
||||||
|
section_options.add_new_option=Add new option
|
||||||
|
section_options.add_option=Add Option
|
||||||
|
section_options.delete_option=Delete option
|
||||||
|
section_options.description=The options that belong to this decision tree's sections.
|
||||||
|
section_options.edit_option=Edit Option
|
||||||
|
section_options.move_option_name=Move option
|
||||||
|
section_options.move_to_beginning=Move to beginning
|
||||||
|
section_options.no_options_yet=No options yet
|
||||||
|
section_options.title=Section Options
|
||||||
|
section_options.view_all_options=View all options
|
||||||
|
option_targets.add_new_target=Add new target
|
||||||
|
option_targets.add_target=Add Target
|
||||||
|
option_targets.delete_target=Delete target
|
||||||
|
option_targets.description=The targets that belong to this decision treeS.
|
||||||
|
option_targets.edit_target=Edit Target
|
||||||
|
option_targets.no_targets_yet=No targets yet
|
||||||
|
option_targets.title=Option Targets
|
||||||
|
option_targets.view_all_targets=View all targets
|
||||||
|
tree_section.submission_cancelled=Submission cancelled
|
||||||
|
tree_sections.add_new_section=Add new section
|
||||||
|
tree_sections.add_section=Add Section
|
||||||
|
tree_sections.delete_section=Delete section
|
||||||
|
tree_sections.description=The sections that belong to this decision tree.
|
||||||
|
tree_sections.edit_section=Edit Section
|
||||||
|
tree_sections.no_sections_yet=No sections yet
|
||||||
|
tree_sections.title=Tree Sections
|
||||||
|
tree_sections.view_all_sections=View all sections
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
error.parameter_name_characters=Dieser Parameter lann nur Buchstaben, Zahlen oder "-_" enthalten.
|
||||||
|
form.none=-- keine --
|
||||||
|
form.please_select=-- bitte ausw\u00e4hlen --
|
||||||
|
form_label.cancel_url=URL Abrechen
|
||||||
|
form_label.description=Beschreibung
|
||||||
|
form_label.instructions=Anweisungen
|
||||||
|
form_label.label=Benennung
|
||||||
|
form_label.match_value=Korrespondierender Wert
|
||||||
|
form_label.parameter_name=Parameter Name
|
||||||
|
form_label.section=Sektion
|
||||||
|
form_label.target_section=Zielsektion
|
||||||
|
form_label.target_url=Ziel-URL
|
||||||
|
form_label.title=Titel
|
||||||
|
form_label.value=Wert
|
||||||
|
form_validation.target_required=Entweder eine Ziel-URL oder eine Ziel-Sektion isr erforderlich.
|
||||||
|
form_validation.duplicate_target=Bitte eine Ziel-URL oder eine Ziel-Sektion angeben, aber nicht beides.
|
||||||
|
properties.cancel_url=URL Abbrechen:
|
||||||
|
section_options.add_new_option=Eine neue Option hinzuf\u00fcgen
|
||||||
|
section_options.add_option=Option hinzuf\u00fcgen
|
||||||
|
section_options.delete_option=Option l\u00f6schen
|
||||||
|
section_options.description=Optionen, die zu dieser Sektion geh\u00f6ren.
|
||||||
|
section_options.edit_option=Option bearbeiten
|
||||||
|
section_options.move_option_name=Option verschieben
|
||||||
|
section_options.move_to_beginning=An den Anfang verschieben
|
||||||
|
section_options.no_options_yet=Bisher keine Optionen eingetragen.
|
||||||
|
section_options.title=Optionen in der Sektion
|
||||||
|
section_options.view_all_options=Alle Optionen anzeigen
|
||||||
|
option_targets.add_new_target=Ein neues Ziel hinzuf\u00fcgen
|
||||||
|
option_targets.add_target=Ziel hinzuf\u00fcgen
|
||||||
|
option_targets.delete_target=Ziel l\u00f6schen
|
||||||
|
option_targets.description=Ziele, die zu dieser Sektion geh\u00f6ren.
|
||||||
|
option_targets.edit_target=Ziel bearbeiten
|
||||||
|
option_targets.no_targets_yet=Bisher keine Ziele verf\u00fcgbar.
|
||||||
|
option_targets.title=Option Targets
|
||||||
|
option_targets.view_all_targets=Alle Ziele anzeigen
|
||||||
|
tree_section.submission_cancelled=Speichern abgebrochen
|
||||||
|
tree_sections.add_new_section=Eine neue Sektion hinzuf\u00fcgen
|
||||||
|
tree_sections.add_section=Sektion hinzuf\u00fcgen
|
||||||
|
tree_sections.delete_section=Sektion l\u00f6schen
|
||||||
|
tree_sections.description=Die Sektionen, die zu diesem Entscheidungsbaum geh\u00f6ren.
|
||||||
|
tree_sections.edit_section=Sektion bearbeiten
|
||||||
|
tree_sections.no_sections_yet=Bisher keine Sektionen verf\u00fcgbar.
|
||||||
|
tree_sections.title=Sektionen
|
||||||
|
tree_sections.view_all_sections=Alle Sektionen anzeigen
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
error.parameter_name_characters=This parameter can only contain letters, digits, or "-_"
|
||||||
|
form.none=-- none --
|
||||||
|
form.please_select=-- please select --
|
||||||
|
form_label.cancel_url=Cancel URL
|
||||||
|
form_label.description=Description
|
||||||
|
form_label.instructions=Instructions
|
||||||
|
form_label.label=Label
|
||||||
|
form_label.match_value=Value to Match
|
||||||
|
form_label.parameter_name=Parameter Name
|
||||||
|
form_label.section=Section
|
||||||
|
form_label.target_section=Target Section
|
||||||
|
form_label.target_url=Target URL
|
||||||
|
form_label.title=Title
|
||||||
|
form_label.value=Value
|
||||||
|
form_validation.target_required=Either a target URL or a target section is required.
|
||||||
|
form_validation.duplicate_target=Please enter a target URL or a target section, but not both.
|
||||||
|
properties.cancel_url=Cancel URL:
|
||||||
|
section_options.add_new_option=Add new option
|
||||||
|
section_options.add_option=Add Option
|
||||||
|
section_options.delete_option=Delete option
|
||||||
|
section_options.description=The options that belong to this decision tree's sections.
|
||||||
|
section_options.edit_option=Edit Option
|
||||||
|
section_options.move_option_name=Move option
|
||||||
|
section_options.move_to_beginning=Move to beginning
|
||||||
|
section_options.no_options_yet=No options yet
|
||||||
|
section_options.title=Section Options
|
||||||
|
section_options.view_all_options=View all options
|
||||||
|
option_targets.add_new_target=Add new target
|
||||||
|
option_targets.add_target=Add Target
|
||||||
|
option_targets.delete_target=Delete target
|
||||||
|
option_targets.description=The targets that belong to this decision treeS.
|
||||||
|
option_targets.edit_target=Edit Target
|
||||||
|
option_targets.no_targets_yet=No targets yet
|
||||||
|
option_targets.title=Option Targets
|
||||||
|
option_targets.view_all_targets=View all targets
|
||||||
|
tree_section.submission_cancelled=Submission cancelled
|
||||||
|
tree_sections.add_new_section=Add new section
|
||||||
|
tree_sections.add_section=Add Section
|
||||||
|
tree_sections.delete_section=Delete section
|
||||||
|
tree_sections.description=The sections that belong to this decision tree.
|
||||||
|
tree_sections.edit_section=Edit Section
|
||||||
|
tree_sections.no_sections_yet=No sections yet
|
||||||
|
tree_sections.title=Tree Sections
|
||||||
|
tree_sections.view_all_sections=View all sections
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
error.parameter_name_characters=This parameter can only contain letters, digits, or "-_"
|
||||||
|
form.none=-- none --
|
||||||
|
form.please_select=-- please select --
|
||||||
|
form_label.cancel_url=Cancel URL
|
||||||
|
form_label.description=Description
|
||||||
|
form_label.instructions=Instructions
|
||||||
|
form_label.label=Label
|
||||||
|
form_label.match_value=Value to Match
|
||||||
|
form_label.parameter_name=Parameter Name
|
||||||
|
form_label.section=Section
|
||||||
|
form_label.target_section=Target Section
|
||||||
|
form_label.target_url=Target URL
|
||||||
|
form_label.title=Title
|
||||||
|
form_label.value=Value
|
||||||
|
form_validation.target_required=Either a target URL or a target section is required.
|
||||||
|
form_validation.duplicate_target=Please enter a target URL or a target section, but not both.
|
||||||
|
properties.cancel_url=Cancel URL:
|
||||||
|
section_options.add_new_option=Add new option
|
||||||
|
section_options.add_option=Add Option
|
||||||
|
section_options.delete_option=Delete option
|
||||||
|
section_options.description=The options that belong to this decision tree's sections.
|
||||||
|
section_options.edit_option=Edit Option
|
||||||
|
section_options.move_option_name=Move option
|
||||||
|
section_options.move_to_beginning=Move to beginning
|
||||||
|
section_options.no_options_yet=No options yet
|
||||||
|
section_options.title=Section Options
|
||||||
|
section_options.view_all_options=View all options
|
||||||
|
option_targets.add_new_target=Add new target
|
||||||
|
option_targets.add_target=Add Target
|
||||||
|
option_targets.delete_target=Delete target
|
||||||
|
option_targets.description=The targets that belong to this decision treeS.
|
||||||
|
option_targets.edit_target=Edit Target
|
||||||
|
option_targets.no_targets_yet=No targets yet
|
||||||
|
option_targets.title=Option Targets
|
||||||
|
option_targets.view_all_targets=View all targets
|
||||||
|
tree_section.submission_cancelled=Submission cancelled
|
||||||
|
tree_sections.add_new_section=Add new section
|
||||||
|
tree_sections.add_section=Add Section
|
||||||
|
tree_sections.delete_section=Delete section
|
||||||
|
tree_sections.description=The sections that belong to this decision tree.
|
||||||
|
tree_sections.edit_section=Edit Section
|
||||||
|
tree_sections.no_sections_yet=No sections yet
|
||||||
|
tree_sections.title=Tree Sections
|
||||||
|
tree_sections.view_all_sections=View all sections
|
||||||
|
|
@ -0,0 +1,185 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2007 Red Hat Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.contenttypes;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.ContentPage;
|
||||||
|
import com.arsdigita.cms.TextAsset;
|
||||||
|
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||||
|
import com.arsdigita.persistence.DataCollection;
|
||||||
|
import com.arsdigita.persistence.DataObject;
|
||||||
|
import com.arsdigita.persistence.OID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A section of the Camden Decision Tree content type.
|
||||||
|
*
|
||||||
|
* @author Carsten Clasohm
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class DecisionTreeSection extends ContentPage {
|
||||||
|
|
||||||
|
public static final Logger s_log = Logger.getLogger(DecisionTreeSection.class);
|
||||||
|
|
||||||
|
public static final String BASE_DATA_OBJECT_TYPE =
|
||||||
|
"com.arsdigita.cms.contenttypes.DecisionTreeSection";
|
||||||
|
|
||||||
|
public static final String PARAMETER_NAME = "parameterName";
|
||||||
|
public static final String INSTRUCTIONS = "instructions";
|
||||||
|
public static final String SECTION_OPTIONS = "sectionOptions";
|
||||||
|
public static final String TREE = "tree";
|
||||||
|
|
||||||
|
public DecisionTreeSection() {
|
||||||
|
this(BASE_DATA_OBJECT_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DecisionTreeSection(OID oid) throws DataObjectNotFoundException {
|
||||||
|
super(oid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DecisionTreeSection(BigDecimal id) throws DataObjectNotFoundException {
|
||||||
|
this(new OID(BASE_DATA_OBJECT_TYPE, id));
|
||||||
|
}
|
||||||
|
|
||||||
|
public DecisionTreeSection(DataObject obj) {
|
||||||
|
super(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DecisionTreeSection(String type) {
|
||||||
|
super(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getBaseDataObjectType() {
|
||||||
|
return BASE_DATA_OBJECT_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void beforeDelete() {
|
||||||
|
super.beforeDelete();
|
||||||
|
|
||||||
|
// Clear the DecisionTree's firstSection field if it points to
|
||||||
|
// this TreeSection.
|
||||||
|
DecisionTree tree = getTree();
|
||||||
|
if (this.equals(tree.getFirstSection())) {
|
||||||
|
tree.setFirstSection(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete all OptionTargets which have this TreeSection as their target.
|
||||||
|
DecisionTreeOptionTargetCollection targets = tree.getTargets();
|
||||||
|
targets.addEqualsFilter("targetSection.id", getID());
|
||||||
|
while (targets.next()) {
|
||||||
|
targets.getTarget().delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getParameterName() {
|
||||||
|
return (String) get(PARAMETER_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParameterName(String value) {
|
||||||
|
set(PARAMETER_NAME, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextAsset getInstructions() {
|
||||||
|
DataObject dataObject = (DataObject)get(INSTRUCTIONS);
|
||||||
|
if (dataObject == null) { return null; }
|
||||||
|
return new TextAsset(dataObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInstructions(TextAsset value) {
|
||||||
|
setAssociation(INSTRUCTIONS, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DecisionTreeSectionOptionCollection getOptions() {
|
||||||
|
return new DecisionTreeSectionOptionCollection(
|
||||||
|
(DataCollection) get(SECTION_OPTIONS));
|
||||||
|
}
|
||||||
|
|
||||||
|
public DecisionTree getTree() {
|
||||||
|
return new DecisionTree((DataObject) get(TREE));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxOptionRank() {
|
||||||
|
DecisionTreeSectionOptionCollection options = getOptions();
|
||||||
|
options.addOrder(DecisionTreeSectionOption.RANK + " desc");
|
||||||
|
|
||||||
|
int maxRank = 0;
|
||||||
|
if (options.next())
|
||||||
|
maxRank = options.getOption().getRank().intValue();
|
||||||
|
options.close();
|
||||||
|
|
||||||
|
return maxRank;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Change the rank of the option with the given id within this object.
|
||||||
|
* Sets the option rank to that given, and moves all other option ranks
|
||||||
|
* as appropriate. If the new rank is greater than the current rank,
|
||||||
|
* options in between will be moved to a numerically lower rank. If the
|
||||||
|
* new rank is less than the current rank than options in between will be
|
||||||
|
* moved to a higher rank.
|
||||||
|
*
|
||||||
|
* @param source the option to reorder
|
||||||
|
* @param rank the new rank for the option. This must be between 1 and
|
||||||
|
* the max section rank inclusively.
|
||||||
|
*/
|
||||||
|
public void changeOptionRank(DecisionTreeSectionOption source, int destRank) {
|
||||||
|
Integer r = source.getRank();
|
||||||
|
if (r == null) {
|
||||||
|
throw new IllegalStateException(source + " has null rank");
|
||||||
|
}
|
||||||
|
|
||||||
|
int curRank = r.intValue();
|
||||||
|
|
||||||
|
if (s_log.isDebugEnabled()) {
|
||||||
|
s_log.debug("*** changeSectionRank, section ID = " + source.getID() +
|
||||||
|
", curRank = " + curRank +
|
||||||
|
", destRank = " + destRank);
|
||||||
|
}
|
||||||
|
|
||||||
|
DecisionTreeSectionOptionCollection coll = getOptions();
|
||||||
|
coll.addOrder(DecisionTreeSectionOption.RANK);
|
||||||
|
if (curRank > destRank) {
|
||||||
|
coll.setRange(new Integer(destRank), new Integer(curRank));
|
||||||
|
int rank = destRank;
|
||||||
|
while (coll.next()) {
|
||||||
|
DecisionTreeSectionOption cur = coll.getOption();
|
||||||
|
cur.setRank(new Integer(rank + 1));
|
||||||
|
cur.save();
|
||||||
|
rank++;
|
||||||
|
}
|
||||||
|
source.setRank(new Integer(destRank));
|
||||||
|
} else if (curRank < destRank) {
|
||||||
|
coll.setRange(new Integer(curRank + 1), new Integer(destRank + 1));
|
||||||
|
int rank = curRank + 1;
|
||||||
|
while (coll.next()) {
|
||||||
|
DecisionTreeSectionOption cur = coll.getOption();
|
||||||
|
cur.setRank(new Integer(rank - 1));
|
||||||
|
cur.save();
|
||||||
|
rank++;
|
||||||
|
}
|
||||||
|
source.setRank(new Integer(destRank));
|
||||||
|
}
|
||||||
|
coll.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,71 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2007 Red Hat Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.contenttypes;
|
||||||
|
|
||||||
|
import com.arsdigita.domain.DomainCollection;
|
||||||
|
import com.arsdigita.domain.DomainObject;
|
||||||
|
import com.arsdigita.persistence.DataCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class contains a collection of TreeSection objects.
|
||||||
|
*
|
||||||
|
* @author Carsten Clasohm
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class DecisionTreeSectionCollection extends DomainCollection {
|
||||||
|
|
||||||
|
public static final String versionId = "$Id$";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
public DecisionTreeSectionCollection(DataCollection dataCollection) {
|
||||||
|
super(dataCollection);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the order of this Collection. This method needs to be called
|
||||||
|
* before <code>next()</code> is called on this collection.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void addOrder(String order) {
|
||||||
|
m_dataCollection.addOrder(order);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a <code>DomainObject</code> for the current position in
|
||||||
|
* the collection.
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
public DomainObject getDomainObject() {
|
||||||
|
return new DecisionTreeSection(m_dataCollection.getDataObject());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a <code>Image</code> for the current position in
|
||||||
|
* the collection.
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
public DecisionTreeSection getSection() {
|
||||||
|
return (DecisionTreeSection) getDomainObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,113 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2007 Red Hat Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.contenttypes;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.ContentItem;
|
||||||
|
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||||
|
import com.arsdigita.persistence.DataObject;
|
||||||
|
import com.arsdigita.persistence.OID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A section option of the Camden Decision Tree content type.
|
||||||
|
*
|
||||||
|
* @author Carsten Clasohm
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class DecisionTreeSectionOption extends ContentItem {
|
||||||
|
private static final Logger s_log = Logger.getLogger(
|
||||||
|
DecisionTreeSectionOption.class);
|
||||||
|
|
||||||
|
public static final String BASE_DATA_OBJECT_TYPE =
|
||||||
|
"com.arsdigita.cms.contenttypes.DecisionTreeSectionOption";
|
||||||
|
|
||||||
|
public static final String TREE_SECTION = "treeSection";
|
||||||
|
public static final String RANK = "rank";
|
||||||
|
public static final String LABEL = "label";
|
||||||
|
public static final String VALUE = "value";
|
||||||
|
|
||||||
|
public DecisionTreeSectionOption() {
|
||||||
|
this(BASE_DATA_OBJECT_TYPE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DecisionTreeSectionOption(OID oid)
|
||||||
|
throws DataObjectNotFoundException {
|
||||||
|
super(oid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DecisionTreeSectionOption(BigDecimal id)
|
||||||
|
throws DataObjectNotFoundException {
|
||||||
|
this(new OID(BASE_DATA_OBJECT_TYPE, id));
|
||||||
|
}
|
||||||
|
|
||||||
|
public DecisionTreeSectionOption(DataObject obj) {
|
||||||
|
super(obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DecisionTreeSectionOption(String type) {
|
||||||
|
super(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the base PDL object type for this item. Child classes
|
||||||
|
* should override this method to return the correct value.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String getBaseDataObjectType() {
|
||||||
|
return BASE_DATA_OBJECT_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DecisionTreeSection getSection() {
|
||||||
|
DataObject dataObject = (DataObject) get(TREE_SECTION);
|
||||||
|
if (dataObject == null) { return null; }
|
||||||
|
return new DecisionTreeSection(dataObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSection(DecisionTreeSection value) {
|
||||||
|
setAssociation(TREE_SECTION, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getRank() {
|
||||||
|
return (Integer) get(RANK);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRank(Integer value) {
|
||||||
|
set(RANK, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLabel() {
|
||||||
|
return (String) get(LABEL);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLabel(String value) {
|
||||||
|
set(LABEL, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue() {
|
||||||
|
return (String) get(VALUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value) {
|
||||||
|
set(VALUE, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,70 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2007 Red Hat Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.contenttypes;
|
||||||
|
|
||||||
|
import com.arsdigita.domain.DomainCollection;
|
||||||
|
import com.arsdigita.domain.DomainObject;
|
||||||
|
import com.arsdigita.persistence.DataCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class contains a collection of SectionOption objects.
|
||||||
|
*
|
||||||
|
* @author Carsten Clasohm
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class DecisionTreeSectionOptionCollection extends DomainCollection {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
public DecisionTreeSectionOptionCollection(DataCollection dataCollection) {
|
||||||
|
super(dataCollection);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the order of this Collection. This method needs to be called
|
||||||
|
* before <code>next()</code> is called on this collection.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void addOrder(String order) {
|
||||||
|
m_dataCollection.addOrder(order);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a <code>DomainObject</code> for the current position in
|
||||||
|
* the collection.
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
@Override
|
||||||
|
public DomainObject getDomainObject() {
|
||||||
|
return new DecisionTreeSectionOption(m_dataCollection.getDataObject());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a <code>Image</code> for the current position in
|
||||||
|
* the collection.
|
||||||
|
*
|
||||||
|
**/
|
||||||
|
public DecisionTreeSectionOption getOption() {
|
||||||
|
return (DecisionTreeSectionOption) getDomainObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,100 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2007 Red Hat Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.contenttypes;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.arsdigita.cms.contenttypes.ContentItemTraversalAdapter;
|
||||||
|
import com.arsdigita.dispatcher.DispatcherHelper;
|
||||||
|
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||||
|
import com.arsdigita.domain.DomainObject;
|
||||||
|
import com.arsdigita.domain.SimpleDomainObjectTraversalAdapter;
|
||||||
|
import com.arsdigita.persistence.metadata.Property;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class DecisionTreeTraversalAdapter extends
|
||||||
|
ContentItemTraversalAdapter {
|
||||||
|
|
||||||
|
private static final Logger s_log = Logger.getLogger(DecisionTreeTraversalAdapter.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public DecisionTreeTraversalAdapter() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param adapter
|
||||||
|
*/
|
||||||
|
public DecisionTreeTraversalAdapter(SimpleDomainObjectTraversalAdapter adapter) {
|
||||||
|
super(adapter);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param obj
|
||||||
|
* @param path
|
||||||
|
* @param prop
|
||||||
|
* @param context
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean processProperty(DomainObject obj, String path,
|
||||||
|
Property prop, String context) {
|
||||||
|
|
||||||
|
HttpServletRequest request = DispatcherHelper.getRequest();
|
||||||
|
|
||||||
|
if ("/object/sections/title".equals(path) ||
|
||||||
|
"/object/sections/instructions".equals(path) ||
|
||||||
|
"/object/sections/sectionOptions".equals(path)) {
|
||||||
|
// Only include one TreeSection in the output.
|
||||||
|
// Which one depends on the section_id parameter.
|
||||||
|
DecisionTreeSection section = (DecisionTreeSection) obj;
|
||||||
|
DecisionTreeSection selectedSection = null;
|
||||||
|
String sectionID = request.getParameter("section_id");
|
||||||
|
if (sectionID == null || "".equals(sectionID)) {
|
||||||
|
DecisionTree tree = section.getTree();
|
||||||
|
selectedSection = tree.getFirstSection();
|
||||||
|
|
||||||
|
if (selectedSection == null) {
|
||||||
|
throw new RuntimeException("The first section has not been set for tree " + tree);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
selectedSection = new
|
||||||
|
DecisionTreeSection(new BigDecimal(sectionID));
|
||||||
|
}
|
||||||
|
catch (DataObjectNotFoundException e) {
|
||||||
|
throw new RuntimeException("Cannot find section for section_id parameter " + sectionID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return section.equals(selectedSection);
|
||||||
|
} else {
|
||||||
|
return super.processProperty(obj, path, prop, context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2007 Red Hat Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.contenttypes;
|
||||||
|
|
||||||
|
import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Miscellaneous utility methods for the Decision Tree content type.
|
||||||
|
*
|
||||||
|
* @author Carsten Clasohm
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class DecisionTreeUtil {
|
||||||
|
public static final String BUNDLE_NAME =
|
||||||
|
"com.arsdigita.camden.cms.contenttypes.DecisionTreeResources";
|
||||||
|
|
||||||
|
public static GlobalizedMessage globalize(String key) {
|
||||||
|
return new GlobalizedMessage(key, BUNDLE_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GlobalizedMessage globalize(String key, Object[] args) {
|
||||||
|
return new GlobalizedMessage(key, BUNDLE_NAME, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,131 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2007 Red Hat Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.ColumnPanel;
|
||||||
|
import com.arsdigita.bebop.Form;
|
||||||
|
import com.arsdigita.bebop.FormProcessException;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.SaveCancelSection;
|
||||||
|
import com.arsdigita.bebop.event.FormInitListener;
|
||||||
|
import com.arsdigita.bebop.event.FormProcessListener;
|
||||||
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
|
import com.arsdigita.bebop.event.FormSubmissionListener;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTreeSectionOption;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTreeUtil;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A form to confirm deletion of a single section of a DecisionTree.
|
||||||
|
*
|
||||||
|
* @author Carsten Clasohm
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class DecisionTreeOptionDeleteForm extends Form
|
||||||
|
implements FormInitListener,
|
||||||
|
FormSubmissionListener,
|
||||||
|
FormProcessListener
|
||||||
|
{
|
||||||
|
private final static Logger s_log = Logger.getLogger(
|
||||||
|
DecisionTreeOptionDeleteForm.class.getName());
|
||||||
|
|
||||||
|
protected ItemSelectionModel m_selTree;
|
||||||
|
protected ItemSelectionModel m_selOption;
|
||||||
|
protected SaveCancelSection m_saveCancelSection;
|
||||||
|
private Label m_optionLabel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param selTree
|
||||||
|
* @param selOption
|
||||||
|
*/
|
||||||
|
public DecisionTreeOptionDeleteForm (ItemSelectionModel selTree,
|
||||||
|
ItemSelectionModel selOption) {
|
||||||
|
|
||||||
|
super("DecisionTreeOptionDeleteForm", new ColumnPanel(2));
|
||||||
|
m_selTree = selTree;
|
||||||
|
m_selOption = selOption;
|
||||||
|
|
||||||
|
ColumnPanel panel = (ColumnPanel)getPanel();
|
||||||
|
panel.setBorder(false);
|
||||||
|
panel.setPadColor("#FFFFFF");
|
||||||
|
panel.setColumnWidth(1, "20%");
|
||||||
|
panel.setColumnWidth(2, "80%");
|
||||||
|
panel.setWidth("100%");
|
||||||
|
|
||||||
|
m_optionLabel = new Label("Option Label");
|
||||||
|
add(m_optionLabel, ColumnPanel.FULL_WIDTH | ColumnPanel.LEFT);
|
||||||
|
addSaveCancelSection();
|
||||||
|
|
||||||
|
addInitListener(this);
|
||||||
|
addSubmissionListener(this);
|
||||||
|
addProcessListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
protected SaveCancelSection addSaveCancelSection () {
|
||||||
|
m_saveCancelSection = new SaveCancelSection();
|
||||||
|
m_saveCancelSection.getSaveButton().setButtonLabel("Delete");
|
||||||
|
add(m_saveCancelSection, ColumnPanel.FULL_WIDTH | ColumnPanel.LEFT);
|
||||||
|
return m_saveCancelSection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param event
|
||||||
|
* @throws FormProcessException
|
||||||
|
*/
|
||||||
|
public void init ( FormSectionEvent event ) throws FormProcessException {
|
||||||
|
PageState state = event.getPageState();
|
||||||
|
|
||||||
|
BigDecimal id = new BigDecimal(m_selOption
|
||||||
|
.getSelectedKey(state).toString());
|
||||||
|
DecisionTreeSectionOption option = new DecisionTreeSectionOption(id);
|
||||||
|
|
||||||
|
m_optionLabel.setLabel(option.getLabel(), state);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void submitted ( FormSectionEvent event ) throws FormProcessException {
|
||||||
|
PageState state = event.getPageState();
|
||||||
|
|
||||||
|
if ( m_saveCancelSection.getCancelButton().isSelected(state) ) {
|
||||||
|
throw new FormProcessException( (String) DecisionTreeUtil
|
||||||
|
.globalize("tree_section.submission_cancelled").localize());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void process ( FormSectionEvent event ) throws FormProcessException {
|
||||||
|
PageState state = event.getPageState();
|
||||||
|
|
||||||
|
BigDecimal id = new BigDecimal(m_selOption
|
||||||
|
.getSelectedKey(state).toString());
|
||||||
|
DecisionTreeSectionOption option = new DecisionTreeSectionOption(id);
|
||||||
|
|
||||||
|
option.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,278 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2007 Red Hat Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.TooManyListenersException;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.ColumnPanel;
|
||||||
|
import com.arsdigita.bebop.Form;
|
||||||
|
import com.arsdigita.bebop.FormData;
|
||||||
|
import com.arsdigita.bebop.FormProcessException;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.bebop.Page;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.SaveCancelSection;
|
||||||
|
import com.arsdigita.bebop.event.FormInitListener;
|
||||||
|
import com.arsdigita.bebop.event.FormProcessListener;
|
||||||
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
|
import com.arsdigita.bebop.event.FormSubmissionListener;
|
||||||
|
import com.arsdigita.bebop.event.PrintEvent;
|
||||||
|
import com.arsdigita.bebop.event.PrintListener;
|
||||||
|
import com.arsdigita.bebop.form.Option;
|
||||||
|
import com.arsdigita.bebop.form.SingleSelect;
|
||||||
|
import com.arsdigita.bebop.form.TextField;
|
||||||
|
import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
||||||
|
import com.arsdigita.bebop.parameters.TrimmedStringParameter;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTree;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTreeSection;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTreeSectionCollection;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTreeSectionOption;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTreeUtil;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Form to edit a SectionOption for a DecisionTree.
|
||||||
|
*
|
||||||
|
* @author Carsten Clasohm
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class DecisionTreeOptionEditForm extends Form
|
||||||
|
implements FormInitListener,
|
||||||
|
FormProcessListener,
|
||||||
|
FormSubmissionListener {
|
||||||
|
|
||||||
|
private final static Logger s_log = Logger.getLogger(
|
||||||
|
DecisionTreeOptionEditForm.class);
|
||||||
|
|
||||||
|
private ItemSelectionModel m_selTree;
|
||||||
|
private ItemSelectionModel m_selOption;
|
||||||
|
|
||||||
|
private DecisionTreeViewOptions m_container;
|
||||||
|
|
||||||
|
private SaveCancelSection m_saveCancelSection;
|
||||||
|
private SingleSelect m_sectionWidget;
|
||||||
|
|
||||||
|
public static final String LABEL = "label";
|
||||||
|
public static final String VALUE = "value";
|
||||||
|
public static final String SECTION = "section";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param selTree the current article
|
||||||
|
* @param selOption the current section
|
||||||
|
*/
|
||||||
|
public DecisionTreeOptionEditForm(ItemSelectionModel selTree,
|
||||||
|
ItemSelectionModel selOption) {
|
||||||
|
this(selTree, selOption, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param selArticle the current article
|
||||||
|
* @param selOption the current section
|
||||||
|
* @param container container which this form is added to
|
||||||
|
*/
|
||||||
|
public DecisionTreeOptionEditForm(ItemSelectionModel selTree,
|
||||||
|
ItemSelectionModel selOption,
|
||||||
|
DecisionTreeViewOptions container) {
|
||||||
|
super("DecisionTreeOptionEditForm", new ColumnPanel(2));
|
||||||
|
m_selTree = selTree;
|
||||||
|
m_selOption = selOption;
|
||||||
|
m_container = container;
|
||||||
|
|
||||||
|
setMethod(Form.POST);
|
||||||
|
setEncType("multipart/form-data");
|
||||||
|
|
||||||
|
ColumnPanel panel = (ColumnPanel)getPanel();
|
||||||
|
panel.setBorder(false);
|
||||||
|
panel.setPadColor("#FFFFFF");
|
||||||
|
panel.setColumnWidth(1, "20%");
|
||||||
|
panel.setColumnWidth(2, "80%");
|
||||||
|
panel.setWidth("100%");
|
||||||
|
|
||||||
|
addWidgets();
|
||||||
|
addSaveCancelSection();
|
||||||
|
|
||||||
|
addInitListener(this);
|
||||||
|
addSubmissionListener(this);
|
||||||
|
addProcessListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiate and add a save/cancel section to the form.
|
||||||
|
*
|
||||||
|
* @return the SaveCancelSection that was added
|
||||||
|
*/
|
||||||
|
protected SaveCancelSection addSaveCancelSection() {
|
||||||
|
m_saveCancelSection = new SaveCancelSection();
|
||||||
|
add(m_saveCancelSection, ColumnPanel.FULL_WIDTH | ColumnPanel.LEFT);
|
||||||
|
return m_saveCancelSection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the save/cancel section from this form.
|
||||||
|
*/
|
||||||
|
public SaveCancelSection getSaveCancelSection() {
|
||||||
|
return m_saveCancelSection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set up the dynamic options for the section select widget.
|
||||||
|
*/
|
||||||
|
private void initSectionOptions(PrintEvent e) {
|
||||||
|
PageState state = e.getPageState();
|
||||||
|
SingleSelect target = (SingleSelect) e.getTarget();
|
||||||
|
DecisionTree tree = (DecisionTree)m_selTree.getSelectedObject(state);
|
||||||
|
|
||||||
|
if (tree != null) {
|
||||||
|
DecisionTreeSectionCollection sections = tree.getSections();
|
||||||
|
if (sections != null) {
|
||||||
|
while (sections.next()) {
|
||||||
|
DecisionTreeSection section = sections.getSection();
|
||||||
|
Option option = new Option(section.getID().toString(), section.getTitle());
|
||||||
|
target.addOption(option, state);
|
||||||
|
}
|
||||||
|
sections.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Form initialisation hook.
|
||||||
|
*/
|
||||||
|
public void init(FormSectionEvent fse) {
|
||||||
|
PageState state = fse.getPageState();
|
||||||
|
FormData data = fse.getFormData();
|
||||||
|
|
||||||
|
if (m_selOption.getSelectedKey(state) != null) {
|
||||||
|
BigDecimal id = new BigDecimal(m_selOption.getSelectedKey(state).toString());
|
||||||
|
// retrieve the selected Option from the persistence layer
|
||||||
|
DecisionTreeSectionOption sectionOption = new DecisionTreeSectionOption(id);
|
||||||
|
|
||||||
|
data.put(SECTION, sectionOption.getSection().getID());
|
||||||
|
data.put(LABEL, sectionOption.getLabel());
|
||||||
|
data.put(VALUE, sectionOption.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add form widgets for a Section.
|
||||||
|
*/
|
||||||
|
protected void addWidgets() {
|
||||||
|
Option pleaseSelect = new Option("", (String)DecisionTreeUtil.globalize("form.please_select").localize());
|
||||||
|
|
||||||
|
add(new Label(DecisionTreeUtil
|
||||||
|
.globalize("form_label.section")));
|
||||||
|
m_sectionWidget = new SingleSelect(SECTION);
|
||||||
|
m_sectionWidget.addValidationListener(new NotNullValidationListener());
|
||||||
|
m_sectionWidget.addOption(pleaseSelect);
|
||||||
|
|
||||||
|
try {
|
||||||
|
m_sectionWidget.addPrintListener(new PrintListener() {
|
||||||
|
public void prepare(PrintEvent e) {
|
||||||
|
initSectionOptions(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (TooManyListenersException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
add(m_sectionWidget);
|
||||||
|
|
||||||
|
add(new Label(DecisionTreeUtil
|
||||||
|
.globalize("form_label.label")));
|
||||||
|
TextField labelWidget = new TextField(new TrimmedStringParameter(LABEL));
|
||||||
|
labelWidget.addValidationListener(new NotNullValidationListener());
|
||||||
|
labelWidget.setSize(60);
|
||||||
|
add(labelWidget);
|
||||||
|
|
||||||
|
add(new Label(DecisionTreeUtil.globalize("form_label.value")));
|
||||||
|
TextField valueWidget = new TextField(new TrimmedStringParameter(VALUE));
|
||||||
|
valueWidget.addValidationListener(new NotNullValidationListener());
|
||||||
|
valueWidget.setSize(60);
|
||||||
|
add(valueWidget);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called on form submission. Check to see if the user clicked the
|
||||||
|
* cancel button. If they did, don't continue with the form.
|
||||||
|
*/
|
||||||
|
public void submitted(FormSectionEvent event)
|
||||||
|
throws FormProcessException {
|
||||||
|
PageState state = event.getPageState();
|
||||||
|
|
||||||
|
if ( m_saveCancelSection.getCancelButton()
|
||||||
|
.isSelected(state) && m_container != null) {
|
||||||
|
m_container.onlyShowComponent(
|
||||||
|
state, DecisionTreeViewOptions.OPTION_TABLE +
|
||||||
|
m_container.getTypeIDStr());
|
||||||
|
throw new FormProcessException(
|
||||||
|
(String)DecisionTreeUtil
|
||||||
|
.globalize("tree_section.submission_cancelled")
|
||||||
|
.localize());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called after form has been validated. Create the new SectionOption and
|
||||||
|
* assign it to the current DecisionTree.
|
||||||
|
*/
|
||||||
|
public void process(FormSectionEvent event) throws FormProcessException {
|
||||||
|
PageState state = event.getPageState();
|
||||||
|
FormData data = event.getFormData();
|
||||||
|
|
||||||
|
DecisionTreeSection section = new DecisionTreeSection(new BigDecimal((String)data.get(SECTION)));
|
||||||
|
|
||||||
|
DecisionTreeSectionOption option = null;
|
||||||
|
if (m_selOption.getSelectedKey(state) != null) {
|
||||||
|
BigDecimal id = new BigDecimal(m_selOption
|
||||||
|
.getSelectedKey(state).toString());
|
||||||
|
// retrieve the selected Option from the persistence layer
|
||||||
|
option = new DecisionTreeSectionOption(id);
|
||||||
|
} else {
|
||||||
|
option = new DecisionTreeSectionOption();
|
||||||
|
option.setName("DecisionTreeSectionOption " + option.getID());
|
||||||
|
int rank = section.getMaxOptionRank() + 1;
|
||||||
|
option.setRank(Integer.valueOf(rank));
|
||||||
|
}
|
||||||
|
|
||||||
|
String label = (String)data.get(LABEL);
|
||||||
|
String value = (String)data.get(VALUE);
|
||||||
|
|
||||||
|
option.setSection(section);
|
||||||
|
option.setLabel(label);
|
||||||
|
option.setValue(value);
|
||||||
|
|
||||||
|
if (m_container != null) {
|
||||||
|
m_container.onlyShowComponent(
|
||||||
|
state,
|
||||||
|
DecisionTreeViewOptions.OPTION_TABLE +
|
||||||
|
m_container.getTypeIDStr());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void register(Page p) {
|
||||||
|
super.register(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,276 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2007 Red Hat Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.Component;
|
||||||
|
import com.arsdigita.bebop.ControlLink;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.Table;
|
||||||
|
import com.arsdigita.bebop.event.TableActionEvent;
|
||||||
|
import com.arsdigita.bebop.event.TableActionListener;
|
||||||
|
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.contenttypes.DecisionTree;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTreeSection;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTreeSectionOption;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTreeSectionOptionCollection;
|
||||||
|
import com.arsdigita.cms.ContentItem;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.SecurityManager;
|
||||||
|
import com.arsdigita.cms.dispatcher.Utilities;
|
||||||
|
import com.arsdigita.util.LockableImpl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A table that displays the options for the currently
|
||||||
|
* selected DecisionTree.
|
||||||
|
*
|
||||||
|
* @author Carsten Clasohm
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class DecisionTreeOptionTable extends Table
|
||||||
|
{
|
||||||
|
// column headings
|
||||||
|
public static final String COL_SECTION = "Section";
|
||||||
|
public static final String COL_OPTION = "Option";
|
||||||
|
public static final String COL_EDIT = "Edit";
|
||||||
|
public static final String COL_MOVE = "Move";
|
||||||
|
public static final String COL_DEL = "Delete";
|
||||||
|
|
||||||
|
private ItemSelectionModel m_selTree;
|
||||||
|
private ItemSelectionModel m_selOption;
|
||||||
|
private ItemSelectionModel m_moveOption;
|
||||||
|
|
||||||
|
private static final Logger s_log = Logger.getLogger(
|
||||||
|
DecisionTreeOptionTable.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param selTree a selection model that returns the MultiPartArticle
|
||||||
|
* which holds the sections to display.
|
||||||
|
*/
|
||||||
|
public DecisionTreeOptionTable(ItemSelectionModel selTree,
|
||||||
|
ItemSelectionModel moveOption) {
|
||||||
|
super();
|
||||||
|
m_selTree = selTree;
|
||||||
|
m_moveOption = moveOption;
|
||||||
|
|
||||||
|
TableColumnModel model = getColumnModel();
|
||||||
|
model.add(new TableColumn(0, COL_SECTION));
|
||||||
|
model.add(new TableColumn(1, COL_OPTION));
|
||||||
|
model.add(new TableColumn(2, COL_EDIT));
|
||||||
|
model.add(new TableColumn(3, COL_MOVE));
|
||||||
|
model.add(new TableColumn(4, COL_DEL));
|
||||||
|
|
||||||
|
model.get(2).setCellRenderer(new SectionTableCellRenderer(true));
|
||||||
|
model.get(3).setCellRenderer(new SectionTableCellRenderer(true));
|
||||||
|
model.get(4).setCellRenderer(new SectionTableCellRenderer(true));
|
||||||
|
|
||||||
|
setModelBuilder(new OptionTableModelBuilder(m_selTree, m_moveOption));
|
||||||
|
|
||||||
|
addTableActionListener ( new TableActionListener () {
|
||||||
|
public void cellSelected ( TableActionEvent event ) {
|
||||||
|
PageState state = event.getPageState();
|
||||||
|
|
||||||
|
TableColumn col = getColumnModel()
|
||||||
|
.get(event.getColumn().intValue());
|
||||||
|
String colName = (String)col.getHeaderValue();
|
||||||
|
|
||||||
|
if ( COL_MOVE.equals(colName) ) {
|
||||||
|
if ( m_moveOption.getSelectedKey(state) == null ) {
|
||||||
|
m_moveOption.setSelectedKey(state, m_selOption.getSelectedKey(state));
|
||||||
|
} else {
|
||||||
|
BigDecimal id = (BigDecimal) m_moveOption.getSelectedKey(state);
|
||||||
|
DecisionTreeSectionOption option = new DecisionTreeSectionOption(id);
|
||||||
|
|
||||||
|
BigDecimal dest = new BigDecimal((String) event.getRowKey());
|
||||||
|
DecisionTreeSectionOption destOption = new DecisionTreeSectionOption(dest);
|
||||||
|
|
||||||
|
DecisionTreeSection section = option.getSection();
|
||||||
|
|
||||||
|
if (section.equals(destOption.getSection())) {
|
||||||
|
// if option is lower in rank than the dest
|
||||||
|
// then move below is default behavior
|
||||||
|
int rank = destOption.getRank().intValue();
|
||||||
|
if (option.getRank().intValue() > rank) {
|
||||||
|
// otherwise, add one to get "move below"
|
||||||
|
rank++;
|
||||||
|
}
|
||||||
|
|
||||||
|
section.changeOptionRank(option, rank);
|
||||||
|
option.save();
|
||||||
|
}
|
||||||
|
m_moveOption.setSelectedKey(state, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void headSelected ( TableActionEvent event ) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOptionModel(ItemSelectionModel selOption) {
|
||||||
|
if (selOption == null) {
|
||||||
|
s_log.warn("null item model");
|
||||||
|
}
|
||||||
|
m_selOption = selOption;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The model builder to generate a suitable model for the OptionTable
|
||||||
|
*/
|
||||||
|
protected class OptionTableModelBuilder extends LockableImpl
|
||||||
|
implements TableModelBuilder
|
||||||
|
{
|
||||||
|
protected ItemSelectionModel m_selTree;
|
||||||
|
protected ItemSelectionModel m_moveOption;
|
||||||
|
|
||||||
|
public OptionTableModelBuilder(ItemSelectionModel selTree, ItemSelectionModel moveOption) {
|
||||||
|
m_selTree = selTree;
|
||||||
|
m_moveOption = moveOption;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TableModel makeModel(Table table, PageState state) {
|
||||||
|
table.getRowSelectionModel().clearSelection(state);
|
||||||
|
DecisionTree tree = (DecisionTree)m_selTree.getSelectedObject(state);
|
||||||
|
return new OptionTableModel(table, state, tree, m_moveOption);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected class OptionTableModel implements TableModel
|
||||||
|
{
|
||||||
|
private TableColumnModel m_colModel;
|
||||||
|
private PageState m_state;
|
||||||
|
private DecisionTreeSectionOptionCollection m_options;
|
||||||
|
private ItemSelectionModel m_moveOption;
|
||||||
|
private DecisionTreeSectionOption m_option;
|
||||||
|
|
||||||
|
/** Constructor. */
|
||||||
|
public OptionTableModel(Table table, PageState state, DecisionTree tree, ItemSelectionModel moveOption) {
|
||||||
|
m_colModel = table.getColumnModel();
|
||||||
|
m_state = state;
|
||||||
|
m_options = tree.getOptions();
|
||||||
|
m_moveOption = moveOption;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return the number of columsn this TableModel has. */
|
||||||
|
public int getColumnCount() {
|
||||||
|
return m_colModel.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Move to the next row and return true if the model is now positioned on
|
||||||
|
* a valid row.
|
||||||
|
*/
|
||||||
|
public boolean nextRow() {
|
||||||
|
if (m_options.next()) {
|
||||||
|
m_option = (DecisionTreeSectionOption) m_options.getOption();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return the data element for the given column and the current row. */
|
||||||
|
public Object getElementAt(int columnIndex) {
|
||||||
|
if (m_colModel == null) { return null; }
|
||||||
|
|
||||||
|
// match columns by name... makes for easier reordering
|
||||||
|
TableColumn col = m_colModel.get(columnIndex);
|
||||||
|
String colName = (String) col.getHeaderValue();
|
||||||
|
|
||||||
|
if (COL_SECTION.equals(colName)) {
|
||||||
|
return m_option.getSection().getTitle();
|
||||||
|
} else if (COL_OPTION.equals(colName)) {
|
||||||
|
return m_option.getLabel();
|
||||||
|
} else if (COL_EDIT.equals(colName)) {
|
||||||
|
return "edit";
|
||||||
|
} else if (COL_MOVE.equals(colName)) {
|
||||||
|
if ( m_moveOption.getSelectedKey(m_state) == null ) {
|
||||||
|
return "move";
|
||||||
|
} else {
|
||||||
|
DecisionTreeSectionOption src = new DecisionTreeSectionOption(new BigDecimal((String) m_moveOption.getSelectedKey(m_state)));
|
||||||
|
if (m_option.getSection().equals(src.getSection()))
|
||||||
|
return "move below here";
|
||||||
|
else
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
} else if (COL_DEL.equals(colName)) {
|
||||||
|
return "delete";
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return the key for the given column and the current row. */
|
||||||
|
public Object getKeyAt(int columnIndex) {
|
||||||
|
return m_option.getID();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class SectionTableCellRenderer extends LockableImpl
|
||||||
|
implements TableCellRenderer
|
||||||
|
{
|
||||||
|
private boolean m_active;
|
||||||
|
|
||||||
|
public SectionTableCellRenderer () {
|
||||||
|
this(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SectionTableCellRenderer(boolean active) {
|
||||||
|
m_active = active;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Component getComponent(Table table, PageState state,
|
||||||
|
Object value, boolean isSelected,
|
||||||
|
Object key, int row, int column) {
|
||||||
|
Component ret = null;
|
||||||
|
SecurityManager sm = Utilities.getSecurityManager(state);
|
||||||
|
ContentItem item = (ContentItem)m_selTree.getSelectedObject(state);
|
||||||
|
|
||||||
|
boolean active = m_active &&
|
||||||
|
sm.canAccess(state.getRequest(), SecurityManager.EDIT_ITEM,
|
||||||
|
item);
|
||||||
|
|
||||||
|
if (value instanceof Component) {
|
||||||
|
ret = (Component)value;
|
||||||
|
} else {
|
||||||
|
if (value == null) {
|
||||||
|
ret = new Label("", false);
|
||||||
|
} else {
|
||||||
|
if (active) {
|
||||||
|
ret = new ControlLink(value.toString());
|
||||||
|
} else {
|
||||||
|
ret = new Label(value.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,78 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2007 Red Hat Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.FormProcessException;
|
||||||
|
import com.arsdigita.bebop.event.ParameterEvent;
|
||||||
|
import com.arsdigita.bebop.parameters.GlobalizedParameterListener;
|
||||||
|
import com.arsdigita.bebop.parameters.ParameterData;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTreeUtil;
|
||||||
|
import com.arsdigita.globalization.GlobalizedMessage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verifies that the
|
||||||
|
* parameter's value contains only letters, digits, "-" and "_".
|
||||||
|
*
|
||||||
|
* @author Carsten Clasohm
|
||||||
|
* @version $Id$
|
||||||
|
**/
|
||||||
|
|
||||||
|
public class DecisionTreeParameterNameValidationListener
|
||||||
|
extends GlobalizedParameterListener {
|
||||||
|
|
||||||
|
public DecisionTreeParameterNameValidationListener() {
|
||||||
|
setError(DecisionTreeUtil.globalize("error.parameter_name_characters"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public DecisionTreeParameterNameValidationListener(GlobalizedMessage error) {
|
||||||
|
setError(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void validate (ParameterEvent e) throws FormProcessException {
|
||||||
|
ParameterData data = e.getParameterData();
|
||||||
|
Object obj = data.getValue();
|
||||||
|
|
||||||
|
if (obj == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String value;
|
||||||
|
try {
|
||||||
|
value = (String) obj;
|
||||||
|
} catch (ClassCastException cce) {
|
||||||
|
throw new FormProcessException (cce.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < value.length(); i++) {
|
||||||
|
char c = value.charAt(i);
|
||||||
|
if (!isPrintableChar(c)) {
|
||||||
|
data.addError(getError());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isPrintableChar( char c ) {
|
||||||
|
Character.UnicodeBlock block = Character.UnicodeBlock.of( c );
|
||||||
|
return (!Character.isISOControl(c)) &&
|
||||||
|
block != null &&
|
||||||
|
block != Character.UnicodeBlock.SPECIALS;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,117 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2007 Red Hat Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.FormData;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.event.FormInitListener;
|
||||||
|
import com.arsdigita.bebop.event.FormProcessListener;
|
||||||
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
|
import com.arsdigita.bebop.event.FormSubmissionListener;
|
||||||
|
import com.arsdigita.bebop.form.TextArea;
|
||||||
|
import com.arsdigita.bebop.form.TextField;
|
||||||
|
import com.arsdigita.bebop.parameters.StringParameter;
|
||||||
|
import com.arsdigita.bebop.parameters.TrimmedStringParameter;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTree;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTreeUtil;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CMS authoring form for the Camden Decision Tree content type.
|
||||||
|
*
|
||||||
|
* @author Carsten Clasohm
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class DecisionTreePropertiesForm extends BasicPageForm implements
|
||||||
|
FormProcessListener, FormInitListener, FormSubmissionListener {
|
||||||
|
|
||||||
|
private final static String ID = "FORM_PROPERTIES";
|
||||||
|
public final static String DESCRIPTION = "description";
|
||||||
|
public final static String CANCEL_URL = "cancelURL";
|
||||||
|
|
||||||
|
private DecisionTreePropertiesStep m_step;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new form to edit the Consultation object specified by the item
|
||||||
|
* selection model passed in.
|
||||||
|
*
|
||||||
|
* @param itemModel
|
||||||
|
* The ItemSelectionModel to use to obtain the Article to work on
|
||||||
|
* @param step
|
||||||
|
* The ArticlePropertiesStep which controls this form.
|
||||||
|
*/
|
||||||
|
public DecisionTreePropertiesForm(ItemSelectionModel itemModel,
|
||||||
|
DecisionTreePropertiesStep step) {
|
||||||
|
super(ID, itemModel);
|
||||||
|
m_step = step;
|
||||||
|
addSubmissionListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void addWidgets() {
|
||||||
|
super.addWidgets();
|
||||||
|
|
||||||
|
add(new Label(DecisionTreeUtil.globalize("form_label.description")));
|
||||||
|
|
||||||
|
TextArea description = new TextArea(new TrimmedStringParameter(DESCRIPTION));
|
||||||
|
description.setRows(5);
|
||||||
|
description.setCols(30);
|
||||||
|
add(description);
|
||||||
|
|
||||||
|
add(new Label(DecisionTreeUtil.globalize("form_label.cancel_url")));
|
||||||
|
TextField cancelURL = new TextField(new StringParameter(CANCEL_URL));
|
||||||
|
cancelURL.setSize(60);
|
||||||
|
add(cancelURL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Cancels streamlined editing. */
|
||||||
|
public void submitted(FormSectionEvent fse) {
|
||||||
|
PageState state = fse.getPageState();
|
||||||
|
|
||||||
|
if (m_step != null &&
|
||||||
|
getSaveCancelSection().getCancelButton().isSelected(state)) {
|
||||||
|
m_step.cancelStreamlinedCreation(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Form processing hook. Saves Event object. */
|
||||||
|
public void process(FormSectionEvent fse) {
|
||||||
|
PageState state = fse.getPageState();
|
||||||
|
FormData data = fse.getFormData();
|
||||||
|
|
||||||
|
DecisionTree decisionTree = (DecisionTree)processBasicWidgets(fse);
|
||||||
|
decisionTree.setDescription((String)data.get(DESCRIPTION));
|
||||||
|
decisionTree.setCancelURL((String)data.get(CANCEL_URL));
|
||||||
|
decisionTree.save();
|
||||||
|
|
||||||
|
if (m_step != null)
|
||||||
|
m_step.maybeForwardToNextStep(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Form initialisation hook. Fills widgets with data. */
|
||||||
|
public void init(FormSectionEvent fse) {
|
||||||
|
DecisionTree item = (DecisionTree)initBasicWidgets(fse);
|
||||||
|
|
||||||
|
FormData data = fse.getFormData();
|
||||||
|
data.put(DESCRIPTION, item.getDescription());
|
||||||
|
data.put(CANCEL_URL, item.getCancelURL());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,78 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2007 Red Hat Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.Component;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTreeUtil;
|
||||||
|
import com.arsdigita.cms.ContentItem;
|
||||||
|
import com.arsdigita.cms.ContentPage;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
||||||
|
import com.arsdigita.cms.ui.authoring.BasicPageForm;
|
||||||
|
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
||||||
|
import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess;
|
||||||
|
import com.arsdigita.cms.util.GlobalizationUtil;
|
||||||
|
import com.arsdigita.toolbox.ui.DomainObjectPropertySheet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CMS authoring step for the Camden Decision Tree content type.
|
||||||
|
*
|
||||||
|
* @author Carsten Clasohm
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class DecisionTreePropertiesStep extends SimpleEditStep {
|
||||||
|
|
||||||
|
/** The name of the editing sheet added to this step */
|
||||||
|
public static String EDIT_SHEET_NAME = "SHEET_PROPERTIES";
|
||||||
|
public final static String CANCEL_URL = "cancelURL";
|
||||||
|
|
||||||
|
public DecisionTreePropertiesStep(ItemSelectionModel itemModel,
|
||||||
|
AuthoringKitWizard parent) {
|
||||||
|
super(itemModel, parent);
|
||||||
|
|
||||||
|
setDefaultEditKey(EDIT_SHEET_NAME);
|
||||||
|
|
||||||
|
BasicPageForm editSheet;
|
||||||
|
|
||||||
|
editSheet = new DecisionTreePropertiesForm( itemModel, this );
|
||||||
|
add(EDIT_SHEET_NAME, "Edit", new WorkflowLockedComponentAccess(editSheet, itemModel),
|
||||||
|
editSheet.getSaveCancelSection().getCancelButton() );
|
||||||
|
|
||||||
|
setDisplayComponent(getPropertySheet(itemModel));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a component that displays the properties of the
|
||||||
|
* Article specified by the ItemSelectionModel passed in.
|
||||||
|
* @param itemModel The ItemSelectionModel to use
|
||||||
|
* @pre itemModel != null
|
||||||
|
* @return A component to display the state of the basic properties
|
||||||
|
* of the release
|
||||||
|
*/
|
||||||
|
public static Component getPropertySheet( ItemSelectionModel itemModel ) {
|
||||||
|
DomainObjectPropertySheet sheet = new DomainObjectPropertySheet(itemModel);
|
||||||
|
|
||||||
|
sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.name"), ContentItem.NAME);
|
||||||
|
sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.title"), ContentPage.TITLE);
|
||||||
|
sheet.add(GlobalizationUtil.globalize("cms.contenttypes.ui.description"), ContentPage.DESCRIPTION);
|
||||||
|
sheet.add(DecisionTreeUtil.globalize("properties.cancel_url"), CANCEL_URL);
|
||||||
|
|
||||||
|
return sheet;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,126 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2007 Red Hat Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.ColumnPanel;
|
||||||
|
import com.arsdigita.bebop.Form;
|
||||||
|
import com.arsdigita.bebop.FormProcessException;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.SaveCancelSection;
|
||||||
|
import com.arsdigita.bebop.event.FormInitListener;
|
||||||
|
import com.arsdigita.bebop.event.FormProcessListener;
|
||||||
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
|
import com.arsdigita.bebop.event.FormSubmissionListener;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTree;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTreeUtil;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTreeSection;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.util.Assert;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A form to confirm deletion of a single section of a DecisionTree.
|
||||||
|
*
|
||||||
|
* @author Carsten Clasohm
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class DecisionTreeSectionDeleteForm extends Form
|
||||||
|
implements FormInitListener, FormSubmissionListener, FormProcessListener
|
||||||
|
{
|
||||||
|
private final static Logger log = Logger.getLogger(
|
||||||
|
DecisionTreeSectionDeleteForm.class.getName());
|
||||||
|
|
||||||
|
protected ItemSelectionModel m_selTree;
|
||||||
|
protected ItemSelectionModel m_selSection;
|
||||||
|
protected SaveCancelSection m_saveCancelSection;
|
||||||
|
private Label m_sectionNameLabel;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param selArticle
|
||||||
|
* @param selSection
|
||||||
|
*/
|
||||||
|
public DecisionTreeSectionDeleteForm( ItemSelectionModel selArticle,
|
||||||
|
ItemSelectionModel selSection) {
|
||||||
|
super("DecisionTreeSectionDeleteForm", new ColumnPanel(2));
|
||||||
|
m_selTree = selArticle;
|
||||||
|
m_selSection = selSection;
|
||||||
|
|
||||||
|
ColumnPanel panel = (ColumnPanel)getPanel();
|
||||||
|
panel.setBorder(false);
|
||||||
|
panel.setPadColor("#FFFFFF");
|
||||||
|
panel.setColumnWidth(1, "20%");
|
||||||
|
panel.setColumnWidth(2, "80%");
|
||||||
|
panel.setWidth("100%");
|
||||||
|
|
||||||
|
m_sectionNameLabel = new Label ("Section Name");
|
||||||
|
add(m_sectionNameLabel, ColumnPanel.FULL_WIDTH | ColumnPanel.LEFT);
|
||||||
|
addSaveCancelSection();
|
||||||
|
|
||||||
|
addInitListener(this);
|
||||||
|
addSubmissionListener(this);
|
||||||
|
addProcessListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected SaveCancelSection addSaveCancelSection () {
|
||||||
|
m_saveCancelSection = new SaveCancelSection();
|
||||||
|
m_saveCancelSection.getSaveButton().setButtonLabel("Delete");
|
||||||
|
add(m_saveCancelSection, ColumnPanel.FULL_WIDTH | ColumnPanel.LEFT);
|
||||||
|
return m_saveCancelSection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init ( FormSectionEvent event ) throws FormProcessException {
|
||||||
|
PageState state = event.getPageState();
|
||||||
|
|
||||||
|
DecisionTreeSection section =
|
||||||
|
(DecisionTreeSection)m_selSection.getSelectedObject(state);
|
||||||
|
|
||||||
|
if ( section == null ) {
|
||||||
|
log.error("No section selected");
|
||||||
|
} else {
|
||||||
|
m_sectionNameLabel.setLabel(section.getTitle(),state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void submitted ( FormSectionEvent event ) throws FormProcessException {
|
||||||
|
PageState state = event.getPageState();
|
||||||
|
|
||||||
|
if ( m_saveCancelSection.getCancelButton().isSelected(state) ) {
|
||||||
|
throw new FormProcessException( (String) DecisionTreeUtil.globalize("tree_section.submission_cancelled").localize());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void process ( FormSectionEvent event ) throws FormProcessException {
|
||||||
|
PageState state = event.getPageState();
|
||||||
|
|
||||||
|
DecisionTree article = (DecisionTree)m_selTree.getSelectedObject(state);
|
||||||
|
DecisionTreeSection section = (DecisionTreeSection)m_selSection.getSelectedObject(state);
|
||||||
|
|
||||||
|
Assert.exists(article, DecisionTree.class);
|
||||||
|
Assert.exists(section, DecisionTreeSection.class);
|
||||||
|
|
||||||
|
article.removeSection(section);
|
||||||
|
|
||||||
|
log.info("section " + m_selSection.getSelectedKey(state) + " delete");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,305 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2007 Red Hat Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.ColumnPanel;
|
||||||
|
import com.arsdigita.bebop.Form;
|
||||||
|
import com.arsdigita.bebop.FormData;
|
||||||
|
import com.arsdigita.bebop.FormProcessException;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.bebop.Page;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.SaveCancelSection;
|
||||||
|
import com.arsdigita.bebop.event.FormInitListener;
|
||||||
|
import com.arsdigita.bebop.event.FormProcessListener;
|
||||||
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
|
import com.arsdigita.bebop.event.FormSubmissionListener;
|
||||||
|
import com.arsdigita.bebop.form.TextField;
|
||||||
|
import com.arsdigita.bebop.parameters.BigDecimalParameter;
|
||||||
|
import com.arsdigita.bebop.parameters.NotEmptyValidationListener;
|
||||||
|
import com.arsdigita.bebop.parameters.StringIsLettersOrDigitsValidationListener;
|
||||||
|
import com.arsdigita.bebop.parameters.TrimmedStringParameter;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTree;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTreeSection;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTreeUtil;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.TextAsset;
|
||||||
|
import com.arsdigita.cms.ui.CMSDHTMLEditor;
|
||||||
|
import com.arsdigita.domain.DataObjectNotFoundException;
|
||||||
|
import com.arsdigita.util.UncheckedWrapperException;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Form to edit a TreeSection for a DecisionTree.
|
||||||
|
*
|
||||||
|
* @author Carsten Clasohm
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class DecisionTreeSectionEditForm extends Form
|
||||||
|
implements FormInitListener,
|
||||||
|
FormProcessListener,
|
||||||
|
FormSubmissionListener {
|
||||||
|
|
||||||
|
private final static Logger log = Logger.getLogger(
|
||||||
|
DecisionTreeSectionEditForm.class);
|
||||||
|
|
||||||
|
private ItemSelectionModel m_selTree;
|
||||||
|
private ItemSelectionModel m_selSection;
|
||||||
|
|
||||||
|
private BigDecimalParameter m_instructionsParam;
|
||||||
|
private ItemSelectionModel m_selInstructions;
|
||||||
|
private DecisionTreeViewSections m_container;
|
||||||
|
|
||||||
|
private SaveCancelSection m_saveCancelSection;
|
||||||
|
|
||||||
|
public static final String TITLE = "title";
|
||||||
|
public static final String PARAMETER_NAME = "parameterName";
|
||||||
|
public static final String INSTRUCTIONS = "instructions";
|
||||||
|
|
||||||
|
private static final String INSTRUCTIONS_PARAM = "instructionsParam";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param selTree the current article
|
||||||
|
* @param selSection the current section
|
||||||
|
*/
|
||||||
|
public DecisionTreeSectionEditForm(ItemSelectionModel selTree,
|
||||||
|
ItemSelectionModel selSection) {
|
||||||
|
this(selTree, selSection, null);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param selArticle the current article
|
||||||
|
* @param selSection the current section
|
||||||
|
* @param container container which this form is added to
|
||||||
|
*/
|
||||||
|
public DecisionTreeSectionEditForm(ItemSelectionModel selTree,
|
||||||
|
ItemSelectionModel selSection,
|
||||||
|
DecisionTreeViewSections container) {
|
||||||
|
super("SectionEditForm", new ColumnPanel(2));
|
||||||
|
m_selTree = selTree;
|
||||||
|
m_selSection = selSection;
|
||||||
|
m_container = container;
|
||||||
|
|
||||||
|
m_instructionsParam = new BigDecimalParameter(INSTRUCTIONS_PARAM);
|
||||||
|
m_selInstructions = new ItemSelectionModel(
|
||||||
|
TextAsset.class.getName(),
|
||||||
|
TextAsset.BASE_DATA_OBJECT_TYPE,
|
||||||
|
m_instructionsParam);
|
||||||
|
|
||||||
|
setMethod(Form.POST);
|
||||||
|
setEncType("multipart/form-data");
|
||||||
|
|
||||||
|
ColumnPanel panel = (ColumnPanel)getPanel();
|
||||||
|
panel.setBorder(false);
|
||||||
|
panel.setPadColor("#FFFFFF");
|
||||||
|
panel.setColumnWidth(1, "20%");
|
||||||
|
panel.setColumnWidth(2, "80%");
|
||||||
|
panel.setWidth("100%");
|
||||||
|
|
||||||
|
addWidgets();
|
||||||
|
addSaveCancelSection();
|
||||||
|
|
||||||
|
addInitListener(this);
|
||||||
|
addSubmissionListener(this);
|
||||||
|
addProcessListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiate and add a save/cancel section to the form.
|
||||||
|
*
|
||||||
|
* @return the SaveCancelSection that was added
|
||||||
|
*/
|
||||||
|
protected SaveCancelSection addSaveCancelSection() {
|
||||||
|
m_saveCancelSection = new SaveCancelSection();
|
||||||
|
add(m_saveCancelSection, ColumnPanel.FULL_WIDTH | ColumnPanel.LEFT);
|
||||||
|
return m_saveCancelSection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the save/cancel section from this form.
|
||||||
|
*/
|
||||||
|
public SaveCancelSection getSaveCancelSection() {
|
||||||
|
return m_saveCancelSection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add form widgets for a Section.
|
||||||
|
*/
|
||||||
|
protected void addWidgets() {
|
||||||
|
add(new Label(DecisionTreeUtil.globalize("form_label.title")));
|
||||||
|
TextField titleWidget = new TextField(new TrimmedStringParameter(TITLE));
|
||||||
|
titleWidget.addValidationListener(new NotEmptyValidationListener());
|
||||||
|
add(titleWidget);
|
||||||
|
|
||||||
|
add(new Label(DecisionTreeUtil.globalize("form_label.parameter_name")));
|
||||||
|
TextField parameterWidget = new TextField(new TrimmedStringParameter(PARAMETER_NAME));
|
||||||
|
parameterWidget.addValidationListener(new NotEmptyValidationListener());
|
||||||
|
parameterWidget.addValidationListener(new DecisionTreeParameterNameValidationListener());
|
||||||
|
add(parameterWidget);
|
||||||
|
|
||||||
|
add(new Label(DecisionTreeUtil.globalize("form_label.instructions")),
|
||||||
|
ColumnPanel.LEFT | ColumnPanel.FULL_WIDTH);
|
||||||
|
CMSDHTMLEditor textWidget =
|
||||||
|
new CMSDHTMLEditor(new TrimmedStringParameter(INSTRUCTIONS));
|
||||||
|
textWidget.setRows(40);
|
||||||
|
textWidget.setCols(70);
|
||||||
|
textWidget.setWrap(CMSDHTMLEditor.SOFT);
|
||||||
|
add(textWidget,
|
||||||
|
ColumnPanel.LEFT | ColumnPanel.FULL_WIDTH);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the form. If there is a selected section, ie. this
|
||||||
|
* is an 'edit' step rather than a 'create new' step, load the data
|
||||||
|
* into the form fields.
|
||||||
|
*/
|
||||||
|
public void init( FormSectionEvent event )
|
||||||
|
throws FormProcessException {
|
||||||
|
PageState state = event.getPageState();
|
||||||
|
FormData data = event.getFormData();
|
||||||
|
m_selInstructions.setSelectedObject(state,null);
|
||||||
|
|
||||||
|
if ( m_selSection.getSelectedKey(state) != null ) {
|
||||||
|
BigDecimal id = new BigDecimal(m_selSection
|
||||||
|
.getSelectedKey(state).toString());
|
||||||
|
try {
|
||||||
|
// retrieve the selected Section from the persistence layer
|
||||||
|
DecisionTreeSection section = new DecisionTreeSection(id);
|
||||||
|
|
||||||
|
data.put(TITLE, section.getTitle());
|
||||||
|
data.put(PARAMETER_NAME, section.getParameterName());
|
||||||
|
|
||||||
|
TextAsset t = section.getInstructions();
|
||||||
|
if ( t != null ) {
|
||||||
|
m_selInstructions.setSelectedObject(state, t);
|
||||||
|
data.put(INSTRUCTIONS, t.getText());
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch ( DataObjectNotFoundException ex ) {
|
||||||
|
log.error("Section(" + id + ") could not be found");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called on form submission. Check to see if the user clicked the
|
||||||
|
* cancel button. If they did, don't continue with the form.
|
||||||
|
*/
|
||||||
|
public void submitted( FormSectionEvent event )
|
||||||
|
throws FormProcessException {
|
||||||
|
PageState state = event.getPageState();
|
||||||
|
|
||||||
|
if ( m_saveCancelSection.getCancelButton()
|
||||||
|
.isSelected(state) && m_container != null) {
|
||||||
|
m_container.onlyShowComponent(
|
||||||
|
state, DecisionTreeViewSections.SECTION_TABLE +
|
||||||
|
m_container.getTypeIDStr());
|
||||||
|
throw new FormProcessException(
|
||||||
|
(String)DecisionTreeUtil
|
||||||
|
.globalize("tree_section.submission_cancelled")
|
||||||
|
.localize());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called after form has been validated. Create the new TreeSection and
|
||||||
|
* assign it to the current DecisionTree.
|
||||||
|
*/
|
||||||
|
public void process(FormSectionEvent event)
|
||||||
|
throws FormProcessException {
|
||||||
|
PageState state = event.getPageState();
|
||||||
|
FormData data = event.getFormData();
|
||||||
|
|
||||||
|
// retrieve the current DecisionTree
|
||||||
|
BigDecimal id = new BigDecimal(
|
||||||
|
m_selTree.getSelectedKey(state).toString());
|
||||||
|
|
||||||
|
DecisionTree tree;
|
||||||
|
try {
|
||||||
|
tree = new DecisionTree(id);
|
||||||
|
} catch ( DataObjectNotFoundException ex ) {
|
||||||
|
throw new UncheckedWrapperException(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
// get the selected section to update or create a new one
|
||||||
|
DecisionTreeSection section = (DecisionTreeSection)
|
||||||
|
m_selSection.getSelectedObject(state);
|
||||||
|
if (section == null) {
|
||||||
|
section = createSection(event, tree);
|
||||||
|
tree.addSection(section);
|
||||||
|
}
|
||||||
|
|
||||||
|
section.setTitle((String) data.get(TITLE));
|
||||||
|
section.setParameterName((String) data.get(PARAMETER_NAME));
|
||||||
|
|
||||||
|
// get the text asset
|
||||||
|
TextAsset textAsset = (TextAsset)m_selInstructions.getSelectedObject(state);
|
||||||
|
if ( textAsset == null ) {
|
||||||
|
textAsset = new TextAsset();
|
||||||
|
textAsset.setName(section.getName() + " text");
|
||||||
|
m_selInstructions.setSelectedObject(state, textAsset);
|
||||||
|
section.setInstructions(textAsset);
|
||||||
|
}
|
||||||
|
|
||||||
|
String text = (String)data.get(INSTRUCTIONS);
|
||||||
|
if ( text == null ) { text = ""; }
|
||||||
|
|
||||||
|
textAsset.setText(text);
|
||||||
|
if ( m_container != null) {
|
||||||
|
m_container.onlyShowComponent(
|
||||||
|
state,
|
||||||
|
DecisionTreeViewSections.SECTION_TABLE +
|
||||||
|
m_container.getTypeIDStr());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility method to create a Section from the form data supplied.
|
||||||
|
*/
|
||||||
|
protected DecisionTreeSection createSection(FormSectionEvent event,
|
||||||
|
DecisionTree tree) {
|
||||||
|
FormData data = event.getFormData();
|
||||||
|
|
||||||
|
DecisionTreeSection section = new DecisionTreeSection();
|
||||||
|
|
||||||
|
section.setTitle((String)data.get(TITLE));
|
||||||
|
section.setName(tree.getName() + ": " + (String)data.get(TITLE));
|
||||||
|
|
||||||
|
return section;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param p
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void register(Page p) {
|
||||||
|
super.register(p);
|
||||||
|
p.addGlobalStateParam(m_instructionsParam);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,219 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2007 Red Hat Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.Component;
|
||||||
|
import com.arsdigita.bebop.ControlLink;
|
||||||
|
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.contenttypes.DecisionTree;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTreeSection;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTreeSectionCollection;
|
||||||
|
import com.arsdigita.cms.ContentItem;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.SecurityManager;
|
||||||
|
import com.arsdigita.cms.dispatcher.Utilities;
|
||||||
|
import com.arsdigita.util.LockableImpl;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A table that displays the sections for the currently
|
||||||
|
* selected DecisionTree.
|
||||||
|
*
|
||||||
|
* @author Carsten Clasohm
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class DecisionTreeSectionTable extends Table
|
||||||
|
{
|
||||||
|
// column headings
|
||||||
|
public static final String COL_TITLE = "Section";
|
||||||
|
public static final String COL_EDIT = "Edit";
|
||||||
|
public static final String COL_DEL = "Delete";
|
||||||
|
public static final String COL_FIRST = "First Section?";
|
||||||
|
|
||||||
|
private ItemSelectionModel m_selTree;
|
||||||
|
|
||||||
|
private static final Logger s_log = Logger.getLogger(
|
||||||
|
DecisionTreeSectionTable.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param selArticle a selection model that returns the MultiPartArticle
|
||||||
|
* which holds the sections to display.
|
||||||
|
*/
|
||||||
|
public DecisionTreeSectionTable (ItemSelectionModel selArticle) {
|
||||||
|
super();
|
||||||
|
m_selTree = selArticle;
|
||||||
|
|
||||||
|
TableColumnModel model = getColumnModel();
|
||||||
|
model.add( new TableColumn(0, COL_TITLE));
|
||||||
|
model.add( new TableColumn(1, COL_EDIT));
|
||||||
|
model.add( new TableColumn(2, COL_DEL));
|
||||||
|
model.add( new TableColumn(3, COL_FIRST));
|
||||||
|
|
||||||
|
model.get(1).setCellRenderer(new SectionTableCellRenderer(true));
|
||||||
|
model.get(2).setCellRenderer(new SectionTableCellRenderer(true));
|
||||||
|
model.get(3).setCellRenderer(new SectionTableCellRenderer(true));
|
||||||
|
|
||||||
|
setModelBuilder(new SectionTableModelBuilder(m_selTree));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSectionModel ( ItemSelectionModel selSection ) {
|
||||||
|
if ( selSection == null ) {
|
||||||
|
s_log.warn("null item model");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The model builder to generate a suitable model for the SectionTable
|
||||||
|
*/
|
||||||
|
protected class SectionTableModelBuilder extends LockableImpl
|
||||||
|
implements TableModelBuilder
|
||||||
|
{
|
||||||
|
protected ItemSelectionModel m_selTree;
|
||||||
|
|
||||||
|
public SectionTableModelBuilder (ItemSelectionModel selTree) {
|
||||||
|
m_selTree = selTree;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TableModel makeModel(Table table, PageState state) {
|
||||||
|
table.getRowSelectionModel().clearSelection(state);
|
||||||
|
|
||||||
|
DecisionTree tree = (DecisionTree)m_selTree.getSelectedObject(state);
|
||||||
|
|
||||||
|
return new SectionTableModel(table, state, tree);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected class SectionTableModel
|
||||||
|
implements TableModel
|
||||||
|
{
|
||||||
|
private TableColumnModel m_colModel;
|
||||||
|
private DecisionTreeSectionCollection m_sections;
|
||||||
|
private DecisionTreeSection m_section;
|
||||||
|
|
||||||
|
/** Constructor. */
|
||||||
|
public SectionTableModel (Table table, PageState state, DecisionTree tree) {
|
||||||
|
m_colModel = table.getColumnModel();
|
||||||
|
m_sections = tree.getSections();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return the number of columsn this TableModel has. */
|
||||||
|
public int getColumnCount () {
|
||||||
|
return m_colModel.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Move to the next row and return true if the model is now positioned on
|
||||||
|
* a valid row.
|
||||||
|
*/
|
||||||
|
public boolean nextRow () {
|
||||||
|
if ( m_sections.next() ) {
|
||||||
|
m_section = (DecisionTreeSection)m_sections.getSection();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return the data element for the given column and the current row. */
|
||||||
|
public Object getElementAt(int columnIndex) {
|
||||||
|
if (m_colModel == null) { return null; }
|
||||||
|
|
||||||
|
// match columns by name... makes for easier reordering
|
||||||
|
TableColumn col = m_colModel.get(columnIndex);
|
||||||
|
String colName = (String)col.getHeaderValue();
|
||||||
|
|
||||||
|
if ( COL_TITLE.equals(colName) ) {
|
||||||
|
return m_section.getTitle();
|
||||||
|
} else if ( COL_EDIT.equals(colName) ) {
|
||||||
|
return "edit";
|
||||||
|
} else if ( COL_DEL.equals(colName) ) {
|
||||||
|
return "delete";
|
||||||
|
} else if ( COL_FIRST.equals(colName) ) {
|
||||||
|
DecisionTree tree = m_section.getTree();
|
||||||
|
DecisionTreeSection firstSection = tree.getFirstSection();
|
||||||
|
if (firstSection != null && firstSection.getID() == m_section.getID()) {
|
||||||
|
return "";
|
||||||
|
} else {
|
||||||
|
return "set";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return the key for the given column and the current row. */
|
||||||
|
public Object getKeyAt(int columnIndex) {
|
||||||
|
return m_section.getID();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class SectionTableCellRenderer extends LockableImpl
|
||||||
|
implements TableCellRenderer
|
||||||
|
{
|
||||||
|
private boolean m_active;
|
||||||
|
|
||||||
|
public SectionTableCellRenderer () {
|
||||||
|
this(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SectionTableCellRenderer ( boolean active ) {
|
||||||
|
m_active = active;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Component getComponent ( Table table, PageState state,
|
||||||
|
Object value, boolean isSelected,
|
||||||
|
Object key, int row, int column ) {
|
||||||
|
Component ret = null;
|
||||||
|
SecurityManager sm = Utilities.getSecurityManager(state);
|
||||||
|
ContentItem item = (ContentItem)m_selTree.getSelectedObject(state);
|
||||||
|
|
||||||
|
boolean active = m_active &&
|
||||||
|
sm.canAccess(state.getRequest(), SecurityManager.EDIT_ITEM,
|
||||||
|
item);
|
||||||
|
|
||||||
|
if (value instanceof Component) {
|
||||||
|
ret = (Component)value;
|
||||||
|
} else {
|
||||||
|
if (value == null) {
|
||||||
|
ret = new Label("", false);
|
||||||
|
} else {
|
||||||
|
if (active) {
|
||||||
|
ret = new ControlLink(value.toString());
|
||||||
|
} else {
|
||||||
|
ret = new Label(value.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,119 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2007 Red Hat Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.ColumnPanel;
|
||||||
|
import com.arsdigita.bebop.Form;
|
||||||
|
import com.arsdigita.bebop.FormProcessException;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.SaveCancelSection;
|
||||||
|
import com.arsdigita.bebop.event.FormInitListener;
|
||||||
|
import com.arsdigita.bebop.event.FormProcessListener;
|
||||||
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
|
import com.arsdigita.bebop.event.FormSubmissionListener;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTreeUtil;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTreeOptionTarget;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A form to confirm deletion of a single section of a DecisionTree.
|
||||||
|
*
|
||||||
|
* @author Carsten Clasohm
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class DecisionTreeTargetDeleteForm extends Form
|
||||||
|
implements FormInitListener, FormSubmissionListener, FormProcessListener
|
||||||
|
{
|
||||||
|
private final static Logger s_log = Logger.getLogger(
|
||||||
|
DecisionTreeTargetDeleteForm.class.getName());
|
||||||
|
|
||||||
|
protected ItemSelectionModel m_selTree;
|
||||||
|
protected ItemSelectionModel m_selTarget;
|
||||||
|
protected SaveCancelSection m_saveCancelSection;
|
||||||
|
private Label m_targetMatchValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param selTree
|
||||||
|
* @param selTarget
|
||||||
|
*/
|
||||||
|
public DecisionTreeTargetDeleteForm (ItemSelectionModel selTree,
|
||||||
|
ItemSelectionModel selTarget) {
|
||||||
|
super("DecisionTreeTargetDeleteForm", new ColumnPanel(2));
|
||||||
|
m_selTree = selTree;
|
||||||
|
m_selTarget = selTarget;
|
||||||
|
|
||||||
|
ColumnPanel panel = (ColumnPanel)getPanel();
|
||||||
|
panel.setBorder(false);
|
||||||
|
panel.setPadColor("#FFFFFF");
|
||||||
|
panel.setColumnWidth(1, "20%");
|
||||||
|
panel.setColumnWidth(2, "80%");
|
||||||
|
panel.setWidth("100%");
|
||||||
|
|
||||||
|
m_targetMatchValue = new Label("Target Match Value");
|
||||||
|
add(m_targetMatchValue, ColumnPanel.FULL_WIDTH | ColumnPanel.LEFT);
|
||||||
|
addSaveCancelSection();
|
||||||
|
|
||||||
|
addInitListener(this);
|
||||||
|
addSubmissionListener(this);
|
||||||
|
addProcessListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected SaveCancelSection addSaveCancelSection () {
|
||||||
|
m_saveCancelSection = new SaveCancelSection();
|
||||||
|
m_saveCancelSection.getSaveButton().setButtonLabel("Delete");
|
||||||
|
add(m_saveCancelSection, ColumnPanel.FULL_WIDTH | ColumnPanel.LEFT);
|
||||||
|
return m_saveCancelSection;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void init ( FormSectionEvent event ) throws FormProcessException {
|
||||||
|
PageState state = event.getPageState();
|
||||||
|
|
||||||
|
BigDecimal id = new BigDecimal(m_selTarget
|
||||||
|
.getSelectedKey(state).toString());
|
||||||
|
DecisionTreeOptionTarget target = new DecisionTreeOptionTarget(id);
|
||||||
|
|
||||||
|
m_targetMatchValue.setLabel(target.getMatchOption().getLabel(), state);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void submitted ( FormSectionEvent event ) throws FormProcessException {
|
||||||
|
PageState state = event.getPageState();
|
||||||
|
|
||||||
|
if ( m_saveCancelSection.getCancelButton().isSelected(state) ) {
|
||||||
|
throw new FormProcessException( (String)
|
||||||
|
DecisionTreeUtil.globalize("tree_section.submission_cancelled")
|
||||||
|
.localize());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void process ( FormSectionEvent event ) throws FormProcessException {
|
||||||
|
PageState state = event.getPageState();
|
||||||
|
|
||||||
|
BigDecimal id = new BigDecimal(m_selTarget
|
||||||
|
.getSelectedKey(state).toString());
|
||||||
|
DecisionTreeOptionTarget target = new DecisionTreeOptionTarget(id);
|
||||||
|
|
||||||
|
target.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,355 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2007 Red Hat Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.TooManyListenersException;
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.ColumnPanel;
|
||||||
|
import com.arsdigita.bebop.Form;
|
||||||
|
import com.arsdigita.bebop.FormData;
|
||||||
|
import com.arsdigita.bebop.FormProcessException;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.bebop.Page;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.SaveCancelSection;
|
||||||
|
import com.arsdigita.bebop.event.FormInitListener;
|
||||||
|
import com.arsdigita.bebop.event.FormProcessListener;
|
||||||
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
|
import com.arsdigita.bebop.event.FormSubmissionListener;
|
||||||
|
import com.arsdigita.bebop.event.FormValidationListener;
|
||||||
|
import com.arsdigita.bebop.event.PrintEvent;
|
||||||
|
import com.arsdigita.bebop.event.PrintListener;
|
||||||
|
import com.arsdigita.bebop.form.Option;
|
||||||
|
import com.arsdigita.bebop.form.SingleSelect;
|
||||||
|
import com.arsdigita.bebop.form.TextField;
|
||||||
|
import com.arsdigita.bebop.parameters.NotNullValidationListener;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTree;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTreeUtil;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTreeSectionOption;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTreeSectionOptionCollection;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTreeOptionTarget;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTreeSection;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTreeSectionCollection;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Form to edit an DecisionTreeOptionTarget for a DecisionTree.
|
||||||
|
*
|
||||||
|
* @author Carsten Clasohm
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class DecisionTreeTargetEditForm extends Form
|
||||||
|
implements FormInitListener,
|
||||||
|
FormProcessListener,
|
||||||
|
FormSubmissionListener {
|
||||||
|
|
||||||
|
private final static Logger s_log = Logger.getLogger(
|
||||||
|
DecisionTreeTargetEditForm.class);
|
||||||
|
|
||||||
|
private ItemSelectionModel m_selTree;
|
||||||
|
private ItemSelectionModel m_selTarget;
|
||||||
|
|
||||||
|
private DecisionTreeViewTargets m_container;
|
||||||
|
|
||||||
|
private SaveCancelSection m_saveCancelSection;
|
||||||
|
private SingleSelect m_sectionWidget;
|
||||||
|
private SingleSelect m_matchValueWidget;
|
||||||
|
private SingleSelect m_targetSectionWidget;
|
||||||
|
private TextField m_targetURLWidget;
|
||||||
|
|
||||||
|
public static final String MATCH_OPTION = "matchOption";
|
||||||
|
public static final String TARGET_URL = "targetURL";
|
||||||
|
public static final String TARGET_SECTION = "targetSection";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param selTree the current article
|
||||||
|
* @param selTarget the current section
|
||||||
|
*/
|
||||||
|
public DecisionTreeTargetEditForm(ItemSelectionModel selTree,
|
||||||
|
ItemSelectionModel selTarget) {
|
||||||
|
this(selTree, selTarget, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param selArticle the current article
|
||||||
|
* @param selTarget the current section
|
||||||
|
* @param container container which this form is added to
|
||||||
|
*/
|
||||||
|
public DecisionTreeTargetEditForm(ItemSelectionModel selTree,
|
||||||
|
ItemSelectionModel selTarget,
|
||||||
|
DecisionTreeViewTargets container) {
|
||||||
|
super("DecisionTreeTargetEditForm", new ColumnPanel(2));
|
||||||
|
m_selTree = selTree;
|
||||||
|
m_selTarget = selTarget;
|
||||||
|
m_container = container;
|
||||||
|
|
||||||
|
setMethod(Form.POST);
|
||||||
|
setEncType("multipart/form-data");
|
||||||
|
|
||||||
|
ColumnPanel panel = (ColumnPanel)getPanel();
|
||||||
|
panel.setBorder(false);
|
||||||
|
panel.setPadColor("#FFFFFF");
|
||||||
|
panel.setColumnWidth(1, "20%");
|
||||||
|
panel.setColumnWidth(2, "80%");
|
||||||
|
panel.setWidth("100%");
|
||||||
|
|
||||||
|
addWidgets();
|
||||||
|
addSaveCancelSection();
|
||||||
|
|
||||||
|
addInitListener(this);
|
||||||
|
addSubmissionListener(this);
|
||||||
|
addProcessListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiate and add a save/cancel section to the form.
|
||||||
|
*
|
||||||
|
* @return the SaveCancelSection that was added
|
||||||
|
*/
|
||||||
|
protected SaveCancelSection addSaveCancelSection() {
|
||||||
|
m_saveCancelSection = new SaveCancelSection();
|
||||||
|
add(m_saveCancelSection, ColumnPanel.FULL_WIDTH | ColumnPanel.LEFT);
|
||||||
|
return m_saveCancelSection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the save/cancel section from this form.
|
||||||
|
*/
|
||||||
|
public SaveCancelSection getSaveCancelSection() {
|
||||||
|
return m_saveCancelSection;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set up the dynamic options for the section select widget.
|
||||||
|
*/
|
||||||
|
private void initSectionOptions(PrintEvent e) {
|
||||||
|
PageState state = e.getPageState();
|
||||||
|
SingleSelect target = (SingleSelect) e.getTarget();
|
||||||
|
DecisionTree tree = (DecisionTree)m_selTree.getSelectedObject(state);
|
||||||
|
|
||||||
|
if (tree != null) {
|
||||||
|
DecisionTreeSectionCollection sections = tree.getSections();
|
||||||
|
if (sections != null) {
|
||||||
|
while (sections.next()) {
|
||||||
|
DecisionTreeSection section = sections.getSection();
|
||||||
|
Option option = new Option(section.getID().toString(),
|
||||||
|
section.getTitle());
|
||||||
|
target.addOption(option, state);
|
||||||
|
}
|
||||||
|
sections.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set up the dynamic options for the target select widget.
|
||||||
|
*/
|
||||||
|
private void initTargetOptions(PrintEvent e) {
|
||||||
|
PageState state = e.getPageState();
|
||||||
|
SingleSelect target = (SingleSelect) e.getTarget();
|
||||||
|
DecisionTree tree = (DecisionTree)m_selTree.getSelectedObject(state);
|
||||||
|
|
||||||
|
if (tree != null) {
|
||||||
|
DecisionTreeSectionCollection sections = tree.getSections();
|
||||||
|
if (sections != null) {
|
||||||
|
while (sections.next()) {
|
||||||
|
DecisionTreeSection section = sections.getSection();
|
||||||
|
Option option = new Option(section.getID().toString(),
|
||||||
|
section.getTitle());
|
||||||
|
target.addOption(option, state);
|
||||||
|
}
|
||||||
|
sections.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set up the dynamic options for the match value select widget.
|
||||||
|
*/
|
||||||
|
private void initMatchOptions(PrintEvent e) {
|
||||||
|
PageState state = e.getPageState();
|
||||||
|
SingleSelect target = (SingleSelect) e.getTarget();
|
||||||
|
DecisionTree tree = (DecisionTree)m_selTree.getSelectedObject(state);
|
||||||
|
|
||||||
|
if (tree != null) {
|
||||||
|
DecisionTreeSectionOptionCollection sectionOptions = tree.getOptions();
|
||||||
|
if (sectionOptions != null) {
|
||||||
|
while (sectionOptions.next()) {
|
||||||
|
DecisionTreeSectionOption sectionOption = sectionOptions.getOption();
|
||||||
|
String label = sectionOption.getSection().getTitle() + " : " + sectionOption.getLabel();
|
||||||
|
Option option = new Option(sectionOption.getID().toString(), label);
|
||||||
|
target.addOption(option, state);
|
||||||
|
}
|
||||||
|
sectionOptions.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Form initialisation hook. Sets the options for select widgets.
|
||||||
|
*/
|
||||||
|
public void init(FormSectionEvent fse) {
|
||||||
|
PageState state = fse.getPageState();
|
||||||
|
FormData data = fse.getFormData();
|
||||||
|
|
||||||
|
if (m_selTarget.getSelectedKey(state) != null) {
|
||||||
|
BigDecimal id = new BigDecimal(m_selTarget.getSelectedKey(state).toString());
|
||||||
|
DecisionTreeOptionTarget target = new DecisionTreeOptionTarget(id);
|
||||||
|
|
||||||
|
data.put(MATCH_OPTION, target.getMatchOption().getID());
|
||||||
|
data.put(TARGET_URL, target.getTargetURL());
|
||||||
|
|
||||||
|
DecisionTreeSection targetSection = target.getTargetSection();
|
||||||
|
if (targetSection != null)
|
||||||
|
data.put(TARGET_SECTION, targetSection.getID());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add form widgets for a Section.
|
||||||
|
*/
|
||||||
|
protected void addWidgets() {
|
||||||
|
Option pleaseSelect = new Option("", (String)DecisionTreeUtil.globalize("form.please_select").localize());
|
||||||
|
Option none = new Option("", (String)DecisionTreeUtil.globalize("form.none").localize());
|
||||||
|
|
||||||
|
add(new Label(DecisionTreeUtil.globalize("form_label.match_value")));
|
||||||
|
m_matchValueWidget = new SingleSelect(MATCH_OPTION);
|
||||||
|
m_matchValueWidget.addValidationListener(new NotNullValidationListener());
|
||||||
|
m_matchValueWidget.addOption(pleaseSelect);
|
||||||
|
|
||||||
|
try {
|
||||||
|
m_matchValueWidget.addPrintListener(new PrintListener() {
|
||||||
|
public void prepare(PrintEvent e) {
|
||||||
|
initMatchOptions(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (TooManyListenersException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
add(m_matchValueWidget);
|
||||||
|
|
||||||
|
add(new Label(DecisionTreeUtil.globalize("form_label.target_url")));
|
||||||
|
m_targetURLWidget = new TextField(TARGET_URL);
|
||||||
|
m_targetURLWidget.setSize(60);
|
||||||
|
add(m_targetURLWidget);
|
||||||
|
|
||||||
|
add(new Label(DecisionTreeUtil.globalize("form_label.target_section")));
|
||||||
|
m_targetSectionWidget = new SingleSelect(TARGET_SECTION);
|
||||||
|
m_targetSectionWidget.addOption(none);
|
||||||
|
|
||||||
|
try {
|
||||||
|
m_targetSectionWidget.addPrintListener(new PrintListener() {
|
||||||
|
public void prepare(PrintEvent e) {
|
||||||
|
initTargetOptions(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (TooManyListenersException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
add(m_targetSectionWidget);
|
||||||
|
|
||||||
|
addValidationListener(new FormValidationListener() {
|
||||||
|
public final void validate(final FormSectionEvent event)
|
||||||
|
throws FormProcessException {
|
||||||
|
final PageState state = event.getPageState();
|
||||||
|
if ("".equals(m_targetURLWidget.getValue(state)) && "".equals(m_targetSectionWidget.getValue(state))) {
|
||||||
|
String msg = (String) DecisionTreeUtil.globalize("form_validation.target_required").localize();
|
||||||
|
throw new FormProcessException(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!"".equals(m_targetURLWidget.getValue(state)) && !"".equals(m_targetSectionWidget.getValue(state))) {
|
||||||
|
String msg = (String) DecisionTreeUtil.globalize("form_validation.duplicate_target").localize();
|
||||||
|
throw new FormProcessException(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called on form submission. Check to see if the user clicked the
|
||||||
|
* cancel button. If they did, don't continue with the form.
|
||||||
|
*/
|
||||||
|
public void submitted(FormSectionEvent event)
|
||||||
|
throws FormProcessException {
|
||||||
|
PageState state = event.getPageState();
|
||||||
|
|
||||||
|
if ( m_saveCancelSection.getCancelButton()
|
||||||
|
.isSelected(state) && m_container != null) {
|
||||||
|
m_container.onlyShowComponent(
|
||||||
|
state, DecisionTreeViewTargets.TARGET_TABLE +
|
||||||
|
m_container.getTypeIDStr());
|
||||||
|
throw new FormProcessException(
|
||||||
|
(String)DecisionTreeUtil
|
||||||
|
.globalize("tree_section.submission_cancelled")
|
||||||
|
.localize());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called after form has been validated. Create the new DecisionTreeOptionTarget and
|
||||||
|
* assign it to the current DecisionTree.
|
||||||
|
*/
|
||||||
|
public void process(FormSectionEvent event) throws FormProcessException {
|
||||||
|
PageState state = event.getPageState();
|
||||||
|
FormData data = event.getFormData();
|
||||||
|
|
||||||
|
DecisionTreeSectionOption matchOption = new
|
||||||
|
DecisionTreeSectionOption(new
|
||||||
|
BigDecimal((String)data.get(MATCH_OPTION)));
|
||||||
|
|
||||||
|
DecisionTreeSection targetSection = null;
|
||||||
|
String sectionID = (String)data.get(TARGET_SECTION);
|
||||||
|
if (!"".equals(sectionID)) {
|
||||||
|
targetSection = new DecisionTreeSection(new BigDecimal(sectionID));
|
||||||
|
}
|
||||||
|
|
||||||
|
DecisionTreeOptionTarget target = null;
|
||||||
|
if (m_selTarget.getSelectedKey(state) != null) {
|
||||||
|
BigDecimal id = new BigDecimal(m_selTarget
|
||||||
|
.getSelectedKey(state).toString());
|
||||||
|
target = new DecisionTreeOptionTarget(id);
|
||||||
|
} else {
|
||||||
|
target = new DecisionTreeOptionTarget();
|
||||||
|
target.setName("OptionTarget " + target.getID());
|
||||||
|
}
|
||||||
|
|
||||||
|
target.setMatchOption(matchOption);
|
||||||
|
target.setTargetURL((String)data.get(TARGET_URL));
|
||||||
|
target.setTargetSection(targetSection);
|
||||||
|
|
||||||
|
if (m_container != null) {
|
||||||
|
m_container.onlyShowComponent(
|
||||||
|
state,
|
||||||
|
DecisionTreeViewTargets.TARGET_TABLE +
|
||||||
|
m_container.getTypeIDStr());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void register(Page p) {
|
||||||
|
super.register(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,221 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2007 Red Hat Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.Component;
|
||||||
|
import com.arsdigita.bebop.ControlLink;
|
||||||
|
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.contenttypes.DecisionTree;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTreeOptionTarget;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTreeOptionTargetCollection;
|
||||||
|
import com.arsdigita.cms.ContentItem;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.SecurityManager;
|
||||||
|
import com.arsdigita.cms.dispatcher.Utilities;
|
||||||
|
import com.arsdigita.util.LockableImpl;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A table that displays the targets for the currently
|
||||||
|
* selected DecisionTree.
|
||||||
|
*
|
||||||
|
* @author Carsten Clasohm
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class DecisionTreeTargetTable extends Table
|
||||||
|
{
|
||||||
|
private static final Logger s_log = Logger.getLogger(
|
||||||
|
DecisionTreeTargetTable.class);
|
||||||
|
|
||||||
|
// column headings
|
||||||
|
public static final String COL_SECTION = "Section";
|
||||||
|
public static final String COL_MATCH = "Match";
|
||||||
|
public static final String COL_EDIT = "Edit";
|
||||||
|
public static final String COL_DEL = "Delete";
|
||||||
|
|
||||||
|
private ItemSelectionModel m_selTree;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param selArticle a selection model that returns the MultiPartArticle
|
||||||
|
* which holds the sections to display.
|
||||||
|
*/
|
||||||
|
public DecisionTreeTargetTable(ItemSelectionModel selArticle) {
|
||||||
|
super();
|
||||||
|
m_selTree = selArticle;
|
||||||
|
|
||||||
|
TableColumnModel model = getColumnModel();
|
||||||
|
model.add(new TableColumn(0, COL_SECTION));
|
||||||
|
model.add(new TableColumn(1, COL_MATCH));
|
||||||
|
model.add(new TableColumn(2, COL_EDIT));
|
||||||
|
model.add(new TableColumn(3, COL_DEL));
|
||||||
|
|
||||||
|
model.get(2).setCellRenderer(new SectionTableCellRenderer(true));
|
||||||
|
model.get(3).setCellRenderer(new SectionTableCellRenderer(true));
|
||||||
|
|
||||||
|
setModelBuilder(new OptionTableModelBuilder(m_selTree));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param selSection
|
||||||
|
*/
|
||||||
|
public void setSectionModel(ItemSelectionModel selSection) {
|
||||||
|
if (selSection == null) {
|
||||||
|
s_log.warn("null item model");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The model builder to generate a suitable model for the OptionTable
|
||||||
|
*/
|
||||||
|
protected class OptionTableModelBuilder extends LockableImpl
|
||||||
|
implements TableModelBuilder
|
||||||
|
{
|
||||||
|
protected ItemSelectionModel m_selTree;
|
||||||
|
|
||||||
|
public OptionTableModelBuilder(ItemSelectionModel selTree) {
|
||||||
|
m_selTree = selTree;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TableModel makeModel(Table table, PageState state) {
|
||||||
|
table.getRowSelectionModel().clearSelection(state);
|
||||||
|
DecisionTree tree = (DecisionTree)m_selTree.getSelectedObject(state);
|
||||||
|
return new TargetTableModel(table, state, tree);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
protected class TargetTableModel implements TableModel
|
||||||
|
{
|
||||||
|
private TableColumnModel m_colModel;
|
||||||
|
private DecisionTreeOptionTargetCollection m_targets;
|
||||||
|
private DecisionTreeOptionTarget m_target;
|
||||||
|
|
||||||
|
/** Constructor. */
|
||||||
|
public TargetTableModel(Table table, PageState state, DecisionTree tree) {
|
||||||
|
m_colModel = table.getColumnModel();
|
||||||
|
m_targets = tree.getTargets();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return the number of columsn this TableModel has. */
|
||||||
|
public int getColumnCount() {
|
||||||
|
return m_colModel.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Move to the next row and return true if the model is now positioned on
|
||||||
|
* a valid row.
|
||||||
|
*/
|
||||||
|
public boolean nextRow() {
|
||||||
|
if (m_targets.next()) {
|
||||||
|
m_target = (DecisionTreeOptionTarget) m_targets.getTarget();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return the data element for the given column and the current row. */
|
||||||
|
public Object getElementAt(int columnIndex) {
|
||||||
|
if (m_colModel == null) { return null; }
|
||||||
|
|
||||||
|
// match columns by name... makes for easier reordering
|
||||||
|
TableColumn col = m_colModel.get(columnIndex);
|
||||||
|
String colName = (String) col.getHeaderValue();
|
||||||
|
|
||||||
|
if (COL_SECTION.equals(colName)) {
|
||||||
|
return m_target.getMatchOption().getSection().getTitle();
|
||||||
|
} else if (COL_MATCH.equals(colName)) {
|
||||||
|
return m_target.getMatchOption().getLabel();
|
||||||
|
} else if (COL_EDIT.equals(colName)) {
|
||||||
|
return "edit";
|
||||||
|
} else if (COL_DEL.equals(colName)) {
|
||||||
|
return "delete";
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return the key for the given column and the current row. */
|
||||||
|
public Object getKeyAt(int columnIndex) {
|
||||||
|
return m_target.getID();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class SectionTableCellRenderer extends LockableImpl
|
||||||
|
implements TableCellRenderer
|
||||||
|
{
|
||||||
|
/** */
|
||||||
|
private boolean m_active;
|
||||||
|
|
||||||
|
/** */
|
||||||
|
public SectionTableCellRenderer () {
|
||||||
|
this(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** */
|
||||||
|
public SectionTableCellRenderer(boolean active) {
|
||||||
|
m_active = active;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** */
|
||||||
|
public Component getComponent(Table table, PageState state,
|
||||||
|
Object value, boolean isSelected,
|
||||||
|
Object key, int row, int column) {
|
||||||
|
Component ret = null;
|
||||||
|
SecurityManager sm = Utilities.getSecurityManager(state);
|
||||||
|
ContentItem item = (ContentItem)m_selTree.getSelectedObject(state);
|
||||||
|
|
||||||
|
boolean active = m_active &&
|
||||||
|
sm.canAccess(state.getRequest(), SecurityManager.EDIT_ITEM,
|
||||||
|
item);
|
||||||
|
|
||||||
|
if (value instanceof Component) {
|
||||||
|
ret = (Component)value;
|
||||||
|
} else {
|
||||||
|
if (value == null) {
|
||||||
|
ret = new Label("", false);
|
||||||
|
} else {
|
||||||
|
if (active) {
|
||||||
|
ret = new ControlLink(value.toString());
|
||||||
|
} else {
|
||||||
|
ret = new Label(value.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,315 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2007 Red Hat Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.ActionLink;
|
||||||
|
import com.arsdigita.bebop.ColumnPanel;
|
||||||
|
import com.arsdigita.bebop.Container;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.bebop.Page;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.event.ActionEvent;
|
||||||
|
import com.arsdigita.bebop.event.ActionListener;
|
||||||
|
import com.arsdigita.bebop.event.ChangeEvent;
|
||||||
|
import com.arsdigita.bebop.event.ChangeListener;
|
||||||
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
|
import com.arsdigita.bebop.event.FormSubmissionListener;
|
||||||
|
import com.arsdigita.bebop.event.PrintEvent;
|
||||||
|
import com.arsdigita.bebop.event.PrintListener;
|
||||||
|
import com.arsdigita.bebop.event.TableActionEvent;
|
||||||
|
import com.arsdigita.bebop.event.TableActionListener;
|
||||||
|
import com.arsdigita.bebop.parameters.BigDecimalParameter;
|
||||||
|
import com.arsdigita.bebop.table.TableColumn;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTree;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTreeUtil;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTreeSectionOption;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTreeSection;
|
||||||
|
import com.arsdigita.cms.ContentItem;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.SecurityManager;
|
||||||
|
import com.arsdigita.cms.contenttypes.ui.ResettableContainer;
|
||||||
|
import com.arsdigita.cms.dispatcher.Utilities;
|
||||||
|
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
||||||
|
import com.arsdigita.util.Assert;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Authoring kit step to manage the options for a DecisionTree.
|
||||||
|
* The editing process is implemented with three main visual components
|
||||||
|
* that manipulate the currently selected DecisionTree and options.
|
||||||
|
* The visibility of these components is managed by this class.
|
||||||
|
*
|
||||||
|
* @author Carsten Clasohm
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class DecisionTreeViewOptions extends ResettableContainer
|
||||||
|
{
|
||||||
|
/** id keys for each editing panel */
|
||||||
|
public static final String OPTION_TABLE = "opt_tbl";
|
||||||
|
public static final String OPTION_EDIT = "opt_edt";
|
||||||
|
public static final String OPTION_DEL = "opt_del";
|
||||||
|
|
||||||
|
/** class attributes */
|
||||||
|
public static final String DATA_TABLE = "dataTable";
|
||||||
|
public static final String ACTION_LINK = "actionLink";
|
||||||
|
|
||||||
|
protected AuthoringKitWizard m_wizard;
|
||||||
|
protected ItemSelectionModel m_selTree;
|
||||||
|
protected ItemSelectionModel m_selOption;
|
||||||
|
protected ItemSelectionModel m_moveOption;
|
||||||
|
protected BigDecimalParameter m_moveParameter;
|
||||||
|
|
||||||
|
/** visual components that do the 'real work' */
|
||||||
|
protected DecisionTreeOptionTable m_optionTable;
|
||||||
|
protected DecisionTreeOptionEditForm m_optionEdit;
|
||||||
|
protected DecisionTreeOptionDeleteForm m_optionDelete;
|
||||||
|
|
||||||
|
protected ActionLink m_beginLink;
|
||||||
|
private Label m_moveOptionLabel;
|
||||||
|
|
||||||
|
private String m_typeIDStr;
|
||||||
|
|
||||||
|
public DecisionTreeViewOptions (ItemSelectionModel selTree, AuthoringKitWizard wizard) {
|
||||||
|
super();
|
||||||
|
m_selTree = selTree;
|
||||||
|
m_wizard = wizard;
|
||||||
|
m_typeIDStr = wizard.getContentType().getID().toString();
|
||||||
|
Assert.exists(m_selTree, ItemSelectionModel.class);
|
||||||
|
|
||||||
|
// create the components and set default visibility
|
||||||
|
add(buildOptionTable(), true);
|
||||||
|
add(buildOptionEdit(), false);
|
||||||
|
add(buildOptionDelete(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds a container to hold an OptionTable and a link
|
||||||
|
* to add a new option.
|
||||||
|
*/
|
||||||
|
protected Container buildOptionTable () {
|
||||||
|
ColumnPanel c = new ColumnPanel(1);
|
||||||
|
c.setKey(OPTION_TABLE+m_typeIDStr);
|
||||||
|
c.setBorderColor("#FFFFFF");
|
||||||
|
c.setPadColor("#FFFFFF");
|
||||||
|
|
||||||
|
m_moveParameter = new BigDecimalParameter("moveOption");
|
||||||
|
m_moveOption = new ItemSelectionModel(DecisionTreeSectionOption.class.getName(),
|
||||||
|
DecisionTreeSectionOption.BASE_DATA_OBJECT_TYPE,
|
||||||
|
m_moveParameter);
|
||||||
|
|
||||||
|
m_optionTable = new DecisionTreeOptionTable(m_selTree, m_moveOption);
|
||||||
|
m_optionTable.setClassAttr(DATA_TABLE);
|
||||||
|
|
||||||
|
// selected option is based on the selection in the OptionTable
|
||||||
|
m_selOption = new ItemSelectionModel(DecisionTreeSectionOption.class.getName(),
|
||||||
|
DecisionTreeSectionOption.BASE_DATA_OBJECT_TYPE,
|
||||||
|
m_optionTable.getRowSelectionModel());
|
||||||
|
m_optionTable.setOptionModel(m_selOption);
|
||||||
|
|
||||||
|
Label emptyView = new Label(DecisionTreeUtil
|
||||||
|
.globalize("section_options.no_options_yet"));
|
||||||
|
m_optionTable.setEmptyView(emptyView);
|
||||||
|
|
||||||
|
m_moveOptionLabel = new Label ("Option Name");
|
||||||
|
c.add(m_moveOptionLabel, ColumnPanel.FULL_WIDTH | ColumnPanel.LEFT);
|
||||||
|
|
||||||
|
m_beginLink = new ActionLink(DecisionTreeUtil
|
||||||
|
.globalize("section_options.move_to_beginning"));
|
||||||
|
c.add(m_beginLink);
|
||||||
|
|
||||||
|
m_beginLink.addActionListener ( new ActionListener() {
|
||||||
|
public void actionPerformed ( ActionEvent event ) {
|
||||||
|
PageState state = event.getPageState();
|
||||||
|
DecisionTreeSectionOption option = new
|
||||||
|
DecisionTreeSectionOption((BigDecimal) m_moveOption
|
||||||
|
.getSelectedKey(state));
|
||||||
|
|
||||||
|
option.getSection().changeOptionRank(option, 1);
|
||||||
|
option.save();
|
||||||
|
m_moveOption.setSelectedKey(state, null);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
m_moveOption.addChangeListener ( new ChangeListener () {
|
||||||
|
public void stateChanged ( ChangeEvent e ) {
|
||||||
|
PageState state = e.getPageState();
|
||||||
|
if ( m_moveOption.getSelectedKey(state) == null ) {
|
||||||
|
m_beginLink.setVisible(state, false);
|
||||||
|
m_moveOptionLabel.setVisible(state, false);
|
||||||
|
} else {
|
||||||
|
m_beginLink.setVisible(state, true);
|
||||||
|
m_moveOptionLabel.setVisible(state, true);
|
||||||
|
|
||||||
|
DecisionTreeSectionOption option =
|
||||||
|
(DecisionTreeSectionOption) m_moveOption
|
||||||
|
.getSelectedObject(state);
|
||||||
|
String optionName = option.getSection().getTitle() + " - "
|
||||||
|
+ option.getLabel();
|
||||||
|
|
||||||
|
m_moveOptionLabel.setLabel
|
||||||
|
( (String)DecisionTreeUtil
|
||||||
|
.globalize("section_options.move_option_name")
|
||||||
|
.localize()
|
||||||
|
+ " \"" + optionName + "\"", state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// handle clicks to preview or delete a Section
|
||||||
|
m_optionTable.addTableActionListener (new TableActionListener () {
|
||||||
|
public void cellSelected (TableActionEvent event) {
|
||||||
|
PageState state = event.getPageState();
|
||||||
|
|
||||||
|
TableColumn col = m_optionTable.getColumnModel()
|
||||||
|
.get(event.getColumn().intValue());
|
||||||
|
String colName = (String)col.getHeaderValue();
|
||||||
|
|
||||||
|
if (DecisionTreeOptionTable.COL_DEL.equals(colName)) {
|
||||||
|
onlyShowComponent(state, OPTION_DEL+m_typeIDStr);
|
||||||
|
} else if (DecisionTreeOptionTable.COL_EDIT.equals(colName)) {
|
||||||
|
onlyShowComponent(state, OPTION_EDIT+m_typeIDStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void headSelected(TableActionEvent e) {}
|
||||||
|
});
|
||||||
|
c.add(m_optionTable);
|
||||||
|
|
||||||
|
// link to add new section
|
||||||
|
c.add(buildAddLink());
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds a container to hold a SectionEditForm and a link
|
||||||
|
* to return to the section list.
|
||||||
|
*/
|
||||||
|
protected Container buildOptionEdit () {
|
||||||
|
ColumnPanel c = new ColumnPanel(1);
|
||||||
|
c.setKey(OPTION_EDIT+m_typeIDStr);
|
||||||
|
c.setBorderColor("#FFFFFF");
|
||||||
|
c.setPadColor("#FFFFFF");
|
||||||
|
|
||||||
|
// display an appropriate title
|
||||||
|
c.add( new Label( new PrintListener() {
|
||||||
|
public void prepare ( PrintEvent event ) {
|
||||||
|
PageState state = event.getPageState();
|
||||||
|
Label label = (Label)event.getTarget();
|
||||||
|
|
||||||
|
if (m_selOption.getSelectedKey(state) == null) {
|
||||||
|
label.setLabel((String)DecisionTreeUtil.globalize("section_options.add_option").localize());
|
||||||
|
} else {
|
||||||
|
label.setLabel((String)DecisionTreeUtil.globalize("section_options.edit_option").localize());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
// form to edit a Section
|
||||||
|
m_optionEdit = new DecisionTreeOptionEditForm(m_selTree, m_selOption, this);
|
||||||
|
c.add(m_optionEdit);
|
||||||
|
|
||||||
|
c.add(buildViewAllLink());
|
||||||
|
// link to add new section
|
||||||
|
c.add(buildAddLink());
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds a container to hold the component to confirm
|
||||||
|
* deletion of a section.
|
||||||
|
*/
|
||||||
|
protected Container buildOptionDelete () {
|
||||||
|
ColumnPanel c = new ColumnPanel(1);
|
||||||
|
c.setKey(OPTION_DEL+m_typeIDStr);
|
||||||
|
c.setBorderColor("#FFFFFF");
|
||||||
|
c.setPadColor("#FFFFFF");
|
||||||
|
|
||||||
|
c.add(new Label(DecisionTreeUtil.globalize("section_options.delete_option")));
|
||||||
|
m_optionDelete = new DecisionTreeOptionDeleteForm(m_selTree, m_selOption);
|
||||||
|
m_optionDelete.addSubmissionListener ( new FormSubmissionListener () {
|
||||||
|
public void submitted ( FormSectionEvent e ) {
|
||||||
|
PageState state = e.getPageState();
|
||||||
|
onlyShowComponent(state, OPTION_TABLE+m_typeIDStr);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
c.add(m_optionDelete);
|
||||||
|
|
||||||
|
c.add(buildViewAllLink());
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility method to create a link to display the section list.
|
||||||
|
*/
|
||||||
|
protected ActionLink buildViewAllLink () {
|
||||||
|
ActionLink viewAllLink = new ActionLink( (String) DecisionTreeUtil.globalize("section_options.view_all_options").localize());
|
||||||
|
viewAllLink.setClassAttr(ACTION_LINK);
|
||||||
|
viewAllLink.addActionListener( new ActionListener() {
|
||||||
|
public void actionPerformed ( ActionEvent event ) {
|
||||||
|
onlyShowComponent(event.getPageState(), OPTION_TABLE+m_typeIDStr);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return viewAllLink;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility method to create a link to display the section list.
|
||||||
|
*/
|
||||||
|
protected ActionLink buildAddLink () {
|
||||||
|
ActionLink addLink = new ActionLink( (String) DecisionTreeUtil.globalize("section_options.add_new_option").localize()) {
|
||||||
|
public boolean isVisible(PageState state) {
|
||||||
|
SecurityManager sm = Utilities.getSecurityManager(state);
|
||||||
|
ContentItem item = (ContentItem)m_selTree.getSelectedObject(state);
|
||||||
|
|
||||||
|
return super.isVisible(state) &&
|
||||||
|
sm.canAccess(state.getRequest(), SecurityManager.EDIT_ITEM,
|
||||||
|
item);
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
addLink.setClassAttr(ACTION_LINK);
|
||||||
|
addLink.addActionListener( new ActionListener () {
|
||||||
|
public void actionPerformed ( ActionEvent event ) {
|
||||||
|
PageState state = event.getPageState();
|
||||||
|
m_selOption.clearSelection(state);
|
||||||
|
onlyShowComponent(state, OPTION_EDIT+m_typeIDStr);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return addLink;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void register ( Page p ) {
|
||||||
|
super.register(p);
|
||||||
|
p.addGlobalStateParam(m_moveParameter);
|
||||||
|
p.setVisibleDefault(m_beginLink, false);
|
||||||
|
p.setVisibleDefault(m_moveOptionLabel, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTypeIDStr() {
|
||||||
|
return m_typeIDStr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,260 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2007 Red Hat Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.ActionLink;
|
||||||
|
import com.arsdigita.bebop.ColumnPanel;
|
||||||
|
import com.arsdigita.bebop.Container;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.event.ActionEvent;
|
||||||
|
import com.arsdigita.bebop.event.ActionListener;
|
||||||
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
|
import com.arsdigita.bebop.event.FormSubmissionListener;
|
||||||
|
import com.arsdigita.bebop.event.PrintEvent;
|
||||||
|
import com.arsdigita.bebop.event.PrintListener;
|
||||||
|
import com.arsdigita.bebop.event.TableActionEvent;
|
||||||
|
import com.arsdigita.bebop.event.TableActionListener;
|
||||||
|
import com.arsdigita.bebop.table.TableColumn;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTree;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTreeUtil;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTreeSection;
|
||||||
|
import com.arsdigita.cms.ContentItem;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.SecurityManager;
|
||||||
|
import com.arsdigita.cms.contenttypes.ui.ResettableContainer;
|
||||||
|
import com.arsdigita.cms.dispatcher.Utilities;
|
||||||
|
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
||||||
|
import com.arsdigita.util.Assert;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Authoring kit step to manage the sections for a DecisionTree.
|
||||||
|
* The editing process is implemented with three main visual components
|
||||||
|
* that manipulate the currently selected DecisionTree and sections.
|
||||||
|
* The visibility of these components is managed by this class.
|
||||||
|
*
|
||||||
|
* @author Carsten Clasohm
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class DecisionTreeViewSections extends ResettableContainer
|
||||||
|
{
|
||||||
|
/** id keys for each editing panel */
|
||||||
|
public static final String SECTION_TABLE = "sec_tbl";
|
||||||
|
public static final String SECTION_EDIT = "sec_edt";
|
||||||
|
public static final String SECTION_DEL = "sec_del";
|
||||||
|
|
||||||
|
/** class attributes */
|
||||||
|
public static final String DATA_TABLE = "dataTable";
|
||||||
|
public static final String ACTION_LINK = "actionLink";
|
||||||
|
|
||||||
|
protected AuthoringKitWizard m_wizard;
|
||||||
|
protected ItemSelectionModel m_selTree;
|
||||||
|
protected ItemSelectionModel m_selSection;
|
||||||
|
|
||||||
|
/** visual components that do the 'real work' */
|
||||||
|
protected DecisionTreeSectionTable m_sectionTable;
|
||||||
|
protected DecisionTreeSectionEditForm m_sectionEdit;
|
||||||
|
protected DecisionTreeSectionDeleteForm m_sectionDelete;
|
||||||
|
|
||||||
|
private String m_typeIDStr;
|
||||||
|
|
||||||
|
public DecisionTreeViewSections (ItemSelectionModel selTree,
|
||||||
|
AuthoringKitWizard wizard) {
|
||||||
|
super();
|
||||||
|
m_selTree = selTree;
|
||||||
|
m_wizard = wizard;
|
||||||
|
m_typeIDStr = wizard.getContentType().getID().toString();
|
||||||
|
Assert.exists(m_selTree, ItemSelectionModel.class);
|
||||||
|
|
||||||
|
// create the components and set default visibility
|
||||||
|
add(buildSectionTable(), true);
|
||||||
|
add(buildSectionEdit(), false);
|
||||||
|
add(buildSectionDelete(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds a container to hold a SectionTable and a link
|
||||||
|
* to add a new section.
|
||||||
|
*/
|
||||||
|
protected Container buildSectionTable () {
|
||||||
|
ColumnPanel c = new ColumnPanel(1);
|
||||||
|
c.setKey(SECTION_TABLE+m_typeIDStr);
|
||||||
|
c.setBorderColor("#FFFFFF");
|
||||||
|
c.setPadColor("#FFFFFF");
|
||||||
|
|
||||||
|
m_sectionTable = new DecisionTreeSectionTable(m_selTree);
|
||||||
|
m_sectionTable.setClassAttr(DATA_TABLE);
|
||||||
|
|
||||||
|
// selected section is based on the selection in the SectionTable
|
||||||
|
m_selSection = new ItemSelectionModel(DecisionTreeSection.class.getName(),
|
||||||
|
DecisionTreeSection.BASE_DATA_OBJECT_TYPE,
|
||||||
|
m_sectionTable.getRowSelectionModel());
|
||||||
|
|
||||||
|
m_sectionTable.setSectionModel(m_selSection);
|
||||||
|
|
||||||
|
Label emptyView = new Label(DecisionTreeUtil
|
||||||
|
.globalize("tree_sections.no_sections_yet"));
|
||||||
|
m_sectionTable.setEmptyView(emptyView);
|
||||||
|
|
||||||
|
// handle clicks to delete a Section
|
||||||
|
m_sectionTable.addTableActionListener (new TableActionListener () {
|
||||||
|
public void cellSelected (TableActionEvent event) {
|
||||||
|
PageState state = event.getPageState();
|
||||||
|
|
||||||
|
TableColumn col = m_sectionTable.getColumnModel()
|
||||||
|
.get(event.getColumn().intValue());
|
||||||
|
String colName = (String)col.getHeaderValue();
|
||||||
|
|
||||||
|
if (DecisionTreeSectionTable.COL_DEL.equals(colName)) {
|
||||||
|
onlyShowComponent(state, SECTION_DEL+m_typeIDStr);
|
||||||
|
} else if (DecisionTreeSectionTable.COL_EDIT.equals(colName)) {
|
||||||
|
onlyShowComponent(state, SECTION_EDIT+m_typeIDStr);
|
||||||
|
} else if (DecisionTreeSectionTable.COL_FIRST.equals(colName)) {
|
||||||
|
DecisionTree tree = (DecisionTree)m_selTree
|
||||||
|
.getSelectedObject(state);
|
||||||
|
DecisionTreeSection section = (DecisionTreeSection)m_selSection
|
||||||
|
.getSelectedItem(state);
|
||||||
|
tree.setFirstSection(section);
|
||||||
|
tree.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void headSelected(TableActionEvent e) {}
|
||||||
|
});
|
||||||
|
c.add(m_sectionTable);
|
||||||
|
|
||||||
|
// link to add new section
|
||||||
|
c.add(buildAddLink());
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds a container to hold a SectionEditForm and a link
|
||||||
|
* to return to the section list.
|
||||||
|
*/
|
||||||
|
protected Container buildSectionEdit () {
|
||||||
|
ColumnPanel c = new ColumnPanel(1);
|
||||||
|
c.setKey(SECTION_EDIT+m_typeIDStr);
|
||||||
|
c.setBorderColor("#FFFFFF");
|
||||||
|
c.setPadColor("#FFFFFF");
|
||||||
|
|
||||||
|
// display an appropriate title
|
||||||
|
c.add( new Label( new PrintListener() {
|
||||||
|
public void prepare ( PrintEvent event ) {
|
||||||
|
PageState state = event.getPageState();
|
||||||
|
Label label = (Label)event.getTarget();
|
||||||
|
|
||||||
|
if (m_selSection.getSelectedKey(state) == null) {
|
||||||
|
label.setLabel(DecisionTreeUtil
|
||||||
|
.globalize("tree_sections.add_section"));
|
||||||
|
} else {
|
||||||
|
label.setLabel(DecisionTreeUtil
|
||||||
|
.globalize("tree_sections.edit_section"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
// form to edit a Section
|
||||||
|
m_sectionEdit = new DecisionTreeSectionEditForm(m_selTree, m_selSection, this);
|
||||||
|
c.add(m_sectionEdit);
|
||||||
|
|
||||||
|
c.add(buildViewAllLink());
|
||||||
|
// link to add new section
|
||||||
|
c.add(buildAddLink());
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds a container to hold the component to confirm
|
||||||
|
* deletion of a section.
|
||||||
|
*/
|
||||||
|
protected Container buildSectionDelete () {
|
||||||
|
ColumnPanel c = new ColumnPanel(1);
|
||||||
|
c.setKey(SECTION_DEL+m_typeIDStr);
|
||||||
|
c.setBorderColor("#FFFFFF");
|
||||||
|
c.setPadColor("#FFFFFF");
|
||||||
|
|
||||||
|
c.add(new Label(DecisionTreeUtil.globalize("tree_sections.delete_section")));
|
||||||
|
m_sectionDelete = new DecisionTreeSectionDeleteForm(m_selTree, m_selSection);
|
||||||
|
m_sectionDelete.addSubmissionListener ( new FormSubmissionListener () {
|
||||||
|
public void submitted ( FormSectionEvent e ) {
|
||||||
|
PageState state = e.getPageState();
|
||||||
|
onlyShowComponent(state, SECTION_TABLE+m_typeIDStr);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
c.add(m_sectionDelete);
|
||||||
|
|
||||||
|
c.add(buildViewAllLink());
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility method to create a link to display the section list.
|
||||||
|
*/
|
||||||
|
protected ActionLink buildViewAllLink () {
|
||||||
|
ActionLink viewAllLink = new ActionLink(DecisionTreeUtil
|
||||||
|
.globalize("tree_sections.view_all_sections"));
|
||||||
|
viewAllLink.setClassAttr(ACTION_LINK);
|
||||||
|
viewAllLink.addActionListener( new ActionListener() {
|
||||||
|
public void actionPerformed ( ActionEvent event ) {
|
||||||
|
onlyShowComponent(event.getPageState(), SECTION_TABLE+m_typeIDStr);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return viewAllLink;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility method to create a link to display the section list.
|
||||||
|
*/
|
||||||
|
protected ActionLink buildAddLink () {
|
||||||
|
ActionLink addLink = new ActionLink(DecisionTreeUtil
|
||||||
|
.globalize("tree_sections.add_new_section")) {
|
||||||
|
@Override
|
||||||
|
public boolean isVisible(PageState state) {
|
||||||
|
SecurityManager sm = Utilities.getSecurityManager(state);
|
||||||
|
ContentItem item = (ContentItem)m_selTree.getSelectedObject(state);
|
||||||
|
|
||||||
|
return super.isVisible(state) &&
|
||||||
|
sm.canAccess(state.getRequest(), SecurityManager.EDIT_ITEM,
|
||||||
|
item);
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
addLink.setClassAttr(ACTION_LINK);
|
||||||
|
addLink.addActionListener( new ActionListener () {
|
||||||
|
public void actionPerformed ( ActionEvent event ) {
|
||||||
|
PageState state = event.getPageState();
|
||||||
|
m_selSection.clearSelection(state);
|
||||||
|
onlyShowComponent(state, SECTION_EDIT+m_typeIDStr);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return addLink;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTypeIDStr() {
|
||||||
|
return m_typeIDStr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,271 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2007 Red Hat Inc. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.arsdigita.cms.contenttypes.ui;
|
||||||
|
|
||||||
|
|
||||||
|
import com.arsdigita.bebop.ActionLink;
|
||||||
|
import com.arsdigita.bebop.ColumnPanel;
|
||||||
|
import com.arsdigita.bebop.Container;
|
||||||
|
import com.arsdigita.bebop.Label;
|
||||||
|
import com.arsdigita.bebop.PageState;
|
||||||
|
import com.arsdigita.bebop.event.ActionEvent;
|
||||||
|
import com.arsdigita.bebop.event.ActionListener;
|
||||||
|
import com.arsdigita.bebop.event.FormSectionEvent;
|
||||||
|
import com.arsdigita.bebop.event.FormSubmissionListener;
|
||||||
|
import com.arsdigita.bebop.event.PrintEvent;
|
||||||
|
import com.arsdigita.bebop.event.PrintListener;
|
||||||
|
import com.arsdigita.bebop.event.TableActionEvent;
|
||||||
|
import com.arsdigita.bebop.event.TableActionListener;
|
||||||
|
import com.arsdigita.bebop.table.TableColumn;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTree;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTreeUtil;
|
||||||
|
import com.arsdigita.cms.contenttypes.DecisionTreeSection;
|
||||||
|
import com.arsdigita.cms.ContentItem;
|
||||||
|
import com.arsdigita.cms.ItemSelectionModel;
|
||||||
|
import com.arsdigita.cms.SecurityManager;
|
||||||
|
import com.arsdigita.cms.contenttypes.ui.ResettableContainer;
|
||||||
|
import com.arsdigita.cms.dispatcher.Utilities;
|
||||||
|
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
||||||
|
import com.arsdigita.util.Assert;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Authoring kit step to manage the targets for a DecisionTree.
|
||||||
|
* The editing process is implemented with three main visual components
|
||||||
|
* that manipulate the currently selected DecisionTree and targets.
|
||||||
|
* The visibility of these components is managed by this class.
|
||||||
|
*
|
||||||
|
* @author Carsten Clasohm
|
||||||
|
* @version $Id$
|
||||||
|
*/
|
||||||
|
public class DecisionTreeViewTargets extends ResettableContainer
|
||||||
|
{
|
||||||
|
/** id keys for each editing panel */
|
||||||
|
public static final String TARGET_TABLE = "tgt_tbl";
|
||||||
|
public static final String TARGET_EDIT = "tgt_edt";
|
||||||
|
public static final String TARGET_DEL = "tgt_del";
|
||||||
|
|
||||||
|
/** class attributes */
|
||||||
|
public static final String DATA_TABLE = "dataTable";
|
||||||
|
public static final String ACTION_LINK = "actionLink";
|
||||||
|
|
||||||
|
protected AuthoringKitWizard m_wizard;
|
||||||
|
protected ItemSelectionModel m_selTree;
|
||||||
|
protected ItemSelectionModel m_selTarget;
|
||||||
|
|
||||||
|
/** visual components that do the 'real work' */
|
||||||
|
protected DecisionTreeTargetTable m_targetTable;
|
||||||
|
protected DecisionTreeTargetEditForm m_targetEdit;
|
||||||
|
protected DecisionTreeTargetDeleteForm m_targetDelete;
|
||||||
|
|
||||||
|
private String m_typeIDStr;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param selTree
|
||||||
|
* @param wizard
|
||||||
|
*/
|
||||||
|
public DecisionTreeViewTargets (ItemSelectionModel selTree,
|
||||||
|
AuthoringKitWizard wizard) {
|
||||||
|
super();
|
||||||
|
m_selTree = selTree;
|
||||||
|
m_wizard = wizard;
|
||||||
|
m_typeIDStr = wizard.getContentType().getID().toString();
|
||||||
|
Assert.exists(m_selTree, ItemSelectionModel.class);
|
||||||
|
|
||||||
|
// create the components and set default visibility
|
||||||
|
add(buildTargetTable(), true);
|
||||||
|
add(buildTargetEdit(), false);
|
||||||
|
add(buildTargetDelete(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds a container to hold a TargetTable and a link
|
||||||
|
* to add a new target.
|
||||||
|
*/
|
||||||
|
protected Container buildTargetTable () {
|
||||||
|
ColumnPanel c = new ColumnPanel(1);
|
||||||
|
c.setKey(TARGET_TABLE+m_typeIDStr);
|
||||||
|
c.setBorderColor("#FFFFFF");
|
||||||
|
c.setPadColor("#FFFFFF");
|
||||||
|
|
||||||
|
m_targetTable = new DecisionTreeTargetTable(m_selTree);
|
||||||
|
m_targetTable.setClassAttr(DATA_TABLE);
|
||||||
|
|
||||||
|
// selected section is based on the selection in the SectionTable
|
||||||
|
m_selTarget = new ItemSelectionModel(DecisionTreeSection.class.getName(),
|
||||||
|
DecisionTreeSection.BASE_DATA_OBJECT_TYPE,
|
||||||
|
m_targetTable.getRowSelectionModel());
|
||||||
|
|
||||||
|
m_targetTable.setSectionModel(m_selTarget);
|
||||||
|
|
||||||
|
Label emptyView = new Label(DecisionTreeUtil
|
||||||
|
.globalize("option_targets.no_targets_yet"));
|
||||||
|
m_targetTable.setEmptyView(emptyView);
|
||||||
|
|
||||||
|
// handle clicks to preview or delete a Section
|
||||||
|
m_targetTable.addTableActionListener (new TableActionListener () {
|
||||||
|
public void cellSelected (TableActionEvent event) {
|
||||||
|
PageState state = event.getPageState();
|
||||||
|
|
||||||
|
TableColumn col = m_targetTable.getColumnModel()
|
||||||
|
.get(event.getColumn().intValue());
|
||||||
|
String colName = (String)col.getHeaderValue();
|
||||||
|
|
||||||
|
if (DecisionTreeSectionTable.COL_DEL.equals(colName)) {
|
||||||
|
onlyShowComponent(state, TARGET_DEL+m_typeIDStr);
|
||||||
|
} else if (DecisionTreeSectionTable.COL_EDIT.equals(colName)) {
|
||||||
|
onlyShowComponent(state, TARGET_EDIT+m_typeIDStr);
|
||||||
|
} else if (DecisionTreeSectionTable.COL_FIRST.equals(colName)) {
|
||||||
|
DecisionTree tree =
|
||||||
|
(DecisionTree)m_selTree.getSelectedObject(state);
|
||||||
|
DecisionTreeSection section =
|
||||||
|
(DecisionTreeSection)m_selTarget.getSelectedItem(state);
|
||||||
|
tree.setFirstSection(section);
|
||||||
|
tree.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void headSelected(TableActionEvent e) {}
|
||||||
|
});
|
||||||
|
c.add(m_targetTable);
|
||||||
|
|
||||||
|
// link to add new section
|
||||||
|
c.add(buildAddLink());
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds a container to hold a SectionEditForm and a link
|
||||||
|
* to return to the section list.
|
||||||
|
*/
|
||||||
|
protected Container buildTargetEdit () {
|
||||||
|
ColumnPanel c = new ColumnPanel(1);
|
||||||
|
c.setKey(TARGET_EDIT+m_typeIDStr);
|
||||||
|
c.setBorderColor("#FFFFFF");
|
||||||
|
c.setPadColor("#FFFFFF");
|
||||||
|
|
||||||
|
// display an appropriate title
|
||||||
|
c.add( new Label( new PrintListener() {
|
||||||
|
public void prepare ( PrintEvent event ) {
|
||||||
|
PageState state = event.getPageState();
|
||||||
|
Label label = (Label)event.getTarget();
|
||||||
|
|
||||||
|
if (m_selTarget.getSelectedKey(state) == null) {
|
||||||
|
label.setLabel(DecisionTreeUtil
|
||||||
|
.globalize("option_targets.add_target"));
|
||||||
|
} else {
|
||||||
|
label.setLabel(DecisionTreeUtil
|
||||||
|
.globalize("option_targets.edit_target"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
// form to edit a Section
|
||||||
|
m_targetEdit = new DecisionTreeTargetEditForm(m_selTree, m_selTarget, this);
|
||||||
|
c.add(m_targetEdit);
|
||||||
|
|
||||||
|
c.add(buildViewAllLink());
|
||||||
|
// link to add new section
|
||||||
|
c.add(buildAddLink());
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds a container to hold the component to confirm
|
||||||
|
* deletion of a section.
|
||||||
|
*/
|
||||||
|
protected Container buildTargetDelete () {
|
||||||
|
ColumnPanel c = new ColumnPanel(1);
|
||||||
|
c.setKey(TARGET_DEL+m_typeIDStr);
|
||||||
|
c.setBorderColor("#FFFFFF");
|
||||||
|
c.setPadColor("#FFFFFF");
|
||||||
|
|
||||||
|
c.add(new Label(DecisionTreeUtil.globalize("option_targets.delete_target")));
|
||||||
|
m_targetDelete = new DecisionTreeTargetDeleteForm(m_selTree, m_selTarget);
|
||||||
|
m_targetDelete.addSubmissionListener ( new FormSubmissionListener () {
|
||||||
|
public void submitted ( FormSectionEvent e ) {
|
||||||
|
PageState state = e.getPageState();
|
||||||
|
onlyShowComponent(state, TARGET_TABLE+m_typeIDStr);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
c.add(m_targetDelete);
|
||||||
|
|
||||||
|
c.add(buildViewAllLink());
|
||||||
|
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility method to create a link to display the section list.
|
||||||
|
*/
|
||||||
|
protected ActionLink buildViewAllLink () {
|
||||||
|
ActionLink viewAllLink = new
|
||||||
|
ActionLink( DecisionTreeUtil.globalize("option_targets.view_all_targets"));
|
||||||
|
viewAllLink.setClassAttr(ACTION_LINK);
|
||||||
|
viewAllLink.addActionListener( new ActionListener() {
|
||||||
|
public void actionPerformed ( ActionEvent event ) {
|
||||||
|
onlyShowComponent(event.getPageState(), TARGET_TABLE+m_typeIDStr);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return viewAllLink;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Utility method to create a link to display the section list.
|
||||||
|
*/
|
||||||
|
protected ActionLink buildAddLink () {
|
||||||
|
|
||||||
|
ActionLink addLink = new ActionLink( DecisionTreeUtil
|
||||||
|
.globalize("option_targets.add_new_target")) {
|
||||||
|
@Override
|
||||||
|
public boolean isVisible(PageState state) {
|
||||||
|
SecurityManager sm = Utilities.getSecurityManager(state);
|
||||||
|
ContentItem item = (ContentItem)m_selTree.getSelectedObject(state);
|
||||||
|
|
||||||
|
return super.isVisible(state) &&
|
||||||
|
sm.canAccess(state.getRequest(), SecurityManager.EDIT_ITEM,
|
||||||
|
item);
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
addLink.setClassAttr(ACTION_LINK);
|
||||||
|
addLink.addActionListener( new ActionListener () {
|
||||||
|
public void actionPerformed ( ActionEvent event ) {
|
||||||
|
PageState state = event.getPageState();
|
||||||
|
m_selTarget.clearSelection(state);
|
||||||
|
onlyShowComponent(state, TARGET_EDIT+m_typeIDStr);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return addLink;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getTypeIDStr() {
|
||||||
|
return m_typeIDStr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,77 @@
|
||||||
|
<!DOCTYPE stylesheet [
|
||||||
|
<!ENTITY nbsp " " ><!-- no-break space = non-breaking space, U+00A0 ISOnum -->
|
||||||
|
]>
|
||||||
|
|
||||||
|
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
||||||
|
xmlns:cms="http://www.arsdigita.com/cms/1.0"
|
||||||
|
version="1.0">
|
||||||
|
|
||||||
|
<xsl:template match="cms:item[objectType='com.arsdigita.cms.contenttypes.DecisionTree']" mode="cms:CT_graphics"
|
||||||
|
name="cms:CT_graphics_com_arsdigita_cms_contenttypes_DecisionTree">
|
||||||
|
<script type="text/javascript"
|
||||||
|
src="/templates/ccm-cms-types-decisiontree/forms.js">
|
||||||
|
// Placeholder to prevent the Camden templates from breaking this tag.
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<h2><xsl:value-of select="./sections/title"/></h2>
|
||||||
|
|
||||||
|
<div><xsl:value-of select="./sections/instructions/content" disable-output-escaping="yes"/></div>
|
||||||
|
|
||||||
|
<form action="/templates/ccm-cms-types-decisiontree/form-handler.jsp" method="GET">
|
||||||
|
<input type="hidden" name="section_oid">
|
||||||
|
<xsl:attribute name="value">
|
||||||
|
<xsl:value-of select="./sections[title]/@oid"/>
|
||||||
|
</xsl:attribute>
|
||||||
|
</input>
|
||||||
|
<input type="hidden" name="return_url">
|
||||||
|
<xsl:attribute name="value">
|
||||||
|
<xsl:value-of select="./customInfo/@currentURL"/>
|
||||||
|
</xsl:attribute>
|
||||||
|
</input>
|
||||||
|
|
||||||
|
<xsl:for-each select="./parameters">
|
||||||
|
<input type="hidden">
|
||||||
|
<xsl:attribute name="name">
|
||||||
|
<xsl:value-of select="@name"/>
|
||||||
|
</xsl:attribute>
|
||||||
|
<xsl:attribute name="value">
|
||||||
|
<xsl:value-of select="@value"/>
|
||||||
|
</xsl:attribute>
|
||||||
|
</input>
|
||||||
|
</xsl:for-each>
|
||||||
|
|
||||||
|
<xsl:for-each select="./sections/sectionOptions">
|
||||||
|
<xsl:sort select="./rank" data-type="number"/>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<input type="radio">
|
||||||
|
<xsl:attribute name="name">
|
||||||
|
<xsl:value-of select="../parameterName"/>
|
||||||
|
</xsl:attribute>
|
||||||
|
<xsl:attribute name="value">
|
||||||
|
<xsl:value-of select="./value"/>
|
||||||
|
</xsl:attribute>
|
||||||
|
<xsl:attribute name="id">
|
||||||
|
<xsl:value-of select="@oid"/>
|
||||||
|
</xsl:attribute>
|
||||||
|
</input>
|
||||||
|
<label>
|
||||||
|
<xsl:attribute name="for">
|
||||||
|
<xsl:value-of select="@oid"/>
|
||||||
|
</xsl:attribute>
|
||||||
|
<xsl:value-of select="./label"/>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
</xsl:for-each>
|
||||||
|
|
||||||
|
<input type="submit" name="cancel" value="Cancel"/>
|
||||||
|
<input type="submit" name="next" value="Next >" onclick="return validate(this.form)"/>
|
||||||
|
</form>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
<xsl:template match="cms:item[objectType='com.arsdigita.cms.contenttypes.DecisionTree']" mode="cms:CT_text"
|
||||||
|
name="cms:CT_text_com_arsdigita_cms_contenttypes_DecisionTree">
|
||||||
|
<h1 class="mainTitle">DECISIONTREE <xsl:text disable-output-escaping="yes">&</xsl:text>gt; <xsl:value-of select="./title"/></h1>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
</xsl:stylesheet>
|
||||||
Loading…
Reference in New Issue