aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Dahlström <johannesd@vaadin.com>2014-03-04 15:48:32 +0200
committerMarc Englund <marc@vaadin.com>2014-04-03 05:53:38 +0000
commitbff6f60d6522a2f3b9730aec5d30c1f50c2e9fbb (patch)
tree1115bef780f34d02dff0acd14af061db2cc828dd
parenta2ac955596346d89c8cd857b06d434f489ba1f2b (diff)
downloadvaadin-framework-bff6f60d6522a2f3b9730aec5d30c1f50c2e9fbb.tar.gz
vaadin-framework-bff6f60d6522a2f3b9730aec5d30c1f50c2e9fbb.zip
Support font icons in ComboBox (#13376)
Change-Id: Idb35b8116c28824c8ced9b8f230e06ba8e7ecaaf
-rw-r--r--client/src/com/vaadin/client/ui/VFilterSelect.java71
1 files changed, 39 insertions, 32 deletions
diff --git a/client/src/com/vaadin/client/ui/VFilterSelect.java b/client/src/com/vaadin/client/ui/VFilterSelect.java
index b97eff0fbd..e0ced98394 100644
--- a/client/src/com/vaadin/client/ui/VFilterSelect.java
+++ b/client/src/com/vaadin/client/ui/VFilterSelect.java
@@ -54,11 +54,11 @@ import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTML;
-import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.PopupPanel.PositionCallback;
import com.google.gwt.user.client.ui.SuggestOracle.Suggestion;
import com.google.gwt.user.client.ui.TextBox;
+import com.google.gwt.user.client.ui.Widget;
import com.vaadin.client.ApplicationConnection;
import com.vaadin.client.BrowserInfo;
import com.vaadin.client.ComponentConnector;
@@ -122,10 +122,9 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
@Override
public String getDisplayString() {
final StringBuffer sb = new StringBuffer();
- if (iconUri != null) {
- sb.append("<img src=\"");
- sb.append(Util.escapeAttribute(iconUri));
- sb.append("\" alt=\"\" class=\"v-icon\" />");
+ final Icon icon = client.getIcon(iconUri);
+ if (icon != null) {
+ sb.append(icon.getElement().getString());
}
String content;
if ("".equals(caption)) {
@@ -990,7 +989,13 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
}
};
- private final Image selectedItemIcon = new Image();
+ private class IconWidget extends Widget {
+ IconWidget(Icon icon) {
+ setElement(icon.getElement());
+ }
+ }
+
+ private IconWidget selectedItemIcon;
/** For internal use only. May be removed or replaced in the future. */
public ApplicationConnection client;
@@ -1113,21 +1118,6 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
tb = createTextBox();
suggestionPopup = createSuggestionPopup();
- selectedItemIcon.setStyleName("v-icon");
- selectedItemIcon.addLoadHandler(new LoadHandler() {
-
- @Override
- public void onLoad(LoadEvent event) {
- if (BrowserInfo.get().isIE8()) {
- // IE8 needs some help to discover it should reposition the
- // text field
- forceReflow();
- }
- updateRootWidth();
- updateSelectedIconPosition();
- }
- });
-
popupOpener.sinkEvents(Event.ONMOUSEDOWN);
Roles.getButtonRole()
.setAriaHiddenState(popupOpener.getElement(), true);
@@ -1413,20 +1403,36 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
* The URI of the icon
*/
public void setSelectedItemIcon(String iconUri) {
+
if (iconUri == null || iconUri.length() == 0) {
- if (selectedItemIcon.isAttached()) {
+ if (selectedItemIcon != null) {
panel.remove(selectedItemIcon);
- if (BrowserInfo.get().isIE8()) {
- // IE8 needs some help to discover it should reposition the
- // text field
- forceReflow();
- }
- updateRootWidth();
+ selectedItemIcon = null;
+ afterSelectedItemIconChange();
}
} else {
+ if (selectedItemIcon != null) {
+ panel.remove(selectedItemIcon);
+ }
+ selectedItemIcon = new IconWidget(client.getIcon(iconUri));
+ selectedItemIcon.addDomHandler(new LoadHandler() {
+ @Override
+ public void onLoad(LoadEvent event) {
+ afterSelectedItemIconChange();
+ }
+ }, LoadEvent.getType());
panel.insert(selectedItemIcon, 0);
- selectedItemIcon.setUrl(iconUri);
- updateRootWidth();
+ afterSelectedItemIconChange();
+ }
+ }
+
+ private void afterSelectedItemIconChange() {
+ if (BrowserInfo.get().isWebkit() || BrowserInfo.get().isIE8()) {
+ // Some browsers need a nudge to reposition the text field
+ forceReflow();
+ }
+ updateRootWidth();
+ if (selectedItemIcon != null) {
updateSelectedIconPosition();
}
}
@@ -1951,8 +1957,9 @@ public class VFilterSelect extends Composite implements Field, KeyDownHandler,
* locked
*/
if (!tb.getElement().getStyle().getWidth().endsWith("px")) {
- tb.setWidth((tb.getOffsetWidth() - selectedItemIcon
- .getOffsetWidth()) + "px");
+ int iconWidth = selectedItemIcon == null ? 0 : selectedItemIcon
+ .getOffsetWidth();
+ tb.setWidth((tb.getOffsetWidth() - iconWidth) + "px");
}
}
}
e='backport/46114/stable30'>backport/46114/stable30 Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Diagnostics/QueryLogger.php
blob: 5efe99d1a747ba52de115c000ff36e3307f617f8 (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
<?php

/**
 * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
 * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
 * SPDX-License-Identifier: AGPL-3.0-only
 */
namespace OC\Diagnostics;

use OCP\Cache\CappedMemoryCache;
use OCP\Diagnostics\IQueryLogger;

class QueryLogger implements IQueryLogger {
	protected int $index = 0;
	protected ?Query $activeQuery = null;
	/** @var CappedMemoryCache<Query> */
	protected CappedMemoryCache $queries;

	/**
	 * QueryLogger constructor.
	 */
	public function __construct() {
		$this->queries = new CappedMemoryCache(1024);
	}


	/**
	 * @var bool - Module needs to be activated by some app
	 */
	private $activated = false;

	/**
	 * @inheritdoc
	 */
	public function startQuery($sql, ?array $params = null, ?array $types = null) {
		if ($this->activated) {
			$this->activeQuery = new Query($sql, $params, microtime(true), $this->getStack());
		}
	}

	private function getStack() {
		$stack = debug_backtrace();
		array_shift($stack);
		array_shift($stack);
		array_shift($stack);
		return $stack;
	}

	/**
	 * @inheritdoc
	 */
	public function stopQuery() {
		if ($this->activated && $this->activeQuery) {
			$this->activeQuery->end(microtime(true));
			$this->queries[(string)$this->index] = $this->activeQuery;
			$this->index++;
			$this->activeQuery = null;
		}
	}

	/**
	 * @inheritdoc
	 */
	public function getQueries() {
		return $this->queries->getData();
	}

	/**
	 * @inheritdoc
	 */
	public function activate() {
		$this->activated = true;
	}
}