Ejemplo n.º 1
0
 /**
  * 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);
   }
 }
Ejemplo n.º 2
0
  @Test
  public void testRenderSelection() throws IOException {
    progressBar.setSelection(10);
    lca.renderChanges(progressBar);

    Message message = Fixture.getProtocolMessage();
    assertEquals(10, message.findSetProperty(progressBar, "selection").asInt());
  }
 /**
  * Set the progress bar ahead by a tick and update the text to the current time.
  *
  * @param currentTimeInSeconds the current number of seconds into the song
  */
 public void setCurrentTime(int currentTimeInSeconds) {
   if (this.currentTimeInSeconds != currentTimeInSeconds) {
     this.currentTimeInSeconds = currentTimeInSeconds;
     progressBar.setSelection(currentTimeInSeconds);
     currentTimeText.setText(formatTimeToString(currentTimeInSeconds));
     currentTimeText.pack();
   }
 }
Ejemplo n.º 4
0
  @Test
  public void testRenderSelectionUnchanged() throws IOException {
    Fixture.markInitialized(display);
    Fixture.markInitialized(progressBar);

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

    Message message = Fixture.getProtocolMessage();
    assertNull(message.findSetOperation(progressBar, "selection"));
  }
Ejemplo n.º 5
0
  private void pintarTabla() {
    // Inicia un webdriver Oculto para buscar la url pasada desde el campo del objeto
    String cUrl = this.currentUrl;
    JavaWebDriver jwd = new JavaWebDriver(cUrl);
    jwd.init(0);
    // Devuelve resultados de la query
    ArrayList<Resultado> results = jwd.getResultados();

    // Pinta la tabla con los resultados de la query
    for (Resultado result : results) {
      TableItem item = new TableItem(tableReport, SWT.NONE);
      item.setText(new String[] {result.getNombre(), result.getUrl(), result.getTelefono()});
    }
    progressBar.setSelection(progressBar.getSelection() + 1);
  }
Ejemplo n.º 6
0
 /** Open the window. */
 public void open() {
   Display display = Display.getDefault();
   createContents();
   shlSkriptLoading.open();
   shlSkriptLoading.layout();
   while (!shlSkriptLoading.isDisposed()) {
     txtLoading.setText(text);
     progressBar.setSelection((int) (((percent + section) / sections) * 100));
     if (!display.readAndDispatch()) {
       display.sleep();
     }
     if (done) {
       display.close();
     }
   }
 }
Ejemplo n.º 7
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;
  }
  public boolean checkPassword(String[] savedUserInfos) {
    // center the dialog screen to the monitor
    Rectangle bounds = display.getBounds();
    Rectangle rect = shlObaLogin.getBounds();
    int x = bounds.x + (bounds.width - rect.width) / 2;
    int y = bounds.y + (bounds.height - rect.height) / 2;
    shlObaLogin.setLocation(x, y);
    shlObaLogin.open();
    for (int i = 0; i < 100; i++) {
      try {
        Thread.sleep(10);
      } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
      bar.setSelection(i);
    }

    controller = OBAController.getInstance();
    boolean result = controller.loginWithSavePasswd(savedUserInfos);
    display.dispose();
    return result;
  }
 // 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);
 }
Ejemplo n.º 10
0
  protected void down() {
    // TODO Auto-generated method stub
    cacel.setEnabled(false);

    if (!canUpdate()) {
      DialogUtil.openInfo(shellww, "没有发下新版本!");
      return;
    }
    HttpURLConnection httpURLConnection = null;
    URL url = null;
    BufferedInputStream bis = null;
    byte[] buf = new byte[10240];
    int size = 0;
    File filea = new File(filePath);
    if (!filea.exists()) {
      filea.mkdir();
    }
    String remoteUrl = downurl;

    // 检查本地文件
    RandomAccessFile rndFile = null;
    File file = new File(filePath + "//" + fileName);
    long remoteFileSize = getRemoteFileSize(remoteUrl);
    long nPos = 0;

    // System.out.println("remote size" + remoteFileSize + "--" + (int)
    // remoteFileSize);
    long every = remoteFileSize / 100;
    // System.out.println("every size" + every);

    if (file.exists()) {
      long localFileSzie = file.length();
      if (localFileSzie < remoteFileSize) {
        System.out.println("文件续传...");
        nPos = localFileSzie;
      } else {
        System.out.println("文件存在,重新下载...");
        file.delete();
        try {
          file.createNewFile();
        } catch (Exception e) {
          // TODO: handle exception
          e.printStackTrace();
        }
      }

    } else {
      // 建立文件
      try {
        file.createNewFile();
      } catch (Exception e) {
        // TODO: handle exception
        e.printStackTrace();
      }
    }

    // 下载文件
    try {
      url = new URL(remoteUrl);
      httpURLConnection = (HttpURLConnection) url.openConnection();
      // 设置User-Agent
      httpURLConnection.setRequestProperty("User-Agent", "Net");
      // 设置续传开始
      httpURLConnection.setRequestProperty("Range", "bytes=" + nPos + "-");
      // 获取输入流
      bis = new BufferedInputStream(httpURLConnection.getInputStream());
      rndFile = new RandomAccessFile(filePath + "\\" + fileName, "rw");
      rndFile.seek(nPos);
      long upsize = 0L; // 递增计数
      int num = 0;
      while ((size = bis.read(buf)) != -1) {
        // if (i > 500) break;
        rndFile.write(buf, 0, size);
        upsize += size;
        num = (int) (upsize / every);
        System.out.println(num + "///////////");
        updatepro.setSelection(num);
      }
      updatepro.setSelection(100);
      httpURLConnection.disconnect();
      MessageDialog.openInformation(shellww, "下载成功!", "重新启动!");
    } catch (Exception e) {
      // TODO: handle exception
      MessageDialog.openInformation(shellww, "exception", e.getMessage());
      MessageDialog.openError(shellww, "网络异常", "网络连接失败,请检查网络环境!");
      return;
    }
    dorestart();
  }
Ejemplo n.º 11
0
 public void setSelection(int value) {
   progressBar.setSelection(value);
 }
Ejemplo n.º 12
0
  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();
  }