aboutsummaryrefslogtreecommitdiffstats
path: root/documentation/clientsidewidgets/clientsidewidgets-grid.asciidoc
blob: 379ca4074925abe757c93f89eda3ef9cdf5d855a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
---
title: Grid
order: 4
layout: page
---

[[clientsidewidgets.grid]]
= Grid

The [classname]#Grid# widget is the client-side counterpart for the server-side
[classname]#Grid# component described in
<<../components/components-grid#components.grid,"Grid">>.

The client-side API is almost identical to the server-side API, so its
documentation is currently omitted here and we refer you to the API
documentation. In the following, we go through some customization features of
[classname]#Grid#.

[[clientsidewidgets.grid.renderers]]
== Renderers

As described in
<<../components/components-grid#components.grid.renderer,"Column
Renderers">>, renderers draw the visual representation of data values on the
client-side. They implement [interfacename]#Renderer# interface and its
[methodname]#render()# method. The method gets a reference to the element of the
grid cell, as well as the data value to be rendered. An implementation needs to
modify the element as needed.

For example, [classname]#TextRenderer# is implemented simply as follows:

[source, java] 
----
public class TextRenderer implements Renderer<String> {
    @Override
    public void render(RendererCellReference cell,
                       String text) {
        cell.getElement().setInnerText(text);
    }
}
----

The server-side renderer API should extend [classname]#AbstractRenderer# or
[classname]#ClickableRenderer# with the data type accepted by the renderer. The
data type also must be given for the superclass constructor.

[source, java] 
----
public class TextRenderer extends AbstractRenderer<String> {
    public TextRenderer() {
        super(String.class);
    }
}
----

The client-side and server-side renderer need to be connected with a connector
extending from [classname]#AbstractRendererConnector#.

[source, java] 
----
@Connect(com.vaadin.ui.renderer.TextRenderer.class)
public class TextRendererConnector
       extends AbstractRendererConnector<String> {
    @Override
    public TextRenderer getRenderer() {
        return (TextRenderer) super.getRenderer();
    }
}
----

Renderers can have parameters, for which normal client-side communication of
extension parameters can be used. Please see the implementations of different
renderers for examples.
ort/44945/stable30'>backport/44945/stable30 Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_encryption/tests/proxy.php
blob: 5aa617e7472b00d5da4651e93ca61d75ded6463b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
/**
 * Copyright (c) 2012 Robin Appelman <icewind@owncloud.com>
 * This file is licensed under the Affero General Public License version 3 or
 * later.
 * See the COPYING-README file.
 */

class Test_CryptProxy extends UnitTestCase {
	private $oldConfig;
	private $oldKey;

	public function setUp() {
		$user=OC_User::getUser();

		$this->oldConfig=OCP\Config::getAppValue('files_encryption','enable_encryption', 'true');
		OCP\Config::setAppValue('files_encryption', 'enable_encryption', 'true');
		$this->oldKey=isset($_SESSION['enckey'])?$_SESSION['enckey']:null;


		//set testing key
		$_SESSION['enckey']=md5(time());

		//clear all proxies and hooks so we can do clean testing
		OC_FileProxy::clearProxies();
		OC_Hook::clear('OC_Filesystem');

		//enable only the encryption hook
		OC_FileProxy::register(new OC_FileProxy_Encryption());

		//set up temporary storage
		OC_Filesystem::clearMounts();
		OC_Filesystem::mount('OC_Filestorage_Temporary', array(), '/');

		OC_Filesystem::init('/'.$user.'/files');

		//set up the users home folder in the temp storage
		$rootView=new OC_FilesystemView('');
		$rootView->mkdir('/'.$user);
		$rootView->mkdir('/'.$user.'/files');
	}

	public function tearDown() {
		OCP\Config::setAppValue('files_encryption', 'enable_encryption', $this->oldConfig);
		if ( ! is_null($this->oldKey)) {
			$_SESSION['enckey']=$this->oldKey;
		}
	}

	public function testSimple() {
		$file=OC::$SERVERROOT.'/3rdparty/MDB2.php';
		$original=file_get_contents($file);

		OC_Filesystem::file_put_contents('/file', $original);

		OC_FileProxy::$enabled=false;
		$stored=OC_Filesystem::file_get_contents('/file');
		OC_FileProxy::$enabled=true;

		$fromFile=OC_Filesystem::file_get_contents('/file');
		$this->assertNotEqual($original, $stored);
		$this->assertEqual(strlen($original), strlen($fromFile));
		$this->assertEqual($original, $fromFile);

	}

	public function testView() {
		$file=OC::$SERVERROOT.'/3rdparty/MDB2.php';
		$original=file_get_contents($file);

		$rootView=new OC_FilesystemView('');
		$view=new OC_FilesystemView('/'.OC_User::getUser());
		$userDir='/'.OC_User::getUser().'/files';

		$rootView->file_put_contents($userDir.'/file', $original);

		OC_FileProxy::$enabled=false;
		$stored=$rootView->file_get_contents($userDir.'/file');
		OC_FileProxy::$enabled=true;

		$this->assertNotEqual($original, $stored);
		$fromFile=$rootView->file_get_contents($userDir.'/file');
		$this->assertEqual($original, $fromFile);

		$fromFile=$view->file_get_contents('files/file');
		$this->assertEqual($original, $fromFile);
	}

	public function testBinary() {
		$file=__DIR__.'/binary';
		$original=file_get_contents($file);

		OC_Filesystem::file_put_contents('/file', $original);

		OC_FileProxy::$enabled=false;
		$stored=OC_Filesystem::file_get_contents('/file');
		OC_FileProxy::$enabled=true;

		$fromFile=OC_Filesystem::file_get_contents('/file');
		$this->assertNotEqual($original, $stored);
		$this->assertEqual(strlen($original), strlen($fromFile));
		$this->assertEqual($original, $fromFile);

		$file=__DIR__.'/zeros';
		$original=file_get_contents($file);

		OC_Filesystem::file_put_contents('/file', $original);

		OC_FileProxy::$enabled=false;
		$stored=OC_Filesystem::file_get_contents('/file');
		OC_FileProxy::$enabled=true;

		$fromFile=OC_Filesystem::file_get_contents('/file');
		$this->assertNotEqual($original, $stored);
		$this->assertEqual(strlen($original), strlen($fromFile));
	}
}