From d0e92f426e8d716fe94f34829c20a1d9c0e1d24e Mon Sep 17 00:00:00 2001 From: jensp Date: Sun, 10 Oct 2010 14:31:31 +0000 Subject: [PATCH] =?UTF-8?q?Folgende=20=C3=84nderungen=20im=20Modul=20sci-o?= =?UTF-8?q?rganization:=20-=20Konfigurationsklasse=20hinzugef=C3=BCgt=20-?= =?UTF-8?q?=20SciProject=20=20=20*=20Description=20und=20Funding=20zusamme?= =?UTF-8?q?ngefasst=20=20=20*=20Die=20Beschreibung=20kann=20wie=20bei=20cc?= =?UTF-8?q?m-types-article=20als=20Datei=20hochgeladen=20werden.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://svn.libreccm.org/ccm/trunk@568 8810af33-2d31-482b-a856-94f89814c4df --- .../arsdigita/cms/contenttypes/SciProject.xml | 9 +- .../src/ccm-sci-types-organization.config | 3 +- .../contenttypes/SciOrganizationConfig.java | 59 +++++ ...SciOrganizationConfig_parameter.properties | 19 ++ .../cms/contenttypes/SciProject.java | 11 + ...ava => SciProjectDescriptionEditForm.java} | 33 ++- .../ui/SciProjectDescriptionStep.java | 20 +- .../ui/SciProjectDescriptionUploadForm.java | 236 ++++++++++++++++++ .../ui/SciProjectFundingForm.java | 67 ----- .../ui/SciProjectFundingStep.java | 52 ---- .../ui/SciProjectPropertyForm.java | 25 +- 11 files changed, 379 insertions(+), 155 deletions(-) create mode 100644 ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/SciOrganizationConfig.java create mode 100644 ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/SciOrganizationConfig_parameter.properties rename ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/{SciProjectEditDescForm.java => SciProjectDescriptionEditForm.java} (62%) create mode 100644 ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectDescriptionUploadForm.java delete mode 100644 ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectFundingForm.java delete mode 100644 ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectFundingStep.java diff --git a/ccm-sci-types-organization/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/SciProject.xml b/ccm-sci-types-organization/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/SciProject.xml index 5e6dd59d5..2701b877c 100644 --- a/ccm-sci-types-organization/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/SciProject.xml +++ b/ccm-sci-types-organization/src/WEB-INF/content-types/com/arsdigita/cms/contenttypes/SciProject.xml @@ -25,14 +25,7 @@ labelBundle="com.arsdigita.cms.contenttypes.ui.SciProjectResources" descriptionKey="sciorganization.ui.project_description.title.description" component="com.arsdigita.cms.contenttypes.ui.SciProjectDescriptionStep" - ordering="2"/> - - + ordering="2"/> diff --git a/ccm-sci-types-organization/src/ccm-sci-types-organization.config b/ccm-sci-types-organization/src/ccm-sci-types-organization.config index 6b16ef9b2..786bbc0dc 100644 --- a/ccm-sci-types-organization/src/ccm-sci-types-organization.config +++ b/ccm-sci-types-organization/src/ccm-sci-types-organization.config @@ -1,4 +1,5 @@ - + diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/SciOrganizationConfig.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/SciOrganizationConfig.java new file mode 100644 index 000000000..e1647c690 --- /dev/null +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/SciOrganizationConfig.java @@ -0,0 +1,59 @@ +package com.arsdigita.cms.contenttypes; + +import com.arsdigita.runtime.AbstractConfig; +import com.arsdigita.util.parameter.BooleanParameter; +import com.arsdigita.util.parameter.Parameter; + +/** + * + * @author Jens Pelzetter + */ +public class SciOrganizationConfig extends AbstractConfig { + + private final Parameter m_projectFundingHide; + private final Parameter m_projectFundingDhtml; + private final Parameter m_projectMaterialsHide; + private final Parameter m_organizationPersonsHide; + + public SciOrganizationConfig() { + m_projectFundingHide = new BooleanParameter( + "com.arsdigita.cms.contenttypes.sciproject.funding_hide", + Parameter.REQUIRED, + Boolean.FALSE); + m_projectFundingDhtml = new BooleanParameter( + "com.arsdigita.cms.contenttypes.sciproject.funding_dhtml", + Parameter.REQUIRED, + Boolean.FALSE); + m_projectMaterialsHide = new BooleanParameter( + "com.arsdigita.cms.contenttypes.sciproject.materials_hide", + Parameter.REQUIRED, + Boolean.FALSE); + m_organizationPersonsHide = new BooleanParameter( + "com.arsdigita.cms.contenttypes.sciorganization.persons_hide", + Parameter.REQUIRED, + Boolean.TRUE); + + register(m_projectFundingHide); + register(m_projectFundingDhtml); + register(m_projectMaterialsHide); + register(m_organizationPersonsHide); + + loadInfo(); + } + + public final boolean getProjectFundingHide() { + return (Boolean) get(m_projectFundingHide); + } + + public final boolean getProjectFundingDhtml() { + return (Boolean) get(m_projectFundingDhtml); + } + + public final boolean getProjectMaterialsHide() { + return (Boolean) get(m_projectMaterialsHide); + } + + public final boolean getOrganizationPersonsHide() { + return (Boolean) get(m_organizationPersonsHide); + } +} diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/SciOrganizationConfig_parameter.properties b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/SciOrganizationConfig_parameter.properties new file mode 100644 index 000000000..828016a48 --- /dev/null +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/SciOrganizationConfig_parameter.properties @@ -0,0 +1,19 @@ +com.arsdigita.cms.contenttypes.sciproject.funding_hide.title = Hide funding text input +com.arsdigita.cms.contenttypes.sciproject.funding_hide.purpose = Hide the funding text inpu +com.arsdigita.cms.contenttypes.sciproject.funding_hide.example = false +com.arsdigita.cms.contenttypes.sciproject.funding_hide.format = [boolean] + +com.arsdigita.cms.contenttypes.sciproject.funding_dhtml.title = Toggles the DHTML for funding +com.arsdigita.cms.contenttypes.sciproject.funding_dhtml.purpose = Toggles the DHTML editor +com.arsdigita.cms.contenttypes.sciproject.funding_dhtml.example = false +com.arsdigita.cms.contenttypes.sciproject.funding_dhtml.format = [boolean] + +com.arsdigita.cms.contenttypes.sciproject.materials_hide.title = Hides the step for linking materials with a project +com.arsdigita.cms.contenttypes.sciproject.materials_hide.purpose = Hides the step for linking materials with a project +com.arsdigita.cms.contenttypes.sciproject.materials_hide.example = false +com.arsdigita.cms.contenttypes.sciproject.materials_hide.format = [boolean] + +com.arsdigita.cms.contenttypes.sciorganization.persons_hide.title = Hides the persons step for SciOrganization +com.arsdigita.cms.contenttypes.sciorganization.persons_hide.purpose = Hides the persons step for SciOrganization +com.arsdigita.cms.contenttypes.sciorganization.persons_hide.example = true +com.arsdigita.cms.contenttypes.sciorganization.persons_hide.format = [boolean] diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/SciProject.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/SciProject.java index ece62363e..ef770aa98 100644 --- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/SciProject.java +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/SciProject.java @@ -48,6 +48,13 @@ public class SciProject extends GenericOrganizationalUnit { public static final String BASE_DATA_OBJECT_TYPE = "com.arsdigita.cms.contenttypes.SciProject"; + private static final SciOrganizationConfig s_config = + new SciOrganizationConfig(); + + static { + s_config.load(); + } + public SciProject() { super(BASE_DATA_OBJECT_TYPE); } @@ -68,6 +75,10 @@ public class SciProject extends GenericOrganizationalUnit { super(type); } + public static final SciOrganizationConfig getConfig() { + return s_config; + } + public Date getBegin() { return (Date) get(BEGIN); } diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectEditDescForm.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectDescriptionEditForm.java similarity index 62% rename from ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectEditDescForm.java rename to ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectDescriptionEditForm.java index 8752c7a7f..0562f0844 100644 --- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectEditDescForm.java +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectDescriptionEditForm.java @@ -2,10 +2,12 @@ package com.arsdigita.cms.contenttypes.ui; import com.arsdigita.bebop.FormData; import com.arsdigita.bebop.FormProcessException; +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.form.TextArea; import com.arsdigita.bebop.parameters.ParameterModel; import com.arsdigita.bebop.parameters.StringParameter; import com.arsdigita.cms.ItemSelectionModel; @@ -17,23 +19,43 @@ import com.arsdigita.cms.ui.authoring.BasicItemForm; * * @author Jens Pelzetter */ -public class SciProjectEditDescForm +public class SciProjectDescriptionEditForm extends BasicItemForm implements FormProcessListener, FormInitListener { - public SciProjectEditDescForm(ItemSelectionModel itemModel) { + public SciProjectDescriptionEditForm(ItemSelectionModel itemModel) { super("sciprojectEditDescForm", itemModel); } @Override protected void addWidgets() { + add(new Label(SciOrganizationGlobalizationUtil.globalize( + "sciorganizazion.ui.project.description"))); ParameterModel descParam = new StringParameter( SciProject.PROJECT_DESCRIPTION); CMSDHTMLEditor desc = new CMSDHTMLEditor(descParam); desc.setCols(75); desc.setRows(25); add(desc); + + + if (!SciProject.getConfig().getProjectFundingHide()) { + add(new Label(SciOrganizationGlobalizationUtil.globalize( + "sciorganizazion.ui.project.funding"))); + ParameterModel fundingParam = new StringParameter( + SciProject.FUNDING); + TextArea funding; + if (SciProject.getConfig().getProjectFundingDhtml()) { + funding = new CMSDHTMLEditor(fundingParam); + } else { + funding = new TextArea(fundingParam); + } + + funding.setCols(75); + funding.setRows(25); + add(funding); + } } @Override @@ -46,6 +68,9 @@ public class SciProjectEditDescForm data.put(SciProject.PROJECT_DESCRIPTION, project.getProjectDescription()); + if (!SciProject.getConfig().getProjectFundingHide()) { + data.put(SciProject.FUNDING, project.getFunding()); + } setVisible(state, true); } @@ -62,6 +87,10 @@ public class SciProjectEditDescForm isSelected(state)) { project.setProjectDescription((String) data.get( SciProject.PROJECT_DESCRIPTION)); + if (!SciProject.getConfig().getProjectFundingHide()) { + project.setFunding((String) data.get( + SciProject.FUNDING)); + } project.save(); diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectDescriptionStep.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectDescriptionStep.java index 77a252e36..d38e9fadb 100644 --- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectDescriptionStep.java +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectDescriptionStep.java @@ -1,6 +1,7 @@ package com.arsdigita.cms.contenttypes.ui; import com.arsdigita.bebop.Component; +import com.arsdigita.bebop.Form; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.contenttypes.SciProject; import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; @@ -16,6 +17,7 @@ import com.arsdigita.toolbox.ui.DomainObjectPropertySheet; public class SciProjectDescriptionStep extends SimpleEditStep { private String EDIT_PROJECT_DESC_SHEET_NAME = "editProjectDesc"; + private String UPLOAD_PROJECT_DESC_SHEET_NAME = "uploadProjectDesc"; public SciProjectDescriptionStep(ItemSelectionModel itemModel, AuthoringKitWizard parent) { @@ -27,13 +29,22 @@ public class SciProjectDescriptionStep extends SimpleEditStep { String prefix) { super(itemModel, parent, prefix); - BasicItemForm editDescForm = new SciProjectEditDescForm(itemModel); + BasicItemForm editDescForm = + new SciProjectDescriptionEditForm(itemModel); add(EDIT_PROJECT_DESC_SHEET_NAME, (String) SciOrganizationGlobalizationUtil.globalize( "sciorganization.ui.project.edit_desc").localize(), new WorkflowLockedComponentAccess(editDescForm, itemModel), editDescForm.getSaveCancelSection().getCancelButton()); + SciProjectDescriptionUploadForm uploadDescForm = + new SciProjectDescriptionUploadForm(itemModel); + add(UPLOAD_PROJECT_DESC_SHEET_NAME, + (String) SciOrganizationGlobalizationUtil.globalize( + "sciorganization.ui.project.upload_desc").localize(), + new WorkflowLockedComponentAccess(uploadDescForm, itemModel), + uploadDescForm.getSaveCancelSection().getCancelButton()); + setDisplayComponent( getSciProjectEditDescSheet(itemModel)); @@ -45,8 +56,11 @@ public class SciProjectDescriptionStep extends SimpleEditStep { itemModel); sheet.add(SciOrganizationGlobalizationUtil.globalize( - "sciorganizaztion.ui.project.desc"), - SciProject.PROJECT_DESCRIPTION); + "sciorganization.ui.project.desc"), + SciProject.PROJECT_DESCRIPTION); + sheet.add(SciOrganizationGlobalizationUtil.globalize( + "sciorganization.ui.project.funding"), + SciProject.FUNDING); return sheet; } diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectDescriptionUploadForm.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectDescriptionUploadForm.java new file mode 100644 index 000000000..ed8ea8e5b --- /dev/null +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectDescriptionUploadForm.java @@ -0,0 +1,236 @@ +package com.arsdigita.cms.contenttypes.ui; + +import com.arsdigita.bebop.BoxPanel; +import com.arsdigita.bebop.Form; +import com.arsdigita.bebop.FormProcessException; +import com.arsdigita.bebop.Label; +import com.arsdigita.bebop.PageState; +import com.arsdigita.bebop.RequestLocal; +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.FormValidationListener; +import com.arsdigita.bebop.form.FormErrorDisplay; +import com.arsdigita.bebop.parameters.NotNullValidationListener; +import com.arsdigita.bebop.util.GlobalizationUtil; +import com.arsdigita.cms.ItemSelectionModel; +import com.arsdigita.cms.contenttypes.SciProject; +import com.arsdigita.cms.ui.FileUploadSection; +import com.arsdigita.globalization.Globalization; +import com.arsdigita.kernel.Kernel; +import com.arsdigita.mimetypes.MimeType; +import com.arsdigita.mimetypes.MimeTypeStatus; +import com.arsdigita.mimetypes.TextMimeType; +import com.arsdigita.mimetypes.converters.ConvertFormat; +import com.arsdigita.util.UncheckedWrapperException; +import java.io.File; +import java.io.FileInputStream; +import java.io.UnsupportedEncodingException; +import org.apache.log4j.Logger; + +/** + * + * @author Jens Pelzetter + */ +public class SciProjectDescriptionUploadForm + extends Form + implements FormInitListener, + FormProcessListener, + FormValidationListener { + + private ItemSelectionModel m_itemModel; + private FileUploadSection m_fileUploadSection; + private SaveCancelSection m_saveCancelSection; + private RequestLocal m_fileUploadContent; + private RequestLocal m_fileUploadContentUsedInso; + private Logger s_log = Logger.getLogger( + SciProjectDescriptionUploadForm.class); + + public SciProjectDescriptionUploadForm(ItemSelectionModel itemModel) { + super("sciprojectUploadDescFrom", new BoxPanel(BoxPanel.VERTICAL)); + m_itemModel = itemModel; + setMethod(Form.POST); + setEncType("multipart/form-data"); + m_fileUploadContent = new RequestLocal(); + m_fileUploadContentUsedInso = new RequestLocal(); + addWidgets(); + } + + protected void addWidgets() { + add(new Label(SciOrganizationGlobalizationUtil.globalize( + "sciorganization.ui.project.description.upload"))); + m_fileUploadSection = new FileUploadSection( + SciOrganizationGlobalizationUtil.globalize( + "sciorganization.ui.project.description.upload.mimetype"), + "mime", + "text/plain"); + m_fileUploadSection.getFileUploadWidget().addValidationListener( + new NotNullValidationListener()); + m_fileUploadSection.getMimeTypeWidget().setDefaultValue( + FileUploadSection.GUESS_MIME); + add(m_fileUploadSection); + + m_saveCancelSection = new SaveCancelSection(); + add(m_saveCancelSection); + + add(new FormErrorDisplay(this)); + + this.addValidationListener(this); + this.addProcessListener(this); + } + + /** + * @return the save/cancel section for this form + */ + public SaveCancelSection getSaveCancelSection() { + return m_saveCancelSection; + } + + @Override + public void init(FormSectionEvent fse) throws FormProcessException { + PageState state = fse.getPageState(); + + setVisible(state, true); + } + + /** + * Validate file upload + * @param e + * @throws FormProcessException + */ + @Override + public void validate(FormSectionEvent e) throws FormProcessException { + + MimeType mime = m_fileUploadSection.getMimeType(e); + boolean textType = mime.getPrefix().equals(TextMimeType.TEXT_PREFIX); + + validateFileType(mime, textType); + + // Convert the file to HTML, if possible + File file = m_fileUploadSection.getFile(e); + byte[] file_bytes = readFileBytes(file); + boolean[] used_inso = new boolean[1]; + String file_content = convertBytes(file_bytes, textType, used_inso); + + if (TextMimeType.MIME_TEXT_HTML.equals(mime.getMimeType())) { + file_content = extractHTMLBody(file_content); + } + + PageState state = e.getPageState(); + m_fileUploadContent.set(state, file_content); + m_fileUploadContentUsedInso.set(state, used_inso[0]); + } + + @Override + public void process(FormSectionEvent fse) throws FormProcessException { + s_log.debug("Processing upload..."); + PageState state = fse.getPageState(); + //File file = m_fileUploadSection.getFile(fse); + SciProject project = (SciProject) m_itemModel.getSelectedObject(state); + + String uploadContent = (String) m_fileUploadContent.get(state); + //boolean usedInso = (Boolean) m_fileUploadContentUsedInso.get(state); + + s_log.debug(String.format("Setting project description to: %s", + uploadContent)); + project.setProjectDescription(uploadContent); + s_log.debug("Saving project."); + project.save(); + } + + private void validateFileType(MimeType mime, boolean textType) + throws FormProcessException { + + boolean validType = textType || ((mime instanceof TextMimeType) && ((TextMimeType) mime). + allowINSOConvert().booleanValue()); + + if (!validType) { + throw new FormProcessException("Cannot load " + "files of type " + mime. + getMimeType() + " into the article body."); + } else { + boolean insoWorks = MimeTypeStatus.getMimeTypeStatus(). + getInsoFilterWorks().intValue() == 1; + + if (!textType && !insoWorks) { + // Can't convert. inso filter is not working. Give message. + throw new FormProcessException( + "Could not convert to html " + + "format because interMedia INSO filter is not installed."); + } + } + } + + /** + * read in the content of the file (in bytes). + */ + private byte[] readFileBytes(File file) throws FormProcessException { + byte[] file_bytes; + try { + FileInputStream fs = new FileInputStream(file); + file_bytes = new byte[fs.available()]; + fs.read(file_bytes); + fs.close(); + } catch (Exception e) { + throw new FormProcessException( + ((String) GlobalizationUtil.globalize( + "cms.ui.authoring.unable_to_load_file"). + localize()).concat(e.getMessage())); + } + return file_bytes; + } + + /** + * Convert bytes to String, possibly using INSO filter to convert to + * HTML type + */ + private String convertBytes(byte[] file_bytes, boolean text_type, + boolean[] used_inso) + throws FormProcessException { + String file_content; + // If mime type is not text type, try to convert to html + if (!text_type) { + file_content = ConvertFormat.toHTML(file_bytes); + if (file_content != null) { + // Converted successfully, flag type should be html + used_inso[0] = true; + } else { + throw new FormProcessException( + "Could not convert to html format. " + + "interMedia INSO filter conversion failed."); + } + } else { + // Text type, no need to convert + String enc = Globalization.getDefaultCharset(Kernel.getContext(). + getLocale()); + try { + file_content = new String(file_bytes, enc); + } catch (UnsupportedEncodingException ex) { + throw new UncheckedWrapperException("cannot convert to encoding " + + enc, ex); + } + used_inso[0] = false; + } + return file_content; + } + + /** + * Extract the contents of the html Body tag. + * (Done to prevent base and other header tags + * from interfering with page display). + */ + private String extractHTMLBody(String htmlText) + throws FormProcessException { + String lc = htmlText.toLowerCase(); + int bodyStart = lc.indexOf("", bodyStart); + int bodyEnd = lc.indexOf("", bodyStart_v); + if (bodyStart == -1 || bodyEnd == -1) { + final String errMsg = + "The file (which should be type " + + "HTML) is missing the or tag."; + throw new FormProcessException(errMsg); + } + return htmlText.substring(bodyStart_v + 1, bodyEnd); + } +} diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectFundingForm.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectFundingForm.java deleted file mode 100644 index de3c2d72d..000000000 --- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectFundingForm.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.arsdigita.cms.contenttypes.ui; - -import com.arsdigita.bebop.FormData; -import com.arsdigita.bebop.FormProcessException; -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.parameters.ParameterModel; -import com.arsdigita.bebop.parameters.StringParameter; -import com.arsdigita.cms.ItemSelectionModel; -import com.arsdigita.cms.contenttypes.SciProject; -import com.arsdigita.cms.ui.CMSDHTMLEditor; -import com.arsdigita.cms.ui.authoring.BasicItemForm; - -/** - * - * @author Jens Pelzetter - */ -public class SciProjectFundingForm - extends BasicItemForm - implements FormProcessListener, - FormInitListener { - - public SciProjectFundingForm(ItemSelectionModel itemModel) { - super("sciprojectEditFundingForm", itemModel); - } - - @Override - protected void addWidgets() { - ParameterModel fundingParam = new StringParameter( - SciProject.FUNDING); - CMSDHTMLEditor funding = new CMSDHTMLEditor(fundingParam); - funding.setCols(75); - funding.setRows(25); - add(funding); - } - - @Override - public void init(FormSectionEvent fse) throws FormProcessException { - PageState state = fse.getPageState(); - - FormData data = fse.getFormData(); - SciProject project = (SciProject) getItemSelectionModel(). - getSelectedObject(state); - - data.put(SciProject.FUNDING, project.getFunding()); - } - - @Override - public void process(FormSectionEvent fse) throws FormProcessException { - PageState state = fse.getPageState(); - - FormData data = fse.getFormData(); - SciProject project = (SciProject) getItemSelectionModel(). - getSelectedObject(state); - - if ((project != null) && this.getSaveCancelSection().getSaveButton(). - isSelected(state)) { - project.setFunding((String) data.get(SciProject.FUNDING)); - - project.save(); - - init(fse); - } - } -} diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectFundingStep.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectFundingStep.java deleted file mode 100644 index d8d35bff8..000000000 --- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectFundingStep.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.arsdigita.cms.contenttypes.ui; - -import com.arsdigita.bebop.Component; -import com.arsdigita.cms.ItemSelectionModel; -import com.arsdigita.cms.contenttypes.SciProject; -import com.arsdigita.cms.ui.authoring.AuthoringKitWizard; -import com.arsdigita.cms.ui.authoring.BasicItemForm; -import com.arsdigita.cms.ui.authoring.SimpleEditStep; -import com.arsdigita.cms.ui.workflow.WorkflowLockedComponentAccess; -import com.arsdigita.toolbox.ui.DomainObjectPropertySheet; - -/** - * - * @author Jens Pelzetter - */ -public class SciProjectFundingStep extends SimpleEditStep { - - private String EDIT_FUNDING_SHEET_NAME = "editFunding"; - - public SciProjectFundingStep(ItemSelectionModel itemModel, - AuthoringKitWizard parent) { - this(itemModel, parent, null); - } - - public SciProjectFundingStep(ItemSelectionModel itemModel, - AuthoringKitWizard parent, - String prefix) { - super(itemModel, parent, prefix); - - BasicItemForm editFundingForm = new SciProjectFundingForm(itemModel); - add(EDIT_FUNDING_SHEET_NAME, - (String) SciOrganizationGlobalizationUtil.globalize( - "sciorganization.ui.project.edit_funding").localize(), - new WorkflowLockedComponentAccess(editFundingForm, itemModel), - editFundingForm.getSaveCancelSection().getCancelButton()); - - setDisplayComponent( - getSciProjectFundingSheet(itemModel)); - } - - public static Component getSciProjectFundingSheet( - ItemSelectionModel itemModel) { - DomainObjectPropertySheet sheet = new DomainObjectPropertySheet( - itemModel); - - sheet.add(SciOrganizationGlobalizationUtil.globalize( - "sciorganization.ui.project.funding"), - SciProject.FUNDING); - - return sheet; - } -} diff --git a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectPropertyForm.java b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectPropertyForm.java index 9ac6aabeb..ff32ee811 100644 --- a/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectPropertyForm.java +++ b/ccm-sci-types-organization/src/com/arsdigita/cms/contenttypes/ui/SciProjectPropertyForm.java @@ -14,7 +14,6 @@ import com.arsdigita.bebop.parameters.ParameterModel; import com.arsdigita.bebop.parameters.StringParameter; import com.arsdigita.cms.ItemSelectionModel; import com.arsdigita.cms.contenttypes.SciProject; -import com.arsdigita.cms.ui.CMSDHTMLEditor; import java.util.Calendar; import java.util.GregorianCalendar; @@ -64,27 +63,9 @@ public class SciProjectPropertyForm ParameterModel shortDescParam = new StringParameter( SciProject.PROJECT_SHORT_DESCRIPTION); TextArea shortDesc = new TextArea(shortDescParam); - shortDesc.setCols(60); - shortDesc.setRows(20); - add(shortDesc); - - /*add(new Label(SciOrganizationGlobalizationUtil.globalize( - "sciorganization.ui.project.description"))); - ParameterModel descParam = new StringParameter( - SciProject.PROJECT_DESCRIPTION); - CMSDHTMLEditor desc = new CMSDHTMLEditor(descParam); - desc.setCols(75); - desc.setRows(25); - add(desc);*/ - - /*add(new Label(SciOrganizationGlobalizationUtil.globalize( - "sciorganization.ui.project.funding"))); - ParameterModel fundingParam = new StringParameter( - SciProject.FUNDING); - CMSDHTMLEditor funding = new CMSDHTMLEditor(fundingParam); - funding.setCols(60); - funding.setRows(18); - add(funding);*/ + shortDesc.setCols(75); + shortDesc.setRows(5); + add(shortDesc); } @Override