Esempio n. 1
0
    public CmdButton(String name, Widget icon, Command cmd, String label, String desc) {
      this.name = name;
      this.command = cmd;
      this.name = name;
      String htmlstr = label == null ? name : label;
      html = new HTML(htmlstr);
      if (desc != null) {
        html.setTitle(desc);
      }
      this.command = cmd;
      html.setWordWrap(false);
      if (command instanceof GeneralCommand) {
        addListeners();
        setButtonEnabled(((GeneralCommand) command).isEnabled());
      }

      GwtUtil.setStyles(iconHolderLeft, "padding", "none", "marginRight", "3px");
      GwtUtil.setStyle(html, "padding", "6px 0");
      container = GwtUtil.makeHoriPanel(null, null, iconHolderLeft, html, iconHolderRight);
      container.setCellVerticalAlignment(iconHolderLeft, VerticalPanel.ALIGN_MIDDLE);
      container.setCellVerticalAlignment(iconHolderRight, VerticalPanel.ALIGN_MIDDLE);
      setIconLeft(icon);
      setIconRight(null);
      GwtUtil.setStyle(container, "margin", "0px auto");
      initWidget(new SimplePanel(container));
    }
Esempio n. 2
0
  private static ServerEvent parseJsonEvent(String msg) {
    try {
      JSONObject eventJ = JSONParser.parseStrict(msg).isObject();
      Name name = new Name(eventJ.get("name").isString().stringValue(), "");
      ServerEvent.Scope scope =
          ServerEvent.Scope.valueOf(eventJ.get("scope").isString().stringValue());
      ServerEvent.DataType dataType =
          eventJ.get("dataType") == null
              ? ServerEvent.DataType.STRING
              : ServerEvent.DataType.valueOf(eventJ.get("dataType").isString().stringValue());
      Serializable data;
      String from = eventJ.get("from") == null ? null : eventJ.get("from").toString();
      if (dataType == ServerEvent.DataType.BG_STATUS) {
        data = BackgroundStatus.parse(eventJ.get("data").isString().stringValue());
      } else if (dataType == ServerEvent.DataType.JSON) {
        data = eventJ.get("data").isObject().toString();
      } else {
        data = eventJ.get("data").isString().stringValue();
      }
      ServerEvent sEvent = new ServerEvent(name, scope, dataType, data);
      sEvent.setFrom(from);
      return sEvent;

    } catch (Exception e) {
      GwtUtil.getClientLogger()
          .log(Level.WARNING, "Unable to parse json message into ServerEvent: " + msg, e);
      return null;
    }
  }
Esempio n. 3
0
    public Widget makeExtraUI(final WebLayerItem item) {

      final CheckBox cb =
          GwtUtil.makeCheckBox(
              "Offset Calculation",
              "Calculate the distance, delta(RA), delta(Dec), and PA between two points",
              _posAngle);
      cb.addValueChangeHandler(
          new ValueChangeHandler<Boolean>() {
            public void onValueChange(ValueChangeEvent<Boolean> ev) {
              _posAngle = ev.getValue();
              redraw();
            }
          });

      SimpleInputField units =
          SimpleInputField.createByProp("PrefGroup.Generic.field.DistanceReadout");
      String pref = Preferences.get(DIST_READOUT);
      units.setValue(pref == null ? DEG : pref);
      units
          .getField()
          .addValueChangeHandler(
              new ValueChangeHandler<String>() {
                public void onValueChange(ValueChangeEvent<String> ev) {
                  Preferences.set(DIST_READOUT, ev.getValue());
                  redraw();
                }
              });

      VerticalPanel vp = new VerticalPanel();
      vp.add(cb);
      vp.add(units);

      return vp;
    }
Esempio n. 4
0
  private void layout(final SearchSummaryItem ssi, final int depth) {

    final int row = table.getRowCount();
    final Image loading = new Image(GwtUtil.LOADING_ICON_URL);
    ssi.checkUpdate();

    table.setWidget(row, iconColIdx, loading);

    if (ssi.isLoaded()) {
      ssi.renderItem(table, row, curGroupByName);
      GwtUtil.setStyles(loading, "visibility", "hidden");
    } else {
      ssi.checkUpdate();
      table.setWidget(row, iconColIdx, loading);
      Timer timer =
          new Timer() {
            public void run() {
              ssi.checkUpdate();
              ssi.renderItem(table, row, curGroupByName);
              if (ssi.isLoaded()) {
                cancel();
                GwtUtil.setStyles(loading, "visibility", "hidden");
              }
            }
          };
      bgList.add(timer);
      timer.scheduleRepeating(1000);
    }

    if (ssi.getChildren() != null && ssi.getChildren().size() > 0) {
      for (SearchSummaryItem child : ssi.getChildren()) {
        layout(child, depth + 1);
      }
    }
  }
Esempio n. 5
0
 public void setIconRight(Widget w) {
   iconHolderRight.setWidget(w);
   iconHolderRight.setVisible(w != null);
   if (w != null) {
     w.setSize("20px", "20px");
     GwtUtil.setStyles(w, "verticalAlign", "middle", "margin", "0");
   }
 }
Esempio n. 6
0
 public void addButton(Button button, Align align, int idx, String width) {
   TTabBar tb =
       align == Align.LEFT ? leftToolbar : align == Align.CENTER ? centerToolbar : rightToolbar;
   idx = idx < 0 || idx > tb.getTabCount() ? tb.getTabCount() : idx;
   tb.insertTab(button.asWidget(), idx);
   TabBar.Tab t = tb.getTab(idx);
   tabs.put(button.getName(), new TabHolder(t, button, tb));
   width = StringUtils.isEmpty(width) ? defaultWidth : width;
   GwtUtil.setStyle(button.asWidget(), "minWidth", width);
 }
Esempio n. 7
0
  public static void onMessage(String msg) {
    try {
      GwtUtil.getClientLogger().log(Level.INFO, "onMessage: " + msg);

      ServerEvent sEvent = parseJsonEvent(msg);
      Name name = sEvent == null ? null : sEvent.getName();
      Serializable data = sEvent.getData();

      if (name == null) {
        GwtUtil.getClientLogger().log(Level.INFO, "Failed to evaluate: " + msg);
      }
      if (name.equals(Name.EVT_CONN_EST)) {
        JSONObject dataJ = JSONParser.parseStrict(sEvent.getData().toString()).isObject();
        String sEventInfo =
            dataJ.get("connID").isString().stringValue()
                + "_"
                + dataJ.get("channel").isString().stringValue();
        Cookies.setCookie("seinfo", sEventInfo);
        GwtUtil.getClientLogger()
            .log(Level.INFO, "Websocket connection established: " + sEventInfo);
      } else if (data instanceof BackgroundStatus) {
        WebEvent<String> ev =
            new WebEvent<String>(
                ClientEventQueue.class, name, ((BackgroundStatus) data).serialize());
        WebEventManager.getAppEvManager().fireEvent(ev);
        GwtUtil.getClientLogger()
            .log(Level.INFO, "Event: Name:" + name.getName() + ", Data: " + ev.getData());
      } else {
        WebEvent<String> ev =
            new WebEvent<String>(ClientEventQueue.class, name, String.valueOf(data));
        WebEventManager.getAppEvManager().fireEvent(ev);
        GwtUtil.getClientLogger()
            .log(Level.INFO, "Event: Name:" + name.getName() + ", Data: " + sEvent.getData());
      }
    } catch (Exception e) {
      GwtUtil.getClientLogger()
          .log(Level.WARNING, "Exception interpreting incoming message: " + msg, e);
    }
  }
Esempio n. 8
0
 public static void onClose(String reason) {
   GwtUtil.getClientLogger().log(Level.INFO, "onClose");
 }
Esempio n. 9
0
 public static void onError(String error) {
   GwtUtil.getClientLogger().log(Level.INFO, "onError: " + error);
 }
Esempio n. 10
0
 public static void onOpen() {
   retries = 0;
   GwtUtil.getClientLogger().log(Level.INFO, "event manager started");
 }
Esempio n. 11
0
 private void setButtonEnabled(boolean enabled) {
   GwtUtil.setStyle(html, "color", enabled ? "black" : "gray");
 }
Esempio n. 12
0
 public SearchSummaryPanel(String name, String shortDesc) {
   setName(name);
   setShortDesc(shortDesc);
   initWidget(mainPanel);
   GwtUtil.setStyle(this, "marginTop", "10px");
 }
Esempio n. 13
0
  public void layout() {

    // clear any backgrounded processes.
    for (Timer t : bgList) {
      t.cancel();
    }

    table = new FlexTable();
    mainPanel.clear();
    if (!StringUtils.isEmpty(name) || !StringUtils.isEmpty(helpId)) {

      String n = StringUtils.isEmpty(name) ? "" : name.trim();
      HorizontalPanel h = new HorizontalPanel();
      h.setWidth("100%");
      HTML lname = new HTML("<b>" + n + "</b>");
      if (shortDesc != null) {
        lname.setTitle(shortDesc);
      }
      GwtUtil.setStyles(lname, "textAlign", "center");
      h.add(lname);
      h.setCellWidth(lname, "100%");

      if (!StringUtils.isEmpty(helpId)) {
        final Widget helpIcon = HelpManager.makeHelpIcon(helpId);
        h.add(helpIcon);
        GwtUtil.setStyles(helpIcon, "marginRight", "11px");
      }
      mainPanel.addNorth(h, 20);
    }

    // setup group by selection
    if (groupByCols != null && groupByCols.size() > 1) {
      EnumFieldDef gb = new EnumFieldDef("groupBy");
      gb.setLabel("Group By");
      gb.setDesc("Select a group by column to update the data table");
      gb.setPreferWidth(200);
      gb.setDefaultValue(curGroupByName);
      for (TableDataView.Column item : headers) {
        if (groupByCols.contains(item.getName())) {
          gb.addItem(item.getName(), item.getTitle());
        }
      }
      final SimpleInputField sif = SimpleInputField.createByDef(gb);
      mainPanel.addNorth(sif, 28);
      sif.getField()
          .addValueChangeHandler(
              new ValueChangeHandler() {
                public void onValueChange(ValueChangeEvent ve) {
                  curGroupByName = sif.getValue();
                  layout();
                }
              });
    }

    ScrollPanel sp = new ScrollPanel();
    sp.add(table);

    mainPanel.add(sp);

    table.setStyleName("firefly-summary-table");
    table.setSize("100%", "100%");
    iconColIdx = headers.size();
    String titleCol = null;

    // render headers
    int colIdx = 0;
    for (int i = 0; i < headers.size(); i++) {
      TableDataView.Column col = headers.get(i);
      if (curGroupByName == null || !curGroupByName.equals(col.getName())) {
        table.setText(0, colIdx, col.getTitle());
        table.getCellFormatter().setStyleName(0, colIdx, "title-bar");
        colIdx++;
        if (titleCol == null) {
          titleCol = col.getName();
        }
      }
    }
    table.setText(0, headers.size(), "");
    table.getCellFormatter().setWidth(0, headers.size(), "100%");

    ArrayList<SearchSummaryItem> itemList = searchItems;

    if (!StringUtils.isEmpty(curGroupByName)) {
      itemList = new ArrayList<SearchSummaryItem>();

      GroupFinder finder = new GroupFinder("");
      List<GroupedSummaryItem> groupList = new ArrayList<GroupedSummaryItem>();
      for (int i = 0; i < searchItems.size(); i++) {
        SearchSummaryItem dsi = searchItems.get(i);
        String cGroupValue = dsi.getValue(curGroupByName);
        GroupedSummaryItem cGroup =
            CollectionUtil.findFirst(groupList, finder.setName(cGroupValue));
        if (cGroup == null) {
          cGroup = new GroupedSummaryItem(cGroupValue);
          groupList.add(cGroup);
          itemList.add(cGroup);
        }
        cGroup.addChild(dsi);
      }
    }

    for (SearchSummaryItem ssi : itemList) {
      ssi.setTitleCol(titleCol);
      layout(ssi, 0);
    }
  }