workspace-sharing-widget/src/main/java/org/gcube/portlets/widgets/workspacesharingwidget/client/WorkspaceSharingWidgetEntry...

119 lines
3.5 KiB
Java

package org.gcube.portlets.widgets.workspacesharingwidget.client;
import org.gcube.portlets.widgets.workspacesharingwidget.client.SimpleMultiDragContact.LOAD_CONTACTS_AS;
import org.gcube.portlets.widgets.workspacesharingwidget.client.view.sharing.SmartShare;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.CredentialModel;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.FileModel;
import org.gcube.portlets.widgets.workspacesharingwidget.shared.InfoContactModel;
import com.extjs.gxt.ui.client.event.BaseEvent;
import com.extjs.gxt.ui.client.event.Events;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.widget.Dialog;
import com.extjs.gxt.ui.client.widget.Window;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.RootPanel;
/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class WorkspaceSharingWidgetEntryPoint implements EntryPoint {
public static String ITEMID = "3cf934a0-decf-4104-8e23-47eb64010017";
/**
* This is the entry point method.
*/
public void onModuleLoad() {
try {
/*WorkspaceSharingController controller = new WorkspaceSharingController(ITEMID, true, ACL_TYPE.READ_ONLY);
final Window sharingWindow = controller.getSharingDialog();
Button openSharingWindow = new Button("Show Sharing Window",
new ClickHandler() {
public void onClick(ClickEvent event) {
sharingWindow.show();
}
});
RootPanel.get("workpacesharingwidget").add(openSharingWindow);
*/
/*FileModel file = new FileModel("123", "test", false);
WorkspaceSmartSharingController controller = new WorkspaceSmartSharingController(file, null, false, false);
SmartConstants.HEADER_TITLE = "puppa";
SmartConstants.ITEM_NAME = "aa";
final SmartShare sharingWindow = controller.getSharingDialog();
Button openSharingWindow = new Button("Show Smart Share Window",
new ClickHandler() {
public void onClick(ClickEvent event) {
sharingWindow.show();
}
});
RootPanel.get("workpacesharingwidget").add(openSharingWindow);
sharingWindow.getButtonById(Dialog.OK).addListener(Events.Select, new Listener<BaseEvent>() {
@Override
public void handleEvent(BaseEvent be) {
if(sharingWindow.isValidForm(true)){
//THAT'S OK
sharingWindow.getSharedListUsers(); //@return the selected contacts (as InfoContactModel)
sharingWindow.getSharedListUsersCredential(); //@return the selected contacts (as CredentialModel)
for (InfoContactModel contact : sharingWindow.getSharedListUsers()) {
System.out.println(contact);
}
for (CredentialModel credential : sharingWindow.getSharedListUsersCredential()) {
System.out.println(credential);
}
}
}
});
*/
showSimpleMultiDrag();
} catch (Exception e) {
e.printStackTrace();
}
}
private void showSimpleMultiDrag(){
final SimpleMultiDragContact multiDragContact = new SimpleMultiDragContact(LOAD_CONTACTS_AS.SHARED_USER, ITEMID, true, false);
Button openSharingWindow = new Button("Show Simple Multi Drag",
new ClickHandler() {
public void onClick(ClickEvent event) {
multiDragContact.getMultiDragContact().show();
}
});
RootPanel.get("workpacesharingwidget").add(openSharingWindow);
}
}