Revision fc0fa492

b/.classpath
26 26
			<attribute name="javadoc_location" value="http://commons.apache.org/codec/api-release/"/>
27 27
		</attributes>
28 28
	</classpathentry>
29
	<classpathentry kind="lib" path="dependencies/gwt-2.0.4/gwt-user.jar"/>
29
	<classpathentry kind="lib" path="dependencies/gwt-2.1.1/gwt-user.jar" sourcepath="/home/kman/.m2/repository/com/google/gwt/gwt-user/2.1.0/gwt-user-2.1.0-sources.jar"/>
30 30
	<classpathentry kind="lib" path="dependencies/junit3.8.1/junit.jar"/>
31 31
	<classpathentry kind="lib" path="dependencies/jboss-5.1.0.GA/lib/concurrent.jar"/>
32 32
	<classpathentry kind="lib" path="dependencies/jboss-5.1.0.GA/lib/dom4j.jar"/>
......
180 180
	<classpathentry kind="lib" path="dependencies/jboss-5.1.0.GA/common/lib/slf4j-jboss-logging.jar"/>
181 181
	<classpathentry kind="lib" path="dependencies/jboss-5.1.0.GA/common/lib/xnio-api.jar"/>
182 182
	<classpathentry kind="lib" path="dependencies/gwt-dnd-3.0.1.jar"/>
183
	<classpathentry kind="lib" path="dependencies/gwt-incubator-20100204-r1747.jar"/>
184 183
	<classpathentry kind="lib" path="dependencies/gwt-gears-1.3.0/gwt-gears.jar"/>
185 184
	<classpathentry kind="lib" path="dependencies/gwt-visualization-1.1.0/gwt-visualization.jar"/>
186 185
	<classpathentry kind="lib" path="dependencies/apache-solr-1.4.1/dist/apache-solr-solrj-1.4.1.jar"/>
b/build.xml
26 26
	<property name="solr.download.url" value="http://apache.ntua.gr/lucene/solr/${solr.version}/${solr.filename}"/>
27 27
	<property name="solrj.version" value="1.4.1"/>
28 28
	<property name="solrj.jar" value="apache-solr-solrj-${solrj.version}.jar"/>
29
    <property name="gwt.path" value="${deps.dir}/gwt-2.0.4"/>
30
    <property name="gwt.filename" value="gwt-2.0.4.zip"/>
31
	<property name="gwt.download.url" value="http://google-web-toolkit.googlecode.com/files/gwt-2.0.4.zip"/>
29
    <property name="gwt.path" value="${deps.dir}/gwt-2.1.1"/>
30
    <property name="gwt.filename" value="gwt-2.1.1.zip"/>
31
	<property name="gwt.download.url" value="http://google-web-toolkit.googlecode.com/files/gwt-2.1.1.zip"/>
32 32
    <property name="hornetq.path" value="${deps.dir}/hornetq-2.0.0.GA" />
33 33
    <property name="hornetq.filename" value="hornetq-2.0.0.GA.zip/"/>
34 34
    <property name="hornetq.download.url" value="http://sourceforge.net/projects/hornetq/files/2.0.0.GA/hornetq-2.0.0.GA.zip/download"/>
......
43 43
    <property name="gwt-visualization.path" value="${deps.dir}/gwt-visualization-1.1.0" />
44 44
    <property name="gwt-visualization.filename" value="gwt-visualization-1.1.0.zip"/>
45 45
    <property name="gwt-visualization.download.url" value="http://gwt-google-apis.googlecode.com/files/gwt-visualization-1.1.0.zip"/>
46
    <property name="gwt-incubator.filename" value="gwt-incubator-20100204-r1747.jar"/>
47
    <property name="gwt-incubator.download.url" value="http://google-web-toolkit-incubator.googlecode.com/files/gwt-incubator-20100204-r1747.jar"/>
46
    <property name="gwt-incubator.filename" value="gwt-incubator-20101117-r1766.jar"/>
47
    <property name="gwt-incubator.download.url" value="http://google-web-toolkit-incubator.googlecode.com/files/gwt-incubator-20101117-r1766.jar"/>
48 48

  
49 49
	<!-- Source and runtime layout configuration -->
50 50
	<property name="jboss_run_configuration" value="default" />
......
129 129
		<pathelement location="${junit.path}/junit.jar"/>
130 130
		<pathelement location="${deps.dir}/${gwt-dnd.filename}"/>
131 131
		<pathelement location="${gwt-gears.path}/gwt-gears.jar"/>
132
		<pathelement location="${deps.dir}/${gwt-incubator.filename}"/>
132
		<!--<pathelement location="${deps.dir}/${gwt-incubator.filename}"/>-->
133 133
		<pathelement location="${gwt-visualization.path}/gwt-visualization.jar"/>
134 134
		<pathelement location="${solr.dist}/${solrj.jar}"/>
135 135
        <pathelement location="${solr.dist}/apache-solr-core-1.4.1.jar"/>
......
141 141
		<available file="${jboss.home}" type="dir" property="jboss.home.present"/>
142 142
	</target>
143 143

  
144
    <target name="fetch-dependencies" description="Fetch the dpendencies" unless="jboss.home.present" depends="check-jboss">
144
    <target name="fetch-dependencies" description="Fetch the dpendencies" depends="check-jboss">
145 145
    	<mkdir dir="${deps.dir}"/>
146
        <get src="${gwt.download.url}" dest="${deps.dir}/${gwt.filename}" usetimestamp="true"/>
147
        <get src="${gwt-dnd.download.url}" dest="${deps.dir}/${gwt-dnd.filename}" usetimestamp="true"/>
146
  <!--       
147
    <get src="${gwt-dnd.download.url}" dest="${deps.dir}/${gwt-dnd.filename}" usetimestamp="true"/>
148 148
        <get src="${gwt-gears.download.url}" dest="${deps.dir}/${gwt-gears.filename}" usetimestamp="true"/>
149 149
        <get src="${gwt-visualization.download.url}" dest="${deps.dir}/${gwt-visualization.filename}" usetimestamp="true"/>
150
        <get src="${gwt-incubator.download.url}" dest="${deps.dir}/${gwt-incubator.filename}" usetimestamp="true"/>
150
       
151 151
        <get src="${hornetq.download.url}" dest="${deps.dir}/${hornetq.filename}" usetimestamp="true"/>
152 152
        <get src="${junit.download.url}" dest="${deps.dir}/${junit.filename}" usetimestamp="true"/>
153 153
        <get src="${jboss.download.url}" dest="${deps.dir}/${jboss.filename}" usetimestamp="true"/>
154
    	<unzip src="${deps.dir}/${gwt.filename}" dest="${deps.dir}"/>
155
        <unzip src="${deps.dir}/${gwt-gears.filename}" dest="${deps.dir}"/>
154
-->
155
	 <get src="${gwt.download.url}" dest="${deps.dir}/${gwt.filename}" usetimestamp="true"/>
156
 <get src="${gwt-incubator.download.url}" dest="${deps.dir}/${gwt-incubator.filename}" usetimestamp="true"/>
157
	<unzip src="${deps.dir}/${gwt.filename}" dest="${deps.dir}"/>
158
<!--  
159

  
160
      <unzip src="${deps.dir}/${gwt-gears.filename}" dest="${deps.dir}"/>
156 161
        <unzip src="${deps.dir}/${gwt-visualization.filename}" dest="${deps.dir}"/>
157 162
        <unzip src="${deps.dir}/${hornetq.filename}" dest="${deps.dir}"/>
158 163
        <unzip src="${deps.dir}/${junit.filename}" dest="${deps.dir}"/>
159
        <unzip src="${deps.dir}/${jboss.filename}" dest="${jboss.home}/.."/>
164
        <unzip src="${deps.dir}/${jboss.filename}" dest="${jboss.home}/.."/>-->
160 165
    </target>
161 166

  
162 167
	<target name="install" depends="fetch-dependencies, install-solr" description="Installs the configuration files of the application server">
......
364 369
		</jar>
365 370
	</target>
366 371
	
367
	<target name="package-ear" depends="package-admin-war, package-war, package-webdav-war, package-ejb, package-mbeans" description="Package up the project as an ear">
372
	<target name="package-ear" depends=" package-war, package-webdav-war, package-ejb, package-mbeans" description="Package up the project as an ear">
368 373
		<jar destfile="${build.dir}/${dist.ear}">
369 374
			<zipfileset dir="${ear.dir}" />
370 375
			<zipfileset dir="${build.dir}" >
371 376
				<include name="ejbs.jar" />
372 377
				<include name="${dist.war}" />
373 378
				<include name="${webdav.war}" />
374
                <include name="${dist.admin.war}" />
379

  
375 380
				<include name="${mbeans.dist.file}"/>
376 381
			</zipfileset>
377 382
    		<zipfileset dir="${solr.dist}" prefix="lib">
b/ear/META-INF/application.xml
7 7
			<context-root>/pithos</context-root>
8 8
		</web>
9 9
	</module>
10
	<!-- 
10 11
	<module>
11 12
		<web>
12 13
			<web-uri>gss-admin.war</web-uri>
13 14
			<context-root>/admin</context-root>
14 15
		</web>
15 16
	</module>
17
	-->
16 18
	<module>
17 19
		<web>
18 20
			<web-uri>webdav.war</web-uri>
/dev/null
1
<?xml version="1.0" encoding="UTF-8"?>
2
<module>
3
  <!-- Inherit the core Web Toolkit stuff.                        -->
4
  <inherits name='com.google.gwt.user.User'/>
5
  <inherits name='com.google.gwt.user.datepicker.DatePicker'/>
6
	
7
  <!-- Inherit the default GWT style sheet.  You can change       -->
8
  <!-- the theme of your GWT application by uncommenting          -->
9
  <!-- any one of the following lines.                            -->
10
  <inherits name="com.google.gwt.user.theme.standard.Standard"/>
11
  <!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
12
  <!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/>     -->
13
	<inherits name='com.google.gwt.gen2.Gen2' /> 
14
    <inherits name="com.google.gwt.visualization.Visualization"/>
15
	<inherits name='gr.ebs.gss.client.exceptions' />
16
	<inherits name='gr.ebs.gss.server.domain.dto' />
17
   <!-- <set-property name="user.agent" value="gecko,gecko1_8" />-->   
18

  
19
  <!-- Specify the app entry point class.                         -->
20
  <entry-point class='gr.ebs.gss.admin.client.TwoAdmin'/>
21

  
22
  <!-- Specify the paths for translatable code                    -->
23
  <source path='client'/>
24
</module>
/dev/null
1
package gr.ebs.gss.admin.client;
2

  
3
import gr.ebs.gss.client.exceptions.InsufficientPermissionsException;
4
import gr.ebs.gss.client.exceptions.ObjectNotFoundException;
5
import gr.ebs.gss.client.exceptions.RpcException;
6
import gr.ebs.gss.server.domain.dto.FileBodyDTO;
7
import gr.ebs.gss.server.domain.dto.FileHeaderDTO;
8
import gr.ebs.gss.server.domain.dto.PermissionDTO;
9
import gr.ebs.gss.server.domain.dto.StatsDTO;
10
import gr.ebs.gss.server.domain.dto.SystemStatsDTO;
11
import gr.ebs.gss.server.domain.dto.UserClassDTO;
12
import gr.ebs.gss.server.domain.dto.UserDTO;
13

  
14
import java.util.Date;
15
import java.util.List;
16
import java.util.Set;
17

  
18
import com.google.gwt.user.client.rpc.RemoteService;
19
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
20

  
21
@RemoteServiceRelativePath("admin")
22
public interface AdminService extends RemoteService {
23
	List<UserDTO> getUsers() throws RpcException, ObjectNotFoundException;
24

  
25
	List<UserDTO> searchUsers(String query) throws RpcException, ObjectNotFoundException;
26

  
27
	StatsDTO getUserStatistics(Long userId) throws RpcException, ObjectNotFoundException;
28

  
29
	void toggleActiveUser(Long userId) throws RpcException,ObjectNotFoundException;
30

  
31
	void setFilePermissions(String uri, Set<PermissionDTO> permissions)	throws RpcException, ObjectNotFoundException;
32

  
33
	SystemStatsDTO getSystemStatistics() throws RpcException,ObjectNotFoundException;
34

  
35
	public List<UserDTO> getLastLoggedInUsers(Date lastLoginDate) throws RpcException;
36

  
37
	public void logout();
38

  
39
	public List<FileHeaderDTO> searchFiles(String query) throws RpcException, ObjectNotFoundException, InsufficientPermissionsException;
40

  
41
	UserDTO getUser(String username) throws ObjectNotFoundException, RpcException;
42

  
43
	FileHeaderDTO getFile(long fileId) throws ObjectNotFoundException, RpcException;
44

  
45
	public List<FileBodyDTO> getVersions(Long userId, Long fileId) throws ObjectNotFoundException, InsufficientPermissionsException,RpcException;
46

  
47
	List<UserDTO> getUsersWaitingActivation() throws RpcException;
48

  
49
	void changeUserClass(Long userId,Long userClassId) throws RpcException,ObjectNotFoundException;
50

  
51
	List<UserClassDTO> getUserClasses() throws RpcException;
52

  
53
	void saveOrUpdateUserClass(UserClassDTO userClass) throws RpcException,ObjectNotFoundException;
54

  
55
	void removeUserClass(UserClassDTO userClass) throws RpcException,ObjectNotFoundException;
56

  
57
	void removeUser(Long userId) throws RpcException,ObjectNotFoundException,InsufficientPermissionsException;
58
	
59
}
/dev/null
1
package gr.ebs.gss.admin.client;
2

  
3
import gr.ebs.gss.server.domain.dto.FileBodyDTO;
4
import gr.ebs.gss.server.domain.dto.FileHeaderDTO;
5
import gr.ebs.gss.server.domain.dto.PermissionDTO;
6
import gr.ebs.gss.server.domain.dto.StatsDTO;
7
import gr.ebs.gss.server.domain.dto.SystemStatsDTO;
8
import gr.ebs.gss.server.domain.dto.UserClassDTO;
9
import gr.ebs.gss.server.domain.dto.UserDTO;
10

  
11
import java.util.Date;
12
import java.util.List;
13
import java.util.Set;
14

  
15
import com.google.gwt.user.client.rpc.AsyncCallback;
16

  
17
public interface AdminServiceAsync {
18
	void getUsers(AsyncCallback<List<UserDTO>> callback);
19

  
20
	void getUserStatistics(Long userId, AsyncCallback<StatsDTO> callback);
21

  
22
	void toggleActiveUser(Long userId, AsyncCallback<Void> callback);
23

  
24
	void setFilePermissions(String uri, Set<PermissionDTO> permissions, AsyncCallback<Void> callback);
25

  
26
	void searchUsers(String query, AsyncCallback<List<UserDTO>> callback);
27

  
28
	void getSystemStatistics(AsyncCallback<SystemStatsDTO> callback);
29

  
30
	void getLastLoggedInUsers(Date lastLoginDate, AsyncCallback<List<UserDTO>> callback);
31

  
32
	void logout(AsyncCallback<Void> callback);
33

  
34
	void searchFiles(String query, AsyncCallback<List<FileHeaderDTO>> callback);
35

  
36
	void getUser(String username, AsyncCallback<UserDTO> callback);
37

  
38
	void getFile(long fileId, AsyncCallback<FileHeaderDTO> callback);
39

  
40
	void getVersions(Long userId, Long fileId, AsyncCallback<List<FileBodyDTO>> callback);
41

  
42
	void getUsersWaitingActivation(AsyncCallback<List<UserDTO>> callback);
43

  
44
	void changeUserClass(Long userId, Long userClassId, AsyncCallback<Void> callback);
45

  
46
	void getUserClasses(AsyncCallback<List<UserClassDTO>> callback);
47

  
48
	void saveOrUpdateUserClass(UserClassDTO userClass, AsyncCallback<Void> callback);
49

  
50
	void removeUserClass(UserClassDTO userClass, AsyncCallback<Void> callback);
51

  
52
	void removeUser(Long userId, AsyncCallback<Void> callback);
53

  
54
}
/dev/null
1
package gr.ebs.gss.admin.client;
2

  
3
import gr.ebs.gss.admin.client.ui.HeaderPanel;
4
import gr.ebs.gss.admin.client.ui.UserPanel;
5
import gr.ebs.gss.admin.client.ui.VisualizationPanel;
6
import gr.ebs.gss.server.domain.dto.SystemStatsDTO;
7

  
8
import com.google.gwt.core.client.EntryPoint;
9
import com.google.gwt.core.client.GWT;
10
import com.google.gwt.event.dom.client.ClickEvent;
11
import com.google.gwt.event.dom.client.ClickHandler;
12
import com.google.gwt.event.logical.shared.ResizeEvent;
13
import com.google.gwt.event.logical.shared.ResizeHandler;
14
import com.google.gwt.event.logical.shared.SelectionEvent;
15
import com.google.gwt.event.logical.shared.SelectionHandler;
16
import com.google.gwt.uibinder.client.UiBinder;
17
import com.google.gwt.uibinder.client.UiField;
18
import com.google.gwt.user.client.Command;
19
import com.google.gwt.user.client.DeferredCommand;
20
import com.google.gwt.user.client.Window;
21
import com.google.gwt.user.client.rpc.AsyncCallback;
22
import com.google.gwt.user.client.ui.Button;
23
import com.google.gwt.user.client.ui.DialogBox;
24
import com.google.gwt.user.client.ui.DockLayoutPanel;
25
import com.google.gwt.user.client.ui.Label;
26
import com.google.gwt.user.client.ui.RootLayoutPanel;
27
import com.google.gwt.user.client.ui.TabLayoutPanel;
28
import com.google.gwt.user.client.ui.VerticalPanel;
29

  
30
/**
31
 * Entry point classes define <code>onModuleLoad()</code>.
32
 */
33
public class TwoAdmin implements EntryPoint {
34

  
35
	interface Binder extends UiBinder<DockLayoutPanel, TwoAdmin> {
36
	}
37

  
38
	private final AdminServiceAsync adminService = GWT.create(AdminService.class);
39

  
40
	private static final Binder binder = GWT.create(Binder.class);
41

  
42
	/**
43
	 * The single TwoAdmin instance.
44
	 */
45
	private static TwoAdmin singleton;
46

  
47
	/**
48
	 * Gets the singleton TwoAdmin instance.
49
	 *
50
	 * @return the TwoAdmin object
51
	 */
52
	public static TwoAdmin get() {
53
		if (TwoAdmin.singleton == null)
54
			TwoAdmin.singleton = new TwoAdmin();
55
		return TwoAdmin.singleton;
56
	}
57

  
58
	@UiField(provided = true)
59
	HeaderPanel headerPanel = new HeaderPanel();
60

  
61
	@UiField UserPanel userPanel;
62

  
63
	@UiField
64
	TabLayoutPanel tabPanel;
65

  
66
	@UiField VisualizationPanel chart2;
67

  
68
	final DialogBox loadingBox = new DialogBox();
69

  
70
	@Override
71
	public void onModuleLoad() {
72
		TwoAdmin.singleton=this;
73
		loadingBox.setHTML("Loading data");
74
		//scroll.setAlwaysShowScrollBars(true);
75
		VerticalPanel vPanel = new VerticalPanel();
76
		loadingBox.setSize("50%", "50%");
77
		loadingBox.setWidget(vPanel);
78
		vPanel.add(new Label("Fetching Requested Data"));
79

  
80
		DockLayoutPanel outer = binder.createAndBindUi(this);
81
		tabPanel.addSelectionHandler(new SelectionHandler<Integer>() {
82

  
83
			@Override
84
			public void onSelection(SelectionEvent<Integer> event) {
85
				switch (event.getSelectedItem()) {
86
					case 0:
87
						loadStatistics();
88
						break;
89
					default:
90
						break;
91
				}
92

  
93
			}
94
		});
95

  
96

  
97
		// Get rid of scrollbars, and clear out the window's built-in margin,
98
		// because we want to take advantage of the entire client area.
99
		//Window.enableScrolling(true);
100
		//Window.setMargin("0px");
101
		Window.addResizeHandler(new ResizeHandler(){
102

  
103
			@Override
104
			public void onResize(ResizeEvent event) {
105
				int height=event.getHeight();
106
				resize(height);
107

  
108
			}
109

  
110
		});
111
		RootLayoutPanel root = RootLayoutPanel.get();
112
		root.add(outer);
113
		// RootPanel.get().add(outer);
114
		loadStatistics();
115
		tabPanel.selectTab(0);
116

  
117
		resize(Window.getClientHeight());
118
	}
119

  
120
	private void resize(int height){
121

  
122
		int newHeight = height - tabPanel.getAbsoluteTop()-100;
123
		if (newHeight < 1)
124
			newHeight = 1;
125
		tabPanel.setHeight("" + newHeight);
126
		GWT.log("New Height:"+ newHeight);
127
	}
128
	/**
129
	 * Retrieve the adminService.
130
	 *
131
	 * @return the adminService
132
	 */
133
	public AdminServiceAsync getAdminService() {
134
		return adminService;
135
	}
136

  
137
	public void showErrorBox(String message) {
138
		final DialogBox dialogBox = new DialogBox();
139
		dialogBox.setHTML("An error occured");
140
		VerticalPanel vPanel = new VerticalPanel();
141
		dialogBox.setSize("50%", "50%");
142
		ClickHandler cancelHandler = new ClickHandler() {
143

  
144
			@Override
145
			public void onClick(ClickEvent event) {
146
				dialogBox.hide();
147
			}
148
		};
149
		dialogBox.setWidget(vPanel);
150
		vPanel.add(new Label(message));
151
		Button close = new Button("Close");
152
		close.addClickHandler(cancelHandler);
153
		vPanel.add(close);
154
		dialogBox.center();
155
		dialogBox.show();
156
	}
157

  
158

  
159

  
160
	public void showLoadingBox() {
161
		loadingBox.center();
162
		loadingBox.show();
163
	}
164

  
165
	public void hideLoadingBox(){
166
		loadingBox.hide();
167
	}
168

  
169

  
170
	public void loadStatistics(){
171
		DeferredCommand.addCommand(new Command() {
172

  
173
			@Override
174
			public void execute() {
175
				showLoadingBox();
176
				getAdminService().getSystemStatistics(new AsyncCallback<SystemStatsDTO>() {
177

  
178
					@Override
179
					public void onFailure(Throwable caught) {
180
						hideLoadingBox();
181
						// TODO Auto-generated method stub
182

  
183
					}
184

  
185
					@Override
186
					public void onSuccess(SystemStatsDTO result) {
187
						chart2.updateData(result);
188
						hideLoadingBox();
189
					}});
190

  
191
			}
192
		});
193
	}
194

  
195
	public void searchUsers(String query){
196
		tabPanel.selectTab(1);
197
		userPanel.populateTable(query);
198
	}
199
}
/dev/null
1
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
2
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
3
	xmlns:g='urn:import:com.google.gwt.user.client.ui' xmlns:admin='urn:import:gr.ebs.gss.admin.client'
4
	xmlns:adminui='urn:import:gr.ebs.gss.admin.client.ui'>
5

  
6
	<g:DockLayoutPanel unit='EM'>
7
		<g:north size='5'>
8
			<adminui:HeaderPanel ui:field='headerPanel' />
9
		</g:north>
10

  
11
		<g:center size='100%'>
12
			<g:TabLayoutPanel barUnit='PX' barHeight='25'
13
				height="600" ui:field="tabPanel">
14

  
15
				<g:tab>
16
					<g:header>Statistics</g:header>
17
					<g:ScrollPanel>
18
						<adminui:VisualizationPanel ui:field="chart2"></adminui:VisualizationPanel>
19
					</g:ScrollPanel>
20

  
21

  
22
				</g:tab>
23
				<g:tab>
24
					<g:header>Search Users</g:header>
25
					<g:ScrollPanel>
26
					<adminui:UserPanel ui:field="userPanel">
27
					</adminui:UserPanel>
28
					</g:ScrollPanel>
29

  
30
				</g:tab>
31
				<g:tab>
32
					<g:header>Files Search</g:header>
33
					<g:ScrollPanel>
34
					<adminui:FilesPanel></adminui:FilesPanel>
35
					</g:ScrollPanel>
36

  
37
				</g:tab>
38
				<g:tab>
39
					<g:header>User Classes</g:header>
40
					<g:ScrollPanel>
41
					<adminui:UserClassListPanel></adminui:UserClassListPanel>
42
					</g:ScrollPanel>
43

  
44
				</g:tab>
45
				
46
				<g:tab>
47
					<g:header>Operations</g:header>
48
					<g:ScrollPanel>
49
					<adminui:OperationsPanel></adminui:OperationsPanel>
50
					</g:ScrollPanel>
51

  
52
				</g:tab>
53

  
54

  
55
			</g:TabLayoutPanel>
56

  
57
		</g:center>
58
	</g:DockLayoutPanel>
59

  
60

  
61

  
62
</ui:UiBinder> 
/dev/null
1
/*
2
 * Copyright 2009 Electronic Business Systems Ltd.
3
 *
4
 * This file is part of GSS.
5
 *
6
 * GSS is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * GSS is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with GSS.  If not, see <http://www.gnu.org/licenses/>.
18
 */
19
package gr.ebs.gss.admin.client.ui;
20

  
21
import com.google.gwt.dom.client.NativeEvent;
22
import com.google.gwt.event.dom.client.ClickEvent;
23
import com.google.gwt.event.dom.client.ClickHandler;
24
import com.google.gwt.event.dom.client.KeyCodes;
25
import com.google.gwt.user.client.Event.NativePreviewEvent;
26
import com.google.gwt.user.client.ui.Button;
27
import com.google.gwt.user.client.ui.DialogBox;
28
import com.google.gwt.user.client.ui.HTML;
29
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
30
import com.google.gwt.user.client.ui.HorizontalPanel;
31
import com.google.gwt.user.client.ui.VerticalPanel;
32

  
33

  
34
/**
35
 * A dialog for requesting confirmation from the user.
36
 *
37
 * @author kman
38
 */
39
public abstract class ConfirmationDialog extends DialogBox {
40

  
41
	/**
42
	 * The widget's constructor.
43
	 *
44
	 * @param message the message to display
45
	 * @param buttonLabel the label of the confirmation button
46
	 */
47
	public ConfirmationDialog(String message, String buttonLabel) {
48
		// Set the dialog's caption.
49
		setText("Confirmation");
50
		setAnimationEnabled(true);
51
		// Create a VerticalPanel to contain the label and the buttons.
52
		VerticalPanel outer = new VerticalPanel();
53
		HorizontalPanel buttons = new HorizontalPanel();
54

  
55
		HTML text = new HTML("<table><tr><td rowspan='2'>" +
56
					//AbstractImagePrototype.create(MessagePanel.images.warn()).getHTML() +
57

  
58
					"</td><td>" + message + "</td></tr></table>");
59
		text.setStyleName("gss-warnMessage");
60
		outer.add(text);
61

  
62
		// Create the 'Update' button, along with a listener that hides the dialog
63
		// when the button is clicked and renames the file.
64
		Button ok = new Button(buttonLabel, new ClickHandler() {
65

  
66
			@Override
67
			public void onClick(ClickEvent event) {
68
				confirm();
69
				hide();
70
			}
71
		});
72
		buttons.add(ok);
73
		buttons.setCellHorizontalAlignment(ok, HasHorizontalAlignment.ALIGN_CENTER);
74
		// Create the 'Cancel' button, along with a listener that hides the
75
		// dialog when the button is clicked.
76
		Button cancel = new Button("Cancel", new ClickHandler() {
77

  
78
			@Override
79
			public void onClick(ClickEvent event) {
80
				hide();
81
				cancel();
82
			}
83
		});
84
		buttons.add(cancel);
85
		buttons.setCellHorizontalAlignment(cancel, HasHorizontalAlignment.ALIGN_CENTER);
86
		buttons.setSpacing(8);
87
		buttons.setStyleName("gss-warnMessage");
88
		outer.setStyleName("gss-warnMessage");
89
		outer.add(buttons);
90
		outer.setCellHorizontalAlignment(text, HasHorizontalAlignment.ALIGN_CENTER);
91
		outer.setCellHorizontalAlignment(buttons, HasHorizontalAlignment.ALIGN_CENTER);
92
		setWidget(outer);
93
	}
94

  
95
	@Override
96
	protected void onPreviewNativeEvent(NativePreviewEvent preview) {
97
		super.onPreviewNativeEvent(preview);
98
		NativeEvent evt = preview.getNativeEvent();
99
		if (evt.getType().equals("keydown"))
100
			// Use the popup's key preview hooks to close the dialog when either
101
			// enter or escape is pressed.
102
			switch (evt.getKeyCode()) {
103
				case KeyCodes.KEY_ENTER:
104
					hide();
105
					confirm();
106
					break;
107
				case KeyCodes.KEY_ESCAPE:
108
					hide();
109
					cancel();
110
					break;
111
			}
112
	}
113

  
114
	public abstract void confirm();
115

  
116
	public abstract void cancel();
117
}
/dev/null
1
package gr.ebs.gss.admin.client.ui;
2

  
3
import gr.ebs.gss.admin.client.TwoAdmin;
4
import gr.ebs.gss.server.domain.dto.FileBodyDTO;
5
import gr.ebs.gss.server.domain.dto.FileHeaderDTO;
6
import gr.ebs.gss.server.domain.dto.PermissionDTO;
7

  
8
import java.util.ArrayList;
9
import java.util.HashSet;
10
import java.util.List;
11

  
12
import com.google.gwt.core.client.GWT;
13
import com.google.gwt.event.dom.client.ClickEvent;
14
import com.google.gwt.event.dom.client.ClickHandler;
15
import com.google.gwt.event.dom.client.KeyPressEvent;
16
import com.google.gwt.event.dom.client.KeyPressHandler;
17
import com.google.gwt.gen2.table.event.client.RowSelectionEvent;
18
import com.google.gwt.gen2.table.event.client.RowSelectionHandler;
19
import com.google.gwt.uibinder.client.UiBinder;
20
import com.google.gwt.uibinder.client.UiField;
21
import com.google.gwt.uibinder.client.UiHandler;
22
import com.google.gwt.user.client.Command;
23
import com.google.gwt.user.client.DeferredCommand;
24
import com.google.gwt.user.client.rpc.AsyncCallback;
25
import com.google.gwt.user.client.ui.Button;
26
import com.google.gwt.user.client.ui.Composite;
27
import com.google.gwt.user.client.ui.Grid;
28
import com.google.gwt.user.client.ui.HTML;
29
import com.google.gwt.user.client.ui.TextBox;
30
import com.google.gwt.user.client.ui.Widget;
31

  
32
public class FilesPanel extends Composite {
33

  
34
	private static UserPanelUiBinder uiBinder = GWT
35
			.create(UserPanelUiBinder.class);
36

  
37
	interface UserPanelUiBinder extends UiBinder<Widget, FilesPanel> {
38
	}
39

  
40

  
41

  
42
	@UiField TextBox searchBox;
43
	@UiField Button searchButton;
44
	@UiField(provided=true) final FilesTable filesTable = new FilesTable();
45
	@UiField(provided=true) Grid g =new Grid(9,6);
46
	@UiField(provided=true) PermissionsList permissionsGrid = new PermissionsList(new HashSet<PermissionDTO>(),"",true);
47
	@UiField(provided=true) VersionsList versionsList = new VersionsList(new ArrayList<FileBodyDTO>());
48
	private Object lastQuery;
49

  
50
	public FilesPanel() {
51
		g.setCellPadding(5);
52
		g.setCellSpacing(5);
53

  
54
		initWidget(uiBinder.createAndBindUi(this));
55
		searchBox.addKeyPressHandler(new KeyPressHandler() {
56

  
57
			@Override
58
			public void onKeyPress(KeyPressEvent event) {
59
				char keyCode = event.getCharCode();
60
				if (keyCode == '\r')
61
					handleClick(null);
62
			}
63
		});
64
		filesTable.addRowSelectionHandler(new RowSelectionHandler() {
65

  
66
			@Override
67
			public void onRowSelection(RowSelectionEvent event) {
68
				final FileHeaderDTO user = filesTable.getSelectedRowObject(event);
69

  
70
				TwoAdmin.get().showLoadingBox();
71
				if(user!=null)
72
					DeferredCommand.addCommand(new Command() {
73

  
74
						@Override
75
						public void execute() {
76
							TwoAdmin.get().showLoadingBox();
77
							TwoAdmin.get().getAdminService().getFile(user.getId(), new AsyncCallback<FileHeaderDTO>() {
78

  
79
								@Override
80
								public void onSuccess(final FileHeaderDTO result) {
81
									TwoAdmin.get().getAdminService().getVersions(result.getOwner().getId(), result.getId(), new AsyncCallback<List<FileBodyDTO>>() {
82

  
83
										@Override
84
										public void onFailure(Throwable caught) {
85
											GWT.log("Error requesting  file details", caught);
86
											TwoAdmin.get().hideLoadingBox();
87
											TwoAdmin.get().showErrorBox("Error requesting file details");
88

  
89
										}
90

  
91
										@Override
92
										public void onSuccess(List<FileBodyDTO> versions) {
93
											clearFileDetails();
94
											displayFileDetails(result, versions);
95
											TwoAdmin.get().hideLoadingBox();
96

  
97

  
98
										}
99

  
100
									});
101

  
102
								}
103

  
104
								@Override
105
								public void onFailure(Throwable caught) {
106
									GWT.log("Error requesting user statistics file", caught);
107
									TwoAdmin.get().hideLoadingBox();
108
									TwoAdmin.get().showErrorBox("Error requesting user statistics");
109

  
110
								}
111
							});
112

  
113
						}
114
					});
115

  
116
			}
117
		});
118

  
119

  
120
		clearFileDetails();
121

  
122
	}
123

  
124
	@UiHandler("searchButton")
125
	void handleClick(@SuppressWarnings("unused") ClickEvent e){
126
		final String toSearch = searchBox.getText();
127
		if(toSearch == null || "".equals(toSearch.trim())){
128
			TwoAdmin.get().showErrorBox("You must enter a query");
129
			return;
130
		}
131
		lastQuery = toSearch;
132
		populateTable(toSearch);
133
	}
134

  
135

  
136

  
137
	public void populateTable(String query){
138
		TwoAdmin.get().showLoadingBox();
139
		TwoAdmin.get().getAdminService().searchFiles(query,new AsyncCallback<List<FileHeaderDTO>>() {
140

  
141
			@Override
142
			public void onFailure(Throwable caught) {
143
				TwoAdmin.get().hideLoadingBox();
144
				GWT.log("Error fetching files", caught);
145
				TwoAdmin.get().showErrorBox("Unable to Find any Files");
146
			}
147

  
148
			@Override
149
			public void onSuccess(List<FileHeaderDTO> result) {
150
				filesTable.showUsers(result);
151
				clearFileDetails();
152
				TwoAdmin.get().hideLoadingBox();
153

  
154
			}
155

  
156
		});
157
	}
158

  
159

  
160

  
161

  
162
	public void displayFileDetails(final FileHeaderDTO file, List<FileBodyDTO> versions){
163
		clearFileDetails();
164
		versionsList.updateTable(versions);
165
		g.setHTML(0, 0, "<span>"  + "Name:");
166
		g.setHTML(0, 1, file.getName()+"</span>");
167
		g.setHTML(1, 0, "<span>"  + "URI:");
168
		g.setHTML(1, 1, file.getURI()+"</span>");
169
		g.setHTML(2, 0, "<span>"  + "Owner:");
170
		HTML userLabel =new HTML("<a href='#'>"+file.getOwner().getUsername()+"</a></span>");
171
		g.setWidget(2, 1, userLabel );
172

  
173
		userLabel.addClickHandler(new ClickHandler() {
174

  
175
			@Override
176
			public void onClick(ClickEvent event) {
177
				TwoAdmin.get().searchUsers("username:"+file.getOwner().getUsername());
178

  
179
			}
180
		});
181
		g.setHTML(3, 0, "<span>"  + "Size:");
182
		g.setHTML(3, 1, file.getFileSizeAsString()+"</span>");
183
		g.setHTML(4, 0, "<span>"  + "Content Type:");
184
		g.setHTML(4, 1, file.getMimeType()+"</span>");
185

  
186
		g.setHTML(5, 0, "<span>"  + "Creation Date:");
187
		g.setHTML(5, 1, file.getAuditInfo().getCreationDate()+"</span>");
188

  
189
		g.setHTML(6, 0, "<span>"  + "Modification Date:");
190
		g.setHTML(6, 1, file.getAuditInfo().getModificationDate()+"</span>");
191
		if(file.isVersioned())
192
			g.setHTML(7, 0, "<span>"  + "File is Versioned:</span>");
193
		else
194
			g.setHTML(7, 0, "<span>"  + "File is NOT Versioned:</span>");
195
		if(file.isReadForAll()){
196
			g.setHTML(8, 0, "<span>"  + "Read For All:");
197
			g.setHTML(8, 1, file.getURI()+"</span>");
198
		}
199
		permissionsGrid.update(file.getPermissions(), file.getURI());
200
	}
201

  
202
	public void clearFileDetails(){
203
		g.setHTML(0, 0, "<span>"  + "Name:");
204
		g.setHTML(0, 1, ""+"</span>");
205
		g.setHTML(1, 0, "<span>"  + "URI:");
206
		g.setHTML(1, 1, ""+"</span>");
207
		g.setHTML(2, 0, "<span>"  + "Owner:");
208
		g.setHTML(2, 1, ""+"</span>");
209
		g.setHTML(3, 0, "<span>"  + "Size:");
210
		g.setHTML(3, 1, ""+"</span>");
211
		g.setHTML(4, 0, "<span>"  + "Content Type:");
212
		g.setHTML(4, 1, ""+"</span>");
213
		g.setHTML(5, 0, "<span>"  + "Creation Date:");
214
		g.setHTML(5, 1, "</span>");
215

  
216
		g.setHTML(6, 0, "<span>"  + "Modification Date:");
217
		g.setHTML(6, 1, "</span>");
218
		g.setHTML(7, 0, "<span>"  + "File is Versioned:</span>");
219
		g.setHTML(8, 0, "<span>"  + "Read For All:");
220
		g.setHTML(8, 1, "</span>");
221
		permissionsGrid.clear();
222
		versionsList.updateTable(new ArrayList<FileBodyDTO>());
223

  
224

  
225
	}
226

  
227

  
228
	/**
229
	 * Retrieve the lastQuery.
230
	 *
231
	 * @return the lastQuery
232
	 */
233
	public Object getLastQuery() {
234
		return lastQuery;
235
	}
236
}
/dev/null
1
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
2
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
3
	xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:adminui='urn:import:gr.ebs.gss.admin.client.ui' 
4
	 xmlns:dp="urn:import:com.google.gwt.user.datepicker.client"
5
	>
6
	<ui:style>
7
		
8
	</ui:style>
9
	
10
	<g:VerticalPanel addStyleNames="Gmnuri3D" width="100%">
11
		<g:HTMLPanel>
12
			<div>
13
				<h3>Files Search</h3>
14
			</div>
15
		</g:HTMLPanel>
16
		<g:HorizontalPanel spacing="3">
17
			<g:cell horizontalAlignment="ALIGN_CENTER" verticalAlignment="ALIGN_MIDDLE">
18
				<g:HTML>Search Files:</g:HTML>
19
			</g:cell>
20
			<g:cell horizontalAlignment="ALIGN_CENTER" verticalAlignment="ALIGN_MIDDLE">
21
				<g:TextBox ui:field="searchBox"  visibleLength="50"></g:TextBox>
22
			</g:cell>
23
			<g:cell horizontalAlignment="ALIGN_CENTER" verticalAlignment="ALIGN_MIDDLE">
24
				<g:Button ui:field="searchButton">Search</g:Button>
25
			</g:cell>
26
			
27
		</g:HorizontalPanel>
28

  
29
		<adminui:FilesTable ui:field="filesTable">
30
		</adminui:FilesTable>
31

  
32
		<g:VerticalPanel width="100%" addStyleNames="Gmnuri3D">
33
			<g:HTMLPanel>
34
				<div>
35
					<h3>File Details</h3>
36
				</div>
37
			</g:HTMLPanel>
38
			<g:HorizontalPanel>
39

  
40
				<g:Grid ui:field="g" width="400px"></g:Grid>
41
				<adminui:PermissionsList ui:field="permissionsGrid"
42
					width="300px"></adminui:PermissionsList>
43
					<adminui:VersionsList ui:field="versionsList"></adminui:VersionsList>
44
			</g:HorizontalPanel>
45
			
46
		</g:VerticalPanel>
47
	</g:VerticalPanel>
48

  
49
</ui:UiBinder> 
/dev/null
1
/*
2
 * Copyright 2010 Electronic Business Systems Ltd.
3
 *
4
 * This file is part of GSS.
5
 *
6
 * GSS is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * GSS is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with GSS.  If not, see <http://www.gnu.org/licenses/>.
18
 */
19
package gr.ebs.gss.admin.client.ui;
20

  
21
import gr.ebs.gss.admin.client.ui.FilesTable.FileSorter.FileComparator;
22
import gr.ebs.gss.server.domain.dto.FileHeaderDTO;
23

  
24
import java.util.ArrayList;
25
import java.util.Collections;
26
import java.util.Comparator;
27
import java.util.Date;
28
import java.util.HashMap;
29
import java.util.Iterator;
30
import java.util.LinkedHashMap;
31
import java.util.LinkedList;
32
import java.util.List;
33
import java.util.Map;
34
import java.util.Set;
35

  
36
import com.google.gwt.core.client.GWT;
37
import com.google.gwt.gen2.table.client.AbstractColumnDefinition;
38
import com.google.gwt.gen2.table.client.AbstractScrollTable.ScrollPolicy;
39
import com.google.gwt.gen2.table.client.AbstractScrollTable.SortPolicy;
40
import com.google.gwt.gen2.table.client.CachedTableModel;
41
import com.google.gwt.gen2.table.client.CellRenderer;
42
import com.google.gwt.gen2.table.client.ColumnDefinition;
43
import com.google.gwt.gen2.table.client.DefaultRowRenderer;
44
import com.google.gwt.gen2.table.client.DefaultTableDefinition;
45
import com.google.gwt.gen2.table.client.FixedWidthGridBulkRenderer;
46
import com.google.gwt.gen2.table.client.MutableTableModel;
47
import com.google.gwt.gen2.table.client.PagingOptions;
48
import com.google.gwt.gen2.table.client.PagingScrollTable;
49
import com.google.gwt.gen2.table.client.ScrollTable;
50
import com.google.gwt.gen2.table.client.SelectionGrid.SelectionPolicy;
51
import com.google.gwt.gen2.table.client.TableDefinition;
52
import com.google.gwt.gen2.table.client.TableDefinition.AbstractCellView;
53
import com.google.gwt.gen2.table.client.TableModel;
54
import com.google.gwt.gen2.table.client.TableModelHelper.Request;
55
import com.google.gwt.gen2.table.client.TableModelHelper.Response;
56
import com.google.gwt.gen2.table.event.client.RowSelectionEvent;
57
import com.google.gwt.gen2.table.event.client.RowSelectionHandler;
58
import com.google.gwt.gen2.table.event.client.TableEvent.Row;
59
import com.google.gwt.i18n.client.DateTimeFormat;
60
import com.google.gwt.user.client.ui.CheckBox;
61
import com.google.gwt.user.client.ui.Composite;
62
import com.google.gwt.user.client.ui.FlexTable;
63
import com.google.gwt.user.client.ui.HTML;
64
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
65
import com.google.gwt.user.client.ui.Label;
66
import com.google.gwt.user.client.ui.VerticalPanel;
67

  
68

  
69
/**
70
 * @author kman
71
 *
72
 */
73
public class FilesTable extends Composite {
74
	private CachedTableModel<FileHeaderDTO> cachedTableModel = null;
75
	private DefaultTableDefinition<FileHeaderDTO> tableDefinition = null;
76
	private PagingScrollTable<FileHeaderDTO> pagingScrollTable = null;
77
	private Label countLabel = new Label("There are no files to display.");
78
	private DataSourceTableModel tableModel = null;
79

  
80
	private VerticalPanel vPanel = new VerticalPanel();
81
	private FlexTable flexTable = new FlexTable();
82

  
83
	/**
84
	 * Constructor
85
	 */
86
	public FilesTable() {
87
		super();
88
		pagingScrollTable = createScrollTable();
89
		pagingScrollTable.setHeight("200px");
90
		pagingScrollTable.setScrollPolicy(ScrollPolicy.DISABLED);
91
		PagingOptions pagingOptions = new PagingOptions(pagingScrollTable);
92

  
93
		flexTable.setWidget(0, 0, pagingScrollTable);
94
		flexTable.getFlexCellFormatter().setColSpan(0, 0, 2);
95
		flexTable.setWidget(1, 0, pagingOptions);
96

  
97
		countLabel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
98
		vPanel.add(countLabel);
99
		vPanel.add(flexTable);
100

  
101
		vPanel.setWidth("100%");
102
		flexTable.setWidth("100%");
103

  
104
		super.initWidget(vPanel);
105
		showUsers(new ArrayList<FileHeaderDTO>());
106
		pagingScrollTable.setFooterGenerated(true);
107
	}
108

  
109
	public void showUsers(List<FileHeaderDTO> newList) {
110
		countLabel.setText("There are "+ newList.size() + " files.");
111
		tableModel.setData(newList);
112
		tableModel.setRowCount(newList.size());
113
		cachedTableModel.clearCache();
114
		cachedTableModel.setRowCount(newList.size());
115

  
116
		pagingScrollTable.gotoPage(0, true);
117
		if(newList.size()<2)
118
			flexTable.setWidget(1, 0, new HTML());
119
		else{
120
			PagingOptions pagingOptions = new PagingOptions(pagingScrollTable);
121
			flexTable.setWidget(1, 0, pagingOptions);
122
		}
123
	}
124

  
125
	public FileHeaderDTO getUserOnRow(int rowIdx){
126
		String id = pagingScrollTable.getDataTable().getHTML(rowIdx, 0);
127
		final FileHeaderDTO m = tableModel.getUserById(Long.parseLong(id));
128
		return m;
129
	}
130

  
131

  
132
	public FileHeaderDTO getSelectedRowObject(RowSelectionEvent event){
133
		Set<Row> set = event.getSelectedRows();
134
		if(set.size() == 1) {
135
			int rowIdx = set.iterator().next().getRowIndex();
136
			String id = pagingScrollTable.getDataTable().getHTML(rowIdx, 0);
137
			FileHeaderDTO m = tableModel.getUserById(Long.parseLong(id));
138
			return m;
139
		}
140
		return null;
141
	}
142

  
143
	public FileHeaderDTO getUser(Long id){
144

  
145
		return tableModel.getUserById(id);
146
	}
147

  
148

  
149

  
150
	/**
151
	 * Initializes the scroll table
152
	 * @return
153
	 */
154
	private PagingScrollTable<FileHeaderDTO> createScrollTable() {
155
		// create our own table model
156
		tableModel = new DataSourceTableModel();
157
		// add it to cached table model
158
		cachedTableModel = createCachedTableModel(tableModel);
159

  
160
		// create the table definition
161
		TableDefinition<FileHeaderDTO> tableDef = createTableDefinition();
162

  
163
		// create the paging scroll table
164
		pagingScrollTable = new PagingScrollTable<FileHeaderDTO>(cachedTableModel, tableDef);
165
		pagingScrollTable.setPageSize(10);
166
		pagingScrollTable.setEmptyTableWidget(new HTML("There is no data to display"));
167
		pagingScrollTable.getDataTable().setSelectionPolicy(SelectionPolicy.ONE_ROW);
168

  
169
		FixedWidthGridBulkRenderer<FileHeaderDTO> bulkRenderer = new FixedWidthGridBulkRenderer<FileHeaderDTO>(pagingScrollTable.getDataTable(), pagingScrollTable);
170
		pagingScrollTable.setBulkRenderer(bulkRenderer);
171

  
172

  
173
		pagingScrollTable.setCellPadding(3);
174
		pagingScrollTable.setCellSpacing(0);
175
		pagingScrollTable.setResizePolicy(ScrollTable.ResizePolicy.FILL_WIDTH);
176

  
177
		pagingScrollTable.setSortPolicy(SortPolicy.SINGLE_CELL);
178

  
179
		return pagingScrollTable;
180
	}
181

  
182
	public void addRowSelectionHandler(RowSelectionHandler handler){
183
		pagingScrollTable.getDataTable().addRowSelectionHandler(handler);
184
	}
185

  
186
	/**
187
	 * Create the {@link CachedTableModel}
188
	 * @param aTableModel
189
	 * @return
190
	 */
191
	private CachedTableModel<FileHeaderDTO> createCachedTableModel(DataSourceTableModel aTableModel) {
192
		CachedTableModel<FileHeaderDTO> tm = new CachedTableModel<FileHeaderDTO>(aTableModel);
193
		tm.setPreCachedRowCount(20);
194
		tm.setPostCachedRowCount(20);
195
		tm.setRowCount(20);
196
		return tm;
197
	}
198

  
199
	private DefaultTableDefinition<FileHeaderDTO> createTableDefinition() {
200
		tableDefinition = new DefaultTableDefinition<FileHeaderDTO>();
201

  
202
		final String[] rowColors = new String[] { "#FFFFDD", "EEEEEE" };
203
		tableDefinition.setRowRenderer(new DefaultRowRenderer<FileHeaderDTO>(rowColors));
204

  
205
		// id
206
		{
207
			IdColumnDefinition columnDef = new IdColumnDefinition();
208
			columnDef.setColumnSortable(true);
209
			columnDef.setColumnTruncatable(false);
210
			columnDef.setPreferredColumnWidth(35);
211
			columnDef.setHeader(0, new HTML("Id"));
212
			columnDef.setHeaderCount(1);
213
			columnDef.setHeaderTruncatable(false);
214
			tableDefinition.addColumnDefinition(columnDef);
215
		}
216
		{
217
			NameColumnDefinition columnDef = new NameColumnDefinition();
218
			columnDef.setColumnSortable(true);
219
			columnDef.setColumnTruncatable(true);
220
			columnDef.setHeader(0, new HTML("File Name"));
221
			columnDef.setHeaderCount(1);
222
			columnDef.setHeaderTruncatable(false);
223
			tableDefinition.addColumnDefinition(columnDef);
224
		}
225
		{
226
			UriColumnDefinition columnDef = new UriColumnDefinition();
227
			columnDef.setColumnSortable(true);
228
			columnDef.setColumnTruncatable(true);
229
			columnDef.setHeader(0, new HTML("URI"));
230
			columnDef.setHeaderCount(1);
231
			columnDef.setHeaderTruncatable(false);
232
			tableDefinition.addColumnDefinition(columnDef);
233
		}
234
		// username
235
		{
236
			UserColumnDefinition columnDef = new UserColumnDefinition();
237
			columnDef.setColumnSortable(true);
238
			columnDef.setColumnTruncatable(true);
239
			columnDef.setHeader(0, new HTML("Username"));
240
			columnDef.setHeaderCount(1);
241
			columnDef.setHeaderTruncatable(false);
242
			tableDefinition.addColumnDefinition(columnDef);
243
		}
244
		{
245
			FilesizeDefinition columnDef = new FilesizeDefinition();
246
			columnDef.setColumnSortable(true);
247
			columnDef.setColumnTruncatable(true);
248
			columnDef.setHeader(0, new HTML("File Size"));
249
			columnDef.setHeaderCount(1);
250
			columnDef.setHeaderTruncatable(false);
251
			tableDefinition.addColumnDefinition(columnDef);
252
		}
253
		{
254
			DeletedColumnDefinition columnDef = new DeletedColumnDefinition();
255
			columnDef.setColumnSortable(true);
256
			columnDef.setColumnTruncatable(true);
257
			columnDef.setHeader(0, new HTML("Deleted"));
258
			columnDef.setHeaderCount(1);
259
			columnDef.setHeaderTruncatable(false);
260
			columnDef.setCellRenderer(new CellRenderer<FileHeaderDTO, Boolean>() {
261

  
262
				@Override
263
				public void renderRowValue(FileHeaderDTO rowValue, ColumnDefinition<FileHeaderDTO, Boolean> aColumnDef, AbstractCellView<FileHeaderDTO> view) {
264
					CheckBox check = new CheckBox();
265
					check.setValue(aColumnDef.getCellValue(rowValue));
266
					check.setEnabled(false);
267
					view.setWidget(check);
268

  
269
				}
270
			});
271
			tableDefinition.addColumnDefinition(columnDef);
272
		}
273

  
274

  
275
		{
276
			CreationColumnDefinition columnDef = new CreationColumnDefinition();
277
			columnDef.setColumnSortable(true);
278
			columnDef.setColumnTruncatable(true);
279
			columnDef.setHeader(0, new HTML("Creation Date"));
280
			columnDef.setHeaderCount(1);
281
			columnDef.setHeaderTruncatable(false);
282
			tableDefinition.addColumnDefinition(columnDef);
283
		}
284

  
285
		{
286
			LastModifiedColumnDefinition columnDef = new LastModifiedColumnDefinition();
287
			columnDef.setColumnSortable(true);
288
			columnDef.setColumnTruncatable(true);
289
			columnDef.setHeader(0, new HTML("Modification Date"));
290
			columnDef.setHeaderCount(1);
291
			columnDef.setHeaderTruncatable(false);
292
			tableDefinition.addColumnDefinition(columnDef);
293
		}
294

  
295

  
296

  
297
		return tableDefinition;
298
	}
299

  
300

  
301
	private class DataSourceTableModel extends MutableTableModel<FileHeaderDTO> {
302
		private Map<Long, FileHeaderDTO> map;
303
		private FileSorter sorter = new FileSorter();
304
		public void setData(List<FileHeaderDTO> list) {
305
			// toss the list, index by id in a map.
306
			map = new HashMap<Long, FileHeaderDTO>(list.size());
307
			for(FileHeaderDTO m : list)
308
				map.put(m.getId(), m);
309
		}
310

  
311
		public FileHeaderDTO getUserById(long id) {
312
			return map.get(id);
313
		}
314

  
315
		@Override
316
		protected boolean onRowInserted(int beforeRow) {
317
			return true;
318
		}
319

  
320
		@Override
321
		protected boolean onRowRemoved(int row) {
322
			return true;
323
		}
324

  
325
		@Override
326
		protected boolean onSetRowValue(int row, FileHeaderDTO rowValue) {
327

  
328
			return true;
329
		}
330

  
331
		@Override
332
		public void requestRows(
333
				final Request request,
334
				TableModel.Callback<FileHeaderDTO> callback) {
335

  
336
			callback.onRowsReady(request, new Response<FileHeaderDTO>(){
337

  
338
				@Override
339
				public Iterator<FileHeaderDTO> getRowValues() {
340
					final int col = request.getColumnSortList().getPrimaryColumn();
341
					final boolean ascending = request.getColumnSortList().isPrimaryAscending();
342
					if(col < 0)
343
						map = sorter.sort(map, new FileComparator(ascending,0));
344
					else
345
						map = sorter.sort(map, new FileComparator(ascending,col));
346
					return map.values().iterator();
347
				}});
348
		}
349

  
350
	}
351

  
352

  
353
	private final class IdColumnDefinition extends AbstractColumnDefinition<FileHeaderDTO, Long> {
354
		@Override
355
		public Long getCellValue(FileHeaderDTO rowValue) {
356
			return rowValue.getId();
357
		}
358
		@Override
359
		public void setCellValue(FileHeaderDTO rowValue, Long cellValue) { }
360
	}
361

  
362

  
363
	private final class NameColumnDefinition extends
364
			AbstractColumnDefinition<FileHeaderDTO, String> {
365
		@Override
366
		public String getCellValue(final FileHeaderDTO rowValue) {
367
			return rowValue.getName();
368
		}
369

  
370
		@Override
371
		public void setCellValue(final FileHeaderDTO rowValue, final String cellValue) {}
372
	}
373

  
374

  
375
	private final class UriColumnDefinition extends
376
		AbstractColumnDefinition<FileHeaderDTO, String> {
377
		@Override
378
		public String getCellValue(final FileHeaderDTO rowValue) {
379
			return rowValue.getURI();
380
		}
381

  
382
		@Override
383
		public void setCellValue(final FileHeaderDTO rowValue, final String cellValue) {}
384
	}
385

  
386

  
387
	private final class FilesizeDefinition extends
388
			AbstractColumnDefinition<FileHeaderDTO, String> {
389
		@Override
390
		public String getCellValue(final FileHeaderDTO rowValue) {
391
			return rowValue.getFileSizeAsString();
392
		}
393

  
394
		@Override
395
		public void setCellValue(final FileHeaderDTO rowValue, final String cellValue) {}
396
	}
397

  
398

  
399
	private final class UserColumnDefinition extends
400
			AbstractColumnDefinition<FileHeaderDTO, String> {
401
		@Override
402
		public String getCellValue(final FileHeaderDTO rowValue) {
403
			return rowValue.getOwner().getUsername();
404
		}
405

  
406
		@Override
407
		public void setCellValue(final FileHeaderDTO rowValue, final String cellValue) {}
408
	}
409

  
410

  
411
	private final class DeletedColumnDefinition extends
412
			AbstractColumnDefinition<FileHeaderDTO, Boolean> {
413
		@Override
414
		public Boolean getCellValue(final FileHeaderDTO rowValue) {
415
			return rowValue.isDeleted();
416
		}
417

  
418
		@Override
419
		public void setCellValue(final FileHeaderDTO rowValue, final Boolean cellValue) {
420

  
421
		}
422
	}
423

  
424
	private final class CreationColumnDefinition extends AbstractColumnDefinition<FileHeaderDTO, String> {
425

  
426
		@Override
427
		public String getCellValue(final FileHeaderDTO rowValue) {
428
			return DateTimeFormat.getFormat("dd/MM/yyyy hh:mm:ss tt").format(rowValue.getAuditInfo().getCreationDate());
429
		}
430

  
431
		@Override
432
		public void setCellValue(final FileHeaderDTO rowValue, final String cellValue) {}
433
	}
434

  
435
	private final class LastModifiedColumnDefinition extends AbstractColumnDefinition<FileHeaderDTO, String> {
436

  
437
		@Override
438
		public String getCellValue(final FileHeaderDTO rowValue) {
439
			return DateTimeFormat.getFormat("dd/MM/yyyy hh:mm:ss tt").format(rowValue.getAuditInfo().getModificationDate());
440
		}
441

  
442
		@Override
443
		public void setCellValue(final FileHeaderDTO rowValue, final String cellValue) {}
444
	}
445

  
446

  
447

  
448
	public static class FileSorter {
449

  
450

  
451
		public Map<Long, FileHeaderDTO> sort(Map<Long, FileHeaderDTO> map, Comparator<FileHeaderDTO> comparator) {
452
			final List<FileHeaderDTO> list = new LinkedList<FileHeaderDTO>(map.values());
453
			Collections.sort(list, comparator);
454
			Map<Long, FileHeaderDTO> result = new LinkedHashMap<Long, FileHeaderDTO>(list.size());
455
			for(FileHeaderDTO p : list)
456
				result.put(p.getId(), p);
457
			return result;
458
		}
459

  
460
		public final static class FileComparator implements Comparator<FileHeaderDTO> {
461

  
462
			private final boolean ascending;
463
			private int property;
464
			public FileComparator(boolean isAscending, int aProperty) {
465
				ascending = isAscending;
466
				property = aProperty;
467
			}
468

  
469
			@Override
470
			public int compare(FileHeaderDTO m1, FileHeaderDTO m2) {
471
				GWT.log("sorting:"+property+" "+m1.getFileSize()+" "+m2.getFileSize());
472
				switch(property){
473
					case 0://id
474
						if(ascending)
475
							return m1.getId().compareTo(m2.getId());
476
						return m2.getId().compareTo(m1.getId());
477
					case 1://name
478
						if(ascending)
479
							return m1.getName().compareTo(m2.getName());
480
						return m2.getName().compareTo(m1.getName());
481
					case 2://uri
482
						if(ascending)
483
							return m1.getURI().compareTo(m2.getURI());
484
						return m2.getURI().compareTo(m1.getURI());
485
					case 3://file size
486
						if(ascending)
487
							return new Long(m1.getFileSize()).compareTo(new Long(m2.getFileSize()));
488
						return new Long(m2.getFileSize()).compareTo(new Long(m1.getFileSize()));
489
					case 4://deleted
490
						if(ascending)
491
							return new Boolean(m1.isDeleted()).compareTo(new Boolean(m2.isDeleted()));
492
						return new Boolean(m2.isDeleted()).compareTo(new Boolean(m1.isDeleted()));
493
					case 5://created
494
							return new DateComparator(ascending).compare(m1.getAuditInfo().getCreationDate(), m2.getAuditInfo().getCreationDate());
495
					case 6://modified
496
						return new DateComparator(ascending).compare(m1.getAuditInfo().getModificationDate(), m2.getAuditInfo().getModificationDate());
497
					default:
498
						if(ascending)
499
							return m1.getId().compareTo(m2.getId());
500
						return m2.getId().compareTo(m1.getId());
501
				}
502

  
503
			}
504
		}
505

  
506

  
507
		public final static class DateComparator implements Comparator<Date> {
508

  
509
			private final boolean ascending;
510

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff