예제 #1
0
  private void initializeStatusGrid() {
    // Creacion del Grid Base
    StatusItemProperties props = GWT.create(StatusItemProperties.class);
    statusStore = new ListStore<StatusItem>(props.key());
    statusStore.setAutoCommit(true);

    ColumnConfig<StatusItem, String> nameCol =
        new ColumnConfig<StatusItem, String>(
            props.name(), 75, UIMessages.INSTANCE.fedColumnNameText());

    ColumnConfig<StatusItem, String> valueCol =
        new ColumnConfig<StatusItem, String>(
            props.value(), 150, UIMessages.INSTANCE.fedNewAttributeDefaultNameText());

    List<ColumnConfig<StatusItem, ?>> columns = new ArrayList<ColumnConfig<StatusItem, ?>>();
    columns.add(nameCol);
    columns.add(valueCol);

    statusGrid = new Grid<StatusItem>(statusStore, new ColumnModel<StatusItem>(columns));
    statusGrid.setSelectionModel(new CellSelectionModel<StatusItem>());
    statusGrid.getColumnModel().getColumn(1).setHideable(false);
    statusGrid.setHideHeaders(true);
    statusGrid.setAllowTextSelection(true);
    statusGrid.getView().setStripeRows(true);
    statusGrid.getView().setColumnLines(true);
    statusGrid.setBorders(false);

    statusStore.add(new StatusItem(LON_LABEL, null));
    statusStore.add(new StatusItem(LAT_LABEL, null));
    statusStore.add(new StatusItem(SCALE_LABEL, null));
    statusStore.add(new StatusItem(CLICK_COORD_X, null));
    statusStore.add(new StatusItem(CLICK_COORD_Y, null));
  }
예제 #2
0
 public void showState(Position position) {
   if (position != null) {
     stateStore.replaceAll(StateReader.getState(position));
   } else {
     stateStore.clear();
   }
 }
예제 #3
0
  public void setClickedCoordinates(double x, double y) {
    StatusItem messageItemX = getStatusItem(CLICK_COORD_X);
    messageItemX.setValue(String.valueOf(x));
    statusStore.update(messageItemX);

    StatusItem messageItemY = getStatusItem(CLICK_COORD_Y);
    messageItemY.setValue(String.valueOf(y));
    statusStore.update(messageItemY);
  }
예제 #4
0
 @Override
 public void onAnything() {
   Device oldDevice = deviceCombo.getValue();
   if (oldDevice != null) {
     deviceCombo.setValue(deviceStore.findModel(oldDevice));
   } else if (deviceStore.size() == 1) {
     deviceCombo.setValue(deviceStore.get(0));
   }
 }
예제 #5
0
  public void addVolume() {
    ToolAutoBeanFactory factory = GWT.create(ToolAutoBeanFactory.class);
    ToolVolume volume = factory.getVolume().as();
    getVolumeTag(volume);

    editing.cancelEditing();
    listStore.add(0, volume);
    int row = listStore.indexOf(volume);
    editing.startEditing(new Grid.GridCell(row, 0));
  }
예제 #6
0
  @UiFactory()
  public Grid<Stock> createGrid() {
    final NumberFormat number = NumberFormat.getFormat("0.00");

    ColumnConfig<Stock, String> nameCol =
        new ColumnConfig<Stock, String>(props.name(), 200, "Company");
    ColumnConfig<Stock, String> symbolCol =
        new ColumnConfig<Stock, String>(props.symbol(), 100, "Symbol");
    ColumnConfig<Stock, Double> lastCol = new ColumnConfig<Stock, Double>(props.last(), 75, "Last");

    ColumnConfig<Stock, Double> changeCol =
        new ColumnConfig<Stock, Double>(props.change(), 100, "Change");

    changeCol.setCell(
        new AbstractCell<Double>() {

          @Override
          public void render(Context context, Double value, SafeHtmlBuilder sb) {
            SafeStylesBuilder stylesBuilder = new SafeStylesBuilder();
            stylesBuilder.appendTrustedString("color:" + (value < 0 ? "red" : "green") + ";");
            String v = number.format(value);
            CellTemplates cellTemplates = GWT.create(CellTemplates.class);
            SafeHtml template = cellTemplates.template(stylesBuilder.toSafeStyles(), v, v);
            sb.append(template);
          }
        });

    ColumnConfig<Stock, Date> lastTransCol =
        new ColumnConfig<Stock, Date>(props.lastTrans(), 100, "Last Updated");
    DateCell dateCell = new DateCell(DateTimeFormat.getFormat("MM/dd/yyyy"));
    lastTransCol.setCell(dateCell);

    List<ColumnConfig<Stock, ?>> l = new ArrayList<ColumnConfig<Stock, ?>>();
    l.add(nameCol);
    l.add(symbolCol);
    l.add(lastCol);
    l.add(changeCol);
    l.add(lastTransCol);
    ColumnModel<Stock> cm = new ColumnModel<Stock>(l);

    ListStore<Stock> store = new ListStore<Stock>(props.key());
    store.addAll(TestData.getStocks());

    final Grid<Stock> grid = new Grid<Stock>(store, cm);
    grid.getView().setAutoExpandColumn(nameCol);
    grid.setBorders(false);
    grid.getView().setStripeRows(true);
    grid.getView().setColumnLines(true);

    // needed to enable quicktips (qtitle for the heading and qtip for the
    // content) that are setup in the change GridCellRenderer
    new QuickTip(grid);

    return grid;
  }
  /**
   * Creates combobox used to select molecular viewer.
   *
   * @return viewer selector
   */
  private ComboBox<String> createViewerTypeCombobox() {
    ListStore<String> store =
        new ListStore<String>(
            new ModelKeyProvider<String>() {
              @Override
              public String getKey(String item) {
                return item;
              }
            });

    store.add(AppPropertiesManager.CONSTANTS.viewer_local());
    store.add(AppPropertiesManager.CONSTANTS.viewer_jmol());
    store.add(AppPropertiesManager.CONSTANTS.viewer_pse());

    final ComboBox<String> viewerTypeComboBox =
        new ComboBox<String>(
            store,
            new LabelProvider<String>() {
              @Override
              public String getLabel(String item) {
                return item;
              }
            });

    viewerTypeComboBox.setId("viewercombo");
    viewerTypeComboBox.setTriggerAction(TriggerAction.ALL);
    viewerTypeComboBox.setEditable(false);
    viewerTypeComboBox.setWidth(100);

    viewerTypeComboBox.setToolTipConfig(createViewerTypeComboBoxToolTipConfig());

    String viewerCookie = Cookies.getCookie("crkviewer");
    if (viewerCookie != null) {
      viewerTypeComboBox.setValue(viewerCookie);
    } else {
      viewerTypeComboBox.setValue(AppPropertiesManager.CONSTANTS.viewer_jmol());
    }

    ApplicationContext.setSelectedViewer(viewerTypeComboBox.getValue());

    viewerTypeComboBox.addSelectionHandler(
        new SelectionHandler<String>() {
          @Override
          public void onSelection(SelectionEvent<String> event) {
            Cookies.setCookie("crkviewer", event.getSelectedItem());
            ApplicationContext.setSelectedViewer(event.getSelectedItem());
          }
        });

    return viewerTypeComboBox;
  }
예제 #8
0
 public void load(TableModel t) {
   getStore().clear();
   if (t != null) {
     store.add(new ModelPropertyModel("表名", t.getName()));
     store.add(new ModelPropertyModel("所有者", t.getOwner()));
     store.add(
         new ModelPropertyModel(
             "创建时间",
             DateTimeFormat.getFormat("yyyy-MM-d HH:mm:ss").format(t.getCreateDate()).toString()));
     store.add(new ModelPropertyModel("路径", t.getPath()));
     String inputFormat = t.getInputFormat();
     if (inputFormat.equals("org.apache.hadoop.mapred.TextInputFormat")) {
       inputFormat = "TextFile";
     } else if (inputFormat.equals("org.apache.hadoop.mapred.SequenceFileInputFormat")) {
       inputFormat = "SequenceFile";
     } else if (inputFormat.equals("org.apache.hadoop.hive.ql.io.RCFileInputFormat")) {
       inputFormat = "RCFile";
     }
     store.add(new ModelPropertyModel("存储格式", inputFormat));
     store.add(new ModelPropertyModel("注释", t.getComment()));
     char fieldDelim = t.getFieldDelim() == null ? '\001' : t.getFieldDelim().toCharArray()[0];
     store.add(new ModelPropertyModel("列分割符", fieldDelim + "(" + getUnicode(fieldDelim) + ")"));
     store.add(
         new ModelPropertyModel(
             "公共表数据字典",
             "http://cheetah.alibaba-inc.com:8000/meta/manage/metaManage.htm?actionName=doMamageList&q="
                 + t.getName()
                 + "&packagename=taobao&isopen=0,1,2&dwlayer=All&level=0&curpage=1&pagesize=25"));
   }
 }
예제 #9
0
  private void updateStatusInfo() {
    if (vectorLayers != null) {
      List<VectorLayerInfo> vectors = new ArrayList<VectorLayerInfo>();

      for (Layer layer : vectorLayers) {
        vectors.add(new VectorLayerInfo((Vector) layer));
      }

      layerStore.clear();
      layerStore.addAll(vectors);
      layerCombo.redraw();
    }

    if (selectedLayer != null) {
      layerCombo.setValue(new VectorLayerInfo(selectedLayer));
    }
  }
예제 #10
0
  /**
   * Method to return a list of current jobs
   *
   * @return list of job id's
   */
  private List<String> getCurrentJobsList() {
    List<String> jobsList = new ArrayList<String>();
    for (MyJobsModel m : myJobsStore.getAll()) {
      jobsList.add(m.getJobid());
    }

    return jobsList;
  }
예제 #11
0
  /** @param supportedValidatorTypes use these to construct content of the combo box */
  AddValidatorDialog(
      Set<ArgumentValidatorType> supportedValidatorTypes, ArgumentValidatorMessages avMessages) {
    this.avMessages = avMessages;

    setHeadingText(avMessages.validatorDialogHeading());
    setAutoHide(false);
    setSize("400", "250");
    // Initialize the ComboBox list store with the given Set<..>
    ListStore<ArgumentValidatorType> validatorTypes = new ListStore<>(new AVTLabelKeyProvider());
    validatorTypes.addAll(supportedValidatorTypes);

    // Initialize the ComboBox
    validatorTypeCB = new ComboBox<>(validatorTypes, new AVTLabelKeyProvider());
    validatorTypeCB.setForceSelection(true);
    validatorTypeCB.setAllowBlank(false);
    validatorTypeCB.setTriggerAction(TriggerAction.ALL);

    // Construct all "provided" fields.
    constructDoubleSpinnerFields();
    constructIntegerSpinnerFields();
    charLimitField = new NumberField<>(new NumberPropertyEditor.IntegerPropertyEditor());
    charLimitField.setAllowBlank(false);
    charLimitField.addValidHandler(this);
    charLimitField.addInvalidHandler(this);

    add(BINDER.createAndBindUi(this));

    // Initialize validatorTypeToCardMap
    validatorTypeToCardMap = Maps.newHashMap();
    validatorTypeToCardMap.put(ArgumentValidatorType.DoubleAbove, dblAboveValidatorCon);
    validatorTypeToCardMap.put(ArgumentValidatorType.DoubleBelow, dblBelowValidatorCon);
    validatorTypeToCardMap.put(ArgumentValidatorType.DoubleRange, dblRangeValidatorCon);

    validatorTypeToCardMap.put(ArgumentValidatorType.IntAbove, intAboveValidatorCon);
    validatorTypeToCardMap.put(ArgumentValidatorType.IntBelow, intBelowValidatorCon);
    validatorTypeToCardMap.put(ArgumentValidatorType.IntRange, intRangeValidatorCon);

    validatorTypeToCardMap.put(ArgumentValidatorType.Regex, regexValidatorCon);
    validatorTypeToCardMap.put(ArgumentValidatorType.CharacterLimit, characterLimitValidatorCon);

    // Set default values.
    ArgumentValidatorType next = supportedValidatorTypes.iterator().next();
    validatorTypeCB.setValue(next, true);
    cardLC.setActiveWidget(validatorTypeToCardMap.get(next));
  }
예제 #12
0
  private StatusItem getStatusItem(String name) {
    for (StatusItem item : statusStore.getAll()) {
      if (item.getName().equals(name)) {
        return item;
      }
    }

    return null;
  }
예제 #13
0
 public boolean isValid() {
   for (ToolVolume volume : listStore.getAll()) {
     if (Strings.isNullOrEmpty(volume.getHostPath())
         || Strings.isNullOrEmpty(volume.getContainerPath())) {
       return false;
     }
   }
   return true;
 }
예제 #14
0
  public void setCurrentCoordinate(LonLat currentCoordinate) {
    StatusItem lonItem = getStatusItem(LON_LABEL);
    lonItem.setValue(Double.toString(currentCoordinate.lon()));
    StatusItem latItem = getStatusItem(LAT_LABEL);
    latItem.setValue(Double.toString(currentCoordinate.lat()));

    statusStore.update(lonItem);
    statusStore.update(latItem);
  }
예제 #15
0
 @UiHandler("clearButton")
 public void onClearClicked(SelectEvent event) {
   for (Map.Entry<Long, ArchivePanel> entry : archivePanels.entrySet()) {
     Device device = deviceStore.findModelWithKey(entry.getKey().toString());
     archiveHandler.onClear(device);
     devicesTabs.remove(entry.getValue().getContentPanel());
   }
   archivePanels.clear();
 }
예제 #16
0
 @UiHandler("devicesTabs")
 public void onDeviceTabClosed(CloseEvent<Widget> event) {
   for (Map.Entry<Long, ArchivePanel> entry : archivePanels.entrySet()) {
     if (entry.getValue().getContentPanel().equals(event.getItem())) {
       Device device = deviceStore.findModelWithKey(entry.getKey().toString());
       archiveHandler.onClear(device);
       archivePanels.remove(entry.getKey());
       break;
     }
   }
 }
예제 #17
0
  @Override
  public Widget asWidget() {
    // reduce the padding on text element as we have widgets in the cells
    SafeStyles textStyles = SafeStylesUtils.fromTrustedString("padding: 1px 3px;");

    ColumnConfig<Plant, String> cc1 =
        new ColumnConfig<Plant, String>(properties.name(), 100, "Name");
    // IMPORTANT we want the text element (cell parent) to only be as wide as the cell and not fill
    // the cell
    cc1.setColumnTextClassName(CommonStyles.get().inlineBlock());
    cc1.setColumnTextStyle(textStyles);

    TextButtonCell button = new TextButtonCell();
    button.addSelectHandler(
        new SelectHandler() {

          @Override
          public void onSelect(SelectEvent event) {
            Context c = event.getContext();
            int row = c.getIndex();
            Plant p = store.get(row);
            Info.display("Event", "The " + p.getName() + " was clicked.");
          }
        });
    cc1.setCell(button);

    DateCell dateCell = new DateCell();
    dateCell.setPropertyEditor(
        new DateTimePropertyEditor(DateTimeFormat.getFormat(PredefinedFormat.DATE_SHORT)));

    ColumnConfig<Plant, Date> cc2 =
        new ColumnConfig<Plant, Date>(properties.available(), 100, "Date");
    cc2.setColumnTextStyle(textStyles);
    cc2.setCell(dateCell);

    List<ColumnConfig<Plant, ?>> l = new ArrayList<ColumnConfig<Plant, ?>>();
    l.add(cc1);
    l.add(cc2);
    ColumnModel<Plant> cm = new ColumnModel<Plant>(l);

    store = new ListStore<Plant>(properties.key());
    store.addAll(TestData.getPlants());

    Grid<Plant> grid = new Grid<Plant>(store, cm);
    grid.getView().setForceFit(true);

    ContentPanel cp = new ContentPanel();
    cp.setHeadingText("Cell Grid");
    cp.setWidget(grid);
    cp.setPixelSize(500, 400);
    cp.addStyleName("margin-10");
    return cp;
  }
예제 #18
0
  /**
   * Selects correct job before removal.
   *
   * @param jobToStop identifier of the job which was removed
   */
  private void selectPrevious(String jobToRemove) {
    List<MyJobsModel> currentJobs = myJobsStore.getAll();

    boolean found = false;
    int jobNr = 0;

    while ((jobNr < currentJobs.size()) && (!found)) {
      if (currentJobs.get(jobNr).getJobid().equals(jobToRemove)) {
        found = true;
      }

      jobNr++;
    }

    jobNr -= 2;

    if (jobNr >= 0) {
      myJobsGrid.getSelectionModel().select(currentJobs.get(jobNr), false);
    } else if (myJobsStore.getAll().size() > 1) {
      myJobsGrid.getSelectionModel().select(currentJobs.get(1), false);
    } else {
      History.newItem("");
    }
  }
예제 #19
0
  @Inject
  public ToolVolumeListEditor(
      ToolVolumeProperties toolVolumeProperties, ToolAdminView.ToolAdminViewAppearance appearance) {
    this.appearance = appearance;
    listStore =
        new ListStore<>(
            new ModelKeyProvider<ToolVolume>() {
              @Override
              public String getKey(ToolVolume item) {
                return getVolumeTag(item);
              }
            });
    listStoreEditor = new ListStoreEditor<>(listStore);
    listStore.setAutoCommit(true);

    ColumnConfig<ToolVolume, String> hostPath =
        new ColumnConfig<>(
            toolVolumeProperties.hostPath(),
            appearance.containerVolumesHostPathWidth(),
            appearance.containerVolumesHostPathLabel());
    ColumnConfig<ToolVolume, String> containerPath =
        new ColumnConfig<>(
            toolVolumeProperties.containerPath(),
            appearance.containerVolumesContainerPathWidth(),
            appearance.containerVolumesContainerPathLabel());

    List<ColumnConfig<ToolVolume, ?>> columns = new ArrayList<>();
    columns.add(hostPath);
    columns.add(containerPath);
    ColumnModel<ToolVolume> cm = new ColumnModel<>(columns);

    grid = new Grid<>(listStore, cm);
    grid.setHeight(100);

    editing = new GridRowEditing<>(grid);
    enableGridEditing(hostPath, containerPath);
    editing.addCancelEditHandler(getCancelHandler());
    ((AbstractGridEditing<ToolVolume>) editing).setClicksToEdit(ClicksToEdit.TWO);

    initWidget(grid);
  }
예제 #20
0
  public Widget asWidget() {
    final Chart<Site> chart = new Chart<Site>(600, 400);
    chart.setDefaultInsets(20);

    final ListStore<Site> store = new ListStore<Site>(siteAccess.nameKey());
    Date initial = f.parse("Feb 1");
    for (int i = 0; i < 7; i++) {
      store.add(
          new Site(initial, Math.random() * 20 + 80, Math.random() * 20 + 40, Math.random() * 20));
      initial = CalendarUtil.copyDate(initial);
      CalendarUtil.addDaysToDate(initial, 1);
    }
    chart.setStore(store);

    NumericAxis<Site> axis = new NumericAxis<Site>();
    axis.setPosition(Position.LEFT);
    axis.addField(siteAccess.visits());
    TextSprite title = new TextSprite("Number of Hits");
    title.setFontSize(18);
    axis.setTitleConfig(title);
    axis.setDisplayGrid(true);
    axis.setMinimum(0);
    axis.setMaximum(100);
    chart.addAxis(axis);

    final TimeAxis<Site> time = new TimeAxis<Site>();
    time.setField(siteAccess.date());
    time.setStartDate(f.parse("Feb 1"));
    time.setEndDate(f.parse("Feb 7"));
    time.setLabelProvider(
        new LabelProvider<Date>() {
          @Override
          public String getLabel(Date item) {
            return f.format(item);
          }
        });
    chart.addAxis(time);

    LineSeries<Site> series = new LineSeries<Site>();
    series.setYAxisPosition(Position.LEFT);
    series.setYField(siteAccess.visits());
    series.setStroke(new RGB(148, 174, 10));
    series.setShowMarkers(true);
    series.setMarkerIndex(1);
    Sprite marker = Primitives.circle(0, 0, 6);
    marker.setFill(new RGB(148, 174, 10));
    series.setMarkerConfig(marker);
    chart.addSeries(series);

    series = new LineSeries<Site>();
    series.setYAxisPosition(Position.LEFT);
    series.setYField(siteAccess.views());
    series.setStroke(new RGB(17, 95, 166));
    series.setShowMarkers(true);
    series.setMarkerIndex(1);
    marker = Primitives.cross(0, 0, 6);
    marker.setFill(new RGB(17, 95, 166));
    series.setMarkerConfig(marker);
    chart.addSeries(series);

    series = new LineSeries<Site>();
    series.setYAxisPosition(Position.LEFT);
    series.setYField(siteAccess.veins());
    series.setStroke(new RGB(166, 17, 32));
    series.setShowMarkers(true);
    series.setMarkerIndex(1);
    marker = Primitives.diamond(0, 0, 6);
    marker.setFill(new RGB(166, 17, 32));
    series.setMarkerConfig(marker);
    chart.addSeries(series);

    update =
        new Timer() {
          @Override
          public void run() {
            Date startDate = CalendarUtil.copyDate(time.getStartDate());
            Date endDate = CalendarUtil.copyDate(time.getEndDate());
            CalendarUtil.addDaysToDate(startDate, 1);
            CalendarUtil.addDaysToDate(endDate, 1);
            chart
                .getStore()
                .add(
                    new Site(
                        endDate,
                        Math.random() * 20 + 80,
                        Math.random() * 20 + 40,
                        Math.random() * 20));
            time.setStartDate(startDate);
            time.setEndDate(endDate);
            chart.redrawChart();
          }
        };

    update.scheduleRepeating(1000);

    ToggleButton animation = new ToggleButton("Animate");
    animation.addValueChangeHandler(
        new ValueChangeHandler<Boolean>() {
          @Override
          public void onValueChange(ValueChangeEvent<Boolean> event) {
            chart.setAnimated(event.getValue());
          }
        });
    animation.setValue(true, true);

    ToolBar toolBar = new ToolBar();
    toolBar.add(animation);

    ContentPanel panel = new FramedPanel();
    panel.getElement().getStyle().setMargin(10, Unit.PX);
    panel.setCollapsible(true);
    panel.setHeadingText("Live Chart");
    panel.setPixelSize(620, 500);
    panel.setBodyBorder(true);

    VerticalLayoutContainer layout = new VerticalLayoutContainer();
    panel.add(layout);

    toolBar.setLayoutData(new VerticalLayoutData(1, -1));
    layout.add(toolBar);

    chart.setLayoutData(new VerticalLayoutData(1, 1));
    layout.add(chart);

    panel.addAttachHandler(
        new AttachEvent.Handler() {
          @Override
          public void onAttachOrDetach(AttachEvent event) {
            if (event.isAttached() == false) {
              update.cancel();
            }
          }
        });

    return panel;
  }
예제 #21
0
  public void setScale(String scale) {
    StatusItem scaleItem = getStatusItem(SCALE_LABEL);
    scaleItem.setValue(scale);

    statusStore.update(scaleItem);
  }
예제 #22
0
 public void deleteVolume() {
   ToolVolume deleteVolume = grid.getSelectionModel().getSelectedItem();
   if (deleteVolume != null) {
     listStore.remove(listStore.findModelWithKey(getVolumeTag(deleteVolume)));
   }
 }
예제 #23
0
  /**
   * Adds jobs to grid.
   *
   * @param jobs jobs to display
   * @param selectedJobId current job
   */
  private void setJobs(List<ProcessingInProgressData> jobs, String selectedJobId) {
    MyJobsModel itemToSelect = null;
    int itemToSelectIndex = 0;

    if (jobs != null) {
      int i = 0;

      for (int ii = 0; ii < myJobsStore.size(); ii++) {
        MyJobsModel model = myJobsStore.get(ii);
        boolean found = false;
        int j = 0;

        while ((j < jobs.size()) && (!found)) {
          if (jobs.get(j).getJobId().equals(model.getJobid())) {
            found = true;
            break;
          }

          j++;
        }

        if (!found) {
          myJobsStore.remove(ii);
        }
      }

      for (ProcessingInProgressData statusData : jobs) {
        MyJobsModel myJobsModel =
            new MyJobsModel(statusData.getJobId(), statusData.getStatus(), statusData.getInput());

        if ((selectedJobId != null) && (statusData.getJobId().equals(selectedJobId))) {
          itemToSelect = myJobsModel;
          itemToSelectIndex = i;
        }

        MyJobsModel existingModel = myJobsStore.findModel(myJobsModel);

        if (existingModel != null) {
          existingModel.setStatus(statusData.getStatus());
          existingModel.setInput(statusData.getInput());
          myJobsStore.update(existingModel);
        } else {
          myJobsStore.add(myJobsModel);
        }

        i++;
      }
    }

    myJobsStore.commitChanges();

    if ((selectedJobId != null) && (myJobsStore.size() > 0)) {
      myJobsGrid.getSelectionModel().select(itemToSelect, false);

      if (isJobsListFirstTimeLoaded) {
        myJobsGrid.getView().focusRow(itemToSelectIndex);
        isJobsListFirstTimeLoaded = false;
      }
      EventBusManager.EVENT_BUS.fireEvent(new ShowJobsPanelEvent());
    } else {
      EventBusManager.EVENT_BUS.fireEvent(new HideJobsPanelEvent());
    }
  }
예제 #24
0
  @Override
  public Widget asWidget() {
    final ListStore<Data> store = new ListStore<Data>(dataAccess.nameKey());
    store.addAll(TestData.getData(12, 20, 100));

    final Chart<Data> chart = new Chart<Data>();
    chart.setStore(store);
    chart.setShadowChart(true);

    NumericAxis<Data> axis = new NumericAxis<Data>();
    axis.setPosition(Position.BOTTOM);
    axis.addField(dataAccess.data1());
    axis.addField(dataAccess.data2());
    axis.addField(dataAccess.data3());
    TextSprite title = new TextSprite("Number of Hits");
    title.setFontSize(18);
    axis.setTitleConfig(title);
    axis.setDisplayGrid(true);
    axis.setMinimum(0);
    axis.setMaximum(100);
    chart.addAxis(axis);

    CategoryAxis<Data, String> catAxis = new CategoryAxis<Data, String>();
    catAxis.setPosition(Position.LEFT);
    catAxis.setField(dataAccess.name());
    title = new TextSprite("Month of the Year");
    title.setFontSize(18);
    catAxis.setTitleConfig(title);
    chart.addAxis(catAxis);

    final BarSeries<Data> bar = new BarSeries<Data>();
    bar.setYAxisPosition(Position.BOTTOM);
    bar.addYField(dataAccess.data1());
    bar.addYField(dataAccess.data2());
    bar.addYField(dataAccess.data3());
    bar.addColor(new RGB(148, 174, 10));
    bar.addColor(new RGB(17, 95, 166));
    bar.addColor(new RGB(166, 17, 32));
    chart.addSeries(bar);

    final Legend<Data> legend = new Legend<Data>();
    legend.setPosition(Position.RIGHT);
    legend.setItemHighlighting(true);
    legend.setItemHiding(true);
    chart.setLegend(legend);

    TextButton regenerate = new TextButton("Reload Data");
    regenerate.addSelectHandler(
        new SelectHandler() {
          @Override
          public void onSelect(SelectEvent event) {
            store.clear();
            store.addAll(TestData.getData(12, 0, 100));
            chart.redrawChart();
          }
        });

    ToggleButton animation = new ToggleButton("Animate");
    animation.addValueChangeHandler(
        new ValueChangeHandler<Boolean>() {
          @Override
          public void onValueChange(ValueChangeEvent<Boolean> event) {
            chart.setAnimated(event.getValue());
          }
        });
    animation.setValue(true, true);
    ToggleButton shadow = new ToggleButton("Shadow");
    shadow.addValueChangeHandler(
        new ValueChangeHandler<Boolean>() {
          @Override
          public void onValueChange(ValueChangeEvent<Boolean> event) {
            chart.setShadowChart(event.getValue());
            chart.redrawChart();
          }
        });
    shadow.setValue(true);

    ToolBar toolBar = new ToolBar();
    toolBar.add(regenerate);
    toolBar.add(animation);
    toolBar.add(shadow);

    ContentPanel panel = new FramedPanel();
    panel.getElement().getStyle().setMargin(10, Unit.PX);
    panel.setCollapsible(true);
    panel.setHeadingText("Grouped Bar Chart");
    panel.setPixelSize(620, 500);
    panel.setBodyBorder(true);

    final Resizable resize = new Resizable(panel, Dir.E, Dir.SE, Dir.S);
    resize.setMinHeight(400);
    resize.setMinWidth(400);

    panel.addExpandHandler(
        new ExpandHandler() {
          @Override
          public void onExpand(ExpandEvent event) {
            resize.setEnabled(true);
          }
        });
    panel.addCollapseHandler(
        new CollapseHandler() {
          @Override
          public void onCollapse(CollapseEvent event) {
            resize.setEnabled(false);
          }
        });

    new Draggable(panel, panel.getHeader()).setUseProxy(false);

    VerticalLayoutContainer layout = new VerticalLayoutContainer();
    panel.add(layout);

    toolBar.setLayoutData(new VerticalLayoutData(1, -1));
    layout.add(toolBar);

    chart.setLayoutData(new VerticalLayoutData(1, 1));
    layout.add(chart);

    return panel;
  }
  @Override
  public Widget asWidget() {
    if (panel == null) {
      final NumberFormat number = NumberFormat.getFormat("0.00");
      final String desc =
          "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Sed metus nibh, sodales a, porta at, vulputate eget, dui. Pellentesque ut nisl. Maecenas tortor turpis, interdum non, sodales non, iaculis ac, lacus. Vestibulum auctor, tortor quis iaculis malesuada, libero lectus bibendum purus, sit amet tincidunt quam turpis vel lacus. In pellentesque nisl non sem. Suspendisse nunc sem, pretium eget, cursus a, fringilla vel, urna.<br/><br/>Aliquam commodo ullamcorper erat. Nullam vel justo in neque porttitor laoreet. Aenean lacus dui, consequat eu, adipiscing eget, nonummy non, nisi. Morbi nunc est, dignissim non, ornare sed, luctus eu, massa. Vivamus eget quam. Vivamus tincidunt diam nec urna. Curabitur velit.";

      RowExpander<Stock> expander =
          new RowExpander<Stock>(
              new AbstractCell<Stock>() {
                @Override
                public void render(Context context, Stock value, SafeHtmlBuilder sb) {
                  sb.appendHtmlConstant(
                      "<p style='margin: 5px 5px 10px'><b>Company:</b>" + value.getName() + "</p>");
                  sb.appendHtmlConstant("<p style='margin: 5px 5px 10px'><b>Summary:</b> " + desc);
                }
              });

      ColumnConfig<Stock, String> nameCol =
          new ColumnConfig<Stock, String>(props.name(), 200, "Company");
      ColumnConfig<Stock, String> symbolCol =
          new ColumnConfig<Stock, String>(props.symbol(), 100, "Symbol");
      ColumnConfig<Stock, Double> lastCol =
          new ColumnConfig<Stock, Double>(props.last(), 75, "Last");

      ColumnConfig<Stock, Double> changeCol =
          new ColumnConfig<Stock, Double>(props.change(), 100, "Change");
      changeCol.setCell(
          new AbstractCell<Double>() {

            @Override
            public void render(Context context, Double value, SafeHtmlBuilder sb) {
              String style = "style='color: " + (value < 0 ? "red" : "green") + "'";
              String v = number.format(value);
              sb.appendHtmlConstant(
                  "<span " + style + " qtitle='Change' qtip='" + v + "'>" + v + "</span>");
            }
          });

      ColumnConfig<Stock, Date> lastTransCol =
          new ColumnConfig<Stock, Date>(props.lastTrans(), 100, "Last Updated");
      lastTransCol.setCell(new DateCell(DateTimeFormat.getFormat("MM/dd/yyyy")));

      List<ColumnConfig<Stock, ?>> l = new ArrayList<ColumnConfig<Stock, ?>>();
      l.add(expander);
      l.add(nameCol);
      l.add(symbolCol);
      l.add(lastCol);
      l.add(changeCol);
      l.add(lastTransCol);
      ColumnModel<Stock> cm = new ColumnModel<Stock>(l);

      ListStore<Stock> store = new ListStore<Stock>(props.key());
      store.addAll(TestData.getStocks());

      panel = new ContentPanel();
      panel.setHeadingText("RowExpander Grid");
      panel.getHeader().setIcon(ExampleImages.INSTANCE.table());
      panel.setPixelSize(600, 320);
      panel.addStyleName("margin-10");

      final Grid<Stock> grid = new Grid<Stock>(store, cm);
      grid.getView().setAutoExpandColumn(nameCol);
      grid.setBorders(false);
      grid.getView().setStripeRows(true);
      grid.getView().setColumnLines(true);

      expander.initPlugin(grid);
      panel.setWidget(grid);
    }

    return panel;
  }
예제 #26
0
  public ArchiveView(final ArchiveHandler archiveHandler, ListStore<Device> deviceStore) {
    this.archiveHandler = archiveHandler;
    deviceStore.addStoreHandlers(deviceStoreHandlers);
    this.deviceStore = deviceStore;

    DeviceProperties deviceProperties = GWT.create(DeviceProperties.class);
    deviceCombo = new ComboBox<Device>(deviceStore, deviceProperties.label());

    // Element that displays the current track color
    styleButtonTrackColor = new TextButton();
    styleButtonTrackColor
        .getElement()
        .getStyle()
        .setProperty("backgroundColor", "#".concat(style.DEFAULT_COLOR));
    styleButtonTrackColor.getElement().getStyle().setCursor(Style.Cursor.TEXT);
    // Menu with the small palette
    smallColorMenu = new ExtColorMenu(ArchiveStyle.COLORS, ArchiveStyle.COLORS);
    smallColorMenu.setColor(ArchiveStyle.DEFAULT_COLOR);
    smallColorMenu
        .getPalette()
        .addValueChangeHandler(
            new ValueChangeHandler<String>() {
              @Override
              public void onValueChange(ValueChangeEvent<String> event) {
                style.setTrackColor(event.getValue());
                smallColorMenu.hide(true);
                fullColorMenu.getPalette().setValue("", false);
                styleButtonTrackColor
                    .getElement()
                    .getStyle()
                    .setProperty("backgroundColor", "#".concat(style.getTrackColor()));
              }
            });
    // Menu with the complete palette
    fullColorMenu = new ColorMenu();
    fullColorMenu
        .getPalette()
        .addValueChangeHandler(
            new ValueChangeHandler<String>() {
              @Override
              public void onValueChange(ValueChangeEvent<String> event) {
                style.setTrackColor(event.getValue());
                fullColorMenu.hide(true);
                smallColorMenu.getPalette().setValue("", false);
                styleButtonTrackColor
                    .getElement()
                    .getStyle()
                    .setProperty("backgroundColor", "#".concat(style.getTrackColor()));
              }
            });
    // Markers
    routeMarkersType = new Menu();
    for (Object[] obj :
        new Object[][] {
          {i18n.noMarkers(), null},
          {i18n.standardMarkers(), PositionIconType.iconArchive},
          {i18n.reducedMarkers(), PositionIconType.dotArchive}
        }) {
      CheckMenuItem item = new CheckMenuItem((String) obj[0]);
      final PositionIconType iconType = (PositionIconType) obj[1];
      item.setGroup("markers");
      item.setChecked(
          iconType == ApplicationContext.getInstance().getUserSettings().getArchiveMarkerType());
      if (item.isChecked()) {
        style.setIconType(iconType);
      }
      item.addSelectionHandler(
          new SelectionHandler<Item>() {
            @Override
            public void onSelection(SelectionEvent<Item> event) {
              style.setIconType(iconType);
              archiveHandler.onChangeArchiveMarkerType(iconType);
            }
          });
      routeMarkersType.add(item);
    }

    devicesTabs =
        new TabPanel(GWT.<TabPanel.TabPanelAppearance>create(BlueTabPanelBottomAppearance.class));
    archivePanels = new HashMap<Long, ArchivePanel>();

    uiBinder.createAndBindUi(this);

    markersMenu.setText(i18n.overlayType(UserSettings.OverlayType.MARKERS));

    // Initialize with current time
    long min = 60 * 1000;
    Date now = new Date();
    Date to = new Date(((now.getTime() + 15 * min) / (15 * min)) * 15 * min);
    Date from = new Date(to.getTime() - 60 * min);
    fromDate.setValue(from);
    fromTime.setValue(from);
    toDate.setValue(to);
    toTime.setValue(to);
  }