@ -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,10 +50,8 @@ 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 .
*
@ -63,13 +61,11 @@ import com.google.gwt.user.client.Random;
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 ;
@ -87,15 +83,13 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
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 )
cm = new ColumnModel ( Arrays . asList ( icon , name , ownerFullName , type , lastUpdate , size , category ) ) ;
else
@ -122,30 +116,28 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
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 ) {
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>" ;
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 ) {
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>" ;
String theSize = SizeUtil . readableFileSize ( value ) ;
return "<span>" + theSize + "</span>" ;
}
return "" ;
}
} ;
@ -153,8 +145,6 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
size . setRenderer ( kbRender ) ;
type . setRenderer ( folderRender ) ;
//setAlphanumericStoreSorter(grid);
GridFilters filters = new GridFilters ( ) ;
filters . setLocal ( true ) ;
@ -195,8 +185,7 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
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
@ -215,18 +203,17 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
if ( fileModel ! = null )
fireEventByFileModelType ( fileModel ) ;
// if(fileModel.isDirectory())
// AppController.getEventBus().fireEvent(new DoubleClickElementSelectedEvent(fileModel));
// AppController.getEventBus().fireEvent(new
// DoubleClickElementSelectedEvent(fileModel));
}
} ) ;
grid . setContextMenu ( null ) ; // add context menu null - ignore browse event right click
grid . addListener ( Events . OnContextMenu , new Listener < GridEvent < FileGridModel > > ( ) {
@Override
public void handleEvent ( GridEvent < FileGridModel > be )
{
public void handleEvent ( GridEvent < FileGridModel > be ) {
if ( be . isRightClick ( ) ) {
@ -241,8 +228,10 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
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 ( ) ) ) ;
}
}
}
@ -297,7 +286,6 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
return ;
}
switch ( target . getGXTFolderItemType ( ) ) {
case EXTERNAL_IMAGE :
@ -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,7 +316,6 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
}
/ * *
* Reset store .
* /
@ -335,7 +323,6 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
store . removeAll ( ) ;
}
/ * *
* Update store .
*
@ -347,7 +334,8 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
resetStore ( ) ;
if ( result ! = null & & result . size ( ) > 0 ) {
for ( FileGridModel file : result ) {
//GWT.log("File: "+file.getName() + " has sync: "+file.getSynchedThreddsStatus());
// GWT.log("File: "+file.getName() + " has sync:
// "+file.getSynchedThreddsStatus());
file . setIcon ( ) ;
}
store . add ( result ) ;
@ -356,7 +344,6 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
return false ;
}
/ * *
* Adds the to store .
*
@ -427,16 +414,12 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
Record record = store . getRecord ( fileTarget ) ;
store . remove ( ( FileGridModel ) record . getModel ( ) ) ;
return true ;
}
else
} 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,7 +438,6 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
this . currentFolderView = currentFolderView ;
}
/ * *
* Rename item . //
*
@ -479,11 +460,9 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
return true ;
}
}
else
} else
System . out . println ( "Record Error: file target not exist in store" ) ;
}
else
} else
System . out . println ( "Rename Error: file target is null" ) ;
return false ;
@ -521,7 +500,6 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
return false ;
}
/ * *
* Gets the store .
*
@ -532,8 +510,8 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
}
/ * *
* 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 ) {
@ -542,8 +520,7 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
if ( bool ) {
this . cp . getElement ( "body" ) . getStyle ( ) . setBorderColor ( "#32CD32" ) ;
}
else
} else
this . cp . getElement ( "body" ) . getStyle ( ) . setBorderColor ( "#99BBE8" ) ;
}
@ -605,10 +582,6 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
* /
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 ) ;
this . setSize ( width , height ) ;
cp . setSize ( width , height ) ;
@ -632,8 +605,6 @@ public class GxtGridFilterGroupPanel extends LayoutContainer {
col . setWidth ( percent ) ;
}
}
//cp.layout(true);
//this.layout(true);
}
}