<classpathentry kind="lib" path="lib/droppable-plugin-1.0.2.jar"/>
<classpathentry kind="lib" path="lib/gwtquery-1.0.0-20110116.074055-7.jar"/>
<classpathentry kind="lib" path="dependencies/selenium-server-standalone-2.0b1.jar"/>
+ <classpathentry kind="lib" path="dependencies/gwt-incubator-20101117-r1766.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<property name="solr.download.url" value="http://apache.ntua.gr/lucene/solr/${solr.version}/${solr.filename}"/>
<property name="solrj.version" value="1.4.1"/>
<property name="solrj.jar" value="apache-solr-solrj-${solrj.version}.jar"/>
- <property name="gwt.path" value="${deps.dir}/gwt-2.1.1"/>
+ <!--
+ <property name="gwt.path" value="${deps.dir}/gwt-2.2-M1"/>
+ <property name="gwt.filename" value="gwt-2.2-M1.zip"/>
+ <property name="gwt.download.url" value="http://google-web-toolkit.googlecode.com/files/gwt-2.2-M1.zip"/>
+ -->
+
+ <property name="gwt.path" value="${deps.dir}/gwt-2.1.1"/>
<property name="gwt.filename" value="gwt-2.1.1.zip"/>
- <property name="gwt.download.url" value="http://google-web-toolkit.googlecode.com/files/gwt-2.1.1.zip"/>
+ <property name="gwt.download.url" value="http://google-web-toolkit.googlecode.com/files/gwt-2.1.1.zip"/>
+
+
+
<property name="hornetq.path" value="${deps.dir}/hornetq-2.0.0.GA" />
<property name="hornetq.filename" value="hornetq-2.0.0.GA.zip/"/>
<property name="hornetq.download.url" value="http://sourceforge.net/projects/hornetq/files/2.0.0.GA/hornetq-2.0.0.GA.zip/download"/>
<pathelement location="${junit.path}/junit.jar"/>
<pathelement location="${deps.dir}/${gwt-dnd.filename}"/>
<pathelement location="${gwt-gears.path}/gwt-gears.jar"/>
- <!-- <pathelement location="${deps.dir}/${gwt-incubator.filename}"/> -->
+ <pathelement location="${deps.dir}/${gwt-incubator.filename}"/>
<pathelement location="${gwt-visualization.path}/gwt-visualization.jar"/>
<pathelement location="${solr.dist}/${solrj.jar}"/>
<pathelement location="${solr.dist}/apache-solr-core-1.4.1.jar"/>
<get src="${hornetq.download.url}" dest="${deps.dir}/${hornetq.filename}" usetimestamp="true"/>
<get src="${jboss.download.url}" dest="${deps.dir}/${jboss.filename}" usetimestamp="true"/>
-->
+ <!--
<get src="${gwt.download.url}" dest="${deps.dir}/${gwt.filename}" usetimestamp="true"/>
+
+ -->
<get src="${gwt-incubator.download.url}" dest="${deps.dir}/${gwt-incubator.filename}" usetimestamp="true"/>
<get src="${junit.download.url}" dest="${deps.dir}/${junit.filename}" usetimestamp="true"/>
<get src="${selenium-server.download.url}" dest="${deps.dir}/${selenium-server.filename}" usetimestamp="true"/>
<arg value="-war"/>
<arg value="${gwt.www.admin.dir}"/>
<arg value="${gwt.admin.module}"/>
- <jvmarg value="-Xmx128m"/>
+ <jvmarg value="-Xmx256m"/>
<classpath>
<pathelement path="${gwt-dev-lib}"/>
<path refid="project.class.path" />
</jar>
</target>
- <target name="package-ear" depends=" package-war, package-webdav-war, package-ejb, package-mbeans" description="Package up the project as an ear">
+ <target name="package-ear" depends=" package-war,package-admin-war,package-webdav-war, package-ejb, package-mbeans" description="Package up the project as an ear">
<jar destfile="${build.dir}/${dist.ear}">
<zipfileset dir="${ear.dir}" />
<zipfileset dir="${build.dir}" >
<include name="ejbs.jar" />
<include name="${dist.war}" />
<include name="${webdav.war}" />
-
+ <include name="${dist.admin.war}" />
<include name="${mbeans.dist.file}"/>
</zipfileset>
<zipfileset dir="${solr.dist}" prefix="lib">
<context-root>/pithos</context-root>
</web>
</module>
- <!--
+
<module>
<web>
<web-uri>gss-admin.war</web-uri>
<context-root>/admin</context-root>
</web>
</module>
- -->
+
<module>
<web>
<web-uri>webdav.war</web-uri>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<module>
+ <!-- Inherit the core Web Toolkit stuff. -->
+ <inherits name='com.google.gwt.user.User'/>
+ <inherits name='com.google.gwt.user.datepicker.DatePicker'/>
+
+ <!-- Inherit the default GWT style sheet. You can change -->
+ <!-- the theme of your GWT application by uncommenting -->
+ <!-- any one of the following lines. -->
+ <inherits name="com.google.gwt.user.theme.standard.Standard"/>
+ <!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
+ <!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
+ <inherits name='com.google.gwt.gen2.Gen2' />
+ <inherits name="com.google.gwt.visualization.Visualization"/>
+ <inherits name='gr.ebs.gss.client.exceptions' />
+ <inherits name='gr.ebs.gss.server.domain.dto' />
+ <!-- <set-property name="user.agent" value="gecko,gecko1_8" />-->
+
+ <!-- Specify the app entry point class. -->
+ <entry-point class='gr.ebs.gss.admin.client.TwoAdmin'/>
+
+ <!-- Specify the paths for translatable code -->
+ <source path='client'/>
+</module>
--- /dev/null
+package gr.ebs.gss.admin.client;
+
+import gr.ebs.gss.client.exceptions.InsufficientPermissionsException;
+import gr.ebs.gss.client.exceptions.ObjectNotFoundException;
+import gr.ebs.gss.client.exceptions.RpcException;
+import gr.ebs.gss.server.domain.dto.FileBodyDTO;
+import gr.ebs.gss.server.domain.dto.FileHeaderDTO;
+import gr.ebs.gss.server.domain.dto.PermissionDTO;
+import gr.ebs.gss.server.domain.dto.StatsDTO;
+import gr.ebs.gss.server.domain.dto.SystemStatsDTO;
+import gr.ebs.gss.server.domain.dto.UserClassDTO;
+import gr.ebs.gss.server.domain.dto.UserDTO;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Set;
+
+import com.google.gwt.user.client.rpc.RemoteService;
+import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
+
+@RemoteServiceRelativePath("admin")
+public interface AdminService extends RemoteService {
+ List<UserDTO> getUsers() throws RpcException, ObjectNotFoundException;
+
+ List<UserDTO> searchUsers(String query) throws RpcException, ObjectNotFoundException;
+
+ StatsDTO getUserStatistics(Long userId) throws RpcException, ObjectNotFoundException;
+
+ void toggleActiveUser(Long userId) throws RpcException,ObjectNotFoundException;
+
+ void setFilePermissions(String uri, Set<PermissionDTO> permissions) throws RpcException, ObjectNotFoundException;
+
+ SystemStatsDTO getSystemStatistics() throws RpcException,ObjectNotFoundException;
+
+ public List<UserDTO> getLastLoggedInUsers(Date lastLoginDate) throws RpcException;
+
+ public void logout();
+
+ public List<FileHeaderDTO> searchFiles(String query) throws RpcException, ObjectNotFoundException, InsufficientPermissionsException;
+
+ UserDTO getUser(String username) throws ObjectNotFoundException, RpcException;
+
+ FileHeaderDTO getFile(long fileId) throws ObjectNotFoundException, RpcException;
+
+ public List<FileBodyDTO> getVersions(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException,RpcException;
+
+ List<UserDTO> getUsersWaitingActivation() throws RpcException;
+
+ void changeUserClass(Long userId,Long userClassId) throws RpcException,ObjectNotFoundException;
+
+ List<UserClassDTO> getUserClasses() throws RpcException;
+
+ void saveOrUpdateUserClass(UserClassDTO userClass) throws RpcException,ObjectNotFoundException;
+
+ void removeUserClass(UserClassDTO userClass) throws RpcException,ObjectNotFoundException;
+
+ void removeUser(Long userId) throws RpcException,ObjectNotFoundException,InsufficientPermissionsException;
+
+}
--- /dev/null
+package gr.ebs.gss.admin.client;
+
+import gr.ebs.gss.server.domain.dto.FileBodyDTO;
+import gr.ebs.gss.server.domain.dto.FileHeaderDTO;
+import gr.ebs.gss.server.domain.dto.PermissionDTO;
+import gr.ebs.gss.server.domain.dto.StatsDTO;
+import gr.ebs.gss.server.domain.dto.SystemStatsDTO;
+import gr.ebs.gss.server.domain.dto.UserClassDTO;
+import gr.ebs.gss.server.domain.dto.UserDTO;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Set;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+
+public interface AdminServiceAsync {
+ void getUsers(AsyncCallback<List<UserDTO>> callback);
+
+ void getUserStatistics(Long userId, AsyncCallback<StatsDTO> callback);
+
+ void toggleActiveUser(Long userId, AsyncCallback<Void> callback);
+
+ void setFilePermissions(String uri, Set<PermissionDTO> permissions, AsyncCallback<Void> callback);
+
+ void searchUsers(String query, AsyncCallback<List<UserDTO>> callback);
+
+ void getSystemStatistics(AsyncCallback<SystemStatsDTO> callback);
+
+ void getLastLoggedInUsers(Date lastLoginDate, AsyncCallback<List<UserDTO>> callback);
+
+ void logout(AsyncCallback<Void> callback);
+
+ void searchFiles(String query, AsyncCallback<List<FileHeaderDTO>> callback);
+
+ void getUser(String username, AsyncCallback<UserDTO> callback);
+
+ void getFile(long fileId, AsyncCallback<FileHeaderDTO> callback);
+
+ void getVersions(Long userId, Long fileId, AsyncCallback<List<FileBodyDTO>> callback);
+
+ void getUsersWaitingActivation(AsyncCallback<List<UserDTO>> callback);
+
+ void changeUserClass(Long userId, Long userClassId, AsyncCallback<Void> callback);
+
+ void getUserClasses(AsyncCallback<List<UserClassDTO>> callback);
+
+ void saveOrUpdateUserClass(UserClassDTO userClass, AsyncCallback<Void> callback);
+
+ void removeUserClass(UserClassDTO userClass, AsyncCallback<Void> callback);
+
+ void removeUser(Long userId, AsyncCallback<Void> callback);
+
+}
--- /dev/null
+package gr.ebs.gss.admin.client;
+
+import gr.ebs.gss.admin.client.ui.HeaderPanel;
+import gr.ebs.gss.admin.client.ui.UserPanel;
+import gr.ebs.gss.admin.client.ui.VisualizationPanel;
+import gr.ebs.gss.server.domain.dto.SystemStatsDTO;
+
+import com.google.gwt.core.client.EntryPoint;
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.event.logical.shared.ResizeEvent;
+import com.google.gwt.event.logical.shared.ResizeHandler;
+import com.google.gwt.event.logical.shared.SelectionEvent;
+import com.google.gwt.event.logical.shared.SelectionHandler;
+import com.google.gwt.uibinder.client.UiBinder;
+import com.google.gwt.uibinder.client.UiField;
+import com.google.gwt.user.client.Command;
+import com.google.gwt.user.client.DeferredCommand;
+import com.google.gwt.user.client.Window;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.DialogBox;
+import com.google.gwt.user.client.ui.DockLayoutPanel;
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.RootLayoutPanel;
+import com.google.gwt.user.client.ui.TabLayoutPanel;
+import com.google.gwt.user.client.ui.VerticalPanel;
+
+/**
+ * Entry point classes define <code>onModuleLoad()</code>.
+ */
+public class TwoAdmin implements EntryPoint {
+
+ interface Binder extends UiBinder<DockLayoutPanel, TwoAdmin> {
+ }
+
+ private final AdminServiceAsync adminService = GWT.create(AdminService.class);
+
+ private static final Binder binder = GWT.create(Binder.class);
+
+ /**
+ * The single TwoAdmin instance.
+ */
+ private static TwoAdmin singleton;
+
+ /**
+ * Gets the singleton TwoAdmin instance.
+ *
+ * @return the TwoAdmin object
+ */
+ public static TwoAdmin get() {
+ if (TwoAdmin.singleton == null)
+ TwoAdmin.singleton = new TwoAdmin();
+ return TwoAdmin.singleton;
+ }
+
+ @UiField(provided = true)
+ HeaderPanel headerPanel = new HeaderPanel();
+
+ @UiField UserPanel userPanel;
+
+ @UiField
+ TabLayoutPanel tabPanel;
+
+ @UiField VisualizationPanel chart2;
+
+ final DialogBox loadingBox = new DialogBox();
+
+ @Override
+ public void onModuleLoad() {
+ TwoAdmin.singleton=this;
+ loadingBox.setHTML("Loading data");
+ //scroll.setAlwaysShowScrollBars(true);
+ VerticalPanel vPanel = new VerticalPanel();
+ loadingBox.setSize("50%", "50%");
+ loadingBox.setWidget(vPanel);
+ vPanel.add(new Label("Fetching Requested Data"));
+
+ DockLayoutPanel outer = binder.createAndBindUi(this);
+ tabPanel.addSelectionHandler(new SelectionHandler<Integer>() {
+
+ @Override
+ public void onSelection(SelectionEvent<Integer> event) {
+ switch (event.getSelectedItem()) {
+ case 0:
+ loadStatistics();
+ break;
+ default:
+ break;
+ }
+
+ }
+ });
+
+
+ // Get rid of scrollbars, and clear out the window's built-in margin,
+ // because we want to take advantage of the entire client area.
+ //Window.enableScrolling(true);
+ //Window.setMargin("0px");
+ Window.addResizeHandler(new ResizeHandler(){
+
+ @Override
+ public void onResize(ResizeEvent event) {
+ int height=event.getHeight();
+ resize(height);
+
+ }
+
+ });
+ RootLayoutPanel root = RootLayoutPanel.get();
+ root.add(outer);
+ // RootPanel.get().add(outer);
+ loadStatistics();
+ tabPanel.selectTab(0);
+
+ resize(Window.getClientHeight());
+ }
+
+ private void resize(int height){
+
+ int newHeight = height - tabPanel.getAbsoluteTop()-100;
+ if (newHeight < 1)
+ newHeight = 1;
+ tabPanel.setHeight("" + newHeight);
+ GWT.log("New Height:"+ newHeight);
+ }
+ /**
+ * Retrieve the adminService.
+ *
+ * @return the adminService
+ */
+ public AdminServiceAsync getAdminService() {
+ return adminService;
+ }
+
+ public void showErrorBox(String message) {
+ final DialogBox dialogBox = new DialogBox();
+ dialogBox.setHTML("An error occured");
+ VerticalPanel vPanel = new VerticalPanel();
+ dialogBox.setSize("50%", "50%");
+ ClickHandler cancelHandler = new ClickHandler() {
+
+ @Override
+ public void onClick(ClickEvent event) {
+ dialogBox.hide();
+ }
+ };
+ dialogBox.setWidget(vPanel);
+ vPanel.add(new Label(message));
+ Button close = new Button("Close");
+ close.addClickHandler(cancelHandler);
+ vPanel.add(close);
+ dialogBox.center();
+ dialogBox.show();
+ }
+
+
+
+ public void showLoadingBox() {
+ loadingBox.center();
+ loadingBox.show();
+ }
+
+ public void hideLoadingBox(){
+ loadingBox.hide();
+ }
+
+
+ public void loadStatistics(){
+ DeferredCommand.addCommand(new Command() {
+
+ @Override
+ public void execute() {
+ showLoadingBox();
+ getAdminService().getSystemStatistics(new AsyncCallback<SystemStatsDTO>() {
+
+ @Override
+ public void onFailure(Throwable caught) {
+ hideLoadingBox();
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void onSuccess(SystemStatsDTO result) {
+ chart2.updateData(result);
+ hideLoadingBox();
+ }});
+
+ }
+ });
+ }
+
+ public void searchUsers(String query){
+ tabPanel.selectTab(1);
+ userPanel.populateTable(query);
+ }
+}
--- /dev/null
+<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
+<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
+ xmlns:g='urn:import:com.google.gwt.user.client.ui' xmlns:admin='urn:import:gr.ebs.gss.admin.client'
+ xmlns:adminui='urn:import:gr.ebs.gss.admin.client.ui'>
+
+ <g:DockLayoutPanel unit='EM'>
+ <g:north size='5'>
+ <adminui:HeaderPanel ui:field='headerPanel' />
+ </g:north>
+
+ <g:center size='100%'>
+ <g:TabLayoutPanel barUnit='PX' barHeight='25'
+ height="600" ui:field="tabPanel">
+
+ <g:tab>
+ <g:header>Statistics</g:header>
+ <g:ScrollPanel>
+ <adminui:VisualizationPanel ui:field="chart2"></adminui:VisualizationPanel>
+ </g:ScrollPanel>
+
+
+ </g:tab>
+ <g:tab>
+ <g:header>Search Users</g:header>
+ <g:ScrollPanel>
+ <adminui:UserPanel ui:field="userPanel">
+ </adminui:UserPanel>
+ </g:ScrollPanel>
+
+ </g:tab>
+ <g:tab>
+ <g:header>Files Search</g:header>
+ <g:ScrollPanel>
+ <adminui:FilesPanel></adminui:FilesPanel>
+ </g:ScrollPanel>
+
+ </g:tab>
+ <g:tab>
+ <g:header>User Classes</g:header>
+ <g:ScrollPanel>
+ <adminui:UserClassListPanel></adminui:UserClassListPanel>
+ </g:ScrollPanel>
+
+ </g:tab>
+
+ <g:tab>
+ <g:header>Operations</g:header>
+ <g:ScrollPanel>
+ <adminui:OperationsPanel></adminui:OperationsPanel>
+ </g:ScrollPanel>
+
+ </g:tab>
+
+
+ </g:TabLayoutPanel>
+
+ </g:center>
+ </g:DockLayoutPanel>
+
+
+
+</ui:UiBinder>
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright 2009 Electronic Business Systems Ltd.
+ *
+ * This file is part of GSS.
+ *
+ * GSS is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GSS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GSS. If not, see <http://www.gnu.org/licenses/>.
+ */
+package gr.ebs.gss.admin.client.ui;
+
+import com.google.gwt.dom.client.NativeEvent;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.event.dom.client.KeyCodes;
+import com.google.gwt.user.client.Event.NativePreviewEvent;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.DialogBox;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.HasHorizontalAlignment;
+import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.VerticalPanel;
+
+
+/**
+ * A dialog for requesting confirmation from the user.
+ *
+ * @author kman
+ */
+public abstract class ConfirmationDialog extends DialogBox {
+
+ /**
+ * The widget's constructor.
+ *
+ * @param message the message to display
+ * @param buttonLabel the label of the confirmation button
+ */
+ public ConfirmationDialog(String message, String buttonLabel) {
+ // Set the dialog's caption.
+ setText("Confirmation");
+ setAnimationEnabled(true);
+ // Create a VerticalPanel to contain the label and the buttons.
+ VerticalPanel outer = new VerticalPanel();
+ HorizontalPanel buttons = new HorizontalPanel();
+
+ HTML text = new HTML("<table><tr><td rowspan='2'>" +
+ //AbstractImagePrototype.create(MessagePanel.images.warn()).getHTML() +
+
+ "</td><td>" + message + "</td></tr></table>");
+ text.setStyleName("gss-warnMessage");
+ outer.add(text);
+
+ // Create the 'Update' button, along with a listener that hides the dialog
+ // when the button is clicked and renames the file.
+ Button ok = new Button(buttonLabel, new ClickHandler() {
+
+ @Override
+ public void onClick(ClickEvent event) {
+ confirm();
+ hide();
+ }
+ });
+ buttons.add(ok);
+ buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER);
+ // Create the 'Cancel' button, along with a listener that hides the
+ // dialog when the button is clicked.
+ Button cancel = new Button("Cancel", new ClickHandler() {
+
+ @Override
+ public void onClick(ClickEvent event) {
+ hide();
+ cancel();
+ }
+ });
+ buttons.add(cancel);
+ buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER);
+ buttons.setSpacing(8);
+ buttons.setStyleName("gss-warnMessage");
+ outer.setStyleName("gss-warnMessage");
+ outer.add(buttons);
+ outer.setCellHorizontalAlignment(text, HasHorizontalAlignment.ALIGN_CENTER);
+ outer.setCellHorizontalAlignment(buttons, HasHorizontalAlignment.ALIGN_CENTER);
+ setWidget(outer);
+ }
+
+ @Override
+ protected void onPreviewNativeEvent(NativePreviewEvent preview) {
+ super.onPreviewNativeEvent(preview);
+ NativeEvent evt = preview.getNativeEvent();
+ if (evt.getType().equals("keydown"))
+ // Use the popup's key preview hooks to close the dialog when either
+ // enter or escape is pressed.
+ switch (evt.getKeyCode()) {
+ case KeyCodes.KEY_ENTER:
+ hide();
+ confirm();
+ break;
+ case KeyCodes.KEY_ESCAPE:
+ hide();
+ cancel();
+ break;
+ }
+ }
+
+ public abstract void confirm();
+
+ public abstract void cancel();
+}
--- /dev/null
+package gr.ebs.gss.admin.client.ui;
+
+import gr.ebs.gss.admin.client.TwoAdmin;
+import gr.ebs.gss.server.domain.dto.FileBodyDTO;
+import gr.ebs.gss.server.domain.dto.FileHeaderDTO;
+import gr.ebs.gss.server.domain.dto.PermissionDTO;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.event.dom.client.KeyPressEvent;
+import com.google.gwt.event.dom.client.KeyPressHandler;
+import com.google.gwt.gen2.table.event.client.RowSelectionEvent;
+import com.google.gwt.gen2.table.event.client.RowSelectionHandler;
+import com.google.gwt.uibinder.client.UiBinder;
+import com.google.gwt.uibinder.client.UiField;
+import com.google.gwt.uibinder.client.UiHandler;
+import com.google.gwt.user.client.Command;
+import com.google.gwt.user.client.DeferredCommand;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.Grid;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.TextBox;
+import com.google.gwt.user.client.ui.Widget;
+
+public class FilesPanel extends Composite {
+
+ private static UserPanelUiBinder uiBinder = GWT
+ .create(UserPanelUiBinder.class);
+
+ interface UserPanelUiBinder extends UiBinder<Widget, FilesPanel> {
+ }
+
+
+
+ @UiField TextBox searchBox;
+ @UiField Button searchButton;
+ @UiField(provided=true) final FilesTable filesTable = new FilesTable();
+ @UiField(provided=true) Grid g =new Grid(9,6);
+ @UiField(provided=true) PermissionsList permissionsGrid = new PermissionsList(new HashSet<PermissionDTO>(),"",true);
+ @UiField(provided=true) VersionsList versionsList = new VersionsList(new ArrayList<FileBodyDTO>());
+ private Object lastQuery;
+
+ public FilesPanel() {
+ g.setCellPadding(5);
+ g.setCellSpacing(5);
+
+ initWidget(uiBinder.createAndBindUi(this));
+ searchBox.addKeyPressHandler(new KeyPressHandler() {
+
+ @Override
+ public void onKeyPress(KeyPressEvent event) {
+ char keyCode = event.getCharCode();
+ if (keyCode == '\r')
+ handleClick(null);
+ }
+ });
+ filesTable.addRowSelectionHandler(new RowSelectionHandler() {
+
+ @Override
+ public void onRowSelection(RowSelectionEvent event) {
+ final FileHeaderDTO user = filesTable.getSelectedRowObject(event);
+
+ TwoAdmin.get().showLoadingBox();
+ if(user!=null)
+ DeferredCommand.addCommand(new Command() {
+
+ @Override
+ public void execute() {
+ TwoAdmin.get().showLoadingBox();
+ TwoAdmin.get().getAdminService().getFile(user.getId(), new AsyncCallback<FileHeaderDTO>() {
+
+ @Override
+ public void onSuccess(final FileHeaderDTO result) {
+ TwoAdmin.get().getAdminService().getVersions(result.getOwner().getId(), result.getId(), new AsyncCallback<List<FileBodyDTO>>() {
+
+ @Override
+ public void onFailure(Throwable caught) {
+ GWT.log("Error requesting file details", caught);
+ TwoAdmin.get().hideLoadingBox();
+ TwoAdmin.get().showErrorBox("Error requesting file details");
+
+ }
+
+ @Override
+ public void onSuccess(List<FileBodyDTO> versions) {
+ clearFileDetails();
+ displayFileDetails(result, versions);
+ TwoAdmin.get().hideLoadingBox();
+
+
+ }
+
+ });
+
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ GWT.log("Error requesting user statistics file", caught);
+ TwoAdmin.get().hideLoadingBox();
+ TwoAdmin.get().showErrorBox("Error requesting user statistics");
+
+ }
+ });
+
+ }
+ });
+
+ }
+ });
+
+
+ clearFileDetails();
+
+ }
+
+ @UiHandler("searchButton")
+ void handleClick(@SuppressWarnings("unused") ClickEvent e){
+ final String toSearch = searchBox.getText();
+ if(toSearch == null || "".equals(toSearch.trim())){
+ TwoAdmin.get().showErrorBox("You must enter a query");
+ return;
+ }
+ lastQuery = toSearch;
+ populateTable(toSearch);
+ }
+
+
+
+ public void populateTable(String query){
+ TwoAdmin.get().showLoadingBox();
+ TwoAdmin.get().getAdminService().searchFiles(query,new AsyncCallback<List<FileHeaderDTO>>() {
+
+ @Override
+ public void onFailure(Throwable caught) {
+ TwoAdmin.get().hideLoadingBox();
+ GWT.log("Error fetching files", caught);
+ TwoAdmin.get().showErrorBox("Unable to Find any Files");
+ }
+
+ @Override
+ public void onSuccess(List<FileHeaderDTO> result) {
+ filesTable.showUsers(result);
+ clearFileDetails();
+ TwoAdmin.get().hideLoadingBox();
+
+ }
+
+ });
+ }
+
+
+
+
+ public void displayFileDetails(final FileHeaderDTO file, List<FileBodyDTO> versions){
+ clearFileDetails();
+ versionsList.updateTable(versions);
+ g.setHTML(0, 0, "<span>" + "Name:");
+ g.setHTML(0, 1, file.getName()+"</span>");
+ g.setHTML(1, 0, "<span>" + "URI:");
+ g.setHTML(1, 1, file.getURI()+"</span>");
+ g.setHTML(2, 0, "<span>" + "Owner:");
+ HTML userLabel =new HTML("<a href='#'>"+file.getOwner().getUsername()+"</a></span>");
+ g.setWidget(2, 1, userLabel );
+
+ userLabel.addClickHandler(new ClickHandler() {
+
+ @Override
+ public void onClick(ClickEvent event) {
+ TwoAdmin.get().searchUsers("username:"+file.getOwner().getUsername());
+
+ }
+ });
+ g.setHTML(3, 0, "<span>" + "Size:");
+ g.setHTML(3, 1, file.getFileSizeAsString()+"</span>");
+ g.setHTML(4, 0, "<span>" + "Content Type:");
+ g.setHTML(4, 1, file.getMimeType()+"</span>");
+
+ g.setHTML(5, 0, "<span>" + "Creation Date:");
+ g.setHTML(5, 1, file.getAuditInfo().getCreationDate()+"</span>");
+
+ g.setHTML(6, 0, "<span>" + "Modification Date:");
+ g.setHTML(6, 1, file.getAuditInfo().getModificationDate()+"</span>");
+ if(file.isVersioned())
+ g.setHTML(7, 0, "<span>" + "File is Versioned:</span>");
+ else
+ g.setHTML(7, 0, "<span>" + "File is NOT Versioned:</span>");
+ if(file.isReadForAll()){
+ g.setHTML(8, 0, "<span>" + "Read For All:");
+ g.setHTML(8, 1, file.getURI()+"</span>");
+ }
+ permissionsGrid.update(file.getPermissions(), file.getURI());
+ }
+
+ public void clearFileDetails(){
+ g.setHTML(0, 0, "<span>" + "Name:");
+ g.setHTML(0, 1, ""+"</span>");
+ g.setHTML(1, 0, "<span>" + "URI:");
+ g.setHTML(1, 1, ""+"</span>");
+ g.setHTML(2, 0, "<span>" + "Owner:");
+ g.setHTML(2, 1, ""+"</span>");
+ g.setHTML(3, 0, "<span>" + "Size:");
+ g.setHTML(3, 1, ""+"</span>");
+ g.setHTML(4, 0, "<span>" + "Content Type:");
+ g.setHTML(4, 1, ""+"</span>");
+ g.setHTML(5, 0, "<span>" + "Creation Date:");
+ g.setHTML(5, 1, "</span>");
+
+ g.setHTML(6, 0, "<span>" + "Modification Date:");
+ g.setHTML(6, 1, "</span>");
+ g.setHTML(7, 0, "<span>" + "File is Versioned:</span>");
+ g.setHTML(8, 0, "<span>" + "Read For All:");
+ g.setHTML(8, 1, "</span>");
+ permissionsGrid.clear();
+ versionsList.updateTable(new ArrayList<FileBodyDTO>());
+
+
+ }
+
+
+ /**
+ * Retrieve the lastQuery.
+ *
+ * @return the lastQuery
+ */
+ public Object getLastQuery() {
+ return lastQuery;
+ }
+}
--- /dev/null
+<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
+<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
+ xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:adminui='urn:import:gr.ebs.gss.admin.client.ui'
+ xmlns:dp="urn:import:com.google.gwt.user.datepicker.client"
+ >
+ <ui:style>
+
+ </ui:style>
+
+ <g:VerticalPanel addStyleNames="Gmnuri3D" width="100%">
+ <g:HTMLPanel>
+ <div>
+ <h3>Files Search</h3>
+ </div>
+ </g:HTMLPanel>
+ <g:HorizontalPanel spacing="3">
+ <g:cell horizontalAlignment="ALIGN_CENTER" verticalAlignment="ALIGN_MIDDLE">
+ <g:HTML>Search Files:</g:HTML>
+ </g:cell>
+ <g:cell horizontalAlignment="ALIGN_CENTER" verticalAlignment="ALIGN_MIDDLE">
+ <g:TextBox ui:field="searchBox" visibleLength="50"></g:TextBox>
+ </g:cell>
+ <g:cell horizontalAlignment="ALIGN_CENTER" verticalAlignment="ALIGN_MIDDLE">
+ <g:Button ui:field="searchButton">Search</g:Button>
+ </g:cell>
+
+ </g:HorizontalPanel>
+
+ <adminui:FilesTable ui:field="filesTable">
+ </adminui:FilesTable>
+
+ <g:VerticalPanel width="100%" addStyleNames="Gmnuri3D">
+ <g:HTMLPanel>
+ <div>
+ <h3>File Details</h3>
+ </div>
+ </g:HTMLPanel>
+ <g:HorizontalPanel>
+
+ <g:Grid ui:field="g" width="400px"></g:Grid>
+ <adminui:PermissionsList ui:field="permissionsGrid"
+ width="300px"></adminui:PermissionsList>
+ <adminui:VersionsList ui:field="versionsList"></adminui:VersionsList>
+ </g:HorizontalPanel>
+
+ </g:VerticalPanel>
+ </g:VerticalPanel>
+
+</ui:UiBinder>
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright 2010 Electronic Business Systems Ltd.
+ *
+ * This file is part of GSS.
+ *
+ * GSS is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GSS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GSS. If not, see <http://www.gnu.org/licenses/>.
+ */
+package gr.ebs.gss.admin.client.ui;
+
+import gr.ebs.gss.admin.client.ui.FilesTable.FileSorter.FileComparator;
+import gr.ebs.gss.server.domain.dto.FileHeaderDTO;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.gen2.table.client.AbstractColumnDefinition;
+import com.google.gwt.gen2.table.client.AbstractScrollTable.ScrollPolicy;
+import com.google.gwt.gen2.table.client.AbstractScrollTable.SortPolicy;
+import com.google.gwt.gen2.table.client.CachedTableModel;
+import com.google.gwt.gen2.table.client.CellRenderer;
+import com.google.gwt.gen2.table.client.ColumnDefinition;
+import com.google.gwt.gen2.table.client.DefaultRowRenderer;
+import com.google.gwt.gen2.table.client.DefaultTableDefinition;
+import com.google.gwt.gen2.table.client.FixedWidthGridBulkRenderer;
+import com.google.gwt.gen2.table.client.MutableTableModel;
+import com.google.gwt.gen2.table.client.PagingOptions;
+import com.google.gwt.gen2.table.client.PagingScrollTable;
+import com.google.gwt.gen2.table.client.ScrollTable;
+import com.google.gwt.gen2.table.client.SelectionGrid.SelectionPolicy;
+import com.google.gwt.gen2.table.client.TableDefinition;
+import com.google.gwt.gen2.table.client.TableDefinition.AbstractCellView;
+import com.google.gwt.gen2.table.client.TableModel;
+import com.google.gwt.gen2.table.client.TableModelHelper.Request;
+import com.google.gwt.gen2.table.client.TableModelHelper.Response;
+import com.google.gwt.gen2.table.event.client.RowSelectionEvent;
+import com.google.gwt.gen2.table.event.client.RowSelectionHandler;
+import com.google.gwt.gen2.table.event.client.TableEvent.Row;
+import com.google.gwt.i18n.client.DateTimeFormat;
+import com.google.gwt.user.client.ui.CheckBox;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.FlexTable;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.HasHorizontalAlignment;
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.VerticalPanel;
+
+
+/**
+ * @author kman
+ *
+ */
+public class FilesTable extends Composite {
+ private CachedTableModel<FileHeaderDTO> cachedTableModel = null;
+ private DefaultTableDefinition<FileHeaderDTO> tableDefinition = null;
+ private PagingScrollTable<FileHeaderDTO> pagingScrollTable = null;
+ private Label countLabel = new Label("There are no files to display.");
+ private DataSourceTableModel tableModel = null;
+
+ private VerticalPanel vPanel = new VerticalPanel();
+ private FlexTable flexTable = new FlexTable();
+
+ /**
+ * Constructor
+ */
+ public FilesTable() {
+ super();
+ pagingScrollTable = createScrollTable();
+ pagingScrollTable.setHeight("200px");
+ pagingScrollTable.setScrollPolicy(ScrollPolicy.DISABLED);
+ PagingOptions pagingOptions = new PagingOptions(pagingScrollTable);
+
+ flexTable.setWidget(0, 0, pagingScrollTable);
+ flexTable.getFlexCellFormatter().setColSpan(0, 0, 2);
+ flexTable.setWidget(1, 0, pagingOptions);
+
+ countLabel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
+ vPanel.add(countLabel);
+ vPanel.add(flexTable);
+
+ vPanel.setWidth("100%");
+ flexTable.setWidth("100%");
+
+ super.initWidget(vPanel);
+ showUsers(new ArrayList<FileHeaderDTO>());
+ pagingScrollTable.setFooterGenerated(true);
+ }
+
+ public void showUsers(List<FileHeaderDTO> newList) {
+ countLabel.setText("There are "+ newList.size() + " files.");
+ tableModel.setData(newList);
+ tableModel.setRowCount(newList.size());
+ cachedTableModel.clearCache();
+ cachedTableModel.setRowCount(newList.size());
+
+ pagingScrollTable.gotoPage(0, true);
+ if(newList.size()<2)
+ flexTable.setWidget(1, 0, new HTML());
+ else{
+ PagingOptions pagingOptions = new PagingOptions(pagingScrollTable);
+ flexTable.setWidget(1, 0, pagingOptions);
+ }
+ }
+
+ public FileHeaderDTO getUserOnRow(int rowIdx){
+ String id = pagingScrollTable.getDataTable().getHTML(rowIdx, 0);
+ final FileHeaderDTO m = tableModel.getUserById(Long.parseLong(id));
+ return m;
+ }
+
+
+ public FileHeaderDTO getSelectedRowObject(RowSelectionEvent event){
+ Set<Row> set = event.getSelectedRows();
+ if(set.size() == 1) {
+ int rowIdx = set.iterator().next().getRowIndex();
+ String id = pagingScrollTable.getDataTable().getHTML(rowIdx, 0);
+ FileHeaderDTO m = tableModel.getUserById(Long.parseLong(id));
+ return m;
+ }
+ return null;
+ }
+
+ public FileHeaderDTO getUser(Long id){
+
+ return tableModel.getUserById(id);
+ }
+
+
+
+ /**
+ * Initializes the scroll table
+ * @return
+ */
+ private PagingScrollTable<FileHeaderDTO> createScrollTable() {
+ // create our own table model
+ tableModel = new DataSourceTableModel();
+ // add it to cached table model
+ cachedTableModel = createCachedTableModel(tableModel);
+
+ // create the table definition
+ TableDefinition<FileHeaderDTO> tableDef = createTableDefinition();
+
+ // create the paging scroll table
+ pagingScrollTable = new PagingScrollTable<FileHeaderDTO>(cachedTableModel, tableDef);
+ pagingScrollTable.setPageSize(10);
+ pagingScrollTable.setEmptyTableWidget(new HTML("There is no data to display"));
+ pagingScrollTable.getDataTable().setSelectionPolicy(SelectionPolicy.ONE_ROW);
+
+ FixedWidthGridBulkRenderer<FileHeaderDTO> bulkRenderer = new FixedWidthGridBulkRenderer<FileHeaderDTO>(pagingScrollTable.getDataTable(), pagingScrollTable);
+ pagingScrollTable.setBulkRenderer(bulkRenderer);
+
+
+ pagingScrollTable.setCellPadding(3);
+ pagingScrollTable.setCellSpacing(0);
+ pagingScrollTable.setResizePolicy(ScrollTable.ResizePolicy.FILL_WIDTH);
+
+ pagingScrollTable.setSortPolicy(SortPolicy.SINGLE_CELL);
+
+ return pagingScrollTable;
+ }
+
+ public void addRowSelectionHandler(RowSelectionHandler handler){
+ pagingScrollTable.getDataTable().addRowSelectionHandler(handler);
+ }
+
+ /**
+ * Create the {@link CachedTableModel}
+ * @param aTableModel
+ * @return
+ */
+ private CachedTableModel<FileHeaderDTO> createCachedTableModel(DataSourceTableModel aTableModel) {
+ CachedTableModel<FileHeaderDTO> tm = new CachedTableModel<FileHeaderDTO>(aTableModel);
+ tm.setPreCachedRowCount(20);
+ tm.setPostCachedRowCount(20);
+ tm.setRowCount(20);
+ return tm;
+ }
+
+ private DefaultTableDefinition<FileHeaderDTO> createTableDefinition() {
+ tableDefinition = new DefaultTableDefinition<FileHeaderDTO>();
+
+ final String[] rowColors = new String[] { "#FFFFDD", "EEEEEE" };
+ tableDefinition.setRowRenderer(new DefaultRowRenderer<FileHeaderDTO>(rowColors));
+
+ // id
+ {
+ IdColumnDefinition columnDef = new IdColumnDefinition();
+ columnDef.setColumnSortable(true);
+ columnDef.setColumnTruncatable(false);
+ columnDef.setPreferredColumnWidth(35);
+ columnDef.setHeader(0, new HTML("Id"));
+ columnDef.setHeaderCount(1);
+ columnDef.setHeaderTruncatable(false);
+ tableDefinition.addColumnDefinition(columnDef);
+ }
+ {
+ NameColumnDefinition columnDef = new NameColumnDefinition();
+ columnDef.setColumnSortable(true);
+ columnDef.setColumnTruncatable(true);
+ columnDef.setHeader(0, new HTML("File Name"));
+ columnDef.setHeaderCount(1);
+ columnDef.setHeaderTruncatable(false);
+ tableDefinition.addColumnDefinition(columnDef);
+ }
+ {
+ UriColumnDefinition columnDef = new UriColumnDefinition();
+ columnDef.setColumnSortable(true);
+ columnDef.setColumnTruncatable(true);
+ columnDef.setHeader(0, new HTML("URI"));
+ columnDef.setHeaderCount(1);
+ columnDef.setHeaderTruncatable(false);
+ tableDefinition.addColumnDefinition(columnDef);
+ }
+ // username
+ {
+ UserColumnDefinition columnDef = new UserColumnDefinition();
+ columnDef.setColumnSortable(true);
+ columnDef.setColumnTruncatable(true);
+ columnDef.setHeader(0, new HTML("Username"));
+ columnDef.setHeaderCount(1);
+ columnDef.setHeaderTruncatable(false);
+ tableDefinition.addColumnDefinition(columnDef);
+ }
+ {
+ FilesizeDefinition columnDef = new FilesizeDefinition();
+ columnDef.setColumnSortable(true);
+ columnDef.setColumnTruncatable(true);
+ columnDef.setHeader(0, new HTML("File Size"));
+ columnDef.setHeaderCount(1);
+ columnDef.setHeaderTruncatable(false);
+ tableDefinition.addColumnDefinition(columnDef);
+ }
+ {
+ DeletedColumnDefinition columnDef = new DeletedColumnDefinition();
+ columnDef.setColumnSortable(true);
+ columnDef.setColumnTruncatable(true);
+ columnDef.setHeader(0, new HTML("Deleted"));
+ columnDef.setHeaderCount(1);
+ columnDef.setHeaderTruncatable(false);
+ columnDef.setCellRenderer(new CellRenderer<FileHeaderDTO, Boolean>() {
+
+ @Override
+ public void renderRowValue(FileHeaderDTO rowValue, ColumnDefinition<FileHeaderDTO, Boolean> aColumnDef, AbstractCellView<FileHeaderDTO> view) {
+ CheckBox check = new CheckBox();
+ check.setValue(aColumnDef.getCellValue(rowValue));
+ check.setEnabled(false);
+ view.setWidget(check);
+
+ }
+ });
+ tableDefinition.addColumnDefinition(columnDef);
+ }
+
+
+ {
+ CreationColumnDefinition columnDef = new CreationColumnDefinition();
+ columnDef.setColumnSortable(true);
+ columnDef.setColumnTruncatable(true);
+ columnDef.setHeader(0, new HTML("Creation Date"));
+ columnDef.setHeaderCount(1);
+ columnDef.setHeaderTruncatable(false);
+ tableDefinition.addColumnDefinition(columnDef);
+ }
+
+ {
+ LastModifiedColumnDefinition columnDef = new LastModifiedColumnDefinition();
+ columnDef.setColumnSortable(true);
+ columnDef.setColumnTruncatable(true);
+ columnDef.setHeader(0, new HTML("Modification Date"));
+ columnDef.setHeaderCount(1);
+ columnDef.setHeaderTruncatable(false);
+ tableDefinition.addColumnDefinition(columnDef);
+ }
+
+
+
+ return tableDefinition;
+ }
+
+
+ private class DataSourceTableModel extends MutableTableModel<FileHeaderDTO> {
+ private Map<Long, FileHeaderDTO> map;
+ private FileSorter sorter = new FileSorter();
+ public void setData(List<FileHeaderDTO> list) {
+ // toss the list, index by id in a map.
+ map = new HashMap<Long, FileHeaderDTO>(list.size());
+ for(FileHeaderDTO m : list)
+ map.put(m.getId(), m);
+ }
+
+ public FileHeaderDTO getUserById(long id) {
+ return map.get(id);
+ }
+
+ @Override
+ protected boolean onRowInserted(int beforeRow) {
+ return true;
+ }
+
+ @Override
+ protected boolean onRowRemoved(int row) {
+ return true;
+ }
+
+ @Override
+ protected boolean onSetRowValue(int row, FileHeaderDTO rowValue) {
+
+ return true;
+ }
+
+ @Override
+ public void requestRows(
+ final Request request,
+ TableModel.Callback<FileHeaderDTO> callback) {
+
+ callback.onRowsReady(request, new Response<FileHeaderDTO>(){
+
+ @Override
+ public Iterator<FileHeaderDTO> getRowValues() {
+ final int col = request.getColumnSortList().getPrimaryColumn();
+ final boolean ascending = request.getColumnSortList().isPrimaryAscending();
+ if(col < 0)
+ map = sorter.sort(map, new FileComparator(ascending,0));
+ else
+ map = sorter.sort(map, new FileComparator(ascending,col));
+ return map.values().iterator();
+ }});
+ }
+
+ }
+
+
+ private final class IdColumnDefinition extends AbstractColumnDefinition<FileHeaderDTO, Long> {
+ @Override
+ public Long getCellValue(FileHeaderDTO rowValue) {
+ return rowValue.getId();
+ }
+ @Override
+ public void setCellValue(FileHeaderDTO rowValue, Long cellValue) { }
+ }
+
+
+ private final class NameColumnDefinition extends
+ AbstractColumnDefinition<FileHeaderDTO, String> {
+ @Override
+ public String getCellValue(final FileHeaderDTO rowValue) {
+ return rowValue.getName();
+ }
+
+ @Override
+ public void setCellValue(final FileHeaderDTO rowValue, final String cellValue) {}
+ }
+
+
+ private final class UriColumnDefinition extends
+ AbstractColumnDefinition<FileHeaderDTO, String> {
+ @Override
+ public String getCellValue(final FileHeaderDTO rowValue) {
+ return rowValue.getURI();
+ }
+
+ @Override
+ public void setCellValue(final FileHeaderDTO rowValue, final String cellValue) {}
+ }
+
+
+ private final class FilesizeDefinition extends
+ AbstractColumnDefinition<FileHeaderDTO, String> {
+ @Override
+ public String getCellValue(final FileHeaderDTO rowValue) {
+ return rowValue.getFileSizeAsString();
+ }
+
+ @Override
+ public void setCellValue(final FileHeaderDTO rowValue, final String cellValue) {}
+ }
+
+
+ private final class UserColumnDefinition extends
+ AbstractColumnDefinition<FileHeaderDTO, String> {
+ @Override
+ public String getCellValue(final FileHeaderDTO rowValue) {
+ return rowValue.getOwner().getUsername();
+ }
+
+ @Override
+ public void setCellValue(final FileHeaderDTO rowValue, final String cellValue) {}
+ }
+
+
+ private final class DeletedColumnDefinition extends
+ AbstractColumnDefinition<FileHeaderDTO, Boolean> {
+ @Override
+ public Boolean getCellValue(final FileHeaderDTO rowValue) {
+ return rowValue.isDeleted();
+ }
+
+ @Override
+ public void setCellValue(final FileHeaderDTO rowValue, final Boolean cellValue) {
+
+ }
+ }
+
+ private final class CreationColumnDefinition extends AbstractColumnDefinition<FileHeaderDTO, String> {
+
+ @Override
+ public String getCellValue(final FileHeaderDTO rowValue) {
+ return DateTimeFormat.getFormat("dd/MM/yyyy hh:mm:ss tt").format(rowValue.getAuditInfo().getCreationDate());
+ }
+
+ @Override
+ public void setCellValue(final FileHeaderDTO rowValue, final String cellValue) {}
+ }
+
+ private final class LastModifiedColumnDefinition extends AbstractColumnDefinition<FileHeaderDTO, String> {
+
+ @Override
+ public String getCellValue(final FileHeaderDTO rowValue) {
+ return DateTimeFormat.getFormat("dd/MM/yyyy hh:mm:ss tt").format(rowValue.getAuditInfo().getModificationDate());
+ }
+
+ @Override
+ public void setCellValue(final FileHeaderDTO rowValue, final String cellValue) {}
+ }
+
+
+
+ public static class FileSorter {
+
+
+ public Map<Long, FileHeaderDTO> sort(Map<Long, FileHeaderDTO> map, Comparator<FileHeaderDTO> comparator) {
+ final List<FileHeaderDTO> list = new LinkedList<FileHeaderDTO>(map.values());
+ Collections.sort(list, comparator);
+ Map<Long, FileHeaderDTO> result = new LinkedHashMap<Long, FileHeaderDTO>(list.size());
+ for(FileHeaderDTO p : list)
+ result.put(p.getId(), p);
+ return result;
+ }
+
+ public final static class FileComparator implements Comparator<FileHeaderDTO> {
+
+ private final boolean ascending;
+ private int property;
+ public FileComparator(boolean isAscending, int aProperty) {
+ ascending = isAscending;
+ property = aProperty;
+ }
+
+ @Override
+ public int compare(FileHeaderDTO m1, FileHeaderDTO m2) {
+ GWT.log("sorting:"+property+" "+m1.getFileSize()+" "+m2.getFileSize());
+ switch(property){
+ case 0://id
+ if(ascending)
+ return m1.getId().compareTo(m2.getId());
+ return m2.getId().compareTo(m1.getId());
+ case 1://name
+ if(ascending)
+ return m1.getName().compareTo(m2.getName());
+ return m2.getName().compareTo(m1.getName());
+ case 2://uri
+ if(ascending)
+ return m1.getURI().compareTo(m2.getURI());
+ return m2.getURI().compareTo(m1.getURI());
+ case 3://file size
+ if(ascending)
+ return new Long(m1.getFileSize()).compareTo(new Long(m2.getFileSize()));
+ return new Long(m2.getFileSize()).compareTo(new Long(m1.getFileSize()));
+ case 4://deleted
+ if(ascending)
+ return new Boolean(m1.isDeleted()).compareTo(new Boolean(m2.isDeleted()));
+ return new Boolean(m2.isDeleted()).compareTo(new Boolean(m1.isDeleted()));
+ case 5://created
+ return new DateComparator(ascending).compare(m1.getAuditInfo().getCreationDate(), m2.getAuditInfo().getCreationDate());
+ case 6://modified
+ return new DateComparator(ascending).compare(m1.getAuditInfo().getModificationDate(), m2.getAuditInfo().getModificationDate());
+ default:
+ if(ascending)
+ return m1.getId().compareTo(m2.getId());
+ return m2.getId().compareTo(m1.getId());
+ }
+
+ }
+ }
+
+
+ public final static class DateComparator implements Comparator<Date> {
+
+ private final boolean ascending;
+
+ public DateComparator(boolean isAscending) {
+ ascending = isAscending;
+ }
+
+ @Override
+ public int compare(Date d1, Date d2) {
+ if(d1==null && d2==null)
+ return 0;
+ if(d1==null && d2 != null)
+ return -1;
+ if(d2==null && d1 != null)
+ return 1;
+ if(ascending)
+ return d1.compareTo(d2);
+ return d2.compareTo(d1);
+ }
+ }
+ }
+
+
+
+}
--- /dev/null
+package gr.ebs.gss.admin.client.ui;
+
+import gr.ebs.gss.admin.client.TwoAdmin;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.uibinder.client.UiBinder;
+import com.google.gwt.uibinder.client.UiField;
+import com.google.gwt.uibinder.client.UiHandler;
+import com.google.gwt.user.client.Window;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.gwt.user.client.ui.Anchor;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.Widget;
+
+public class HeaderPanel extends Composite {
+
+ interface Binder extends UiBinder<Widget, HeaderPanel> { }
+ private static final Binder binder = GWT.create(Binder.class);
+
+ @UiField Anchor signOutLink;
+
+ public HeaderPanel() {
+ initWidget(binder.createAndBindUi(this));
+ }
+
+ @UiHandler("signOutLink")
+ void onSignOutClicked(@SuppressWarnings("unused") ClickEvent event) {
+ TwoAdmin.get().getAdminService().logout(new AsyncCallback<Void>() {
+
+ @Override
+ public void onSuccess(Void result) {
+ Window.open("/admin", "_self", null);
+
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ TwoAdmin.get().showErrorBox(caught.getMessage());
+
+ }
+ });
+ }
+
+}
--- /dev/null
+<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
+<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
+ xmlns:g="urn:import:com.google.gwt.user.client.ui"
+ xmlns:admin='urn:import:gr.ebs.gss.admin.client'>
+ <ui:image field='logo' src='service-logo.png'/>
+
+ <ui:style>
+ .statusDiv {
+ text-align: right;
+ margin: 1em;
+ }
+
+ .linksDiv {
+ text-align: right;
+ }
+
+ @if user.agent ie6 {
+ .logo {
+ background-image: url(logo_ie6.gif);
+ width: 140px;
+ height: 75px;
+ position: absolute;
+ }
+ } @else {
+ @sprite .logo {
+ gwt-image: 'logo';
+ position: absolute;
+ }
+ }
+ </ui:style>
+
+ <g:HTMLPanel>
+ <div class='{style.logo}'/>
+
+ <div class="{style.statusDiv}">
+ <div>
+ <b>Administration Panel</b>
+ </div>
+
+ <div class='{style.linksDiv}'>
+ <g:Anchor href='javascript:;' ui:field='signOutLink'>Sign Out</g:Anchor>
+ </div>
+ </div>
+ </g:HTMLPanel>
+</ui:UiBinder>
--- /dev/null
+/*
+ * Copyright 2010 Electronic Business Systems Ltd.
+ *
+ * This file is part of GSS.
+ *
+ * GSS is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GSS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GSS. If not, see <http://www.gnu.org/licenses/>.
+ */
+package gr.ebs.gss.admin.client.ui;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.uibinder.client.UiBinder;
+import com.google.gwt.uibinder.client.UiField;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.Widget;
+
+
+/**
+ * @author kman
+ *
+ */
+public class OperationsPanel extends Composite {
+
+ private static UserPanelUiBinder uiBinder = GWT
+ .create(UserPanelUiBinder.class);
+
+ interface UserPanelUiBinder extends UiBinder<Widget, OperationsPanel> {
+ }
+
+
+
+
+ //@UiField Button fixButton;
+
+ public OperationsPanel() {
+
+
+ initWidget(uiBinder.createAndBindUi(this));
+
+
+ }
+
+ /*@UiHandler("fixButton")
+ void handleClick(@SuppressWarnings("unused") ClickEvent e){
+ DeferredCommand.addCommand(new Command() {
+
+ @Override
+ public void execute() {
+ TwoAdmin.get().showLoadingBox();
+ TwoAdmin.get().getAdminService().fixSharedFlagForAllFoldersAndFiles( new AsyncCallback<Void>() {
+
+ @Override
+ public void onSuccess(Void result) {
+ TwoAdmin.get().hideLoadingBox();
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ GWT.log("Error Fixing Permissions", caught);
+ TwoAdmin.get().hideLoadingBox();
+ TwoAdmin.get().showErrorBox("Error Fixing Permissions");
+
+ }
+ });
+
+ }
+ });
+ }*/
+
+
+
+
+
+}
--- /dev/null
+<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
+<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
+ xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:adminui='urn:import:gr.ebs.gss.admin.client.ui'
+ xmlns:dp="urn:import:com.google.gwt.user.datepicker.client"
+ >
+ <ui:style>
+
+ </ui:style>
+
+ <g:VerticalPanel addStyleNames="Gmnuri3D" width="100%">
+ <g:HTMLPanel>
+ <div>
+ <h3>Administrative Operations</h3>
+ </div>
+ </g:HTMLPanel>
+ <!-- g:HorizontalPanel spacing="3">
+ <g:cell horizontalAlignment="ALIGN_CENTER" verticalAlignment="ALIGN_MIDDLE">
+ <g:HTML>Fix Sharing flag:</g:HTML>
+ </g:cell>
+
+ <g:cell horizontalAlignment="ALIGN_CENTER" verticalAlignment="ALIGN_MIDDLE">
+ <g:Button ui:field="fixButton">Search</g:Button>
+ </g:cell>
+
+ </g:HorizontalPanel -->
+
+
+
+ </g:VerticalPanel>
+
+</ui:UiBinder>
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright 2008, 2009 Electronic Business Systems Ltd.
+ *
+ * This file is part of GSS.
+ *
+ * GSS is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GSS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GSS. If not, see <http://www.gnu.org/licenses/>.
+ */
+package gr.ebs.gss.admin.client.ui;
+
+import gr.ebs.gss.admin.client.TwoAdmin;
+import gr.ebs.gss.server.domain.dto.PermissionDTO;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.http.client.URL;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.CheckBox;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.FlexTable;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.HasHorizontalAlignment;
+import com.google.gwt.user.client.ui.VerticalPanel;
+
+
+/**
+ * @author kman
+ *
+ */
+public class PermissionsList extends Composite {
+
+ int selectedRow = -1;
+ int permissionCount=-1;
+ Set<PermissionDTO> permissions = null;
+
+ final VerticalPanel permPanel = new VerticalPanel();
+ final FlexTable permTable = new FlexTable();
+ final String owner;
+ PermissionDTO toRemove = null;
+ private boolean hasChanges = false;
+ private boolean hasAddition = false;
+ private boolean allowEditPermissions = false;
+ private String uri;
+ public PermissionsList(Set<PermissionDTO> thePermissions, String anOwner, boolean _allowEditPermissions){
+ owner = anOwner;
+ permissions = new HashSet<PermissionDTO>();
+ permissions.addAll(thePermissions);
+ permTable.setText(0, 0, "Users/Groups");
+ permTable.setText(0, 1, "Read");
+ permTable.setText(0, 2, "Write");
+ permTable.setText(0, 3, "Modify Access");
+ permTable.setText(0, 4, "");
+ permTable.getFlexCellFormatter().setStyleName(0, 0, "props-toplabels");
+ permTable.getFlexCellFormatter().setStyleName(0, 1, "props-toplabels");
+ permTable.getFlexCellFormatter().setStyleName(0, 2, "props-toplabels");
+ permTable.getFlexCellFormatter().setStyleName(0, 3, "props-toplabels");
+ permPanel.add(permTable);
+ Button savePermissions = new Button("Save");
+ permPanel.add(savePermissions);
+
+ savePermissions.addClickHandler(new ClickHandler() {
+
+ @Override
+ public void onClick(ClickEvent event) {
+ updatePermissionsAccordingToInput();
+ if(hasChanges())
+ TwoAdmin.get().getAdminService().setFilePermissions(uri,permissions, new AsyncCallback<Void>() {
+
+ @Override
+ public void onSuccess(Void result) {
+
+
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ GWT.log("Error fetching file", caught);
+ TwoAdmin.get().showErrorBox("Unable to Find File");
+
+ }
+ });
+
+ }
+ });
+ permPanel.addStyleName("gss-TabPanelBottom");
+ allowEditPermissions = _allowEditPermissions;
+ initWidget(permPanel);
+ updateTable();
+ }
+
+ public boolean hasChanges(){
+ return hasChanges || hasAddition;
+ }
+
+ public void clear(){
+ permissions= new HashSet<PermissionDTO>();
+ uri=null;
+ updateTable();
+ }
+ public void update(Set<PermissionDTO> per, String aUri){
+ permissions=per;
+ uri=aUri;
+ updateTable();
+ }
+ public void updateTable(){
+ int i=1;
+ if(toRemove != null){
+ permissions.remove(toRemove);
+ toRemove = null;
+ }
+ for(final PermissionDTO dto : permissions){
+
+ Button removeButton = new Button("remove", new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
+ toRemove = dto;
+ updateTable();
+ hasChanges = true;
+ }
+ });
+
+ if(dto.getUser() !=null)
+ if(dto.getUser()!=null && dto.getUser().getUsername().equals(owner)){
+ permTable.setHTML(i, 0, "<span>" + " Owner</span>");
+ removeButton.setVisible(false);
+ }
+ else{
+ HTML userLabel = new HTML("<a href='#'>"+dto.getUser().getUsername()+"</a></span>");
+ permTable.setWidget(i, 0, userLabel);
+ userLabel.addClickHandler(new ClickHandler() {
+
+ @Override
+ public void onClick(ClickEvent event) {
+ TwoAdmin.get().searchUsers("username:"+dto.getUser().getUsername());
+
+ }
+ });
+ }
+ else if(dto.getGroup() != null) {
+ //String user = GSS.get().getCurrentUserResource().getUsername();
+ String[] names = dto.getGroup().getName().split("/");
+ String name = URL.decodeComponent(names[names.length - 1]);
+ //String ownr = names.length>1 ? URL.decodeComponent(names[names.length - 3]) : user;
+ String groupName = name;
+ permTable.setHTML(i, 0, "<span>" + " "+groupName+"</span>");
+ }
+ CheckBox read = new CheckBox();
+ read.setValue(dto.getRead());
+ CheckBox write = new CheckBox();
+ write.setValue(dto.getWrite());
+ CheckBox modify = new CheckBox();
+ modify.setValue(dto.getModifyACL());
+ permTable.setWidget(i, 1, read);
+ permTable.setWidget(i, 2, write);
+ permTable.setWidget(i, 3, modify);
+ if (dto.getUser()!=null && dto.getUser().getUsername().equals(owner) || !allowEditPermissions) {
+ read.setEnabled(false);
+ write.setEnabled(false);
+ modify.setEnabled(false);
+ }
+ else
+ permTable.setWidget(i, 4, removeButton);
+ permTable.getFlexCellFormatter().setStyleName(i, 0, "props-labels");
+ permTable.getFlexCellFormatter().setHorizontalAlignment(i, 1, HasHorizontalAlignment.ALIGN_CENTER);
+ permTable.getFlexCellFormatter().setHorizontalAlignment(i, 2, HasHorizontalAlignment.ALIGN_CENTER);
+ permTable.getFlexCellFormatter().setHorizontalAlignment(i, 3, HasHorizontalAlignment.ALIGN_CENTER);
+ i++;
+ }
+ for(; i<permTable.getRowCount(); i++)
+ permTable.removeRow(i);
+ hasChanges = false;
+
+ }
+
+ public void updatePermissionsAccordingToInput(){
+ int i=1;
+ for(PermissionDTO dto : permissions){
+ /*if(dto.getId() == null)
+ hasChanges =true;*/
+ CheckBox r = (CheckBox) permTable.getWidget(i, 1);
+ CheckBox w = (CheckBox) permTable.getWidget(i, 2);
+ CheckBox m = (CheckBox) permTable.getWidget(i, 3);
+ if(dto.getRead() != r.getValue() || dto.getWrite() != w.getValue() || dto.getModifyACL() != m.getValue())
+ hasChanges = true;
+ dto.setRead(r.getValue());
+ dto.setWrite(w.getValue());
+ dto.setModifyACL(m.getValue());
+ i++;
+ }
+ }
+
+
+ /**
+ * Retrieve the permissions.
+ *
+ * @return the permissions
+ */
+ public Set<PermissionDTO> getPermissions() {
+ return permissions;
+ }
+
+ public void addPermission(PermissionDTO permission){
+ permissions.add(permission);
+ hasAddition = true;
+ }
+
+
+}
--- /dev/null
+/*
+ * Copyright 2010 Electronic Business Systems Ltd.
+ *
+ * This file is part of GSS.
+ *
+ * GSS is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GSS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GSS. If not, see <http://www.gnu.org/licenses/>.
+ */
+package gr.ebs.gss.admin.client.ui;
+
+import gr.ebs.gss.admin.client.TwoAdmin;
+import gr.ebs.gss.server.domain.dto.UserClassDTO;
+
+import java.util.List;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.uibinder.client.UiBinder;
+import com.google.gwt.uibinder.client.UiField;
+import com.google.gwt.uibinder.client.UiHandler;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.FlexTable;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.HasHorizontalAlignment;
+import com.google.gwt.user.client.ui.TextBox;
+import com.google.gwt.user.client.ui.Widget;
+
+
+/**
+ * @author kman
+ *
+ */
+public class UserClassListPanel extends Composite {
+
+ private static UserClassListPanelUiBinder uiBinder = GWT.create(UserClassListPanelUiBinder.class);
+
+ interface UserClassListPanelUiBinder extends UiBinder<Widget, UserClassListPanel> {
+ }
+ @UiField(provided=true)
+ FlexTable userClassList;
+ @UiField(provided=true)
+ FlexTable userClassEdit;
+ @UiField
+ Button saveButton;
+ @UiField
+ Button newButton;
+ TextBox nameBox = new TextBox();
+ TextBox quotaBox = new TextBox();
+ TextBox bandwithBox = new TextBox();
+ UserClassDTO userClass;
+
+ public UserClassListPanel() {
+ userClassList = new FlexTable();
+ userClassEdit = new FlexTable();
+ userClassList.setText(0, 0, "Name");
+ userClassList.setText(0, 1, "Quota");
+ userClassList.setText(0, 2, "Bandwith Quota");
+ userClassList.setText(0, 3, "");
+ userClassList.setText(0, 4, "");
+ userClassList.getFlexCellFormatter().setStyleName(0, 0, "props-toplabels");
+ userClassList.getFlexCellFormatter().setStyleName(0, 1, "props-toplabels");
+ userClassList.getFlexCellFormatter().setStyleName(0, 2, "props-toplabels");
+ userClassList.getFlexCellFormatter().setStyleName(0, 3, "props-toplabels");
+ userClassList.getFlexCellFormatter().setStyleName(0, 4, "props-toplabels");
+ userClassList.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
+ userClassList.getFlexCellFormatter().setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_CENTER);
+ userClassList.getFlexCellFormatter().setHorizontalAlignment(0, 2, HasHorizontalAlignment.ALIGN_CENTER);
+ userClassList.getFlexCellFormatter().setHorizontalAlignment(0, 3, HasHorizontalAlignment.ALIGN_CENTER);
+ userClassList.getFlexCellFormatter().setHorizontalAlignment(0, 4, HasHorizontalAlignment.ALIGN_CENTER);
+ userClassList.addStyleName("gss-permList");
+
+
+
+ userClassEdit.setText(0, 0, "Name");
+ userClassEdit.setText(1, 0, "Quota");
+ userClassEdit.setText(2, 0, "Bandwith Quota");
+ userClassEdit.setText(3, 0, "");
+
+ userClassEdit.setWidget(0, 1, nameBox);
+ userClassEdit.setWidget(1, 1, quotaBox);
+ userClassEdit.setWidget(2, 1, bandwithBox);
+ userClassEdit.setText(3, 0, "");
+ userClassList.getFlexCellFormatter().setStyleName(0, 0, "props-toplabels");
+ userClassList.getFlexCellFormatter().setStyleName(1, 0, "props-toplabels");
+ userClassList.getFlexCellFormatter().setStyleName(2, 0, "props-toplabels");
+ userClassList.getFlexCellFormatter().setStyleName(3, 0, "props-toplabels");
+ initWidget(uiBinder.createAndBindUi(this));
+
+
+ updateTable();
+ }
+
+ public void updateTable(){
+ clearInput();
+ clearTable();
+ TwoAdmin.get().getAdminService().getUserClasses(new AsyncCallback<List<UserClassDTO>>() {
+
+ @Override
+ public void onSuccess(List<UserClassDTO> result) {
+ int i=1;
+ for(final UserClassDTO dto : result){
+ userClassList.setHTML(i, 0, "<span>" + dto.getName() + "</span>");
+ userClassList.setHTML(i, 1, "<span>" + dto.getQuotaAsString() + "</span>");
+ userClassList.setHTML(i, 2, "<span></span>"); // XXX
+ HTML edit = new HTML("<a href='#'>Edit</a>");
+ edit.addClickHandler(new ClickHandler() {
+
+ @Override
+ public void onClick(ClickEvent event) {
+ userClass = dto;
+ updateInput();
+ }
+ });
+ userClassList.setWidget(i, 3, edit);
+ HTML delete = new HTML("<a href='#'>Remove</a>");
+ delete.addClickHandler(new ClickHandler() {
+
+ @Override
+ public void onClick(ClickEvent event) {
+ clearInput();
+ TwoAdmin.get().getAdminService().removeUserClass(dto, new AsyncCallback<Void>() {
+
+ @Override
+ public void onFailure(Throwable caught) {
+ TwoAdmin.get().hideLoadingBox();
+ GWT.log("Error deleting class", caught);
+ TwoAdmin.get().showErrorBox("Unable to Delete User Class");
+
+ }
+
+ @Override
+ public void onSuccess(Void removeResult) {
+ updateTable();
+
+ }});
+ }
+ });
+ userClassList.setWidget(i, 4, delete);
+ userClassList.getFlexCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_CENTER);
+ userClassList.getFlexCellFormatter().setHorizontalAlignment(i, 1, HasHorizontalAlignment.ALIGN_CENTER);
+ userClassList.getFlexCellFormatter().setHorizontalAlignment(i, 2, HasHorizontalAlignment.ALIGN_CENTER);
+ userClassList.getFlexCellFormatter().setHorizontalAlignment(i, 3, HasHorizontalAlignment.ALIGN_CENTER);
+ userClassList.getFlexCellFormatter().setHorizontalAlignment(i, 4, HasHorizontalAlignment.ALIGN_CENTER);
+ i++;
+ }
+
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ // TODO Auto-generated method stub
+
+ }
+ });
+ }
+ public void clearTable(){
+ int count = userClassList.getRowCount();
+ for(int i=1;i<count;i++){
+ userClassList.setHTML(i, 0, "<span></span>");
+ userClassList.setHTML(i, 1, "<span></span>");
+ userClassList.setHTML(i, 2, "<span></span>");
+ userClassList.setHTML(i, 3, "<span></span>");
+ userClassList.setHTML(i, 4, "<span></span>");
+ }
+ }
+ public void clearInput(){
+ userClass= new UserClassDTO();
+ nameBox.setText("");
+ quotaBox.setText("");
+ bandwithBox.setText("");
+ }
+
+ public void updateInput(){
+ nameBox.setText(userClass.getName());
+ quotaBox.setText(String.valueOf(userClass.getQuota()));
+ bandwithBox.setText(""); // XXX
+ }
+
+ @UiHandler("newButton")
+ public void handleNew(@SuppressWarnings("unused") ClickEvent e){
+ clearInput();
+ }
+
+ @UiHandler("saveButton")
+ public void handleSave(@SuppressWarnings("unused") ClickEvent e){
+ userClass.setName(nameBox.getText());
+ userClass.setQuota(Long.parseLong(quotaBox.getText()));
+ TwoAdmin.get().getAdminService().saveOrUpdateUserClass(userClass, new AsyncCallback<Void>() {
+
+ @Override
+ public void onFailure(Throwable caught) {
+ TwoAdmin.get().hideLoadingBox();
+ GWT.log("Error saving class", caught);
+ TwoAdmin.get().showErrorBox("Unable to Save User Class");
+
+ }
+
+ @Override
+ public void onSuccess(Void result) {
+ updateTable();
+
+ }});
+ }
+
+
+}
\ No newline at end of file
--- /dev/null
+<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
+<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
+ xmlns:g="urn:import:com.google.gwt.user.client.ui">
+ <ui:style>
+ /* Add CSS here. See the GWT docs on UI Binder for more details */
+ .important {
+ font-weight: bold;
+ }
+ </ui:style>
+ <g:VerticalPanel addStyleNames="Gmnuri3D" width="100%">
+ <g:HTMLPanel>
+ <div>
+ <h3>User Classes</h3>
+ </div>
+ </g:HTMLPanel>
+ <g:HorizontalPanel>
+ <g:FlexTable ui:field="userClassList"></g:FlexTable>
+ </g:HorizontalPanel>
+ <g:HTMLPanel>
+ <div>
+ <h3>User Class</h3>
+ </div>
+ </g:HTMLPanel>
+ <g:HorizontalPanel>
+ <g:FlexTable ui:field="userClassEdit"></g:FlexTable>
+ </g:HorizontalPanel>
+ <g:HorizontalPanel>
+ <g:Button ui:field="newButton">New</g:Button> <g:Button ui:field="saveButton">Save</g:Button>
+ </g:HorizontalPanel>
+
+ </g:VerticalPanel>
+</ui:UiBinder>
\ No newline at end of file
--- /dev/null
+package gr.ebs.gss.admin.client.ui;
+
+import gr.ebs.gss.admin.client.TwoAdmin;
+import gr.ebs.gss.server.domain.dto.StatsDTO;
+import gr.ebs.gss.server.domain.dto.UserClassDTO;
+import gr.ebs.gss.server.domain.dto.UserDTO;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.event.dom.client.KeyPressEvent;
+import com.google.gwt.event.dom.client.KeyPressHandler;
+import com.google.gwt.gen2.table.event.client.RowSelectionEvent;
+import com.google.gwt.gen2.table.event.client.RowSelectionHandler;
+import com.google.gwt.i18n.client.DateTimeFormat;
+import com.google.gwt.uibinder.client.UiBinder;
+import com.google.gwt.uibinder.client.UiField;
+import com.google.gwt.uibinder.client.UiHandler;
+import com.google.gwt.user.client.Command;
+import com.google.gwt.user.client.DeferredCommand;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.CheckBox;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.DialogBox;
+import com.google.gwt.user.client.ui.Grid;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.ListBox;
+import com.google.gwt.user.client.ui.TextBox;
+import com.google.gwt.user.client.ui.VerticalPanel;
+import com.google.gwt.user.client.ui.Widget;
+import com.google.gwt.user.datepicker.client.DateBox;
+
+public class UserPanel extends Composite {
+
+ private static UserPanelUiBinder uiBinder = GWT
+ .create(UserPanelUiBinder.class);
+
+ interface UserPanelUiBinder extends UiBinder<Widget, UserPanel> {
+ }
+
+
+ @UiField(provided=true) DateBox dateBox = new DateBox();
+ @UiField(provided=true) Button showLastLoginButton = new Button();
+ @UiField TextBox searchBox;
+ @UiField Button searchButton;
+ @UiField Button showInactiveButton;
+ @UiField(provided=true) final UsersTable usersTable = new UsersTable();
+ @UiField(provided=true) Grid g =new Grid(8,6);
+ private Object lastQuery;
+
+ public UserPanel() {
+ DateTimeFormat dateFormat = DateTimeFormat.getLongDateFormat();
+ dateBox.setFormat(new DateBox.DefaultFormat(dateFormat));
+ g.setCellPadding(5);
+ g.setCellSpacing(5);
+ g.setText( 0, 0, "Username:" );
+ g.getCellFormatter().setStyleName(0, 0, "props-toplabels");
+ g.setText( 1, 0, "Name:" );
+ g.getCellFormatter().setStyleName(1, 0, "props-toplabels");
+ g.setText( 2, 0, "Email:" );
+ g.getCellFormatter().setStyleName(2, 0, "props-toplabels");
+ g.setText( 3, 0, "User Class:" );
+ g.getCellFormatter().setStyleName(3, 0, "props-toplabels");
+ g.setText( 4, 0, "Active:" );
+ g.getCellFormatter().setStyleName(4, 0, "props-toplabels");
+ g.setText( 0, 2, "Quota:" );
+ g.getCellFormatter().setStyleName(0, 2, "props-toplabels");
+ g.setText( 1, 2, "Bandwith Quota:" );
+ g.getCellFormatter().setStyleName(1, 2, "props-toplabels");
+ g.setText( 2, 2, "File Count:" );
+ g.getCellFormatter().setStyleName(2, 2, "props-toplabels");
+ g.setText( 3, 2, "Total File Size:" );
+ g.getCellFormatter().setStyleName(3, 2, "props-toplabels");
+ g.setText( 4, 2, "Quota Left:" );
+ g.getCellFormatter().setStyleName(4, 2, "props-toplabels");
+ g.setText( 5, 2, "Bandwith Quota Used:" );
+ g.getCellFormatter().setStyleName(5, 2, "props-toplabels");
+ g.setText( 0, 4, "Quota Used%:" );
+ g.getCellFormatter().setStyleName(0, 4, "props-toplabels");
+ g.setText( 1, 4, "Bandwith Quota Used%:" );
+ g.getCellFormatter().setStyleName(1, 4, "props-toplabels");
+ initWidget(uiBinder.createAndBindUi(this));
+ searchBox.addKeyPressHandler(new KeyPressHandler() {
+
+ @Override
+ public void onKeyPress(KeyPressEvent event) {
+ char keyCode = event.getCharCode();
+ if (keyCode == '\r')
+ handleClick(null);
+ }
+ });
+ usersTable.addRowSelectionHandler(new RowSelectionHandler() {
+
+ @Override
+ public void onRowSelection(RowSelectionEvent event) {
+ final UserDTO user = usersTable.getSelectedRowObject(event);
+ clearProfile();
+ if(user!=null)
+ DeferredCommand.addCommand(new Command() {
+
+ @Override
+ public void execute() {
+ TwoAdmin.get().showLoadingBox();
+ TwoAdmin.get().getAdminService().getUserStatistics(user.getId(), new AsyncCallback<StatsDTO>() {
+
+ @Override
+ public void onSuccess(StatsDTO result) {
+ displayProfile(user,result);
+ TwoAdmin.get().hideLoadingBox();
+
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ GWT.log("Error requesting user statistics file", caught);
+ TwoAdmin.get().hideLoadingBox();
+ TwoAdmin.get().showErrorBox("Error requesting user statistics");
+
+ }
+ });
+
+ }
+ });
+
+ }
+ });
+
+
+ clearProfile();
+
+ }
+
+ @UiHandler("showInactiveButton")
+ void handleWaitingClick(@SuppressWarnings("unused") ClickEvent e){
+ lastQuery = true;
+ populateTable();
+ }
+
+ @UiHandler("searchButton")
+ void handleClick(@SuppressWarnings("unused") ClickEvent e){
+ final String toSearch = searchBox.getText();
+ if(toSearch == null || "".equals(toSearch.trim())){
+ TwoAdmin.get().showErrorBox("You must enter a query");
+ return;
+ }
+ lastQuery = toSearch;
+ populateTable(toSearch);
+ }
+
+ @UiHandler("showLastLoginButton")
+ void handleDateClick(@SuppressWarnings("unused") ClickEvent e){
+ final Date toSearch = dateBox.getValue();
+ if(toSearch == null){
+ TwoAdmin.get().showErrorBox("You must enter a query");
+ return;
+ }
+ lastQuery = toSearch;
+ populateTable(toSearch);
+ }
+
+
+ public void populateTable(String query){
+ TwoAdmin.get().showLoadingBox();
+ if(query.startsWith("username:")){
+ String username = query.replaceAll("username:","");
+ TwoAdmin.get().getAdminService().getUser(username, new AsyncCallback<UserDTO>() {
+
+ @Override
+ public void onFailure(Throwable caught) {
+ TwoAdmin.get().hideLoadingBox();
+ GWT.log("Error fetching users", caught);
+ TwoAdmin.get().showErrorBox("Unable to Find any Users");
+
+ }
+
+ @Override
+ public void onSuccess(final UserDTO user) {
+ List<UserDTO> res = new ArrayList<UserDTO>();
+ res.add(user);
+ usersTable.showUsers(res);
+ TwoAdmin.get().getAdminService().getUserStatistics(user.getId(), new AsyncCallback<StatsDTO>() {
+
+ @Override
+ public void onSuccess(StatsDTO result) {
+ displayProfile(user,result);
+ TwoAdmin.get().hideLoadingBox();
+
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ GWT.log("Error requesting user statistics file", caught);
+ TwoAdmin.get().hideLoadingBox();
+ TwoAdmin.get().showErrorBox("Error requesting user statistics");
+
+ }
+ });
+ }
+ });
+ } else
+ TwoAdmin.get().getAdminService().searchUsers(query,new AsyncCallback<List<UserDTO>>() {
+
+ @Override
+ public void onFailure(Throwable caught) {
+ TwoAdmin.get().hideLoadingBox();
+ GWT.log("Error fetching users", caught);
+ TwoAdmin.get().showErrorBox("Unable to Find any Users");
+ }
+
+ @Override
+ public void onSuccess(List<UserDTO> result) {
+ usersTable.showUsers(result);
+ TwoAdmin.get().hideLoadingBox();
+
+ }
+
+ });
+ }
+
+ private void populateTable(){
+ TwoAdmin.get().showLoadingBox();
+ TwoAdmin.get().getAdminService().getUsersWaitingActivation(new AsyncCallback<List<UserDTO>>() {
+
+ @Override
+ public void onFailure(Throwable caught) {
+ GWT.log("Error fetching users", caught);
+ TwoAdmin.get().showErrorBox("Unable to Find any Users");
+ TwoAdmin.get().hideLoadingBox();
+ }
+
+ @Override
+ public void onSuccess(List<UserDTO> result) {
+ usersTable.showUsers(result);
+ TwoAdmin.get().hideLoadingBox();
+ }
+
+ });
+ }
+
+ private void populateTable(Date query){
+ TwoAdmin.get().showLoadingBox();
+ TwoAdmin.get().getAdminService().getLastLoggedInUsers(query,new AsyncCallback<List<UserDTO>>() {
+
+ @Override
+ public void onFailure(Throwable caught) {
+ GWT.log("Error fetching users", caught);
+ TwoAdmin.get().showErrorBox("Unable to Find any Users");
+ TwoAdmin.get().hideLoadingBox();
+ }
+
+ @Override
+ public void onSuccess(List<UserDTO> result) {
+ usersTable.showUsers(result);
+ TwoAdmin.get().hideLoadingBox();
+ }
+
+ });
+ }
+
+
+ public void clearProfile(){
+ g.getColumnFormatter().setWidth(1, "200px");
+ g.setWidget( 0, 1, new HTML("") );
+ g.setWidget( 1, 1, new HTML("") );
+ g.setWidget( 2, 1, new HTML("") );
+ g.setWidget( 3, 1, new HTML("") );
+
+ CheckBox ck = new CheckBox();
+ ck.setValue(false);
+ ck.setEnabled(false);
+ g.setWidget( 4, 1, ck );
+ g.getColumnFormatter().setWidth(3, "200px");
+ g.setWidget( 0, 3, new HTML("") );
+ g.setWidget( 1, 3, new HTML("") );
+ g.setWidget( 2, 3, new HTML("") );
+ g.setWidget( 3, 3, new HTML("") );
+ g.setWidget( 4, 3, new HTML("") );
+ g.setWidget( 5, 3, new HTML("") );
+ g.setWidget( 0, 5, new HTML("") );
+ g.setWidget( 1, 5, new HTML("") );
+ g.setWidget( 2, 5, new HTML("") );
+
+ }
+
+ public void displayProfile(final UserDTO user, StatsDTO stats){
+ g.setWidget( 0, 1, new HTML(user.getUsername()) );
+ g.setWidget( 1, 1, new HTML(user.getName()) );
+
+ g.setWidget( 2, 1, new HTML(user.getEmail()) );
+ if(user.getUserClass()!=null){
+ HTML userClass;
+ g.setWidget( 3, 1,userClass=new HTML("<a href='#'>"+user.getUserClass().getName()+"</a>") );
+ userClass.addClickHandler(new ClickHandler() {
+
+ @Override
+ public void onClick(ClickEvent event) {
+ TwoAdmin.get().getAdminService().getUserClasses(new AsyncCallback<List<UserClassDTO>>() {
+
+ @Override
+ public void onFailure(Throwable caught) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void onSuccess(List<UserClassDTO> result) {
+ DialogBox cbox =createDialogBox(user, result);
+ cbox.center();
+ cbox.show();
+
+ }
+
+ });
+
+ }
+ });
+ }
+ final CheckBox ck = new CheckBox();
+ ck.setValue(user.isActive());
+ ck.setEnabled(false);
+ g.setWidget( 4, 1, ck );
+ Button status = new Button("Toggle Active");
+ status.addClickHandler(new ClickHandler() {
+
+ @Override
+ public void onClick(ClickEvent event) {
+
+ ConfirmationDialog confirm = new ConfirmationDialog("Are you sure you want to toggle user State?","Toggle") {
+
+ @Override
+ public void confirm() {
+ TwoAdmin.get().showLoadingBox();
+ TwoAdmin.get().getAdminService().toggleActiveUser(user.getId(), new AsyncCallback<Void>() {
+
+ @Override
+ public void onSuccess(Void result) {
+ ck.setValue(!user.isActive());
+ if(getLastQuery() instanceof Date)
+ populateTable((Date)getLastQuery());
+ else if(getLastQuery() instanceof String)
+ populateTable((String)getLastQuery());
+ else
+ populateTable();
+ TwoAdmin.get().hideLoadingBox();
+
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ TwoAdmin.get().hideLoadingBox();
+
+ }
+ });
+
+ }
+
+ @Override
+ public void cancel() {
+ // TODO Auto-generated method stub
+
+ }
+ };
+ confirm.center();
+ confirm.show();
+
+ }
+ });
+ g.setWidget(5,1,status);
+
+ if(user.getUserClass()!=null){
+ g.setWidget( 0, 3, new HTML(user.getUserClass().getQuotaAsString()) );
+ g.setWidget( 1, 3, new HTML("") ); // XXX
+ g.setWidget( 1, 5, new HTML("") ); // XXX
+ }
+ g.setWidget( 2, 3, new HTML(""+stats.getFileCount()) );
+ g.setWidget( 3, 3, new HTML(stats.getFileSizeAsString()) );
+ g.setWidget( 4, 3, new HTML(stats.getQuotaLeftAsString()) );
+ g.setWidget( 5, 3, new HTML("") ); // XXX
+ g.setWidget( 0, 5, new HTML(100-stats.percentOfFreeSpace()+"%"));
+ Button remove = new Button("Remove User");
+ remove.addClickHandler(new ClickHandler() {
+
+ @Override
+ public void onClick(ClickEvent event) {
+
+ ConfirmationDialog confirm = new ConfirmationDialog("Are you" +
+ " sure you want to <strong>permanently</strong> " +
+ "remove user " + user.getUsername() + "?", "Remove") {
+
+ @Override
+ public void confirm() {
+ TwoAdmin.get().showLoadingBox();
+ TwoAdmin.get().getAdminService().removeUser(user.getId(), new AsyncCallback<Void>() {
+
+ @Override
+ public void onSuccess(Void result) {
+ if(getLastQuery() instanceof Date)
+ populateTable((Date)getLastQuery());
+ else if(getLastQuery() instanceof String)
+ populateTable((String)getLastQuery());
+ else
+ populateTable();
+ TwoAdmin.get().hideLoadingBox();
+
+ }
+
+ @Override
+ public void onFailure(Throwable caught) {
+ GWT.log("",caught);
+ TwoAdmin.get().hideLoadingBox();
+
+ }
+ });
+
+ }
+
+ @Override
+ public void cancel() {
+ // TODO Auto-generated method stub
+
+ }
+ };
+ confirm.center();
+ confirm.show();
+
+ }
+ });
+ g.setWidget(2,5,remove);
+
+
+
+ }
+
+
+ /**
+ * Retrieve the lastQuery.
+ *
+ * @return the lastQuery
+ */
+ public Object getLastQuery() {
+ return lastQuery;
+ }
+
+ public DialogBox createDialogBox(final UserDTO m, List<UserClassDTO> classes) {
+
+ // Create a dialog box and set the caption text
+ final DialogBox dialogBox = new DialogBox();
+ dialogBox.setHTML("User Class: "+m.getUserClass().getName());
+
+ // Create a table to layout the content
+ VerticalPanel dialogVPanel = new VerticalPanel();
+ dialogBox.setSize("50%", "50%");
+
+ ClickHandler cancelHandler = new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
+ dialogBox.hide();
+ }
+ };
+
+ dialogBox.setWidget(dialogVPanel);
+ final ListBox listbox = new ListBox();
+ int i=0;
+ for(UserClassDTO u : classes){
+ listbox.addItem(u.getName(), u.getId().toString());
+ if(u.getName().equals(m.getUserClass().getName()))
+ listbox.setSelectedIndex(i);
+ i++;
+ }
+ dialogVPanel.add(listbox);
+ Button change = new Button("Change");
+ change.addClickHandler(new ClickHandler() {
+
+ @Override
+ public void onClick(ClickEvent event) {
+ TwoAdmin.get().getAdminService().changeUserClass(m.getId(), Long.parseLong(listbox.getValue(listbox.getSelectedIndex())), new AsyncCallback<Void>() {
+
+ @Override
+ public void onFailure(Throwable caught) {
+
+
+ }
+
+ @Override
+ public void onSuccess(Void result) {
+ if(getLastQuery() instanceof Date)
+ populateTable((Date)getLastQuery());
+ else if(getLastQuery() instanceof String)
+ populateTable((String)getLastQuery());
+ else
+ populateTable();
+ TwoAdmin.get().hideLoadingBox();
+
+ }
+
+ });
+ dialogBox.hide();
+
+ }
+ });
+
+ Button close = new Button("Close");
+ close.addClickHandler(cancelHandler);
+ dialogVPanel.add(change);
+ dialogVPanel.add(close);
+
+ // Return the dialog box
+ return dialogBox;
+ }
+}
--- /dev/null
+<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
+<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
+ xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:adminui='urn:import:gr.ebs.gss.admin.client.ui'
+ xmlns:dp="urn:import:com.google.gwt.user.datepicker.client"
+ >
+ <ui:style>
+
+ </ui:style>
+
+ <g:VerticalPanel addStyleNames="Gmnuri3D" width="100%">
+ <g:HTMLPanel>
+ <div>
+ <h3>User Search</h3>
+ </div>
+ </g:HTMLPanel>
+ <g:HorizontalPanel spacing="3">
+ <g:cell horizontalAlignment="ALIGN_CENTER" verticalAlignment="ALIGN_MIDDLE">
+ <g:HTML>Search Users:</g:HTML>
+ </g:cell>
+ <g:cell horizontalAlignment="ALIGN_CENTER" verticalAlignment="ALIGN_MIDDLE">
+ <g:TextBox ui:field="searchBox"></g:TextBox>
+ </g:cell>
+ <g:cell horizontalAlignment="ALIGN_CENTER" verticalAlignment="ALIGN_MIDDLE">
+ <g:Button ui:field="searchButton">Search</g:Button>
+ </g:cell>
+
+ <g:cell horizontalAlignment="ALIGN_CENTER" verticalAlignment="ALIGN_MIDDLE">
+ <g:HTML>Search Last Logged In Users:</g:HTML>
+ </g:cell>
+ <g:cell horizontalAlignment="ALIGN_CENTER" verticalAlignment="ALIGN_MIDDLE">
+ <dp:DateBox ui:field="dateBox"></dp:DateBox>
+
+ </g:cell>
+ <g:cell horizontalAlignment="ALIGN_CENTER" verticalAlignment="ALIGN_MIDDLE">
+ <g:Button ui:field="showLastLoginButton">Show</g:Button>
+ </g:cell>
+
+ <g:cell horizontalAlignment="ALIGN_CENTER" verticalAlignment="ALIGN_MIDDLE">
+ <g:Button ui:field="showInactiveButton">Show Inactive Users</g:Button>
+ </g:cell>
+
+ </g:HorizontalPanel>
+
+ <adminui:UsersTable ui:field="usersTable">
+ </adminui:UsersTable>
+
+ <g:VerticalPanel width="100%" addStyleNames="Gmnuri3D">
+ <g:HTMLPanel>
+ <div>
+ <h3>User Details</h3>
+ </div>
+ </g:HTMLPanel>
+ <g:Grid ui:field="g"></g:Grid>
+ </g:VerticalPanel>
+ </g:VerticalPanel>
+
+</ui:UiBinder>
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright 2010 Electronic Business Systems Ltd.
+ *
+ * This file is part of GSS.
+ *
+ * GSS is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GSS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GSS. If not, see <http://www.gnu.org/licenses/>.
+ */
+package gr.ebs.gss.admin.client.ui;
+
+import gr.ebs.gss.admin.client.ui.UsersTable.UserSorter.UserComparator;
+import gr.ebs.gss.server.domain.dto.StatsDTO;
+import gr.ebs.gss.server.domain.dto.UserDTO;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.gen2.table.client.AbstractColumnDefinition;
+import com.google.gwt.gen2.table.client.AbstractScrollTable.ScrollPolicy;
+import com.google.gwt.gen2.table.client.AbstractScrollTable.SortPolicy;
+import com.google.gwt.gen2.table.client.CachedTableModel;
+import com.google.gwt.gen2.table.client.CellRenderer;
+import com.google.gwt.gen2.table.client.ColumnDefinition;
+import com.google.gwt.gen2.table.client.DefaultRowRenderer;
+import com.google.gwt.gen2.table.client.DefaultTableDefinition;
+import com.google.gwt.gen2.table.client.FixedWidthGridBulkRenderer;
+import com.google.gwt.gen2.table.client.MutableTableModel;
+import com.google.gwt.gen2.table.client.PagingOptions;
+import com.google.gwt.gen2.table.client.PagingScrollTable;
+import com.google.gwt.gen2.table.client.ScrollTable;
+import com.google.gwt.gen2.table.client.SelectionGrid.SelectionPolicy;
+import com.google.gwt.gen2.table.client.TableDefinition;
+import com.google.gwt.gen2.table.client.TableDefinition.AbstractCellView;
+import com.google.gwt.gen2.table.client.TableModel;
+import com.google.gwt.gen2.table.client.TableModelHelper.Request;
+import com.google.gwt.gen2.table.client.TableModelHelper.Response;
+import com.google.gwt.gen2.table.event.client.RowSelectionEvent;
+import com.google.gwt.gen2.table.event.client.RowSelectionHandler;
+import com.google.gwt.gen2.table.event.client.TableEvent.Row;
+import com.google.gwt.i18n.client.DateTimeFormat;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.CheckBox;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.DialogBox;
+import com.google.gwt.user.client.ui.FlexTable;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.HasHorizontalAlignment;
+import com.google.gwt.user.client.ui.Label;
+import com.google.gwt.user.client.ui.VerticalPanel;
+
+
+/**
+ * @author kman
+ *
+ */
+public class UsersTable extends Composite {
+ private CachedTableModel<UserDTO> cachedTableModel = null;
+ private DefaultTableDefinition<UserDTO> tableDefinition = null;
+ private PagingScrollTable<UserDTO> pagingScrollTable = null;
+ private Label countLabel = new Label("There are no users to display.");
+ private DataSourceTableModel tableModel = null;
+
+ private VerticalPanel vPanel = new VerticalPanel();
+ private FlexTable flexTable = new FlexTable();
+
+ /**
+ * Constructor
+ */
+ public UsersTable() {
+ super();
+ pagingScrollTable = createScrollTable();
+ pagingScrollTable.setHeight("200px");
+ pagingScrollTable.setScrollPolicy(ScrollPolicy.DISABLED);
+ PagingOptions pagingOptions = new PagingOptions(pagingScrollTable);
+
+ flexTable.setWidget(0, 0, pagingScrollTable);
+ flexTable.getFlexCellFormatter().setColSpan(0, 0, 2);
+ flexTable.setWidget(1, 0, pagingOptions);
+
+ countLabel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
+ vPanel.add(countLabel);
+ vPanel.add(flexTable);
+
+ vPanel.setWidth("100%");
+ flexTable.setWidth("100%");
+
+ super.initWidget(vPanel);
+ showUsers(new ArrayList<UserDTO>());
+ pagingScrollTable.setFooterGenerated(true);
+ }
+
+ /**
+ *
+ * @param newList the list of users to show
+ */
+ public void showUsers(List<UserDTO> newList) {
+ countLabel.setText("There are "+ newList.size() + " users.");
+ tableModel.setData(newList);
+ tableModel.setRowCount(newList.size());
+ cachedTableModel.clearCache();
+ cachedTableModel.setRowCount(newList.size());
+
+ pagingScrollTable.gotoPage(0, true);
+ if(newList.size()<2)
+ flexTable.setWidget(1, 0, new HTML());
+ else{
+ PagingOptions pagingOptions = new PagingOptions(pagingScrollTable);
+ flexTable.setWidget(1, 0, pagingOptions);
+ }
+ }
+
+ public UserDTO getUserOnRow(int rowIdx){
+ String id = pagingScrollTable.getDataTable().getHTML(rowIdx, 0);
+ final UserDTO m = tableModel.getUserById(Long.parseLong(id));
+ return m;
+ }
+
+
+ public UserDTO getSelectedRowObject(RowSelectionEvent event){
+ Set<Row> set = event.getSelectedRows();
+ if(set.size() == 1) {
+ int rowIdx = set.iterator().next().getRowIndex();
+ String id = pagingScrollTable.getDataTable().getHTML(rowIdx, 0);
+ UserDTO m = tableModel.getUserById(Long.parseLong(id));
+ return m;
+ }
+ return null;
+ }
+
+ public UserDTO getUser(Long id){
+
+ return tableModel.getUserById(id);
+ }
+
+ public DialogBox createDialogBox(UserDTO m, StatsDTO s) {
+
+ // Create a dialog box and set the caption text
+ final DialogBox dialogBox = new DialogBox();
+ dialogBox.setHTML("User Details: "+m.getUsername());
+
+ // Create a table to layout the content
+ VerticalPanel dialogVPanel = new VerticalPanel();
+ dialogBox.setSize("50%", "50%");
+
+ ClickHandler cancelHandler = new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
+ dialogBox.hide();
+ }
+ };
+
+ dialogBox.setWidget(dialogVPanel);
+ dialogVPanel.add(new Label("Username: "+m.getUsername()));
+ dialogVPanel.add(new Label("Email: "+m.getEmail()));
+ dialogVPanel.add(new Label("Name: "+m.getName()));
+ if(m.getUserClass()!=null)
+ dialogVPanel.add(new Label("Quota: "+m.getUserClass().getQuotaAsString()));
+ dialogVPanel.add(new Label("File Count: "+s.getFileCount()));
+ dialogVPanel.add(new Label("File Size: "+s.getFileSizeAsString()));
+ dialogVPanel.add(new Label("Quota Left: "+s.getQuotaLeftAsString()));
+
+ Button close = new Button("Close");
+ close.addClickHandler(cancelHandler);
+ dialogVPanel.add(close);
+
+ // Return the dialog box
+ return dialogBox;
+ }
+
+ /**
+ * Initializes the scroll table
+ * @return
+ */
+ private PagingScrollTable<UserDTO> createScrollTable() {
+ // create our own table model
+ tableModel = new DataSourceTableModel();
+ // add it to cached table model
+ cachedTableModel = createCachedTableModel(tableModel);
+
+ // create the table definition
+ TableDefinition<UserDTO> tableDef = createTableDefinition();
+
+ // create the paging scroll table
+ pagingScrollTable = new PagingScrollTable<UserDTO>(cachedTableModel, tableDef);
+ pagingScrollTable.setPageSize(10);
+ pagingScrollTable.setEmptyTableWidget(new HTML("There is no data to display"));
+ pagingScrollTable.getDataTable().setSelectionPolicy(SelectionPolicy.ONE_ROW);
+
+ FixedWidthGridBulkRenderer<UserDTO> bulkRenderer = new FixedWidthGridBulkRenderer<UserDTO>(pagingScrollTable.getDataTable(), pagingScrollTable);
+ pagingScrollTable.setBulkRenderer(bulkRenderer);
+
+
+ pagingScrollTable.setCellPadding(3);
+ pagingScrollTable.setCellSpacing(0);
+ pagingScrollTable.setResizePolicy(ScrollTable.ResizePolicy.FILL_WIDTH);
+
+ pagingScrollTable.setSortPolicy(SortPolicy.SINGLE_CELL);
+
+ return pagingScrollTable;
+ }
+
+ public void addRowSelectionHandler(RowSelectionHandler handler){
+ pagingScrollTable.getDataTable().addRowSelectionHandler(handler);
+ }
+
+ /**
+ * Create the {@link CachedTableModel}
+ * @param aTableModel
+ * @return
+ */
+ private CachedTableModel<UserDTO> createCachedTableModel(DataSourceTableModel aTableModel) {
+ CachedTableModel<UserDTO> tm = new CachedTableModel<UserDTO>(aTableModel);
+ tm.setPreCachedRowCount(20);
+ tm.setPostCachedRowCount(20);
+ tm.setRowCount(20);
+ return tm;
+ }
+
+ private DefaultTableDefinition<UserDTO> createTableDefinition() {
+ tableDefinition = new DefaultTableDefinition<UserDTO>();
+
+ final String[] rowColors = new String[] { "#FFFFDD", "EEEEEE" };
+ tableDefinition.setRowRenderer(new DefaultRowRenderer<UserDTO>(rowColors));
+
+ // id
+ {
+ IdColumnDefinition columnDef = new IdColumnDefinition();
+ columnDef.setColumnSortable(true);
+ columnDef.setColumnTruncatable(false);
+ columnDef.setPreferredColumnWidth(35);
+ columnDef.setHeader(0, new HTML("Id"));
+ columnDef.setHeaderCount(1);
+ columnDef.setHeaderTruncatable(false);
+ tableDefinition.addColumnDefinition(columnDef);
+ }
+ {
+ UserClassColumnDefinition columnDef = new UserClassColumnDefinition();
+ columnDef.setColumnSortable(true);
+ columnDef.setColumnTruncatable(true);
+ columnDef.setHeader(0, new HTML("User Class"));
+ columnDef.setHeaderCount(1);
+ columnDef.setHeaderTruncatable(false);
+ tableDefinition.addColumnDefinition(columnDef);
+ }
+ {
+ ActiveColumnDefinition columnDef = new ActiveColumnDefinition();
+ columnDef.setColumnSortable(true);
+ columnDef.setColumnTruncatable(true);
+ columnDef.setHeader(0, new HTML("Active"));
+ columnDef.setHeaderCount(1);
+ columnDef.setHeaderTruncatable(false);
+ columnDef.setCellRenderer(new CellRenderer<UserDTO, Boolean>() {
+
+ @Override
+ public void renderRowValue(UserDTO rowValue, ColumnDefinition<UserDTO, Boolean> aColumnDef, AbstractCellView<UserDTO> view) {
+ CheckBox check = new CheckBox();
+ check.setValue(aColumnDef.getCellValue(rowValue));
+ check.setEnabled(false);
+ view.setWidget(check);
+
+ }
+ });
+ tableDefinition.addColumnDefinition(columnDef);
+ }
+ // username
+ {
+ UsernameColumnDefinition columnDef = new UsernameColumnDefinition();
+ columnDef.setColumnSortable(true);
+ columnDef.setColumnTruncatable(true);
+ columnDef.setHeader(0, new HTML("Username"));
+ columnDef.setHeaderCount(1);
+ columnDef.setHeaderTruncatable(false);
+ tableDefinition.addColumnDefinition(columnDef);
+ }
+ {
+ EmailColumnDefinition columnDef = new EmailColumnDefinition();
+ columnDef.setColumnSortable(true);
+ columnDef.setColumnTruncatable(true);
+ columnDef.setHeader(0, new HTML("Email"));
+ columnDef.setHeaderCount(1);
+ columnDef.setHeaderTruncatable(false);
+ tableDefinition.addColumnDefinition(columnDef);
+ }
+ {
+ FullNameColumnDefinition columnDef = new FullNameColumnDefinition();
+ columnDef.setColumnSortable(true);
+ columnDef.setColumnTruncatable(true);
+ columnDef.setHeader(0, new HTML("Name"));
+ columnDef.setHeaderCount(1);
+ columnDef.setHeaderTruncatable(false);
+ tableDefinition.addColumnDefinition(columnDef);
+ }
+
+ {
+ LastLoginColumnDefinition columnDef = new LastLoginColumnDefinition();
+ columnDef.setColumnSortable(true);
+ columnDef.setColumnTruncatable(true);
+ columnDef.setHeader(0, new HTML("Last Login"));
+ columnDef.setHeaderCount(1);
+ columnDef.setHeaderTruncatable(false);
+ tableDefinition.addColumnDefinition(columnDef);
+ }
+
+
+
+ return tableDefinition;
+ }
+
+
+ private class DataSourceTableModel extends MutableTableModel<UserDTO> {
+ private Map<Long, UserDTO> map;
+ private UserSorter sorter = new UserSorter();
+ public void setData(List<UserDTO> list) {
+ // toss the list, index by id in a map.
+ map = new HashMap<Long, UserDTO>(list.size());
+ for(UserDTO m : list)
+ map.put(m.getId(), m);
+ }
+
+ public UserDTO getUserById(long id) {
+ return map.get(id);
+ }
+
+ @Override
+ protected boolean onRowInserted(int beforeRow) {
+ return true;
+ }
+
+ @Override
+ protected boolean onRowRemoved(int row) {
+ return true;
+ }
+
+ @Override
+ protected boolean onSetRowValue(int row, UserDTO rowValue) {
+
+ return true;
+ }
+
+ @Override
+ public void requestRows(
+ final Request request,
+ TableModel.Callback<UserDTO> callback) {
+
+ callback.onRowsReady(request, new Response<UserDTO>(){
+
+ @Override
+ public Iterator<UserDTO> getRowValues() {
+ final int col = request.getColumnSortList().getPrimaryColumn();
+ final boolean ascending = request.getColumnSortList().isPrimaryAscending();
+ if(col < 0)
+ map = sorter.sort(map, new UserComparator(ascending,0));
+ else
+ map = sorter.sort(map, new UserComparator(ascending,col));
+ return map.values().iterator();
+ }});
+ }
+
+ }
+
+
+ private final class IdColumnDefinition extends AbstractColumnDefinition<UserDTO, Long> {
+ @Override
+ public Long getCellValue(UserDTO rowValue) {
+ return rowValue.getId();
+ }
+ @Override
+ public void setCellValue(UserDTO rowValue, Long cellValue) { }
+ }
+
+
+ private final class UsernameColumnDefinition extends
+ AbstractColumnDefinition<UserDTO, String> {
+ @Override
+ public String getCellValue(final UserDTO rowValue) {
+ return rowValue.getUsername();
+ }
+
+ @Override
+ public void setCellValue(final UserDTO rowValue, final String cellValue) {}
+ }
+
+
+ private final class FullNameColumnDefinition extends
+ AbstractColumnDefinition<UserDTO, String> {
+ @Override
+ public String getCellValue(final UserDTO rowValue) {
+ return rowValue.getName();
+ }
+
+ @Override
+ public void setCellValue(final UserDTO rowValue, final String cellValue) {}
+ }
+
+
+ private final class EmailColumnDefinition extends
+ AbstractColumnDefinition<UserDTO, String> {
+ @Override
+ public String getCellValue(final UserDTO rowValue) {
+ return rowValue.getEmail();
+ }
+
+ @Override
+ public void setCellValue(final UserDTO rowValue, final String cellValue) {}
+ }
+
+
+ private final class UserClassColumnDefinition extends
+ AbstractColumnDefinition<UserDTO, String> {
+ @Override
+ public String getCellValue(final UserDTO rowValue) {
+ if(rowValue.getUserClass() != null)
+ return rowValue.getUserClass().getName();
+ return "";
+ }
+
+ @Override
+ public void setCellValue(final UserDTO rowValue, final String cellValue) {}
+ }
+
+
+ private final class ActiveColumnDefinition extends
+ AbstractColumnDefinition<UserDTO, Boolean> {
+ @Override
+ public Boolean getCellValue(final UserDTO rowValue) {
+ if(rowValue.isActive() == null)
+ return true;
+ return rowValue.isActive();
+ }
+
+ @Override
+ public void setCellValue(final UserDTO rowValue, final Boolean cellValue) {
+ rowValue.setActive(cellValue);
+ }
+ }
+
+
+ private final class LastLoginColumnDefinition extends AbstractColumnDefinition<UserDTO, String> {
+
+ @Override
+ public String getCellValue(final UserDTO rowValue) {
+ if(rowValue.getCurrentLoginDate()==null)
+ return "no data";
+ return DateTimeFormat.getFormat("dd/MM/yyyy hh:mm:ss tt").format(rowValue.getCurrentLoginDate());
+ }
+
+ @Override
+ public void setCellValue(final UserDTO rowValue, final String cellValue) {}
+ }
+
+
+
+ public static class UserSorter {
+
+
+ public Map<Long, UserDTO> sort(Map<Long, UserDTO> map, Comparator<UserDTO> comparator) {
+ final List<UserDTO> list = new LinkedList<UserDTO>(map.values());
+ Collections.sort(list, comparator);
+ Map<Long, UserDTO> result = new LinkedHashMap<Long, UserDTO>(list.size());
+ for(UserDTO p : list)
+ result.put(p.getId(), p);
+ return result;
+ }
+
+ public final static class UserComparator implements Comparator<UserDTO> {
+
+ private final boolean ascending;
+ private int property;
+ public UserComparator(boolean isAscending, int aProperty) {
+ ascending = isAscending;
+ property = aProperty;
+ }
+
+ @Override
+ public int compare(UserDTO m1, UserDTO m2) {
+ switch(property){
+ case 0:
+ if(ascending)
+ return m1.getId().compareTo(m2.getId());
+ return m2.getId().compareTo(m1.getId());
+ case 1:
+ if(ascending)
+ return m1.getUserClass().getName().compareTo(m2.getUserClass().getName());
+ return m2.getUserClass().getName().compareTo(m1.getUserClass().getName());
+ case 2:
+ if(ascending)
+ return m1.isActive().compareTo(m2.isActive());
+ return m2.isActive().compareTo(m1.isActive());
+ case 3:
+ if(ascending)
+ return m1.getUsername().compareTo(m2.getUsername());
+ return m2.getUsername().compareTo(m1.getUsername());
+ case 4:
+ if(ascending)
+ return m1.getEmail().compareTo(m2.getEmail());
+ return m2.getEmail().compareTo(m1.getEmail());
+ case 5:
+ if(ascending)
+ return m1.getName().compareTo(m2.getName());
+ return m2.getName().compareTo(m1.getName());
+ case 6:
+ return new DateComparator(ascending).compare(m2, m1);
+ default:
+
+ }
+ String s1 = m1.getUsername();
+ String s2 = m2.getUsername();
+ if(ascending)
+ return s1.compareTo(s2);
+ return s2.compareTo(s1);
+ }
+ }
+
+
+ public final static class DateComparator implements Comparator<UserDTO> {
+
+ private final boolean ascending;
+
+ public DateComparator(boolean isAscending) {
+ ascending = isAscending;
+ }
+
+ @Override
+ public int compare(UserDTO m1, UserDTO m2) {
+ final Date d1 = m1.getLastLoginDate();
+ final Date d2 = m2.getLastLoginDate();
+ if(d1==null && d2==null)
+ return 0;
+ if(d1==null && d2 != null)
+ return -1;
+ if(d2==null && d1 != null)
+ return 1;
+ if(ascending)
+ return d1.compareTo(d2);
+ return d2.compareTo(d1);
+ }
+ }
+ }
+
+
+
+}
--- /dev/null
+/*
+ * Copyright 2010 Electronic Business Systems Ltd.
+ *
+ * This file is part of GSS.
+ *
+ * GSS is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GSS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GSS. If not, see <http://www.gnu.org/licenses/>.
+ */
+package gr.ebs.gss.admin.client.ui;
+
+import gr.ebs.gss.admin.client.TwoAdmin;
+import gr.ebs.gss.server.domain.dto.FileBodyDTO;
+
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.List;
+
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.i18n.client.DateTimeFormat;
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.FlexTable;
+import com.google.gwt.user.client.ui.HTML;
+import com.google.gwt.user.client.ui.HasHorizontalAlignment;
+import com.google.gwt.user.client.ui.VerticalPanel;
+
+
+/**
+ * @author kman
+ *
+ */
+public class VersionsList extends Composite{
+
+
+ final FlexTable permTable = new FlexTable();
+ final VerticalPanel permPanel = new VerticalPanel();
+
+ /**
+ *
+ */
+ public VersionsList(List<FileBodyDTO> versions) {
+
+ permTable.setText(0, 0, "Version");
+ permTable.setText(0, 1, "Created By");
+ permTable.setText(0, 2, "Created");
+ permTable.setText(0, 3, "Modified By");
+ permTable.setText(0, 4, "Modified");
+ permTable.setText(0, 5, "Size");
+ permTable.setText(0, 6, "");
+ permTable.getFlexCellFormatter().setStyleName(0, 0, "props-toplabels");
+ permTable.getFlexCellFormatter().setStyleName(0, 1, "props-toplabels");
+ permTable.getFlexCellFormatter().setStyleName(0, 2, "props-toplabels");
+ permTable.getFlexCellFormatter().setStyleName(0, 3, "props-toplabels");
+ permTable.getFlexCellFormatter().setStyleName(0, 4, "props-toplabels");
+ permTable.getFlexCellFormatter().setStyleName(0, 5, "props-toplabels");
+ permTable.getFlexCellFormatter().setStyleName(0, 6, "props-toplabels");
+ permTable.getFlexCellFormatter().setColSpan(0, 1, 2);
+ permTable.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
+ permTable.getFlexCellFormatter().setHorizontalAlignment(0, 1, HasHorizontalAlignment.ALIGN_CENTER);
+ permTable.getFlexCellFormatter().setHorizontalAlignment(0, 2, HasHorizontalAlignment.ALIGN_CENTER);
+ permTable.getFlexCellFormatter().setHorizontalAlignment(0, 3, HasHorizontalAlignment.ALIGN_CENTER);
+ permTable.getFlexCellFormatter().setHorizontalAlignment(0, 4, HasHorizontalAlignment.ALIGN_CENTER);
+ permTable.getFlexCellFormatter().setHorizontalAlignment(0, 5, HasHorizontalAlignment.ALIGN_CENTER);
+ permPanel.add(permTable);
+ permPanel.addStyleName("gss-TabPanelBottom");
+ permTable.addStyleName("gss-permList");
+ initWidget(permPanel);
+ updateTable(versions);
+ }
+
+ public void updateTable(List<FileBodyDTO> versions) {
+ Collections.sort(versions, new Comparator<FileBodyDTO>(){
+
+ @Override
+ public int compare(FileBodyDTO o1, FileBodyDTO o2) {
+ return new Integer(o1.getVersion()).compareTo(new Integer(o2.getVersion()));
+ }
+
+ });
+ int i = 1;
+ for (final FileBodyDTO dto : versions) {
+
+ permTable.setHTML(i, 0, "<span>" + dto.getVersion() + "</span>");
+ HTML createdByLabel = new HTML("<a href='#'>"+dto.getAuditInfo().getCreatedBy().getUsername()+"</a></span>");
+ permTable.setWidget(i, 1, createdByLabel);
+ createdByLabel.addClickHandler(new ClickHandler() {
+
+ @Override
+ public void onClick(ClickEvent event) {
+ TwoAdmin.get().searchUsers("username:"+dto.getAuditInfo().getCreatedBy().getUsername());
+
+ }
+ });
+ permTable.setHTML(i, 2, "<span>" + formatLocalDateTime(dto.getAuditInfo().getCreationDate()) + "</span>");
+ HTML modifiedByLabel = new HTML("<a href='#'>"+dto.getAuditInfo().getModifiedBy().getUsername()+"</a></span>");
+ permTable.setWidget(i, 3, modifiedByLabel);
+ modifiedByLabel.addClickHandler(new ClickHandler() {
+
+ @Override
+ public void onClick(ClickEvent event) {
+ TwoAdmin.get().searchUsers("username:"+dto.getAuditInfo().getModifiedBy().getUsername());
+
+ }
+ });
+
+ permTable.setHTML(i, 4, "<span>" + formatLocalDateTime(dto.getAuditInfo().getModificationDate()) + "</span>");
+ permTable.setHTML(i, 5, "<span>" + dto.getFileSizeAsString() + "</span>");
+ HTML downloadHtml = new HTML("<a class='hidden-link info' href='#'><span>"+"</span><div>View this Version</div></a>");
+ downloadHtml.addClickHandler( new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
+
+
+ }
+ });
+ permTable.setWidget(i, 6, downloadHtml);
+
+ permTable.getFlexCellFormatter().setStyleName(i, 0, "props-labels");
+ permTable.getFlexCellFormatter().setHorizontalAlignment(i, 0, HasHorizontalAlignment.ALIGN_CENTER);
+ permTable.getFlexCellFormatter().setHorizontalAlignment(i, 1, HasHorizontalAlignment.ALIGN_CENTER);
+ permTable.getFlexCellFormatter().setColSpan(i, 1, 2);
+ permTable.getFlexCellFormatter().setHorizontalAlignment(i, 2, HasHorizontalAlignment.ALIGN_CENTER);
+ permTable.getFlexCellFormatter().setHorizontalAlignment(i, 3, HasHorizontalAlignment.ALIGN_CENTER);
+ i++;
+ }
+ for (; i < permTable.getRowCount(); i++)
+ permTable.removeRow(i);
+ }
+
+ public static String formatLocalDateTime(Date date) {
+ Date convertedDate = new Date(date.getTime() - date.getTimezoneOffset());
+ final DateTimeFormat dateFormatter = DateTimeFormat.getShortDateFormat();
+ final DateTimeFormat timeFormatter = DateTimeFormat.getFormat("HH:mm");
+ String datePart = dateFormatter.format(convertedDate);
+ String timePart = timeFormatter.format(convertedDate);
+ return datePart + " " + timePart;
+ }
+
+}
--- /dev/null
+/*
+ * Copyright 2010 Electronic Business Systems Ltd.
+ *
+ * This file is part of GSS.
+ *
+ * GSS is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GSS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GSS. If not, see <http://www.gnu.org/licenses/>.
+ */
+package gr.ebs.gss.admin.client.ui;
+
+import gr.ebs.gss.server.domain.dto.SystemStatsDTO;
+import gr.ebs.gss.server.domain.dto.UserClassDTO;
+
+import com.google.gwt.user.client.ui.Composite;
+import com.google.gwt.user.client.ui.HorizontalPanel;
+import com.google.gwt.user.client.ui.VerticalPanel;
+import com.google.gwt.visualization.client.DataTable;
+import com.google.gwt.visualization.client.AbstractDataTable.ColumnType;
+import com.google.gwt.visualization.client.visualizations.PieChart;
+
+
+/**
+ * @author kman
+ *
+ */
+public class VisualizationPanel extends Composite{
+
+ PieChart userCountChart;
+ PieChart fileCountChart;
+ PieChart fileSizeChart;
+
+ PieChart lastWeekChart;
+ PieChart lastMonthChart;
+ PieChart bandwithChart;
+
+ /**
+ *
+ */
+ public VisualizationPanel() {
+ final VerticalPanel vp = new VerticalPanel();
+ vp.getElement().getStyle().setPropertyPx("margin", 15);
+ userCountChart = new PieChart();
+ userCountChart.addStyleName("stats");
+ fileCountChart = new PieChart();
+ fileCountChart.addStyleName("stats");
+ fileSizeChart = new PieChart();
+ fileSizeChart.addStyleName("stats");
+
+ lastWeekChart = new PieChart();
+ lastWeekChart.addStyleName("stats");
+ lastMonthChart = new PieChart();
+ lastMonthChart.addStyleName("stats");
+ bandwithChart = new PieChart();
+ bandwithChart.addStyleName("stats");
+ HorizontalPanel row1 = new HorizontalPanel();
+ HorizontalPanel row2 = new HorizontalPanel();
+
+ row1.add(userCountChart);
+ row1.add(fileCountChart);
+ row1.add(fileSizeChart);
+
+ row2.add(lastWeekChart);
+ row2.add(lastMonthChart);
+ row2.add(bandwithChart);
+ vp.add(row1);
+ vp.add(row2);
+ initWidget(vp);
+ }
+
+ public void updateData(SystemStatsDTO stats){
+ DataTable data = DataTable.create();
+ data.addColumn(ColumnType.STRING, "UserClass");
+ data.addColumn(ColumnType.NUMBER, "UserCount");
+ data.addRows(stats.getUserClasses().size());
+ for(int i=0;i<stats.getUserClasses().size();i++){
+ UserClassDTO dto = stats.getUserClasses().get(i);
+ data.setValue(i, 0, dto.getName()+":"+dto.getStatistics().getUserCount()+ " users");
+ data.setValue(i, 1, dto.getStatistics().getUserCount());
+ }
+
+ PieChart.Options options = PieChart.Options.create();
+ options.setWidth(350);
+ options.setHeight(240);
+ options.set3D(true);
+ options.setColors("green","red","blue");
+ options.setTitle("User Count:"+stats.getUserCount()+ " users");
+ userCountChart.draw(data, options);
+
+ data = DataTable.create();
+ data.addColumn(ColumnType.STRING, "UserClass");
+ data.addColumn(ColumnType.NUMBER, "FileCount");
+ data.addRows(stats.getUserClasses().size());
+ for(int i=0;i<stats.getUserClasses().size();i++){
+ UserClassDTO dto = stats.getUserClasses().get(i);
+ data.setValue(i, 0, dto.getName()+":"+dto.getStatistics().getFileCount()+" files");
+ data.setValue(i, 1, dto.getStatistics().getFileCount());
+ }
+
+ options = PieChart.Options.create();
+ options.setWidth(350);
+ options.setHeight(240);
+ options.set3D(true);
+ options.setColors("red","green","blue");
+ options.setTitle("File Count:"+stats.getFileCount()+" files");
+ fileCountChart.draw(data, options);
+
+ data = DataTable.create();
+ data.addColumn(ColumnType.STRING, "UserClass");
+ data.addColumn(ColumnType.NUMBER, "FileSize");
+ data.addRows(stats.getUserClasses().size());
+ for(int i=0;i<stats.getUserClasses().size();i++){
+ UserClassDTO dto = stats.getUserClasses().get(i);
+ data.setValue(i, 0, dto.getName()+":"+dto.getStatistics().getFileSizeAsString());
+ data.setValue(i, 1, dto.getStatistics().getFileSize());
+ }
+
+ options = PieChart.Options.create();
+ options.setWidth(350);
+ options.setHeight(240);
+ options.set3D(true);
+ options.setColors("blue","red","green");
+ options.setTitle("Total File Size:"+stats.getFileSizeAsString());
+ fileSizeChart.draw(data, options);
+
+ data = DataTable.create();
+ data.addColumn(ColumnType.STRING, "UserClass");
+ data.addColumn(ColumnType.NUMBER, "Active Last Month");
+ data.addRows(2);
+ data.setValue(0, 0, "Active"+":"+stats.getLastMonthUsers()+" users");
+ data.setValue(0, 1, stats.getLastMonthUsers());
+ data.setValue(1, 0, "Inactive"+":"+(stats.getUserCount()-stats.getLastMonthUsers())+" users");
+ data.setValue(1, 1, (stats.getUserCount()-stats.getLastMonthUsers()));
+
+
+ options = PieChart.Options.create();
+ options.setWidth(350);
+ options.setHeight(240);
+ options.set3D(true);
+ options.setTitle("Last Month Users:"+stats.getLastMonthUsers());
+ lastMonthChart.draw(data, options);
+
+ data = DataTable.create();
+ data.addColumn(ColumnType.STRING, "UserClass");
+ data.addColumn(ColumnType.NUMBER, "Last Week Users");
+ data.addRows(2);
+ data.setValue(0, 0, "Active"+":"+stats.getLastWeekUsers() +" users");
+ data.setValue(0, 1, stats.getLastWeekUsers());
+ data.setValue(1, 0, "Inactive"+":"+(stats.getUserCount()-stats.getLastWeekUsers())+" users");
+ data.setValue(1, 1, (stats.getUserCount()-stats.getLastWeekUsers()));
+
+ options = PieChart.Options.create();
+ options.setWidth(350);
+ options.setHeight(240);
+ options.set3D(true);
+ options.setTitle("Last Week Users:"+stats.getLastWeekUsers());
+ lastWeekChart.draw(data, options);
+
+ data = DataTable.create();
+ data.addColumn(ColumnType.STRING, "UserClass");
+ data.addColumn(ColumnType.NUMBER, "Bandwith Used");
+ data.addRows(stats.getUserClasses().size());
+ for(int i=0;i<stats.getUserClasses().size();i++){
+ UserClassDTO dto = stats.getUserClasses().get(i);
+ data.setValue(i, 0, dto.getName()+":"+dto.getStatistics().getBandwithUsedAsString());
+ data.setValue(i, 1, dto.getStatistics().getBandwithUsed());
+ }
+
+ options = PieChart.Options.create();
+ options.setWidth(350);
+ options.setHeight(240);
+ options.set3D(true);
+ options.setTitle("Bandwith Used:"+stats.getBandwithUsedAsString());
+ bandwithChart.draw(data, options);
+ }
+
+}
--- /dev/null
+/** Add css rules here for your application. */
+
+
+/** Example rules used by the template application (remove for your app) */
+h1 {
+ font-size: 2em;
+ font-weight: bold;
+ color: #777777;
+ margin: 40px 0px 70px;
+ text-align: center;
+}
+
+.gwt-TabPanelBottom{
+ height:100%;
+ overflow: auto;
+ }
+
+
+.sendButton {
+ display: block;
+ font-size: 16pt;
+}
+
+/** Most GWT widgets already have a style name defined */
+.gwt-DialogBox {
+ width: 400px;
+}
+
+.dialogVPanel {
+ margin: 5px;
+}
+
+.serverResponseLabelError {
+ color: red;
+}
+
+/** Set ids using widget.getElement().setId("idOfElement") */
+#closeButton {
+ margin: 15px 6px 6px;
+}
+
+
+.Gmnuri3D {
+border:0 none;
+border-collapse:collapse;
+padding:0;
+}
+.Gmnuri3D > div {
+border:1px solid #D9E6F0;
+border-collapse:collapse;
+}
+.Gmnuri3D h3 {
+-moz-background-clip:border;
+-moz-background-inline-policy:continuous;
+-moz-background-origin:padding;
+background:#E3E9FF none repeat scroll 0 0;
+border-bottom:1px solid #D9E6F0;
+color:#375B91;
+margin:0;
+padding:2px;
+}
+.Gmnuri3F {
+-moz-background-clip:border;
+-moz-background-inline-policy:continuous;
+-moz-background-origin:padding;
+background:transparent none repeat scroll 0 0;
+border-collapse:collapse;
+margin:4px;
+}
+.Gmnuri3F > tbody > tr > td {
+border:1px solid #D9E6F0;
+padding:2px;
+}
+.Gmnuri3F > tbody > tr {
+color:#375B91;
+}
+.Gmnuri3F > tbody > tr:first-child {
+-moz-background-clip:border;
+-moz-background-inline-policy:continuous;
+-moz-background-origin:padding;
+background:#E3E9FF none repeat scroll 0 0;
+color:#000000;
+}
+.Gmnuri3E {
+-moz-background-clip:border;
+-moz-background-inline-policy:continuous;
+-moz-background-origin:padding;
+background:transparent none repeat scroll 0 0;
+border-collapse:collapse;
+}
+.Gmnuri3E > tbody > tr > td > div {
+margin:4px;
+padding:0;
+}
+.Gmnuri3E > tbody > tr > td > button {
+margin:4px;
+padding:2px 0 0;
+width:80px;
+}
+.Gmnuri3B {
+border:0 none;
+border-collapse:collapse;
+padding:0;
+}
+.Gmnuri3B > div {
+border:1px solid #D9E6F0;
+border-collapse:collapse;
+}
+.Gmnuri3B h3 {
+-moz-background-clip:border;
+-moz-background-inline-policy:continuous;
+-moz-background-origin:padding;
+background:#E3E9FF none repeat scroll 0 0;
+border-bottom:1px solid #D9E6F0;
+color:#375B91;
+margin:0;
+padding:2px;
+}
+.Gmnuri3B > div > table > tbody > tr > td {
+-moz-background-clip:border;
+-moz-background-inline-policy:continuous;
+-moz-background-origin:padding;
+background:#E3E9FF none repeat scroll 0 0;
+border:1px solid #D9E6F0;
+margin:0;
+padding:2px;
+width:150px;
+}
+.Gmnuri3B > div > button {
+margin:4px;
+padding:0;
+width:92px;
+}
+.Gmnuri3C {
+-moz-background-clip:border;
+-moz-background-inline-policy:continuous;
+-moz-background-origin:padding;
+background:transparent none repeat scroll 0 0;
+border-collapse:collapse;
+margin:4px;
+}
+.Gmnuri3A {
+border:0 none;
+border-collapse:collapse;
+margin:0;
+padding:0;
+}
+.Gmnuri3A > div {
+border:1px solid #D9E6F0;
+border-collapse:collapse;
+}
+.Gmnuri3A h3 {
+-moz-background-clip:border;
+-moz-background-inline-policy:continuous;
+-moz-background-origin:padding;
+background:#E3E9FF none repeat scroll 0 0;
+border-bottom:1px solid #D9E6F0;
+color:#375B91;
+margin:0;
+padding:2px;
+}
+.Gmnuri3A > div > select {
+-moz-background-clip:border;
+-moz-background-inline-policy:continuous;
+-moz-background-origin:padding;
+background:#E3E9FF none repeat scroll 0 0;
+border:1px solid #D9E6F0;
+margin:4px;
+padding:2px 0 0;
+}
+.Gmnuri3A > div > button {
+margin:4px;
+padding:2px 0 0;
+width:80px;
+}
+
+body {
+ padding: 10px;
+}
+
+/*
+ * ScrollTable
+ */
+.gwt-ScrollTable {
+ border-color: #aaa;
+ border-style: solid;
+ border-width: 1px 0px 1px 1px;
+}
+
+.gwt-ScrollTable .headerWrapper {
+ background: #8bd url(images/bg_header_gradient.gif) repeat-x bottom left;
+}
+
+.gwt-ScrollTable .footerWrapper {
+ border-top: 1px solid #aaa;
+ background: #8bd url(images/bg_header_gradient.gif) repeat-x bottom left;
+}
+
+.gwt-ScrollTable .dataTable td,
+.gwt-ScrollTable .headerTable td,
+.gwt-ScrollTable .footerTable td {
+ border-color: #aaa;
+ border-style: solid;
+ border-width: 0px 1px 1px 0px;
+ white-space: nowrap;
+ overflow: hidden;
+}
+
+.gwt-ScrollTable .headerTable td,
+.gwt-ScrollTable .footerTable td {
+ color: #fff;
+}
+
+.gwt-ScrollTable .dataTable tr.highlighted {
+ background: #C3D9FF;
+}
+
+.gwt-ScrollTable .dataTable td.highlighted {
+ background: #FFFFAA;
+ cursor: hand;
+ cursor: pointer;
+}
+
+.gwt-ScrollTable .dataTable tr.selected td {
+ background: #7AA5D6;
+}
+
+.badGPA {
+ background: #FFAAAA;
+}
+.goodGPA {
+ background: #AAAAFF;
+}
+.greatGPA {
+ background: #AAFFAA;
+}
+
+/**
+ * Applied to the options at the bottom of the page.
+ */
+.gwt-PagingOptions {
+ background: #e8eef7;
+ border: 1px solid #aaa;
+ border-top: none;
+}
+
+.gwt-PagingOptions .errorMessage {
+ color: red;
+}
+
+.pagingOptionsFirstPage,
+.pagingOptionsLastPage,
+.pagingOptionsNextPage,
+.pagingOptionsPrevPage {
+ cursor: hand;
+ cursor: pointer;
+}
+
+.gwt-InlineCellEditor {
+ border: 3px solid #7AA5D6;
+ padding: 4px;
+ background: white;
+ overflow: auto;
+}
+.gwt-InlineCellEditor .accept {
+ cursor: pointer;
+ cursor: hand;
+}
+.gwt-InlineCellEditor .cancel {
+ cursor: pointer;
+ cursor: hand;
+}
+
+/** Applied to AbstractOptions */
+.AbstractOption-Label {
+ font-weight: bold;
+ text-align: right;
+}
+
+.stats{
+ border: 1px solid #92C1F0;
+ }
+
+
+
--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<!-- The HTML 4.01 Transitional DOCTYPE declaration-->
+<!-- above set at the top of the file will set -->
+<!-- the browser's rendering engine into -->
+<!-- "Quirks Mode". Replacing this declaration -->
+<!-- with a "Standards Mode" doctype is supported, -->
+<!-- but may lead to some differences in layout. -->
+
+
+<html>
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+
+ <!-- -->
+ <!-- Consider inlining CSS to reduce the number of requested files -->
+ <!-- -->
+ <link type="text/css" rel="stylesheet" href="TwoAdmin.css">
+ <link type="text/css" rel="stylesheet" href="gss.css">
+
+ <!-- -->
+ <!-- Any title is fine -->
+ <!-- -->
+ <title>Administration Application</title>
+
+ <!-- -->
+ <!-- This script loads your compiled module. -->
+ <!-- If you add any GWT meta tags, they must -->
+ <!-- be added before this line. -->
+ <!-- -->
+ <script type="text/javascript" src="http://www.google.com/jsapi"></script>
+ <script type="text/javascript">
+ google.load("visualization", "1", {'packages' : ["piechart"] });
+ </script>
+ <script type="text/javascript" language="javascript" src="gr.ebs.gss.admin.TwoAdmin.nocache.js"></script>
+ </head>
+
+ <!-- -->
+ <!-- The body can have arbitrary html, or -->
+ <!-- you can leave the body empty if you want -->
+ <!-- to create a completely dynamic UI. -->
+ <!-- -->
+ <body>
+ <noscript>
+ <div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color:white; border: 1px solid red; padding: 4px; font-family: sans-serif">
+ Your web browser must have JavaScript enabled
+ in order for this application to display correctly.
+ </div>
+ </noscript>
+ </body>
+</html>
--- /dev/null
+body {
+ background-color: #f5f5f5;
+ color: black;
+ font-family: "Lucida Grande","Lucida Sans Unicode",Arial,Verdana,sans-serif;
+ font-size: small;
+ margin: 8px;
+ margin-top: 3px;
+}
+
+a {
+ color: darkblue;
+}
+
+a:visited {
+ color: darkblue;
+}
+
+.hidden-link {
+ text-decoration: none !important;
+ color: black !important;
+}
+
+.hidden-link:visited {
+ text-decoration: none !important;
+ color: black !important;
+}
+
+.gss-TopPanel {
+ font-size: 100%;
+}
+
+.gss-TopPanelLinks {
+ font-size: 100%;
+}
+
+.gss-AboutText {
+ width: 24em;
+ /* Restore the padding we remove when overriding the gwt-DialogBox style */
+ padding: 3px;
+}
+
+.gss-Groups {
+ background-color: white;
+ font-size: 80%;
+}
+
+.toolbar {
+ border-bottom: 1px solid darkgrey;
+ background-color: #F5F5F5;
+ font-size: 80%;
+ cursor: pointer;
+}
+
+.toolbarmenu {
+ font-size: 80%;
+ cursor: pointer;
+}
+
+.statusbar-inner {
+ border: none;
+ font-size: 90%;
+ vertical-align: middle;
+ font-weight: normal;
+}
+
+.gss-List {
+ background-color: white;
+ font-size: 80%;
+ cursor: default;
+ border-collapse: collapse;
+ /* prevents selecting text in table with shift and ctrl*/
+ -moz-user-select: none;
+}
+
+.gss-ListHeader {
+ border: 1px darkgrey solid;
+ background-color: #DCDCDC;
+ font-weight: bold;
+ cursor: pointer;
+}
+
+.gss-searchLabel {
+ font-weight: bold;
+ font-style: italic;
+ font-size: 90%;
+ padding:5px;
+}
+
+.gss-ListNavBar {
+ font-size: 80%;
+}
+
+.gss-SelectedRow {
+ background-color: #DCDCDC;
+}
+.gss-fileRow{
+ cursor: pointer;
+}
+
+.gss-Toolbar {
+
+}
+
+.gss-ToolButton {
+ font-size: 80%;
+ width: 10em;
+}
+
+.props-labels {
+ font-size: 80%;
+ font-weight: bold;
+}
+
+.props-toplabels {
+ font-size: 80%;
+ font-weight: bold;
+ font-style: italic;
+}
+
+.props-values {
+ font-size: 80%;
+}
+
+.gss-errorMessage {
+ font-size: 90%;
+ background-color: #ff9999;
+ cursor: pointer;
+}
+
+.gss-warnMessage {
+ font-size: 90%;
+ background-color: #eeee99;
+ cursor: pointer;
+}
+
+.gss-infoMessage {
+ font-size: 90%;
+ background-color: #ccffcc;
+ cursor: pointer;
+}
+
+.gss-clearMessage {
+ font-size: 90%;
+ font-weight: bold;
+ text-decoration: none;
+ color: black;
+}
+
+.gss-clearMessage:visited {
+ font-size: 90%;
+ font-weight: bold;
+ text-decoration: none;
+ color: black;
+}
+
+.gss-search {
+ color: black;
+}
+
+.gss-search-empty {
+ color: #d3d3d3;
+}
+
+.gss-DialogBox {
+}
+
+.gss-readForAllNote {
+ width: 240px;
+ text-align: justify;
+ font-style: italic;
+ font-size: 12px;
+ padding-left: 4;
+}
+
+/* Tooltips */
+a.info {
+ position: relative; /*this is the key*/
+ z-index: 24;
+ color: black;
+ text-decoration: none
+}
+
+a.info:hover {
+ z-index: 25;
+ background-color: yellow;
+}
+
+a.info div {
+ display: none
+}
+
+a.info:hover span {
+ cursor: pointer;
+}
+
+/* The span will only display on :hover state. */
+a.info:hover div {
+ display: block;
+ position: absolute;
+ bottom: 2em;
+ right: 1em;
+ width: 10em;
+ border: 1px solid darkgrey;
+ background-color: #DCDCDC;
+ color: black;
+ text-align: center
+}
+
+table.gss-permList.props-labels {
+ font-weight: bold;
+}
+
+table.gss-permList {
+ border-spacing: 3px;
+ border-collapse: collapse;
+
+}
+
+table.gss-permList td {
+ padding: 5px 5px 5px 5px;
+ font-size:80%;
+}
+
+.progressbar-text {
+ font-weight: bold;
+}
+
+.progressbar-remaining {
+ font-size: 12px;
+ font-style: italic;
+}
+
+.progressbar-outer {
+}
+
+.progressbar-inner {
+ border: 1px solid darkgrey;
+ margin: 1px;
+}
+
+.progressbar-bar {
+ width: 5px;
+ height: 15px;
+ margin: 0px;
+}
+
+.progressbar-fullbar {
+ background: #DCDCDC;
+}
+
+.progressbar-blankbar {
+ background: white;
+}
+
+.gss-uploadNote {
+ text-align: justify;
+ font-style: italic;
+ font-size: 12px;
+ padding-top: 16;
+ padding-bottom: 16;
+ padding-right: 4;
+ padding-left: 4;
+}
+
+.gss-MainTabBar {
+ padding-top: 4px;
+}
+
+.gss-MainTabPanelBottom {
+ border-bottom: none;
+ border-left: none;
+ border-right: none;
+ overflow: hidden;
+ padding: 6px;
+}
+
+.gss-TabPanelBottom {
+ border-color: darkgrey;
+ border-width: 1px 1px 1px;
+ overflow: hidden;
+ padding: 6px;
+}
+
+.gss-splitPanel {
+ background-color: white;
+ border: 1px solid darkgrey;
+}
+
+/* Avoid extended background color in tree nodes. */
+.gwt-TreeItem-selected .gwt-HTML {
+ display: inline;
+}
+
+/*
+ * Remove the padding inside the dialog boxes so that our background color
+ * appears uniform in warnings and errors.
+ */
+.gwt-DialogBox .dialogMiddleCenter {
+ background:none repeat scroll 0 0 white;
+ padding: 0;
+}
--- /dev/null
+/*
+ * Copyright 2010 Electronic Business Systems Ltd.
+ *
+ * This file is part of GSS.
+ *
+ * GSS is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * GSS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with GSS. If not, see <http://www.gnu.org/licenses/>.
+ */
+package gr.ebs.gss.server.admin;
+
+import static gr.ebs.gss.server.configuration.GSSConfigurationFactory.getConfiguration;
+import gr.ebs.gss.admin.client.AdminService;
+import gr.ebs.gss.client.exceptions.InsufficientPermissionsException;
+import gr.ebs.gss.client.exceptions.ObjectNotFoundException;
+import gr.ebs.gss.client.exceptions.RpcException;
+import gr.ebs.gss.server.configuration.GSSConfigurationFactory;
+import gr.ebs.gss.server.domain.dto.FileBodyDTO;
+import gr.ebs.gss.server.domain.dto.FileHeaderDTO;
+import gr.ebs.gss.server.domain.dto.PermissionDTO;
+import gr.ebs.gss.server.domain.dto.StatsDTO;
+import gr.ebs.gss.server.domain.dto.SystemStatsDTO;
+import gr.ebs.gss.server.domain.dto.UserClassDTO;
+import gr.ebs.gss.server.domain.dto.UserDTO;
+import gr.ebs.gss.server.ejb.AdminAPI;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Set;
+
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.rmi.PortableRemoteObject;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import com.google.gwt.user.server.rpc.RemoteServiceServlet;
+
+public class AdminServiceImpl extends RemoteServiceServlet implements AdminService {
+ /**
+ * The logger.
+ */
+ private static Log logger = LogFactory.getLog(AdminServiceImpl.class);
+
+ /**
+ * A helper method that retrieves a reference to the AdminAPI bean and
+ * stores it for future use.
+ *
+ * @return an AdminAPI instance
+ * @throws RpcException in case an error occurs
+ */
+ protected AdminAPI getService() throws RpcException {
+ try {
+ final Context ctx = new InitialContext();
+ final Object ref = ctx.lookup(getConfiguration().getString("adminApiPath"));
+ return (AdminAPI) PortableRemoteObject.narrow(ref, AdminAPI.class);
+ } catch (final NamingException e) {
+ logger.error("Unable to retrieve the AdminAPI EJB", e);
+ throw new RpcException("An error occurred while contacting the naming service");
+ }
+ }
+
+ @Override
+ public List<UserDTO> getUsers() throws RpcException, ObjectNotFoundException {
+ return getService().searchUsers("");
+ }
+
+ @Override
+ public StatsDTO getUserStatistics(Long userId) throws RpcException, ObjectNotFoundException {
+ return getService().getUserStatistics(userId);
+ }
+
+
+
+ @Override
+ public void toggleActiveUser(Long userId) throws RpcException, ObjectNotFoundException {
+ getService().toggleActiveUser(userId);
+
+ }
+
+ @Override
+ public void setFilePermissions(String uri, Set<PermissionDTO> permissions) throws ObjectNotFoundException, RpcException {
+ getService().setFilePermissions(uri, permissions);
+ }
+
+ @Override
+ public List<UserDTO> searchUsers(String query) throws RpcException, ObjectNotFoundException {
+ return getService().searchUsers(query);
+ }
+
+ @Override
+ public SystemStatsDTO getSystemStatistics() throws RpcException {
+ return getService().getSystemStatistics();
+ }
+
+ @Override
+ public List<UserDTO> getLastLoggedInUsers(Date lastLoginDate) throws RpcException {
+ return getService().getLastLoggedInUsers(lastLoginDate);
+ }
+
+ @Override
+ public void logout() {
+ getThreadLocalRequest().getSession().invalidate();
+ }
+
+ @Override
+ public List<FileHeaderDTO> searchFiles(String query) throws RpcException, ObjectNotFoundException, InsufficientPermissionsException {
+ if(query==null)
+ throw new ObjectNotFoundException("Invalid query");
+ String restUrl = GSSConfigurationFactory.getConfiguration().getString("restUrl");
+ if(query.startsWith(restUrl))
+ query= query.substring(restUrl.length(),query.length());
+ if(query.indexOf("/")==-1)//do only a name search
+ return getService().searchFileByFilename(query);
+ return getService().getFiles(query);
+ }
+
+ @Override
+ public UserDTO getUser(String username) throws ObjectNotFoundException, RpcException{
+ return getService().getUser(username);
+ }
+
+ @Override
+ public FileHeaderDTO getFile(long fileId) throws ObjectNotFoundException, RpcException {
+ return getService().getFile(fileId);
+ }
+
+ @Override
+ public List<FileBodyDTO> getVersions(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException, RpcException {
+ return getService().getVersions(userId, fileId);
+ }
+
+ @Override
+ public List<UserDTO> getUsersWaitingActivation() throws RpcException {
+ return getService().getUsersWaitingActivation();
+ }
+
+ @Override
+ public void changeUserClass(Long userId, Long userClassId) throws RpcException, ObjectNotFoundException {
+ getService().changeUserClass(userId, userClassId);
+
+ }
+
+ @Override
+ public List<UserClassDTO> getUserClasses() throws RpcException {
+ return getService().getUserClasses();
+ }
+
+ @Override
+ public void saveOrUpdateUserClass(UserClassDTO userClass) throws RpcException, ObjectNotFoundException {
+ getService().saveOrUpdateUserClass(userClass);
+ }
+
+ @Override
+ public void removeUserClass(UserClassDTO userClass) throws RpcException, ObjectNotFoundException {
+ getService().removeUserClass(userClass);
+ }
+
+ @Override
+ public void removeUser(Long userId) throws RpcException, ObjectNotFoundException, InsufficientPermissionsException {
+ getService().removeUser(userId);
+
+ }
+
+}