Ejemplo n.º 1
0
  /* (non-Javadoc)
   * @see org.eclipse.ui.part.WorkbenchPart#dispose()
   */
  @Override
  public void dispose() {
    view.removeViewChangeListener(viewChangeListener);

    if (subsetHistory != null) {
      PropertyChangeSupport propertyChangeSupport =
          (PropertyChangeSupport) subsetHistory.getAdapter(PropertyChangeSupport.class);
      if (propertyChangeSupport != null) {
        propertyChangeSupport.removePropertyChangeListener(propertyChangeListener);
      }
    }

    if (UIActivator.getDefault() != null) {
      IPreferenceStore preferences = UIActivator.getDefault().getPreferenceStore();
      preferences.removePropertyChangeListener(preferenceChangeListener);
    }

    super.dispose();
  }
Ejemplo n.º 2
0
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
          if (IPropertyConstants.BARS.equals(evt.getPropertyName())) {
            TimeSpan resolution = TimeSpan.fromString(dialogSettings.get(K_RESOLUTION));
            view.setRootDataSeries(
                new OHLCDataSeries(
                    security.getName(), subsetHistory.getAdjustedOHLC(), resolution));
            Display.getDefault()
                .asyncExec(
                    new Runnable() {

                      @Override
                      public void run() {
                        if (!viewer.getControl().isDisposed()) {
                          refreshChart();
                        }
                      }
                    });
          }
        }
Ejemplo n.º 3
0
  void scheduleLoadJob() {
    final Display display = viewer.getControl().getDisplay();

    if (subsetHistory != null) {
      PropertyChangeSupport propertyChangeSupport =
          (PropertyChangeSupport) subsetHistory.getAdapter(PropertyChangeSupport.class);
      if (propertyChangeSupport != null) {
        propertyChangeSupport.removePropertyChangeListener(propertyChangeListener);
      }
    }

    ChartLoadJob job = new ChartLoadJob(security);
    job.addJobChangeListener(
        new JobChangeAdapter() {

          @Override
          public void done(IJobChangeEvent event) {
            final ChartLoadJob job = (ChartLoadJob) event.getJob();

            history = job.getHistory();
            subsetHistory = job.getSubsetHistory();
            view.setRootDataSeries(
                new OHLCDataSeries(
                    security.getName(),
                    subsetHistory.getAdjustedOHLC(),
                    job.getResolutionTimeSpan()));

            display.asyncExec(
                new Runnable() {

                  @Override
                  public void run() {
                    if (viewer.getControl().isDisposed()) {
                      return;
                    }

                    if (memento == null) {
                      memento = XMLMemento.createWriteRoot("root"); // $NON-NLS-1$
                    }
                    saveState(memento);

                    TimeSpan resolutionTimeSpan =
                        TimeSpan.fromString(dialogSettings.get(K_RESOLUTION));
                    if (resolutionTimeSpan == null) {
                      resolutionTimeSpan = TimeSpan.days(1);
                    }
                    viewer.setResolutionTimeSpan(resolutionTimeSpan);

                    dropListener.setView(view);

                    PropertyChangeSupport propertyChangeSupport =
                        (PropertyChangeSupport)
                            subsetHistory.getAdapter(PropertyChangeSupport.class);
                    if (propertyChangeSupport != null) {
                      propertyChangeSupport.addPropertyChangeListener(propertyChangeListener);
                    }

                    refreshChart();
                  }
                });
          }
        });
    job.setTimeSpan(TimeSpan.fromString(dialogSettings.get(K_PERIOD)));
    job.setResolutionTimeSpan(TimeSpan.fromString(dialogSettings.get(K_RESOLUTION)));
    job.setName(Messages.ChartViewPart_LoadingText + getPartName());
    job.setUser(true);
    job.schedule();
  }