vpanel.add(horzPanel);
// ----------------------------------------------------------------------
vpanel.add(new ContentGroupLabel("Server Instances"));
HorizontalPanel tableOptions = new HorizontalPanel();
tableOptions.getElement().setAttribute("cellpadding", "2px");
groupFilter = new ComboBox();
groupFilter.addValueChangeHandler(new ValueChangeHandler<String>() {
@Override
public void onValueChange(ValueChangeEvent<String> event) {
presenter.onFilterByGroup(event.getValue());
}
});
Widget typeFilterWidget = groupFilter.asWidget();
typeFilterWidget.getElement().setAttribute("width", "200px;");
tableOptions.add(new Label(Console.CONSTANTS.common_label_serverGroup()+":"));
tableOptions.add(typeFilterWidget);
tableOptions.getElement().setAttribute("style", "float:right;");
vpanel.add(tableOptions);
// ----------------------------------------------------------------------
instanceTable = new DefaultCellTable<ServerInstance>(10);
instanceProvider = new ListDataProvider<ServerInstance>();
instanceProvider.addDataDisplay(instanceTable);
// Create columns
Column<ServerInstance, String> nameColumn = new Column<ServerInstance, String>(new TextCell()) {
@Override
public String getValue(ServerInstance object) {
return object.getName();
}
};
Column<ServerInstance, String> groupColumn = new Column<ServerInstance, String>(new TextCell()) {
@Override
public String getValue(ServerInstance object) {
return object.getGroup();
}
};
Column<ServerInstance, ImageResource> statusColumn =
new Column<ServerInstance, ImageResource>(new ImageResourceCell()) {
@Override
public ImageResource getValue(ServerInstance instance) {
ImageResource res = null;
if(instance.isRunning())
res = Icons.INSTANCE.statusGreen_small();
else
res = Icons.INSTANCE.statusRed_small();
return res;
}
};
instanceTable.addColumn(nameColumn, Console.CONSTANTS.common_label_server());
instanceTable.addColumn(groupColumn, Console.CONSTANTS.common_label_serverGroup());
instanceTable.addColumn(statusColumn, Console.CONSTANTS.common_label_status());
vpanel.add(instanceTable);
// scroll enabled
ScrollPanel scroll = new ScrollPanel();
scroll.add(vpanel);
layout.add(scroll);
layout.setWidgetTopHeight(titleBar, 0, Style.Unit.PX, 28, Style.Unit.PX);
layout.setWidgetTopHeight(scroll, 28, Style.Unit.PX, 100, Style.Unit.PCT);
// ----------------------------------------------------------------------
VerticalPanel formPanel = new VerticalPanel();
formPanel.setStyleName("fill-layout-width");
final Form<ServerInstance> form = new Form<ServerInstance>(ServerInstance.class);
form.setNumColumns(2);
ToolStrip formTools = new ToolStrip();
formTools.addToolButton(new ToolButton("Start/Stop", new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
String state = form.getEditedEntity().isRunning() ? "stop" : "start";
Feedback.confirm(Console.CONSTANTS.common_label_serverStatus(), Console.MESSAGES.changeServerStatus(state, form.getEditedEntity().getName()),
new Feedback.ConfirmationHandler()
{
@Override
public void onConfirmation(boolean isConfirmed) {
if(isConfirmed)
{
ServerInstance instance = form.getEditedEntity();
presenter.startServer(instance.getServer(), !instance.isRunning());
}
}
});
}
}));
/* https://issues.jboss.org/browse/AS7-953
formTools.addToolButtonRight(new ToolButton("Reload", new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
Feedback.confirm("Reload server configuration",
"Do you want ot reload the server configuration for server "+form.getEditedEntity().getName()+"?",
new Feedback.ConfirmationHandler()
{
@Override
public void onConfirmation(boolean isConfirmed) {
if(isConfirmed)
{
ServerInstance instance = form.getEditedEntity();
presenter.reloadServer(instance.getServer());
}
}
});
}
}));
*/
formPanel.add(formTools);
// -----
TextItem nameItem = new TextItem("name", Console.CONSTANTS.common_label_serverInstance());
TextItem serverItem = new TextItem("server", Console.CONSTANTS.common_label_serverConfig());
StatusItem enableItem = new StatusItem("running", "Running?");
form.setFields(nameItem, serverItem, enableItem);
form.bind(instanceTable);
form.setEnabled(false);
Widget formWidget = form.asWidget();
//formWidget.getElement().setAttribute("style", "margin-top:15px;");
formPanel.add(formWidget);
// ----------------------------------------------------------
TabPanel bottomLayout = new TabPanel();
bottomLayout.addStyleName("default-tabpanel");
bottomLayout.getElement().setAttribute("style", "padding-top:20px");
bottomLayout.add(formPanel, "Availability");
// TODO: server VM metrics
//bottomLayout.add(new HTML("This going to display heap, permgen, etc, "), Console.CONSTANTS.common_label_virtualMachine());
bottomLayout.selectTab(0);
vpanel.add(new ContentGroupLabel("Status"));
vpanel.add(bottomLayout);
return layout;
}