コード例 #1
0
  /**
   * 通过过滤条件获得相应的消息
   *
   * @throws Exception
   */
  @SuppressWarnings("unchecked")
  public void retrieveData() throws Exception {

    List input = (List) tv.getInput();
    if (input != null) {
      input.clear();
    }

    MessageService ms = AppContext.getInstance().getMessageService();
    List<Message> list_messages = null;
    if (executeMethod.getText().equals("查询所有")) {
      list_messages = ms.getAllMessages();
    } else {
      list_messages =
          ms.getMessages(
              executeSender.getText(),
              executeReceiver.getText(),
              beginDateText.getDate(),
              endDateText.getDate());
    }

    if (list_messages != null && !list_messages.isEmpty()) {
      for (Message msg : list_messages) {
        DeptMessageTableViewLabelProvider dp = new DeptMessageTableViewLabelProvider(msg);
        input.add(dp);
      }
    } else {
      MessageUtil.ShowHintMessage(getShell(), "没有查询到数据!");
    }

    tv.setInput(input);
  }
コード例 #2
0
  private Composite getBottomComposite(Composite parent) {
    Composite comp = new Composite(parent, SWT.FILL);
    GridLayout gl = new GridLayout(5, false);
    gl.horizontalSpacing = 15;
    comp.setLayout(gl);

    GridData gd2 = new GridData();
    gd2.horizontalSpan = 2;

    AdvancedWidgetCreator.createNewTitleLabel(comp, 5, -1, false, "  过 滤 条 件 设 置  ");

    AdvancedWidgetCreator.createNewTitleLabel(comp, 1, -1, false, "发送用户:");
    executeSender = AdvancedWidgetCreator.createNewContentText(comp, 1, 1, SWT.BORDER);
    executeSender.setFont(UIConstant.FONT_WIDGET);

    AdvancedWidgetCreator.createNewTitleLabel(comp, 1, -1, false, "接收用户:");
    // receiverFlag = new Combo(comp, SWT.BORDER | SWT.READ_ONLY);
    // receiverFlag.setFont(UIConstant.FONT_DEFAULT);
    // //receiverFlag.add("仅查询");
    // receiverFlag.add("包含");
    // receiverFlag.select(0);
    executeReceiver = AdvancedWidgetCreator.createNewContentText(comp, 1, 1, SWT.BORDER);
    executeReceiver.setFont(UIConstant.FONT_DEFAULT_TABLE);
    AdvancedWidgetCreator.createNewTitleLabel(comp, 1, -1, false, "").setVisible(false);

    AdvancedWidgetCreator.createNewTitleLabel(comp, 1, -1, false, "开始时间:");
    Date current_date = new Date();
    beginDateText =
        new TimeSimpleText(comp, SWT.BORDER, DateUtil.getCalcDatetimeByDays(current_date, -1));
    beginDateText.setFont(UIConstant.FONT_DEFAULT_TABLE);

    AdvancedWidgetCreator.createNewTitleLabel(comp, 1, -1, false, "结束时间:");
    endDateText = new TimeSimpleText(comp, SWT.BORDER, current_date);
    endDateText.setLayoutData(gd2);
    endDateText.setFont(UIConstant.FONT_DEFAULT_TABLE);

    AdvancedWidgetCreator.createNewTitleLabel(comp, 1, -1, false, "查询方式:");
    executeMethod = new Combo(comp, SWT.BORDER | SWT.READ_ONLY);
    executeMethod.setFont(UIConstant.FONT_DEFAULT_TABLE);
    executeMethod.add("按过滤条件查询");
    executeMethod.add("查询所有");
    executeMethod.select(0);
    executeMethod.setLayoutData(gd2);

    Button queryButton = new Button(comp, SWT.NONE);
    queryButton.setFont(UIConstant.FONT_DEFAULT_TABLE);
    queryButton.setText("  查 询  ");
    queryButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            try {
              retrieveData();
            } catch (Exception e1) {
              MessageUtil.ShowErroMessage(getShell(), "数据查询时出现异常,请联系系统维护人员!");
              OwnerLog.writeExceptionLog(e1);
            }
          }
        });

    Button closeButton = new Button(comp, SWT.NONE);
    closeButton.setFont(UIConstant.FONT_DEFAULT_TABLE);
    closeButton.setText("  关 闭  ");
    closeButton.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            Display.getCurrent().getActiveShell().close();
          }
        });

    // Init();

    return comp;
  }