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(); } } }
private void initChartSettingsPopup(Boolean activatePopup) { try { boolean isIndicatorSelected = chartTarget.getChartedEvtDef() != null && !chartTarget.getChartedEvtDef().equals(EventDefinition.ZERO); boolean isEmptyOutputIndicator = false; boolean isClearInProgress = false; String errorMessage = "Only user defined calculators can be customised.\n" + "You must select one of your user defined calculators in '" + INDICATORSBUTTXT + "'\n" + "And wait for its calculation to finish before changing the display settings.\n" + "New calculators can be defined using the menu Events -> Customise and create calculators ..."; if (isIndicatorSelected) { final Set<OutputDescr> availableOutputs = new TreeSet<OutputDescr>(); final Set<OutputDescr> displayedOutputs = new TreeSet<OutputDescr>(); try { availableOutputs.addAll( chartTarget.getChartedEvtDef().getEventDefDescriptor().allOutputs()); displayedOutputs.addAll( chartTarget.getChartedEvtDef().getEventDefDescriptor().displayedOutputs()); } catch (NoSuchElementException e) { // errorMessage = e.toString() + "\n\n" +errorMessage; isClearInProgress = true; LOGGER.warn(e); } if (!availableOutputs.isEmpty()) { ActionDialogAction disactivateAction = new ActionDialogAction() { @Override public void action(Control targetControl) { for (OutputDescr outputDescr : availableOutputs) { if (displayedOutputs.contains(outputDescr)) { outputDescr.setDisplayOnChart(true); } else { outputDescr.setDisplayOnChart(false); } } Stock viewStateParams = chartTarget.getHightlitedEventModel().getViewParamRoot(); highLight(chartTarget.getHighligtedId(), viewStateParams, true); } }; if (chartSettingsPopup == null || chartSettingsPopup.getSelectionShell().isDisposed()) { chartSettingsPopup = new PopupMenu<OutputDescr>( chartTarget, indicSettings, availableOutputs, displayedOutputs, false, true, SWT.CHECK, null, disactivateAction, true); Rectangle parentBounds = chartTarget.getDisplay().map(chartTarget, null, chartTarget.getBounds()); chartSettingsPopup.open( new Point(parentBounds.x + parentBounds.width, parentBounds.y), false); } else { chartSettingsPopup.updateAction( availableOutputs, displayedOutputs, null, disactivateAction, true); chartSettingsPopup.getSelectionShell().setVisible(true); if (activatePopup) { chartSettingsPopup.getSelectionShell().setActive(); chartSettingsPopup.getSelectionShell().setFocus(); } } } else { if (chartSettingsPopup != null && !chartSettingsPopup.getSelectionShell().isDisposed()) { chartSettingsPopup.getSelectionShell().dispose(); } isEmptyOutputIndicator = true; } } if (!isIndicatorSelected || (!isClearInProgress && isEmptyOutputIndicator)) { showPopupDialog( "No calculator selected or No settings available for the selected calculator.", "Ok", errorMessage, null); } } catch (Exception e) { LOGGER.warn(e, e); showPopupDialog(e.getMessage(), "Ok", null, null); } }
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(); } } }