/** Create contents of the window. */
  protected void createContents() {
    mAndroidSdkUpdater = new Shell(mParentShell, SWT.SHELL_TRIM);
    mAndroidSdkUpdater.addDisposeListener(
        new DisposeListener() {
          public void widgetDisposed(DisposeEvent e) {
            onAndroidSdkUpdaterDispose(); // $hide$ (hide from SWT designer)
          }
        });

    FillLayout fl;
    mAndroidSdkUpdater.setLayout(fl = new FillLayout(SWT.HORIZONTAL));
    fl.marginHeight = fl.marginWidth = 5;
    mAndroidSdkUpdater.setMinimumSize(new Point(200, 50));
    mAndroidSdkUpdater.setSize(745, 433);
    mAndroidSdkUpdater.setText("Android SDK and AVD Manager");

    mSashForm = new SashForm(mAndroidSdkUpdater, SWT.NONE);

    mPageList = new List(mSashForm, SWT.BORDER);
    mPageList.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            onPageListSelected(); // $hide$ (hide from SWT designer)
          }
        });

    mPagesRootComposite = new Composite(mSashForm, SWT.NONE);
    mStackLayout = new StackLayout();
    mPagesRootComposite.setLayout(mStackLayout);

    createPages();

    mSashForm.setWeights(new int[] {150, 576});
  }
Example #2
0
  /** Create contents of the window. */
  protected void createContents() {
    shell = new Shell();
    shell.setMinimumSize(new Point(800, 600));
    shell.setSize(800, 600);
    shell.setText("RIGERS - Statistiche");
    shell.setLayout(new GridLayout(1, false));

    composite = new Composite(shell, SWT.NONE);
    ViewDataTab();
  }
Example #3
0
  private void create(Shell parent, boolean readOnly) {
    shell.setText("Segmentation");
    if (parent != null) UIUtil.inheritIcon(shell, parent);
    GridLayout layTmp = new GridLayout();
    layTmp.marginBottom = 0;
    layTmp.verticalSpacing = 0;
    shell.setLayout(layTmp);

    createComposite(shell);

    // --- Dialog-level buttons

    SelectionAdapter OKCancelActions =
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            result = false;
            if (e.widget.getData().equals("h")) {
              if (help != null) help.showWiki("Segmentation Step");
              return;
            }
            if (e.widget.getData().equals("o")) saveData();
            shell.close();
          };
        };
    pnlActions = new OKCancelPanel(shell, SWT.NONE, OKCancelActions, true);
    pnlActions.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    pnlActions.btOK.setEnabled(!readOnly);
    if (!readOnly) {
      shell.setDefaultButton(pnlActions.btOK);
    }

    shell.pack();
    shell.setMinimumSize(shell.getSize());
    Point startSize = shell.getMinimumSize();
    if (startSize.x < 600) startSize.x = 600;
    shell.setSize(startSize);
    setData();
    Dialogs.centerWindow(shell, parent);
  }
Example #4
0
  public static void display() {
    initShell();
    initGroup();
    newLabel("Number of rows");
    newSpinner();
    newLabel("Number of columns");
    newSpinner();

    new Label(askShell, SWT.NONE);

    Button button = new Button(askShell, SWT.PUSH);
    button.setText("OK");
    button.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, false, false, 1, 1));
    button.addListener(
        SWT.Selection,
        new Listener() {
          @Override
          public void handleEvent(Event e) {
            GameOfLife.USER_COORDINATES =
                new Coordinate(dimensions[0].getSelection(), dimensions[1].getSelection());
            askShell.notifyListeners(SWT.OK, null);
          }
        });

    askShell.pack();
    askShell.setMinimumSize(askShell.getSize());

    center();

    askShell.open();
    while (!askShell.isDisposed() && !GameOfLife.CANCELLED) {
      if (!GameOfLife.DISPLAY.readAndDispatch()) {
        GameOfLife.DISPLAY.sleep();
      }
    }
  }
  public void showDialog(Shell shell) {
    TGMeasureImpl measure = getEditor().getTablature().getCaret().getMeasure();
    if (measure != null) {
      final Shell dialog = DialogUtils.newDialog(shell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);

      dialog.setLayout(new GridLayout());
      dialog.setText(TuxGuitar.getProperty("composition.tripletfeel"));
      dialog.setMinimumSize(300, 0);

      // -------------TIME SIGNATURE-----------------------------------------------
      Group tripletFeel = new Group(dialog, SWT.SHADOW_ETCHED_IN);
      tripletFeel.setLayout(new GridLayout());
      tripletFeel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
      tripletFeel.setText(TuxGuitar.getProperty("composition.tripletfeel"));

      // none
      final Button tripletFeelNone = new Button(tripletFeel, SWT.RADIO);
      tripletFeelNone.setText(TuxGuitar.getProperty("composition.tripletfeel.none"));
      tripletFeelNone.setSelection(measure.getTripletFeel() == TGMeasureHeader.TRIPLET_FEEL_NONE);

      final Button tripletFeelEighth = new Button(tripletFeel, SWT.RADIO);
      tripletFeelEighth.setText(TuxGuitar.getProperty("composition.tripletfeel.eighth"));
      tripletFeelEighth.setSelection(
          measure.getTripletFeel() == TGMeasureHeader.TRIPLET_FEEL_EIGHTH);

      final Button tripletFeelSixteenth = new Button(tripletFeel, SWT.RADIO);
      tripletFeelSixteenth.setText(TuxGuitar.getProperty("composition.tripletfeel.sixteenth"));
      tripletFeelSixteenth.setSelection(
          measure.getTripletFeel() == TGMeasureHeader.TRIPLET_FEEL_SIXTEENTH);

      // --------------------To End Checkbox-------------------------------
      Group check = new Group(dialog, SWT.SHADOW_ETCHED_IN);
      check.setLayout(new GridLayout());
      check.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
      check.setText(TuxGuitar.getProperty("options"));

      final Button toEnd = new Button(check, SWT.CHECK);
      toEnd.setText(TuxGuitar.getProperty("composition.tripletfeel.to-the-end"));
      toEnd.setSelection(true);
      // ------------------BUTTONS--------------------------
      Composite buttons = new Composite(dialog, SWT.NONE);
      buttons.setLayout(new GridLayout(2, false));
      buttons.setLayoutData(new GridData(SWT.END, SWT.FILL, true, true));

      final Button buttonOk = new Button(buttons, SWT.PUSH);
      buttonOk.setText(TuxGuitar.getProperty("ok"));
      buttonOk.setLayoutData(getButtonData());
      buttonOk.addSelectionListener(
          new SelectionAdapter() {
            public void widgetSelected(SelectionEvent arg0) {
              final boolean toEndValue = toEnd.getSelection();
              final int tripletFeel =
                  getSelectedTripletFeel(tripletFeelNone, tripletFeelEighth, tripletFeelSixteenth);

              dialog.dispose();
              try {
                TGSynchronizer.instance()
                    .runLater(
                        new TGSynchronizer.TGRunnable() {
                          public void run() throws Throwable {
                            ActionLock.lock();
                            TuxGuitar.instance().loadCursor(SWT.CURSOR_WAIT);
                            setTripletFeel(tripletFeel, toEndValue);
                            TuxGuitar.instance().updateCache(true);
                            TuxGuitar.instance().loadCursor(SWT.CURSOR_ARROW);
                            ActionLock.unlock();
                          }
                        });
              } catch (Throwable throwable) {
                MessageDialog.errorMessage(throwable);
              }
            }
          });

      Button buttonCancel = new Button(buttons, SWT.PUSH);
      buttonCancel.setLayoutData(getButtonData());
      buttonCancel.setText(TuxGuitar.getProperty("cancel"));
      buttonCancel.addSelectionListener(
          new SelectionAdapter() {
            public void widgetSelected(SelectionEvent arg0) {
              dialog.dispose();
            }
          });

      dialog.setDefaultButton(buttonOk);

      DialogUtils.openDialog(
          dialog,
          DialogUtils.OPEN_STYLE_CENTER
              | DialogUtils.OPEN_STYLE_PACK
              | DialogUtils.OPEN_STYLE_WAIT);
    }
  }
Example #6
0
  /**
   * Creates a new AboutDialog object. The icon displayed in this dialog box is provided by the
   * parent shell. It should be either a unique image (Shell.getImage()), or the second image of a
   * list of (Shell.getImages()[1]).
   *
   * @param parent The parent shell (also carry the icon to display).
   * @param caption Caption text.
   * @param description Text for the application description line.
   * @param version Text for the application version line.
   */
  public AboutDialog(Shell parent, String caption, String description, String version) {
    // Take the opportunity to do some clean up if possible
    Runtime rt = Runtime.getRuntime();
    rt.runFinalization();
    rt.gc();

    shell = new Shell(parent, SWT.CLOSE | SWT.TITLE | SWT.RESIZE | SWT.APPLICATION_MODAL);
    shell.setText(caption);
    UIUtil.inheritIcon(shell, parent);
    shell.setLayout(new GridLayout());

    Composite cmpTmp = new Composite(shell, SWT.BORDER);
    cmpTmp.setLayoutData(new GridData(GridData.FILL_BOTH));
    GridLayout layTmp = new GridLayout(2, false);
    cmpTmp.setLayout(layTmp);

    // Application icon
    Label appIcon = new Label(cmpTmp, SWT.NONE);
    GridData gdTmp = new GridData();
    gdTmp.verticalSpan = 2;
    appIcon.setLayoutData(gdTmp);
    Image[] list = parent.getImages();
    // Gets the single icon
    if ((list == null) || (list.length < 2)) {
      appIcon.setImage(parent.getImage());
    } else { // Or the second one if there are more than one.
      appIcon.setImage(list[1]);
    }

    Label label = new Label(cmpTmp, SWT.NONE);
    label.setText(description == null ? "TBD" : description); // $NON-NLS-1$
    gdTmp =
        new GridData(
            GridData.HORIZONTAL_ALIGN_CENTER
                | GridData.GRAB_HORIZONTAL
                | GridData.VERTICAL_ALIGN_CENTER
                | GridData.GRAB_VERTICAL);
    label.setLayoutData(gdTmp);

    label = new Label(cmpTmp, SWT.NONE);
    label.setText(
        String.format(
            Res.getString("AboutDialog.versionLabel"),
            version == null ? "TBD" : version)); // $NON-NLS-1$
    gdTmp =
        new GridData(
            GridData.HORIZONTAL_ALIGN_CENTER
                | GridData.GRAB_HORIZONTAL
                | GridData.VERTICAL_ALIGN_CENTER
                | GridData.GRAB_VERTICAL);
    label.setLayoutData(gdTmp);

    // Info

    cmpTmp = new Composite(shell, SWT.BORDER);
    cmpTmp.setLayoutData(new GridData(GridData.FILL_BOTH));
    layTmp = new GridLayout(2, false);
    cmpTmp.setLayout(layTmp);

    label = new Label(cmpTmp, SWT.NONE);
    label.setText(Res.getString("AboutDialog.jvmVersion")); // $NON-NLS-1$
    label = new Label(cmpTmp, SWT.NONE);
    label.setText(System.getProperty("java.version")); // $NON-NLS-1$
    label = new Label(cmpTmp, SWT.NONE);
    label.setText(Res.getString("AboutDialog.platform")); // $NON-NLS-1$
    label = new Label(cmpTmp, SWT.NONE);
    label.setText(
        String.format(
            "%s, %s, %s", //$NON-NLS-1$
            System.getProperty("os.name"), // $NON-NLS-1$
            System.getProperty("os.arch"), // $NON-NLS-1$
            System.getProperty("os.version"))); // $NON-NLS-1$
    label = new Label(cmpTmp, SWT.NONE);
    label.setText(Res.getString("AboutDialog.memoryLabel")); // $NON-NLS-1$
    label = new Label(cmpTmp, SWT.NONE);
    NumberFormat nf = NumberFormat.getInstance();
    label.setText(
        String.format(
            Res.getString("AboutDialog.memory"), // $NON-NLS-1$
            nf.format(rt.freeMemory() / 1024),
            nf.format(rt.totalMemory() / 1024)));

    // --- Dialog-level buttons

    SelectionAdapter CloseActions =
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            shell.close();
          };
        };
    ClosePanel pnlActions = new ClosePanel(shell, SWT.NONE, CloseActions, false);
    pnlActions.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    shell.setDefaultButton(pnlActions.btClose);

    shell.pack();
    shell.setMinimumSize(shell.getSize());
    Point startSize = shell.getMinimumSize();
    if (startSize.x < 350) startSize.x = 350;
    shell.setSize(startSize);
    Dialogs.centerWindow(shell, parent);
  }
Example #7
0
  private void create(Shell parent, boolean readOnly) {
    shell.setText(Res.getString("EditorCaption"));
    if (parent != null) shell.setImage(parent.getImage());
    GridLayout layTmp = new GridLayout();
    layTmp.marginBottom = 0;
    layTmp.verticalSpacing = 0;
    shell.setLayout(layTmp);

    TabFolder tfTmp = new TabFolder(shell, SWT.NONE);
    GridData gdTmp = new GridData(GridData.FILL_BOTH);
    tfTmp.setLayoutData(gdTmp);

    // --- Options tab

    Composite cmpTmp = new Composite(tfTmp, SWT.NONE);
    layTmp = new GridLayout();
    cmpTmp.setLayout(layTmp);

    Group grpTmp = new Group(cmpTmp, SWT.NONE);
    layTmp = new GridLayout();
    grpTmp.setLayout(layTmp);
    grpTmp.setText(Res.getString("grpStandaloneStrings"));
    gdTmp = new GridData(GridData.FILL_HORIZONTAL);
    grpTmp.setLayoutData(gdTmp);

    chkExtractStandalone = new Button(grpTmp, SWT.CHECK);
    chkExtractStandalone.setText(Res.getString("chkExtractStandalone"));

    grpTmp = new Group(cmpTmp, SWT.NONE);
    grpTmp.setLayout(new GridLayout());
    grpTmp.setText(Res.getString("grpKeyValuePairs"));
    gdTmp = new GridData(GridData.FILL_HORIZONTAL);
    grpTmp.setLayoutData(gdTmp);

    rdExtractAllPairs = new Button(grpTmp, SWT.RADIO);
    rdExtractAllPairs.setText(Res.getString("rdExtractAllPairs"));
    rdDontExtractPairs = new Button(grpTmp, SWT.RADIO);
    rdDontExtractPairs.setText(Res.getString("rdDontExtractPairs"));

    Label label = new Label(grpTmp, SWT.NONE);
    label.setText(Res.getString("stExceptions"));

    edExceptions = new Text(grpTmp, SWT.BORDER);
    gdTmp = new GridData(GridData.FILL_HORIZONTAL);
    edExceptions.setLayoutData(gdTmp);

    TabItem tiTmp = new TabItem(tfTmp, SWT.NONE);
    tiTmp.setText(Res.getString("tabOptions"));
    tiTmp.setControl(cmpTmp);

    // --- Inline tab

    cmpTmp = new Composite(tfTmp, SWT.NONE);
    layTmp = new GridLayout();
    cmpTmp.setLayout(layTmp);

    chkUseCodeFinder = new Button(cmpTmp, SWT.CHECK);
    chkUseCodeFinder.setText("Has inline codes as defined below:");
    chkUseCodeFinder.addSelectionListener(
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            updateInlineCodes();
          };
        });

    pnlCodeFinder = new InlineCodeFinderPanel(cmpTmp, SWT.NONE);
    pnlCodeFinder.setLayoutData(new GridData(GridData.FILL_BOTH));

    tiTmp = new TabItem(tfTmp, SWT.NONE);
    tiTmp.setText("Inline Codes");
    tiTmp.setControl(cmpTmp);

    // --- Output tab

    /*cmpTmp = new Composite(tfTmp, SWT.NONE);
    layTmp = new GridLayout();
    cmpTmp.setLayout(layTmp);

    grpTmp = new Group(cmpTmp, SWT.NONE);
    layTmp = new GridLayout();
    grpTmp.setLayout(layTmp);
    grpTmp.setText(Res.getString("grpExtendedChars"));
    gdTmp = new GridData(GridData.FILL_HORIZONTAL);
    grpTmp.setLayoutData(gdTmp);

    chkEscapeExtendedChars = new Button(grpTmp, SWT.CHECK);
    chkEscapeExtendedChars.setText(Res.getString("chkEscapeExtendedChars"));

    tiTmp = new TabItem(tfTmp, SWT.NONE);
    tiTmp.setText(Res.getString("tabOutput"));
    tiTmp.setControl(cmpTmp);*/

    // --- Dialog-level buttons

    SelectionAdapter OKCancelActions =
        new SelectionAdapter() {
          public void widgetSelected(SelectionEvent e) {
            result = false;
            if (e.widget.getData().equals("h")) {
              if (help != null) help.showWiki("JSON Filter");
              return;
            }
            if (e.widget.getData().equals("o")) {
              if (!saveData()) return;
              result = true;
            }
            shell.close();
          };
        };
    pnlActions = new OKCancelPanel(shell, SWT.NONE, OKCancelActions, true);
    gdTmp = new GridData(GridData.FILL_HORIZONTAL);
    pnlActions.setLayoutData(gdTmp);
    pnlActions.btOK.setEnabled(!readOnly);
    if (!readOnly) {
      shell.setDefaultButton(pnlActions.btOK);
    }

    shell.pack();
    Rectangle Rect = shell.getBounds();
    shell.setMinimumSize(Rect.width, Rect.height);
    Dialogs.centerWindow(shell, parent);
    setData();
  }
  /** Create contents of the window */
  protected void createContents() {

    m_shell = new Shell();

    m_shell.setImage(SWTResourceManager.getImage(IPAToolAppWnd.class, "/Properties.ico"));
    final BorderLayout borderLayout = new BorderLayout(0, 0);
    borderLayout.setVgap(5);
    m_shell.setLayout(borderLayout);
    m_shell.setSize(800, 400);
    m_shell.setMinimumSize(new Point(800, 400));
    m_shell.setText("IPATool2");

    Composite composite;
    composite = new Composite(m_shell, SWT.NONE);
    {
      TabFolder tabFolder = new TabFolder(composite, SWT.NONE);
      tabFolder.setBounds(10, 10, 748, 200);

      {
        TabItem tbtmTools = new TabItem(tabFolder, SWT.NONE);
        tbtmTools.setText("Tools");

        Composite composite_1 = new Composite(tabFolder, SWT.NONE);
        tbtmTools.setControl(composite_1);

        m_txtUpdFolder = new Text(composite_1, SWT.BORDER);
        m_txtUpdFolder.setText("");
        m_txtUpdFolder.setBounds(122, 14, 564, 21);

        Button btnUpdFolder = new Button(composite_1, SWT.NONE);
        btnUpdFolder.addSelectionListener(
            new SelectionAdapter() {

              @Override
              public void widgetSelected(SelectionEvent e) {
                _selectFolder(m_txtUpdFolder);
              }
            });
        btnUpdFolder.setText("...");
        btnUpdFolder.setBounds(692, 12, 38, 25);

        m_txtExistingFolder = new Text(composite_1, SWT.BORDER);
        m_txtExistingFolder.setText("");
        m_txtExistingFolder.setBounds(122, 45, 564, 21);

        Button btnExFolder = new Button(composite_1, SWT.NONE);
        btnExFolder.addSelectionListener(
            new SelectionAdapter() {

              @Override
              public void widgetSelected(SelectionEvent e) {
                _selectFolder(m_txtExistingFolder);
              }
            });
        btnExFolder.setText("...");
        btnExFolder.setBounds(692, 43, 38, 25);

        m_txtITunesFolder = new Text(composite_1, SWT.BORDER);
        m_txtITunesFolder.setText("");
        m_txtITunesFolder.setBounds(122, 76, 564, 21);

        Button btnitunesFolder = new Button(composite_1, SWT.NONE);
        btnitunesFolder.addSelectionListener(
            new SelectionAdapter() {

              @Override
              public void widgetSelected(SelectionEvent e) {
                _selectFolder(m_txtITunesFolder);
              }
            });
        btnitunesFolder.setText("...");
        btnitunesFolder.setBounds(692, 74, 38, 25);

        m_lbliTunes = new Label(composite_1, SWT.NONE);
        m_lbliTunes.setText("iTunes IPAs Folder:");
        m_lbliTunes.setBounds(10, 79, 119, 15);

        m_lblExFolder = new Label(composite_1, SWT.NONE);
        m_lblExFolder.setText("Current IPAs Folder:");
        m_lblExFolder.setBounds(10, 48, 119, 15);

        Label lblUpdFolder = new Label(composite_1, SWT.NONE);
        lblUpdFolder.setFont(SWTResourceManager.getFont("Segoe UI", 9, SWT.BOLD));
        lblUpdFolder.setForeground(SWTResourceManager.getColor(SWT.COLOR_RED));
        lblUpdFolder.setText(" IPAs Folder:");
        lblUpdFolder.setBounds(10, 17, 119, 15);
        {
          m_chkRecurseFolders = new Button(composite_1, SWT.CHECK);
          m_chkRecurseFolders.addSelectionListener(
              new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {}
              });
          m_chkRecurseFolders.setLocation(122, 103);
          m_chkRecurseFolders.setSize(107, 16);
          m_chkRecurseFolders.setSelection(true);
          m_chkRecurseFolders.setText("Recurse folders");
        }
        {
          m_btnRenameIPAs = new Button(composite_1, SWT.NONE);
          m_btnRenameIPAs.setBackground(SWTResourceManager.getColor(SWT.COLOR_RED));
          m_btnRenameIPAs.setLocation(120, 137);
          m_btnRenameIPAs.setSize(94, 25);
          m_btnRenameIPAs.addSelectionListener(
              new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                  renameIPAs();
                }
              });
          m_btnRenameIPAs.setText("Rename IPAs");
        }

        m_btnUpdateIPAs = new Button(composite_1, SWT.NONE);
        m_btnUpdateIPAs.addSelectionListener(
            new SelectionAdapter() {

              @Override
              public void widgetSelected(SelectionEvent e) {
                updateIPAs();
              }
            });
        m_btnUpdateIPAs.setBounds(216, 137, 94, 25);
        m_btnUpdateIPAs.setText("Update IPAs");

        m_chkUseAllFolders = new Button(composite_1, SWT.CHECK);
        m_chkUseAllFolders.addSelectionListener(
            new SelectionAdapter() {

              @Override
              public void widgetSelected(SelectionEvent e) {
                if (m_chkUseAllFolders.getSelection()) {
                  m_lblExFolder.setForeground(SWTResourceManager.getColor(SWT.COLOR_RED));
                  m_lbliTunes.setForeground(SWTResourceManager.getColor(SWT.COLOR_RED));
                } else {
                  m_lblExFolder.setForeground(null);
                  m_lbliTunes.setForeground(null);
                }
              }
            });
        m_chkUseAllFolders.setBounds(244, 103, 107, 16);
        m_chkUseAllFolders.setText("Use all folders");

        m_btnCleanJPGs = new Button(composite_1, SWT.NONE);
        m_btnCleanJPGs.setBackground(SWTResourceManager.getColor(SWT.COLOR_RED));
        m_btnCleanJPGs.setBounds(310, 137, 94, 25);
        m_btnCleanJPGs.addSelectionListener(
            new SelectionAdapter() {

              @Override
              public void widgetSelected(SelectionEvent e) {
                cleanJPEGs();
              }
            });
        m_btnCleanJPGs.setText("Clean JPEGs");
      }

      TabItem tbtmCheckIPAs = new TabItem(tabFolder, SWT.NONE);
      tbtmCheckIPAs.setText("Check");

      Composite composite_1 = new Composite(tabFolder, SWT.NONE);
      tbtmCheckIPAs.setControl(composite_1);

      m_txtIPhoneFolder = new Text(composite_1, SWT.BORDER);
      m_txtIPhoneFolder.setText("");
      m_txtIPhoneFolder.setBounds(122, 14, 564, 21);

      Button btnIPhoneFolder = new Button(composite_1, SWT.NONE);
      btnIPhoneFolder.addSelectionListener(
          new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
              _selectFolder(m_txtIPhoneFolder);
            }
          });
      btnIPhoneFolder.setText("...");
      btnIPhoneFolder.setBounds(692, 12, 38, 25);

      m_txtIPadFolder = new Text(composite_1, SWT.BORDER);
      m_txtIPadFolder.setText("");
      m_txtIPadFolder.setBounds(122, 45, 564, 21);

      Button btnIPadFolder = new Button(composite_1, SWT.NONE);
      btnIPadFolder.addSelectionListener(
          new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
              _selectFolder(m_txtIPadFolder);
            }
          });
      btnIPadFolder.setText("...");
      btnIPadFolder.setBounds(692, 43, 38, 25);

      m_txtMixedFolder = new Text(composite_1, SWT.BORDER);
      m_txtMixedFolder.setText("");
      m_txtMixedFolder.setBounds(122, 76, 564, 21);

      Button btnMixedFolder = new Button(composite_1, SWT.NONE);
      btnMixedFolder.addSelectionListener(
          new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
              _selectFolder(m_txtMixedFolder);
            }
          });
      btnMixedFolder.setText("...");
      btnMixedFolder.setBounds(692, 74, 38, 25);

      Label lblBothIpasFolder = new Label(composite_1, SWT.NONE);
      lblBothIpasFolder.setText("mixed Folder:");
      lblBothIpasFolder.setBounds(10, 79, 119, 15);

      Label lblIpadIpasFolder = new Label(composite_1, SWT.NONE);
      lblIpadIpasFolder.setText("iPad Folder:");
      lblIpadIpasFolder.setBounds(10, 48, 119, 15);

      Label lblIphoneFolder = new Label(composite_1, SWT.NONE);
      lblIphoneFolder.setText("iPhone Folder:");
      lblIphoneFolder.setBounds(10, 17, 119, 15);

      m_btnCheck = new Button(composite_1, SWT.NONE);
      m_btnCheck.addSelectionListener(
          new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
              checkIPAs();
            }
          });
      m_btnCheck.setText("Check IPAs");
      m_btnCheck.setBounds(122, 122, 90, 25);
    }
    composite.setLayoutData(BorderLayout.NORTH);

    final Label lblX = new Label(composite, SWT.NONE);
    lblX.setBounds(10, 10, 14, 211);
    final TabFolder m_tabTraces = new TabFolder(m_shell, SWT.NONE);
    m_tabTraces.setLayoutData(BorderLayout.CENTER);

    final Composite composite_1 = new Composite(m_shell, SWT.NONE);
    composite_1.setLayout(new BorderLayout(0, 0));
    composite_1.setLayoutData(BorderLayout.CENTER);

    // ------------------------------------------------------------------------
    // ********** TabbedTracer ***********************************************
    final CTabFolder tabTraces = m_tabbedTracer.createTabFolder(composite_1);
    tabTraces.setLayoutData(BorderLayout.CENTER);
    Tracer.setTracer(m_tabbedTracer);
  }
  /** Create contents of the window */
  protected void createContents() {

    m_BkscoverageShell = new Shell();

    m_BkscoverageShell.setImage(
        SWTResourceManager.getImage(BKSCoverageAppWnd.class, "/Properties.ico"));
    final BorderLayout borderLayout = new BorderLayout(0, 0);
    borderLayout.setVgap(5);
    m_BkscoverageShell.setLayout(borderLayout);
    m_BkscoverageShell.setSize(800, 400);
    m_BkscoverageShell.setMinimumSize(new Point(800, 400));
    m_BkscoverageShell.setText("BKSCoverage");

    Composite composite;
    composite = new Composite(m_BkscoverageShell, SWT.NONE);
    {
      TabFolder tabFolder = new TabFolder(composite, SWT.NONE);
      tabFolder.setBounds(10, 10, 748, 173);

      {
        TabItem tbtmTools = new TabItem(tabFolder, SWT.NONE);
        tbtmTools.setText("Parameters");

        Composite composite_1 = new Composite(tabFolder, SWT.NONE);
        tbtmTools.setControl(composite_1);

        m_txtWKSPFolder = new Text(composite_1, SWT.BORDER);
        m_txtWKSPFolder.setText("");
        m_txtWKSPFolder.setBounds(122, 14, 564, 21);

        Button btnWKSPFolder = new Button(composite_1, SWT.NONE);
        btnWKSPFolder.addSelectionListener(
            new SelectionAdapter() {

              @Override
              public void widgetSelected(SelectionEvent e) {
                _selectFolder(m_txtWKSPFolder);
              }
            });
        btnWKSPFolder.setText("...");
        btnWKSPFolder.setBounds(692, 12, 38, 25);

        m_txtStorageFile = new Text(composite_1, SWT.BORDER);
        m_txtStorageFile.setText("");
        m_txtStorageFile.setBounds(122, 45, 564, 21);

        Button btnStorageFile = new Button(composite_1, SWT.NONE);
        btnStorageFile.addSelectionListener(
            new SelectionAdapter() {

              @Override
              public void widgetSelected(SelectionEvent e) {
                _selectFolder(m_txtStorageFile);
              }
            });
        btnStorageFile.setText("...");
        btnStorageFile.setBounds(692, 43, 38, 25);

        m_lblStorageFile = new Label(composite_1, SWT.NONE);
        m_lblStorageFile.setText("Storage File:");
        m_lblStorageFile.setBounds(10, 48, 119, 15);

        Label lblUpdFolder = new Label(composite_1, SWT.NONE);
        lblUpdFolder.setText("WKSP Folder:");
        lblUpdFolder.setBounds(10, 17, 119, 15);
        {
          m_chkLoadFromStorage = new Button(composite_1, SWT.CHECK);
          m_chkLoadFromStorage.addSelectionListener(
              new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {}
              });
          m_chkLoadFromStorage.setLocation(122, 75);
          m_chkLoadFromStorage.setSize(138, 16);
          m_chkLoadFromStorage.setSelection(true);
          m_chkLoadFromStorage.setText("Load From Storage");
        }
        {
          m_btnCheckWKSP = new Button(composite_1, SWT.NONE);
          m_btnCheckWKSP.setLocation(120, 109);
          m_btnCheckWKSP.setSize(90, 25);
          m_btnCheckWKSP.addSelectionListener(
              new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                  checkWKPS();
                }
              });
          m_btnCheckWKSP.setText("Check WKSP");
        }
      }
    }
    composite.setLayoutData(BorderLayout.NORTH);

    final Label lblX = new Label(composite, SWT.NONE);
    lblX.setBounds(10, 10, 14, 180);
    final CTabFolder m_tabTraces = new CTabFolder(m_BkscoverageShell, SWT.NONE);
    m_tabTraces.setLayoutData(BorderLayout.CENTER);

    m_infoTabItem = new CTabItem(m_tabTraces, SWT.NONE);
    m_infoTabItem.setText("Info");

    final Text txtInfo =
        new Text(m_tabTraces, SWT.V_SCROLL | SWT.READ_ONLY | SWT.MULTI | SWT.H_SCROLL | SWT.BORDER);
    txtInfo.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));
    txtInfo.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
    txtInfo.setEditable(false);
    m_infoTabItem.setControl(txtInfo);

    m_warnTabItem = new CTabItem(m_tabTraces, SWT.NONE);
    m_warnTabItem.setText("Warning");

    final Text txtWarn =
        new Text(m_tabTraces, SWT.V_SCROLL | SWT.READ_ONLY | SWT.MULTI | SWT.H_SCROLL | SWT.BORDER);
    txtWarn.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));
    txtWarn.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
    txtWarn.setEditable(false);
    m_warnTabItem.setControl(txtWarn);

    m_debugTabItem = new CTabItem(m_tabTraces, SWT.NONE);
    m_debugTabItem.setText("Debug");

    final Text txtDebug =
        new Text(m_tabTraces, SWT.V_SCROLL | SWT.READ_ONLY | SWT.MULTI | SWT.H_SCROLL | SWT.BORDER);
    txtDebug.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));
    txtDebug.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
    txtDebug.setEditable(false);
    m_debugTabItem.setControl(txtDebug);

    m_errorTabItem = new CTabItem(m_tabTraces, SWT.NONE);
    m_errorTabItem.setText("Error");

    final Text txtError =
        new Text(m_tabTraces, SWT.V_SCROLL | SWT.READ_ONLY | SWT.MULTI | SWT.H_SCROLL | SWT.BORDER);
    txtError.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED));
    txtError.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
    txtError.setEditable(false);
    m_errorTabItem.setControl(txtError);
  }
Example #10
0
 /**
  * Configures the shell.
  *
  * @param shell The shell to configure
  */
 protected void configureShell(Shell shell) {
   super.configureShell(shell);
   shell.setText(title);
   shell.setMinimumSize(600, 300);
 }
 /**
  * Method configureShell.
  *
  * @param shell Shell
  * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
  */
 @Override
 protected void configureShell(Shell shell) {
   super.configureShell(shell);
   shell.setText(ADD_PARTICIPANT_DIALOG_TITLE);
   shell.setMinimumSize(R4EUIConstants.DIALOG_DEFAULT_WIDTH, R4EUIConstants.DIALOG_DEFAULT_HEIGHT);
 }
Example #12
0
  protected void createContents() {
    shlPonyTrivia = new Shell();
    shlPonyTrivia.setBackground(SWTResourceManager.getColor(255, 240, 245));
    shlPonyTrivia.setSize(800, 600);
    shlPonyTrivia.setText("Pony Trivia");
    shlPonyTrivia.setLayout(new FormLayout());
    shlPonyTrivia.setMinimumSize(shlPonyTrivia.getSize());

    final Label lblFlower = new Label(shlPonyTrivia, SWT.NONE);
    lblFlower.setBackground(SWTResourceManager.getColor(255, 240, 245));
    FormData fd_lblFlower = new FormData();
    fd_lblFlower.left = new FormAttachment(0, 10);
    lblFlower.setLayoutData(fd_lblFlower);
    lblFlower.setImage(
        SWTResourceManager.getImage(GameScreen.class, "/ponytrivia/gui/res/flower.gif"));

    final Label lblDevil = new Label(shlPonyTrivia, SWT.NONE);
    lblDevil.setBackground(SWTResourceManager.getColor(255, 240, 245));
    FormData fd_lblDevil = new FormData();
    fd_lblDevil.right = new FormAttachment(100, -10);
    fd_lblDevil.top = new FormAttachment(lblFlower, 0, SWT.TOP);
    lblDevil.setLayoutData(fd_lblDevil);
    lblDevil.setImage(
        SWTResourceManager.getImage(GameScreen.class, "/ponytrivia/gui/res/hell_boy.gif"));

    Composite composite = new Composite(shlPonyTrivia, SWT.NONE);
    composite.setBackground(SWTResourceManager.getColor(255, 240, 245));
    composite.setLocation(10, -227);
    composite.setLayout(new FormLayout());
    FormData fd_composite = new FormData();
    fd_composite.bottom = new FormAttachment(100, -10);
    fd_composite.left = new FormAttachment(0, 10);
    fd_composite.right = new FormAttachment(100, -10);
    composite.setLayoutData(fd_composite);

    final Button btnNext = new Button(composite, SWT.NONE);
    btnNext.setEnabled(false);
    FormData fd_btnNext = new FormData();
    fd_btnNext.right = new FormAttachment(100, -10);
    btnNext.setLayoutData(fd_btnNext);
    btnNext.setText("Next");

    final Button btnFiftyFifty = new Button(composite, SWT.NONE);
    fd_btnNext.left = new FormAttachment(btnFiftyFifty, 0, SWT.LEFT);
    btnFiftyFifty.setToolTipText("");
    FormData fd_btnFiftyFifty = new FormData();
    fd_btnFiftyFifty.right = new FormAttachment(100, -10);
    btnFiftyFifty.setLayoutData(fd_btnFiftyFifty);
    btnFiftyFifty.setImage(
        SWTResourceManager.getImage(GameScreen.class, "/ponytrivia/gui/res/lifebelt.gif"));

    Composite composite_1 = new Composite(composite, SWT.NONE);
    composite_1.setBackground(SWTResourceManager.getColor(255, 240, 245));
    fd_btnNext.top = new FormAttachment(composite_1, 4);
    fd_btnFiftyFifty.bottom = new FormAttachment(composite_1, -6);
    composite_1.setLayout(new FillLayout(SWT.VERTICAL));
    FormData fd_composite_1 = new FormData();
    fd_composite_1.left = new FormAttachment(0, 10);
    fd_composite_1.right = new FormAttachment(100, -10);
    fd_composite_1.top = new FormAttachment(0, 90);
    fd_composite_1.bottom = new FormAttachment(100, -44);
    composite_1.setLayoutData(fd_composite_1);

    SelectionAdapter enableNext =
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent arg0) {
            if (shlPonyTrivia.isDisposed()) {
              return;
            }
            btnNext.setEnabled(true);
          }
        };

    final Button btnAnswer_1 = new Button(composite_1, SWT.RADIO);
    btnAnswer_1.addSelectionListener(enableNext);
    btnAnswer_1.setText("Answer 1");
    btnAnswer_1.setBackground(SWTResourceManager.getColor(255, 240, 245));

    final Button btnAnswer_2 = new Button(composite_1, SWT.RADIO);
    btnAnswer_2.addSelectionListener(enableNext);
    btnAnswer_2.setText("Answer 2");
    btnAnswer_2.setBackground(SWTResourceManager.getColor(255, 240, 245));

    final Button btnAnswer_3 = new Button(composite_1, SWT.RADIO);
    btnAnswer_3.addSelectionListener(enableNext);
    btnAnswer_3.setText("Answer 3");
    btnAnswer_3.setBackground(SWTResourceManager.getColor(255, 240, 245));

    final Button btnAnswer_4 = new Button(composite_1, SWT.RADIO);
    btnAnswer_4.addSelectionListener(enableNext);
    btnAnswer_4.setText("Answer 4");
    btnAnswer_4.setBackground(SWTResourceManager.getColor(255, 240, 245));

    Composite composite_2 = new Composite(composite, SWT.NONE);
    FormData fd_composite_2 = new FormData();
    fd_composite_2.right = new FormAttachment(btnFiftyFifty, -6);
    fd_composite_2.bottom = new FormAttachment(0, 84);
    fd_composite_2.top = new FormAttachment(0, 10);
    fd_composite_2.left = new FormAttachment(0, 10);
    composite_2.setLayoutData(fd_composite_2);
    composite_2.setLayout(new FillLayout(SWT.HORIZONTAL));

    final Label lblQuestionText = new Label(composite_2, SWT.NONE);
    lblQuestionText.setBackground(SWTResourceManager.getColor(255, 240, 245));
    lblQuestionText.setText("Question Text");

    Composite composite_3 = new Composite(shlPonyTrivia, SWT.NONE);
    composite_3.setBackground(SWTResourceManager.getColor(255, 240, 245));
    fd_lblFlower.top = new FormAttachment(composite_3, 37);
    composite_3.setLayout(new FormLayout());
    FormData fd_composite_3 = new FormData();
    fd_composite_3.left = new FormAttachment(0);
    fd_composite_3.right = new FormAttachment(100);
    fd_composite_3.top = new FormAttachment(0, 10);
    fd_composite_3.bottom = new FormAttachment(0, 51);
    composite_3.setLayoutData(fd_composite_3);

    final Label lblTime = new Label(composite_3, SWT.NONE);
    lblTime.setBackground(SWTResourceManager.getColor(255, 240, 245));
    FormData fd_lblTime = new FormData();
    fd_lblTime.top = new FormAttachment(0, 10);
    fd_lblTime.left = new FormAttachment(0, 10);
    lblTime.setLayoutData(fd_lblTime);
    lblTime.setText("Remaining Time: 30");

    final Label lblScore = new Label(composite_3, SWT.NONE);
    lblScore.setBackground(SWTResourceManager.getColor(255, 240, 245));
    FormData fd_lblScore = new FormData();
    fd_lblScore.left = new FormAttachment(100, -89);
    fd_lblScore.top = new FormAttachment(lblTime, 0, SWT.TOP);
    fd_lblScore.right = new FormAttachment(100, -10);
    lblScore.setLayoutData(fd_lblScore);
    lblScore.setText("Score: 0");

    final Composite composite_4 = new Composite(shlPonyTrivia, SWT.NONE);
    composite_4.setBackground(SWTResourceManager.getColor(255, 240, 245));
    fd_composite.top = new FormAttachment(0, 222);
    composite_4.setLayout(null);
    FormData fd_composite_4 = new FormData();
    fd_composite_4.bottom = new FormAttachment(composite, -6);
    fd_composite_4.top = new FormAttachment(composite_3, 6);
    fd_composite_4.right = new FormAttachment(lblDevil, -6);
    fd_composite_4.left = new FormAttachment(lblFlower, 6);
    composite_4.setLayoutData(fd_composite_4);

    final Label lblGrass = new Label(composite_4, SWT.NONE);
    lblGrass.setBounds(10, 129, 589, 20);

    final Label lblPony = new Label(composite_4, SWT.NONE);
    lblPony.setBackground(SWTResourceManager.getColor(255, 240, 245));
    lblPony.setBounds(260, 37, 84, 86);
    lblPony.setAlignment(SWT.CENTER);
    lblPony.setImage(imgKitty1);
    lblGrass.setBackground(SWTResourceManager.getColor(0, 204, 102));

    ////////////////////////////////////////////////////////////////////////////////// 0/////////

    final Button answerButtons[] =
        new Button[] {btnAnswer_1, btnAnswer_2, btnAnswer_3, btnAnswer_4};

    composite_4.addListener(
        SWT.Resize,
        new Listener() {
          public void handleEvent(Event e) {
            if (shlPonyTrivia.isDisposed()) {
              return;
            }

            Rectangle r = lblGrass.getBounds();
            r.width = composite_4.getBounds().width - 6;
            lblGrass.setBounds(r);

            int x =
                (int)
                    ((lblGrass.getBounds().width / 2)
                        * (1 - ((double) gameState.pony_pos) / config.questions_to_win));
            lblPony.setLocation(x - lblPony.getBounds().width / 2, lblPony.getLocation().y);
          }
        });

    final Runnable updateTimeLabel =
        new Runnable() {
          private Color original = lblTime.getForeground();

          @Override
          public void run() {
            if (shlPonyTrivia.isDisposed()) {
              return;
            }
            lblTime.setText("Remaining time: " + Math.max(0, gameState.remaining_time));
            if (gameState.remaining_time <= config.alotted_time / 3) {
              lblTime.setForeground(display.getSystemColor(SWT.COLOR_RED));
            } else {
              lblTime.setForeground(original);
            }
          }
        };
    updateTimeLabel.run();

    final Color origButtonColor = btnAnswer_1.getBackground();

    final Runnable updateQuestion =
        new Runnable() {
          @Override
          public void run() {
            if (shlPonyTrivia.isDisposed()) {
              return;
            }
            QuestionInfo qi;
            qi = questionRegistry.getQuestion();
            lblQuestionText.setText(qi.questionText);
            for (int i = 0; i < answerButtons.length; i++) {
              Button btn = answerButtons[i];
              btn.setText(qi.answers.get(i));
              btn.setEnabled(true);
              btn.setBackground(origButtonColor);
              btn.setSelection(false);
            }
            gameState.correctAnswerIndex = qi.correctAnswerIndex;
          }
        };
    updateQuestion.run();

    final SelectionAdapter answerQuestion =
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent arg0) {
            if (shlPonyTrivia.isDisposed()) {
              return;
            }

            int delta = lblGrass.getBounds().width / (2 * config.questions_to_win);
            int timeout = 1000;
            gameState.enabled = false;
            btnNext.setEnabled(false);

            final Button correct = answerButtons[gameState.correctAnswerIndex];

            if (correct.getSelection()) {
              gameState.total_score +=
                  10 + (gameState.remaining_time < 0 ? 0 : gameState.remaining_time);
              delta = -delta;
              correct.setBackground(new Color(display, 150, 250, 150));
              lblPony.setImage(imgKitty1);
              gameState.pony_pos += 1;
            } else {
              gameState.total_score -= 10;
              correct.setBackground(new Color(display, 250, 150, 150));
              timeout = 1500;
              lblPony.setImage(imgKitty2);
              gameState.pony_pos -= 1;
            }
            if (gameState.total_score < 0) {
              gameState.total_score = 0;
            }
            lblScore.setText("Score: " + gameState.total_score);
            gameState.question_number += 1;

            gameState.turnsBeforeEnablingFiftyFifty -= 1;

            class AnimatePony implements Runnable {
              private int delta;
              private int cnt;
              private int timeout;
              private final int steps = 20;
              private Point origPony;
              private Point origFlower;
              private Point origDevil;

              public AnimatePony(int delta, int timeout) {
                this.delta = delta;
                this.timeout = timeout;
                cnt = 0;
                origPony = lblPony.getLocation();
                origFlower = lblFlower.getLocation();
                origDevil = lblDevil.getLocation();
              }

              @Override
              public void run() {
                cnt++;
                Point p = lblPony.getLocation();
                double height = Math.abs(Math.sin(((double) cnt / steps) * 3 * Math.PI));
                lblPony.setLocation(p.x + delta / steps, origPony.y - (int) (10 * height));

                if (delta < 0) {
                  lblFlower.setLocation(
                      origFlower.x,
                      origFlower.y - (int) (10 * Math.sin((double) cnt / steps * Math.PI)));
                } else {
                  lblDevil.setLocation(
                      origDevil.x,
                      origDevil.y - (int) (10 * Math.sin((double) cnt / steps * Math.PI)));
                }

                if (cnt < steps) {
                  display.timerExec(timeout / steps, this);
                }
              }
            }

            display.timerExec(0, new AnimatePony(delta, (int) (timeout * 0.9)));

            display.timerExec(
                timeout,
                new Runnable() {
                  @Override
                  public void run() {
                    if (gameState.pony_pos >= config.questions_to_win) {
                      shlPonyTrivia.setEnabled(false);

                      try {
                        insertHighscore.insert(config.playerId, gameState.total_score);
                        schema.commit();
                      } catch (SQLException e) {
                        e.printStackTrace();
                      }

                      WinScreen.run(display);
                      shlPonyTrivia.close();
                      return;
                    }
                    if (gameState.pony_pos <= -config.questions_to_win) {
                      shlPonyTrivia.setEnabled(false);

                      try {
                        insertHighscore.insert(config.playerId, gameState.total_score);
                        schema.commit();
                      } catch (SQLException e) {
                        e.printStackTrace();
                      }

                      LoseScreen.run(display);
                      shlPonyTrivia.close();
                      return;
                    }
                    if (gameState.turnsBeforeEnablingFiftyFifty <= 0) {
                      gameState.turnsBeforeEnablingFiftyFifty = 0;
                      btnFiftyFifty.setEnabled(true);
                    }
                    updateTimeLabel.run();
                    updateQuestion.run();
                    gameState.remaining_time = config.alotted_time;
                    gameState.enabled = true;
                  }
                });
          }
        };

    btnFiftyFifty.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent arg0) {
            if (shlPonyTrivia.isDisposed()) {
              return;
            }
            btnFiftyFifty.setEnabled(false);
            gameState.turnsBeforeEnablingFiftyFifty = config.initalTurnsForFiftyFifty;
            ArrayList<Integer> discarded = new ArrayList<Integer>();
            discarded.add(0);
            discarded.add(1);
            discarded.add(2);
            discarded.add(3);
            discarded.remove(gameState.correctAnswerIndex);
            Collections.shuffle(discarded);
            discarded.remove(2);
            for (int i : discarded) {
              Button btn = answerButtons[i];
              btn.setEnabled(false);
              btn.setSelection(false);
              btn.setBackground(new Color(display, 50, 50, 50));
            }
          }
        });

    final Runnable timer =
        new Runnable() {
          public void run() {
            if (shlPonyTrivia.isDisposed()) {
              return;
            }
            gameState.remaining_time -= 1;
            display.timerExec(1000, this);
            updateTimeLabel.run();
            if (gameState.remaining_time <= 0 && gameState.enabled) {
              for (Button btn : answerButtons) {
                btn.setSelection(false);
              }
              answerQuestion.widgetSelected(null);
            }
          }
        };
    display.timerExec(1000, timer);

    btnNext.addSelectionListener(answerQuestion);

    bgMusicThread.setDaemon(true);
    bgMusicThread.start();
  }
Example #13
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();
  }