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-94f89814c4dfmaster
parent
d57fe474a8
commit
6bf4288e69
|
|
@ -31,10 +31,12 @@ 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>
|
||||||
|
|
@ -86,34 +88,49 @@ 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) {
|
|
||||||
super();
|
|
||||||
|
|
||||||
this.applications = applications;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
//public ApplicationInstancesTableModelBuilder(final ApplicationCollection applications) {
|
||||||
|
// super();
|
||||||
|
//
|
||||||
|
// 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() {
|
||||||
|
|
@ -121,31 +138,63 @@ public class MultiInstanceApplicationPane<T extends Application> extends BaseApp
|
||||||
}
|
}
|
||||||
|
|
||||||
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 appData.get(currentIndex).getPath();
|
||||||
}
|
}
|
||||||
return applications.getApplication().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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue