Exemple #1
0
    /**
     * Constructs a course viewer form.
     * 
     * @param course
     *            The course that will be displayed
     */
    public CourseViewerForm(Course course) {
        initComponents();

        description.setText(course.getDescription());
        semester.setText(course.getSemester());
        lecturer.setText(course.getLecturer());
        advisor.setText(course.getAdvisor());
        targetAudience.setText(course.getTargetAudience());
        numberOfGroups.setText(String.valueOf(course.getNumberOfGroups()));
        AWHperGroup.setText(NumberFormat.getInstance().format(
            course.getUnqualifiedWorkingHours())
                + "h");
        bookedBudget.setText(NumberFormat.getInstance().format(
            (new CourseBudget(course)).getBookedBudget())
                + "h");
        totalBudget.setText(NumberFormat.getInstance().format(
            course.getNumberOfGroups() * course.getUnqualifiedWorkingHours())
                + "h");
        scope.setText(course.getScope());
        part.setText(String.valueOf(course.getPart()));
        group.setText(course.getGroup());
        remark.setText(course.getRemark());

        try {
            FinancialCategory fc = (new FinancialCategory()).getById(course
                .getFinancialCategoryId());

            financialCategory.setText(new UIFinancialCategory(fc).toString());
        } catch (SienaException e) {
            Logger.error(e.getMessage());
        }
    }
  public static void main(String[] args) {
    if (args.length != 1) {
      System.err.println("Usage: InterestedParty <server-address>");
      System.exit(1);
    }

    ThinClient mySiena;
    try {
      // accepts one argument with a String in the form <protocol>:<ipaddress>:<port>
      mySiena = new ThinClient(args[0]);

      Filter f = new Filter();
      f.addConstraint("tag", Op.EQ, "Antiques"); // interested only in Antiques
      f.addConstraint(
          "price", Op.LT, 4997); // interested only if their initial price is below 4,997$
      InterestedParty party = new InterestedParty();

      System.out.println("subscribing for " + f.toString());
      try {
        mySiena.subscribe(f, party);
        try {
          Thread.sleep(60000); // sleeps for 1 minute
        } catch (java.lang.InterruptedException ex) {
          System.out.println("interrupted");
        }
        System.out.println("unsubscribing");
        mySiena.unsubscribe(f, party);
      } catch (SienaException ex) {
        System.err.println("Siena error:" + ex.toString());
      }
      System.out.println("shutting down.");
      mySiena.shutdown();
      System.exit(0);
    } catch (Exception ex) {
      ex.printStackTrace();
      System.exit(1);
    }
  };