Exemplo n.º 1
0
  private void initLayout() { // {{{
    layout = new javax.swing.GroupLayout(listPanel);

    super.setLayout(blayout);
    layout.setHonorsVisibility(true);
    // layout.setAutoCreateContainerGaps(true);
    layout.setAutoCreateGaps(true);

    ParallelGroup pg = layout.createParallelGroup(Alignment.LEADING);
    SequentialGroup sg = layout.createSequentialGroup();
    pg = pg.addGroup(sg);
    // add components to this one.
    vgroup = layout.createParallelGroup(Alignment.LEADING);
    sg.addGroup(vgroup);
    layout.setHorizontalGroup(pg);

    // Add out components to this one.
    hgroup = layout.createSequentialGroup();
    ParallelGroup pg1 = layout.createParallelGroup(Alignment.LEADING).addGroup(hgroup);
    layout.setVerticalGroup(pg1);
    // Add the listPanel to our layout
    listPanel.setLayout(layout);
    add(userListPane, BorderLayout.CENTER);
    setupToolBar();
    add(toolbar, BorderLayout.NORTH);
    btnNext.setEnabled(false);
    btnPrev.setEnabled(false);

    userListPane.setHorizontalScrollBarPolicy(
        javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    userListPane.setVerticalScrollBarPolicy(
        javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    userListPane.setAutoscrolls(true);
    userListPane.setName("userListPane"); // NOI18N
    userListPane.setViewportView(listPanel);
    javax.swing.JScrollBar bar = userListPane.getVerticalScrollBar();
    bar.setUnitIncrement(50);
    TwitzMainView.fixJScrollPaneBarsSize(userListPane);
  } // }}}
  private void initComponents() {
    entry = new JTextField();
    textArea = new JTextArea();
    status = new JLabel();
    jLabel1 = new JLabel();

    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    setTitle("TextFieldDemo");

    textArea.setColumns(20);
    textArea.setLineWrap(true);
    textArea.setRows(5);
    textArea.setWrapStyleWord(true);
    textArea.setEditable(false);
    jScrollPane1 = new JScrollPane(textArea);

    jLabel1.setText("Enter text to search:");

    GroupLayout layout = new GroupLayout(getContentPane());
    getContentPane().setLayout(layout);

    ParallelGroup hGroup = layout.createParallelGroup(GroupLayout.Alignment.LEADING);

    SequentialGroup h1 = layout.createSequentialGroup();
    ParallelGroup h2 = layout.createParallelGroup(GroupLayout.Alignment.TRAILING);

    h1.addContainerGap();

    h2.addComponent(
        jScrollPane1,
        GroupLayout.Alignment.LEADING,
        GroupLayout.DEFAULT_SIZE,
        450,
        Short.MAX_VALUE);
    h2.addComponent(
        status, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 450, Short.MAX_VALUE);

    SequentialGroup h3 = layout.createSequentialGroup();
    h3.addComponent(jLabel1);
    h3.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED);
    h3.addComponent(entry, GroupLayout.DEFAULT_SIZE, 321, Short.MAX_VALUE);

    h2.addGroup(h3);
    h1.addGroup(h2);

    h1.addContainerGap();

    hGroup.addGroup(GroupLayout.Alignment.TRAILING, h1);
    layout.setHorizontalGroup(hGroup);

    ParallelGroup vGroup = layout.createParallelGroup(GroupLayout.Alignment.LEADING);
    SequentialGroup v1 = layout.createSequentialGroup();
    v1.addContainerGap();
    ParallelGroup v2 = layout.createParallelGroup(GroupLayout.Alignment.BASELINE);
    v2.addComponent(jLabel1);
    v2.addComponent(
        entry, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE);
    v1.addGroup(v2);
    v1.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED);
    v1.addComponent(jScrollPane1, GroupLayout.DEFAULT_SIZE, 233, Short.MAX_VALUE);

    v1.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED);
    v1.addComponent(status);
    v1.addContainerGap();

    vGroup.addGroup(v1);
    layout.setVerticalGroup(vGroup);
    pack();
  }
  private void initComponents() {
    // Start with indeterminate
    progressBar.setIndeterminate(false);

    // the text fields are not editable
    authUrlText.setEditable(false);
    repoUrlText.setEditable(false);
    stackStatusText.setEditable(false);
    statusTable.setEnabled(false);
    totalText.setEditable(false);
    // seupt the layout
    GroupLayout layout = new GroupLayout(this);
    this.setLayout(layout);
    this.setBorder(border);
    // Use default gaps
    layout.setAutoCreateGaps(true);
    layout.setAutoCreateContainerGaps(true);
    // Horizontal
    ParallelGroup h1 = layout.createParallelGroup(GroupLayout.Alignment.TRAILING);
    h1.addComponent(authStaticLabel);
    h1.addComponent(repoStaticLabel);
    h1.addComponent(stackStatusLabel);
    h1.addComponent(totalLabel);
    ParallelGroup h2 = layout.createParallelGroup(GroupLayout.Alignment.LEADING);
    h2.addComponent(authUrlText);
    h2.addComponent(repoUrlText);
    h2.addComponent(stackStatusText);
    h2.addComponent(totalText);
    ParallelGroup h3 = layout.createParallelGroup(GroupLayout.Alignment.LEADING);
    h3.addComponent(changeStatus);
    SequentialGroup hSequence = layout.createSequentialGroup();
    hSequence.addGroup(h1);
    hSequence.addGroup(h2);
    hSequence.addGroup(h3);

    ParallelGroup h4 = layout.createParallelGroup(GroupLayout.Alignment.LEADING);
    h4.addComponent(progressLabel);
    h4.addComponent(progressBar);
    h4.addComponent(tableScrollPane);

    ParallelGroup hOuter = layout.createParallelGroup(GroupLayout.Alignment.LEADING);
    hOuter.addGroup(hSequence);
    hOuter.addGroup(h4);

    // Vertical
    ParallelGroup v1 = layout.createParallelGroup(GroupLayout.Alignment.BASELINE);
    v1.addComponent(authStaticLabel);
    v1.addComponent(authUrlText);
    ParallelGroup v2 = layout.createParallelGroup(GroupLayout.Alignment.BASELINE);
    v2.addComponent(repoStaticLabel);
    v2.addComponent(repoUrlText);
    ParallelGroup v3 = layout.createParallelGroup(GroupLayout.Alignment.BASELINE);
    v3.addComponent(stackStatusLabel);
    v3.addComponent(stackStatusText);
    v3.addComponent(changeStatus);
    ParallelGroup v4 = layout.createParallelGroup(GroupLayout.Alignment.BASELINE);
    v4.addComponent(progressLabel);
    ParallelGroup v5 = layout.createParallelGroup(GroupLayout.Alignment.BASELINE);
    v5.addComponent(progressBar);
    ParallelGroup v6 = layout.createParallelGroup(GroupLayout.Alignment.BASELINE);
    v6.addComponent(tableScrollPane);
    ParallelGroup v7 = layout.createParallelGroup(GroupLayout.Alignment.BASELINE);
    v7.addComponent(totalLabel);
    v7.addComponent(totalText);

    SequentialGroup vSequence = layout.createSequentialGroup();
    vSequence.addGroup(v1);
    vSequence.addGroup(v2);
    vSequence.addGroup(v3);
    vSequence.addGroup(v4);
    vSequence.addGroup(v5);
    vSequence.addGroup(v6);
    vSequence.addGroup(v7);

    layout.setHorizontalGroup(hOuter);
    layout.setVerticalGroup(vSequence);

    setPreferredSize(new Dimension(300, 400));
  }
  private JPanel makeAPI() {
    JPanel p = new JPanel();
    GroupLayout layout = new GroupLayout(p);
    p.setLayout(layout);

    Group hg1 = layout.createParallelGroup();
    Group hg2 = layout.createParallelGroup();
    SequentialGroup vg = layout.createSequentialGroup();
    final int pref = GroupLayout.PREFERRED_SIZE;

    JComponent[] targs = initializeTargets();

    for (int i = 0; i < targs.length; i++) {
      JLabel label = new JLabel(labels[i]);

      hg1.addComponent(label);
      hg2.addComponent(targs[i]);

      vg.addGroup(
          layout
              .createParallelGroup(Alignment.BASELINE)
              /**/ .addComponent(label)
              /**/ .addComponent(targs[i], pref, pref, pref));
    }

    tfAuth = new JTextField(null);
    taDesc = new JTextArea();
    tfAuth.setEditable(false);
    taDesc.setEditable(false);
    taDesc.setLineWrap(true);
    taDesc.setWrapStyleWord(true);

    JLabel lAuth =
        new JLabel(Messages.getString("EnigmaSettingsFrame.LABEL_AUTHOR")); // $NON-NLS-1$
    JScrollPane desc = new JScrollPane(taDesc);

    layout.setHorizontalGroup(
        layout
            .createParallelGroup()
            /**/ .addGroup(
                layout
                    .createSequentialGroup()
                    /*	*/ .addGroup(hg1)
                    /*	*/ .addPreferredGap(ComponentPlacement.RELATED)
                    /*	*/ .addGroup(hg2))
            /**/ .addGroup(
                layout
                    .createSequentialGroup()
                    /*	*/ .addComponent(lAuth)
                    /*	*/ .addPreferredGap(ComponentPlacement.RELATED)
                    /*	*/ .addComponent(tfAuth))
            /**/ .addComponent(desc));
    layout.setVerticalGroup(
        vg
            /**/ .addPreferredGap(ComponentPlacement.RELATED)
            /**/ .addGroup(
                layout
                    .createParallelGroup(Alignment.BASELINE)
                    /*	*/ .addComponent(lAuth)
                    /*	*/ .addComponent(tfAuth))
            /**/ .addPreferredGap(ComponentPlacement.RELATED)
            /**/ .addComponent(desc, 0, 0, Integer.MAX_VALUE));

    return p;
  }
  private JPanel makeSettings() {
    JPanel p = new JPanel();
    GroupLayout layout = new GroupLayout(p);
    p.setLayout(layout);

    List<JPanel> panels = generateOptionPanels();

    sDef = new SimpleCodeHolder(res.definitions);
    sGlobLoc = new SimpleCodeHolder(res.globalLocals);
    sInit = new SimpleCodeHolder(res.initialization);
    sClean = new SimpleCodeHolder(res.cleanup);

    bDef =
        new JButton(
            Messages.getString("EnigmaSettingsFrame.BUTTON_DEFINITIONS"), CODE_ICON); // $NON-NLS-1$
    bGlobLoc =
        new JButton(
            Messages.getString("EnigmaSettingsFrame.BUTTON_GLOBAL_LOCALS"),
            CODE_ICON); //$NON-NLS-1$
    bInit =
        new JButton(
            Messages.getString("EnigmaSettingsFrame.BUTTON_INITIALIZATION"),
            CODE_ICON); //$NON-NLS-1$
    bClean =
        new JButton(
            Messages.getString("EnigmaSettingsFrame.BUTTON_CLEANUP"), CODE_ICON); // $NON-NLS-1$

    bDef.addActionListener(this);
    bGlobLoc.addActionListener(this);
    bInit.addActionListener(this);
    bClean.addActionListener(this);

    Group gh = layout.createParallelGroup();
    SequentialGroup gv = layout.createSequentialGroup();
    if (panels != null)
      for (JPanel pp : panels) {
        gh.addComponent(pp);
        gv.addComponent(pp);
      }

    layout.setHorizontalGroup(
        gh
            /**/ .addGroup(
                layout
                    .createSequentialGroup()
                    /*	*/ .addComponent(bDef)
                    /*	*/ .addComponent(bGlobLoc))
            /**/ .addGroup(
                layout
                    .createSequentialGroup()
                    /*	*/ .addComponent(bInit)
                    /*	*/ .addComponent(bClean)));
    layout.setVerticalGroup(
        gv
            /**/ .addGroup(
                layout.createParallelGroup() /*	*/.addComponent(bDef) /*	*/.addComponent(bGlobLoc))
            /**/ .addGroup(
                layout.createParallelGroup() /*	*/.addComponent(bInit) /*	*/.addComponent(bClean))
            /**/ .addContainerGap());

    return p;
  }