Browse Source

Feature #22251 implemented - Make workspace file size field smart

master
Francesco Mangiacrapa 2 months ago
parent
commit
e1cda838c4
  1. 6
      .classpath
  2. 2
      .settings/com.gwtplugins.gdt.eclipse.core.prefs
  3. 40
      .settings/org.eclipse.wst.common.component
  4. 6
      CHANGELOG.md
  5. 2
      pom.xml
  6. 42
      src/main/java/org/gcube/portlets/user/workspace/client/view/SizeUtil.java
  7. 289
      src/main/java/org/gcube/portlets/user/workspace/client/view/grids/GxtGridFilterGroupPanel.java

6
.classpath

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding="**" kind="src" output="target/workspace-6.27.1-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<classpathentry excluding="**" kind="src" output="target/workspace-6.28.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
@ -22,7 +22,7 @@
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/workspace-6.27.1-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<classpathentry kind="src" output="target/workspace-6.28.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
@ -35,5 +35,5 @@
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/workspace-6.27.1-SNAPSHOT/WEB-INF/classes"/>
<classpathentry kind="output" path="target/workspace-6.28.0-SNAPSHOT/WEB-INF/classes"/>
</classpath>

2
.settings/com.gwtplugins.gdt.eclipse.core.prefs

@ -1,4 +1,4 @@
eclipse.preferences.version=1
lastWarOutDir=/home/francescomangiacrapa/git/workspace/target/workspace-6.27.1-SNAPSHOT
lastWarOutDir=/home/francescomangiacrapa/git/workspace/target/workspace-6.28.0-SNAPSHOT
warSrcDir=src/main/webapp
warSrcDirIsOutput=false

40
.settings/org.eclipse.wst.common.component

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
@ -18,8 +18,10 @@
<wb-module deploy-name="workspace-6.27.1-SNAPSHOT">
<wb-module deploy-name="workspace-6.28.0-SNAPSHOT">
@ -39,7 +41,8 @@
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
@ -59,7 +62,8 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
@ -79,7 +83,8 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
@ -98,22 +103,18 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<dependent-module archiveName="workspace-explorer-2.2.0.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/workspace-explorer/workspace-explorer">
<dependent-module archiveName="workspace-tree-widget-6.34.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/WorkspaceTree/WorkspaceTree">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="catalogue-util-library-1.1.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/catalogue-util-library/catalogue-util-library">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="ws-task-executor-widget-1.0.0.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/ws-task-executor-widget-TRUNK/ws-task-executor-widget-TRUNK">
<dependency-type>uses</dependency-type>
</dependent-module>
@ -133,7 +134,8 @@
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
@ -153,7 +155,8 @@
<property name="context-root" value="workspace"/>
@ -173,7 +176,8 @@
</wb-module>

6
CHANGELOG.md

@ -4,6 +4,12 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v6.28.0-SNAPSHOT] - 2021-11-05
#### Enhancements
* [#22251] Make workspace file size field smart
## [v6.27.1] - 2021-06-22
[#21575] Including ws-tree bug fix

2
pom.xml

@ -13,7 +13,7 @@
<groupId>org.gcube.portlets.user</groupId>
<artifactId>workspace</artifactId>
<packaging>war</packaging>
<version>6.27.1</version>
<version>6.28.0-SNAPSHOT</version>
<name>gCube Workspace Portlet</name>
<description>
gCube Workspace Portlet is a web-gui to manage the gCube workspace, a collaborative area where users can exchange and organize information objects (workspace items) according to their specific needs.

42
src/main/java/org/gcube/portlets/user/workspace/client/view/SizeUtil.java

@ -0,0 +1,42 @@
package org.gcube.portlets.user.workspace.client.view;
import com.google.gwt.core.client.GWT;
import com.google.gwt.i18n.client.NumberFormat;
/**
* The Class SizeUtil.
*
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
*
* Nov 5, 2021
*/
public class SizeUtil {
public static final NumberFormat numberFormat = NumberFormat.getFormat("#,##0.#");
/**
* Readable file size.
*
* @param size the size
* @return the string
*/
public static String readableFileSize(long size) {
GWT.log("Converting size: "+size);
// -1 should be the size of a folder
if (size == -1)
return "";
// in some cases the size returned by SHUB is negative,
// so reporting as 1B to user
if (size < 0)
return "1 byte";
if (size == 0)
return "0 byte";
final String[] units = new String[] { "bytes", "kB", "MB", "GB", "TB" };
int digitGroups = (int) (Math.log10(size) / Math.log10(1024));
return numberFormat.format(size / Math.pow(1024, digitGroups)) +" " +units[digitGroups];
}
}

289
src/main/java/org/gcube/portlets/user/workspace/client/view/grids/GxtGridFilterGroupPanel.java

@ -5,7 +5,6 @@ import java.util.Arrays;
import java.util.List;
import org.gcube.portlets.user.workspace.client.AppController;
import org.gcube.portlets.user.workspace.client.ConstantsExplorer;
import org.gcube.portlets.user.workspace.client.event.FileDownloadEvent;
import org.gcube.portlets.user.workspace.client.event.FileDownloadEvent.DownloadType;
import org.gcube.portlets.user.workspace.client.event.ImagePreviewEvent;
@ -18,6 +17,7 @@ import org.gcube.portlets.user.workspace.client.gridevent.StoreGridChangedEvent;
import org.gcube.portlets.user.workspace.client.model.FileGridModel;
import org.gcube.portlets.user.workspace.client.model.FileModel;
import org.gcube.portlets.user.workspace.client.model.GroupingStoreModel;
import org.gcube.portlets.user.workspace.client.view.SizeUtil;
import com.extjs.gxt.ui.client.Style.SelectionMode;
import com.extjs.gxt.ui.client.data.ModelData;
@ -50,28 +50,24 @@ import com.extjs.gxt.ui.client.widget.grid.filters.StringFilter;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.google.gwt.core.shared.GWT;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.i18n.client.NumberFormat;
import com.google.gwt.user.client.Random;
/**
* The Class GxtGridFilterGroupPanel.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa{@literal @}isti.cnr.it
* Nov 17, 2015
* Nov 17, 2015
*/
public class GxtGridFilterGroupPanel extends LayoutContainer {
private ContentPanel cp = new ContentPanel();
// private ListStore<FileModel> store = ListStoreModel.getInstance().getStore();
private GroupingStore<FileGridModel> store = GroupingStoreModel.getInstance().getStore();
private FileGridModel currentItemSelected = null;
private FileModel currentFolderView = null;
private GroupingView view = new GroupingView();
private boolean groupingEnabled = false;
private NumberFormat number = ConstantsExplorer.numberFormatterKB;
private final Grid<FileGridModel> grid;
private ColumnModel cm = null;
private final Grid<FileGridModel> grid;
private ColumnModel cm = null;
/**
* Instantiates a new gxt grid filter group panel.
@ -80,23 +76,21 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
*/
public GxtGridFilterGroupPanel(boolean group) {
// setLayout(new FitLayout());
setId("GxtGridFilterGroupPanel "+Random.nextInt());
setId("GxtGridFilterGroupPanel " + Random.nextInt());
ColumnConfig icon = new ColumnConfig(FileModel.ICON, "", 60);
icon.setSortable(false);
ColumnConfig name = new ColumnConfig(FileGridModel.NAME, FileGridModel.NAME, 280);
ColumnConfig type = new ColumnConfig(FileGridModel.TYPE, FileGridModel.TYPE, 60);
ColumnConfig lastUpdate = new ColumnConfig(FileGridModel.LASTMODIFIED, "Last Update", 90);
lastUpdate.setDateTimeFormat(DateTimeFormat.getFormat("dd MMM hh:mm aaa yyyy"));
ColumnConfig category = new ColumnConfig(FileModel.HUMAN_REDABLE_CATEGORY, FileModel.HUMAN_REDABLE_CATEGORY, 100);
ColumnConfig category = new ColumnConfig(FileModel.HUMAN_REDABLE_CATEGORY, FileModel.HUMAN_REDABLE_CATEGORY,
100);
ColumnConfig size = new ColumnConfig(FileGridModel.SIZE, FileGridModel.SIZE, 45);
ColumnConfig ownerFullName = new ColumnConfig(FileGridModel.OWNERFULLNAME, FileGridModel.OWNER, 90);
size.setEditor(new CellEditor(new NumberField()));
if(group)
if (group)
cm = new ColumnModel(Arrays.asList(icon, name, ownerFullName, type, lastUpdate, size, category));
else
cm = new ColumnModel(Arrays.asList(icon, name, ownerFullName, type, lastUpdate, size));
@ -110,50 +104,46 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
grid = new Grid<FileGridModel>(store, columnModel);
grid.getView().setAutoFill(true);
view.setShowGroupedColumn(false);
view.setForceFit(true);
grid.setView(view);
view.setEmptyText(FileGridModel.EMPTY);
view.setShowGroupedColumn(false);
view.setForceFit(true);
grid.setView(view);
view.setEmptyText(FileGridModel.EMPTY);
if(group){
store.groupBy(FileGridModel.HUMAN_REDABLE_CATEGORY);
groupingEnabled = true;
}
if (group) {
store.groupBy(FileGridModel.HUMAN_REDABLE_CATEGORY);
groupingEnabled = true;
}
GridCellRenderer<FileGridModel> folderRender = new GridCellRenderer<FileGridModel>() {
GridCellRenderer<FileGridModel> folderRender = new GridCellRenderer<FileGridModel>() {
@Override
public String render(FileGridModel model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<FileGridModel> store, Grid<FileGridModel> grid) {
String val = model.get(property);
if(val==null || val.isEmpty())
return "";
return "<span qtitle='" + columnModel.getColumnById(property).getHeader() + "' qtip='" + val + "' >" + val + "</span>";
public String render(FileGridModel model, String property, ColumnData config, int rowIndex, int colIndex,
ListStore<FileGridModel> store, Grid<FileGridModel> grid) {
String val = model.get(property);
if (val == null || val.isEmpty())
return "";
return "<span qtitle='" + columnModel.getColumnById(property).getHeader() + "' qtip='" + val + "' >"
+ val + "</span>";
}
};
GridCellRenderer<FileGridModel> kbRender = new GridCellRenderer<FileGridModel>() {
@Override
public String render(FileGridModel model, String property, ColumnData config,
int rowIndex, int colIndex, ListStore<FileGridModel> store, Grid<FileGridModel> grid) {
long value = (Long) model.get(property);
if(value!=-1){
double kb = value/1024;
if(kb<1)
kb=1;
return "<span>" + number.format(kb) + "</span>";
}
};
return "";
}
};
size.setRenderer(kbRender);
type.setRenderer(folderRender);
GridCellRenderer<FileGridModel> kbRender = new GridCellRenderer<FileGridModel>() {
@Override
public String render(FileGridModel model, String property, ColumnData config, int rowIndex, int colIndex,
ListStore<FileGridModel> store, Grid<FileGridModel> grid) {
long value = (Long) model.get(property);
//
if (value != -1) {
String theSize = SizeUtil.readableFileSize(value);
return "<span>" + theSize + "</span>";
}
return "";
}
};
//setAlphanumericStoreSorter(grid);
size.setRenderer(kbRender);
type.setRenderer(folderRender);
GridFilters filters = new GridFilters();
filters.setLocal(true);
@ -186,17 +176,16 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
ModelData target = se.getSelectedItem();
if(target!=null){
if (target != null) {
currentItemSelected = (FileGridModel) target;
boolean isMultiselection = false;
if(se.getSelection()!=null && se.getSelection().size()>1)
if (se.getSelection() != null && se.getSelection().size() > 1)
isMultiselection = true;
AppController.getEventBus().fireEvent(new GridElementSelectedEvent(target, isMultiselection));
}
else{
} else {
currentItemSelected = null;
AppController.getEventBus().fireEvent(new GridElementUnSelectedEvent());
}
@ -204,7 +193,6 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
}
});
grid.addListener(Events.RowDoubleClick, new Listener<BaseEvent>() {
@Override
@ -212,39 +200,40 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
FileGridModel fileModel = grid.getSelectionModel().getSelectedItem();
if(fileModel!=null)
if (fileModel != null)
fireEventByFileModelType(fileModel);
// if(fileModel.isDirectory())
// AppController.getEventBus().fireEvent(new DoubleClickElementSelectedEvent(fileModel));
// if(fileModel.isDirectory())
// AppController.getEventBus().fireEvent(new
// DoubleClickElementSelectedEvent(fileModel));
}
});
});
grid.setContextMenu(null); //add context menu null - ignore browse event right click
grid.setContextMenu(null); // add context menu null - ignore browse event right click
grid.addListener(Events.OnContextMenu, new Listener<GridEvent<FileGridModel>>(){
grid.addListener(Events.OnContextMenu, new Listener<GridEvent<FileGridModel>>() {
@Override
public void handleEvent(GridEvent<FileGridModel> be)
{
public void handleEvent(GridEvent<FileGridModel> be) {
if(be.isRightClick()){
if (be.isRightClick()) {
List<FileGridModel> selection = grid.getSelectionModel().getSelection();
if(selection!=null && selection.size()>0){
List<FileGridModel> selection = grid.getSelectionModel().getSelection();
if (selection != null && selection.size() > 0) {
// if(grid.getSelectionModel().getSelection().size()>1){
// new InfoDisplay("Info", "The context menu is not available if multi-select is active");
// return;
// }
List<FileModel> selected = new ArrayList<FileModel>(selection.size());
for (FileGridModel fileGridModel : selection) {
selected.add(fileGridModel);
List<FileModel> selected = new ArrayList<FileModel>(selection.size());
for (FileGridModel fileGridModel : selection) {
selected.add(fileGridModel);
}
//List<FileGridModel> selectedItems = grid.getSelectionModel().getSelectedItems();
AppController.getEventBus().fireEvent(new OpenContextMenuTreeEvent(selected, be.getClientX(), be.getClientY()));
}
}
// List<FileGridModel> selectedItems =
// grid.getSelectionModel().getSelectedItems();
AppController.getEventBus()
.fireEvent(new OpenContextMenuTreeEvent(selected, be.getClientX(), be.getClientY()));
}
}
}
});
@ -281,7 +270,7 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
if (groupingStore != null) {
groupingStore.groupBy(FileGridModel.HUMAN_REDABLE_CATEGORY);
}
this.groupingEnabled = true;
this.groupingEnabled = true;
}
}
@ -290,19 +279,18 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
*
* @param target the target
*/
private void fireEventByFileModelType(FileModel target){
private void fireEventByFileModelType(FileModel target) {
if(target.isDirectory()){
if (target.isDirectory()) {
AppController.getEventBus().fireEvent(new DoubleClickElementSelectedEvent(target));
return;
}
switch(target.getGXTFolderItemType()){
switch (target.getGXTFolderItemType()) {
case EXTERNAL_IMAGE:
case IMAGE_DOCUMENT:
AppController.getEventBus().fireEvent(new ImagePreviewEvent(target,0, 0));
AppController.getEventBus().fireEvent(new ImagePreviewEvent(target, 0, 0));
break;
case EXTERNAL_FILE:
case EXTERNAL_PDF_FILE:
@ -311,7 +299,8 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
case URL_DOCUMENT:
case EXTERNAL_RESOURCE_LINK:
AppController.getEventBus().fireEvent(new FileDownloadEvent(target.getIdentifier(), target.getName(), DownloadType.SHOW, target.isDirectory() || target.isVreFolder(), null));
AppController.getEventBus().fireEvent(new FileDownloadEvent(target.getIdentifier(), target.getName(),
DownloadType.SHOW, target.isDirectory() || target.isVreFolder(), null));
break;
case EXTERNAL_URL:
AppController.getEventBus().fireEvent(new ShowUrlEvent(target));
@ -327,27 +316,26 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
}
/**
* Reset store.
*/
private void resetStore(){
private void resetStore() {
store.removeAll();
}
/**
* Update store.
*
* @param result the result
* @return true, if successful
*/
public boolean updateStore(List<FileGridModel> result){
public boolean updateStore(List<FileGridModel> result) {
resetStore();
if(result!= null && result.size()>0){
for(FileGridModel file: result){
//GWT.log("File: "+file.getName() + " has sync: "+file.getSynchedThreddsStatus());
if (result != null && result.size() > 0) {
for (FileGridModel file : result) {
// GWT.log("File: "+file.getName() + " has sync:
// "+file.getSynchedThreddsStatus());
file.setIcon();
}
store.add(result);
@ -356,16 +344,15 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
return false;
}
/**
* Adds the to store.
*
* @param result the result
* @return true, if successful
*/
public boolean addToStore(FileGridModel result){
public boolean addToStore(FileGridModel result) {
if(result!= null){
if (result != null) {
result.setIcon();
store.add(result);
return true;
@ -378,7 +365,7 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
*
* @return the selected item
*/
public FileGridModel getSelectedItem(){
public FileGridModel getSelectedItem() {
return currentItemSelected;
}
@ -388,7 +375,7 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
*
* @return the selected items
*/
public List<FileGridModel> getSelectedItems(){
public List<FileGridModel> getSelectedItems() {
return grid.getSelectionModel().getSelection();
}
@ -398,9 +385,9 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
*
* @return the ids selected items
*/
public List<String> getIdsSelectedItems(){
public List<String> getIdsSelectedItems() {
if(grid.getSelectionModel().getSelection()!=null){
if (grid.getSelectionModel().getSelection() != null) {
List<String> ids = new ArrayList<String>();
for (FileModel file : grid.getSelectionModel().getSelection()) {
@ -421,22 +408,18 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
*/
public boolean deleteItem(String identifier) {
FileGridModel fileTarget = getFileGridModelByIdentifier(identifier);
FileGridModel fileTarget = getFileGridModelByIdentifier(identifier);
if(fileTarget!=null){
if (fileTarget != null) {
Record record = store.getRecord(fileTarget);
store.remove((FileGridModel) record.getModel());
return true;
}
else
System.out.println("Delete Error: file target with " + identifier + " identifier not exist in store" );
} else
System.out.println("Delete Error: file target with " + identifier + " identifier not exist in store");
return false;
}
/**
* Gets the current folder view.
*
@ -446,7 +429,6 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
return currentFolderView;
}
/**
* Sets the current folder view.
*
@ -456,35 +438,32 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
this.currentFolderView = currentFolderView;
}
/**
* Rename item.//
*
* @param itemIdentifier the item identifier
* @param newName the new name
* @param extension the extension
* @param newName the new name
* @param extension the extension
* @return true, if successful
*/
public boolean renameItem(String itemIdentifier, String newName, String extension) {
if(itemIdentifier!=null){
FileGridModel fileTarget = getFileGridModelByIdentifier(itemIdentifier);
if(fileTarget!=null){
if (itemIdentifier != null) {
FileGridModel fileTarget = getFileGridModelByIdentifier(itemIdentifier);
if (fileTarget != null) {
Record record = store.getRecord(fileTarget);
if(record!=null){
if(extension!= null)
record.set(FileGridModel.NAME, newName+extension);
if (record != null) {
if (extension != null)
record.set(FileGridModel.NAME, newName + extension);
else
record.set(FileGridModel.NAME, newName);
return true;
}
}
else
System.out.println("Record Error: file target not exist in store" );
}
else
System.out.println("Rename Error: file target is null" );
} else
System.out.println("Record Error: file target not exist in store");
} else
System.out.println("Rename Error: file target is null");
return false;
@ -496,7 +475,7 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
* @param id the id
* @return the file grid model by identifier
*/
public FileGridModel getFileGridModelByIdentifier(String id){
public FileGridModel getFileGridModelByIdentifier(String id) {
return store.findModel(FileGridModel.IDENTIFIER, id);
}
@ -506,13 +485,13 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
* @param id the id
* @return true, if successful
*/
public boolean selectItemByFileModelId(String id){
public boolean selectItemByFileModelId(String id) {
if(id!=null && !id.isEmpty()){
if (id != null && !id.isEmpty()) {
FileGridModel fileModel = getFileGridModelByIdentifier(id);
if(fileModel!=null){
if (fileModel != null) {
grid.getSelectionModel().select(fileModel, true);
return true;
}
@ -521,29 +500,27 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
return false;
}
/**
* Gets the store.
*
* @return the store
*/
public GroupingStore<FileGridModel> getStore(){
public GroupingStore<FileGridModel> getStore() {
return store;
}
/**
* Sets the border as on search.
*percentulae in java
* Sets the border as on search. percentulae in java
*
* @param bool the new border as on search
*/
public void setBorderAsOnSearch(boolean bool){
public void setBorderAsOnSearch(boolean bool) {
if(this.cp.getElement("body")!=null){
if (this.cp.getElement("body") != null) {
if(bool){
if (bool) {
this.cp.getElement("body").getStyle().setBorderColor("#32CD32");
}
else
} else
this.cp.getElement("body").getStyle().setBorderColor("#99BBE8");
}
@ -552,9 +529,9 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
/**
* Adds the data changed store listener.
*/
private void addDataChangedStoreListener(){
private void addDataChangedStoreListener() {
store.addListener(Store.Add, new Listener<StoreEvent<ModelData>>(){
store.addListener(Store.Add, new Listener<StoreEvent<ModelData>>() {
@Override
public void handleEvent(StoreEvent<ModelData> be) {
@ -563,7 +540,7 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
}
});
store.addListener(Store.Remove, new Listener<StoreEvent<ModelData>>(){
store.addListener(Store.Remove, new Listener<StoreEvent<ModelData>>() {
@Override
public void handleEvent(StoreEvent<ModelData> be) {
@ -572,7 +549,7 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
}
});
store.addListener(Store.Clear, new Listener<StoreEvent<ModelData>>(){
store.addListener(Store.Clear, new Listener<StoreEvent<ModelData>>() {
@Override
public void handleEvent(StoreEvent<ModelData> be) {
@ -588,9 +565,9 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
*
* @return -1 if store is null. The size otherwise
*/
private int storeSize(){
private int storeSize() {
if(store!=null && store.getModels()!=null){
if (store != null && store.getModels() != null) {
return store.getModels().size();
}
@ -600,40 +577,34 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
/**
* Refresh size.
*
* @param width the width
* @param width the width
* @param height the height
*/
public void refreshSize(String width, String height) {
// if(this.isRendered()){
// GWT.log("refresh size grid "+height);
// this.setHeight(height);
// }
GWT.log("refresh size grid "+width +"; heigth: "+height);
GWT.log("refresh size grid " + width + "; heigth: " + height);
this.setSize(width, height);
cp.setSize(width, height);
grid.setWidth(width);
int theWidth = Integer.parseInt(width.replace("px", ""));
GWT.log("theWidth is "+theWidth);
for (int i=1; i<cm.getColumnCount(); i++) {
GWT.log("theWidth is " + theWidth);
for (int i = 1; i < cm.getColumnCount(); i++) {
ColumnConfig col = cm.getColumn(i);
int percent;
if(i==1) {
percent = theWidth*30/100;
//GWT.log("i is: "+i+" percent is "+percent);
if (i == 1) {
percent = theWidth * 30 / 100;
// GWT.log("i is: "+i+" percent is "+percent);
col.setWidth(percent);
}else if (i==cm.getColumnCount()-1){
percent = theWidth*10/100;
//GWT.log("i is last column: "+i+" percent is "+percent);
} else if (i == cm.getColumnCount() - 1) {
percent = theWidth * 10 / 100;
// GWT.log("i is last column: "+i+" percent is "+percent);
col.setWidth(percent);
}else {
percent = theWidth*20/100;
//GWT.log("i is: "+i+" percent is "+percent);
} else {
percent = theWidth * 20 / 100;
// GWT.log("i is: "+i+" percent is "+percent);
col.setWidth(percent);
}
}
//cp.layout(true);
//this.layout(true);
}
}
Loading…
Cancel
Save