示例#1
0
  /**
   * This method initializes the class, by loading properties, texts and setting the endpoint.
   *
   * @throws IOException
   */
  public void initialize() throws IOException {

    // load properties
    InputStream inputStream = this.getClass().getResourceAsStream(PROPERTIES_FILE_LOCATION);
    if (inputStream == null) {
      throw new IllegalArgumentException(
          "Could not load properties from classpath (" + PROPERTIES_FILE_LOCATION + ")");
    }
    props.load(inputStream);

    // load text
    InputStream languageStream = null;

    // try to get language form property file
    if (props.containsKey("Language")) {
      languageStream =
          this.getClass()
              .getResourceAsStream("/props/ALEClient_" + props.getProperty("Language") + ".lang");
    }

    // try system default language
    if (languageStream == null) {
      languageStream =
          this.getClass()
              .getResourceAsStream(
                  "/props/ALEClient_" + SYSTEM_DEFAULT_LOCALE.getLanguage() + ".lang");
    }

    // try default language
    if (languageStream == null) {
      languageStream =
          this.getClass()
              .getResourceAsStream("/props/ALEClient_" + DEFAULT_LOCALE.getLanguage() + ".lang");
    }

    if (languageStream == null) {
      throw new IllegalArgumentException(
          "Could not load language package from classpath (" + DEFAULT_LOCALE + ")");
    }
    guiText = new PropertyResourceBundle(languageStream);

    // set endpoint
    aleProxy.setEndpoint(props.getProperty("EndPoint"));

    initializeGUI();
  }
示例#2
0
  /**
   * This method adds a specification name combobox to the panel.
   *
   * @param panel to which the specification name combobox should be added
   */
  private void addECSpecNameComboBox(JPanel panel) {

    specNameComboBox = new JComboBox();
    specNameComboBox.setEditable(true);
    specNameComboBox.addItem(null);

    String[] ecSpecNames;
    try {
      ecSpecNames = aleProxy.getECSpecNames(new EmptyParms());
      if (ecSpecNames != null && ecSpecNames.length > 0) {
        Arrays.sort(ecSpecNames, String.CASE_INSENSITIVE_ORDER);
        for (String specName : ecSpecNames) {
          specNameComboBox.addItem(specName);
        }
      }
    } catch (RemoteException e) {
    }

    panel.add(new JLabel(guiText.getString("SpecNameLabel")));
    panel.add(specNameComboBox);
  }
示例#3
0
  /**
   * This method executes the command which is selected in the command selection combobox with the
   * parameters which are set in the corresponding fields. To execute the commands, the methods of
   * the ale proxy will be invoked.
   */
  private void executeCommand() {

    Object result = null;
    String specName = null;
    String notificationURI = null;

    try {

      switch (commandSelection.getSelectedIndex()) {
        case 4: // getECSpecNames
          result = aleProxy.getECSpecNames(new EmptyParms());
          break;

        case 10: // getStandardVersion
          result = aleProxy.getStandardVersion(new EmptyParms());
          break;

        case 11: // getVendorVersion
          result = aleProxy.getVendorVersion(new EmptyParms());
          break;

        case 2: // undefine
        case 3: // getECSpec
        case 7: // poll
        case 9: // getSubscribers
          // get specName
          specName = (String) specNameComboBox.getSelectedItem();
          if (specName == null || "".equals(specName)) {
            showExcpetionDialog(guiText.getString("SpecNameNotSpecifiedDialog"));
            break;
          }

          switch (commandSelection.getSelectedIndex()) {
            case 2: // undefine
              Undefine undefineParms = new Undefine();
              undefineParms.setSpecName(specName);
              aleProxy.undefine(undefineParms);
              result = guiText.getString("SuccessfullyUndefinedMessage");
              break;

            case 3: // getECSpec
              GetECSpec getECSpecParms = new GetECSpec();
              getECSpecParms.setSpecName(specName);
              result = aleProxy.getECSpec(getECSpecParms);
              break;

            case 7: // poll
              Poll pollParms = new Poll();
              pollParms.setSpecName(specName);
              result = aleProxy.poll(pollParms);
              break;

            case 9: // getSubscribers
              GetSubscribers getSubscribersParms = new GetSubscribers();
              getSubscribersParms.setSpecName(specName);
              result = aleProxy.getSubscribers(getSubscribersParms);
              break;
          }

          break;

        case 5: // subscribe
        case 6: // unsubscribe
          // get specName
          specName = (String) specNameComboBox.getSelectedItem();
          if (specName == null || "".equals(specName)) {
            showExcpetionDialog(guiText.getString("SpecNameNotSpecifiedDialog"));
            break;
          }

          // get notificationURI
          notificationURI = notificationUriField.getText();
          if (notificationURI == null || "".equals(notificationURI)) {
            showExcpetionDialog(guiText.getString("NotificationUriNotSpecifiedDialog"));
            break;
          }

          switch (commandSelection.getSelectedIndex()) {
            case 5:
              Subscribe subscribeParms = new Subscribe();
              subscribeParms.setSpecName(specName);
              subscribeParms.setNotificationURI(notificationURI);
              aleProxy.subscribe(subscribeParms);
              result = guiText.getString("SuccessfullySubscribedMessage");
              break;

            case 6:
              Unsubscribe unsubscribeParms = new Unsubscribe();
              unsubscribeParms.setSpecName(specName);
              unsubscribeParms.setNotificationURI(notificationURI);
              aleProxy.unsubscribe(unsubscribeParms);
              result = guiText.getString("SuccessfullyUnsubscribedMessage");
              break;
          }

          break;

        case 1: // define
        case 8: // immediate
          if (commandSelection.getSelectedIndex() == 1) {
            // get specName
            specName = (String) specNameComboBox.getSelectedItem();
            if (specName == null || "".equals(specName)) {
              showExcpetionDialog(guiText.getString("SpecNameNotSpecifiedDialog"));
              break;
            }
          }

          // get filePath
          String filePath = filePathField.getText();
          if (filePath == null || "".equals(filePath)) {
            showExcpetionDialog(guiText.getString("FilePathNotSpecifiedDialog"));
            break;
          }

          // get ecSpec
          ECSpec ecSpec;
          try {
            ecSpec = getECSpecFromFile(filePath);
          } catch (FileNotFoundException e) {
            showExcpetionDialog(guiText.getString("FileNotFoundDialog"));
            break;
          } catch (Exception e) {
            showExcpetionDialog(guiText.getString("UnexpectedFileFormatDialog"));
            break;
          }

          if (commandSelection.getSelectedIndex() == 1) {
            Define defineParms = new Define();
            defineParms.setSpecName(specName);
            defineParms.setSpec(ecSpec);
            aleProxy.define(defineParms);
            result = guiText.getString("SuccessfullyDefinedMessage");
          } else {
            Immediate immediateParms = new Immediate();
            immediateParms.setSpec(ecSpec);
            result = aleProxy.immediate(immediateParms);
          }
          break;
      }

    } catch (RemoteException e) {
      if (e instanceof ALEException) {
        String reason = ((ALEException) e).getReason();
        if (e instanceof DuplicateNameException) {
          showExcpetionDialog(guiText.getString("DuplicateNameExceptionDialog"), reason);
        } else if (e instanceof DuplicateSubscriptionException) {
          showExcpetionDialog(guiText.getString("DuplicateSubscriptionExceptionDialog"), reason);
        } else if (e instanceof ECSpecValidationException) {
          showExcpetionDialog(guiText.getString("ECSpecValidationExceptionDialog"), reason);
        } else if (e instanceof ImplementationException) {
          showExcpetionDialog(guiText.getString("ImplementationExceptionDialog"), reason);
        } else if (e instanceof InvalidURIException) {
          showExcpetionDialog(guiText.getString("InvalidURIExceptionDialog"), reason);
        } else if (e instanceof NoSuchNameException) {
          showExcpetionDialog(guiText.getString("NoSuchNameExceptionDialog"), reason);
        } else if (e instanceof NoSuchSubscriberException) {
          showExcpetionDialog(guiText.getString("NoSuchSubscriberExceptionDialog"), reason);
        } else if (e instanceof SecurityException) {
          showExcpetionDialog(guiText.getString("SecurityExceptionDialog"), reason);
        }
      } else {
        if (e instanceof AxisFault
            && "java.net.ConnectException: Connection refused: connect"
                .equals(((AxisFault) e).getFaultReason())) {
          showExcpetionDialog(
              guiText.getString("ConnectionExceptionDialog"), props.getProperty("EndPoint"));
        } else {
          showExcpetionDialog(guiText.getString("UnknownExceptionDialog"), e.getMessage());
        }
      }
    }

    showResult(result);

    // update spec name combobox
    String[] ecSpecNames = null;
    try {
      ecSpecNames = aleProxy.getECSpecNames(new EmptyParms());
    } catch (RemoteException e) {
    }
    if (ecSpecNames != null
        && specNameComboBox != null
        && specNameComboBox.getSelectedObjects() != null
        && specNameComboBox.getSelectedObjects().length > 0) {
      String current = (String) specNameComboBox.getSelectedObjects()[0];
      Arrays.sort(ecSpecNames, String.CASE_INSENSITIVE_ORDER);
      specNameComboBox.removeAllItems();
      if (ecSpecNames != null && ecSpecNames.length > 0) {
        for (String name : ecSpecNames) {
          specNameComboBox.addItem(name);
        }
      }
      specNameComboBox.setSelectedItem(current);
    }
  }