示例#1
0
  @Override
  public void setCursor(Cursor cursor) {
    super.setCursor(cursor);

    final java.awt.Cursor awtPredefinedCursor;
    if (cursor != null
        && (cursor.equals(CursorFactory.getCursor(SWT.CURSOR_WAIT))
            || cursor.equals(CursorFactory.getCursor(SWT.CURSOR_APPSTARTING))
            || cursor.equals(CursorFactory.getCursor(SWT.CURSOR_SIZENS)))) {

      if (cursor.equals(CursorFactory.getCursor(SWT.CURSOR_APPSTARTING))) {
        awtPredefinedCursor = java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR);
      } else if (cursor.equals(CursorFactory.getCursor(SWT.CURSOR_SIZENS))) {
        awtPredefinedCursor = java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.HAND_CURSOR);
      } else {
        awtPredefinedCursor = java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR);
      }

    } else {
      awtPredefinedCursor = java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR);
    }

    final Frame frame = SWT_AWT.getFrame(mainChartComposite);
    Runnable runnable =
        new Runnable() {
          public void run() {
            frame.setCursor(awtPredefinedCursor);
            if (mainChartPanel.getComponents().length > 0) {
              mainChartPanel.getComponent(0).setCursor(awtPredefinedCursor);
            }
          }
        };
    EventQueue.invokeLater(runnable);
  }
示例#2
0
  @Override
  public void endRefreshAction(List<Exception> exceptions) {

    chartDisplayStrategy.endRefreshAction(exceptions);
    try {
      logComposite.endJob(exceptions);
    } finally {
      getParent().getParent().setCursor(CursorFactory.getCursor(SWT.CURSOR_ARROW));
    }
  }
示例#3
0
 @Override
 public void initRefreshAction() {
   logComposite.initRefresh(this);
   getParent().getParent().setCursor(CursorFactory.getCursor(SWT.CURSOR_WAIT));
   chartDisplayStrategy.initRefreshAction();
 }
  @Override
  public void highLight(Integer idx, Stock selectedShare, Boolean recalculationGranted) {

    try {

      this.chartTarget.getShell().setEnabled(false);
      this.chartTarget.getParent().getParent().setCursor(CursorFactory.getCursor(SWT.CURSOR_WAIT));

      chartTarget.getMainChartWraper().setMainYAxisLabel("");
      if (idx == null || selectedShare == null) {
        return;
      }

      chartTarget.setHighligtedId(idx);
      chartTarget.getHightlitedEventModel().setViewParamRoot(selectedShare);

      if (chartTarget.isDisposed() || !chartTarget.isVisible()) {
        return;
      }

      if (!chartTarget.getChartedEvtDefsTrends().isEmpty()) {
        chartTarget.getMainChartWraper().resetBarChart();
      }
      if (!chartTarget.getChartedEvtDef().equals(EventDefinition.ZERO)) {
        chartTarget.getMainChartWraper().resetIndicChart();
      }

      hideAllButSelected(selectedShare);

      chartTarget.getMainChartWraper().setMainYAxisLabel(selectedShare.getFriendlyName());
      chartTarget.getMainChartWraper().highLightSerie(idx, 1);

      if (!chartTarget.getChartedEvtDefsTrends().isEmpty()
          || !chartTarget
              .getChartedEvtDef()
              .equals(EventDefinition.ZERO)) { // Some thing has to be displayed

        // We try and run
        try {
          Set<EventInfo> allEvtInfos = chartTarget.initChartedEvtDefsTrendsSet();
          allEvtInfos.addAll(chartTarget.getChartedEvtDefsTrends());
          if (!chartTarget.getChartedEvtDef().equals(EventDefinition.ZERO))
            allEvtInfos.add(chartTarget.getChartedEvtDef());

          HashSet<EventInfo> notUpToDateEventInfos = new HashSet<EventInfo>();
          Calendar minDate = Calendar.getInstance();
          minDate.setTime(new Date(0));
          Boolean needsUpdate =
              chartTarget
                  .getHightlitedEventModel()
                  .cacheNeedsUpdateCheck(
                      selectedShare,
                      chartTarget.getSlidingStartDate(),
                      chartTarget.getSlidingEndDate(),
                      notUpToDateEventInfos,
                      minDate,
                      allEvtInfos.toArray(new EventInfo[0]));

          if (needsUpdate) {
            eventsRecalculationAck(
                selectedShare,
                chartTarget.getSlidingStartDate(),
                chartTarget.getSlidingEndDate(),
                notUpToDateEventInfos,
                minDate);
          }

          if (!chartTarget.getChartedEvtDef().equals(EventDefinition.ZERO)) {
            updateChartIndicator(selectedShare, recalculationGranted, needsUpdate);
          } else {
            if (chartSettingsPopup != null
                && !chartSettingsPopup.getSelectionShell().isDisposed()) {
              chartSettingsPopup.getSelectionShell().dispose();
            }
          }

          if (!chartTarget.getChartedEvtDefsTrends().isEmpty()) {
            updateBarChart(
                selectedShare,
                chartTarget.getSlidingStartDate(),
                recalculationGranted,
                needsUpdate);
          }

        } catch (Exception e) {
          LOGGER.error(e, e);
        }
      }

      if (chartTarget.getChartedEvtDef() != null
          && chartTarget.getChartedEvtDef().equals(EventDefinition.ZERO))
        chartTarget.getMainChartWraper().resetIndicChart();
      if (chartTarget.getChartedEvtDefsTrends().isEmpty())
        chartTarget.getMainChartWraper().resetBarChart();

      if (chartTarget.getChartedEvtDefsTrends().isEmpty()
          && (chartTarget.getChartedEvtDef() == null
              || chartTarget.getChartedEvtDef().equals(EventDefinition.ZERO))) {
        String errorMessage =
            "No Calculator or Trend is selected.\n Use the buttons below the chart to select a calculator and trends.";
        showPopupDialog(errorMessage, "Ok", null, null);
      }

    } finally {

      this.chartTarget.getShell().setEnabled(true);
      this.chartTarget.getParent().getParent().setCursor(CursorFactory.getCursor(SWT.CURSOR_ARROW));
    }
  }