@ -52,7 +52,7 @@ import com.extjs.gxt.ui.client.widget.toolbar.ToolBar;
* The Class MultiDragContact .
*
* @author Francesco Mangiacrapa francesco . mangiacrapa { @literal @ } isti . cnr . it
* Jun 1 , 2016
* Jun 1 , 2016
* /
public class MultiDragContact extends Dialog {
@ -66,10 +66,10 @@ public class MultiDragContact extends Dialog {
private static final int HEIGHT_CONTAINER_TEXT_AREA = 72 ;
private static final int HEIGHT_TEXT_AREA = 55 ;
private static final int WIDTH_CP = 597 ;
// private static final int HEIGHT_DIALOG = 542;
// private static final int HEIGHT_DIALOG = 542;
private static final int HEIGHT_DIALOG = 580 ;
private static final int WIDTH_DIALOG = 630 ;
// private static final int WIDTH_DIALOG = 625;
// private static final int WIDTH_DIALOG = 625;
private static final int HEIGHT_GRID = 310 ;
private GridDropTarget dropSource ;
@ -85,262 +85,260 @@ public class MultiDragContact extends Dialog {
private Button buttonAllRight ;
private Button buttonAllLeft ;
/ * *
* Instantiates a new multi drag contact .
* /
public MultiDragContact ( ) {
setStyleAttribute ( "margin" , "10px" ) ;
setSize ( WIDTH_DIALOG , HEIGHT_DIALOG ) ;
setHeading ( "Group dragging contacts" ) ;
setResizable ( false ) ;
setMaximizable ( false ) ;
setIcon ( Resources . getIconUsers ( ) ) ;
setModal ( true ) ;
setScrollMode ( Scroll . AUTOY ) ;
setBodyStyle ( "padding: 9px; background: none" ) ;
setResizable ( true ) ;
setButtonAlign ( HorizontalAlignment . CENTER ) ;
setButtons ( Dialog . OKCANCEL ) ;
//SORTING STORE
setGropUserStoreSorter ( storeSource ) ;
setGropUserStoreSorter ( storeTarget ) ;
ContentPanel cpAlreadyShared = new ContentPanel ( ) ;
cpAlreadyShared . setSize ( WIDTH_CP , HEIGHT_CONTAINER_TEXT_AREA ) ;
cpAlreadyShared . setHeaderVisible ( false ) ;
cpAlreadyShared . setLayout ( new FitLayout ( ) ) ;
VerticalPanel vpShared = new VerticalPanel ( ) ;
vpShared . setVerticalAlign ( VerticalAlignment . MIDDLE ) ;
vpShared . setHorizontalAlign ( HorizontalAlignment . CENTER ) ;
vpShared . setStyleAttribute ( "padding" , "5px" ) ;
vpShared . setLayout ( new FitLayout ( ) ) ;
HorizontalPanel hpSharedContacts = new HorizontalPanel ( ) ;
hpSharedContacts . setHorizontalAlign ( HorizontalAlignment . CENTER ) ;
hpSharedContacts . setVerticalAlign ( VerticalAlignment . MIDDLE ) ;
textAreaAlreadyShared = new TextArea ( ) ;
// textField.setFieldLabel("Already shared with");
// textField.setHeight(30);
textAreaAlreadyShared . setWidth ( 501 ) ;
textAreaAlreadyShared . setHeight ( HEIGHT_TEXT_AREA ) ;
cpAlreadyShared . setStyleAttribute ( "padding-bottom" , "5px" ) ;
textAreaAlreadyShared . setReadOnly ( true ) ;
cpAlreadyShared . add ( textAreaAlreadyShared ) ;
Label label = new Label ( "Already shared with" ) ;
label . setStyleAttribute ( "padding-right" , "10px" ) ;
label . setStyleAttribute ( "font-size" , "12px" ) ;
hpSharedContacts . add ( label ) ;
hpSharedContacts . add ( textAreaAlreadyShared ) ;
vpShared . add ( hpSharedContacts ) ;
cpAlreadyShared . add ( vpShared ) ;
add ( cpAlreadyShared ) ;
final ContentPanel cp = new ContentPanel ( ) ;
cp . setSize ( WIDTH_CP , HEIGHT_CONTAINER_GRID ) ;
cp . setHeaderVisible ( false ) ;
cp . setLayout ( new RowLayout ( Orientation . HORIZONTAL ) ) ;
ToolBar toolBar = new ToolBar ( ) ;
Button buttonHelp = new Button ( ) ;
buttonHelp . setIcon ( Resources . getIconInfo ( ) ) ;
buttonHelp . addSelectionListener ( new SelectionListener < ButtonEvent > ( ) {
@Override
public void componentSelected ( ButtonEvent ce ) {
MessageBox . info ( "Group dragging action" , "Drag one or more contacts from the left (All Contacts) to the right (Share with) to add users in your sharing list." , null ) ;
}
} ) ;
/ * *
* Instantiates a new multi drag contact .
* /
public MultiDragContact ( ) {
setStyleAttribute ( "margin" , "10px" ) ;
setSize ( WIDTH_DIALOG , HEIGHT_DIALOG ) ;
setHeading ( "Group dragging contacts" ) ;
setResizable ( false ) ;
setMaximizable ( false ) ;
setIcon ( Resources . getIconUsers ( ) ) ;
setModal ( true ) ;
setScrollMode ( Scroll . AUTOY ) ;
setBodyStyle ( "padding: 9px; background: none" ) ;
setResizable ( true ) ;
setButtonAlign ( HorizontalAlignment . CENTER ) ;
setButtons ( Dialog . OKCANCEL ) ;
// SORTING STORE
setGropUserStoreSorter ( storeSource ) ;
setGropUserStoreSorter ( storeTarget ) ;
ContentPanel cpAlreadyShared = new ContentPanel ( ) ;
cpAlreadyShared . setSize ( WIDTH_CP , HEIGHT_CONTAINER_TEXT_AREA ) ;
cpAlreadyShared . setHeaderVisible ( false ) ;
cpAlreadyShared . setLayout ( new FitLayout ( ) ) ;
VerticalPanel vpShared = new VerticalPanel ( ) ;
vpShared . setVerticalAlign ( VerticalAlignment . MIDDLE ) ;
vpShared . setHorizontalAlign ( HorizontalAlignment . CENTER ) ;
vpShared . setStyleAttribute ( "padding" , "5px" ) ;
vpShared . setLayout ( new FitLayout ( ) ) ;
HorizontalPanel hpSharedContacts = new HorizontalPanel ( ) ;
hpSharedContacts . setHorizontalAlign ( HorizontalAlignment . CENTER ) ;
hpSharedContacts . setVerticalAlign ( VerticalAlignment . MIDDLE ) ;
textAreaAlreadyShared = new TextArea ( ) ;
// textField.setFieldLabel("Already shared with");
// textField.setHeight(30);
textAreaAlreadyShared . setWidth ( 501 ) ;
textAreaAlreadyShared . setHeight ( HEIGHT_TEXT_AREA ) ;
cpAlreadyShared . setStyleAttribute ( "padding-bottom" , "5px" ) ;
textAreaAlreadyShared . setReadOnly ( true ) ;
cpAlreadyShared . add ( textAreaAlreadyShared ) ;
Label label = new Label ( "Already shared with" ) ;
label . setStyleAttribute ( "padding-right" , "10px" ) ;
label . setStyleAttribute ( "font-size" , "12px" ) ;
hpSharedContacts . add ( label ) ;
hpSharedContacts . add ( textAreaAlreadyShared ) ;
vpShared . add ( hpSharedContacts ) ;
cpAlreadyShared . add ( vpShared ) ;
add ( cpAlreadyShared ) ;
final ContentPanel cp = new ContentPanel ( ) ;
cp . setSize ( WIDTH_CP , HEIGHT_CONTAINER_GRID ) ;
cp . setHeaderVisible ( false ) ;
cp . setLayout ( new RowLayout ( Orientation . HORIZONTAL ) ) ;
ToolBar toolBar = new ToolBar ( ) ;
Button buttonHelp = new Button ( ) ;
buttonHelp . setIcon ( Resources . getIconInfo ( ) ) ;
buttonHelp . addSelectionListener ( new SelectionListener < ButtonEvent > ( ) {
toolBar . add ( buttonHelp ) ;
setTopComponent ( toolBar ) ;
@Override
public void componentSelected ( ButtonEvent ce ) {
MessageBox . info ( "Group dragging action" ,
"Drag one or more contacts from the left (All Contacts) to the right (Share with) to add users in your sharing list." ,
null ) ;
final VerticalPanel vpAllContacts = new VerticalPanel ( ) ;
vpAllContacts . setHorizontalAlign ( HorizontalAlignment . CENTER ) ;
vpAllContacts . add ( new Label ( "All Contacts" ) ) ;
}
} ) ;
gridAllContacts = new Grid < ExtendedInfoContactModel > ( storeSource , createColumnModel ( ) ) ;
toolBar . add ( buttonHelp ) ;
setTopComponent ( toolBar ) ;
final VerticalPanel vpAllContacts = new VerticalPanel ( ) ;
vpAllContacts . setHorizontalAlign ( HorizontalAlignment . CENTER ) ;
vpAllContacts . add ( new Label ( "All Contacts" ) ) ;
GridCellRenderer < ExtendedInfoContactModel > displayNameCellRender = new GridCellRenderer < ExtendedInfoContactModel > ( ) {
public String render ( ExtendedInfoContactModel model , String property , ColumnData config , int rowIndex , int colIndex , ListStore < ExtendedInfoContactModel > store , Grid < ExtendedInfoContactModel > grid ) {
gridAllContacts = new Grid < ExtendedInfoContactModel > ( storeSource , createColumnModel ( ) ) ;
if ( model ! = null ) {
GridCellRenderer < ExtendedInfoContactModel > displayNameCellRender = new GridCellRenderer < ExtendedInfoContactModel > ( ) {
public String render ( ExtendedInfoContactModel model , String property , ColumnData config , int rowIndex ,
int colIndex , ListStore < ExtendedInfoContactModel > store , Grid < ExtendedInfoContactModel > grid ) {
String value = model . get ( property ) ;
if ( value ! = null ) {
return "<span qtitle='' qtip='" + model . getLogin ( ) + "'>" + value + "</span>" ;
}
}
if ( model ! = null ) {
return "" ;
}
} ;
String value = model . get ( property ) ;
if ( value ! = null ) {
return "<span qtitle='' qtip='" + model . getLogin ( ) + "'>" + value + "</span>" ;
}
}
columnConfigDisplayName . setRenderer ( displayNameCellRender ) ;
return "" ;
}
} ;
storeSource . setDefaultSort ( InfoContactModel . FULLNAME , SortDir . ASC ) ;
storeSource . sort ( InfoContactModel . FULLNAME , SortDir . ASC ) ;
columnConfigDisplayName . setRenderer ( displayNameCellRender ) ;
storeTarget . setDefaultSort ( InfoContactModel . FULLNAME , SortDir . ASC ) ;
storeTarget . sort ( InfoContactModel . FULLNAME , SortDir . ASC ) ;
storeSource . setDefaultSort ( InfoContactModel . FULLNAME , SortDir . ASC ) ;
storeSource . sort ( InfoContactModel . FULLNAME , SortDir . ASC ) ;
storeTarget . setDefaultSort ( InfoContactModel . FULLNAME , SortDir . ASC ) ;
storeTarget . sort ( InfoContactModel . FULLNAME , SortDir . ASC ) ;
final StoreFilterField < ExtendedInfoContactModel > filter = new StoreFilterField < ExtendedInfoContactModel > ( ) {
final StoreFilterField < ExtendedInfoContactModel > filter = new StoreFilterField < ExtendedInfoContactModel > ( ) {
@Override
protected boolean doSelect ( Store < ExtendedInfoContactModel > store ,
ExtendedInfoContactModel parent , ExtendedInfoContactModel record ,
String property , String filter ) {
@Override
protected boolean doSelect ( Store < ExtendedInfoContactModel > store , ExtendedInfoContactModel parent ,
ExtendedInfoContactModel record , String property , String filter ) {
String name = record . getName ( ) ;
name = name . toLowerCase ( ) ;
if ( name . contains ( filter . toLowerCase ( ) ) ) {
return true ;
String name = record . getName ( ) ;
name = name . toLowerCase ( ) ;
if ( name . contains ( filter . toLowerCase ( ) ) ) {
return true ;
}
return false ;
}
return false ;
}
} ;
} ;
filter . setEmptyText ( "Filter All Contacts" ) ;
HorizontalPanel hp = new HorizontalPanel ( ) ;
hp . setStyleAttribute ( "padding-top" , "5px" ) ;
hp . setStyleAttribute ( "padding-bottom" , "5px" ) ;
hp . add ( filter ) ;
filter . bind ( storeSource ) ;
filter . setEmptyText ( "Filter All Contacts" ) ;
HorizontalPanel hp = new HorizontalPanel ( ) ;
hp . setStyleAttribute ( "padding-top" , "5px" ) ;
hp . setStyleAttribute ( "padding-bottom" , "5px" ) ;
hp . add ( filter ) ;
filter . bind ( storeSource ) ;
gridAllContacts . setHeight ( HEIGHT_GRID ) ;
gridAllContacts . setBorders ( false ) ;
gridAllContacts . getView ( ) . setAutoFill ( true ) ;
gridAllContacts . setBorders ( true ) ;
gridAllContacts . setHeight ( HEIGHT_GRID ) ;
gridAllContacts . setBorders ( false ) ;
gridAllContacts . getView ( ) . setAutoFill ( true ) ;
gridAllContacts . setBorders ( true ) ;
vpAllContacts . add ( hp ) ;
vpAllContacts . add ( gridAllContacts ) ;
vpAllContacts . add ( hp ) ;
vpAllContacts . add ( gridAllContacts ) ;
RowData rowData = new RowData ( .4 , 1 ) ;
rowData . setMargins ( new Margins ( 6 ) ) ;
cp . add ( vpAllContacts , rowData ) ;
RowData rowData = new RowData ( .4 , 1 ) ;
rowData . setMargins ( new Margins ( 6 ) ) ;
cp . add ( vpAllContacts , rowData ) ;
rowData = new RowData ( .2 , 1 ) ;
rowData . setMargins ( new Margins ( 6 ) ) ;
LayoutContainer lc = createMoveContactsContainer ( ) ;
cp . add ( lc , rowData ) ;
rowData = new RowData ( .2 , 1 ) ;
rowData . setMargins ( new Margins ( 6 ) ) ;
LayoutContainer lc = createMoveContactsContainer ( ) ;
cp . add ( lc , rowData ) ;
rowData = new RowData ( .4 , 1 ) ;
rowData . setMargins ( new Margins ( 6 , 6 , 6 , 0 ) ) ;
rowData = new RowData ( .4 , 1 ) ;
rowData . setMargins ( new Margins ( 6 , 6 , 6 , 0 ) ) ;
final VerticalPanel vpShareWith = new VerticalPanel ( ) ;
vpShareWith . setHorizontalAlign ( HorizontalAlignment . CENTER ) ;
vpShareWith . add ( new Label ( "Share with..." ) ) ;
gridShareWith = new Grid < ExtendedInfoContactModel > ( storeTarget , createColumnModel ( ) ) ;
final VerticalPanel vpShareWith = new VerticalPanel ( ) ;
vpShareWith . setHorizontalAlign ( HorizontalAlignment . CENTER ) ;
vpShareWith . add ( new Label ( "Share with..." ) ) ;
gridShareWith = new Grid < ExtendedInfoContactModel > ( storeTarget , createColumnModel ( ) ) ;
final StoreFilterField < ExtendedInfoContactModel > filter2 = new StoreFilterField < ExtendedInfoContactModel > ( ) {
final StoreFilterField < ExtendedInfoContactModel > filter2 = new StoreFilterField < ExtendedInfoContactModel > ( ) {
@Override
protected boolean doSelect ( Store < ExtendedInfoContactModel > store ,
ExtendedInfoContactModel parent , ExtendedInfoContactModel record ,
String property , String filter ) {
@Override
protected boolean doSelect ( Store < ExtendedInfoContactModel > store , ExtendedInfoContactModel parent ,
ExtendedInfoContactModel record , String property , String filter ) {
String name = record . getName ( ) ;
name = name . toLowerCase ( ) ;
if ( name . contains ( filter . toLowerCase ( ) ) ) {
return true ;
String name = record . getName ( ) ;
name = name . toLowerCase ( ) ;
if ( name . contains ( filter . toLowerCase ( ) ) ) {
return true ;
}
return false ;
}
return false ;
}
} ;
} ;
filter2 . setEmptyText ( "Filter Share with" ) ;
filter2 . setEmptyText ( "Filter Share with" ) ;
hp = new HorizontalPanel ( ) ;
hp . setStyleAttribute ( "padding-top" , "5px" ) ;
hp . setStyleAttribute ( "padding-bottom" , "5px" ) ;
hp . add ( filter2 ) ;
filter2 . bind ( storeTarget ) ;
hp = new HorizontalPanel ( ) ;
hp . setStyleAttribute ( "padding-top" , "5px" ) ;
hp . setStyleAttribute ( "padding-bottom" , "5px" ) ;
hp . add ( filter2 ) ;
filter2 . bind ( storeTarget ) ;
gridShareWith . setHeight ( HEIGHT_GRID ) ;
gridShareWith . setBorders ( false ) ;
gridShareWith . getView ( ) . setAutoFill ( true ) ;
// gridShareWith.setAutoExpandColumn(InfoContactModel.FULLNAME);
gridShareWith . setBorders ( true ) ;
vpShareWith . add ( hp ) ;
vpShareWith . add ( gridShareWith ) ;
gridShareWith . setHeight ( HEIGHT_GRID ) ;
gridShareWith . setBorders ( false ) ;
gridShareWith . getView ( ) . setAutoFill ( true ) ;
// gridShareWith.setAutoExpandColumn(InfoContactModel.FULLNAME);
gridShareWith . setBorders ( true ) ;
vpShareWith . add ( hp ) ;
vpShareWith . add ( gridShareWith ) ;
cp . add ( vpShareWith , rowData ) ;
cp . add ( vpShareWith , rowData ) ;
new GridDragSource ( gridAllContacts ) ;
new GridDragSource ( gridShareWith ) ;
new GridDragSource ( gridAllContacts ) ;
new GridDragSource ( gridShareWith ) ;
dropSource = new GridDropTarget ( gridAllContacts ) ;
dropSource . setAllowSelfAsSource ( false ) ;
dropSource = new GridDropTarget ( gridAllContacts ) ;
dropSource . setAllowSelfAsSource ( false ) ;
dropTarget = new GridDropTarget ( gridShareWith ) ;
dropTarget . setAllowSelfAsSource ( false ) ;
dropTarget = new GridDropTarget ( gridShareWith ) ;
dropTarget . setAllowSelfAsSource ( false ) ;
add ( cp ) ;
add ( cp ) ;
this . getButtonById ( Dialog . CANCEL ) . addSelectionListener ( new SelectionListener < ButtonEvent > ( ) {
@Override
public void componentSelected ( ButtonEvent ce ) {
hide ( ) ;
}
} ) ;
this . getButtonById ( Dialog . CANCEL ) . addSelectionListener ( new SelectionListener < ButtonEvent > ( ) {
@Override
public void componentSelected ( ButtonEvent ce ) {
hide ( ) ;
}
} ) ;
this . getButtonById ( Dialog . OK ) . addSelectionListener ( new SelectionListener < ButtonEvent > ( ) {
this . getButtonById ( Dialog . OK ) . addSelectionListener ( new SelectionListener < ButtonEvent > ( ) {
@Override
public void componentSelected ( ButtonEvent ce ) {
List < ExtendedInfoContactModel > shareContacts = storeTarget . getModels ( ) ;
@Override
public void componentSelected ( ButtonEvent ce ) {
List < ExtendedInfoContactModel > shareContacts = storeTarget . getModels ( ) ;
if ( shareContacts = = null | | shareContacts . isEmpty ( ) ) {
if ( shareContacts = = null | | shareContacts . isEmpty ( ) ) {
MessageBoxConfirm mbc = new MessageBoxConfirm ( "Confirm exit?" , "You have not selected any contact to share, confirm exit?" ) ;
MessageBoxConfirm mbc = new MessageBoxConfirm ( "Confirm exit?" ,
"You have not selected any contact to share, confirm exit?" ) ;
mbc . getMessageBoxConfirm ( ) . addCallback ( new Listener < MessageBoxEvent > ( ) {
mbc . getMessageBoxConfirm ( ) . addCallback ( new Listener < MessageBoxEvent > ( ) {
@Override
public void handleEvent ( MessageBoxEvent be ) {
String clickedButton = be . getButtonClicked ( ) . getItemId ( ) ;
if ( clickedButton . equals ( Dialog . YES ) ) {
hide ( ) ;
@Override
public void handleEvent ( MessageBoxEvent be ) {
String clickedButton = be . getButtonClicked ( ) . getItemId ( ) ;
if ( clickedButton . equals ( Dialog . YES ) ) {
hide ( ) ;
}
}
}
} ) ;
} else
hide ( ) ;
}
} ) ;
// needed to enable quicktips (qtitle for the heading and qtip for the
// content) that are setup in the change GridCellRenderer
cp . addListener ( Events . Render , new Listener < BaseEvent > ( ) {
@Override
public void handleEvent ( BaseEvent be ) {
int width = gridAllContacts . getWidth ( ) ;
filter . setWidth ( width - 2 ) ;
filter2 . setWidth ( width - 2 ) ;
gridShareWith . setWidth ( width + 5 ) ;
vpShareWith . setWidth ( width + 15 ) ;
gridAllContacts . setWidth ( width + 5 ) ;
vpAllContacts . setWidth ( width + 15 ) ;
vpShareWith . layout ( ) ;
vpAllContacts . layout ( ) ;
cp . layout ( ) ;
}
} ) ;
} ) ;
} else
hide ( ) ;
}
} ) ;
// needed to enable quicktips (qtitle for the heading and qtip for the
// content) that are setup in the change GridCellRenderer
cp . addListener ( Events . Render , new Listener < BaseEvent > ( ) {
@Override
public void handleEvent ( BaseEvent be ) {
int width = gridAllContacts . getWidth ( ) ;
filter . setWidth ( width - 2 ) ;
filter2 . setWidth ( width - 2 ) ;
gridShareWith . setWidth ( width + 5 ) ;
vpShareWith . setWidth ( width + 15 ) ;
gridAllContacts . setWidth ( width + 5 ) ;
vpAllContacts . setWidth ( width + 15 ) ;
vpShareWith . layout ( ) ;
vpAllContacts . layout ( ) ;
cp . layout ( ) ;
}
} ) ;
new QuickTip ( gridAllContacts ) ;
}
new QuickTip ( gridAllContacts ) ;
}
/ * *
* Creates the move contacts container .
@ -357,94 +355,82 @@ public class MultiDragContact extends Dialog {
buttonSelectedLeft = new Button ( ) ;
buttonSelectedLeft . setIcon ( Resources . getSelectedLeft ( ) ) ;
buttonSelectedLeft
. setToolTip ( "Move selected contact/s from 'All Contact' to 'Share with'" ) ;
buttonSelectedLeft
. addSelectionListener ( new SelectionListener < ButtonEvent > ( ) {
buttonSelectedLeft . setToolTip ( "Move selected contact/s from 'All Contact' to 'Share with'" ) ;
buttonSelectedLeft . addSelectionListener ( new SelectionListener < ButtonEvent > ( ) {
@Override
public void componentSelected ( ButtonEvent ce ) {
@Override
public void componentSelected ( ButtonEvent ce ) {
List < ExtendedInfoContactModel > selectedItems = gridAllContacts
. getSelectionModel ( ) . getSelectedItems ( ) ;
List < ExtendedInfoContactModel > selectedItems = gridAllContacts . getSelectionModel ( ) . getSelectedItems ( ) ;
if ( selectedItems ! = null & & selectedItems . size ( ) > 0 ) {
if ( selectedItems ! = null & & selectedItems . size ( ) > 0 ) {
for ( ExtendedInfoContactModel extendedInfoContactModel : selectedItems ) {
storeTarget . add ( extendedInfoContactModel ) ;
storeSource . remove ( extendedInfoContactModel ) ;
}
}
for ( ExtendedInfoContactModel extendedInfoContactModel : selectedItems ) {
storeTarget . add ( extendedInfoContactModel ) ;
storeSource . remove ( extendedInfoContactModel ) ;
}
} ) ;
}
}
} ) ;
buttonSelectedRight = new Button ( ) ;
buttonSelectedRight . setIcon ( Resources . getSelectedRight ( ) ) ;
buttonSelectedRight
. setToolTip ( "Move selected contact/s from 'Share with' to 'All Contact'" ) ;
buttonSelectedRight . setToolTip ( "Move selected contact/s from 'Share with' to 'All Contact'" ) ;
buttonSelectedRight
. addSelectionListener ( new SelectionListener < ButtonEvent > ( ) {
buttonSelectedRight . addSelectionListener ( new SelectionListener < ButtonEvent > ( ) {
@Override
public void componentSelected ( ButtonEvent ce ) {
@Override
public void componentSelected ( ButtonEvent ce ) {
List < ExtendedInfoContactModel > selectedItems = gridShareWith
. getSelectionModel ( ) . getSelectedItems ( ) ;
List < ExtendedInfoContactModel > selectedItems = gridShareWith . getSelectionModel ( ) . getSelectedItems ( ) ;
if ( selectedItems ! = null & & selectedItems . size ( ) > 0 ) {
if ( selectedItems ! = null & & selectedItems . size ( ) > 0 ) {
for ( ExtendedInfoContactModel extendedInfoContactModel : selectedItems ) {
storeSource . add ( extendedInfoContactModel ) ;
storeTarget . remove ( extendedInfoContactModel ) ;
}
}
for ( ExtendedInfoContactModel extendedInfoContactModel : selectedItems ) {
storeSource . add ( extendedInfoContactModel ) ;
storeTarget . remove ( extendedInfoContactModel ) ;
}
} ) ;
}
}
} ) ;
buttonAllLeft = new Button ( ) ;
buttonAllLeft . setIcon ( Resources . getAllLeft ( ) ) ;
buttonAllLeft
. setToolTip ( "Move all contact/s from 'All Contact' to 'Share with'" ) ;
buttonAllLeft . setToolTip ( "Move all contact/s from 'All Contact' to 'Share with'" ) ;
buttonAllLeft
. addSelectionListener ( new SelectionListener < ButtonEvent > ( ) {
buttonAllLeft . addSelectionListener ( new SelectionListener < ButtonEvent > ( ) {
@Override
public void componentSelected ( ButtonEvent ce ) {
if ( storeSource ! = null & & storeSource . getCount ( ) > 0 ) {
for ( ExtendedInfoContactModel extendedInfoContactModel : storeSource
. getModels ( ) ) {
storeTarget . add ( extendedInfoContactModel ) ;
storeSource . remove ( extendedInfoContactModel ) ;
}
}
@Override
public void componentSelected ( ButtonEvent ce ) {
if ( storeSource ! = null & & storeSource . getCount ( ) > 0 ) {
for ( ExtendedInfoContactModel extendedInfoContactModel : storeSource . getModels ( ) ) {
storeTarget . add ( extendedInfoContactModel ) ;
storeSource . remove ( extendedInfoContactModel ) ;
}
} ) ;
}
}
} ) ;
buttonAllRight = new Button ( ) ;
buttonAllRight . setIcon ( Resources . getAllRight ( ) ) ;
buttonAllRight
. setToolTip ( "Move all contact/s from 'Share with' to 'All Contact'" ) ;
buttonAllRight . setToolTip ( "Move all contact/s from 'Share with' to 'All Contact'" ) ;
buttonAllRight
. addSelectionListener ( new SelectionListener < ButtonEvent > ( ) {
buttonAllRight . addSelectionListener ( new SelectionListener < ButtonEvent > ( ) {
@Override
public void componentSelected ( ButtonEvent ce ) {
if ( storeTarget ! = null & & storeTarget . getCount ( ) > 0 ) {
for ( ExtendedInfoContactModel extendedInfoContactModel : storeTarget
. getModels ( ) ) {
storeSource . add ( extendedInfoContactModel ) ;
storeTarget . remove ( extendedInfoContactModel ) ;
}
}
@Override
public void componentSelected ( ButtonEvent ce ) {
if ( storeTarget ! = null & & storeTarget . getCount ( ) > 0 ) {
for ( ExtendedInfoContactModel extendedInfoContactModel : storeTarget . getModels ( ) ) {
storeSource . add ( extendedInfoContactModel ) ;
storeTarget . remove ( extendedInfoContactModel ) ;
}
} ) ;
}
}
} ) ;
vp1 . add ( buttonSelectedLeft ) ;
vp1 . add ( buttonAllLeft ) ;
@ -468,175 +454,186 @@ public class MultiDragContact extends Dialog {
return lc ;
}
/ * *
* Creates the column model .
*
* @return the column model
* /
private ColumnModel createColumnModel ( ) {
List < ColumnConfig > configs = new ArrayList < ColumnConfig > ( ) ;
ColumnConfig icon = new ColumnConfig ( ExtendedInfoContactModel . ICON , "" , 25 ) ;
configs . add ( icon ) ;
columnConfigDisplayName = new ColumnConfig ( ExtendedInfoContactModel . FULLNAME , "Name" , 150 ) ;
configs . add ( columnConfigDisplayName ) ;
ColumnConfig type = new ColumnConfig ( ExtendedInfoContactModel . ISGROUP , "Type" , 50 ) ;
configs . add ( type ) ;
GridCellRenderer < ExtendedInfoContactModel > typeRender = new GridCellRenderer < ExtendedInfoContactModel > ( ) {
@Override
public String render ( ExtendedInfoContactModel model , String property , ColumnData config , int rowIndex , int colIndex , ListStore < ExtendedInfoContactModel > store , Grid < ExtendedInfoContactModel > grid ) {
Boolean isGroup = ( Boolean ) model . get ( property ) ;
String color = "#0F4FA8" ;
String val = "" ;
if ( isGroup ) {
val = "Group" ;
color = "#05316D" ;
return "<span style='font-weight: bold; color:" + color + "'>" + val + "</span>" ;
} else {
val = "User" ;
return "<span style='font-weight: bold; color:" + color + "'>" + val + "</span>" ;
}
/ * *
* Creates the column model .
*
* @return the column model
* /
private ColumnModel createColumnModel ( ) {
List < ColumnConfig > configs = new ArrayList < ColumnConfig > ( ) ;
ColumnConfig icon = new ColumnConfig ( ExtendedInfoContactModel . ICON , "" , 25 ) ;
configs . add ( icon ) ;
columnConfigDisplayName = new ColumnConfig ( ExtendedInfoContactModel . FULLNAME , "Name" , 150 ) ;
configs . add ( columnConfigDisplayName ) ;
ColumnConfig type = new ColumnConfig ( ExtendedInfoContactModel . ISGROUP , "Type" , 50 ) ;
configs . add ( type ) ;
GridCellRenderer < ExtendedInfoContactModel > typeRender = new GridCellRenderer < ExtendedInfoContactModel > ( ) {
@Override
public String render ( ExtendedInfoContactModel model , String property , ColumnData config , int rowIndex ,
int colIndex , ListStore < ExtendedInfoContactModel > store , Grid < ExtendedInfoContactModel > grid ) {
Boolean isGroup = ( Boolean ) model . get ( property ) ;
String color = "#0F4FA8" ;
String val = "" ;
if ( isGroup ) {
val = "Group" ;
color = "#05316D" ;
return "<span style='font-weight: bold; color:" + color + "'>" + val + "</span>" ;
} else {
val = "User" ;
return "<span style='font-weight: bold; color:" + color + "'>" + val + "</span>" ;
}
}
} ;
type . setRenderer ( typeRender ) ;
return new ColumnModel ( configs ) ;
}
/ * *
* Adds the source contacts .
*
* @param listContact
* the list contact
* /
public void addSourceContacts ( List < InfoContactModel > listContact ) {
gridAllContacts . mask ( "" , ConstantsExplorer . LOADINGSTYLE ) ;
if ( listContact ! = null & & listContact . size ( ) > 0 ) {
List < ExtendedInfoContactModel > listExtended = new ArrayList < ExtendedInfoContactModel > ( ) ;
// SETTING ICONS
for ( InfoContactModel infoContactModel : listContact ) {
ExtendedInfoContactModel ext = new ExtendedInfoContactModel ( infoContactModel . getId ( ) ,
infoContactModel . getLogin ( ) , infoContactModel . getName ( ) , infoContactModel . getEmailDomain ( ) ,
infoContactModel . isGroup ( ) ) ;
ext . setIcon ( ) ;
listExtended . add ( ext ) ;
}
storeSource . add ( listExtended ) ;
// GWT.log("Added sources: "+listExtended.toString());
}
gridAllContacts . unmask ( ) ;
gridAllContacts . repaint ( ) ;
}
/ * *
* Adds the already shared contacts .
*
* @param listContact
* the list contact
* /
public void addAlreadySharedContacts ( List < InfoContactModel > listContact ) {
gridShareWith . mask ( "" , ConstantsExplorer . LOADINGSTYLE ) ;
if ( listContact ! = null & & listContact . size ( ) > 0 ) {
String alreadyShared = "" ;
for ( int i = 0 ; i < listContact . size ( ) - 1 ; i + + )
alreadyShared + = listContact . get ( i ) . getName ( ) + ", " ;
alreadyShared + = listContact . get ( listContact . size ( ) - 1 ) . getName ( ) ;
textAreaAlreadyShared . setValue ( alreadyShared ) ;
}
gridShareWith . unmask ( ) ;
}
/ * *
* Adds the target contacts .
*
* @param listContact
* the list contact
* /
public void addTargetContacts ( List < InfoContactModel > listContact ) {
if ( listContact ! = null & & listContact . size ( ) > 0 ) {
storeTarget . add ( convertFromInfoContactModel ( listContact ) ) ;
}
}
/ * *
* Convert from info contact model .
*
* @param listContact
* the list contact
* @return the list
* /
private List < ExtendedInfoContactModel > convertFromInfoContactModel ( List < InfoContactModel > listContact ) {
if ( listContact ! = null ) {
List < ExtendedInfoContactModel > listExtended = new ArrayList < ExtendedInfoContactModel > ( listContact . size ( ) ) ;
// SETTING ICONS
for ( InfoContactModel infoContactModel : listContact ) {
listExtended . add ( convertFromInfoContactModel ( infoContactModel ) ) ;
}
return listExtended ;
}
return new ArrayList < ExtendedInfoContactModel > ( ) ;
}
/ * *
* Convert from info contact model .
*
* @param infoContactModel
* the info contact model
* @return the extended info contact model
* /
private ExtendedInfoContactModel convertFromInfoContactModel ( InfoContactModel infoContactModel ) {
if ( infoContactModel ! = null ) {
String fullName = infoContactModel . getName ( ) ;
if ( fullName = = null | | fullName . isEmpty ( ) )
fullName = infoContactModel . getLogin ( ) ;
ExtendedInfoContactModel ext = new ExtendedInfoContactModel ( infoContactModel . getId ( ) ,
infoContactModel . getLogin ( ) , fullName , infoContactModel . getEmailDomain ( ) ,
infoContactModel . isGroup ( ) ) ;
ext . setIcon ( ) ;
return ext ;
}
} ;
type . setRenderer ( typeRender ) ;
return new ColumnModel ( configs ) ;
}
/ * *
* Adds the source contacts .
*
* @param listContact the list contact
* /
public void addSourceContacts ( List < InfoContactModel > listContact ) {
gridAllContacts . mask ( "" , ConstantsExplorer . LOADINGSTYLE ) ;
if ( listContact ! = null & & listContact . size ( ) > 0 ) {
List < ExtendedInfoContactModel > listExtended = new ArrayList < ExtendedInfoContactModel > ( ) ;
//SETTING ICONS
for ( InfoContactModel infoContactModel : listContact ) {
ExtendedInfoContactModel ext = new ExtendedInfoContactModel ( infoContactModel . getId ( ) , infoContactModel . getLogin ( ) , infoContactModel . getName ( ) , infoContactModel . isGroup ( ) ) ;
ext . setIcon ( ) ;
listExtended . add ( ext ) ;
}
storeSource . add ( listExtended ) ;
// GWT.log("Added sources: "+listExtended.toString());
}
gridAllContacts . unmask ( ) ;
gridAllContacts . repaint ( ) ;
}
/ * *
* Adds the already shared contacts .
*
* @param listContact the list contact
* /
public void addAlreadySharedContacts ( List < InfoContactModel > listContact ) {
gridShareWith . mask ( "" , ConstantsExplorer . LOADINGSTYLE ) ;
if ( listContact ! = null & & listContact . size ( ) > 0 ) {
String alreadyShared = "" ;
for ( int i = 0 ; i < listContact . size ( ) - 1 ; i + + )
alreadyShared + = listContact . get ( i ) . getName ( ) + ", " ;
alreadyShared + = listContact . get ( listContact . size ( ) - 1 ) . getName ( ) ;
textAreaAlreadyShared . setValue ( alreadyShared ) ;
}
gridShareWith . unmask ( ) ;
}
/ * *
* Adds the target contacts .
*
* @param listContact the list contact
* /
public void addTargetContacts ( List < InfoContactModel > listContact ) {
if ( listContact ! = null & & listContact . size ( ) > 0 ) {
storeTarget . add ( convertFromInfoContactModel ( listContact ) ) ;
}
}
/ * *
* Convert from info contact model .
*
* @param listContact the list contact
* @return the list
* /
private List < ExtendedInfoContactModel > convertFromInfoContactModel ( List < InfoContactModel > listContact ) {
if ( listContact ! = null ) {
List < ExtendedInfoContactModel > listExtended = new ArrayList < ExtendedInfoContactModel > ( listContact . size ( ) ) ;
//SETTING ICONS
for ( InfoContactModel infoContactModel : listContact ) {
listExtended . add ( convertFromInfoContactModel ( infoContactModel ) ) ;
}
return listExtended ;
}
return new ArrayList < ExtendedInfoContactModel > ( ) ;
}
/ * *
* Convert from info contact model .
*
* @param infoContactModel the info contact model
* @return the extended info contact model
* /
private ExtendedInfoContactModel convertFromInfoContactModel ( InfoContactModel infoContactModel ) {
if ( infoContactModel ! = null ) {
String fullName = infoContactModel . getName ( ) ;
if ( fullName = = null | | fullName . isEmpty ( ) )
fullName = infoContactModel . getLogin ( ) ;
ExtendedInfoContactModel ext = new ExtendedInfoContactModel ( infoContactModel . getId ( ) , infoContactModel . getLogin ( ) , fullName , infoContactModel . isGroup ( ) ) ;
ext . setIcon ( ) ;
return ext ;
}
return new ExtendedInfoContactModel ( ) ;
}
/ * *
* Adds the target contact .
*
* @param contact the contact
* /
public void addTargetContact ( InfoContactModel contact ) {
if ( contact ! = null )
storeTarget . add ( convertFromInfoContactModel ( contact ) ) ;
}
/ * *
* Gets the target list contact .
*
* @return the target list contact
* /
public List < InfoContactModel > getTargetListContact ( ) {
List < ? extends InfoContactModel > infoContacts = storeTarget . getModels ( ) ;
return ( List < InfoContactModel > ) infoContacts ;
}
/ * *
* Sets the grop user store sorter .
*
* @param store the new grop user store sorter
* /
private void setGropUserStoreSorter ( ListStore < ExtendedInfoContactModel > store ) {
return new ExtendedInfoContactModel ( ) ;
}
/ * *
* Adds the target contact .
*
* @param contact
* the contact
* /
public void addTargetContact ( InfoContactModel contact ) {
if ( contact ! = null )
storeTarget . add ( convertFromInfoContactModel ( contact ) ) ;
}
/ * *
* Gets the target list contact .
*
* @return the target list contact
* /
public List < InfoContactModel > getTargetListContact ( ) {
List < ? extends InfoContactModel > infoContacts = storeTarget . getModels ( ) ;
return ( List < InfoContactModel > ) infoContacts ;
}
/ * *
* Sets the grop user store sorter .
*
* @param store
* the new grop user store sorter
* /
private void setGropUserStoreSorter ( ListStore < ExtendedInfoContactModel > store ) {
// Sorting files
store . setStoreSorter ( new StoreSorter < ExtendedInfoContactModel > ( ) {
store . setStoreSorter ( new StoreSorter < ExtendedInfoContactModel > ( ) {
@Override
public int compare ( Store < ExtendedInfoContactModel > store , ExtendedInfoContactModel m1 , ExtendedInfoContactModel m2 , String property ) {
public int compare ( Store < ExtendedInfoContactModel > store , ExtendedInfoContactModel m1 ,
ExtendedInfoContactModel m2 , String property ) {
boolean m1Folder = m1 . isGroup ( ) ;
boolean m2Folder = m2 . isGroup ( ) ;