Weitere Ergänzung um das Nebenläufigskeitsproblem im Admin-Tab zu beheben.

git-svn-id: https://svn.libreccm.org/ccm/trunk@2285 8810af33-2d31-482b-a856-94f89814c4df
master
jensp 2013-08-02 08:43:54 +00:00
parent d57fe474a8
commit 6bf4288e69
1 changed files with 79 additions and 30 deletions

View File

@ -31,12 +31,14 @@ import com.arsdigita.util.LockableImpl;
import com.arsdigita.web.Application; import com.arsdigita.web.Application;
import com.arsdigita.web.ApplicationCollection; import com.arsdigita.web.ApplicationCollection;
import com.arsdigita.web.ApplicationType; import com.arsdigita.web.ApplicationType;
import java.util.ArrayList;
import java.util.List;
/** /**
* Pane for multi instance applications. Additional to the data provided by {@link BaseApplicationPane} it shows a * Pane for multi instance applications. Additional to the data provided by {@link BaseApplicationPane} it shows a table
* table of all instances of the application type and a form for creating new instances of the application type. * of all instances of the application type and a form for creating new instances of the application type.
* *
* @param <T> * @param <T>
* @author Jens Pelzetter <jens@jp-digital.de> * @author Jens Pelzetter <jens@jp-digital.de>
* @version $Id$ * @version $Id$
*/ */
@ -86,66 +88,113 @@ public class MultiInstanceApplicationPane<T extends Application> extends BaseApp
private class ApplicationInstancesTableModelBuilder extends LockableImpl implements TableModelBuilder { private class ApplicationInstancesTableModelBuilder extends LockableImpl implements TableModelBuilder {
private final ApplicationCollection applications; //private final ApplicationCollection applications;
private final String appType;
public ApplicationInstancesTableModelBuilder(final ApplicationCollection applications) { //public ApplicationInstancesTableModelBuilder(final ApplicationCollection applications) {
super(); // super();
//
this.applications = applications; // this.applications = applications;
} //}
public ApplicationInstancesTableModelBuilder(final String appType) { public ApplicationInstancesTableModelBuilder(final String appType) {
super(); super();
this.applications = Application.retrieveAllApplications(appType); //this.applications = Application.retrieveAllApplications(appType);
this.appType = appType;
} }
public TableModel makeModel(final Table table, final PageState state) { public TableModel makeModel(final Table table, final PageState state) {
return new ApplicationInstancesTableModel(table, applications); return new ApplicationInstancesTableModel(table, appType);
} }
} }
private class ApplicationInstancesTableModel implements TableModel { private class ApplicationInstancesTableModel implements TableModel {
private final Table table; private final Table table;
private final ApplicationCollection applications; //private final ApplicationCollection applications;
private final List<AppData> appData = new ArrayList<AppData>();
private int currentIndex = -1;
public ApplicationInstancesTableModel(final Table table, final ApplicationCollection applications) { //public ApplicationInstancesTableModel(final Table table, final ApplicationCollection applications) {
// this.table = table;
// this.applications = applications;
//}
public ApplicationInstancesTableModel(final Table table, final String appType) {
this.table = table; this.table = table;
this.applications = applications; final ApplicationCollection applications = Application.retrieveAllApplications(appType);
while (applications.next()) {
addAppData(applications.getApplication());
}
}
private void addAppData(final Application application) {
appData.add(new AppData(application.getTitle(),
application.getDescription(),
application.getPath()));
} }
public int getColumnCount() { public int getColumnCount() {
return table.getColumnModel().size(); return table.getColumnModel().size();
} }
public boolean nextRow() { public boolean nextRow() {
if (applications.isAfterLast()) { currentIndex++;
applications.rewind(); return currentIndex < appData.size();
}
return applications.next();
} }
public Object getElementAt(final int columnIndex) { public Object getElementAt(final int columnIndex) {
switch (columnIndex) { switch (columnIndex) {
case COL_TITLE: case COL_TITLE:
return applications.getApplication().getTitle(); //return applications.getApplication().getTitle();
return appData.get(currentIndex).getTitle();
case COL_DESC: case COL_DESC:
return applications.getApplication().getDescription(); //return applications.getApplication().getDescription();
return appData.get(currentIndex).getDescription();
case COL_URL: case COL_URL:
return applications.getApplication().getPath(); //return applications.getApplication().getPath();
return appData.get(currentIndex).getPath();
default: default:
return null; return null;
} }
} }
public Object getKeyAt(final int columnIndex) { public Object getKeyAt(final int columnIndex) {
if (SessionManager.getSession().getTransactionContext().inTxn()) { //if (SessionManager.getSession().getTransactionContext().inTxn()) {
SessionManager.getSession().getTransactionContext().commitTxn(); // SessionManager.getSession().getTransactionContext().commitTxn();
} //}
return applications.getApplication().getPath(); //return applications.getApplication().getPath();
return appData.get(currentIndex).getPath();
}
}
private class AppData {
private final String title;
private final String description;
private final String path;
public AppData() {
title = "";
description = "";
path = "";
} }
public AppData(final String title, final String description, final String path) {
this.title = title;
this.description = description;
this.path = path;
}
public String getTitle() {
return title;
}
public String getDescription() {
return description;
}
public String getPath() {
return path;
}
} }
} }