Пример #1
0
 /**
  * Update ProgressBar widget.<br>
  * Try to reuse the old ProgressBar if possible, otherwise dispose it and create a new one.
  *
  * @param parent
  * @param indeterminate
  * @param visible
  */
 void eswtUpdateProgressbar(Composite parent, boolean indeterminate, boolean visible) {
   // Only dispose old ProgressBar if it has wrong style
   if (eswtProgressBar != null) {
     boolean isIndeterminate = (eswtProgressBar.getStyle() & SWT.INDETERMINATE) != 0;
     if (indeterminate != isIndeterminate) {
       eswtProgressBar.setLayoutData(null);
       eswtProgressBar.dispose();
       eswtProgressBar = null;
     }
   }
   // create new ProgressBar
   if (eswtProgressBar == null) {
     int newStyle = indeterminate ? SWT.INDETERMINATE : SWT.NONE;
     eswtProgressBar = new ProgressBar(parent, newStyle);
     eswtProgressBar.setLayoutData(eswtProgbarLD);
     // update ScrolledText's layoutdata
     FormData imageLD = (FormData) eswtImgLabel.getLayoutData();
     imageLD.bottom = new FormAttachment(eswtProgressBar);
   }
   // set Progressbar visibility
   if (eswtProgressBar != null) {
     eswtProgbarLD.top = (visible ? null : new FormAttachment(100));
     eswtProgressBar.setVisible(visible);
   }
 }
Пример #2
0
  /** Create contents of the window. */
  protected void createContents() {
    shlSkriptLoading = new Shell();
    shlSkriptLoading.setSize(450, 91);
    shlSkriptLoading.setText("Skript Editor is Loading");
    shlSkriptLoading.setLayout(new GridLayout(1, false));

    txtLoading = new Label(shlSkriptLoading, SWT.NONE);
    txtLoading.setText("Loading");
    txtLoading.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    progressBar = new ProgressBar(shlSkriptLoading, SWT.NONE);
    progressBar.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
  }
  public TrackProgressBar(Composite parent, int flags) {
    super(parent, flags);
    currentTotalTime = 0;

    setLayout(new GridLayout(3, false));

    currentTimeText = new Label(this, SWT.NONE);
    currentTimeText.setText("---:---");

    progressBar = new ProgressBar(this, SWT.SMOOTH);
    progressBar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));

    totalTimeText = new Label(this, SWT.NONE);
    totalTimeText.setText("---:---");
  }
Пример #4
0
  public void openLoadingShell() {
    this.message = "";
    this.isLoading = true;
    this.loadingShell = new Shell(this.display);
    this.loadingShell.setSize(50, 100);
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 1;
    this.loadingShell.setLayout(gridLayout);
    ProgressBar pb = new ProgressBar(this.loadingShell, SWT.HORIZONTAL | SWT.INDETERMINATE);
    pb.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    Label searching = new Label(this.loadingShell, SWT.NONE);
    searching.setText("Loading...");
    this.loadingShell.open();
  }
Пример #5
0
  public Upload(Composite parent, int style, int... uploadStyles) {
    super(parent, style);
    setLayout(FormLayoutFactory.defaults().create());

    fileUpload = new FileUpload(this, SWT.NONE);
    fileUpload.setLayoutData(FormDataFactory.filled().create());
    fileUpload.setText(i18n.get("select"));
    fileUpload.setData(RWT.TOOLTIP_MARKUP_ENABLED, Boolean.TRUE);
    setData(RWT.TOOLTIP_MARKUP_ENABLED, Boolean.TRUE);

    fileUpload.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent ev) {
            UIUtils.activateCallback("upload");
            fileUpload.submit(UploadService.registerHandler(Upload.this));
          }
        });

    if (ArrayUtils.contains(uploadStyles, SHOW_UPLOAD_BUTTON)) {
      log.info("SHOW_UPLOAD_BUTTON is not supported yet.");
    }

    if (ArrayUtils.contains(uploadStyles, SHOW_PROGRESS)) {
      fileUpload.setLayoutData(FormDataFactory.filled().noRight().create());

      progress = new ProgressBar(this, SWT.HORIZONTAL);
      progress.setLayoutData(FormDataFactory.filled().left(fileUpload).create());
      progress.setMaximum(Integer.MAX_VALUE);

      progressLabel = new Label(this, SWT.NONE);
      progressLabel.setLayoutData(FormDataFactory.filled().top(0, 5).left(fileUpload, 20).create());
      progressLabel.setText(i18n.get("progressLabel"));
      log.warn("not yet ported: progressLabel.setForeground( new Color( 0x60, 0x60, 0x60 ) ) ");
      progressLabel.moveAbove(progress);
    }
  }
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.ui.internal.progress.AnimationItem#createAnimationItem(org.eclipse.swt.widgets.Composite)
   */
  @Override
  protected Control createAnimationItem(Composite parent) {

    if (okImage == null) {
      Display display = parent.getDisplay();
      noneImage =
          WorkbenchImages.getWorkbenchImageDescriptor("progress/progress_none.png")
              .createImage(display); // $NON-NLS-1$
      okImage =
          WorkbenchImages.getWorkbenchImageDescriptor("progress/progress_ok.png")
              .createImage(display); // $NON-NLS-1$
      errorImage =
          WorkbenchImages.getWorkbenchImageDescriptor("progress/progress_error.png")
              .createImage(display); // $NON-NLS-1$
    }

    top = new Composite(parent, SWT.NULL);
    top.addDisposeListener(
        new DisposeListener() {
          @Override
          public void widgetDisposed(DisposeEvent e) {
            FinishedJobs.getInstance().removeListener(ProgressAnimationItem.this);
            noneImage.dispose();
            okImage.dispose();
            errorImage.dispose();
          }
        });

    boolean isCarbon = Util.isMac();

    GridLayout gl = new GridLayout();
    if (isHorizontal()) gl.numColumns = isCarbon ? 3 : 2;
    gl.marginHeight = 0;
    gl.marginWidth = 0;
    if (isHorizontal()) {
      gl.horizontalSpacing = 2;
    } else {
      gl.verticalSpacing = 2;
    }
    top.setLayout(gl);

    bar = new ProgressBar(top, flags | SWT.INDETERMINATE);
    bar.setVisible(false);
    bar.addMouseListener(mouseListener);

    GridData gd;
    int hh = 12;
    if (isHorizontal()) {
      gd = new GridData(SWT.BEGINNING, SWT.CENTER, true, false);
      gd.heightHint = hh;
    } else {
      gd = new GridData(SWT.CENTER, SWT.BEGINNING, false, true);
      gd.widthHint = hh;
    }

    bar.setLayoutData(gd);

    toolbar = new ToolBar(top, SWT.FLAT);
    toolbar.setVisible(false);

    toolButton = new ToolItem(toolbar, SWT.NONE);
    toolButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            doAction();
          }
        });

    if (isCarbon) {
      new Label(top, SWT.NONE).setLayoutData(new GridData(4, 4));
    }

    refresh();

    return top;
  }
  public void ProgessBarExample1(
      String ip, String port, String database, String username, String password) {
    final Display display = Display.getDefault();
    final Shell shell = new Shell(SWT.CLOSE);
    shell.setText("");
    shell.setSize(315, 127);
    shell.setLocation(350, 180);
    shell.setLayout(new FormLayout());

    progressBar = new ProgressBar(shell, SWT.HORIZONTAL);

    FormData data = new FormData(237, 20);
    data.left = new FormAttachment(0, 35);
    data.bottom = new FormAttachment(100, -30);
    progressBar.setLayoutData(data);
    progressBar.setMaximum(100);
    max = progressBar.getMaximum();
    text = new Text(shell, SWT.BORDER);
    data.right = new FormAttachment(100, -69);
    text.setEnabled(false);

    final FormData fd_text = new FormData();
    fd_text.top = new FormAttachment(progressBar, 0, SWT.TOP);
    fd_text.left = new FormAttachment(progressBar, 11);
    fd_text.right = new FormAttachment(100, -25);
    text.setLayoutData(fd_text);

    Label label = new Label(shell, SWT.NONE);
    data.top = new FormAttachment(label, 25);
    FormData fd_label = new FormData();
    fd_label.bottom = new FormAttachment(100, -72);
    fd_label.right = new FormAttachment(100, -67);
    fd_label.left = new FormAttachment(0, 25);
    label.setLayoutData(fd_label);
    label.setText("\u9A8C\u8BC1\u4E2D\uFF0C\u8BF7\u7A0D\u540E\u3002\u3002\u3002\u3002\u3002");

    new Thread() {
      public void run() {
        new Thread() {
          public void run() {
            PropertyConfigurator.configure(ClassLoader.getSystemResource("log4j.properties"));
            Logger logger = Logger.getLogger(ProgressBarWindow.class);
            try {
              Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
              @SuppressWarnings("unused")
              Connection conn =
                  DriverManager.getConnection(
                      "jdbc:sqlserver://" + ip + ":" + port + ";DatabaseName=" + database + "",
                      "" + username + "",
                      "" + password + "");
              flag = true;
              PropertiesUtil.writePropertiesFile(
                  "jdbc.ip",
                  ip,
                  System.getProperty("user.dir")
                      + "\\configuration\\database_configuration.properties");
              PropertiesUtil.writePropertiesFile(
                  "jdbc.port",
                  port,
                  System.getProperty("user.dir")
                      + "\\configuration\\database_configuration.properties");
              PropertiesUtil.writePropertiesFile(
                  "jdbc.databasename",
                  database,
                  System.getProperty("user.dir")
                      + "\\configuration\\database_configuration.properties");
              PropertiesUtil.writePropertiesFile(
                  "jdbc.username",
                  username,
                  System.getProperty("user.dir")
                      + "\\configuration\\database_configuration.properties");
              PropertiesUtil.writePropertiesFile(
                  "jdbc.password",
                  password,
                  System.getProperty("user.dir")
                      + "\\configuration\\database_configuration.properties");
            } catch (ClassNotFoundException e) {
              flag = false;
              e.printStackTrace();
              logger.info(e.getMessage());
            } catch (SQLException e) {
              flag = false;
              e.printStackTrace();
              logger.info(e.getMessage());
            }
          }
        }.start();
        for (i = 1; i < max; i++) {
          try {
            Thread.sleep(150);
          } catch (Throwable e) {

          }
          display.asyncExec(
              new Runnable() {
                public void run() {
                  progressBar.setSelection(i);
                  Value = progressBar.getMaximum();
                  value = progressBar.getSelection();
                  text.setText(value + "%");
                  if (Value == value) {
                    final Display dis = Display.getDefault();
                    @SuppressWarnings("unused")
                    Shell sh = new Shell(dis);
                    if (flag == false) {
                      MessageDialog.openInformation(shell, "提示", "数据库参数有误,请核对");
                    } else {
                      MessageDialog.openInformation(shell, "提示", "数据库参数配置正确,将重启软件");

                      try {
                        Runtime.getRuntime()
                            .exec(
                                System.getProperty("user.dir")
                                    + "//APL.exe"); // 此处的exe文件名必须和打包生成的exe文件名一致
                      } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                      }
                      System.exit(Value);
                    }
                    shell.dispose();
                    return;
                  }
                }
              });
        }
      }
    }.start();
    shell.open();
    shell.layout();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
  }
Пример #8
0
  void show(
      boolean owned,
      org.eclipse.swt.graphics.Point location,
      org.eclipse.swt.graphics.Point size,
      boolean addressBar,
      boolean menuBar,
      boolean statusBar,
      boolean toolBar) {
    final org.eclipse.swt.widgets.Shell shell = browser.getShell();
    if (owned) {
      if (location != null) {
        shell.setLocation(location);
      }
      if (size != null) {
        shell.setSize(shell.computeSize(size.x, size.y));
      }
    }
    org.eclipse.swt.layout.FormData data = null;
    if (toolBar) {
      toolbar = new org.eclipse.swt.widgets.ToolBar(parent, SWT.NONE);
      data = new org.eclipse.swt.layout.FormData();
      data.top = new org.eclipse.swt.layout.FormAttachment(0, 5);
      toolbar.setLayoutData(data);
      itemBack = new org.eclipse.swt.widgets.ToolItem(toolbar, SWT.PUSH);
      itemBack.setText(getResourceString("Back"));
      itemForward = new org.eclipse.swt.widgets.ToolItem(toolbar, SWT.PUSH);
      itemForward.setText(getResourceString("Forward"));
      final org.eclipse.swt.widgets.ToolItem itemStop =
          new org.eclipse.swt.widgets.ToolItem(toolbar, SWT.PUSH);
      itemStop.setText(getResourceString("Stop"));
      final org.eclipse.swt.widgets.ToolItem itemRefresh =
          new org.eclipse.swt.widgets.ToolItem(toolbar, SWT.PUSH);
      itemRefresh.setText(getResourceString("Refresh"));
      final org.eclipse.swt.widgets.ToolItem itemGo =
          new org.eclipse.swt.widgets.ToolItem(toolbar, SWT.PUSH);
      itemGo.setText(getResourceString("Go"));
      itemBack.setEnabled(browser.isBackEnabled());
      itemForward.setEnabled(!browser.isForwardEnabled());
      org.eclipse.swt.widgets.Listener listener =
          new org.eclipse.swt.widgets.Listener() {
            public void handleEvent(org.eclipse.swt.widgets.Event event) {
              org.eclipse.swt.widgets.ToolItem item =
                  (org.eclipse.swt.widgets.ToolItem) event.widget;
              if (item == itemBack) {
                browser.back();
              } else {
                if (item == itemForward) {
                  browser.forward();
                } else {
                  if (item == itemStop) {
                    browser.stop();
                  } else {
                    if (item == itemRefresh) {
                      browser.refresh();
                    } else {
                      if (item == itemGo) {
                        browser.setUrl(locationBar.getText());
                      }
                    }
                  }
                }
              }
            }
          };
      itemBack.addListener(SWT.Selection, listener);
      itemForward.addListener(SWT.Selection, listener);
      itemStop.addListener(SWT.Selection, listener);
      itemRefresh.addListener(SWT.Selection, listener);
      itemGo.addListener(SWT.Selection, listener);
      canvas = new org.eclipse.swt.widgets.Canvas(parent, SWT.NO_BACKGROUND);
      data = new org.eclipse.swt.layout.FormData();
      data.width = 24;
      data.height = 24;
      data.top = new org.eclipse.swt.layout.FormAttachment(0, 5);
      data.right = new org.eclipse.swt.layout.FormAttachment(100, -5);
      canvas.setLayoutData(data);
      final org.eclipse.swt.graphics.Rectangle rect = images[0].getBounds();
      canvas.addListener(
          SWT.Paint,
          new org.eclipse.swt.widgets.Listener() {
            public void handleEvent(org.eclipse.swt.widgets.Event e) {
              org.eclipse.swt.graphics.Point pt =
                  ((org.eclipse.swt.widgets.Canvas) e.widget).getSize();
              e.gc.drawImage(images[index], 0, 0, rect.width, rect.height, 0, 0, pt.x, pt.y);
            }
          });
      canvas.addListener(
          SWT.MouseDown,
          new org.eclipse.swt.widgets.Listener() {
            public void handleEvent(org.eclipse.swt.widgets.Event e) {
              browser.setUrl(getResourceString("Startup"));
            }
          });
      final org.eclipse.swt.widgets.Display display = parent.getDisplay();
      display.asyncExec(
          new java.lang.Runnable() {
            public void run() {
              if (canvas.isDisposed()) {
                return;
              }
              if (busy) {
                index++;
                if (index == images.length) {
                  index = 0;
                }
                canvas.redraw();
              }
              display.timerExec(150, this);
            }
          });
    }
    if (addressBar) {
      locationBar = new org.eclipse.swt.widgets.Text(parent, SWT.BORDER);
      data = new org.eclipse.swt.layout.FormData();
      if (toolbar != null) {
        data.top = new org.eclipse.swt.layout.FormAttachment(toolbar, 0, SWT.TOP);
        data.left = new org.eclipse.swt.layout.FormAttachment(toolbar, 5, SWT.RIGHT);
        data.right = new org.eclipse.swt.layout.FormAttachment(canvas, -5, SWT.DEFAULT);
      } else {
        data.top = new org.eclipse.swt.layout.FormAttachment(0, 0);
        data.left = new org.eclipse.swt.layout.FormAttachment(0, 0);
        data.right = new org.eclipse.swt.layout.FormAttachment(100, 0);
      }
      locationBar.setLayoutData(data);
      locationBar.addListener(
          SWT.DefaultSelection,
          new org.eclipse.swt.widgets.Listener() {
            public void handleEvent(org.eclipse.swt.widgets.Event e) {
              browser.setUrl(locationBar.getText());
            }
          });
    }
    if (statusBar) {
      status = new org.eclipse.swt.widgets.Label(parent, SWT.NONE);
      progressBar = new org.eclipse.swt.widgets.ProgressBar(parent, SWT.NONE);
      data = new org.eclipse.swt.layout.FormData();
      data.left = new org.eclipse.swt.layout.FormAttachment(0, 5);
      data.right = new org.eclipse.swt.layout.FormAttachment(progressBar, 0, SWT.DEFAULT);
      data.bottom = new org.eclipse.swt.layout.FormAttachment(100, -5);
      status.setLayoutData(data);
      data = new org.eclipse.swt.layout.FormData();
      data.right = new org.eclipse.swt.layout.FormAttachment(100, -5);
      data.bottom = new org.eclipse.swt.layout.FormAttachment(100, -5);
      progressBar.setLayoutData(data);
      browser.addStatusTextListener(
          new org.eclipse.swt.browser.StatusTextListener() {
            public void changed(org.eclipse.swt.browser.StatusTextEvent event) {
              status.setText(event.text);
            }
          });
    }
    parent.setLayout(new org.eclipse.swt.layout.FormLayout());
    org.eclipse.swt.widgets.Control aboveBrowser =
        toolBar
            ? (org.eclipse.swt.widgets.Control) canvas
            : addressBar ? (org.eclipse.swt.widgets.Control) locationBar : null;
    data = new org.eclipse.swt.layout.FormData();
    data.left = new org.eclipse.swt.layout.FormAttachment(0, 0);
    data.top =
        aboveBrowser != null
            ? new org.eclipse.swt.layout.FormAttachment(aboveBrowser, 5, SWT.DEFAULT)
            : new org.eclipse.swt.layout.FormAttachment(0, 0);
    data.right = new org.eclipse.swt.layout.FormAttachment(100, 0);
    data.bottom =
        status != null
            ? new org.eclipse.swt.layout.FormAttachment(status, -5, SWT.DEFAULT)
            : new org.eclipse.swt.layout.FormAttachment(100, 0);
    browser.setLayoutData(data);
    if (statusBar || toolBar) {
      browser.addProgressListener(
          new org.eclipse.swt.browser.ProgressListener() {
            public void changed(org.eclipse.swt.browser.ProgressEvent event) {
              if (event.total == 0) {
                return;
              }
              int ratio = event.current * 100 / event.total;
              if (progressBar != null) {
                progressBar.setSelection(ratio);
              }
              busy = event.current != event.total;
              if (!busy) {
                index = 0;
                if (canvas != null) {
                  canvas.redraw();
                }
              }
            }

            public void completed(org.eclipse.swt.browser.ProgressEvent event) {
              if (progressBar != null) {
                progressBar.setSelection(0);
              }
              busy = false;
              index = 0;
              if (canvas != null) {
                itemBack.setEnabled(browser.isBackEnabled());
                itemForward.setEnabled(browser.isForwardEnabled());
                canvas.redraw();
              }
            }
          });
    }
    if (addressBar || statusBar || toolBar) {
      browser.addLocationListener(
          new org.eclipse.swt.browser.LocationListener() {
            public void changed(org.eclipse.swt.browser.LocationEvent event) {
              busy = true;
              if (event.top && locationBar != null) {
                locationBar.setText(event.location);
              }
            }

            public void changing(org.eclipse.swt.browser.LocationEvent event) {}
          });
    }
    if (title) {
      browser.addTitleListener(
          new org.eclipse.swt.browser.TitleListener() {
            public void changed(org.eclipse.swt.browser.TitleEvent event) {
              shell.setText(event.title + " - " + getResourceString("window.title"));
            }
          });
    }
    parent.layout(true);
    if (owned) {
      shell.open();
    }
  }
Пример #9
0
  @Override
  protected Control createDialogArea(Composite parent) {
    parent.setLayout(new GridLayout());

    setTitle(TITLE);
    setMessage(DEFAULT_MESSAGE);

    Group controlGroup = new Group(parent, SWT.BORDER);
    controlGroup.setLayout(new GridLayout(2, false));
    controlGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    controlGroup.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLUE));
    controlGroup.setText("Trace Options");

    createLabel(controlGroup, "Collect Framebuffer contents on eglSwapBuffers()");
    final Button eglSwapCheckBox = createButton(controlGroup, mTraceOptions.collectFbOnEglSwap);

    createLabel(controlGroup, "Collect Framebuffer contents on glDraw*()");
    final Button glDrawCheckBox = createButton(controlGroup, mTraceOptions.collectFbOnGlDraw);

    createLabel(controlGroup, "Collect texture data for glTexImage*()");
    final Button glTexImageCheckBox = createButton(controlGroup, mTraceOptions.collectTextureData);

    SelectionListener l =
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent event) {
            boolean eglSwap = eglSwapCheckBox.getSelection();
            boolean glDraw = glDrawCheckBox.getSelection();
            boolean glTexImage = glTexImageCheckBox.getSelection();

            try {
              mTraceCommandWriter.setTraceOptions(eglSwap, glDraw, glTexImage);
            } catch (IOException e) {
              eglSwapCheckBox.setEnabled(false);
              glDrawCheckBox.setEnabled(false);
              glTexImageCheckBox.setEnabled(false);

              MessageDialog.openError(
                  Display.getDefault().getActiveShell(),
                  "OpenGL ES Trace",
                  "Error while setting trace options: " + e.getMessage());
            }

            // update the text on the button
            if (!(event.getSource() instanceof Button)) {
              return;
            }
            Button sourceButton = (Button) event.getSource();
            sourceButton.setText(getToggleActionText(sourceButton.getSelection()));
            sourceButton.pack();
          }
        };

    eglSwapCheckBox.addSelectionListener(l);
    glDrawCheckBox.addSelectionListener(l);
    glTexImageCheckBox.addSelectionListener(l);

    Group statusGroup = new Group(parent, SWT.NONE);
    statusGroup.setLayout(new GridLayout(2, false));
    statusGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    statusGroup.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLUE));
    statusGroup.setText("Trace Status");

    createLabel(statusGroup, "Frames Collected:");
    mFramesCollectedLabel = createLabel(statusGroup, "");

    createLabel(statusGroup, "Trace File Size:");
    mTraceFileSizeLabel = createLabel(statusGroup, "");

    ProgressBar pb = new ProgressBar(statusGroup, SWT.INDETERMINATE);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.horizontalSpan = 2;
    pb.setLayoutData(gd);

    mRefreshTask = new StatusRefreshTask();
    new Thread(mRefreshTask, "Trace Status Refresh Thread").start();

    return super.createDialogArea(parent);
  }
Пример #10
0
  public static void main(String[] args) {
    Display display = new Display();
    final Shell shell = new Shell(display);
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 3;
    shell.setLayout(gridLayout);
    ToolBar toolbar = new ToolBar(shell, SWT.NONE);
    ToolItem itemBack = new ToolItem(toolbar, SWT.PUSH);
    itemBack.setText("Back");
    ToolItem itemForward = new ToolItem(toolbar, SWT.PUSH);
    itemForward.setText("Forward");
    ToolItem itemStop = new ToolItem(toolbar, SWT.PUSH);
    itemStop.setText("Stop");
    ToolItem itemRefresh = new ToolItem(toolbar, SWT.PUSH);
    itemRefresh.setText("Refresh");
    ToolItem itemGo = new ToolItem(toolbar, SWT.PUSH);
    itemGo.setText("Go");

    GridData data = new GridData();
    data.horizontalSpan = 3;
    toolbar.setLayoutData(data);

    Label labelAddress = new Label(shell, SWT.NONE);
    labelAddress.setText("Address");

    final Text location = new Text(shell, SWT.BORDER);
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.horizontalSpan = 2;
    data.grabExcessHorizontalSpace = true;
    location.setLayoutData(data);

    final Browser browser;
    try {
      browser = new Browser(shell, SWT.NONE);
    } catch (SWTError e) {
      System.out.println("Could not instantiate Browser: " + e.getMessage());
      display.dispose();
      return;
    }
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.verticalAlignment = GridData.FILL;
    data.horizontalSpan = 3;
    data.grabExcessHorizontalSpace = true;
    data.grabExcessVerticalSpace = true;
    browser.setLayoutData(data);

    final Label status = new Label(shell, SWT.NONE);
    data = new GridData(GridData.FILL_HORIZONTAL);
    data.horizontalSpan = 2;
    status.setLayoutData(data);

    final ProgressBar progressBar = new ProgressBar(shell, SWT.NONE);
    data = new GridData();
    data.horizontalAlignment = GridData.END;
    progressBar.setLayoutData(data);

    /* event handling */
    Listener listener =
        new Listener() {
          @Override
          public void handleEvent(Event event) {
            ToolItem item = (ToolItem) event.widget;
            String string = item.getText();
            if (string.equals("Back")) browser.back();
            else if (string.equals("Forward")) browser.forward();
            else if (string.equals("Stop")) browser.stop();
            else if (string.equals("Refresh")) browser.refresh();
            else if (string.equals("Go")) browser.setUrl(location.getText());
          }
        };
    browser.addProgressListener(
        new ProgressListener() {
          @Override
          public void changed(ProgressEvent event) {
            if (event.total == 0) return;
            int ratio = event.current * 100 / event.total;
            progressBar.setSelection(ratio);
          }

          @Override
          public void completed(ProgressEvent event) {
            progressBar.setSelection(0);
          }
        });
    browser.addStatusTextListener(
        new StatusTextListener() {
          @Override
          public void changed(StatusTextEvent event) {
            status.setText(event.text);
          }
        });
    browser.addLocationListener(
        new LocationListener() {
          @Override
          public void changed(LocationEvent event) {
            if (event.top) location.setText(event.location);
          }

          @Override
          public void changing(LocationEvent event) {}
        });
    itemBack.addListener(SWT.Selection, listener);
    itemForward.addListener(SWT.Selection, listener);
    itemStop.addListener(SWT.Selection, listener);
    itemRefresh.addListener(SWT.Selection, listener);
    itemGo.addListener(SWT.Selection, listener);
    location.addListener(
        SWT.DefaultSelection,
        new Listener() {
          @Override
          public void handleEvent(Event e) {
            browser.setUrl(location.getText());
          }
        });

    shell.open();
    browser.setUrl("http://eclipse.org");

    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    display.dispose();
  }
Пример #11
0
  /**
   * Create the composite.
   *
   * @param parent
   * @param style
   */
  public IOSNavBarComposite(Composite parent, BrowserSimImageList imageList) {
    super(parent, SWT.NONE);

    this.setLayout(new FormLayout());

    pageTitleStyledText = new IOSPageTitleStyledText(this, imageList);
    FormData formData = new FormData();
    formData.left = new FormAttachment(0, 0);
    formData.right = new FormAttachment(100, 0);
    formData.top = new FormAttachment(0, 0);
    formData.bottom = new FormAttachment(0, 26);
    formData.height = 27;
    pageTitleStyledText.setLayoutData(formData);

    urlText = new AdressBarText(this, SWT.SINGLE);
    formData = new FormData();
    formData.left = new FormAttachment(0, 12);
    formData.right = new FormAttachment(100, -58);
    formData.top = new FormAttachment(0, 33 - AdressBarText.adressBarUrlOffset);
    formData.height = 16;
    urlText.setLayoutData(formData);

    refreshButtonComposite =
        new ImageButtonComposite(
            this,
            imageList.getImage(BD + "refresh.png"),
            imageList.getImage(BD + "refresh.png"),
            imageList.getImage(BD + "refresh-selected.png"));
    formData = new FormData();
    Rectangle refreshImageBounds = imageList.getImage(BD + "refresh.png").getBounds();
    formData.right = new FormAttachment(100, -8);
    formData.bottom = new FormAttachment(100, -7);
    formData.width = refreshImageBounds.width;
    formData.height = refreshImageBounds.height;
    refreshButtonComposite.setLayoutData(formData);

    stopButtonComposite =
        new ImageButtonComposite(
            this,
            imageList.getImage(BD + "stop.png"),
            imageList.getImage(BD + "stop.png"),
            imageList.getImage(BD + "stop-selected.png"));
    formData = new FormData();
    Rectangle stopImageBounds = imageList.getImage(BD + "stop.png").getBounds();
    formData.right = new FormAttachment(100, -42);
    formData.bottom = new FormAttachment(100, -12);
    formData.width = stopImageBounds.width;
    formData.height = stopImageBounds.height;
    stopButtonComposite.setLayoutData(formData);

    progressBar = new ProgressBar(this, SWT.NONE);
    progressBar.setVisible(false);
    formData = new FormData();
    formData.left = new FormAttachment(0, 7);
    formData.right = new FormAttachment(100, -36);
    formData.bottom = new FormAttachment(100, -1);
    formData.height = 5;
    progressBar.setLayoutData(formData);

    Composite imagesComposite = new Composite(this, SWT.NONE);
    formData = new FormData();
    formData.left = new FormAttachment(0);
    formData.right = new FormAttachment(100);
    formData.top = new FormAttachment(0);
    formData.bottom = new FormAttachment(100);
    imagesComposite.setLayoutData(formData);

    GridLayout gridLayout = new GridLayout(5, false);
    gridLayout.verticalSpacing = 0;
    gridLayout.horizontalSpacing = 0;
    gridLayout.marginWidth = 0;
    gridLayout.marginHeight = 0;

    imagesComposite.setLayout(gridLayout);

    for (ImageDescriptor descriptor : BODY_DESCRIPTOR) {
      descriptor.createWidget(imagesComposite, imageList);
    }
  }
Пример #12
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;
  }
Пример #13
0
  @Override
  public Composite createUI(Composite parent) {
    this.display = WorkPart.display();
    Shell shell = new Shell(this.display);
    shell.setSize(50, 100);
    GridLayout gridLayout = new GridLayout();
    gridLayout.numColumns = 1;
    shell.setLayout(gridLayout);
    ProgressBar pb = new ProgressBar(shell, SWT.HORIZONTAL | SWT.INDETERMINATE);
    pb.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    Label searching = new Label(shell, SWT.NONE);
    searching.setText("Searching...");
    shell.open();
    this.isSearching = true;
    new Thread() {
      public void run() {
        testTm_cz = RetrieveData.testTm_czConnection();
        testTm_lz = RetrieveData.testTm_lzConnection();
        testDeapp = RetrieveData.testDeappConnection();
        root = new TreeNode("Dataset explorer", null, false);
        studyTree = new StudyTree(root);
        topNodeController = new TopNodeController(root, dataType, studyTree);
        root = topNodeController.buildTree();
        topNode = dataType.getStudy().getTopNode();
        isSearching = false;
      }
    }.start();
    this.display = WorkPart.display();
    while (this.isSearching) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }
    shell.close();
    Composite composite = new Composite(parent, SWT.NONE);
    GridLayout gd = new GridLayout();
    gd.numColumns = 1;
    gd.horizontalSpacing = 0;
    gd.verticalSpacing = 0;
    composite.setLayout(gd);
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));

    ScrolledComposite scroller = new ScrolledComposite(composite, SWT.H_SCROLL | SWT.V_SCROLL);
    scroller.setLayoutData(new GridData(GridData.FILL_BOTH));
    gd = new GridLayout();
    gd.numColumns = 1;
    gd.horizontalSpacing = 0;
    gd.verticalSpacing = 0;
    scroller.setLayout(gd);
    scroller.setLayoutData(new GridData(GridData.FILL_BOTH));

    Composite scrolledComposite = new Composite(scroller, SWT.NONE);
    scroller.setContent(scrolledComposite);
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    layout.verticalSpacing = 10;
    scrolledComposite.setLayout(layout);
    scrolledComposite.setLayoutData(new GridData(GridData.FILL_BOTH));

    this.topNode = this.dataType.getStudy().getTopNode();
    if (topNode != null && topNode.compareTo("") != 0) {
      viewer = new TreeViewer(scrolledComposite, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
      viewer.setContentProvider(new StudyContentProvider());
      viewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);

      viewer.setInput(this.studyTree);
      GridData gridData = new GridData(GridData.FILL_BOTH);
      gridData.horizontalAlignment = SWT.FILL;
      gridData.verticalAlignment = SWT.FILL;
      gridData.grabExcessHorizontalSpace = true;
      gridData.grabExcessVerticalSpace = true;
      gridData.heightHint = 300;
      gridData.widthHint = 250;
      this.viewer.getControl().setLayoutData(gridData);
      viewer.setLabelProvider(
          new ColumnLabelProvider() {
            @Override
            public String getText(Object element) {
              return element.toString();
            }

            @Override
            public Color getBackground(Object element) {
              if (((TreeNode) element).isStudyRoot()) {
                return new Color(Display.getCurrent(), 237, 91, 67);
              }
              if (((TreeNode) element).isLabel()) {
                return new Color(Display.getCurrent(), 212, 212, 212);
              }
              return null;
            }
          });

      securityButton = new Button(scrolledComposite, SWT.CHECK);
      securityButton.setText("Security required");
      securityButton.addListener(
          SWT.Selection,
          new Listener() {

            @Override
            public void handleEvent(Event event) {
              security = securityButton.getSelection();
            }
          });

      /*indexesButton=new Button(scrolledComposite, SWT.CHECK);
      indexesButton.setText("Turn off the indexes during loaded (only for large datasets)");
      indexesButton.addListener(SWT.Selection, new Listener(){

      	@Override
      	public void handleEvent(Event event) {
      		indexes=indexesButton.getSelection();
      	}
      })*/ ;
    } else {
      Label label = new Label(scrolledComposite, SWT.NONE);
      label.setText("Please first choose a study node in the description data type");
    }

    Button button = new Button(scrolledComposite, SWT.PUSH);
    button.setText("Load");

    if (topNode != null && topNode.compareTo("") != 0) {
      if (this.testTm_cz && this.testTm_lz && this.testDeapp) {
        button.addListener(SWT.Selection, new LoadGeneExpressionDataListener(this, this.dataType));
        Label dbLabel = new Label(scrolledComposite, SWT.NONE);
        dbLabel.setText("You are connected to database '" + PreferencesHandler.getDb() + "'");
      } else {
        button.setEnabled(false);
        Label warn = new Label(scrolledComposite, SWT.NONE);
        warn.setText("Warning: connection to database is not possible");
      }
    } else {
      button.setEnabled(false);
    }
    scrolledComposite.setSize(scrolledComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    return composite;
  }
Пример #14
0
 public static void main(String[] args) {
   final Display display = new Display();
   final int[] count = new int[] {4};
   final Image image = new Image(display, 300, 300);
   GC gc = new GC(image);
   gc.setBackground(display.getSystemColor(SWT.COLOR_CYAN));
   gc.fillRectangle(image.getBounds());
   gc.drawText("Splash Screen", 10, 10);
   gc.dispose();
   final Shell splash = new Shell(SWT.ON_TOP);
   final ProgressBar bar = new ProgressBar(splash, SWT.NONE);
   bar.setMaximum(count[0]);
   Label label = new Label(splash, SWT.NONE);
   label.setImage(SWTResourceManager.getImage(SplashScreen.class, "/resources/splashep.png"));
   FormLayout layout = new FormLayout();
   splash.setLayout(layout);
   FormData labelData = new FormData();
   labelData.right = new FormAttachment(100, 0);
   labelData.bottom = new FormAttachment(100, 0);
   label.setLayoutData(labelData);
   FormData progressData = new FormData();
   progressData.left = new FormAttachment(0, 5);
   progressData.right = new FormAttachment(100, -5);
   progressData.bottom = new FormAttachment(100, -5);
   bar.setLayoutData(progressData);
   splash.pack();
   Rectangle splashRect = splash.getBounds();
   Rectangle displayRect = display.getBounds();
   int x = (displayRect.width - splashRect.width) / 2;
   int y = (displayRect.height - splashRect.height) / 2;
   splash.setLocation(x, y);
   splash.open();
   display.asyncExec(
       new Runnable() {
         @Override
         public void run() {
           Shell[] shells = new Shell[count[0]];
           for (int i = 0; i < count[0]; i++) {
             shells[i] = new Shell(display);
             shells[i].setSize(300, 300);
             shells[i].addListener(
                 SWT.Close,
                 new Listener() {
                   @Override
                   public void handleEvent(Event e) {
                     --count[0];
                   }
                 });
             bar.setSelection(i + 1);
             try {
               Thread.sleep(1000);
             } catch (Throwable e) {
             }
           }
           splash.close();
           image.dispose();
           // Start Main Window
           MainWindow.main(null);
         }
       });
   while (count[0] != 0) {
     if (!display.readAndDispatch()) display.sleep();
   }
   display.dispose();
 }
Пример #15
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();
  }