}
@Override
public Widget createWidget() {
LayoutPanel layout = new LayoutPanel();
FakeTabPanel titleBar = new FakeTabPanel(Console.CONSTANTS.common_label_serverInstances());
layout.add(titleBar);
VerticalPanel vpanel = new VerticalPanel();
vpanel.setStyleName("rhs-content-panel");
// ----------------------------------------------------------------------
nameLabel = new ContentHeaderLabel(Console.CONSTANTS.common_label_runtimeStatus());
vpanel.add(nameLabel);
vpanel.add(new ContentDescription(Console.CONSTANTS.server_instances_desc()));
// -----------------
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;");
//TODO: Fixme vpanel.add(tableOptions);
// -----------------
instanceTable = new DefaultCellTable<ServerInstance>(8, new ProvidesKey<ServerInstance>() {
@Override
public Object getKey(ServerInstance item) {
return item.getName()+"_"+item.getGroup();
}
});
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, String> stateColumn =
new Column<ServerInstance, String>(new TextCell()) {
@Override
public String getValue(ServerInstance object) {
if(object.getFlag()!=null)
{
return object.getFlag().name();
}
else
{
return "";
}
}
};
Column<ServerInstance, ImageResource> statusColumn =
new Column<ServerInstance, ImageResource>(new ImageResourceCell()) {
@Override
public ImageResource getValue(ServerInstance instance) {
ImageResource res = null;
if(instance.isRunning() && instance.getFlag()==null)
res = Icons.INSTANCE.status_good();
else if(instance.isRunning() && instance.getFlag()!=null)
res = Icons.INSTANCE.status_warn();
else
res = Icons.INSTANCE.status_bad();
return res;
}
};
instanceTable.addColumn(nameColumn, Console.CONSTANTS.common_label_server());
instanceTable.addColumn(groupColumn, Console.CONSTANTS.common_label_serverGroup());
instanceTable.addColumn(stateColumn, Console.CONSTANTS.common_label_status());
instanceTable.addColumn(statusColumn, Console.CONSTANTS.common_label_active());
ToolStrip tableTools = new ToolStrip();
startBtn = new ToolButton("Start/Stop", new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
String state = form.getEditedEntity().isRunning() ? "Stop" : "Start";
Feedback.confirm(
state + " Server Instance",
Console.MESSAGES.modifyConfirm("Server Instance "+ form.getEditedEntity().getName()),
new Feedback.ConfirmationHandler() {
@Override
public void onConfirmation(boolean isConfirmed) {
if (isConfirmed) {
ServerInstance instance = form.getEditedEntity();
presenter.startServer(hostName, instance.getServer(), !instance.isRunning());
}
}
});
}
});
startBtn.ensureDebugId(Console.DEBUG_CONSTANTS.debug_label_start_serverInstancesView());
tableTools.addToolButtonRight(startBtn);
vpanel.add(tableTools.asWidget());
vpanel.add(instanceTable);
DefaultPager pager = new DefaultPager();
pager.setDisplay(instanceTable);
vpanel.add(pager);
// scroll enabled
ScrollPanel scroll = new ScrollPanel();
scroll.add(vpanel);
layout.add(scroll);
layout.setWidgetTopHeight(titleBar, 0, Style.Unit.PX, 40, Style.Unit.PX);
layout.setWidgetTopHeight(scroll, 40, Style.Unit.PX, 100, Style.Unit.PCT);
// ----------------------------------------------------------------------
VerticalPanel formPanel = new VerticalPanel();