enhancements on sharing with groups
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-sharing-widget@97857 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
d275856fa3
commit
2788eb29ec
|
@ -1,5 +1,6 @@
|
|||
package org.gcube.portlets.widgets.workspacesharingwidget.client;
|
||||
|
||||
import org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.SmartShare;
|
||||
import org.gcube.portlets.widgets.workspacesharingwidget.shared.ACL_TYPE;
|
||||
|
||||
import com.extjs.gxt.ui.client.widget.Window;
|
||||
|
@ -22,8 +23,9 @@ public class WorkspaceSharingWidgetEntryPoint implements EntryPoint {
|
|||
public void onModuleLoad() {
|
||||
|
||||
try {
|
||||
|
||||
|
||||
WorkspaceSharingController controller = new WorkspaceSharingController(ITEMID, true, ACL_TYPE.READ_ONLY);
|
||||
/*WorkspaceSharingController controller = new WorkspaceSharingController(ITEMID, true, ACL_TYPE.READ_ONLY);
|
||||
|
||||
final Window sharingWindow = controller.getSharingDialog();
|
||||
|
||||
|
@ -36,6 +38,20 @@ public class WorkspaceSharingWidgetEntryPoint implements EntryPoint {
|
|||
});
|
||||
|
||||
RootPanel.get("workpacesharingwidget").add(openSharingWindow);
|
||||
|
||||
*/
|
||||
|
||||
final SmartShare smartShare = new SmartShare(false, true);
|
||||
|
||||
Button openSharingWindow = new Button("Show Smart Share Window",
|
||||
new ClickHandler() {
|
||||
public void onClick(ClickEvent event) {
|
||||
|
||||
smartShare.show();
|
||||
}
|
||||
});
|
||||
|
||||
RootPanel.get("workpacesharingwidget").add(openSharingWindow);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
@ -25,5 +25,17 @@ public interface Icons extends ClientBundle {
|
|||
|
||||
@Source("share.png")
|
||||
ImageResource share();
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
@Source("shareuser.png")
|
||||
ImageResource user();
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
@Source("sharegroup.png")
|
||||
ImageResource group();
|
||||
}
|
||||
|
||||
|
|
|
@ -45,5 +45,20 @@ public class Resources {
|
|||
public static AbstractImagePrototype getIconShare() {
|
||||
return AbstractImagePrototype.create(ICONS.share());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public static AbstractImagePrototype getIconUser() {
|
||||
return AbstractImagePrototype.create(ICONS.user());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public static AbstractImagePrototype getIconGroup() {
|
||||
return AbstractImagePrototype.create(ICONS.group());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 854 B |
Binary file not shown.
After Width: | Height: | Size: 760 B |
|
@ -18,6 +18,7 @@ import com.extjs.gxt.ui.client.event.ButtonEvent;
|
|||
import com.extjs.gxt.ui.client.event.SelectionListener;
|
||||
import com.extjs.gxt.ui.client.store.ListStore;
|
||||
import com.extjs.gxt.ui.client.store.Store;
|
||||
import com.extjs.gxt.ui.client.store.StoreSorter;
|
||||
import com.extjs.gxt.ui.client.util.Margins;
|
||||
import com.extjs.gxt.ui.client.widget.ContentPanel;
|
||||
import com.extjs.gxt.ui.client.widget.Dialog;
|
||||
|
@ -29,8 +30,10 @@ import com.extjs.gxt.ui.client.widget.button.Button;
|
|||
import com.extjs.gxt.ui.client.widget.form.StoreFilterField;
|
||||
import com.extjs.gxt.ui.client.widget.form.TextArea;
|
||||
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
|
||||
import com.extjs.gxt.ui.client.widget.grid.ColumnData;
|
||||
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
|
||||
import com.extjs.gxt.ui.client.widget.grid.Grid;
|
||||
import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer;
|
||||
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
|
||||
import com.extjs.gxt.ui.client.widget.layout.RowData;
|
||||
import com.extjs.gxt.ui.client.widget.layout.RowLayout;
|
||||
|
@ -57,6 +60,10 @@ public class MultiDragContact extends Dialog {
|
|||
setResizable(true);
|
||||
setButtonAlign(HorizontalAlignment.CENTER);
|
||||
setButtons(Dialog.OKCANCEL);
|
||||
//SORTING STORE
|
||||
setGropUserStoreSorter(storeSource);
|
||||
setGropUserStoreSorter(storeTarget);
|
||||
|
||||
|
||||
ContentPanel cpAlreadyShared = new ContentPanel();
|
||||
cpAlreadyShared.setSize(530, 60);
|
||||
|
@ -151,8 +158,9 @@ public class MultiDragContact extends Dialog {
|
|||
filter.bind(storeSource);
|
||||
|
||||
gridAllContacts.setSize(250,310);
|
||||
gridAllContacts.setBorders(false);
|
||||
gridAllContacts.setAutoExpandColumn(InfoContactModel.FULLNAME);
|
||||
gridAllContacts.setBorders(false);
|
||||
gridAllContacts.getView().setAutoFill(true);
|
||||
// gridAllContacts.setAutoExpandColumn(InfoContactModel.FULLNAME);
|
||||
gridAllContacts.setBorders(true);
|
||||
|
||||
vp.add(hp);
|
||||
|
@ -199,7 +207,8 @@ public class MultiDragContact extends Dialog {
|
|||
|
||||
gridShareWith.setSize(250, 310);
|
||||
gridShareWith.setBorders(false);
|
||||
gridShareWith.setAutoExpandColumn(InfoContactModel.FULLNAME);
|
||||
gridShareWith.getView().setAutoFill(true);
|
||||
// gridShareWith.setAutoExpandColumn(InfoContactModel.FULLNAME);
|
||||
gridShareWith.setBorders(true);
|
||||
vp.add(hp);
|
||||
vp.add(gridShareWith);
|
||||
|
@ -239,20 +248,49 @@ public class MultiDragContact extends Dialog {
|
|||
|
||||
private ColumnModel createColumnModel() {
|
||||
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
|
||||
|
||||
ColumnConfig column = new ColumnConfig();
|
||||
column.setId(InfoContactModel.FULLNAME);
|
||||
column.setHeader("Name");
|
||||
column.setWidth(200);
|
||||
configs.add(column);
|
||||
|
||||
// column = new ColumnConfig();
|
||||
// column.setId("symbol");
|
||||
// column.setHeader("Symbol");
|
||||
// column.setWidth(100);
|
||||
// configs.add(column);
|
||||
|
||||
return new ColumnModel(configs);
|
||||
|
||||
ColumnConfig icon = new ColumnConfig("Icon", "", 25);
|
||||
configs.add(icon);
|
||||
|
||||
ColumnConfig columnConfigDisplayName = new ColumnConfig(InfoContactModel.FULLNAME, "Name", 150);
|
||||
configs.add(columnConfigDisplayName);
|
||||
|
||||
ColumnConfig type = new ColumnConfig(InfoContactModel.ISGROUP, "Type", 50);
|
||||
configs.add(type);
|
||||
|
||||
GridCellRenderer<InfoContactModel> iconRender = new GridCellRenderer<InfoContactModel>() {
|
||||
@Override
|
||||
public String render(InfoContactModel model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<InfoContactModel> store, Grid<InfoContactModel> grid) {
|
||||
Boolean isGroup = (Boolean) model.get(property);
|
||||
if(isGroup){
|
||||
return Resources.getIconGroup().getHTML();
|
||||
}else{
|
||||
return Resources.getIconUser().getHTML();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
icon.setRenderer(iconRender);
|
||||
|
||||
GridCellRenderer<InfoContactModel> typeRender = new GridCellRenderer<InfoContactModel>() {
|
||||
@Override
|
||||
public String render(InfoContactModel model, String property, ColumnData config, int rowIndex, int colIndex, ListStore<InfoContactModel> store, Grid<InfoContactModel> 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);
|
||||
}
|
||||
|
||||
public void addSourceContacts(List<InfoContactModel> listContact){
|
||||
|
@ -302,4 +340,24 @@ public class MultiDragContact extends Dialog {
|
|||
return storeTarget.getModels();
|
||||
}
|
||||
|
||||
private void setGropUserStoreSorter(ListStore<InfoContactModel> store){
|
||||
|
||||
// Sorting files
|
||||
store.setStoreSorter(new StoreSorter<InfoContactModel>() {
|
||||
|
||||
@Override
|
||||
public int compare(Store<InfoContactModel> store, InfoContactModel m1, InfoContactModel m2, String property) {
|
||||
boolean m1Group = m1.isGroup();
|
||||
boolean m2Group = m2.isGroup();
|
||||
|
||||
if (m1Group && !m2Group) {
|
||||
return -1;
|
||||
} else if (!m1Group && m2Group) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return m1.getName().compareToIgnoreCase(m2.getName());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,6 +87,10 @@ public class GWTWorkspaceSharingBuilder {
|
|||
hashTestUser.put("valentina.marioli", new InfoContactModel(
|
||||
"valentina.marioli", "valentina.marioli",
|
||||
"Valentina Marioli", false));
|
||||
|
||||
hashTestUser.put("devVRE", new InfoContactModel(
|
||||
"devVRE", "devVRE",
|
||||
"devVRE", true));
|
||||
|
||||
// hashTestUser.put(WsUtil.TEST_USER.toString(),
|
||||
// new InfoContactModel(
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel
|
|||
import org.gcube.portlets.widgets.workspacesharingwidget.shared.SessionExpiredException;
|
||||
import org.gcube.portlets.widgets.workspacesharingwidget.shared.WorkspaceACL;
|
||||
import org.gcube.portlets.widgets.workspacesharingwidget.shared.system.VO;
|
||||
import org.gcube.portlets.widgets.workspacesharingwidget.shared.system.VRE;
|
||||
import org.gcube.vomanagement.usermanagement.GroupManager;
|
||||
import org.gcube.vomanagement.usermanagement.UserManager;
|
||||
import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayGroupManager;
|
||||
|
@ -89,8 +90,7 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
|||
GWTWorkspaceSharingBuilder builder = getGWTWorkspaceBuilder();
|
||||
|
||||
if(isTestMode()){
|
||||
logger.info("WORKSPACE PORTLET IS IN TEST MODE - RETURN TEST USERS");
|
||||
logger.warn("WORKSPACE PORTLET IS IN TEST MODE - RETURN TEST USERS");
|
||||
logger.warn("WORKSPACE PORTLET IS IN TEST MODE - RETURN TEST USERS AND GROUPS");
|
||||
List<InfoContactModel> listContactsModel = new ArrayList<InfoContactModel>();
|
||||
// //TEST USERS
|
||||
listContactsModel.add(new InfoContactModel("federico.defaveri", "federico.defaveri", "Federico de Faveri", false));
|
||||
|
@ -102,6 +102,10 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
|||
listContactsModel.add(new InfoContactModel("massimiliano.assante", "massimiliano.assante", "Massimiliano Assante", false));
|
||||
listContactsModel.add(new InfoContactModel("valentina.marioli", "valentina.marioli", "Valentina Marioli", false));
|
||||
listContactsModel.add(new InfoContactModel("leonardo.candela", "leonardo.candela", "Leonardo Candela", false));
|
||||
|
||||
listContactsModel.add(new InfoContactModel("devVRE", "devVRE", "devVRE", true));
|
||||
|
||||
// listContactsModel.addAll(getFakeGroups());
|
||||
return listContactsModel;
|
||||
|
||||
}
|
||||
|
@ -135,7 +139,7 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
|||
listContactsModel.addAll(builder.buildGXTListContactsModelFromVOs(lsVOs));
|
||||
}
|
||||
|
||||
|
||||
logger.info("Get all contacts returning a list having size: "+listContactsModel.size());
|
||||
return listContactsModel;
|
||||
|
||||
} catch (Exception e) {
|
||||
|
@ -453,20 +457,43 @@ public class WorkspaceSharingServiceImpl extends RemoteServiceServlet implements
|
|||
|
||||
return listContacts;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* DEBUG
|
||||
* @return
|
||||
*/
|
||||
private List<InfoContactModel> getFakeGroups(){
|
||||
|
||||
List<InfoContactModel> listContactsModel = new ArrayList<InfoContactModel>();
|
||||
|
||||
PortalContext context = PortalContext.getConfiguration();
|
||||
System.out.println("context.getInfrastructureName(): "+context.getInfrastructureName());
|
||||
// System.out.println("context.getVOsAsString(): "+context.getVOsAsString());
|
||||
List<VO> vos = WsUtil.getVresFromInfrastructure(context.getInfrastructureName(), "devsec");
|
||||
|
||||
for (VO vo : vos) {
|
||||
System.out.println("vo name "+vo.getName());
|
||||
|
||||
for (VRE vre : vo.getVres()) {
|
||||
System.out.println("vre name "+vre.getName());
|
||||
listContactsModel.add(new InfoContactModel(vre.getName(), vre.getName(), vre.getName(), true));
|
||||
}
|
||||
}
|
||||
|
||||
return listContactsModel;
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
// WorkspaceSharingServiceImpl impl = new WorkspaceSharingServiceImpl();
|
||||
WorkspaceSharingServiceImpl impl = new WorkspaceSharingServiceImpl();
|
||||
|
||||
try {
|
||||
PortalContext context = PortalContext.getConfiguration();
|
||||
System.out.println("context.getInfrastructureName(): "+context.getInfrastructureName());
|
||||
System.out.println("context.getVOsAsString(): "+context.getVOsAsString());
|
||||
List<VO> vos = WsUtil.getVresFromInfrastructure(context.getInfrastructureName(), context.getVOsAsString());
|
||||
List<InfoContactModel> groups = impl.getFakeGroups();
|
||||
|
||||
for (VO vo : vos) {
|
||||
System.out.println("vo name "+vo.getName());
|
||||
for (InfoContactModel infoContactModel : groups) {
|
||||
System.out.println(infoContactModel);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 854 B |
Binary file not shown.
After Width: | Height: | Size: 760 B |
Loading…
Reference in New Issue