/**
  * Update ProgressBar values.
  *
  * @param minValue the minimum value
  * @param maxValue the maximum value
  * @param selValue the value
  */
 void eswtSetProgressbarValues(int minValue, int maxValue, int selValue) {
   if (eswtProgressBar != null) {
     eswtProgressBar.setMinimum(minValue);
     eswtProgressBar.setMaximum(maxValue);
     eswtProgressBar.setSelection(selValue);
   }
 }
Exemple #2
0
  @Test
  public void testRenderMinimum() throws IOException {
    progressBar.setMinimum(10);
    lca.renderChanges(progressBar);

    Message message = Fixture.getProtocolMessage();
    assertEquals(10, message.findSetProperty(progressBar, "minimum").asInt());
  }
  // 创建进度条
  private ProgressBar createProgressBar(Composite parent) {

    ProgressBar progressBar = new ProgressBar(parent, SWT.SMOOTH);

    progressBar.setMinimum(0); // 最小值

    progressBar.setMaximum(100); // 最大值

    return progressBar;
  }
Exemple #4
0
  @Test
  public void testRenderMinimumUnchanged() throws IOException {
    Fixture.markInitialized(display);
    Fixture.markInitialized(progressBar);

    progressBar.setMinimum(10);
    Fixture.preserveWidgets();
    lca.renderChanges(progressBar);

    Message message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(progressBar, "minimum"));
  }
  public void open(int minValue, int maxValue) {
    childShell = new Shell(shell.getDisplay(), SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
    childShell.setText("Exporting to Excel.. please wait");

    progressBar = new ProgressBar(childShell, SWT.SMOOTH);
    progressBar.setMinimum(minValue);
    progressBar.setMaximum(maxValue);
    progressBar.setBounds(0, 0, 400, 25);
    progressBar.setFocus();

    childShell.pack();
    childShell.open();
  }
Exemple #6
0
  public static Object create(ActionContext actionContext) {
    Thing self = (Thing) actionContext.get("self");

    int style = SWT.NONE;
    String selfStyle = self.getString("style");
    if ("HORIZONTAL".equals(selfStyle)) {
      style |= SWT.HORIZONTAL;
    } else if ("VERTICAL".equals(selfStyle)) {
      style |= SWT.VERTICAL;
    }

    if (self.getBoolean("SMOOTH")) style |= SWT.SMOOTH;
    if (self.getBoolean("BORDER")) style |= SWT.BORDER;
    if (self.getBoolean("INDETERMINATE")) style |= SWT.INDETERMINATE;

    Composite parent = (Composite) actionContext.get("parent");
    ProgressBar bar = new ProgressBar(parent, style);

    // 父类的初始化方法
    Bindings bindings = actionContext.push(null);
    bindings.put("control", bar);
    try {
      self.doAction("super.init", actionContext);
    } finally {
      actionContext.pop();
    }

    bar.setMaximum(self.getInt("maximum", 100));
    bar.setMinimum(self.getInt("minimum", 0));
    bar.setSelection(self.getInt("selection", 0));

    // 保存变量和创建子事物
    actionContext.getScope(0).put(self.getString("name"), bar);
    actionContext.peek().put("parent", bar);
    for (Thing child : self.getAllChilds()) {
      child.doAction("create", actionContext);
    }
    actionContext.peek().remove("parent");

    Designer.attach(bar, self.getMetadata().getPath(), actionContext);
    return bar;
  }
 // this method must be private or protected so the auto-gen tool keeps it
 private void setDefaults() {
   progressBar.setMaximum(100);
   progressBar.setMinimum(10);
   progressBar.setSelection(50);
 }
Exemple #8
0
  /**
   * Open the dialog.
   *
   * @return the result
   */
  public Object open() {
    Display display = getParent().getDisplay();
    shellww = new Shell(getParent(), 0);
    shellww.setSize(450, 316);
    {
      shell = LayoutUtils.centerDWdefult(shellww, "更新程序", true, false);
    }
    shell.setLayout(new FormLayout());

    updatepro = new ProgressBar(shell, 0);
    FormData fd_updatepro = new FormData();
    fd_updatepro.right = new FormAttachment(0, 406);
    fd_updatepro.top = new FormAttachment(0, 131);
    fd_updatepro.left = new FormAttachment(0, 127);
    updatepro.setLayoutData(fd_updatepro);

    updatepro.setMaximum(100);
    updatepro.setMinimum(0);

    Label label = new Label(shell, SWT.NONE);
    FormData fd_label = new FormData();
    fd_label.right = new FormAttachment(0, 121);
    fd_label.top = new FormAttachment(0, 131);
    fd_label.left = new FormAttachment(0, 61);
    label.setLayoutData(fd_label);
    label.setText("下载进度");

    Label label_1 = new Label(shell, SWT.NONE);
    FormData fd_label_1 = new FormData();
    fd_label_1.right = new FormAttachment(0, 337);
    fd_label_1.top = new FormAttachment(0, 46);
    fd_label_1.left = new FormAttachment(0, 146);
    label_1.setLayoutData(fd_label_1);
    label_1.setText("下载完成将自动重启更新!");

    begin = new Button(shell, SWT.NONE);
    FormData fd_begin = new FormData();
    fd_begin.right = new FormAttachment(0, 166);
    fd_begin.top = new FormAttachment(0, 215);
    fd_begin.left = new FormAttachment(0, 98);
    begin.setLayoutData(fd_begin);
    begin.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            down();
          }
        });
    begin.setText("开 始");

    cacel = new Button(shell, SWT.NONE);
    FormData fd_cacel = new FormData();
    fd_cacel.right = new FormAttachment(0, 406);
    fd_cacel.top = new FormAttachment(0, 215);
    fd_cacel.left = new FormAttachment(0, 338);
    cacel.setLayoutData(fd_cacel);
    cacel.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            shellww.close();
          }
        });
    cacel.setText("取 消");

    shellww.open();
    shellww.layout();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    return result;
  }
  private void create() {
    shell = new Shell(SWT.APPLICATION_MODAL | SWT.CLOSE);
    shell.setText("Project File Restore/Replace");
    shell.setMinimumSize(450, 250);

    GridLayout layout = new GridLayout(1, false);
    shell.setLayout(layout);
    layout.horizontalSpacing = 5;
    layout.verticalSpacing = 5;
    layout.makeColumnsEqualWidth = true;

    // Groups
    Group restoreGroup = new Group(shell, SWT.NONE);
    restoreGroup.setText("Restore/Replace");
    restoreGroup.setLayout(new GridLayout(2, false));

    Group statusGroup = new Group(shell, SWT.NONE);
    statusGroup.setText("Status");
    statusGroup.setLayout(new GridLayout(1, false));

    // Status box
    final ProgressBar progress = new ProgressBar(statusGroup, SWT.NONE);
    progress.setMaximum(100);
    progress.setMinimum(0);
    progress.setSelection(0);
    final Text status = new Text(statusGroup, SWT.MULTI | SWT.READ_ONLY | SWT.V_SCROLL);

    // Restore box
    final Text file = new Text(restoreGroup, SWT.SINGLE | SWT.BORDER);
    Button browse = new Button(restoreGroup, SWT.PUSH);
    browse.setText("Browse...");

    final Combo symCombo = new Combo(restoreGroup, SWT.DROP_DOWN);
    for (int sym : Config.getSyms()) {
      symCombo.add("Sym " + sym);
    }

    Button doit = new Button(restoreGroup, SWT.PUSH);
    doit.setText("Replace");

    browse.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            org.eclipse.swt.widgets.FileDialog f =
                new org.eclipse.swt.widgets.FileDialog(shell, SWT.OPEN);
            String fn = f.open();
            if (fn != null) file.setText(fn);
          }
        });

    doit.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            // Oh my god, error checking like this sucks.  I am tempted to make an
            // "easy error dialog" static method... Imagine...
            //   ErrorBox.open("Error: no file specified", "You must specify a file to continue");
            // that would be so much nicer than this crappy 7 line method of doing it.
            if (file.getText() == null || !(new File(file.getText())).exists()) {
              MessageBox error = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
              error.setText("File Error");
              error.setMessage("You must specify a file that exists.");
              error.open();
              return;
            }

            if (symCombo.getSelectionIndex() == -1) {
              MessageBox error = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
              error.setText("Select a sym");
              error.setMessage("You must select a sym");
              error.open();
              return;
            }

            int sym = Integer.parseInt(symCombo.getItem(symCombo.getSelectionIndex()).substring(4));
            if (RepDevMain.SYMITAR_SESSIONS.get(sym).isConnected()) {
              MessageBox error = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
              error.setText("Not logged out");
              error.setMessage(
                  "You must log out of the sym that you want to restore your project file in");
              error.open();
              return;
            }

            progress.setSelection(10);
            status.setText(status.getText() + "Logging in to sym " + sym + "\r\n");

            int err = SymLoginShell.symLogin(shell.getDisplay(), shell, sym);
            if (err != -1) {
              progress.setSelection(25);

              SymitarSession session = RepDevMain.SYMITAR_SESSIONS.get(sym);
              SymitarFile pf =
                  new SymitarFile(
                      sym,
                      "repdev." + session.getUserID().substring(0, 3) + "projects",
                      FileType.REPGEN);

              status.setText(
                  status.getText()
                      + "Replacing Project file for "
                      + session.getUserID().substring(0, 3)
                      + " on sym "
                      + sym
                      + "...\r\n");
              try {
                progress.setSelection(40);
                File f = new File(file.getText());
                FileReader project = new FileReader(f);
                char[] data = new char[(int) f.length()];
                project.read(data);
                progress.setSelection(50);
                SessionError se = session.saveFile(pf, new String(data));
                progress.setSelection(80);
                status.setText(status.getText() + "Finished, errors: " + se.toString() + "\r\n");

              } catch (FileNotFoundException e1) {
                e1.printStackTrace();
              } catch (IOException e1) {
                e1.printStackTrace();
              }

              session.disconnect();
              progress.setSelection(100);
            }
          }
        });

    // restoreGroup's layout data
    GridData data = new GridData(SWT.FILL, SWT.TOP, true, false);
    restoreGroup.setLayoutData(data);

    file.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    symCombo.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    browse.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    doit.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));

    // inside of statusGroup...
    data = new GridData(SWT.FILL, SWT.TOP, true, false);
    progress.setLayoutData(data);

    data = new GridData(SWT.FILL, SWT.FILL, true, true);
    status.setLayoutData(data);

    // For the status group's layout stuff...
    data = new GridData(SWT.FILL, SWT.FILL, true, true);
    statusGroup.setLayoutData(data);

    restoreGroup.pack();
    statusGroup.pack();
    shell.pack();

    shell.open();
  }