Exemplo n.º 1
0
  public void show(int serverId, Rectangle r) {
    dialog = setDialogLayout(serverId);
    dialog.pack();

    UIUtil.setDialogDefaultFunctions(dialog);

    getOldDescription();

    dialog.setSize(400, 150);
    dialog.setLocation(r.x + 100, r.y + 100);
    dialog.open();
  }
Exemplo n.º 2
0
 public void show(String title, final String message, List<StyleRange> srList) {
   final Shell dialog = new Shell(Display.getDefault(), SWT.DIALOG_TRIM | SWT.RESIZE);
   UIUtil.setDialogDefaultFunctions(dialog);
   dialog.setText(title);
   dialog.setLayout(new GridLayout(1, true));
   final StyledText text =
       new StyledText(dialog, SWT.MULTI | SWT.WRAP | SWT.BORDER | SWT.V_SCROLL);
   GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
   gd.widthHint = 400;
   gd.heightHint = 300;
   text.setLayoutData(gd);
   text.setText(message);
   text.addKeyListener(
       new KeyAdapter() {
         public void keyPressed(KeyEvent e) {
           if (e.stateMask == SWT.CTRL) {
             if (e.keyCode == 'a' || e.keyCode == 'A') {
               text.selectAll();
             }
           }
         }
       });
   if (srList != null && srList.size() > 0) {
     text.setStyleRanges(srList.toArray(new StyleRange[srList.size()]));
   }
   Button btn = new Button(dialog, SWT.PUSH);
   gd = new GridData(SWT.RIGHT, SWT.FILL, false, false);
   gd.widthHint = 100;
   btn.setLayoutData(gd);
   btn.setText("&Close");
   btn.addSelectionListener(
       new SelectionAdapter() {
         public void widgetSelected(SelectionEvent e) {
           dialog.close();
         }
       });
   dialog.pack();
   dialog.open();
 }
Exemplo n.º 3
0
  public void show(long stime, long etime) {
    final Shell dialog = new Shell(display, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
    dialog.setLayout(new GridLayout(4, false));
    dialog.setText("Time Range");
    UIUtil.setDialogDefaultFunctions(dialog);

    Label label = new Label(dialog, SWT.NONE);
    label.setText("From");
    final DateTime startTime = new DateTime(dialog, SWT.TIME | SWT.SHORT);
    startTime.setHours(DateUtil.getHour(stime));
    startTime.setMinutes(DateUtil.getMin(stime));

    label = new Label(dialog, SWT.NONE);
    label.setText("To");
    final DateTime endTime = new DateTime(dialog, SWT.TIME | SWT.SHORT);
    endTime.setHours(DateUtil.getHour(etime));
    endTime.setMinutes(DateUtil.getMin(etime));

    Button okButton = new Button(dialog, SWT.PUSH);
    okButton.setText("&OK");
    okButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1));
    okButton.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event event) {
            switch (event.type) {
              case SWT.Selection:
                try {
                  String fromTime =
                      yyyymmdd
                          + (startTime.getHours() < 10 ? "0" : "")
                          + startTime.getHours()
                          + (startTime.getMinutes() < 10 ? "0" : "")
                          + startTime.getMinutes();
                  String toTime =
                      yyyymmdd
                          + (endTime.getHours() < 10 ? "0" : "")
                          + endTime.getHours()
                          + (endTime.getMinutes() < 10 ? "0" : "")
                          + endTime.getMinutes();
                  long stime = DateUtil.getTime(fromTime, "yyyyMMddHHmm");
                  long etime = DateUtil.getTime(toTime, "yyyyMMddHHmm");
                  if (etime <= stime) {
                    MessageDialog.openWarning(
                        dialog,
                        "Warning",
                        "Time range is incorrect. "
                            + DateUtil.timestamp(stime)
                            + " ~ "
                            + DateUtil.timestamp(etime));
                  } else {
                    callback.setTimeRange(stime, etime);
                    dialog.close();
                  }
                } catch (Exception e) {
                  e.printStackTrace();
                  MessageDialog.openError(dialog, "Error", "Date format error:" + e.getMessage());
                }
                break;
            }
          }
        });

    Button cancelButton = new Button(dialog, SWT.PUSH);
    cancelButton.setText("&Cancel");
    cancelButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 2, 1));
    cancelButton.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event event) {
            switch (event.type) {
              case SWT.Selection:
                dialog.close();
                break;
            }
          }
        });

    dialog.setDefaultButton(okButton);
    dialog.pack();
    dialog.open();
  }