use of org.eclipse.kura.web.shared.model.GwtGroupedNVPair in project kura by eclipse.
the class GwtStatusServiceImpl method getPositionStatus.
private List<GwtGroupedNVPair> getPositionStatus() throws GwtKuraException {
List<GwtGroupedNVPair> pairs = new ArrayList<GwtGroupedNVPair>();
try {
PositionService positionService = ServiceLocator.getInstance().getService(PositionService.class);
if (positionService != null) {
pairs.add(new GwtGroupedNVPair("positionStatus", "Longitude", Double.toString(Math.toDegrees(positionService.getPosition().getLongitude().getValue()))));
pairs.add(new GwtGroupedNVPair("positionStatus", "Latitude", Double.toString(Math.toDegrees(positionService.getPosition().getLatitude().getValue()))));
pairs.add(new GwtGroupedNVPair("positionStatus", "Altitude", positionService.getPosition().getAltitude().toString()));
}
} catch (GwtKuraException e) {
s_logger.warn("Get position status failed", e);
throw e;
}
return pairs;
}
use of org.eclipse.kura.web.shared.model.GwtGroupedNVPair in project kura by eclipse.
the class ThreadGroupComparator method findThreads.
@SuppressWarnings("unchecked")
@Override
public ArrayList<GwtGroupedNVPair> findThreads(GwtXSRFToken xsrfToken) throws GwtKuraException {
checkXSRFToken(xsrfToken);
List<GwtGroupedNVPair> pairs = new ArrayList<GwtGroupedNVPair>();
// get root thread group
ThreadGroup rootGroup = Thread.currentThread().getThreadGroup();
while (rootGroup.getParent() != null) {
rootGroup = rootGroup.getParent();
}
// enumerate all other threads
int numGroups = rootGroup.activeGroupCount();
final ThreadGroup[] groups = new ThreadGroup[2 * numGroups];
numGroups = rootGroup.enumerate(groups);
Arrays.sort(groups, ThreadGroupComparator.getInstance());
for (ThreadGroup group : groups) {
if (group != null) {
StringBuilder sbGroup = new StringBuilder();
sbGroup.append("ThreadGroup ").append(group.getName()).append(" [").append("maxprio=").append(group.getMaxPriority());
sbGroup.append(", parent=");
if (group.getParent() != null) {
sbGroup.append(group.getParent().getName());
} else {
sbGroup.append('-');
}
sbGroup.append(", isDaemon=");
sbGroup.append(group.isDaemon());
sbGroup.append(", isDestroyed=");
sbGroup.append(group.isDestroyed());
sbGroup.append(']');
int numThreads = group.activeCount();
Thread[] threads = new Thread[numThreads * 2];
group.enumerate(threads, false);
Arrays.sort(threads, ThreadComparator.getInstance());
for (Thread thread : threads) {
if (thread != null) {
StringBuilder sbThreadName = new StringBuilder();
sbThreadName.append(thread.getId()).append('/').append(thread.getName());
StringBuilder sbThreadValue = new StringBuilder();
sbThreadValue.append("priority=");
sbThreadValue.append(thread.getPriority());
sbThreadValue.append(", alive=");
sbThreadValue.append(thread.isAlive());
sbThreadValue.append(", daemon=");
sbThreadValue.append(thread.isDaemon());
sbThreadValue.append(", interrupted=");
sbThreadValue.append(thread.isInterrupted());
sbThreadValue.append(", loader=");
sbThreadValue.append(thread.getContextClassLoader());
sbThreadValue.append(']');
pairs.add(new GwtGroupedNVPair(sbGroup.toString(), sbThreadName.toString(), sbThreadValue.toString()));
}
}
}
}
return new ArrayList<GwtGroupedNVPair>(pairs);
}
use of org.eclipse.kura.web.shared.model.GwtGroupedNVPair in project kura by eclipse.
the class ThreadGroupComparator method findSystemProperties.
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public ArrayList<GwtGroupedNVPair> findSystemProperties(GwtXSRFToken xsrfToken) throws GwtKuraException {
checkXSRFToken(xsrfToken);
List<GwtGroupedNVPair> pairs = new ArrayList<GwtGroupedNVPair>();
// kura properties
SystemService systemService = ServiceLocator.getInstance().getService(SystemService.class);
Properties kuraProps = systemService.getProperties();
SortedSet kuraKeys = new TreeSet(kuraProps.keySet());
for (Iterator ki = kuraKeys.iterator(); ki.hasNext(); ) {
Object key = ki.next();
pairs.add(new GwtGroupedNVPair("propsKura", key.toString(), kuraProps.get(key).toString()));
}
return new ArrayList<GwtGroupedNVPair>(pairs);
}
use of org.eclipse.kura.web.shared.model.GwtGroupedNVPair in project kura by eclipse.
the class StatusPanelUi method loadStatusData.
// fetch table data
public void loadStatusData() {
this.statusGridProvider.getList().clear();
EntryClassUi.showWaitModal();
this.gwtXSRFService.generateSecurityToken(new AsyncCallback<GwtXSRFToken>() {
@Override
public void onFailure(Throwable ex) {
EntryClassUi.hideWaitModal();
FailureHandler.handle(ex);
}
@Override
public void onSuccess(GwtXSRFToken token) {
StatusPanelUi.this.gwtStatusService.getDeviceConfig(token, StatusPanelUi.this.currentSession.isNetAdminAvailable(), new AsyncCallback<ArrayList<GwtGroupedNVPair>>() {
@Override
public void onFailure(Throwable caught) {
FailureHandler.handle(caught);
StatusPanelUi.this.statusGridProvider.flush();
EntryClassUi.hideWaitModal();
}
@Override
public void onSuccess(ArrayList<GwtGroupedNVPair> result) {
String title = "cloudStatus";
StatusPanelUi.this.statusGridProvider.getList().add(new GwtGroupedNVPair(" ", msgs.getString(title), " "));
StatusPanelUi.this.parent.updateConnectionStatusImage(false);
int connectionNameIndex = 0;
for (GwtGroupedNVPair resultPair : result) {
if ("Connection Name".equals(resultPair.getName()) && resultPair.getValue().endsWith("CloudService")) {
// done based on the idea that in the pairs data connection name is before connection
// status
GwtGroupedNVPair connectionStatus = result.get(connectionNameIndex + 1);
if ("Service Status".equals(connectionStatus.getName()) && "CONNECTED".equals(connectionStatus.getValue())) {
StatusPanelUi.this.parent.updateConnectionStatusImage(true);
} else {
StatusPanelUi.this.parent.updateConnectionStatusImage(false);
}
}
connectionNameIndex++;
if (!title.equals(resultPair.getGroup())) {
title = resultPair.getGroup();
StatusPanelUi.this.statusGridProvider.getList().add(new GwtGroupedNVPair(" ", msgs.getString(title), " "));
}
StatusPanelUi.this.statusGridProvider.getList().add(resultPair);
}
int size = StatusPanelUi.this.statusGridProvider.getList().size();
StatusPanelUi.this.statusGrid.setVisibleRange(0, size);
StatusPanelUi.this.statusGridProvider.flush();
EntryClassUi.hideWaitModal();
}
});
}
});
}
use of org.eclipse.kura.web.shared.model.GwtGroupedNVPair in project kura by eclipse.
the class StatusPanelUi method loadStatusTable.
// create table layout
public void loadStatusTable(CellTable<GwtGroupedNVPair> grid, ListDataProvider<GwtGroupedNVPair> dataProvider) {
TextColumn<GwtGroupedNVPair> col1 = new TextColumn<GwtGroupedNVPair>() {
@Override
public String getValue(GwtGroupedNVPair object) {
return String.valueOf(object.getName());
}
};
col1.setCellStyleNames("status-table-row");
grid.addColumn(col1);
Column<GwtGroupedNVPair, SafeHtml> col2 = new Column<GwtGroupedNVPair, SafeHtml>(new SafeHtmlCell()) {
@Override
public SafeHtml getValue(GwtGroupedNVPair object) {
return SafeHtmlUtils.fromTrustedString(String.valueOf(object.getValue()));
}
};
col2.setCellStyleNames("status-table-row");
grid.addColumn(col2);
dataProvider.addDataDisplay(grid);
}
Aggregations