예제 #1
0
 /** Creates a new ProgressWatch object. */
 private ProgressWatch() {
   // FIXME: it is highly desirable to have a customised scheduledThreadPool since there are some
   // issues that
   // will go uncaught
   poller =
       Executors.newScheduledThreadPool(
           5, SudplanConcurrency.createThreadFactory("progress-watch")); // NOI18N
   deregisterDispatcher =
       CismetExecutors.newSingleThreadExecutor(
           SudplanConcurrency.createThreadFactory("deregister-dispatcher")); // NOI18N
 }
  @Override
  public void readSettings(final Object settings) {
    wizard = (WizardDescriptor) settings;
    spsError = null;
    scenario = (String) wizard.getProperty(RainfallDownscalingWizardAction.PROP_SCENARIO);
    scenarios = new String[] {};

    SudplanConcurrency.getSudplanGeneralPurposePool()
        .execute(
            new Runnable() {

              @Override
              public void run() {
                try {
                  final DataHandler dh =
                      DataHandlerCache.getInstance()
                          .getSPSDataHandler(
                              RainfallDownscalingModelManager.RF_SPS_LOOKUP,
                              RainfallDownscalingModelManager.RF_SPS_URL);
                  final Properties filter = new Properties();
                  filter.put(
                      TimeSeries.PROCEDURE, RainfallDownscalingModelManager.RF_TS_DS_PROCEDURE);
                  final Datapoint dp = dh.createDatapoint(filter, null, DataHandler.Access.READ);
                  final InputDescriptor id =
                      (InputDescriptor)
                          dp.getProperties().get("jaxb_desc:climate_scenario"); // NOI18N
                  final List<String> scenarioList =
                      id.getDefinition()
                          .getCommonData()
                          .getCategory()
                          .getConstraint()
                          .getAllowedTokens()
                          .getValueList()
                          .get(0)
                          .getValue();
                  scenarios = scenarioList.toArray(new String[scenarioList.size()]);
                } catch (final Exception ex) {
                  LOG.error("error during sps communication", ex); // NOI18N
                  spsError = ex;
                } finally {
                  EventQueue.invokeLater(
                      new Runnable() {

                        @Override
                        public void run() {
                          component.init();

                          fireChangeEvent();
                        }
                      });
                }
              }
            });

    component.init();
  }
 /** Creates a new TimeseriesTransmitter object. */
 private TimeseriesTransmitter() {
   executor =
       CismetExecutors.newCachedThreadPool(
           SudplanConcurrency.createThreadFactory("timeseries-transmitter")); // NOI18N
 }