示例#1
0
  /**
   * Executes the spatial search using the search string provided.
   *
   * @param searchString
   * @param listModel
   */
  @Override
  public void onNewSearchString(final String searchString, final DefaultListModel listModel) {

    // No serach is selected
    if (this.searchByObject == null) {
      return;
    }

    // Check if a map search is currently running and if so, cancel it
    if (searchTask != null && TaskManager.getInstance().isTaskRunning(searchTask.getId())) {
      TaskManager.getInstance().removeTask(searchTask);
    }

    final List<SpatialSearchResultTO> searchResults = new ArrayList<SpatialSearchResultTO>();
    final String queryName = this.searchByObject.getQueryName();
    final String searchTitle = this.searchByObject.getTitle();
    listModel.clear();

    searchTask =
        new SolaTask<Void, Void>() {

          @Override
          public Void doTask() {
            // Perform the search on a background thread
            setMessage(
                MessageUtility.getLocalizedMessage(
                        ClientMessage.PROGRESS_MSG_MAP_SEARCHING, new String[] {searchTitle})
                    .getMessage());
            try {
              // Allow a small delay on the background thread so that the tread can be cancelled
              // before executing the search if the user is still typing.
              Thread.sleep(500);
              searchResults.addAll(
                  WSManager.getInstance()
                      .getSearchService()
                      .searchSpatialObjects(queryName, searchString, map.getSrid()));
            } catch (InterruptedException ex) {
            }
            return null;
          }

          @Override
          public void taskDone() {
            // Update the GUI using the primary EDT thread
            if (searchResults.size() > 0) {
              // Convert the TOs to Beans
              List<SpatialSearchResultBean> beanList =
                  TypeConverters.TransferObjectListToBeanList(
                      searchResults, SpatialSearchResultBean.class, null);
              // Sort the beans and then display them in the list.
              Collections.sort(beanList);
              for (SpatialSearchResultBean bean : beanList) {
                listModel.addElement(bean);
              }
            }
          }
        };
    TaskManager.getInstance().runTask(searchTask);
  }
  private void openRightHolderForm(
      final PartySummaryBean partySummaryBean, final boolean isReadOnly) {
    final RightHolderFormListener listener = new RightHolderFormListener();

    SolaTask t =
        new SolaTask<Void, Void>() {

          @Override
          public Void doTask() {
            setMessage(
                MessageUtility.getLocalizedMessageText(ClientMessage.PROGRESS_MSG_OPEN_PERSON));
            PartyPanelForm partyForm;

            if (partySummaryBean != null) {
              partyForm = new PartyPanelForm(true, partySummaryBean, isReadOnly, true);
            } else {
              partyForm = new PartyPanelForm(true, null, isReadOnly, true);
            }
            partyForm.addPropertyChangeListener(listener);
            getMainContentPanel().addPanel(partyForm, MainContentPanel.CARD_PERSON, true);
            return null;
          }
        };
    TaskManager.getInstance().runTask(t);
  }
  private void openSelectRightHolderForm() {
    final RightHolderFormListener listener = new RightHolderFormListener();

    SolaTask t =
        new SolaTask<Void, Void>() {

          @Override
          public Void doTask() {
            setMessage(
                MessageUtility.getLocalizedMessageText(ClientMessage.PROGRESS_MSG_OPEN_PERSON));
            PartySearchPanelForm partySearchForm = null;

            partySearchForm = initializePartySearchForm(partySearchForm);

            partySearchForm.addPropertyChangeListener(listener);
            getMainContentPanel()
                .addPanel(partySearchForm, MainContentPanel.CARD_SEARCH_PERSONS, true);
            return null;
          }
        };
    TaskManager.getInstance().runTask(t);
  }
示例#4
0
  /** Creates new instance of panel. */
  public TaskPanel() {
    initComponents();

    ResourceBundle resourceBundle =
        java.util.ResourceBundle.getBundle(
            "org/sola/clients/swing/common/tasks/resources/TaskPanel");

    int busyAnimationRate =
        Integer.parseInt(resourceBundle.getString("StatusBar.busyAnimationRate"));
    for (int i = 0; i < busyIcons.length; i++) {
      busyIcons[i] =
          new ImageIcon(
              getClass()
                  .getResource(
                      "/org/sola/clients/swing/common/tasks/resources/busyicons/busy-icon"
                          + i
                          + ".png"));
    }

    busyIconTimer =
        new Timer(
            busyAnimationRate,
            new ActionListener() {

              @Override
              public void actionPerformed(ActionEvent e) {
                busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
                statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
              }
            });

    idleIcon =
        new ImageIcon(
            getClass()
                .getResource(
                    "/org/sola/clients/swing/common/tasks/resources/busyicons/idle-icon.png"));
    statusAnimationLabel.setIcon(idleIcon);
    pnlProgressBar.setVisible(false);

    TaskManager.getInstance()
        .addPropertyChangeListener(
            new java.beans.PropertyChangeListener() {

              @Override
              public void propertyChange(java.beans.PropertyChangeEvent evt) {
                String propertyName = evt.getPropertyName();

                if (propertyName.equals(SolaTask.EVENT_STATE)) {
                  StateValue state = (StateValue) evt.getNewValue();
                  if (state.name().equals(SolaTask.TASK_STARTED)) {
                    pnlProgressBar.setVisible(true);
                    if (!busyIconTimer.isRunning()) {
                      statusAnimationLabel.setIcon(busyIcons[0]);
                      busyIconIndex = 0;
                      busyIconTimer.start();
                    }
                    progressBar.setIndeterminate(true);
                  }
                  if (state.name().equals(SolaTask.TASK_DONE)) {
                    stopAnimation();
                  }
                } else if (SolaTask.REMOVE_TASK.equals(propertyName)) {
                  stopAnimation();
                } else if (SolaTask.EVENT_MESSAGE.equals(propertyName)) {
                  String text = (String) (evt.getNewValue());
                  statusMessageLabel.setText((text == null) ? "" : text);
                } else if (SolaTask.EVENT_PROGRESS.equals(propertyName)) {
                  int value = (Integer) (evt.getNewValue());
                  progressBar.setIndeterminate(false);
                  progressBar.setValue(value);
                }
              }

              private void stopAnimation() {
                busyIconTimer.stop();
                statusMessageLabel.setText(null);
                statusAnimationLabel.setIcon(idleIcon);
                pnlProgressBar.setVisible(false);
                progressBar.setValue(0);
              }
            });
  }