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 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
| public class Application implements EntryPoint {
private static Application desktop;
public static Application getInstance() {
return desktop;
}
private Panel mainPanel;
private final CardLayout cardLayout = new CardLayout(true);
private Panel deckPanel;
private WelcomePanel welcomePanel;
private MonitoringPanel monitoringPanel;
private MessagesPanel messagesPanel;
private AuditApplicationPanel auditApplicationPanel;
private AuditUserPanel auditUserPanel;
private MonitoringServiceAsync moniService;
/**
* This is the entry point method.
*/
public void onModuleLoad() {
desktop = this;
moniService = (MonitoringServiceAsync) GWT.create(monpackage.MonitoringService.class);
ServiceDefTarget endpoint = (ServiceDefTarget) moniService;
endpoint.setServiceEntryPoint("services/monitoringService");
mainPanel = createMainPanel();
new Viewport(mainPanel);
}
/**
* Create the main panel.
* @return main panel
*/
private Panel createMainPanel() {
Panel panel = new Panel();
panel.setLayout(new FitLayout());
Panel borderPanel = new Panel();
borderPanel.setLayout(new BorderLayout());
Panel northPanel = new Panel();
northPanel.setBorder(false);
northPanel.setLayout(new ColumnLayout());
northPanel.setFrame(true);
northPanel.setHeight(80);
northPanel.setHtml("<h1><font size=\"4\">Administration Console</font></h1>");
BorderLayoutData northLayoutData = new BorderLayoutData(RegionPosition.NORTH);
northLayoutData.setMargins(new Margins(5, 5, 5, 5));
borderPanel.add(northPanel, northLayoutData);
BorderLayoutData westData = new BorderLayoutData(RegionPosition.WEST);
westData.setSplit(true);
westData.setMinSize(175);
westData.setMaxSize(400);
westData.setMargins(new Margins(0, 5, 0, 5));
borderPanel.add(createMenuPanel(), westData);
BorderLayoutData centerLayoutData = new BorderLayoutData(RegionPosition.CENTER);
centerLayoutData.setMargins(new Margins(0, 0, 5, 5));
deckPanel = new Panel();
deckPanel.setLayout(new FitLayout());
welcomePanel = new WelcomePanel();
welcomePanel.setLayout(new HorizontalLayout(10));
deckPanel.add(welcomePanel);
messagesPanel = new MessagesPanel();
//deckPanel.add(messagesPanel);
auditApplicationPanel = new AuditApplicationPanel();
//deckPanel.add(auditApplicationPanel);
auditUserPanel = new AuditUserPanel();
//deckPanel.add(auditUserPanel);
monitoringPanel = new MonitoringPanel();
//deckPanel.add(monitoringPanel);
//deckPanel.setActiveItem(0);
borderPanel.add(deckPanel, centerLayoutData);
panel.add(borderPanel);
return panel;
}
/**
* Create the menu panel.
* @return menu panel
*/
private Panel createMenuPanel() {
final Panel menuPanel = new Panel();
menuPanel.setWidth(200);
menuPanel.setCollapsible(true);
menuPanel.setTitle("Menu");
menuPanel.setBorder(true);
Panel subMenuPanel = new Panel();
subMenuPanel.setLayout(new VerticalLayout(5));
subMenuPanel.setMargins(5, 5, 0, 0);
Panel cmPanel = new Panel();
cmPanel.setCollapsible(true);
cmPanel.setTitle("Content management");
cmPanel.setId("cmPanelId");
cmPanel.setSize(190, 80);
cmPanel.setFrame(true);
Hyperlink labelsLink = new Hyperlink("Manage labels", "labels");
labelsLink.addClickListener(new ClickListener() {
public void onClick(Widget sender) {
//deckPanel.setActiveItem(1);
deckPanel.removeAll();
deckPanel.add(messagesPanel);
}
});
cmPanel.add(labelsLink);
subMenuPanel.add(cmPanel);
Panel auditPanel = new Panel();
auditPanel.setCollapsible(true);
auditPanel.setTitle("Audit");
auditPanel.setId("auditPanelId");
auditPanel.setSize(190, 80);
auditPanel.setFrame(true);
Hyperlink appliLogLink = new Hyperlink("Application log", "appliLog");
appliLogLink.addClickListener(new ClickListener() {
public void onClick(Widget sender) {
//deckPanel.setActiveItem(2);
deckPanel.removeAll();
deckPanel.add(auditApplicationPanel);
}
});
auditPanel.add(appliLogLink);
Hyperlink userLogLink = new Hyperlink("User log", "userLog");
userLogLink.addClickListener(new ClickListener() {
public void onClick(Widget sender) {
//deckPanel.setActiveItem(3);
deckPanel.removeAll();
deckPanel.add(auditUserPanel);
}
});
auditPanel.add(userLogLink);
subMenuPanel.add(auditPanel);
Panel moniPanel = new Panel();
moniPanel.setCollapsible(true);
moniPanel.setTitle("Monitoring");
moniPanel.setId("moniPanelId");
moniPanel.setSize(190, 80);
moniPanel.setFrame(true);
Hyperlink monDepLink = new Hyperlink("Monitor dependencies", "monDep");
monDepLink.addClickListener(new ClickListener() {
public void onClick(Widget sender) {
showMonitoringPanel();
}
});
moniPanel.add(monDepLink);
subMenuPanel.add(moniPanel);
menuPanel.add(subMenuPanel);
return menuPanel;
}
/**
* Show the monitoring panel.
*/
private void showMonitoringPanel() {
MessageBox.show(new MessageBoxConfig() {
{
setMsg("Retrieving status of modules...");
setProgressText("Getting...");
setWidth(300);
setWait(true);
setWaitConfig(new WaitConfig() {
{
setInterval(200);
}
});
}
});
final AsyncCallback callback = new AsyncCallback() {
public void onSuccess(Object result) {
Store currentStore = monitoringPanel.getGrid().getStore();
Record record = currentStore.getAt(0);
record.set("status", result.toString());
currentStore.commitChanges();
//deckPanel.setActiveItem(4);
deckPanel.removeAll();
deckPanel.add(monitoringPanel);
MessageBox.hide();
}
public void onFailure(Throwable ex) {
MessageBox.hide();
}
};
moniService.pingModule("Xxxx", callback);
}
} |
Partager