Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*******************************************************************************
* Copyright 2015 xWic group (http://www.xwic.de)
*
* Licensed under the Apache License, Version 2.0 (the "License").
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*******************************************************************************/
package de.jwic.controls.tableviewer;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.commons.logging.LogFactory;
import de.jwic.base.Control;
import de.jwic.base.Field;
import de.jwic.base.IControlRenderer;
import de.jwic.base.ImageRef;
import de.jwic.base.JWicRuntime;
import de.jwic.base.RenderContext;
import de.jwic.data.IContentProvider;
import de.jwic.data.Range;
/**
* Default implementation of the ITableRenderer interface. The default renderer
* generates HTML "by code", without using templates. The reason for this is
* because its faster, costs less resources and the generated HTML is quite
* complex so that templates would be quite ugly anyway.
*
* @author Jens Bornemann
*/
public class FixColumnTableRenderer extends DefaultTableRenderer {
/**
*
*/
private static final long serialVersionUID = 1L;
protected int fixColumn = 0;
protected boolean reuseContent = true;
/* (non-Javadoc)
* @see de.jwic.ecolib.tableviewer.ITableRenderer#renderTable(de.jwic.base.RenderContext, de.jwic.ecolib.tableviewer.TableViewer, de.jwic.ecolib.tableviewer.TableModel)
*/
@SuppressWarnings("unused")
public void renderTable(RenderContext renderContext, TableViewer viewer, TableModel model, ITableLabelProvider labelProvider) {
if (!viewer.isScrollable() || fixColumn < 0) {
super.renderTable(renderContext, viewer, model, labelProvider);
return;
}
String tblvWebPath = JWicRuntime.getJWicRuntime().getContextPath() + "/ecolib/tblviewer/";
PrintWriter writer = renderContext.getWriter();
IContentProvider> contentProvider = model.getContentProvider();
int tblWidth = 0;
for (Iterator it = model.getColumnIterator(); it.hasNext(); ) {
TableColumn tc = it.next();
if (!tc.isVisible()) {
continue;
}
tblWidth += tc.getWidth();
}
int defaultColumnWidth = 150;
// TODO use defined css border width instead of this fixed one...
int leftWidth = (fixColumn + 1) * 2;
{
int c = 0;
for (Iterator itC = model.getColumnIterator(); itC.hasNext(); ) {
TableColumn column = itC.next();
if (c++ > fixColumn || !column.isVisible()) {
break;
}
int width = column.getWidth() != 0 ? column.getWidth() : defaultColumnWidth;
leftWidth += width;
}
}
int rightWidth = viewer.getWidth() != 0 ? viewer.getWidth() - leftWidth : 0;
// Add resizer div
if (viewer.isResizeableColumns()) {
writer.print("");
}
// render main table.
writer.print("
");
}
// render HEADER columns
if (viewer.isShowHeader()) {
renderHeader(writer, model, viewer, tblvWebPath, right, dataWidth);
}
// if scrollable, seperate the data table from the header
// and render it within its own, scrollable DIV. Will only
// look proper if the columns have a fixed width.
int dataHeight = viewer.getHeight() != 0 ? viewer.getHeight() - (viewer.isShowHeader() ? 20 : 0): 200;
if (viewer.isShowStatusBar()) {
dataHeight -= 18;
}
if (viewer.isShowHeader()) {
writer.println("
");
}
if (!right) {
writer.print("
");
writer.print("
");
} else {
writer.print("
");
writer.print("
");
}
}
// render table BODY
leftWriter.print("");
rightWriter.print("");
int count = 0;
try {
writer = leftWriter;
tblView = "tblViewLeft";
Range range = model.getRange();
if (range.getMax() == 0) { // = Auto
int max = -1;
int rowSpace = viewer.getHeight() - (35 + 20); // - header height + scroll bar height
if (rowSpace != 0) {
if (viewer.isShowStatusBar()) {
rowSpace -= 18;
}
max = rowSpace / viewer.getRowHeightHint(); //
if (max < 1) {
max = 1;
}
model.setLastRenderedPageSize(max);
}
range = new Range(range.getStart(), max);
}
List");
writer.print("
");
writer.print("
");
}
// finish left and right...
leftWriter.close();
rightWriter.close();
writer = renderContext.getWriter();
writer.print("
");
int c = -1;
for (Iterator itC = model.getColumnIterator(); itC.hasNext(); ) {
TableColumn column = itC.next();
c++;
if (!right) {
if (c > fixColumn) {
break;
}
} else {
if (c <= fixColumn) {
continue;
}
}
if (!column.isVisible()) {
continue;
}
if (isResizable && column.getWidth() == 0) {
// must set a default width if resizeable columns is activated
column.setWidth(150);
}
writer.print("
");
if (column.getSortIcon() != TableColumn.SORT_ICON_NONE) {
ImageRef imgSort = null;
switch (column.getSortIcon()) {
case TableColumn.SORT_ICON_UP:
imgSort = ICON_SORTUP;
break;
case TableColumn.SORT_ICON_DOWN:
imgSort = ICON_SORTDOWN;
break;
}
if (imgSort != null) {
writer.print("
");
writer.print("");
writer.print("
");
}
}
if (isResizable) {
writer.print("
");
writer.print("
");
}
writer.print("
");
writer.println("
");
}
// if the width is fixed, we must render an empty column at the end so that the
// browser will not adjust the columns width
if (dataWidth != 0 && right) {
writer.print("