protected SymbolEvents constructEvent(
      String eventListName,
      ScreeningSupplementedStock screenedStock,
      EventDefinition eventDefinition,
      Integer rank,
      Integer previousRank,
      EventType eventType,
      String message,
      Date eventDate) {

    ConcurrentSkipListMap<EventKey, EventValue> eventMap =
        new ConcurrentSkipListMap<EventKey, EventValue>();

    EventKey key = new StandardEventKey(eventDate, eventDefinition, eventType);
    message = message + ". Rank is : --" + rank + "--";
    if (previousRank != null) message = message + " and was " + previousRank;
    EventValue value =
        new AlertEventValue(eventDate, eventType, eventDefinition, message, eventListName);
    eventMap.put(key, value);
    SymbolEvents symbolEvents =
        new SymbolEvents(
            screenedStock.getStock(),
            eventMap,
            EventDefinition.loadMaxPassPrefsEventInfo(),
            EventState.STATE_TERMINATED);
    return symbolEvents;
  }
  private void initEvtDefTrendPopup(Boolean activate) {

    Set<EventInfo> availEventDefs = EventDefinition.loadMaxPassPrefsEventInfo();
    ActionDialogAction disactivateAction =
        new ActionDialogAction() {

          @Override
          public void action(Control targetControl) {

            Stock viewStateParams = chartTarget.getHightlitedEventModel().getViewParamRoot();
            if (viewStateParams != null) {
              highLight(chartTarget.getHighligtedId(), viewStateParams, true);
            } else {
              if (chartTarget.getChartedEvtDefsTrends() != null
                  && !chartTarget.getChartedEvtDefsTrends().isEmpty()) {
                String errorMessage =
                    "You must select a share in the portfolio to display its analysis.";
                showPopupDialog(errorMessage, "Ok", null, null);
              }
            }
          }
        };

    if (evtDefTrendPopupMenu == null || evtDefTrendPopupMenu.getSelectionShell().isDisposed()) {

      evtDefTrendPopupMenu =
          new PopupMenu<EventInfo>(
              chartTarget,
              evtDefsTrendChartingBut,
              availEventDefs,
              chartTarget.getChartedEvtDefsTrends(),
              false,
              true,
              SWT.CHECK,
              null,
              disactivateAction,
              true);
      Rectangle parentBounds =
          chartTarget.getDisplay().map(chartTarget, null, chartTarget.getBounds());
      evtDefTrendPopupMenu.open(
          new Point(parentBounds.x + parentBounds.width, parentBounds.y + parentBounds.height / 2),
          true);

    } else {

      evtDefTrendPopupMenu.updateAction(
          availEventDefs, chartTarget.getChartedEvtDefsTrends(), null, disactivateAction, true);
      evtDefTrendPopupMenu.getSelectionShell().setVisible(true);
      if (activate) {
        evtDefTrendPopupMenu.getSelectionShell().setActive();
        evtDefTrendPopupMenu.getSelectionShell().setFocus();
      }
    }
  }
Beispiel #3
0
  protected void checkChartSelectionValidity() {
    try {
      chartedEvtDef = EventDefinition.valueOfEventInfo(chartedEvtDef.getEventDefinitionRef());
    } catch (NoSuchFieldException e) {
      LOGGER.warn(
          "Event info as been disabled or deleted. Removing from chart indicators selection : "
              + chartedEvtDef);
      chartedEvtDef = EventDefinition.ZERO;
    }

    SortedSet<EventInfo> updatedChartedEvtDefsTrends = initChartedEvtDefsTrendsSet();
    for (EventInfo eventInfo : chartedEvtDefsTrends) {
      try {
        updatedChartedEvtDefsTrends.add(
            EventDefinition.valueOfEventInfo(eventInfo.getEventDefinitionRef()));
      } catch (NoSuchFieldException e) {
        LOGGER.warn(
            "Event info as been disabled or deleted. Removing from chart trend selection : "
                + eventInfo);
      }
    }
    chartedEvtDefsTrends = updatedChartedEvtDefsTrends;
  }
Beispiel #4
0
  @Override
  public void refreshView(List<Exception> exceptions) {

    EventDefinition.refreshMaxPassPrefsEventInfo();

    Stock viewStateParams = hightlitedEventModel.getViewParamRoot();
    if (viewStateParams != null) {
      checkChartSelectionValidity();
      chartDisplayStrategy.highLight(highligtedId, viewStateParams, false);
    }
    chartDisplayStrategy.refreshView(exceptions);

    if (isVisible()) {
      Shell[] childrenShells = this.getShell().getShells();
      for (Shell child : childrenShells) {
        if (child.getText().contains("Warning")) child.forceActive();
      }
    }
  }
Beispiel #5
0
  private void initGui() {

    GridLayout layout = new GridLayout(2, true);
    shell.setLayout(layout);
    shell.setBackground(MainGui.pOPUP_BG);

    {
      Label evtOccSpanLab = new Label(shell, SWT.NONE);
      GridData labelLayoutData = new GridData(SWT.FILL, SWT.TOP, true, false);
      evtOccSpanLab.setLayoutData(labelLayoutData);
      evtOccSpanLab.setBackground(MainGui.pOPUP_BG);
      evtOccSpanLab.setFont(MainGui.DEFAULTFONT);
      evtOccSpanLab.setText("Trend event days span");
      evtOccSpanLab.setToolTipText(
          "Trend events can be represented with a validity span, reflected in the width of the bars.\nZero means that the trend event is valid until an other event occurs.");

      final Text evtOccSpanTxt = new Text(shell, SWT.NONE);
      GridData txtLayoutData = new GridData(SWT.FILL, SWT.TOP, true, false);
      evtOccSpanTxt.setLayoutData(txtLayoutData);
      evtOccSpanTxt.setFont(MainGui.DEFAULTFONT);
      evtOccSpanTxt.setText("" + barChartSettings.getMaxFill());

      Listener listener =
          new Listener() {
            public void handleEvent(Event e) {
              try {
                barChartSettings.setMaxFill(Integer.valueOf(evtOccSpanTxt.getText()));
                action.action(null);
              } catch (NumberFormatException pe) {
                UserDialog inst = new UserDialog(shell, pe.getMessage(), null);
                inst.open();
                evtOccSpanTxt.setText("" + barChartSettings.getMaxFill());
              }
            }
          };
      evtOccSpanTxt.addListener(SWT.FocusOut, listener);
      evtOccSpanTxt.addListener(SWT.DefaultSelection, listener);
    }
    {
      final Button isReachTop = new Button(shell, SWT.CHECK);
      GridData layoutData = new GridData(SWT.FILL, SWT.TOP, true, false);
      layoutData.horizontalSpan = 2;
      isReachTop.setLayoutData(layoutData);
      isReachTop.setBackground(MainGui.pOPUP_BG);
      isReachTop.setFont(MainGui.DEFAULTFONT);
      isReachTop.setText("Draw bars to the top");
      isReachTop.setToolTipText(
          "All the bars will at the top, overlapping each other with transparency.\nIf unchecked, bars stop at label level.");
      isReachTop.addSelectionListener(
          new SelectionListener() {

            @Override
            public void widgetSelected(SelectionEvent e) {
              handle();
            }

            @Override
            public void widgetDefaultSelected(SelectionEvent e) {
              handle();
            }

            private void handle() {
              barChartSettings.setIsReachTop(isReachTop.getSelection());
              action.action(null);
            }
          });
      isReachTop.setSelection(barChartSettings.getIsReachTop());
    }
    {
      final Button isZeroBase = new Button(shell, SWT.CHECK);
      GridData layoutData = new GridData(SWT.FILL, SWT.TOP, true, false);
      layoutData.horizontalSpan = 2;
      isZeroBase.setLayoutData(layoutData);
      isZeroBase.setBackground(MainGui.pOPUP_BG);
      isZeroBase.setFont(MainGui.DEFAULTFONT);
      isZeroBase.setText("Draw bars to the base");
      isZeroBase.setToolTipText(
          "All the bars will start at zero, overlapping each other with transparency.\nIf unchecked, bars stop at label level.");
      isZeroBase.addSelectionListener(
          new SelectionListener() {

            @Override
            public void widgetSelected(SelectionEvent e) {
              handle();
            }

            @Override
            public void widgetDefaultSelected(SelectionEvent e) {
              handle();
            }

            private void handle() {
              barChartSettings.setIsZerobased(isZeroBase.getSelection());
              action.action(null);
            }
          });
      isZeroBase.setSelection(barChartSettings.getIsZeroBased());
    }
    {
      sideBySide = new Button(shell, SWT.CHECK);
      GridData layoutData = new GridData(SWT.FILL, SWT.TOP, true, false);
      layoutData.horizontalSpan = 2;
      sideBySide.setLayoutData(layoutData);
      sideBySide.setBackground(MainGui.pOPUP_BG);
      sideBySide.setFont(MainGui.DEFAULTFONT);
      sideBySide.setText("Display side by side");
      sideBySide.setToolTipText(
          "Bar are displayed side by side, form top to bottom.\n"
              + "For this to be working, the event validity days span has to be above the number of indicators involved.");
      sideBySide.addSelectionListener(
          new SelectionListener() {

            @Override
            public void widgetSelected(SelectionEvent e) {
              handle();
            }

            @Override
            public void widgetDefaultSelected(SelectionEvent e) {
              handle();
            }

            private void handle() {
              barChartSettings.setSideBySide(sideBySide.getSelection());
              action.action(null);
            }
          });
      sideBySide.addMouseMoveListener(
          new MouseMoveListener() {

            @Override
            public void mouseMove(MouseEvent e) {
              sideBySide.setToolTipText(
                  "Bar are displayed side by side, form top to bottom.\n"
                      + "For this to be working, the event validity days span has to be above the number of indicators involved.\n"
                      + "I.e. : "
                      + chartTarget.getChartedEvtDefsTrends().size());
            }
          });
      sideBySide.setSelection(barChartSettings.getSideBySide());
    }
    {
      final Button isGradient = new Button(shell, SWT.CHECK);
      GridData layoutData = new GridData(SWT.FILL, SWT.TOP, true, false);
      layoutData.horizontalSpan = 2;
      isGradient.setLayoutData(layoutData);
      isGradient.setBackground(MainGui.pOPUP_BG);
      isGradient.setFont(MainGui.DEFAULTFONT);
      isGradient.setText("Progressive opacity");
      isGradient.setToolTipText(
          "Bar are displayed using a progressive opacity.\nIf unchecked, bars are using the same opacity");
      isGradient.addSelectionListener(
          new SelectionListener() {

            @Override
            public void widgetSelected(SelectionEvent e) {
              handle();
            }

            @Override
            public void widgetDefaultSelected(SelectionEvent e) {
              handle();
            }

            private void handle() {
              barChartSettings.setIsGradient(isGradient.getSelection());
              action.action(null);
            }
          });
      isGradient.setSelection(barChartSettings.getIsGradiant());
    }
    {
      final Spinner alphaSpinner = new Spinner(shell, SWT.WRAP | SWT.READ_ONLY);
      GridData layoutData = new GridData(SWT.FILL, SWT.TOP, false, false);
      layoutData.horizontalSpan = 2;
      alphaSpinner.setLayoutData(layoutData);
      alphaSpinner.setFont(MainGui.DEFAULTFONT);
      int digits = 1;
      alphaSpinner.setDigits(digits);
      alphaSpinner.setMinimum(5);
      alphaSpinner.setMaximum(EventDefinition.loadMaxPassPrefsEventInfo().size() * 10);
      alphaSpinner.setIncrement(5);
      alphaSpinner.setSelection((int) (barChartSettings.getAlphaDividend() * Math.pow(10, digits)));
      alphaSpinner.setToolTipText(
          "For a better visibility of the result, You can change the opacity of the charted trend.\n"
              + "You must select a share in the portfolio to display its analysis\n"
              + "You also must choose the trends you want to display using the '"
              + ChartIndicatorDisplay.TRENDBUTTXT
              + "' button.");
      alphaSpinner.addSelectionListener(
          new SelectionAdapter() {

            public void widgetSelected(SelectionEvent e) {
              int selection = alphaSpinner.getSelection();
              int digits = alphaSpinner.getDigits();
              barChartSettings.setAlphaDividend(selection / Math.pow(10, digits));
            }
          });
      alphaSpinner.addListener(
          SWT.MouseExit,
          new Listener() {

            public void handleEvent(Event arg0) {
              if (!barChartSettings.getAlphaDividend().equals(initialAlphaDividend)) {
                action.action(null);
                initialAlphaDividend = barChartSettings.getAlphaDividend();
              }
            }
          });
    }
  }
  private void initEvtChartingPopup(Boolean activatePopup) {

    Set<EventInfo> availEventDefs =
        new HashSet<EventInfo>(EventDefinition.loadMaxPassPrefsEventInfo());
    availEventDefs.add(EventDefinition.ZERO);
    final Set<EventInfo> chartedEvtDefTmpSet = new HashSet<EventInfo>();
    chartedEvtDefTmpSet.add(chartTarget.getChartedEvtDef());

    ActionDialogAction action =
        new ActionDialogAction() {

          @Override
          public void action(Control targetControl) {

            Stock viewStateParams = chartTarget.getHightlitedEventModel().getViewParamRoot();
            if (!chartedEvtDefTmpSet.isEmpty()) {
              // changing evtdef selection
              chartTarget.setChartedEvtDef(chartedEvtDefTmpSet.iterator().next());
              // if stock selected, we update
              boolean stockSelected = viewStateParams != null;
              if (stockSelected) {
                highLight(chartTarget.getHighligtedId(), viewStateParams, true);
              } else {
                // warning only if evtdef selected and no stock
                if (chartTarget.getChartedEvtDef() != null
                    && !chartTarget.getChartedEvtDef().equals(EventDefinition.ZERO)) {
                  String errorMessage =
                      "You must select a share in the portfolio to display its analysis.";
                  showPopupDialog(errorMessage, "Ok", null, null);
                }
              }
            }
          }
        };

    if (evtDefChartingPopupMenu == null
        || evtDefChartingPopupMenu.getSelectionShell().isDisposed()) {

      evtDefChartingPopupMenu =
          new PopupMenu<EventInfo>(
              chartTarget,
              evtDefsChartingBut,
              availEventDefs,
              chartedEvtDefTmpSet,
              false,
              false,
              SWT.RADIO,
              action);
      Rectangle parentBounds =
          chartTarget.getDisplay().map(chartTarget, null, chartTarget.getBounds());
      evtDefChartingPopupMenu.open(
          new Point(parentBounds.x + parentBounds.width, parentBounds.y + parentBounds.height / 2),
          false);

    } else {

      evtDefChartingPopupMenu.updateAction(availEventDefs, chartedEvtDefTmpSet, action, null, null);
      evtDefChartingPopupMenu.getSelectionShell().setVisible(true);
      if (activatePopup) {
        evtDefChartingPopupMenu.getSelectionShell().setActive();
        evtDefChartingPopupMenu.getSelectionShell().setFocus();
      }
    }
  }