public TopicMetrics(JMSMetricPresenter presenter) {
this.presenter = presenter;
}
Widget asWidget() {
final ToolStrip toolStrip = new ToolStrip();
toolStrip.addToolButtonRight(new ToolButton(Console.CONSTANTS.common_label_refresh(), new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
presenter.setSelectedTopic(getCurrentSelection());
}
}));
// ----
topicTable = new DefaultCellTable<JMSEndpoint>(5);
topicTable.setSelectionModel(new SingleSelectionModel<JMSEndpoint>());
dataProvider = new ListDataProvider<JMSEndpoint>();
dataProvider.addDataDisplay(topicTable);
com.google.gwt.user.cellview.client.Column<JMSEndpoint, String> nameColumn = new com.google.gwt.user.cellview.client.Column<JMSEndpoint, String>(new TextCell()) {
@Override
public String getValue(JMSEndpoint object) {
return object.getName();
}
};
com.google.gwt.user.cellview.client.Column<JMSEndpoint, String> protocolColumn = new com.google.gwt.user.cellview.client.Column<JMSEndpoint, String>(new TextCell()) {
@Override
public String getValue(JMSEndpoint object) {
return object.getJndiName();
}
};
topicTable.addColumn(nameColumn, "Name");
topicTable.addColumn(protocolColumn, "JNDI");
topicTable.getSelectionModel().addSelectionChangeHandler(new SelectionChangeEvent.Handler(){
@Override
public void onSelectionChange(SelectionChangeEvent event) {
JMSEndpoint topic = getCurrentSelection();
presenter.setSelectedTopic(topic);
}
});
topicTable.getElement().setAttribute("style", "margin-top:15px;margin-bottom:0px;");
// ----
NumberColumn inQueue = new NumberColumn("message-count", "Messages in Topic");
Column[] cols = new Column[] {
inQueue.setBaseline(true),
new NumberColumn("delivering-count","In Delivery").setComparisonColumn(inQueue),
};
String title = "In-Flight Messages";
final HelpSystem.AddressCallback addressCallback = new HelpSystem.AddressCallback() {
@Override
public ModelNode getAddress() {
ModelNode address = new ModelNode();
address.get(ModelDescriptionConstants.ADDRESS).set(RuntimeBaseAddress.get());
address.get(ModelDescriptionConstants.ADDRESS).add("subsystem", "messaging");
address.get(ModelDescriptionConstants.ADDRESS).add("hornetq-server", "default");
address.get(ModelDescriptionConstants.ADDRESS).add("jms-topic", "*");
return address;
}
};
inflightSampler = new PlainColumnView(title, addressCallback)
.setColumns(cols)
.setWidth(100, Style.Unit.PCT);
// ----
NumberColumn processedCol = new NumberColumn("messages-added", "Messages Added");
Column[] cols2 = new Column[] {
processedCol.setBaseline(true),
new NumberColumn("durable-message-count","Number Durable Messages").setComparisonColumn(processedCol),
new NumberColumn("non-durable-message-count","Number Non-Durable Messages").setComparisonColumn(processedCol)
};
String title2 = "Messages Processed";
processedSampler = new PlainColumnView(title2, addressCallback)
.setColumns(cols2)
.setWidth(100, Style.Unit.PCT);
// ----
NumberColumn subscriptionsCols = new NumberColumn("subscription-count", "Number of Subscriptions");
Column[] cols3 = new Column[] {
subscriptionsCols.setBaseline(true),
new NumberColumn("durable-subscription-count","Durable Subscribers").setComparisonColumn(subscriptionsCols),
new NumberColumn("non-durable-subscription-count","Nun-Durable Subscribers").setComparisonColumn(subscriptionsCols)
};
String title3 = "Subscriptions";
subscriptionSampler = new PlainColumnView(title3, addressCallback)
.setColumns(cols3)
.setWidth(100, Style.Unit.PCT);
// ----
DefaultPager pager = new DefaultPager();
pager.setDisplay(topicTable);
VerticalPanel tablePanel = new VerticalPanel();
tablePanel.setStyleName("fill-layout-width");
tablePanel.add(topicTable);
tablePanel.add(pager);
VerticalPanel messagePanel = new VerticalPanel();
messagePanel.setStyleName("fill-layout-width");
messagePanel.add(inflightSampler.asWidget());
messagePanel.add(processedSampler.asWidget());
OneToOneLayout layout = new OneToOneLayout()
.setTitle("Topics")
.setPlain(true)
.setTopLevelTools(toolStrip.asWidget())
.setHeadline("JMS Topic Metrics")
.setDescription(Console.CONSTANTS.subsys_messaging_topic_metric_desc())
.setMaster("Topic Selection", tablePanel)
.addDetail("Messages", messagePanel)
.addDetail("Subscriptions", subscriptionSampler.asWidget());