/
GroupToolbarGrid.java
61 lines (50 loc) · 2.18 KB
/
GroupToolbarGrid.java
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
/*******************************************************************************
* Copyright (c) 2017, 2020 Eurotech and/or its affiliates and others
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Eurotech - initial API and implementation
*******************************************************************************/
package org.eclipse.kapua.app.console.module.authorization.client.group;
import org.eclipse.kapua.app.console.module.api.client.ui.dialog.KapuaDialog;
import org.eclipse.kapua.app.console.module.api.client.ui.widget.EntityCRUDToolbar;
import org.eclipse.kapua.app.console.module.api.shared.model.session.GwtSession;
import org.eclipse.kapua.app.console.module.authorization.shared.model.GwtGroup;
import org.eclipse.kapua.app.console.module.authorization.shared.model.permission.GroupSessionPermission;
import com.google.gwt.user.client.Element;
public class GroupToolbarGrid extends EntityCRUDToolbar<GwtGroup> {
public GroupToolbarGrid(GwtSession currentSession) {
super(currentSession);
}
@Override
protected KapuaDialog getAddDialog() {
return new GroupAddDialog(currentSession);
}
@Override
protected void onRender(Element target, int index) {
super.onRender(target, index);
getAddEntityButton().setEnabled(currentSession.hasPermission(GroupSessionPermission.write()));
}
@Override
protected KapuaDialog getEditDialog() {
GwtGroup selectedGroup = gridSelectionModel.getSelectedItem();
GroupEditDialog dialog = null;
if (selectedGroup != null) {
dialog = new GroupEditDialog(currentSession, selectedGroup);
}
return dialog;
}
@Override
protected KapuaDialog getDeleteDialog() {
GwtGroup selectedGroup = gridSelectionModel.getSelectedItem();
GroupDeleteDialog dialog = null;
if (selectedGroup != null) {
dialog = new GroupDeleteDialog(selectedGroup);
}
return dialog;
}
}