UI zum Hinzufügen von Organizatations, Departments und Superprojekten zu einem Projekt.
git-svn-id: https://svn.libreccm.org/ccm/trunk@566 8810af33-2d31-482b-a856-94f89814c4dfmaster
parent
e2081752e1
commit
3c82d87bcc
|
|
@ -33,5 +33,6 @@ association {
|
|||
join ct_sciorga_departments_projects_map.project_id
|
||||
to ct_sciorga_projects.project_id;
|
||||
|
||||
Integer[0..1] departmentOrder = ct_sciorga_departments_projects_map.departmentOrder INTEGER;
|
||||
Integer[0..1] projectOrder = ct_sciorga_departments_projects_map.projectorder INTEGER;
|
||||
}
|
||||
|
|
@ -21,6 +21,7 @@ association {
|
|||
to ct_sciorga_departments.department_id;
|
||||
|
||||
Integer[0..1] departmentOrder = ct_sciorga_organizations_departments_map.department_order INTEGER;
|
||||
Integer[0..1] organizationOrder = ct_sciorga_organizations_departments_map.organization_order INTEGER;
|
||||
}
|
||||
|
||||
association {
|
||||
|
|
@ -35,6 +36,7 @@ association {
|
|||
to ct_sciorga_projects.project_id;
|
||||
|
||||
Integer[0..1] projectOrder = ct_sciorga_organizations_projects_map.project_order INTEGER;
|
||||
Integer[0..1] organizationOrder = ct_sciorga_organizations_projects_map.organization_order INTEGER;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -7,15 +7,15 @@ object type SciProject extends GenericOrganizationalUnit {
|
|||
|
||||
Date[0..1] projectbegin = ct_sciorga_projects.projectbegin DATE;
|
||||
Date[0..1] projectend = ct_sciorga_projects.projectend DATE;
|
||||
String[0..1] projectShortDesc = ct_sciorga_projects.shortdesc VARCHAR(2048);
|
||||
String[0..1] projectShortDesc = ct_sciorga_projects.shortdesc VARCHAR(500);
|
||||
String[0..1] projectDescription = ct_sciorga_projects.description CLOB;
|
||||
String[0..1] funding = ct_sciorga_projects.funding VARCHAR(2048);
|
||||
String[0..1] funding = ct_sciorga_projects.funding CLOB;
|
||||
|
||||
reference key ( ct_sciorga_projects.project_id );
|
||||
}
|
||||
|
||||
association {
|
||||
SciProject[0..n] project = join ct_sciorga_projects.project_id
|
||||
SciProject[0..n] superProject = join ct_sciorga_projects.project_id
|
||||
to ct_sciorga_projects_subprojects_map.subproject_id,
|
||||
join ct_sciorga_projects_subprojects_map.project_id
|
||||
to ct_sciorga_projects.project_id;
|
||||
|
|
|
|||
|
|
@ -40,6 +40,11 @@ public class SciProject extends GenericOrganizationalUnit {
|
|||
public static final String FUNDING = "funding";
|
||||
public static final String SUBPROJECTS = "subProjects";
|
||||
public static final String SUBPROJECT_ORDER = "subProjectOrder";
|
||||
public static final String ORGANIZATIONS = "organization";
|
||||
public static final String ORGANIZATIONS_ORDER = "organization";
|
||||
public static final String SUPER_PROJECT = "superProject";
|
||||
public static final String DEPARTMENTS = "department";
|
||||
public static final String DEPARTMENTS_ORDER = "department";
|
||||
public static final String BASE_DATA_OBJECT_TYPE =
|
||||
"com.arsdigita.cms.contenttypes.SciProject";
|
||||
|
||||
|
|
@ -109,7 +114,7 @@ public class SciProject extends GenericOrganizationalUnit {
|
|||
}
|
||||
|
||||
public void addSubProject(SciProject project) {
|
||||
Assert.exists((project), SciProject.class);
|
||||
Assert.exists(project, SciProject.class);
|
||||
|
||||
DataObject link = add(SUBPROJECTS, project);
|
||||
|
||||
|
|
@ -118,12 +123,89 @@ public class SciProject extends GenericOrganizationalUnit {
|
|||
}
|
||||
|
||||
public void removeSubProject(SciProject project) {
|
||||
Assert.exists((project), SciProject.class);
|
||||
Assert.exists(project, SciProject.class);
|
||||
|
||||
remove(SUBPROJECTS, project);
|
||||
}
|
||||
|
||||
public boolean hasSubProjects() {
|
||||
return !this.getSearchSummary().isEmpty();
|
||||
return !this.getSubProjects().isEmpty();
|
||||
}
|
||||
|
||||
public SciProjectOrganizationsCollection getOrganizations() {
|
||||
return new SciProjectOrganizationsCollection((DataCollection) get(
|
||||
ORGANIZATIONS));
|
||||
}
|
||||
|
||||
public void addOrganization(SciOrganization orga) {
|
||||
Assert.exists(orga, SciOrganization.class);
|
||||
|
||||
DataObject link = add(ORGANIZATIONS, orga);
|
||||
|
||||
link.set(ORGANIZATIONS_ORDER,
|
||||
Integer.valueOf((int) getOrganizations().size()));
|
||||
}
|
||||
|
||||
public void removeOrganization(SciOrganization orga) {
|
||||
Assert.exists(orga, SciOrganization.class);
|
||||
|
||||
remove(ORGANIZATIONS, orga);
|
||||
}
|
||||
|
||||
public boolean hasOrganizations() {
|
||||
return !this.getOrganizations().isEmpty();
|
||||
}
|
||||
|
||||
public SciProjectDepartmentsCollection getDepartments() {
|
||||
return new SciProjectDepartmentsCollection((DataCollection) get(
|
||||
DEPARTMENTS));
|
||||
}
|
||||
|
||||
public void addDepartment(SciDepartment department) {
|
||||
Assert.exists(department, SciDepartment.class);
|
||||
|
||||
DataObject link = add(DEPARTMENTS, department);
|
||||
|
||||
link.set(DEPARTMENTS_ORDER,
|
||||
Integer.valueOf((int) getDepartments().size()));
|
||||
}
|
||||
|
||||
public void removeDepartment(SciDepartment department) {
|
||||
Assert.exists(department, SciDepartment.class);
|
||||
|
||||
remove(DEPARTMENTS, department);
|
||||
}
|
||||
|
||||
public boolean hasDepartments() {
|
||||
return !this.getDepartments().isEmpty();
|
||||
}
|
||||
|
||||
public SciProject getSuperProject() {
|
||||
DataCollection collection;
|
||||
|
||||
collection = (DataCollection) get(SUPER_PROJECT);
|
||||
|
||||
if (0 == collection.size()) {
|
||||
return null;
|
||||
} else {
|
||||
DataObject dobj;
|
||||
|
||||
collection.next();
|
||||
dobj = collection.getDataObject();
|
||||
|
||||
return new SciProject(dobj);
|
||||
}
|
||||
}
|
||||
|
||||
public void setSuperProject(SciProject superProject) {
|
||||
SciProject oldSuperProject;
|
||||
|
||||
oldSuperProject = getSuperProject();
|
||||
remove(SUPER_PROJECT, oldSuperProject);
|
||||
|
||||
if (null != superProject) {
|
||||
Assert.exists(superProject, SciProject.class);
|
||||
add(SUPER_PROJECT, superProject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,153 @@
|
|||
/*
|
||||
* Copyright (c) 2010 Jens Pelzetter,
|
||||
* for the Center of Social Politics of the University of Bremen
|
||||
*
|
||||
* 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.persistence.DataCollection;
|
||||
import com.arsdigita.persistence.DataObject;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
*/
|
||||
public class SciProjectDepartmentsCollection extends DomainCollection {
|
||||
|
||||
public String ORDER = "departmentOrder";
|
||||
public String LINKORDER = "link.departmentOrder";
|
||||
public static final Logger s_log = Logger.getLogger(
|
||||
SciProjectDepartmentsCollection.class);
|
||||
|
||||
public SciProjectDepartmentsCollection(DataCollection dataCollection) {
|
||||
super(dataCollection);
|
||||
|
||||
m_dataCollection.addOrder(LINKORDER);
|
||||
}
|
||||
|
||||
public Integer getDepartmentOrder() {
|
||||
return (Integer) m_dataCollection.get(LINKORDER);
|
||||
}
|
||||
|
||||
public void setDepartmentOrder(Integer order) {
|
||||
DataObject link = (DataObject) this.get("link");
|
||||
|
||||
link.set(ORDER, order);
|
||||
}
|
||||
|
||||
public void swapWithNext(SciDepartment department) {
|
||||
int currentPosition = 0;
|
||||
int currentIndex = 0;
|
||||
int nextIndex = 0;
|
||||
|
||||
s_log.debug("Searching department...");
|
||||
this.rewind();
|
||||
while (this.next()) {
|
||||
currentPosition = this.getPosition();
|
||||
currentIndex = this.getDepartmentOrder();
|
||||
s_log.debug(String.format("Position: %d(%d)/%d", currentPosition,
|
||||
currentIndex, this.size()));
|
||||
s_log.debug(String.format("getDepartmentOrder(): %d",
|
||||
getDepartmentOrder()));
|
||||
if (this.getDepartment().equals(department)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentPosition == 0) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format(
|
||||
"The provided subproject is not "
|
||||
+ "part of this collection."));
|
||||
}
|
||||
|
||||
if (this.next()) {
|
||||
nextIndex = this.getDepartmentOrder();
|
||||
} else {
|
||||
throw new IllegalArgumentException(
|
||||
"The provided subproject is the last "
|
||||
+ "in the collection, so there is no next object "
|
||||
+ "to swap with.");
|
||||
}
|
||||
|
||||
this.rewind();
|
||||
|
||||
while (this.getPosition() != currentPosition) {
|
||||
this.next();
|
||||
}
|
||||
|
||||
this.setDepartmentOrder(nextIndex);
|
||||
this.next();
|
||||
this.setDepartmentOrder(currentIndex);
|
||||
this.rewind();
|
||||
}
|
||||
|
||||
public void swapWithPrevious(SciDepartment department) {
|
||||
int previousPosition = 0;
|
||||
int previousIndex = 0;
|
||||
int currentPosition = 0;
|
||||
int currentIndex = 0;
|
||||
|
||||
s_log.debug("Searching organization...");
|
||||
this.rewind();
|
||||
while (this.next()) {
|
||||
currentPosition = this.getPosition();
|
||||
currentIndex = this.getDepartmentOrder();
|
||||
s_log.debug(String.format("Position: %d(%d)/%d", currentPosition,
|
||||
currentIndex, this.size()));
|
||||
s_log.debug(String.format("getDepartmentOrder(): %d",
|
||||
getDepartmentOrder()));
|
||||
if (this.getDepartment().equals(department)) {
|
||||
break;
|
||||
}
|
||||
|
||||
previousPosition = currentPosition;
|
||||
previousIndex = currentIndex;
|
||||
}
|
||||
|
||||
if (currentPosition == 0) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format(
|
||||
"The provided organization is not "
|
||||
+ "part of this collection."));
|
||||
}
|
||||
|
||||
if (previousPosition == 0) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format(
|
||||
"The provided organization is the first one in this "
|
||||
+ "collection, so there is no previous one to switch "
|
||||
+ "with."));
|
||||
}
|
||||
|
||||
this.rewind();
|
||||
while (this.getPosition() != previousPosition) {
|
||||
this.next();
|
||||
}
|
||||
|
||||
this.setDepartmentOrder(currentIndex);
|
||||
this.next();
|
||||
this.setDepartmentOrder(previousIndex);
|
||||
this.rewind();
|
||||
}
|
||||
|
||||
public SciDepartment getDepartment() {
|
||||
return new SciDepartment(m_dataCollection.getDataObject());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,155 @@
|
|||
/*
|
||||
* Copyright (c) 2010 Jens Pelzetter,
|
||||
* for the Center of Social Politics of the University of Bremen
|
||||
*
|
||||
* 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.persistence.DataCollection;
|
||||
import com.arsdigita.persistence.DataObject;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
*/
|
||||
public class SciProjectOrganizationsCollection extends DomainCollection {
|
||||
|
||||
public String ORDER = "organizationOrder";
|
||||
public String LINKORDER = "link.organizationOrder";
|
||||
private static final Logger s_log =
|
||||
Logger.getLogger(
|
||||
SciProjectSubProjectsCollection.class);
|
||||
|
||||
public SciProjectOrganizationsCollection(DataCollection dataCollection) {
|
||||
super(dataCollection);
|
||||
|
||||
m_dataCollection.addOrder(LINKORDER);
|
||||
}
|
||||
|
||||
public Integer getOrganizationOrder() {
|
||||
return (Integer) m_dataCollection.get(LINKORDER);
|
||||
}
|
||||
|
||||
public void setOrganizationOrder(Integer order) {
|
||||
DataObject link = (DataObject) this.get("link");
|
||||
|
||||
link.set(ORDER, order);
|
||||
}
|
||||
|
||||
public void swapWithNext(SciOrganization orga) {
|
||||
int currentPosition = 0;
|
||||
int currentIndex = 0;
|
||||
int nextIndex = 0;
|
||||
|
||||
s_log.debug("Searching organization...");
|
||||
this.rewind();
|
||||
while (this.next()) {
|
||||
currentPosition = this.getPosition();
|
||||
currentIndex = this.getOrganizationOrder();
|
||||
s_log.debug(String.format("Position: %d(%d)/%d", currentPosition,
|
||||
currentIndex, this.size()));
|
||||
s_log.debug(String.format("getOrganizationOrder(): %d",
|
||||
getOrganizationOrder()));
|
||||
if (this.getOrganization().equals(orga)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (currentPosition == 0) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format(
|
||||
"The provided subproject is not "
|
||||
+ "part of this collection."));
|
||||
}
|
||||
|
||||
if (this.next()) {
|
||||
nextIndex = this.getOrganizationOrder();
|
||||
} else {
|
||||
throw new IllegalArgumentException(
|
||||
"The provided subproject is the last "
|
||||
+ "in the collection, so there is no next object "
|
||||
+ "to swap with.");
|
||||
}
|
||||
|
||||
this.rewind();
|
||||
|
||||
while (this.getPosition() != currentPosition) {
|
||||
this.next();
|
||||
}
|
||||
|
||||
this.setOrganizationOrder(nextIndex);
|
||||
this.next();
|
||||
this.setOrganizationOrder(currentIndex);
|
||||
this.rewind();
|
||||
}
|
||||
|
||||
public void swapWithPrevious(SciOrganization orga) {
|
||||
int previousPosition = 0;
|
||||
int previousIndex = 0;
|
||||
int currentPosition = 0;
|
||||
int currentIndex = 0;
|
||||
|
||||
s_log.debug("Searching organization...");
|
||||
this.rewind();
|
||||
while (this.next()) {
|
||||
currentPosition = this.getPosition();
|
||||
currentIndex = this.getOrganizationOrder();
|
||||
s_log.debug(String.format("Position: %d(%d)/%d", currentPosition,
|
||||
currentIndex, this.size()));
|
||||
s_log.debug(String.format("getOrganizationOrder(): %d",
|
||||
getOrganizationOrder()));
|
||||
if (this.getOrganization().equals(orga)) {
|
||||
break;
|
||||
}
|
||||
|
||||
previousPosition = currentPosition;
|
||||
previousIndex = currentIndex;
|
||||
}
|
||||
|
||||
if (currentPosition == 0) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format(
|
||||
"The provided organization is not "
|
||||
+ "part of this collection."));
|
||||
}
|
||||
|
||||
if (previousPosition == 0) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format(
|
||||
"The provided organization is the first one in this "
|
||||
+ "collection, so there is no previous one to switch "
|
||||
+ "with."));
|
||||
}
|
||||
|
||||
this.rewind();
|
||||
while (this.getPosition() != previousPosition) {
|
||||
this.next();
|
||||
}
|
||||
|
||||
this.setOrganizationOrder(currentIndex);
|
||||
this.next();
|
||||
this.setOrganizationOrder(previousIndex);
|
||||
this.rewind();
|
||||
}
|
||||
|
||||
public SciOrganization getOrganization() {
|
||||
return new SciOrganization(m_dataCollection.getDataObject());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
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.cms.ContentType;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.contenttypes.SciDepartment;
|
||||
import com.arsdigita.cms.contenttypes.SciProject;
|
||||
import com.arsdigita.cms.ui.ItemSearchWidget;
|
||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
*/
|
||||
public class SciProjectDepartmentAddForm
|
||||
extends BasicItemForm
|
||||
implements FormProcessListener,
|
||||
FormInitListener {
|
||||
|
||||
private ItemSearchWidget m_itemSearch;
|
||||
private final String ITEM_SEARCH = "projectDepartment";
|
||||
|
||||
public SciProjectDepartmentAddForm(ItemSelectionModel itemModel) {
|
||||
super("projectDepartmentAddForm", itemModel);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addWidgets() {
|
||||
add(new Label(SciOrganizationGlobalizationUtil.globalize(
|
||||
"sciorganization.ui.project.select_department")));
|
||||
m_itemSearch = new ItemSearchWidget(
|
||||
ITEM_SEARCH,
|
||||
ContentType.findByAssociatedObjectType(
|
||||
SciDepartment.class.getName()));
|
||||
add(m_itemSearch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FormSectionEvent fse) throws FormProcessException {
|
||||
PageState state = fse.getPageState();
|
||||
|
||||
setVisible(state, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(FormSectionEvent fse) throws FormProcessException {
|
||||
FormData data = fse.getFormData();
|
||||
PageState state = fse.getPageState();
|
||||
SciProject project = (SciProject) getItemSelectionModel().
|
||||
getSelectedObject(state);
|
||||
|
||||
if (!(this.getSaveCancelSection().getCancelButton().
|
||||
isSelected(state))) {
|
||||
project.addDepartment((SciDepartment) data.get(ITEM_SEARCH));
|
||||
|
||||
init(fse);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package com.arsdigita.cms.contenttypes.ui;
|
||||
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
*/
|
||||
public class SciProjectDepartmentsStep extends SimpleEditStep {
|
||||
|
||||
private String PROJECT_ADD_DEPARTMENT_SHEET_NAME = "projectAddDepartment";
|
||||
|
||||
public SciProjectDepartmentsStep(ItemSelectionModel itemModel,
|
||||
AuthoringKitWizard parent) {
|
||||
this(itemModel, parent, null);
|
||||
}
|
||||
|
||||
public SciProjectDepartmentsStep(ItemSelectionModel itemModel,
|
||||
AuthoringKitWizard parent,
|
||||
String prefix) {
|
||||
super(itemModel, parent, prefix);
|
||||
|
||||
BasicItemForm addDepartmentForm =
|
||||
new SciProjectDepartmentAddForm(itemModel);
|
||||
add(PROJECT_ADD_DEPARTMENT_SHEET_NAME,
|
||||
(String) SciOrganizationGlobalizationUtil.globalize(
|
||||
"sciorganization.ui.project.addDepartment").localize(),
|
||||
new WorkflowLockedComponentAccess(addDepartmentForm, itemModel),
|
||||
addDepartmentForm.getSaveCancelSection().getCancelButton());
|
||||
|
||||
setDisplayComponent(new SciProjectDepartmentsTable(itemModel));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,302 @@
|
|||
package com.arsdigita.cms.contenttypes.ui;
|
||||
|
||||
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.ItemSelectionModel;
|
||||
import com.arsdigita.cms.SecurityManager;
|
||||
import com.arsdigita.cms.contenttypes.SciDepartment;
|
||||
import com.arsdigita.cms.contenttypes.SciProject;
|
||||
import com.arsdigita.cms.contenttypes.SciProjectDepartmentsCollection;
|
||||
import com.arsdigita.cms.dispatcher.Utilities;
|
||||
import com.arsdigita.util.LockableImpl;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
*/
|
||||
public class SciProjectDepartmentsTable
|
||||
extends Table
|
||||
implements TableActionListener {
|
||||
|
||||
private final String TABLE_COL_EDIT = "table_col_edit";
|
||||
private final String TABLE_COL_DEL = "table_col_del";
|
||||
private final String TABLE_COL_UP = "table_col_up";
|
||||
private final String TABLE_COL_DOWN = "table_col_down";
|
||||
private ItemSelectionModel m_itemModel;
|
||||
|
||||
public SciProjectDepartmentsTable(ItemSelectionModel itemModel) {
|
||||
super();
|
||||
m_itemModel = itemModel;
|
||||
|
||||
setEmptyView(
|
||||
new Label(SciOrganizationGlobalizationUtil.globalize(
|
||||
"sciorganization.ui.project.departments.none")));
|
||||
|
||||
TableColumnModel colModel = getColumnModel();
|
||||
colModel.add(new TableColumn(
|
||||
0,
|
||||
SciOrganizationGlobalizationUtil.globalize(
|
||||
"sciorganization.ui.project.department").localize(),
|
||||
TABLE_COL_EDIT));
|
||||
colModel.add(new TableColumn(
|
||||
1,
|
||||
SciOrganizationGlobalizationUtil.globalize(
|
||||
"sciorganization.ui.project.department.remove").localize(),
|
||||
TABLE_COL_DEL));
|
||||
colModel.add(new TableColumn(
|
||||
2,
|
||||
SciOrganizationGlobalizationUtil.globalize(
|
||||
"sciorganization.ui.project.department.up").localize(),
|
||||
TABLE_COL_UP));
|
||||
colModel.add(new TableColumn(
|
||||
3,
|
||||
SciOrganizationGlobalizationUtil.globalize(
|
||||
"sciorganization.ui.project.department.down").localize(),
|
||||
TABLE_COL_DOWN));
|
||||
|
||||
setModelBuilder(
|
||||
new SciProjectDepartmentsTableModelBuilder(itemModel));
|
||||
colModel.get(0).setCellRenderer(new EditCellRenderer());
|
||||
colModel.get(1).setCellRenderer(new DeleteCellRenderer());
|
||||
colModel.get(2).setCellRenderer(new UpCellRenderer());
|
||||
colModel.get(3).setCellRenderer(new DownCellRenderer());
|
||||
|
||||
addTableActionListener(this);
|
||||
}
|
||||
|
||||
private class SciProjectDepartmentsTableModelBuilder
|
||||
extends LockableImpl
|
||||
implements TableModelBuilder {
|
||||
|
||||
public SciProjectDepartmentsTableModelBuilder(
|
||||
ItemSelectionModel itemModel) {
|
||||
m_itemModel = itemModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableModel makeModel(Table table, PageState state) {
|
||||
table.getRowSelectionModel().clearSelection(state);
|
||||
SciProject project = (SciProject) m_itemModel.getSelectedObject(
|
||||
state);
|
||||
return new SciProjectDepartmentsTableModel(table,
|
||||
state,
|
||||
project);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private class SciProjectDepartmentsTableModel
|
||||
implements TableModel {
|
||||
|
||||
private Table m_table;
|
||||
private SciProjectDepartmentsCollection m_departments;
|
||||
private SciDepartment m_department;
|
||||
|
||||
public SciProjectDepartmentsTableModel(Table table,
|
||||
PageState state,
|
||||
SciProject project) {
|
||||
m_table = table;
|
||||
m_departments = project.getDepartments();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return m_table.getColumnModel().size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean nextRow() {
|
||||
boolean ret;
|
||||
|
||||
if ((m_departments != null) && m_departments.next()) {
|
||||
m_department = m_departments.getDepartment();
|
||||
ret = true;
|
||||
} else {
|
||||
ret = false;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getElementAt(int columnIndex) {
|
||||
switch (columnIndex) {
|
||||
case 0:
|
||||
return m_department.getTitle();
|
||||
case 1:
|
||||
return SciOrganizationGlobalizationUtil.globalize(
|
||||
"sciorganization.ui.project.department.remove").
|
||||
localize();
|
||||
case 2:
|
||||
return SciOrganizationGlobalizationUtil.globalize(
|
||||
"sciorganization.ui.project.department.up").
|
||||
localize();
|
||||
case 3:
|
||||
return SciOrganizationGlobalizationUtil.globalize(
|
||||
"sciorganization.ui.project.department.down").
|
||||
localize();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getKeyAt(int columnIndex) {
|
||||
return m_department.getID();
|
||||
}
|
||||
}
|
||||
|
||||
private class EditCellRenderer
|
||||
extends LockableImpl
|
||||
implements TableCellRenderer {
|
||||
|
||||
@Override
|
||||
public Component getComponent(Table table,
|
||||
PageState state,
|
||||
Object value,
|
||||
boolean isSelected,
|
||||
Object key,
|
||||
int row,
|
||||
int column) {
|
||||
Label label = new Label(value.toString());
|
||||
return label;
|
||||
}
|
||||
}
|
||||
|
||||
private class DeleteCellRenderer
|
||||
extends LockableImpl
|
||||
implements TableCellRenderer {
|
||||
|
||||
@Override
|
||||
public Component getComponent(Table table,
|
||||
PageState state,
|
||||
Object value,
|
||||
boolean isSelected,
|
||||
Object key,
|
||||
int row,
|
||||
int col) {
|
||||
SecurityManager securityManager =
|
||||
Utilities.getSecurityManager(state);
|
||||
SciProject project = (SciProject) m_itemModel.getSelectedObject(
|
||||
state);
|
||||
|
||||
boolean canEdit = securityManager.canAccess(
|
||||
state.getRequest(),
|
||||
SecurityManager.DELETE_ITEM,
|
||||
project);
|
||||
|
||||
if (canEdit) {
|
||||
ControlLink link = new ControlLink(value.toString());
|
||||
link.setConfirmation((String) SciOrganizationGlobalizationUtil.
|
||||
globalize(
|
||||
"sciorganization.ui.project.organization."
|
||||
+ ".confirm_remove").
|
||||
localize());
|
||||
return link;
|
||||
} else {
|
||||
Label label = new Label(value.toString());
|
||||
return label;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class UpCellRenderer
|
||||
extends LockableImpl
|
||||
implements TableCellRenderer {
|
||||
|
||||
@Override
|
||||
public Component getComponent(
|
||||
Table table,
|
||||
PageState state,
|
||||
Object value,
|
||||
boolean isSelected,
|
||||
Object key,
|
||||
int row,
|
||||
int col) {
|
||||
|
||||
if (0 == row) {
|
||||
Label label = new Label("");
|
||||
return label;
|
||||
} else {
|
||||
ControlLink link = new ControlLink(
|
||||
(String) SciOrganizationGlobalizationUtil.globalize(
|
||||
"sciorganization.ui.project.department.up").
|
||||
localize());
|
||||
return link;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class DownCellRenderer
|
||||
extends LockableImpl
|
||||
implements TableCellRenderer {
|
||||
|
||||
@Override
|
||||
public Component getComponent(
|
||||
Table table,
|
||||
PageState state,
|
||||
Object value,
|
||||
boolean isSelected,
|
||||
Object key,
|
||||
int row,
|
||||
int col) {
|
||||
|
||||
SciProject project = (SciProject) m_itemModel.getSelectedObject(
|
||||
state);
|
||||
SciProjectDepartmentsCollection departments =
|
||||
project.getDepartments();
|
||||
|
||||
if ((departments.size() - 1) == row) {
|
||||
Label label = new Label("");
|
||||
return label;
|
||||
} else {
|
||||
ControlLink link = new ControlLink(
|
||||
(String) SciOrganizationGlobalizationUtil.globalize(
|
||||
"sciorganization.ui.project.department.down").
|
||||
localize());
|
||||
return link;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cellSelected(TableActionEvent event) {
|
||||
PageState state = event.getPageState();
|
||||
|
||||
SciDepartment department = new SciDepartment(
|
||||
new BigDecimal(event.getRowKey().toString()));
|
||||
|
||||
SciProject project =
|
||||
(SciProject) m_itemModel.getSelectedObject(state);
|
||||
|
||||
SciProjectDepartmentsCollection departments =
|
||||
project.getDepartments();
|
||||
|
||||
TableColumn column = getColumnModel().get(event.getColumn().intValue());
|
||||
|
||||
if (column.getHeaderKey().toString().equals(TABLE_COL_EDIT)) {
|
||||
} else if (column.getHeaderKey().toString().equals(TABLE_COL_DEL)) {
|
||||
project.removeDepartment(department);
|
||||
} else if (column.getHeaderKey().toString().equals(TABLE_COL_UP)) {
|
||||
departments.swapWithPrevious(department);
|
||||
} else if (column.getHeaderKey().toString().equals(TABLE_COL_DOWN)) {
|
||||
departments.swapWithNext(department);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void headSelected(TableActionEvent event) {
|
||||
//Nothing to do.
|
||||
}
|
||||
}
|
||||
|
|
@ -25,7 +25,7 @@ public class SciProjectFundingStep extends SimpleEditStep {
|
|||
public SciProjectFundingStep(ItemSelectionModel itemModel,
|
||||
AuthoringKitWizard parent,
|
||||
String prefix) {
|
||||
super(itemModel, parent, null);
|
||||
super(itemModel, parent, prefix);
|
||||
|
||||
BasicItemForm editFundingForm = new SciProjectFundingForm(itemModel);
|
||||
add(EDIT_FUNDING_SHEET_NAME,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,65 @@
|
|||
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.cms.ContentType;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.contenttypes.SciOrganization;
|
||||
import com.arsdigita.cms.contenttypes.SciProject;
|
||||
import com.arsdigita.cms.ui.ItemSearchWidget;
|
||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
*/
|
||||
public class SciProjectOrganizationsAddForm
|
||||
extends BasicItemForm
|
||||
implements FormProcessListener,
|
||||
FormInitListener {
|
||||
|
||||
private ItemSearchWidget m_itemSearch;
|
||||
private final String ITEM_SEARCH = "projectOrga";
|
||||
|
||||
public SciProjectOrganizationsAddForm(ItemSelectionModel itemModel) {
|
||||
super("projectOrgaAddForm", itemModel);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addWidgets() {
|
||||
add(new Label(SciOrganizationGlobalizationUtil.globalize(
|
||||
"sciorganization.ui.project.select_organization")));
|
||||
m_itemSearch = new ItemSearchWidget(
|
||||
ITEM_SEARCH,
|
||||
ContentType.findByAssociatedObjectType(
|
||||
SciOrganization.class.getName()));
|
||||
add(m_itemSearch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FormSectionEvent fse) throws FormProcessException {
|
||||
PageState state = fse.getPageState();
|
||||
|
||||
setVisible(state, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(FormSectionEvent fse) throws FormProcessException {
|
||||
FormData data = fse.getFormData();
|
||||
PageState state = fse.getPageState();
|
||||
SciProject project = (SciProject) getItemSelectionModel().
|
||||
getSelectedObject(state);
|
||||
|
||||
if (!(this.getSaveCancelSection().getCancelButton().
|
||||
isSelected(state))) {
|
||||
project.addOrganization((SciOrganization) data.get(ITEM_SEARCH));
|
||||
|
||||
init(fse);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
package com.arsdigita.cms.contenttypes.ui;
|
||||
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
*/
|
||||
public class SciProjectOrganizationsStep extends SimpleEditStep {
|
||||
|
||||
private String PROJECT_ADD_ORGA_SHEET_NAME = "projectAddOrga";
|
||||
|
||||
public SciProjectOrganizationsStep(ItemSelectionModel itemModel,
|
||||
AuthoringKitWizard parent) {
|
||||
this(itemModel, parent, null);
|
||||
}
|
||||
|
||||
public SciProjectOrganizationsStep(ItemSelectionModel itemModel,
|
||||
AuthoringKitWizard parent,
|
||||
String prefix) {
|
||||
super(itemModel, parent, prefix);
|
||||
|
||||
BasicItemForm addOrgaForm =
|
||||
new SciProjectOrganizationsAddForm(itemModel);
|
||||
add(PROJECT_ADD_ORGA_SHEET_NAME,
|
||||
(String) SciOrganizationGlobalizationUtil.globalize(
|
||||
"sciorganization.ui.project.addOrga").localize(),
|
||||
new WorkflowLockedComponentAccess(addOrgaForm, itemModel),
|
||||
addOrgaForm.getSaveCancelSection().getCancelButton());
|
||||
|
||||
setDisplayComponent(
|
||||
new SciProjectOrganizationsTable(itemModel));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,321 @@
|
|||
package com.arsdigita.cms.contenttypes.ui;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
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.ItemSelectionModel;
|
||||
import com.arsdigita.cms.SecurityManager;
|
||||
import com.arsdigita.cms.contenttypes.SciOrganization;
|
||||
import com.arsdigita.cms.contenttypes.SciProject;
|
||||
import com.arsdigita.cms.contenttypes.SciProjectOrganizationsCollection;
|
||||
import com.arsdigita.cms.contenttypes.SciProjectSubProjectsCollection;
|
||||
import com.arsdigita.cms.dispatcher.Utilities;
|
||||
import com.arsdigita.util.LockableImpl;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
*/
|
||||
public class SciProjectOrganizationsTable
|
||||
extends Table
|
||||
implements TableActionListener {
|
||||
|
||||
private final String TABLE_COL_EDIT = "table_col_edit";
|
||||
private final String TABLE_COL_DEL = "table_col_del";
|
||||
private final String TABLE_COL_UP = "table_col_up";
|
||||
private final String TABLE_COL_DOWN = "table_col_down";
|
||||
private ItemSelectionModel m_itemModel;
|
||||
|
||||
public SciProjectOrganizationsTable(ItemSelectionModel itemModel) {
|
||||
super();
|
||||
m_itemModel = itemModel;
|
||||
|
||||
setEmptyView(
|
||||
new Label(SciOrganizationGlobalizationUtil.globalize(
|
||||
"sciorganization.ui.project.organization.none")));
|
||||
TableColumnModel colModel = getColumnModel();
|
||||
colModel.add(new TableColumn(
|
||||
0,
|
||||
SciOrganizationGlobalizationUtil.globalize(
|
||||
"sciorganization.ui.project.organization").localize(),
|
||||
TABLE_COL_EDIT));
|
||||
colModel.add(new TableColumn(
|
||||
1,
|
||||
SciOrganizationGlobalizationUtil.globalize(
|
||||
"sciorganization.ui.project.organization.remove").localize(),
|
||||
TABLE_COL_DEL));
|
||||
colModel.add(new TableColumn(
|
||||
2,
|
||||
SciOrganizationGlobalizationUtil.globalize(
|
||||
"sciorganization.ui.project.organization.up").localize(),
|
||||
TABLE_COL_UP));
|
||||
colModel.add(new TableColumn(
|
||||
3,
|
||||
SciOrganizationGlobalizationUtil.globalize(
|
||||
"sciorganization.ui.project.organization.down").localize(),
|
||||
TABLE_COL_DOWN));
|
||||
|
||||
|
||||
setModelBuilder(
|
||||
new SciProjectOrganizationsTableModelBuilder(itemModel));
|
||||
|
||||
colModel.get(0).setCellRenderer(new EditCellRenderer());
|
||||
colModel.get(1).setCellRenderer(new DeleteCellRenderer());
|
||||
colModel.get(2).setCellRenderer(new UpCellRenderer());
|
||||
colModel.get(3).setCellRenderer(new DownCellRenderer());
|
||||
|
||||
addTableActionListener(this);
|
||||
}
|
||||
|
||||
private class SciProjectOrganizationsTableModelBuilder
|
||||
extends LockableImpl
|
||||
implements TableModelBuilder {
|
||||
|
||||
private ItemSelectionModel m_itemModel;
|
||||
|
||||
public SciProjectOrganizationsTableModelBuilder(
|
||||
ItemSelectionModel itemModel) {
|
||||
m_itemModel = itemModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableModel makeModel(Table table, PageState state) {
|
||||
table.getRowSelectionModel().clearSelection(state);
|
||||
SciProject project = (SciProject) m_itemModel.getSelectedObject(
|
||||
state);
|
||||
return new SciProjectOrganizationsTableModel(table,
|
||||
state,
|
||||
project);
|
||||
}
|
||||
}
|
||||
|
||||
private class SciProjectOrganizationsTableModel
|
||||
implements TableModel {
|
||||
|
||||
private Table m_table;
|
||||
private SciProjectOrganizationsCollection m_organizations;
|
||||
private SciOrganization m_organization;
|
||||
|
||||
public SciProjectOrganizationsTableModel(Table table,
|
||||
PageState state,
|
||||
SciProject project) {
|
||||
m_table = table;
|
||||
m_organizations = project.getOrganizations();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColumnCount() {
|
||||
return m_table.getColumnModel().size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean nextRow() {
|
||||
boolean ret;
|
||||
|
||||
if ((m_organizations != null) && m_organizations.next()) {
|
||||
m_organization = m_organizations.getOrganization();
|
||||
ret = true;
|
||||
} else {
|
||||
ret = false;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getElementAt(int columnIndex) {
|
||||
switch (columnIndex) {
|
||||
case 0:
|
||||
return m_organization.getTitle();
|
||||
case 1:
|
||||
return SciOrganizationGlobalizationUtil.globalize(
|
||||
"sciorganization.ui.project.organization.remove").
|
||||
localize();
|
||||
case 2:
|
||||
return SciOrganizationGlobalizationUtil.globalize(
|
||||
"sciorganization.ui.project.organization.up").
|
||||
localize();
|
||||
case 3:
|
||||
return SciOrganizationGlobalizationUtil.globalize(
|
||||
"sciorganization.ui.project.organization.down").
|
||||
localize();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getKeyAt(int columnIndex) {
|
||||
return m_organization.getID();
|
||||
}
|
||||
}
|
||||
|
||||
private class EditCellRenderer
|
||||
extends LockableImpl
|
||||
implements TableCellRenderer {
|
||||
|
||||
@Override
|
||||
public Component getComponent(Table table,
|
||||
PageState state,
|
||||
Object value,
|
||||
boolean isSelected,
|
||||
Object key,
|
||||
int row,
|
||||
int col) {
|
||||
SecurityManager securityManager =
|
||||
Utilities.getSecurityManager(state);
|
||||
SciProject project = (SciProject) m_itemModel.getSelectedObject(
|
||||
state);
|
||||
|
||||
boolean canEdit = securityManager.canAccess(
|
||||
state.getRequest(),
|
||||
SecurityManager.EDIT_ITEM,
|
||||
project);
|
||||
|
||||
/*if (canEdit) {
|
||||
ControlLink link = new ControlLink(value.toString());
|
||||
return link;
|
||||
} else {*/
|
||||
Label label = new Label(value.toString());
|
||||
return label;
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
private class DeleteCellRenderer
|
||||
extends LockableImpl
|
||||
implements TableCellRenderer {
|
||||
|
||||
@Override
|
||||
public Component getComponent(Table table,
|
||||
PageState state,
|
||||
Object value,
|
||||
boolean isSelected,
|
||||
Object key,
|
||||
int row,
|
||||
int col) {
|
||||
SecurityManager securityManager =
|
||||
Utilities.getSecurityManager(state);
|
||||
SciProject project = (SciProject) m_itemModel.getSelectedObject(
|
||||
state);
|
||||
|
||||
boolean canEdit = securityManager.canAccess(
|
||||
state.getRequest(),
|
||||
SecurityManager.DELETE_ITEM,
|
||||
project);
|
||||
|
||||
if (canEdit) {
|
||||
ControlLink link = new ControlLink(value.toString());
|
||||
link.setConfirmation((String) SciOrganizationGlobalizationUtil.
|
||||
globalize(
|
||||
"sciorganization.ui.project.organization."
|
||||
+ ".confirm_remove").
|
||||
localize());
|
||||
return link;
|
||||
} else {
|
||||
Label label = new Label(value.toString());
|
||||
return label;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class UpCellRenderer
|
||||
extends LockableImpl
|
||||
implements TableCellRenderer {
|
||||
|
||||
@Override
|
||||
public Component getComponent(
|
||||
Table table,
|
||||
PageState state,
|
||||
Object value,
|
||||
boolean isSelected,
|
||||
Object key,
|
||||
int row,
|
||||
int col) {
|
||||
|
||||
if (0 == row) {
|
||||
Label label = new Label("");
|
||||
return label;
|
||||
} else {
|
||||
ControlLink link = new ControlLink(
|
||||
(String) SciOrganizationGlobalizationUtil.globalize(
|
||||
"sciorganization.ui.project.organization.up").
|
||||
localize());
|
||||
return link;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class DownCellRenderer
|
||||
extends LockableImpl
|
||||
implements TableCellRenderer {
|
||||
|
||||
@Override
|
||||
public Component getComponent(
|
||||
Table table,
|
||||
PageState state,
|
||||
Object value,
|
||||
boolean isSelected,
|
||||
Object key,
|
||||
int row,
|
||||
int col) {
|
||||
|
||||
SciProject project = (SciProject) m_itemModel.getSelectedObject(
|
||||
state);
|
||||
SciProjectSubProjectsCollection subProjects =
|
||||
project.getSubProjects();
|
||||
|
||||
if ((subProjects.size() - 1) == row) {
|
||||
Label label = new Label("");
|
||||
return label;
|
||||
} else {
|
||||
ControlLink link = new ControlLink(
|
||||
(String) SciOrganizationGlobalizationUtil.globalize(
|
||||
"sciorganization.ui.project.organization.down").
|
||||
localize());
|
||||
return link;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cellSelected(TableActionEvent event) {
|
||||
PageState state = event.getPageState();
|
||||
|
||||
SciOrganization orga = new SciOrganization(
|
||||
new BigDecimal(event.getRowKey().toString()));
|
||||
|
||||
SciProject project =
|
||||
(SciProject) m_itemModel.getSelectedObject(state);
|
||||
|
||||
SciProjectOrganizationsCollection subprojects =
|
||||
project.getOrganizations();
|
||||
|
||||
TableColumn column = getColumnModel().get(event.getColumn().intValue());
|
||||
|
||||
if (column.getHeaderKey().toString().equals(TABLE_COL_EDIT)) {
|
||||
} else if (column.getHeaderKey().toString().equals(TABLE_COL_DEL)) {
|
||||
project.removeOrganization(orga);
|
||||
} else if (column.getHeaderKey().toString().equals(TABLE_COL_UP)) {
|
||||
subprojects.swapWithPrevious(orga);
|
||||
} else if (column.getHeaderKey().toString().equals(TABLE_COL_DOWN)) {
|
||||
subprojects.swapWithNext(orga);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void headSelected(TableActionEvent event) {
|
||||
//Nothing to do.
|
||||
}
|
||||
}
|
||||
|
|
@ -72,18 +72,26 @@ public class SciProjectPropertiesStep
|
|||
@Override
|
||||
protected void addSteps(ItemSelectionModel itemModel,
|
||||
AuthoringKitWizard parent) {
|
||||
/*addStep(new GenericOrganizationalUnitContactPropertiesStep(itemModel,
|
||||
addStep(new GenericOrganizationalUnitContactPropertiesStep(itemModel,
|
||||
parent),
|
||||
"cms.contenttypes.ui.orgaunit.contact");
|
||||
addStep(new GenericOrganizationalUnitPersonPropertiesStep(itemModel,
|
||||
parent),
|
||||
"cms.contenttypes.ui.orgaunit.persons");*/
|
||||
"cms.contenttypes.ui.orgaunit.persons");
|
||||
|
||||
super.addSteps(itemModel, parent);
|
||||
|
||||
addStep(new SciProjectSuperProjectStep(itemModel,
|
||||
parent),
|
||||
"sciorganization.ui.project.superproject");
|
||||
addStep(new SciProjectSubprojectsStep(itemModel,
|
||||
parent),
|
||||
"cms.contenttypes.ui.project.subprojects");
|
||||
"sciorganization.ui.project.subprojects");
|
||||
|
||||
addStep(new SciProjectOrganizationsStep(itemModel, parent),
|
||||
"sciorganization.ui.project.organizations");
|
||||
|
||||
addStep(new SciProjectDepartmentsStep(itemModel, parent),
|
||||
"sciorganization.ui.project.departments");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,6 @@ public class SciProjectSubProjectsTable
|
|||
|
||||
setModelBuilder(
|
||||
new SciProjectSubProjectsTableModelBuilder(itemModel));
|
||||
|
||||
colModel.get(0).setCellRenderer(new EditCellRenderer());
|
||||
colModel.get(1).setCellRenderer(new DeleteCellRenderer());
|
||||
colModel.get(2).setCellRenderer(new UpCellRenderer());
|
||||
|
|
@ -181,13 +180,13 @@ public class SciProjectSubProjectsTable
|
|||
SecurityManager.EDIT_ITEM,
|
||||
project);
|
||||
|
||||
if (canEdit) {
|
||||
/*if (canEdit) {
|
||||
ControlLink link = new ControlLink(value.toString());
|
||||
return link;
|
||||
} else {
|
||||
} else {*/
|
||||
Label label = new Label(value.toString());
|
||||
return label;
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -269,8 +268,10 @@ public class SciProjectSubProjectsTable
|
|||
int row,
|
||||
int col) {
|
||||
|
||||
SciProject project = (SciProject) m_itemModel.getSelectedObject(state);
|
||||
SciProjectSubProjectsCollection subProjects = project.getSubProjects();
|
||||
SciProject project = (SciProject) m_itemModel.getSelectedObject(
|
||||
state);
|
||||
SciProjectSubProjectsCollection subProjects =
|
||||
project.getSubProjects();
|
||||
|
||||
if ((subProjects.size() - 1) == row) {
|
||||
Label label = new Label("");
|
||||
|
|
@ -284,6 +285,7 @@ public class SciProjectSubProjectsTable
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cellSelected(TableActionEvent event) {
|
||||
PageState state = event.getPageState();
|
||||
|
|
@ -313,5 +315,4 @@ public class SciProjectSubProjectsTable
|
|||
public void headSelected(TableActionEvent event) {
|
||||
//Nothing to do.
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,8 +57,8 @@ public class SciProjectSubprojectAddForm
|
|||
if (!(this.getSaveCancelSection().getCancelButton().
|
||||
isSelected(state))) {
|
||||
project.addSubProject((SciProject) data.get(ITEM_SEARCH));
|
||||
}
|
||||
|
||||
init(fse);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.arsdigita.cms.contenttypes.ui;
|
||||
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.contenttypes.util.ContenttypesGlobalizationUtil;
|
||||
import com.arsdigita.cms.ui.authoring.AuthoringKitWizard;
|
||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
||||
import com.arsdigita.cms.ui.authoring.SimpleEditStep;
|
||||
|
|
@ -32,8 +31,8 @@ public class SciProjectSubprojectsStep extends SimpleEditStep {
|
|||
BasicItemForm addSubProjectSheet =
|
||||
new SciProjectSubprojectAddForm(itemModel);
|
||||
add(ADD_CHILD_SHEET_NAME,
|
||||
(String) ContenttypesGlobalizationUtil.globalize(
|
||||
"cms.contenttypes.ui.genericorgaunit.add_child").localize(),
|
||||
(String) SciOrganizationGlobalizationUtil.globalize(
|
||||
"sciorganization.ui.project.addSubProject").localize(),
|
||||
new WorkflowLockedComponentAccess(addSubProjectSheet, itemModel),
|
||||
addSubProjectSheet.getSaveCancelSection().getCancelButton());
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,64 @@
|
|||
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.cms.ContentType;
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
import com.arsdigita.cms.contenttypes.SciProject;
|
||||
import com.arsdigita.cms.ui.ItemSearchWidget;
|
||||
import com.arsdigita.cms.ui.authoring.BasicItemForm;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
*/
|
||||
public class SciProjectSuperProjectAttachForm
|
||||
extends BasicItemForm
|
||||
implements FormProcessListener,
|
||||
FormInitListener {
|
||||
|
||||
private ItemSearchWidget m_itemSearch;
|
||||
private final String ITEM_SEARCH = "superproject";
|
||||
|
||||
public SciProjectSuperProjectAttachForm(ItemSelectionModel itemModel) {
|
||||
super("SuperProjectAttachForm", itemModel);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addWidgets() {
|
||||
add(new Label((String) SciOrganizationGlobalizationUtil.globalize(
|
||||
"sciorganization.ui.project.select_superproject").localize()));
|
||||
m_itemSearch = new ItemSearchWidget(
|
||||
ITEM_SEARCH,
|
||||
ContentType.findByAssociatedObjectType(
|
||||
SciProject.class.getName()));
|
||||
add(m_itemSearch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FormSectionEvent fse) throws FormProcessException {
|
||||
PageState state = fse.getPageState();
|
||||
|
||||
setVisible(state, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(FormSectionEvent fse) throws FormProcessException {
|
||||
FormData data = fse.getFormData();
|
||||
PageState state = fse.getPageState();
|
||||
SciProject project = (SciProject) getItemSelectionModel().
|
||||
getSelectedObject(state);
|
||||
|
||||
if (!(this.getSaveCancelSection().getCancelButton().
|
||||
isSelected(state))) {
|
||||
project.setSuperProject((SciProject) data.get(ITEM_SEARCH));
|
||||
|
||||
init(fse);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,208 @@
|
|||
package com.arsdigita.cms.contenttypes.ui;
|
||||
|
||||
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.ItemSelectionModel;
|
||||
import com.arsdigita.cms.SecurityManager;
|
||||
import com.arsdigita.cms.contenttypes.SciProject;
|
||||
import com.arsdigita.cms.dispatcher.Utilities;
|
||||
|
||||
import com.arsdigita.util.LockableImpl;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
*/
|
||||
public class SciProjectSuperProjectSheet
|
||||
extends Table
|
||||
implements TableActionListener {
|
||||
|
||||
private final String TABLE_COL_EDIT = "table_col_edit";
|
||||
private final String TABLE_COL_DEL = "table_col_del";
|
||||
private ItemSelectionModel m_itemModel;
|
||||
|
||||
public SciProjectSuperProjectSheet(ItemSelectionModel itemModel) {
|
||||
super();
|
||||
m_itemModel = itemModel;
|
||||
|
||||
setEmptyView(
|
||||
new Label(SciOrganizationGlobalizationUtil.globalize(
|
||||
"sciorganization.ui.project.superproject_none")));
|
||||
|
||||
TableColumnModel colModel = getColumnModel();
|
||||
colModel.add(new TableColumn(
|
||||
0,
|
||||
SciOrganizationGlobalizationUtil.globalize(
|
||||
"sciorganization.ui.project.superproject").localize(),
|
||||
TABLE_COL_EDIT));
|
||||
colModel.add(new TableColumn(
|
||||
1,
|
||||
SciOrganizationGlobalizationUtil.globalize(
|
||||
"sciorganization.ui.project.superproject.remove").localize(),
|
||||
TABLE_COL_DEL));
|
||||
|
||||
setModelBuilder(
|
||||
new SciProjectSuperProjectSheetModelBuilder(itemModel));
|
||||
colModel.get(0).setCellRenderer(new EditCellRenderer());
|
||||
colModel.get(1).setCellRenderer(new DeleteCellRenderer());
|
||||
|
||||
addTableActionListener(this);
|
||||
}
|
||||
|
||||
private class SciProjectSuperProjectSheetModelBuilder
|
||||
extends LockableImpl
|
||||
implements TableModelBuilder {
|
||||
|
||||
private ItemSelectionModel m_itemModel;
|
||||
|
||||
public SciProjectSuperProjectSheetModelBuilder(
|
||||
ItemSelectionModel itemModel) {
|
||||
m_itemModel = itemModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableModel makeModel(Table table, PageState state) {
|
||||
table.getRowSelectionModel().clearSelection(state);
|
||||
SciProject project = (SciProject) m_itemModel.getSelectedObject(
|
||||
state);
|
||||
return new SciProjectSuperProjectSheetModel(table,
|
||||
state,
|
||||
project);
|
||||
}
|
||||
}
|
||||
|
||||
private class SciProjectSuperProjectSheetModel
|
||||
implements TableModel {
|
||||
|
||||
private Table m_table;
|
||||
private SciProject m_superProject;
|
||||
|
||||
public SciProjectSuperProjectSheetModel(Table table,
|
||||
PageState state,
|
||||
SciProject project) {
|
||||
m_table = table;
|
||||
m_superProject = project.getSuperProject();
|
||||
}
|
||||
|
||||
public int getColumnCount() {
|
||||
return m_table.getColumnModel().size();
|
||||
}
|
||||
|
||||
public boolean nextRow() {
|
||||
boolean ret;
|
||||
|
||||
if (null == m_superProject) {
|
||||
ret = false;
|
||||
} else {
|
||||
ret = true;
|
||||
m_superProject = null;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Object getElementAt(int columnIndex) {
|
||||
switch (columnIndex) {
|
||||
case 0:
|
||||
return m_superProject.getTitle();
|
||||
case 1:
|
||||
return SciOrganizationGlobalizationUtil.globalize(
|
||||
"sciorganization.ui.project.superproject.remove");
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Object getKeyAt(int columnIndex) {
|
||||
return m_superProject.getID();
|
||||
}
|
||||
}
|
||||
|
||||
private class EditCellRenderer
|
||||
extends LockableImpl
|
||||
implements TableCellRenderer {
|
||||
|
||||
@Override
|
||||
public Component getComponent(Table table,
|
||||
PageState state,
|
||||
Object value,
|
||||
boolean isSelected,
|
||||
Object key,
|
||||
int row,
|
||||
int column) {
|
||||
Label label = new Label(value.toString());
|
||||
return label;
|
||||
}
|
||||
}
|
||||
|
||||
private class DeleteCellRenderer
|
||||
extends LockableImpl
|
||||
implements TableCellRenderer {
|
||||
|
||||
@Override
|
||||
public Component getComponent(Table table,
|
||||
PageState state,
|
||||
Object value,
|
||||
boolean isSelected,
|
||||
Object key,
|
||||
int row,
|
||||
int col) {
|
||||
SecurityManager securityManager =
|
||||
Utilities.getSecurityManager(state);
|
||||
SciProject project = (SciProject) m_itemModel.getSelectedObject(
|
||||
state);
|
||||
|
||||
boolean canEdit = securityManager.canAccess(
|
||||
state.getRequest(),
|
||||
SecurityManager.DELETE_ITEM,
|
||||
project);
|
||||
|
||||
if (canEdit) {
|
||||
ControlLink link = new ControlLink(value.toString());
|
||||
link.setConfirmation((String) SciOrganizationGlobalizationUtil.
|
||||
globalize(
|
||||
"sciorganization.ui.project.superproject."
|
||||
+ ".confirm_remove").
|
||||
localize());
|
||||
return link;
|
||||
} else {
|
||||
Label label = new Label(value.toString());
|
||||
return label;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cellSelected(TableActionEvent event) {
|
||||
PageState state = event.getPageState();
|
||||
|
||||
SciProject superProject = new SciProject(
|
||||
new BigDecimal(event.getRowKey().toString()));
|
||||
|
||||
SciProject project = (SciProject) m_itemModel.getSelectedObject(state);
|
||||
|
||||
TableColumn column = getColumnModel().get(event.getColumn().intValue());
|
||||
|
||||
if (column.getHeaderKey().toString().equals(TABLE_COL_EDIT)) {
|
||||
} else if (column.getHeaderKey().toString().equals(TABLE_COL_DEL)) {
|
||||
project.setSuperProject(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void headSelected(TableActionEvent event) {
|
||||
//Nothing to do.
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package com.arsdigita.cms.contenttypes.ui;
|
||||
|
||||
import com.arsdigita.cms.ItemSelectionModel;
|
||||
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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Jens Pelzetter
|
||||
*/
|
||||
public class SciProjectSuperProjectStep extends SimpleEditStep {
|
||||
|
||||
private String ATTACH_SUPER_PROJECT_STEP = "attachSuperProject";
|
||||
|
||||
public SciProjectSuperProjectStep(ItemSelectionModel itemModel,
|
||||
AuthoringKitWizard parent) {
|
||||
this(itemModel, parent, null);
|
||||
}
|
||||
|
||||
public SciProjectSuperProjectStep(ItemSelectionModel itemModel,
|
||||
AuthoringKitWizard parent,
|
||||
String prefix) {
|
||||
super(itemModel, parent, prefix);
|
||||
|
||||
BasicItemForm attachSuperProjectForm =
|
||||
new SciProjectSuperProjectAttachForm(itemModel);
|
||||
add(ATTACH_SUPER_PROJECT_STEP,
|
||||
(String) SciOrganizationGlobalizationUtil.globalize(
|
||||
"sciorganization.ui.project.attachSuperProject").localize(),
|
||||
new WorkflowLockedComponentAccess(attachSuperProjectForm,
|
||||
itemModel),
|
||||
attachSuperProjectForm.getSaveCancelSection().
|
||||
getCancelButton());
|
||||
|
||||
SciProjectSuperProjectSheet superProjectSheet =
|
||||
new SciProjectSuperProjectSheet(itemModel);
|
||||
setDisplayComponent(superProjectSheet);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue