Search in sources :

Example 1 with GwtGroupedNVPair

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;
}
Also used : GwtKuraException(org.eclipse.kura.web.shared.GwtKuraException) PositionService(org.eclipse.kura.position.PositionService) ArrayList(java.util.ArrayList) GwtGroupedNVPair(org.eclipse.kura.web.shared.model.GwtGroupedNVPair)

Example 2 with GwtGroupedNVPair

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);
}
Also used : ArrayList(java.util.ArrayList) GwtGroupedNVPair(org.eclipse.kura.web.shared.model.GwtGroupedNVPair)

Example 3 with GwtGroupedNVPair

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);
}
Also used : SystemService(org.eclipse.kura.system.SystemService) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) Properties(java.util.Properties) GwtGroupedNVPair(org.eclipse.kura.web.shared.model.GwtGroupedNVPair) SortedSet(java.util.SortedSet)

Example 4 with GwtGroupedNVPair

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();
                }
            });
        }
    });
}
Also used : AsyncCallback(com.google.gwt.user.client.rpc.AsyncCallback) ArrayList(java.util.ArrayList) GwtGroupedNVPair(org.eclipse.kura.web.shared.model.GwtGroupedNVPair) GwtXSRFToken(org.eclipse.kura.web.shared.model.GwtXSRFToken)

Example 5 with GwtGroupedNVPair

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);
}
Also used : TextColumn(com.google.gwt.user.cellview.client.TextColumn) Column(com.google.gwt.user.cellview.client.Column) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) SafeHtmlCell(com.google.gwt.cell.client.SafeHtmlCell) GwtGroupedNVPair(org.eclipse.kura.web.shared.model.GwtGroupedNVPair) TextColumn(com.google.gwt.user.cellview.client.TextColumn)

Aggregations

GwtGroupedNVPair (org.eclipse.kura.web.shared.model.GwtGroupedNVPair)25 ArrayList (java.util.ArrayList)21 AsyncCallback (com.google.gwt.user.client.rpc.AsyncCallback)14 GwtXSRFToken (org.eclipse.kura.web.shared.model.GwtXSRFToken)14 ListLoadResult (com.extjs.gxt.ui.client.data.ListLoadResult)6 ColumnConfig (com.extjs.gxt.ui.client.widget.grid.ColumnConfig)6 ColumnModel (com.extjs.gxt.ui.client.widget.grid.ColumnModel)6 RpcProxy (com.extjs.gxt.ui.client.data.RpcProxy)5 GroupingView (com.extjs.gxt.ui.client.widget.grid.GroupingView)5 FitLayout (com.extjs.gxt.ui.client.widget.layout.FitLayout)4 GwtKuraException (org.eclipse.kura.web.shared.GwtKuraException)3 ButtonEvent (com.extjs.gxt.ui.client.event.ButtonEvent)2 Button (com.extjs.gxt.ui.client.widget.button.Button)2 SystemService (org.eclipse.kura.system.SystemService)2 ServiceReference (org.osgi.framework.ServiceReference)2 El (com.extjs.gxt.ui.client.core.El)1 ModelData (com.extjs.gxt.ui.client.data.ModelData)1 BaseEvent (com.extjs.gxt.ui.client.event.BaseEvent)1 ComponentEvent (com.extjs.gxt.ui.client.event.ComponentEvent)1 KeyListener (com.extjs.gxt.ui.client.event.KeyListener)1