Exemple #1
0
 void setActivePage(DREPage page) {
   if (currentPage != null) {
     currentPage.hiddened();
   }
   currentPage = page;
   if (page != null) {
     page.activated();
   }
 }
Exemple #2
0
  void open() {
    prefs = new PreferenceStore(PREFERENCES_PATH);
    try {
      prefs.load();
    } catch (IOException e) {
    }

    prefs.setDefault(PREFS_LANGUAGE_KEY, Locale.getDefault().getLanguage());
    prefs.setDefault(PREFS_SHELL_WIDTH_KEY, 840);
    prefs.setDefault(PREFS_SHELL_HEIGHT_KEY, 540);

    messages =
        new Messages(
            LANG_BASENAME,
            new Locale(prefs.getString(PREFS_LANGUAGE_KEY)),
            this.getClass().getClassLoader());

    pageMap = new HashMap<Class<? extends DREPage>, DREPage>();
    putPage(FileEntrySelectPage.class, new FileEntrySelectPage(this));
    putPage(PackageSelectPage.class, new PackageSelectPage(this));
    putPage(MeasureExecutePage.class, new MeasureExecutePage(this));
    putPage(SimilarEntrySelectPage.class, new SimilarEntrySelectPage(this));
    putPage(DisposeWaySelectPage.class, new DisposeWaySelectPage(this));
    putPage(DisposeExecutePage.class, new DisposeExecutePage(this));

    Display display = Display.getDefault();
    shell = new Shell(display);
    shell.setText(Application.APP_NAME + " " + Application.VERSION);
    shell.setSize(prefs.getInt(PREFS_SHELL_WIDTH_KEY), prefs.getInt(PREFS_SHELL_HEIGHT_KEY));
    {
      FormLayout l = new FormLayout();
      shell.setLayout(l);
    }
    shell.addShellListener(SHELL_CLOSED);
    createContents(shell);

    setActivePage(getPage(FileEntrySelectPage.class));

    shell.open();
    while (!shell.isDisposed()) {
      if (!display.readAndDispatch()) {
        display.sleep();
      }
    }

    try {
      prefs.save();
    } catch (IOException e) {
    }

    for (DREPage page : pageMap.values()) {
      page.dispose();
    }
    display.dispose();
  }
Exemple #3
0
 @Override
 public void widgetSelected(SelectionEvent event) {
   currentPage.nextRequested();
 }
Exemple #4
0
  private void createContents(Composite parent) {
    titleBar = new Composite(parent, SWT.NONE);
    titleBar.setBackground(new Color(Display.getDefault(), 255, 255, 255));
    {
      RowLayout l = new RowLayout(SWT.VERTICAL);
      l.marginWidth = l.marginHeight = 8;
      titleBar.setLayout(l);
    }
    pageTitleLabel = new Label(titleBar, SWT.NONE);
    pageTitleLabel.setBackground(new Color(Display.getDefault(), 255, 255, 255));
    pageTitleLabel.setFont(
        new Font(
            Display.getDefault(),
            Display.getDefault().getSystemFont().getFontData()[0].getName(),
            Display.getDefault().getSystemFont().getFontData()[0].getHeight(),
            SWT.BOLD));
    pageDescLabel = new Label(titleBar, SWT.NONE);
    pageDescLabel.setBackground(new Color(Display.getDefault(), 255, 255, 255));

    Group contentGroup = new Group(parent, SWT.NONE);
    {
      FillLayout l = new FillLayout();
      l.marginWidth = l.marginHeight = 8;
      contentGroup.setLayout(l);
    }
    contentComp = new Composite(contentGroup, SWT.NONE);
    contentComp.setLayout(contentStack = new StackLayout());

    Composite buttonBar = new Composite(parent, SWT.NONE);
    {
      FormLayout l = new FormLayout();
      l.marginWidth = l.marginHeight = 8;
      l.spacing = 8;
      buttonBar.setLayout(l);
    }
    prefsButton = new Button(buttonBar, SWT.PUSH);
    prefsButton.setText(messages.getString("DREFrame.CONFIG_BUTTON_TEXT"));
    prefsButton.addSelectionListener(PREFS_BUTTON_SELECTED);
    prevButton = new Button(buttonBar, SWT.PUSH);
    prevButton.setText(messages.getString("DREFrame.BACK_BUTTON_TEXT"));
    prevButton.addSelectionListener(PREV_BUTTON_SELECTED);
    nextButton = new Button(buttonBar, SWT.PUSH);
    nextButton.setText(messages.getString("DREFrame.NEXT_BUTTON_TEXT"));
    nextButton.addSelectionListener(NEXT_BUTTON_SELECTED);
    closeButton = new Button(buttonBar, SWT.PUSH);
    closeButton.setText(messages.getString("DREFrame.CLOSE_BUTTON_TEXT"));
    closeButton.addSelectionListener(CLOSE_BUTTON_SELECTED);

    prefsButton.setLayoutData(new FormDataBuilder().left(0).width(120).height(30).build());
    prevButton.setLayoutData(new FormDataBuilder().width(120).right(nextButton).height(30).build());
    nextButton.setLayoutData(
        new FormDataBuilder().width(120).right(closeButton).height(30).build());
    closeButton.setLayoutData(new FormDataBuilder().width(80).right(100).height(30).build());

    {
      FormData fd = new FormData();
      fd.top = new FormAttachment(0, 0);
      fd.left = new FormAttachment(0, 0);
      fd.right = new FormAttachment(100, 0);
      titleBar.setLayoutData(fd);
    }
    {
      FormData fd = new FormData();
      fd.top = new FormAttachment(titleBar);
      fd.bottom = new FormAttachment(buttonBar);
      fd.left = new FormAttachment(0, 0);
      fd.right = new FormAttachment(100, 0);
      contentGroup.setLayoutData(fd);
    }
    {
      FormData fd = new FormData();
      fd.bottom = new FormAttachment(100, 0);
      fd.left = new FormAttachment(0, 0);
      fd.right = new FormAttachment(100, 0);
      buttonBar.setLayoutData(fd);
    }

    for (DREPage page : pageMap.values()) {
      page.createContents(contentComp);
    }
  }