1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package com.hack23.cia.web.impl.ui.application.views.admin.agentoperations.pagemode;
20
21 import java.util.Arrays;
22
23 import org.springframework.beans.factory.annotation.Autowired;
24 import org.springframework.security.access.annotation.Secured;
25 import org.springframework.stereotype.Component;
26
27 import com.hack23.cia.model.internal.application.data.impl.DataAgentOperation;
28 import com.hack23.cia.model.internal.application.data.impl.DataAgentTarget;
29 import com.hack23.cia.service.api.AgentContainer;
30 import com.hack23.cia.web.impl.ui.application.action.ViewAction;
31 import com.hack23.cia.web.impl.ui.application.views.common.labelfactory.LabelFactory;
32 import com.hack23.cia.web.impl.ui.application.views.common.sizing.ContentRatio;
33 import com.hack23.cia.web.impl.ui.application.views.common.viewnames.AdminViews;
34 import com.hack23.cia.web.impl.ui.application.views.pageclicklistener.StartAgentClickListener;
35 import com.vaadin.server.FontAwesome;
36 import com.vaadin.server.Sizeable.Unit;
37 import com.vaadin.ui.Button;
38 import com.vaadin.ui.ComboBox;
39 import com.vaadin.ui.Layout;
40 import com.vaadin.ui.MenuBar;
41 import com.vaadin.ui.Panel;
42 import com.vaadin.ui.VerticalLayout;
43
44
45
46
47 @Component
48 public final class AgentOperationsOverviewPageModContentFactoryImpl
49 extends AbstractAgentOperationsPageModContentFactoryImpl {
50
51
52 public static final String NAME = AdminViews.ADMIN_AGENT_OPERATIONVIEW_NAME;
53
54
55 private static final String OPERATION2 = "/Operation";
56
57
58 private static final String TARGET2 = "/Target";
59
60
61 private static final String START = "Start";
62
63
64 private static final String OPERATION = "Operation";
65
66
67 private static final String TARGET = "Target";
68
69
70 private static final String ADMIN_AGENT_OPERATION = "Admin Agent Operation";
71
72
73 @Autowired
74 private AgentContainer agentContainer;
75
76
77
78
79
80 public AgentOperationsOverviewPageModContentFactoryImpl() {
81 super();
82 }
83
84 @Override
85 public boolean matches(final String page, final String parameters) {
86 return NAME.equals(page);
87 }
88
89 @Secured({ "ROLE_ADMIN" })
90 @Override
91 public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
92 final VerticalLayout content = createPanelContent();
93
94 getMenuItemFactory().createMainPageMenuBar(menuBar);
95
96 LabelFactory.createHeader2Label(content,ADMIN_AGENT_OPERATION);
97
98 final ComboBox targetSelect = new ComboBox(TARGET, Arrays.asList(DataAgentTarget.values()));
99 targetSelect.setId(ViewAction.START_AGENT_BUTTON + TARGET2);
100 content.addComponent(targetSelect);
101 content.setExpandRatio(targetSelect, ContentRatio.SMALL2);
102
103 final ComboBox operationSelect = new ComboBox(OPERATION, Arrays.asList(DataAgentOperation.values()));
104 operationSelect.setId(ViewAction.START_AGENT_BUTTON + OPERATION2);
105 content.addComponent(operationSelect);
106 content.setExpandRatio(operationSelect, ContentRatio.SMALL2);
107
108 final Button startAgentButton = new Button(START,
109 new StartAgentClickListener(targetSelect, operationSelect, agentContainer));
110 startAgentButton.setId(ViewAction.START_AGENT_BUTTON.name());
111 startAgentButton.setIcon(FontAwesome.CROSSHAIRS);
112 content.addComponent(startAgentButton);
113 content.setExpandRatio(startAgentButton, ContentRatio.SMALL3);
114
115 content.setSizeFull();
116 content.setMargin(false);
117 content.setSpacing(true);
118
119 content.setWidth(100, Unit.PERCENTAGE);
120 content.setHeight(100, Unit.PERCENTAGE);
121
122 return content;
123 }
124
125 }