/**
  * The constructor
  *
  * @param passwordSafe the password safe service instance
  */
 public PasswordSafeOptionsPanel(PasswordSafe passwordSafe) {
   final PasswordSafeImpl ps = (PasswordSafeImpl) passwordSafe;
   final ChangeListener listener =
       new ChangeListener() {
         public void stateChanged(ChangeEvent e) {
           boolean isDisk = myRememberOnDiskProtectedRadioButton.isSelected();
           myManagePasswordButton.setEnabled(isDisk);
         }
       };
   myRememberOnDiskProtectedRadioButton.addChangeListener(listener);
   listener.stateChanged(null);
   myManagePasswordButton.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           if (isMasterKeyEmpty(ps)) {
             MasterPasswordDialog.resetMasterPasswordDialog(
                     null, ps.getMasterKeyProvider(), PasswordSafeOptionsPanel.class)
                 .show();
           } else {
             MasterPasswordDialog.changeMasterPasswordDialog(
                     null, ps.getMasterKeyProvider(), PasswordSafeOptionsPanel.class)
                 .show();
           }
           listener.stateChanged(null);
         }
       });
 }
 /**
  * This method initializes useStdSrvBtt
  *
  * @return javax.swing.JRadioButton
  */
 private JRadioButton getUseStdSrvBtt() {
   if (useStdSrvBtt == null) {
     useStdSrvBtt = new JRadioButton();
     useStdSrvBtt.setText("Use Standalone server");
     useStdSrvBtt.addChangeListener(bttStateChange);
     bttGroup.add(useStdSrvBtt);
   }
   return useStdSrvBtt;
 }
 /**
  * This method initializes useEmdSrvBtt
  *
  * @return javax.swing.JRadioButton
  */
 private JRadioButton getUseEmdSrvBtt() {
   if (useEmdSrvBtt == null) {
     useEmdSrvBtt = new JRadioButton();
     useEmdSrvBtt.setSelected(true);
     useEmdSrvBtt.setText("Use Embedded server");
     useEmdSrvBtt.addChangeListener(bttStateChange);
     bttGroup.add(useEmdSrvBtt);
   }
   return useEmdSrvBtt;
 }
  public NewElementCatalog(Project project, final JFrame frame) {
    super(project);

    setTitle("Oracle WebCenter Sites New Element");
    webCenterSitesPluginModuleConfigurationData =
        WebCenterSitesPluginModuleConfigurationData.getInstance(project);
    newElementCatalog = this;

    this.elementCatalogEntry = new ElementCatalogEntry();
    setDefaultProperties();

    setOKButtonText("Finish");
    setOKActionEnabled(isPageComplete());

    init();
    setSize(600, 550);
    textFieldElementCatalogName.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            super.keyPressed(e);
            populateElementFields();
          }

          @Override
          public void keyReleased(KeyEvent e) {
            super.keyReleased(e);
            populateElementFields();
          }
        });

    textFieldElementCatalogElementParameter.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            super.keyPressed(e);
            elementCatalogEntry.setElementParameters(
                textFieldElementCatalogElementParameter.getText());
            setPageError();
          }

          @Override
          public void keyReleased(KeyEvent e) {
            super.keyReleased(e);
            elementCatalogEntry.setElementParameters(
                textFieldElementCatalogElementParameter.getText());
            setPageError();
          }
        });
    textFieldElementCatalogAdditionalParameters.addKeyListener(
        new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            super.keyPressed(e);
            elementCatalogEntry.setAdditionalElementParameters(
                textFieldElementCatalogAdditionalParameters.getText());
            setPageError();
          }

          @Override
          public void keyReleased(KeyEvent e) {
            super.keyReleased(e);
            elementCatalogEntry.setAdditionalElementParameters(
                textFieldElementCatalogAdditionalParameters.getText());
            setPageError();
          }
        });
    XMLRadioButton.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent e) {
            if (XMLRadioButton.isSelected()) {
              elementCatalogEntry.setElementType(ElementFileType.XML_EC);
              populateElementFields();
            }
          }
        });
    JSPRadioButton.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent e) {
            if (JSPRadioButton.isSelected()) {
              elementCatalogEntry.setElementType(ElementFileType.JSP_EC);
              populateElementFields();
            }
          }
        });
    groovyRadioButton.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent e) {
            if (groovyRadioButton.isSelected()) {
              elementCatalogEntry.setElementType(ElementFileType.GROOVY);
              populateElementFields();
            }
          }
        });
    HTMLRadioButton.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent e) {
            if (HTMLRadioButton.isSelected()) {
              elementCatalogEntry.setElementType(ElementFileType.HTML);
              populateElementFields();
            }
          }
        });

    show();
  }
  private void setupEvents() {
    specifyUPB.addActionListener(specifyUPBListener);

    specifyLWB.addActionListener(specifyLWBListener);

    yesUPB.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            if (yesUPB.isSelected()) {
              specifyUPB.setVisible(true);
              UPBLabel.setVisible(specifyUPB.isSelected());
              UPBDetailPanel.setVisible(true);
            } else {
              if (yesCyclic.isSelected()) {
                specifyUPB.setVisible(true);
                yesUPB.setSelected(true);
                UPBDetailPanel.setVisible(true);
                UPBLabel.setVisible(specifyUPB.isSelected());
              } else {
                specifyUPB.setSelected(false);
                specifyUPB.setVisible(false);
                UPBLabel.setText("0");
                UPBLabel.setVisible(false);
                UPBDetailPanel.setVisible(false);
              }
            }
          }
        });

    yesLWB.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            if (yesLWB.isSelected()) {
              specifyLWB.setVisible(true);
              LWBLabel.setVisible(specifyLWB.isSelected());
              LWBDetailPanel.setVisible(true);
            } else {
              if (yesCyclic.isSelected()) {
                specifyLWB.setVisible(true);
                yesLWB.setSelected(true);
                LWBDetailPanel.setVisible(true);
                LWBLabel.setVisible(specifyLWB.isSelected());
              } else {
                specifyLWB.setSelected(false);
                specifyLWB.setVisible(false);
                LWBLabel.setText("0");
                LWBLabel.setVisible(false);
                LWBDetailPanel.setVisible(false);
              }
            }
          }
        });

    UPBLabel.addKeyListener(listener);

    LWBLabel.addKeyListener(listener);

    yesCyclic.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            if (yesCyclic.isSelected()) {
              specifyLWB.setVisible(true);
              yesLWB.setSelected(true);
              specifyUPB.setVisible(true);
              yesUPB.setSelected(true);
              LWBLabel.setVisible(specifyLWB.isSelected());
              UPBLabel.setVisible(specifyUPB.isSelected());
            }
          }
        });
  }
Example #6
0
  /**
   * Customization of external program paths.
   *
   * @param prefs a <code>JabRefPreferences</code> value
   */
  public TablePrefsTab(JabRefPreferences prefs) {
    this.prefs = prefs;
    setLayout(new BorderLayout());

    /**
     * Added Bibtexkey to combobox.
     *
     * <p>[ 1540646 ] default sort order: bibtexkey
     *
     * <p>http://sourceforge.net/tracker/index.php?func=detail&aid=1540646&group_id=92314&atid=600306
     */
    Vector<String> fieldNames = new Vector<String>(Arrays.asList(BibtexFields.getAllFieldNames()));
    fieldNames.add(BibtexFields.KEY_FIELD);
    Collections.sort(fieldNames);
    String[] allPlusKey = fieldNames.toArray(new String[fieldNames.size()]);
    priSort = new JComboBox(allPlusKey);
    secSort = new JComboBox(allPlusKey);
    terSort = new JComboBox(allPlusKey);

    autoResizeMode = new JCheckBox(Localization.lang("Fit table horizontally on screen"));

    namesAsIs = new JRadioButton(Localization.lang("Show names unchanged"));
    namesFf = new JRadioButton(Localization.lang("Show 'Firstname Lastname'"));
    namesFl = new JRadioButton(Localization.lang("Show 'Lastname, Firstname'"));
    namesNatbib = new JRadioButton(Localization.lang("Natbib style"));
    noAbbrNames = new JRadioButton(Localization.lang("Do not abbreviate names"));
    abbrNames = new JRadioButton(Localization.lang("Abbreviate names"));
    lastNamesOnly = new JRadioButton(Localization.lang("Show last names only"));

    floatMarked = new JCheckBox(Localization.lang("Float marked entries"));

    priField = new JTextField(10);
    secField = new JTextField(10);
    terField = new JTextField(10);

    numericFields = new JTextField(30);

    priSort.insertItemAt(Localization.lang("<select>"), 0);
    secSort.insertItemAt(Localization.lang("<select>"), 0);
    terSort.insertItemAt(Localization.lang("<select>"), 0);

    priSort.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            if (priSort.getSelectedIndex() > 0) {
              priField.setText(priSort.getSelectedItem().toString());
              priSort.setSelectedIndex(0);
            }
          }
        });
    secSort.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            if (secSort.getSelectedIndex() > 0) {
              secField.setText(secSort.getSelectedItem().toString());
              secSort.setSelectedIndex(0);
            }
          }
        });
    terSort.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            if (terSort.getSelectedIndex() > 0) {
              terField.setText(terSort.getSelectedItem().toString());
              terSort.setSelectedIndex(0);
            }
          }
        });

    ButtonGroup nameStyle = new ButtonGroup();
    nameStyle.add(namesAsIs);
    nameStyle.add(namesNatbib);
    nameStyle.add(namesFf);
    nameStyle.add(namesFl);
    ButtonGroup nameAbbrev = new ButtonGroup();
    nameAbbrev.add(lastNamesOnly);
    nameAbbrev.add(abbrNames);
    nameAbbrev.add(noAbbrNames);
    priDesc = new JCheckBox(Localization.lang("Descending"));
    secDesc = new JCheckBox(Localization.lang("Descending"));
    terDesc = new JCheckBox(Localization.lang("Descending"));

    FormLayout layout =
        new FormLayout(
            "1dlu, 8dlu, left:pref, 4dlu, fill:pref, 4dlu, fill:60dlu, 4dlu, fill:pref", "");
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    JLabel lab;
    JPanel pan = new JPanel();

    builder.appendSeparator(Localization.lang("Format of author and editor names"));
    DefaultFormBuilder nameBuilder =
        new DefaultFormBuilder(new FormLayout("left:pref, 8dlu, left:pref", ""));

    nameBuilder.append(namesAsIs);
    nameBuilder.append(noAbbrNames);
    nameBuilder.nextLine();
    nameBuilder.append(namesFf);
    nameBuilder.append(abbrNames);
    nameBuilder.nextLine();
    nameBuilder.append(namesFl);
    nameBuilder.append(lastNamesOnly);
    nameBuilder.nextLine();
    nameBuilder.append(namesNatbib);
    builder.append(pan);
    builder.append(nameBuilder.getPanel());
    builder.nextLine();

    builder.appendSeparator(Localization.lang("Default sort criteria"));
    // Create a new panel with its own FormLayout for these items:
    FormLayout layout2 =
        new FormLayout("left:pref, 8dlu, fill:pref, 4dlu, fill:60dlu, 4dlu, left:pref", "");
    DefaultFormBuilder builder2 = new DefaultFormBuilder(layout2);
    lab = new JLabel(Localization.lang("Primary sort criterion"));
    builder2.append(lab);
    builder2.append(priSort);
    builder2.append(priField);
    builder2.append(priDesc);
    builder2.nextLine();
    lab = new JLabel(Localization.lang("Secondary sort criterion"));
    builder2.append(lab);
    builder2.append(secSort);
    builder2.append(secField);
    builder2.append(secDesc);
    builder2.nextLine();
    lab = new JLabel(Localization.lang("Tertiary sort criterion"));
    builder2.append(lab);
    builder2.append(terSort);
    builder2.append(terField);
    builder2.append(terDesc);
    builder.nextLine();
    builder.append(pan);
    builder.append(builder2.getPanel());
    builder.nextLine();
    builder.append(pan);
    builder.append(floatMarked);
    builder.nextLine();
    builder.append(pan);
    builder2 = new DefaultFormBuilder(new FormLayout("left:pref, 8dlu, fill:pref", ""));
    builder2.append(Localization.lang("Sort the following fields as numeric fields") + ':');
    builder2.append(numericFields);
    builder.append(builder2.getPanel(), 5);
    builder.nextLine();
    builder.appendSeparator(Localization.lang("General"));
    builder.append(pan);
    builder.append(autoResizeMode);
    builder.nextLine();

    pan = builder.getPanel();
    pan.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    add(pan, BorderLayout.CENTER);

    namesNatbib.addChangeListener(
        new ChangeListener() {

          @Override
          public void stateChanged(ChangeEvent changeEvent) {
            abbrNames.setEnabled(!namesNatbib.isSelected());
            lastNamesOnly.setEnabled(!namesNatbib.isSelected());
            noAbbrNames.setEnabled(!namesNatbib.isSelected());
          }
        });
  }
Example #7
0
  public SearchPanel(ApplicationContext _context, JTable _table) {
    setLayout(new BorderLayout());
    myContext = _context;
    myTable = _table;
    myOptions = new Vector();

    JPanel optionSetPanel = new JPanel();
    optionSetPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    optionSetPanel.setLayout(new BoxLayout(optionSetPanel, BoxLayout.Y_AXIS));

    myStandardSeach = new JRadioButton("Standard Search");
    myStandardSeach.setAlignmentX(0.0f);
    myAdvancedSearch = new JRadioButton("Advanced Search");
    myAdvancedSearch.setAlignmentX(0.0f);
    ButtonGroup optionsGroup = new ButtonGroup();
    optionsGroup.add(myStandardSeach);
    optionsGroup.add(myAdvancedSearch);
    myStandardSeach.addChangeListener(new StandardSearchListener());

    JPanel optionsPanel = new JPanel();
    optionsPanel.setAlignmentX(0.0f);
    optionsPanel.setLayout(new GridLayout(0, 1));
    optionsPanel.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0));
    addOption(optionsPanel, new TextOption("Title", DatabaseTags.TITLE_TAG));
    addOption(optionsPanel, new TextOption("Artist", DatabaseTags.ARTIST_TAG));
    addOption(optionsPanel, new TextOption("Source", DatabaseTags.SOURCE_TAG));
    addOption(optionsPanel, new TextOption("Genre", DatabaseTags.GENRE_TAG));
    addOption(optionsPanel, new TextOption("Year", DatabaseTags.YEAR_TAG));

    JPanel advancedPanel = new JPanel();
    advancedPanel.setAlignmentX(0.0f);
    advancedPanel.setLayout(new GridLayout(0, 1));
    advancedPanel.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0));
    myAdvancedTextField = new JTextField();
    advancedPanel.add(myAdvancedTextField);

    JButton searchButton = new JButton("Search");
    searchButton.addActionListener(new SearchListener());

    JButton saveResultsButton = new JButton("Save");
    saveResultsButton.addActionListener(new SaveResultsListener());

    JPanel buttonsPanel = new JPanel();
    buttonsPanel.setLayout(new FlowLayout());
    buttonsPanel.add(searchButton);
    buttonsPanel.add(saveResultsButton);
    buttonsPanel.setAlignmentX(0.0f);

    optionSetPanel.add(myStandardSeach);
    optionSetPanel.add(optionsPanel, BorderLayout.NORTH);
    optionSetPanel.add(myAdvancedSearch);
    optionSetPanel.add(advancedPanel);
    //    optionSetPanel.add(myFindContainerPlaylists);
    //    optionSetPanel.add(Box.createVerticalStrut(10));
    if (_table != null) {
      optionSetPanel.add(Box.createVerticalStrut(10));
      optionSetPanel.add(buttonsPanel);
    }
    add(optionSetPanel, BorderLayout.NORTH);

    myStandardSeach.setSelected(true);
  }
Example #8
0
  private void createDialog() {
    diag = new JDialog(frame, Globals.lang("Set/clear/rename fields"), true);

    field = new JTextField();
    text = new JTextField();
    text.setEnabled(false);
    renameTo = new JTextField();
    renameTo.setEnabled(false);

    JButton ok = new JButton(Globals.lang("Ok"));
    JButton cancel = new JButton(Globals.lang("Cancel"));

    all = new JRadioButton(Globals.lang("All entries"));
    selected = new JRadioButton(Globals.lang("Selected entries"));
    clear = new JRadioButton(Globals.lang("Clear fields"));
    set = new JRadioButton(Globals.lang("Set fields"));
    rename = new JRadioButton(Globals.lang("Rename field to:"));
    rename.setToolTipText(
        Globals.lang("Move contents of a field into a field with a different name"));
    set.addChangeListener(
        new ChangeListener() {

          @Override
          public void stateChanged(ChangeEvent e) {
            // Entering a text is only relevant if we are setting, not clearing:
            text.setEnabled(set.isSelected());
          }
        });
    clear.addChangeListener(
        new ChangeListener() {

          @Override
          public void stateChanged(ChangeEvent event) {
            // Overwrite protection makes no sense if we are clearing the field:
            overwrite.setEnabled(!clear.isSelected());
          }
        });
    rename.addChangeListener(
        new ChangeListener() {

          @Override
          public void stateChanged(ChangeEvent e) {
            // Entering a text is only relevant if we are renaming
            renameTo.setEnabled(rename.isSelected());
          }
        });
    overwrite = new JCheckBox(Globals.lang("Overwrite existing field values"), true);
    ButtonGroup bg = new ButtonGroup();
    bg.add(all);
    bg.add(selected);
    bg = new ButtonGroup();
    bg.add(clear);
    bg.add(set);
    bg.add(rename);
    DefaultFormBuilder builder =
        new DefaultFormBuilder(new FormLayout("left:pref, 4dlu, fill:100dlu", ""));
    builder.appendSeparator(Globals.lang("Field name"));
    builder.append(Globals.lang("Field name"));
    builder.append(field);
    builder.nextLine();
    builder.appendSeparator(Globals.lang("Include entries"));
    builder.append(all, 3);
    builder.nextLine();
    builder.append(selected, 3);
    builder.nextLine();
    builder.appendSeparator(Globals.lang("New field value"));
    builder.append(set);
    builder.append(text);
    builder.nextLine();
    builder.append(clear);
    builder.nextLine();
    builder.append(rename);
    builder.append(renameTo);
    builder.nextLine();
    builder.append(overwrite, 3);

    ButtonBarBuilder bb = new ButtonBarBuilder();
    bb.addGlue();
    bb.addButton(ok);
    bb.addButton(cancel);
    bb.addGlue();
    builder.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    diag.getContentPane().add(builder.getPanel(), BorderLayout.CENTER);
    diag.getContentPane().add(bb.getPanel(), BorderLayout.SOUTH);
    diag.pack();

    ok.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            // Check if the user tries to rename multiple fields:
            if (rename.isSelected()) {
              String[] fields = getFieldNames(field.getText());
              if (fields.length > 1) {
                JOptionPane.showMessageDialog(
                    diag,
                    Globals.lang("You can only rename one field at a time"),
                    "",
                    JOptionPane.ERROR_MESSAGE);
                return; // Do not close the dialog.
              }
            }
            cancelled = false;
            diag.dispose();
          }
        });

    AbstractAction cancelAction =
        new AbstractAction() {

          @Override
          public void actionPerformed(ActionEvent e) {
            cancelled = true;
            diag.dispose();
          }
        };
    cancel.addActionListener(cancelAction);

    // Key bindings:
    ActionMap am = builder.getPanel().getActionMap();
    InputMap im = builder.getPanel().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    im.put(Globals.prefs.getKey("Close dialog"), "close");
    am.put("close", cancelAction);
  }
  public FacetConfigurationEditor(
      ConfigurationData data,
      FacetEditorContext editorContext,
      FacetValidatorsManager validatorsManager) {
    myData = data;
    myEditorContext = editorContext;
    myValidatorsManager = validatorsManager;

    myDebuggingInfoLevel.setModel(new DefaultComboBoxModel(DebuggingInfoLevel.values()));
    myLibraryRenderer = new LibraryRenderer(myCompilerLibrary);
    myCompilerLibrary.setRenderer(myLibraryRenderer);

    myEnableWarnings.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            updateCheckboxesState();
          }
        });

    myFSCRadioButton.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            updateCompilerSection();
          }
        });

    CompilerPluginsTableModel model = new CompilerPluginsTableModel();
    model.setItems(myPlugins);
    tablePlugins.setModel(model);

    addButton.setAction(myAddPluginAction);
    removeButton.setAction(myRemovePluginAction);
    editButton.setAction(myEditPluginAction);
    moveUpButton.setAction(myMoveUpPluginAction);
    moveDownButton.setAction(myMoveDownPluginAction);

    myAddPluginAction.registerOn(panelPlugins);
    myRemovePluginAction.registerOn(tablePlugins);
    myEditPluginAction.registerOn(tablePlugins);
    myMoveUpPluginAction.registerOn(tablePlugins);
    myMoveDownPluginAction.registerOn(tablePlugins);

    ListSelectionModel selectionModel = tablePlugins.getSelectionModel();
    selectionModel.addListSelectionListener(myAddPluginAction);
    selectionModel.addListSelectionListener(myRemovePluginAction);
    selectionModel.addListSelectionListener(myEditPluginAction);
    selectionModel.addListSelectionListener(myMoveUpPluginAction);
    selectionModel.addListSelectionListener(myMoveDownPluginAction);

    tablePlugins.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2) {
              myEditPluginAction.perform();
            }
          }
        });

    myValidatorsManager.registerValidator(
        new FacetEditorValidator() {
          @Override
          public ValidationResult check() {
            ValidationResult libraryResult =
                myFSCRadioButton.isSelected()
                    ? ValidationResult.OK
                    : checkCompilerLibrary((LibraryDescriptor) myCompilerLibrary.getSelectedItem());

            ValidationResult continuationsResult =
                myEnableContinuations.isSelected()
                    ? checkContinuationsPlugin(getPluginsModel().getItems())
                    : ValidationResult.OK;

            return conjunctionOf(libraryResult, continuationsResult);
          }
        },
        myCompilerLibrary,
        myFSCRadioButton,
        myEnableContinuations,
        tablePlugins);

    myAddPluginAction.update();
    myRemovePluginAction.update();
    myEditPluginAction.update();
    myMoveUpPluginAction.update();
    myMoveDownPluginAction.update();

    myFscSettings.setListener(
        new LinkListener() {
          public void linkSelected(LinkLabel aSource, Object aLinkData) {
            ShowSettingsUtil.getInstance()
                .showSettingsDialog(myEditorContext.getProject(), "Scala Compiler");
          }
        },
        null);
  }
  /**
   * Constructs new dialog. Loads settings, registers listeners.
   *
   * @param project the project
   * @param vcsRoots the vcs roots
   * @param roots the loaded information about roots
   */
  private GitPushActiveBranchesDialog(
      final Project project, List<VirtualFile> vcsRoots, List<Root> roots) {
    super(project, true);
    myVcs = GitVcs.getInstance(project);
    myProject = project;
    myVcsRoots = vcsRoots;
    myGeneralSettings = GeneralSettings.getInstance();
    myProjectManager = ProjectManagerEx.getInstanceEx();

    updateTree(roots, null);
    updateUI();

    final GitVcsSettings settings = GitVcsSettings.getInstance(project);
    if (settings != null) {
      UpdatePolicyUtils.updatePolicyItem(
          settings.getPushActiveBranchesRebaseSavePolicy(),
          myStashRadioButton,
          myShelveRadioButton);
    }
    ChangeListener listener =
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            if (settings != null) {
              settings.setPushActiveBranchesRebaseSavePolicy(
                  UpdatePolicyUtils.getUpdatePolicy(myStashRadioButton, myShelveRadioButton));
            }
          }
        };
    myStashRadioButton.addChangeListener(listener);
    myShelveRadioButton.addChangeListener(listener);
    myCommitTree
        .getSelectionModel()
        .addTreeSelectionListener(
            new TreeSelectionListener() {
              public void valueChanged(TreeSelectionEvent e) {
                TreePath path = myCommitTree.getSelectionModel().getSelectionPath();
                if (path == null) {
                  myViewButton.setEnabled(false);
                  return;
                }
                DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
                myViewButton.setEnabled(
                    node != null
                        && myCommitTree.getSelectionCount() == 1
                        && node.getUserObject() instanceof Commit);
              }
            });
    myViewButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            TreePath path = myCommitTree.getSelectionModel().getSelectionPath();
            if (path == null) {
              return;
            }
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
            if (node == null || !(node.getUserObject() instanceof Commit)) {
              return;
            }
            Commit c = (Commit) node.getUserObject();
            GitShowAllSubmittedFilesAction.showSubmittedFiles(
                project, c.revision.asString(), c.root.root);
          }
        });
    myFetchButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            fetch();
          }
        });
    myRebaseButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            rebase();
          }
        });

    myPushButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            push();
          }
        });

    setTitle(GitBundle.getString("push.active.title"));
    setOKButtonText(GitBundle.getString("push.active.rebase.and.push"));
    setCancelButtonText(GitBundle.getString("git.push.active.close"));
    init();
  }
  // Must be delegated through ActionFrame(Action)
  private ActionFrame(Action a, LibAction la) {
    super(la.description, false);
    if (la.parent == null) setTitle(Messages.getString("Action.UNKNOWN")); // $NON-NLS-1$
    if (la.actImage != null)
      setFrameIcon(new ImageIcon(la.actImage.getScaledInstance(16, 16, Image.SCALE_SMOOTH)));
    String s;
    ResourceReference<GmObject> at = a.getAppliesTo();
    if (at == GmObject.OBJECT_SELF) s = Messages.getString("ActionFrame.SELF"); // $NON-NLS-1$
    else s = Messages.getString("ActionFrame.OTHER"); // $NON-NLS-1$
    appliesObject = new ResourceMenu<GmObject>(Resource.Kind.OBJECT, s, false, 100);
    appliesObject.setEnabled(GmObject.refAsInt(at) >= 0);
    appliesObject.setOpaque(false);
    appliesObject.setSelected(at);
    act = a;

    appliesPanel = new JPanel();
    appliesPanel.setOpaque(false);
    appliesPanel.setLayout(new GridBagLayout());

    GridBagConstraints gbc;
    applies = new IndexButtonGroup(3, true, false);
    JRadioButton button = new JRadioButton(Messages.getString("ActionFrame.SELF")); // $NON-NLS-1$
    button.setOpaque(false);
    applies.add(button, -1);
    gbc = new GridBagConstraints();
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    appliesPanel.add(button, gbc);
    button = new JRadioButton(Messages.getString("ActionFrame.OTHER")); // $NON-NLS-1$
    button.setOpaque(false);
    applies.add(button, -2);
    gbc = new GridBagConstraints();
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    appliesPanel.add(button, gbc);
    button = new JRadioButton(Messages.getString("ActionFrame.OBJECT")); // $NON-NLS-1$
    button.setHorizontalAlignment(JRadioButton.LEFT);
    button.setOpaque(false);
    button.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            boolean sel = ((JRadioButton) e.getSource()).isSelected();
            appliesObject.setEnabled(sel);
          }
        });
    applies.add(button, 0);
    gbc = new GridBagConstraints();
    gbc.gridy = 1;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    appliesPanel.add(button, gbc);
    gbc = new GridBagConstraints();
    gbc.gridy = 1;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 1.0;
    gbc.insets = new Insets(0, 2, 0, 6);
    appliesPanel.add(appliesObject, gbc);
    applies.setValue(Math.min(GmObject.refAsInt(at), 0));

    if (la.interfaceKind == LibAction.INTERFACE_CODE) {
      setSize(600, 400);
      setClosable(true);
      setMaximizable(true);
      setResizable(true);
      setIconifiable(true);

      tool = new JToolBar();
      tool.setFloatable(false);
      tool.setAlignmentX(0);
      save = new JButton(LGM.getIconForKey("ActionFrame.SAVE")); // $NON-NLS-1$
      save.addActionListener(this);
      //			add(save);
      tool.add(save);
      tool.addSeparator();

      code = new GMLTextArea(a.getArguments().get(0).getVal());
      code.addEditorButtons(tool);

      tool.addSeparator();
      tool.add(new JLabel(Messages.getString("ActionFrame.APPLIES"))); // $NON-NLS-1$
      tool.add(appliesPanel);

      status = new JPanel(new FlowLayout());
      status.setLayout(new BoxLayout(status, BoxLayout.X_AXIS));
      status.setMaximumSize(new Dimension(Integer.MAX_VALUE, 11));
      final JLabel caretPos =
          new JLabel((code.getCaretLine() + 1) + ":" + (code.getCaretColumn() + 1));
      status.add(caretPos);
      code.addCaretListener(
          new CaretListener() {
            public void caretUpdate(CaretEvent e) {
              caretPos.setText((code.getCaretLine() + 1) + ":" + (code.getCaretColumn() + 1));
            }
          });

      add(tool, BorderLayout.NORTH);
      add(code, BorderLayout.CENTER);
      add(status, BorderLayout.SOUTH);

      setFocusTraversalPolicy(new TextAreaFocusTraversalPolicy(code));
      appliesPanel.setLayout(new BoxLayout(appliesPanel, BoxLayout.LINE_AXIS));
    } else makeArgumentPane(a, la);
    pack();
    repaint();
    SubframeInformer.fireSubframeAppear(this);
  }
Example #12
0
  @Override
  public void addViews() {
    setLayout(new GridBagLayout());
    final GridBagConstraints c = new DefaultGridBagConstraints();

    // Champ Module
    c.gridx = 0;
    c.gridy++;
    c.gridwidth = GridBagConstraints.REMAINDER;
    final JPanel addP = ComptaSQLConfElement.createAdditionalPanel();
    this.setAdditionalFieldsPanel(new FormLayouter(addP, 2));
    this.add(addP, c);

    c.gridy++;
    c.gridwidth = 1;
    final JLabel labelNumero = new JLabel(getLabelFor("NUMERO"));
    labelNumero.setHorizontalAlignment(SwingConstants.RIGHT);
    this.add(labelNumero, c);

    // Ligne 1: Numero du devis

    c.gridx++;
    c.weightx = 1;
    c.fill = GridBagConstraints.NONE;
    this.numeroUniqueDevis = new JUniqueTextField(15);
    DefaultGridBagConstraints.lockMinimumSize(this.numeroUniqueDevis);
    DefaultGridBagConstraints.lockMaximumSize(this.numeroUniqueDevis);
    this.add(this.numeroUniqueDevis, c);

    // Date

    c.gridx++;
    c.weightx = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    final JLabel labelDate = new JLabel(getLabelFor("DATE"));

    labelDate.setHorizontalAlignment(SwingConstants.RIGHT);

    this.add(labelDate, c);
    c.gridx++;

    c.weightx = 1;

    c.fill = GridBagConstraints.NONE;
    final JDate dateDevis = new JDate(true);
    this.add(dateDevis, c);

    // Etat devis
    this.radioEtat.setLayout(new VFlowLayout());
    this.radioEtat.setBorder(BorderFactory.createTitledBorder(getLabelFor("ID_ETAT_DEVIS")));
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.gridheight = 5;
    c.weightx = 0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.EAST;
    c.gridx += 2;
    this.radioEtat.initLocalization(
        new ITransformer<String, String>() {
          @Override
          public String transformChecked(String id) {
            return id;
            // return TranslationManager.getInstance().getTranslationForItem(id);
          }
        });
    this.add(this.radioEtat, c);
    // this.radioEtat.setVisible(false);

    // Ligne 2: Reference
    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.fill = GridBagConstraints.HORIZONTAL;

    c.weightx = 0;

    final JLabel labelObjet = new JLabel(getLabelFor("OBJET"));
    labelObjet.setHorizontalAlignment(SwingConstants.RIGHT);

    this.add(labelObjet, c);

    final SQLTextCombo textObjet = new SQLTextCombo();
    c.gridx++;
    c.weightx = 1;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.BOTH;
    this.add(textObjet, c);

    String field;
    field = "ID_COMMERCIAL";
    // Commercial
    final JLabel labelCommercial = new JLabel(getLabelFor(field));
    labelCommercial.setHorizontalAlignment(SwingConstants.RIGHT);
    c.gridx++;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0;

    this.add(labelCommercial, c);

    final ElementComboBox comboCommercial = new ElementComboBox(false, 25);

    comboCommercial.setListIconVisible(false);
    c.gridx++;
    c.weightx = 1;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.WEST;

    this.add(comboCommercial, c);
    addRequiredSQLObject(comboCommercial, field);

    // Ligne 3: Client
    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 1;
    final JLabel labelClient = new JLabel(getLabelFor("ID_CLIENT"));
    labelClient.setHorizontalAlignment(SwingConstants.RIGHT);
    c.weightx = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    this.add(labelClient, c);

    final ElementComboBox comboClient = new ElementComboBox();
    c.gridx++;
    c.gridwidth = 1;
    c.weightx = 0;
    c.weighty = 0;
    c.fill = GridBagConstraints.NONE;
    this.add(comboClient, c);
    addRequiredSQLObject(comboClient, "ID_CLIENT");

    final ElementComboBox boxTarif = new ElementComboBox();

    if (getTable().getFieldsName().contains("DATE_VALIDITE")) {
      c.gridx++;
      this.add(new JLabel(getLabelFor("DATE_VALIDITE")), c);
      c.gridx++;
      JDate dateValidite = new JDate();
      this.add(dateValidite, c);
      this.addView(dateValidite, "DATE_VALIDITE");
    }

    // Tarif
    if (this.getTable().getFieldsName().contains("ID_TARIF")) {
      // TARIF
      c.gridy++;
      c.gridx = 0;
      c.weightx = 0;
      c.weighty = 0;
      c.gridwidth = 1;
      JLabel comp = new JLabel("Tarif à appliquer", SwingConstants.RIGHT);
      this.add(comp, c);
      c.gridx++;
      c.gridwidth = GridBagConstraints.REMAINDER;

      c.weightx = 1;
      this.add(boxTarif, c);
      this.addView(boxTarif, "ID_TARIF");
      DefaultGridBagConstraints.lockMinimumSize(boxTarif);
      boxTarif.addModelListener(
          "wantedID",
          new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {

              SQLRow selectedRow =
                  boxTarif.getRequest().getPrimaryTable().getRow(boxTarif.getWantedID());
              table.setTarif(selectedRow, !isFilling());
            }
          });
    }

    // Table d'élément
    this.table = new DevisItemTable();

    c.fill = GridBagConstraints.BOTH;
    c.gridx = 0;
    c.gridy += 5;
    c.weighty = 1;
    c.gridwidth = GridBagConstraints.REMAINDER;
    this.add(this.table, c);
    this.addView(this.table.getRowValuesTable(), "");

    // Panel en bas
    final JPanel bottomPanel = new JPanel(new GridBagLayout());
    final GridBagConstraints cBottom = new DefaultGridBagConstraints();
    // 1ere Colonne : Infos
    cBottom.weightx = 1;
    bottomPanel.add(new TitledSeparator(getLabelFor("INFOS")), cBottom);
    cBottom.gridy++;
    cBottom.fill = GridBagConstraints.BOTH;
    cBottom.weighty = 0;

    final JScrollPane scrollPane = new JScrollPane(this.infos);
    scrollPane.setBorder(null);
    bottomPanel.add(scrollPane, cBottom);

    // 2eme Colonne : Poids total
    final JPanel panel = new JPanel(new GridBagLayout());

    this.textPoidsTotal = new JTextField(8);
    this.textPoidsTotal.setText("0.0");
    final GridBagConstraints cPanel = new DefaultGridBagConstraints();
    panel.add(new JLabel(getLabelFor("T_POIDS")), cPanel);
    cPanel.weightx = 0;
    cPanel.gridx++;
    panel.add(this.textPoidsTotal, cPanel);
    this.textPoidsTotal.setEnabled(false);
    this.textPoidsTotal.setEditable(false);
    this.textPoidsTotal.setHorizontalAlignment(SwingConstants.RIGHT);
    this.textPoidsTotal.setDisabledTextColor(Color.BLACK);

    // Port
    cPanel.gridy++;
    cPanel.gridx = 0;
    panel.add(new JLabel(getLabelFor("PORT_HT"), SwingConstants.RIGHT), cPanel);

    cPanel.gridx++;
    final DeviseField textPortHT = new DeviseField();
    panel.add(textPortHT, cPanel);

    // Remise HT
    final JRadioButton radioEuros = new JRadioButton("en €");
    final JRadioButton radioPourCent = new JRadioButton("en %");
    final ButtonGroup radioGroup = new ButtonGroup();
    radioGroup.add(radioEuros);
    radioGroup.add(radioPourCent);
    radioEuros.setSelected(true);

    final JPanel panelRemise = new JPanel(new GridBagLayout());
    final GridBagConstraints cRemise = new DefaultGridBagConstraints();
    cRemise.insets = new Insets(0, 0, 1, 0);
    final JLabel labelRemise = new JLabel(getLabelFor("REMISE_HT"));
    panelRemise.add(labelRemise, cRemise);
    cRemise.gridx++;
    panelRemise.add(radioEuros, cRemise);

    cRemise.gridx++;
    cRemise.weightx = 0;
    this.textRemiseHT = new DeviseField();
    panelRemise.add(this.textRemiseHT, cRemise);
    this.textRemiseHT.setMinimumSize(new Dimension(150, 20));
    this.textRemiseHT.setPreferredSize(new Dimension(150, 20));

    cRemise.gridx = 1;
    cRemise.gridy++;
    cRemise.weightx = 0;
    panelRemise.add(radioPourCent, cRemise);

    this.textPourcentRemise = new JTextField(5);
    DefaultGridBagConstraints.lockMinimumSize(this.textPourcentRemise);
    cRemise.gridx++;
    panelRemise.add(this.textPourcentRemise, cRemise);

    cPanel.gridx = 0;
    cPanel.gridy++;
    cPanel.gridwidth = 2;
    panel.add(panelRemise, cPanel);

    cBottom.gridy = 0;
    cBottom.gridx++;
    cBottom.weighty = 0;
    cBottom.weightx = 1;
    cBottom.gridheight = 2;
    cBottom.fill = GridBagConstraints.HORIZONTAL;
    cBottom.anchor = GridBagConstraints.NORTHEAST;
    DefaultGridBagConstraints.lockMinimumSize(panel);
    // bottomPanel.add(panel, cBottom);

    addSQLObject(this.textRemiseHT, "REMISE_HT");
    addSQLObject(textPortHT, "PORT_HT");
    // this.checkImpression.setSelected(true);

    // Total
    this.fieldHT = new DeviseField();
    final DeviseField fieldTVA = new DeviseField();
    final DeviseField fieldTTC = new DeviseField();
    final DeviseField fieldDevise = new DeviseField();
    final DeviseField fieldService = new DeviseField();
    this.fieldHT.setEditable(false);
    fieldTVA.setEditable(false);
    fieldTTC.setEditable(false);
    fieldService.setEditable(false);

    addRequiredSQLObject(this.fieldHT, "T_HT");
    addRequiredSQLObject(fieldTVA, "T_TVA");
    addSQLObject(fieldDevise, "T_DEVISE");
    addRequiredSQLObject(fieldTTC, "T_TTC");
    addRequiredSQLObject(fieldService, "T_SERVICE");
    JTextField poids = new JTextField();
    // addSQLObject(poids, "T_POIDS");

    // FIXME Field add field T_HA dans installation avec recalcul des devis deja saisis
    final DeviseField fieldHA = new DeviseField();

    if (getTable().contains("PREBILAN")) {
      addSQLObject(fieldHA, "PREBILAN");
    } else if (getTable().contains("T_HA")) {

      addSQLObject(fieldHA, "T_HA");
    }

    final TotalPanel totalTTC =
        new TotalPanel(
            this.table,
            this.fieldHT,
            fieldTVA,
            fieldTTC,
            textPortHT,
            this.textRemiseHT,
            fieldService,
            fieldHA,
            fieldDevise,
            poids,
            null);

    cBottom.gridy = 0;
    cBottom.gridx += 2;
    cBottom.gridheight = 2;
    cBottom.gridwidth = 1;
    cBottom.fill = GridBagConstraints.NONE;
    cBottom.weightx = 0;
    cBottom.anchor = GridBagConstraints.NORTHEAST;
    DefaultGridBagConstraints.lockMinimumSize(totalTTC);
    bottomPanel.add(totalTTC, cBottom);

    c.gridy++;
    c.gridx = 0;
    c.weighty = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridwidth = GridBagConstraints.REMAINDER;
    this.add(bottomPanel, c);

    c.gridx = 0;
    c.gridy++;
    c.weighty = 0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.SOUTHEAST;

    this.panelOO = new PanelOOSQLComponent(this);
    this.add(this.panelOO, c);

    textPortHT
        .getDocument()
        .addDocumentListener(
            new SimpleDocumentListener() {

              @Override
              public void update(final DocumentEvent e) {
                totalTTC.updateTotal();
              }
            });

    this.textRemiseHT
        .getDocument()
        .addDocumentListener(
            new SimpleDocumentListener() {

              @Override
              public void update(final DocumentEvent e) {
                totalTTC.updateTotal();
              }
            });

    this.textPourcentRemise
        .getDocument()
        .addDocumentListener(
            new SimpleDocumentListener() {

              @Override
              public void update(final DocumentEvent e) {
                calculPourcentage();
              }
            });

    radioEuros.addChangeListener(
        new ChangeListener() {

          public void stateChanged(final ChangeEvent e) {
            DevisSQLComponent.this.textRemiseHT.setEnabled(radioEuros.isSelected());
            DevisSQLComponent.this.textPourcentRemise.setEnabled(!radioEuros.isSelected());
          }
        });

    this.table
        .getModel()
        .addTableModelListener(
            new TableModelListener() {

              public void tableChanged(final TableModelEvent e) {
                DevisSQLComponent.this.textPoidsTotal.setText(
                    String.valueOf(DevisSQLComponent.this.table.getPoidsTotal()));
              }
            });

    addSQLObject(textObjet, "OBJET");
    addSQLObject(this.textPoidsTotal, "T_POIDS");
    addRequiredSQLObject(dateDevis, "DATE");
    addRequiredSQLObject(this.radioEtat, "ID_ETAT_DEVIS");
    addRequiredSQLObject(this.numeroUniqueDevis, "NUMERO");
    addSQLObject(this.infos, "INFOS");
    comboClient.addModelListener(
        "wantedID",
        new PropertyChangeListener() {

          @Override
          public void propertyChange(PropertyChangeEvent arg0) {
            if (!isFilling()) {
              Integer id = comboClient.getWantedID();

              if (id > 1) {

                SQLRow row = comboClient.getElement().getTable().getRow(id);
                if (comboClient.getElement().getTable().getFieldsName().contains("ID_TARIF")) {

                  SQLRowAccessor foreignRow = row.getForeignRow("ID_TARIF");
                  if (!foreignRow.isUndefined()
                      && (boxTarif.getSelectedRow() == null
                          || boxTarif.getSelectedId() != foreignRow.getID())
                      && JOptionPane.showConfirmDialog(
                              null, "Appliquer les tarifs associés au client?")
                          == JOptionPane.YES_OPTION) {
                    boxTarif.setValue(foreignRow.getID());
                    // SaisieVenteFactureSQLComponent.this.tableFacture.setTarif(foreignRow,
                    // true);
                  } else {
                    boxTarif.setValue(foreignRow.getID());
                  }

                  // SQLRowAccessor foreignRow = row.getForeignRow("ID_TARIF");
                  // if (foreignRow.isUndefined() &&
                  // !row.getForeignRow("ID_DEVISE").isUndefined()) {
                  // SQLRowValues rowValsD = new SQLRowValues(foreignRow.getTable());
                  // rowValsD.put("ID_DEVISE", row.getObject("ID_DEVISE"));
                  // foreignRow = rowValsD;
                  //
                  // }
                  // table.setTarif(foreignRow, true);
                }
              }
            }
          }
        });
    DefaultGridBagConstraints.lockMinimumSize(comboCommercial);
    DefaultGridBagConstraints.lockMinimumSize(comboClient);
  }
  //  private int getDefaultTextComponentHeight() {
  //    if (defaultTextComponentHeight == -1) defaultTextComponentHeight = new
  // JComboBox().getPreferredSize().height;
  //    return defaultTextComponentHeight;
  //  }
  private void initComponents() {
    setLayout(new GridBagLayout());

    GridBagConstraints constraints;

    // takeLabel
    takeLabel = new JLabel(Bundle.SnapshotCustomizer_TakeLabelText());
    constraints = new GridBagConstraints();
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.fill = GridBagConstraints.NONE;
    constraints.insets = new Insets(0, 0, 5, 5);
    add(takeLabel, constraints);

    // firstLineCaptionSpacer
    constraints = new GridBagConstraints();
    constraints.gridx = 1;
    constraints.gridy = 0;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.fill = GridBagConstraints.NONE;
    constraints.insets = new Insets(0, 0, 0, 0);
    add(firstLineCaptionSpacer, constraints);

    ButtonGroup takeRadiosGroup = new ButtonGroup();
    JPanel takeRadiosContainer = new JPanel(new GridBagLayout());

    // takeSnapshotRadio
    takeSnapshotRadio = new JRadioButton();
    org.openide.awt.Mnemonics.setLocalizedText(
        takeSnapshotRadio, Bundle.SnapshotCustomizer_ProfilingDataRadioText());
    takeRadiosGroup.add(takeSnapshotRadio);
    constraints = new GridBagConstraints();
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.fill = GridBagConstraints.NONE;
    constraints.insets = new Insets(0, 0, 0, 5);
    takeRadiosContainer.add(takeSnapshotRadio, constraints);
    takeSnapshotRadio.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            resetResultsCheckbox.setEnabled(takeSnapshotRadio.isSelected());
          }
        });

    // takeHeapdumpRadio
    takeHeapdumpRadio = new JRadioButton();
    org.openide.awt.Mnemonics.setLocalizedText(
        takeHeapdumpRadio, Bundle.SnapshotCustomizer_HeapDumpRadioText());
    takeRadiosGroup.add(takeHeapdumpRadio);
    constraints = new GridBagConstraints();
    constraints.gridx = 1;
    constraints.gridy = 0;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.fill = GridBagConstraints.NONE;
    constraints.insets = new Insets(0, 0, 0, 0);
    takeRadiosContainer.add(takeHeapdumpRadio, constraints);

    JPanel takeRadiosSpacer = new JPanel(new FlowLayout(FlowLayout.LEADING, 0, 0));
    constraints = new GridBagConstraints();
    constraints.gridx = 2;
    constraints.gridy = 0;
    constraints.gridwidth = GridBagConstraints.REMAINDER;
    constraints.weightx = 1;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.insets = new Insets(0, 0, 0, 0);
    takeRadiosContainer.add(takeRadiosSpacer, constraints);

    // takeRadiosContainer
    constraints = new GridBagConstraints();
    constraints.gridx = 2;
    constraints.gridy = 0;
    constraints.weightx = 1;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.insets = new Insets(0, 0, 5, 0);
    add(takeRadiosContainer, constraints);

    //    return new Dimension(super.getMinimumSize().width, getDefaultTextComponentHeight());
    // --- next row ----------------------------------------------------------
    ButtonGroup saveRadiosGroup = new ButtonGroup();

    // lineLabel
    saveLabel = new JLabel(Bundle.SnapshotCustomizer_SaveLabelText());
    constraints = new GridBagConstraints();
    constraints.gridx = 0;
    constraints.gridy = 1;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.fill = GridBagConstraints.NONE;
    constraints.insets = new Insets(0, 0, 0, 5);
    add(saveLabel, constraints);

    // secondLineCaptionSpacer
    constraints = new GridBagConstraints();
    constraints.gridx = 1;
    constraints.gridy = 1;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.fill = GridBagConstraints.NONE;
    constraints.insets = new Insets(0, 0, 0, 0);
    add(secondLineCaptionSpacer, constraints);

    // saveToProjectRadio
    saveToProjectRadio = new JRadioButton();
    org.openide.awt.Mnemonics.setLocalizedText(
        saveToProjectRadio, Bundle.SnapshotCustomizer_ToProjectRadioText());
    saveRadiosGroup.add(saveToProjectRadio);
    saveToProjectRadio.addChangeListener(this);
    constraints.gridx = 2;
    constraints.gridy = 1;
    constraints.gridwidth = GridBagConstraints.REMAINDER;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.fill = GridBagConstraints.NONE;
    constraints.insets = new Insets(0, 0, 0, 0);
    add(saveToProjectRadio, constraints);

    // --- next row ----------------------------------------------------------
    JPanel saveToFileSettingsContainer = new JPanel(new GridBagLayout());

    JPanel saveToFileSpacer = new JPanel(new FlowLayout(FlowLayout.LEADING, 0, 0));
    constraints = new GridBagConstraints();
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.insets = new Insets(0, 0, 0, 0);
    takeRadiosContainer.add(saveToFileSpacer, constraints);

    // thirdLineCaptionSpacer
    constraints = new GridBagConstraints();
    constraints.gridx = 1;
    constraints.gridy = 2;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.fill = GridBagConstraints.NONE;
    constraints.insets = new Insets(0, 0, 0, 0);
    add(thirdLineCaptionSpacer, constraints);

    // saveToFileRadio
    saveToFileRadio = new JRadioButton();
    org.openide.awt.Mnemonics.setLocalizedText(
        saveToFileRadio, Bundle.SnapshotCustomizer_ToDirectoryRadioText());
    saveRadiosGroup.add(saveToFileRadio);
    saveToFileRadio.setSelected(true);
    saveToFileRadio.addChangeListener(this);
    constraints = new GridBagConstraints();
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.fill = GridBagConstraints.NONE;
    constraints.insets = new Insets(0, 0, 0, 5);
    saveToFileSettingsContainer.add(saveToFileRadio, constraints);

    // saveToFileField
    saveToFileField =
        new JTextField("") { // NOI18N
          public Dimension getPreferredSize() {
            return new Dimension(super.getMinimumSize().width, super.getPreferredSize().height);
          }

          public Dimension getMinimumSize() {
            return getPreferredSize();
          }
        };
    saveToFileField
        .getAccessibleContext()
        .setAccessibleName(Bundle.SnapshotCustomizer_ToDirectoryRadioText());
    saveToFileField
        .getAccessibleContext()
        .setAccessibleDescription(Bundle.SnapshotCustomizer_SaveFieldAccessName());
    saveToFileField.getDocument().addDocumentListener(this);
    constraints = new GridBagConstraints();
    constraints.gridx = 1;
    constraints.gridy = 0;
    constraints.weightx = 1;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.insets = new Insets(0, 0, 0, 5);
    saveToFileSettingsContainer.add(saveToFileField, constraints);

    // saveToFileButton
    saveToFileButton = new JButton();
    org.openide.awt.Mnemonics.setLocalizedText(
        saveToFileButton, Bundle.SnapshotCustomizer_BrowseButtonText());
    saveToFileButton.addActionListener(this);
    constraints = new GridBagConstraints();
    constraints.gridx = 2;
    constraints.gridy = 0;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.fill = GridBagConstraints.NONE;
    constraints.insets = new Insets(0, 0, 0, 0);
    saveToFileSettingsContainer.add(saveToFileButton, constraints);

    // saveToFileSettingsContainer
    constraints = new GridBagConstraints();
    constraints.gridx = 2;
    constraints.gridy = 2;
    constraints.gridwidth = GridBagConstraints.REMAINDER;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    constraints.insets = new Insets(0, 0, 8, 0);
    add(saveToFileSettingsContainer, constraints);

    // --- next row ----------------------------------------------------------
    resetResultsCheckbox = new JCheckBox();
    org.openide.awt.Mnemonics.setLocalizedText(
        resetResultsCheckbox, Bundle.SnapshotCustomizer_ResetResultsCheckboxText());
    constraints = new GridBagConstraints();
    constraints.gridx = 0;
    constraints.gridy = 3;
    constraints.gridwidth = GridBagConstraints.REMAINDER;
    constraints.anchor = GridBagConstraints.WEST;
    constraints.fill = GridBagConstraints.NONE;
    constraints.insets = new Insets(0, 0, 0, 0);
    add(resetResultsCheckbox, constraints);

    // --- next row ----------------------------------------------------------
    JPanel fillerPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 0, 0));
    constraints = new GridBagConstraints();
    constraints.gridx = 0;
    constraints.gridy = 4;
    constraints.weighty = 1;
    constraints.anchor = GridBagConstraints.NORTHWEST;
    constraints.fill = GridBagConstraints.BOTH;
    constraints.insets = new Insets(0, 0, 0, 0);
    add(fillerPanel, constraints);
  }
Example #14
0
  public NewUserDialog(Frame frame, ModelingCommons communicator, String errorLabelText) {
    super(frame);
    this.communicator = communicator;
    this.frame = frame;
    initializeGUIComponents();
    errorLabel.setText(errorLabelText);
    getRootPane().setDefaultButton(createAccountButton);
    for (String country : communicator.getPriorityCountries()) {
      countryComboBox.addItem(country, true);
    }
    countryComboBox.addItem("--------", false);
    for (String country : communicator.getUnpriorityCountries()) {
      countryComboBox.addItem(country, true);
    }
    femaleRadioButton.setSelected(true);
    userAgreementTextPane.setText(communicator.getNewUserAgreement());
    userAgreementTextPane.setCaretPosition(0);
    int startYear = 1930;
    birthdayYearComboBox.addItem(null);
    for (int y = Calendar.getInstance().get(Calendar.YEAR); y >= startYear; y--) {
      birthdayYearComboBox.addItem(y);
    }
    birthdayMonthComboBox.addItem(null);
    for (Month month : Month.getMonths()) {
      birthdayMonthComboBox.addItem(month);
    }
    birthdayDayComboBox.addItem(null);
    for (int d = 1; d <= 31; d++) {
      birthdayDayComboBox.addItem(d);
    }
    imageFromFileRadioButton.addChangeListener(
        new ChangeListener() {

          @Override
          public void stateChanged(ChangeEvent changeEvent) {
            if (imageFromFileRadioButton.isSelected()) {
              fileSelector.setEnabled(true);
            } else {
              fileSelector.setEnabled(false);
            }
          }
        });
    imageFromFileRadioButton.setSelected(true);
    createAccountButton.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {
            onOK();
          }
        });
    cancelButton.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {
            onCancel();
          }
        });
    loginButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent actionEvent) {
            dispose();
            NewUserDialog.this.communicator.promptForLogin();
          }
        });
    // call onCancel() when cross is clicked
    setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
    addWindowListener(
        new WindowAdapter() {

          public void windowClosing(WindowEvent e) {
            onCancel();
          }
        });
    // call onCancel() on ESCAPE
    topLevelContainer.registerKeyboardAction(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {
            onCancel();
          }
        },
        KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
        JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    setModal(true);
    pack();
    setLocationRelativeTo(frame);
    setResizable(true);
  }
  public BiblioSearchLimitPanel(
      DatabankSchema schema, MarcQueryBuilder queryBuilder, int language, SearchUI utils) {
    super(new GridBagLayout(), queryBuilder);
    this.schema = schema;
    this.language = language;
    ButtonGroup g;

    props = PropertyUtils.loadProperties(getClass().getName(), LocaleUtils.getLocale(language));
    GuiUtils.setActionName(dateRangeAction, props.getProperty("date_range.name"));
    GuiUtils.setActionName(yearAction, props.getProperty("year.name"));
    this.utils = utils;

    lblCodingLevel = new JLabel(props.getProperty("coding_level.name"));
    cmCodingLevel = utils.constantTableLookup(SearchEngineDocumentModel.BIBLIO_LEADER_17);
    cmCodingLevel.setName("biblioCodingLevel");
    lblCodingLevel.setLabelFor(cmCodingLevel);

    lblCataloguingForm = new JLabel(props.getProperty("cataloguing_form.name"));
    cmCataloguingForm = utils.constantTableLookup(SearchEngineDocumentModel.BIBLIO_LEADER_18);
    cmCataloguingForm.setName("biblioCataloguingForm");
    lblCataloguingForm.setLabelFor(cmCataloguingForm);

    rBetween = new JRadioButton(props.getProperty("between.name"));
    rBetween.setName("biblioBetweenYears");
    rLt = new JRadioButton(props.getProperty("lt.name"));
    rLt.setName("biblioLessThanYear");
    rGt = new JRadioButton(props.getProperty("gt.name"));
    rGt.setName("biblioGreaterThanYear");
    txfYear = utils.queryTextField(4);
    txfYear.setName("biblioYearEquals");
    rYear = new JRadioButton(yearAction);
    rYear.setName("biblioYear");
    rDateRange = new JRadioButton(dateRangeAction);
    rDateRange.setName("biblioDateRange");
    lblDoctype = new JLabel(props.getProperty("biblio_doctype.name"));
    lblFrom = new JLabel(props.getProperty("from.name"));
    lblTo = new JLabel(props.getProperty("to.name"));
    lblLanguage = new JLabel(props.getProperty("language.name"));
    lblLocation = new JLabel(props.getProperty("location.name"));
    lblRetriveNo = new JLabel(props.getProperty("retriveNo.name"));
    lblRecType = new JLabel(props.getProperty("rectype.name"));
    lblRecStatus = new JLabel(props.getProperty("recstatus.name"));
    lblCalendar = new JLabel(props.getProperty("calendar.name"));
    lblBiblevel = new JLabel(props.getProperty("biblevel.name"));
    lblHierarchicalLevel = new JLabel(props.getProperty("hierarchical_level.name"));
    cmDoctype = utils.constantTableLookup(SearchEngineDocumentModel.BIBLIO_DOC_TYPE);
    cmDoctype.setName("biblioDocType");
    cmLocation = utils.constantTableLookup(SearchEngineDocumentModel.LOCATION);
    cmLocation.setName("biblioLocation");
    cmLanguage = utils.constantTableLookup(SearchEngineDocumentModel.LANGUAGE);
    cmLanguage.setName("biblioLanguage");
    cmBiblevel = utils.constantTableLookup(SearchEngineDocumentModel.BIBLIO_LEADER_7);
    cmBiblevel.setName("biblioLevel");
    cmHierarchicalLevel = utils.constantTableLookup(SearchEngineDocumentModel.BIBLIO_LEADER_8);
    cmHierarchicalLevel.setName("biblioHierarchicalLevel");
    cmRecType = utils.constantTableLookup(SearchEngineDocumentModel.BIBLIO_LEADER_6);
    cmRecType.setName("biblioRecType");
    cmRecStatus = utils.constantTableLookup(SearchEngineDocumentModel.BIBLIO_LEADER_5);
    cmRecStatus.setName("biblioRecStatus");
    cmCalendar = utils.constantTableLookup(SearchEngineDocumentModel.CALENDAR);
    cmCalendar.setName("biblioCalendar");
    txfFrom = utils.queryTextField(10);
    txfFrom.setName("biblioFromYear");
    txfTo = utils.queryTextField(10);
    txfTo.setName("biblioToYear");
    txfRetriveNo = utils.queryTextField(10);
    txfRetriveNo.setName("retriveNo");
    lblDoctype.setLabelFor(cmDoctype);
    lblLocation.setLabelFor(cmLocation);
    lblLanguage.setLabelFor(cmLanguage);
    lblFrom.setLabelFor(txfFrom);
    lblTo.setLabelFor(txfTo);
    lblRetriveNo.setLabelFor(txfRetriveNo);
    lblTo.setVerticalTextPosition(JLabel.BOTTOM);
    lblCalendar.setHorizontalAlignment(JLabel.TRAILING);
    lblLanguage.setHorizontalAlignment(JLabel.TRAILING);
    lblRecType.setHorizontalAlignment(JLabel.TRAILING);
    lblDoctype.setHorizontalAlignment(JLabel.TRAILING);
    lblLocation.setHorizontalAlignment(JLabel.TRAILING);
    cbHasAttachment = new JCheckBox(props.getProperty("attachment.name"));
    cbIsOpenShelf = new JCheckBox(props.getProperty("openShelf.name"));
    cbIsLendable = new JCheckBox(props.getProperty("lendable.name"));
    rWithAttachment = new JRadioButton(props.getProperty("attachment-present.name"));
    rWithoutAttachment = new JRadioButton(props.getProperty("attachment-notpresent.name"));
    cbHasAttachment.setName("biblioAttachment");
    cbIsOpenShelf.setName("holdingIsOpenShelf");
    cbIsLendable.setName("holdingIsLendable");
    rWithAttachment.setName("biblioAttachmentPresent");
    rWithoutAttachment.setName("biblioAttachmentNotPresent");
    cbHasAttachment.addChangeListener(attachmentChangedListener);
    rWithAttachment.setEnabled(false);
    rWithoutAttachment.setEnabled(false);
    cbHasAttachment.setSelected(false);
    cbIsOpenShelf.setSelected(false);
    cbIsLendable.setSelected(false);
    g = new ButtonGroup();
    g.add(rWithAttachment);
    g.add(rWithoutAttachment);

    g = new ButtonGroup();
    g.add(rBetween);
    g.add(rLt);
    g.add(rGt);
    g = new ButtonGroup();
    g.add(rDateRange);
    g.add(rYear);
    rYear.setSelected(true);
    dateCriteriaChanged();

    lblDescriptionLevel = new JLabel(props.getProperty("level-of-description.name"));
    cmDescriptionLevel =
        utils.constantTableLookup(SearchEngineDocumentModel.BIBLIO_ISAD_LEVEL_OF_DESCRIPTION);
    cmDescriptionLevel.setName("biblioDescriptionLevel");
    lblDescriptionLevel.setLabelFor(cmDescriptionLevel);

    lblGMD = new JLabel(props.getProperty("general-material.name"));
    cmGMD = utils.constantTableLookup(SearchEngineDocumentModel.BIBLIO_GMD_LIST);
    cmGMD.setName("biblioGMD");
    lblGMD.setLabelFor(cmGMD);

    lblLCClass = new JLabel(props.getProperty("lcclass.name"));
    txfLCClass = new JTextField(20);
    GuiUtils.localeSupport(txfLCClass);
    GuiUtils.setComponentOrientation(txfLCClass, ComponentOrientation.LEFT_TO_RIGHT);
    lblLCClass.setLabelFor(txfLCClass);

    LayoutFacility lf = new LayoutFacility(this);
    /*
            lf.add(lblCodingLevel,
                    new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 2, 2), 0, 0));
            lf.add(cmCodingLevel,
                    new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0));
    */
    int y = 0;
    lf.add(
        lblDoctype,
        new GridBagConstraints(
            0,
            y,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));
    lf.add(
        cmDoctype,
        new GridBagConstraints(
            1,
            y,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));
    lf.add(
        lblRecType,
        new GridBagConstraints(
            2,
            y,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_END,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));
    lf.add(
        cmRecType,
        new GridBagConstraints(
            3,
            y++,
            GridBagConstraints.REMAINDER,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));
    lf.add(
        lblGMD,
        new GridBagConstraints(
            0,
            y,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_END,
            GridBagConstraints.NONE,
            new Insets(2, 2, 2, 2),
            0,
            0));
    lf.add(
        cmGMD,
        new GridBagConstraints(
            1,
            y++,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));

    lf.add(
        lblLocation,
        new GridBagConstraints(
            0,
            y,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));
    lf.add(
        cmLocation,
        new GridBagConstraints(
            1,
            y,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));
    lf.add(
        lblLanguage,
        new GridBagConstraints(
            2,
            y,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));
    lf.add(
        cmLanguage,
        new GridBagConstraints(
            3,
            y,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));
    lf.add(
        lblBiblevel,
        new GridBagConstraints(
            4,
            y,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));
    lf.add(
        cmBiblevel,
        new GridBagConstraints(
            5,
            y++,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));
    ////
    lf.add(
        lblCataloguingForm,
        new GridBagConstraints(
            0,
            y,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));
    lf.add(
        cmCataloguingForm,
        new GridBagConstraints(
            1,
            y,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));
    lf.add(
        lblHierarchicalLevel,
        new GridBagConstraints(
            2,
            y,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));
    lf.add(
        cmHierarchicalLevel,
        new GridBagConstraints(
            3,
            y,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));
    lf.add(
        lblRecStatus,
        new GridBagConstraints(
            4,
            y,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));
    lf.add(
        cmRecStatus,
        new GridBagConstraints(
            5,
            y++,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));
    ////
    lf.add(
        lblCodingLevel,
        new GridBagConstraints(
            4,
            y,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));
    lf.add(
        cmCodingLevel,
        new GridBagConstraints(
            5,
            y,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.NONE,
            new Insets(2, 2, 2, 2),
            0,
            0));
    lf.add(
        rYear,
        new GridBagConstraints(
            0,
            y,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.FIRST_LINE_START,
            GridBagConstraints.NONE,
            new Insets(2, 2, 2, 2),
            0,
            0));
    lf.add(
        txfYear,
        new GridBagConstraints(
            1,
            y,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.FIRST_LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));
    lf.add(
        lblCalendar,
        new GridBagConstraints(
            2,
            y,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.FIRST_LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));
    lf.add(
        cmCalendar,
        new GridBagConstraints(
            3,
            y++,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.FIRST_LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));

    lf.add(
        rDateRange,
        new GridBagConstraints(
            0,
            y,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.FIRST_LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));

    LayoutFacility datelf = new LayoutFacility(new JPanel());
    datelf.add(
        lblFrom,
        new GridBagConstraints(
            1,
            1,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.NONE,
            new Insets(2, 5, 2, 5),
            0,
            0));
    datelf.add(
        txfFrom,
        new GridBagConstraints(
            2,
            1,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));
    datelf.add(
        rGt,
        new GridBagConstraints(
            3,
            1,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.NONE,
            new Insets(2, 2, 2, 2),
            0,
            0));
    datelf.add(
        rBetween,
        new GridBagConstraints(
            4,
            1,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.NONE,
            new Insets(2, 2, 2, 2),
            0,
            0));
    datelf.add(
        rLt,
        new GridBagConstraints(
            5,
            1,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.NONE,
            new Insets(2, 2, 2, 2),
            0,
            0));
    datelf.add(
        lblTo,
        new GridBagConstraints(
            6,
            1,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.NONE,
            new Insets(2, 5, 2, 5),
            0,
            0));
    datelf.add(
        txfTo,
        new GridBagConstraints(
            7,
            1,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));
    datelf.add(
        Box.createHorizontalGlue(),
        new GridBagConstraints(
            8,
            1,
            GridBagConstraints.REMAINDER,
            1,
            1.0,
            0.0,
            GridBagConstraints.LINE_END,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));

    lf.add(
        datelf.container,
        new GridBagConstraints(
            1,
            y++,
            GridBagConstraints.REMAINDER,
            1,
            1.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));

    LayoutFacility lcClasslf = new LayoutFacility(new JPanel());
    lcClasslf.add(
        lblLCClass,
        new GridBagConstraints(
            1,
            1,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.NONE,
            new Insets(2, 5, 2, 5),
            0,
            0));
    lcClasslf.add(
        txfLCClass,
        new GridBagConstraints(
            2,
            1,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));

    lf.add(
        lcClasslf.container,
        new GridBagConstraints(
            0,
            y++,
            2,
            1,
            1.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL,
            new Insets(2, 2, 2, 2),
            0,
            0));

    LayoutFacility attLf = LayoutFacility.createLayoutFacility();
    int x = 0;
    attLf.add(
        cbHasAttachment,
        new GridBagConstraints(
            x++,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.NONE,
            new Insets(2, 2, 2, 2),
            0,
            0));
    attLf.add(
        cbIsOpenShelf,
        new GridBagConstraints(
            x++,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.NONE,
            new Insets(2, 2, 2, 2),
            0,
            0));
    //        attLf.add(cbIsLendable,
    //        		new GridBagConstraints(x++, 0, 1, 1, 0.0, 0.0, GridBagConstraints.LINE_START,
    // GridBagConstraints.NONE, new Insets(2, 2, 2, 10), 0, 0));
    attLf.add(
        lblRetriveNo,
        new GridBagConstraints(
            x++,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.NONE,
            new Insets(2, 20, 2, 2),
            0,
            0));
    attLf.add(
        txfRetriveNo,
        new GridBagConstraints(
            x++,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.NONE,
            new Insets(2, 2, 2, 2),
            25,
            0));

    if (SystemUtils.isISADAvailable()) {
      attLf.add(
          lblDescriptionLevel,
          new GridBagConstraints(
              x++,
              0,
              1,
              1,
              0.0,
              0.0,
              GridBagConstraints.LINE_START,
              GridBagConstraints.HORIZONTAL,
              new Insets(2, 20, 2, 2),
              0,
              0));
      attLf.add(
          cmDescriptionLevel,
          new GridBagConstraints(
              x++,
              0,
              1,
              1,
              0.0,
              0.0,
              GridBagConstraints.LINE_START,
              GridBagConstraints.NONE,
              new Insets(2, 2, 2, 2),
              0,
              0));
    }

    /*
            attLf.add(rWithAttachment,
                    new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0));
            attLf.add(rWithoutAttachment,
                    new GridBagConstraints(2, 0, 1, 1, 1.0, 0.0, GridBagConstraints.LINE_START, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0));
    */

    lf.add(
        attLf.container,
        new GridBagConstraints(
            0,
            y,
            GridBagConstraints.REMAINDER,
            1,
            0.0,
            0.0,
            GridBagConstraints.LINE_START,
            GridBagConstraints.NONE,
            new Insets(2, 2, 2, 2),
            0,
            0));
    //        lf.add(Box.createHorizontalGlue(),
    //                new GridBagConstraints(1, 4, 0, 1, 0.0, 0.0, GridBagConstraints.LINE_START,
    // GridBagConstraints.HORIZONTAL, new Insets(2, 2, 2, 2), 0, 0));

    ChangeListener limitChangeListener =
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            txfFrom.setEditable(!rLt.isSelected() && rDateRange.isSelected());
            txfTo.setEditable(!rGt.isSelected() && rDateRange.isSelected());
          }
        };
    rGt.addChangeListener(limitChangeListener);
    rLt.addChangeListener(limitChangeListener);
    rBetween.addChangeListener(limitChangeListener);
    rGt.setSelected(true);
  }
  /**
   * Initializes a window with all necessary components. This includes a JComboBox, JButton,
   * multiple JRadioButtons and multiple JLabels into the appropriate panels and adds them to the
   * current frame.
   */
  private void initUI() {

    // Get data for comboBox
    final ArrayList<String> locList = new ArrayList<String>();

    // Catch exceptions
    try {
      locationList(locList);
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }

    // Search buttons and selected value text
    JLabel lblHello = new JLabel("Choose your location...");
    lblHello.setForeground(Color.BLACK);
    final JLabel lblText = new JLabel();
    lblText.setForeground(Color.BLACK);

    // Radio Buttons
    JRadioButton radCelsius;
    final JRadioButton radFahrenheit;

    radCelsius = new JRadioButton("Celsius");
    radCelsius.setSelected(true);
    radCelsius.setForeground(Color.BLACK);
    radFahrenheit = new JRadioButton("Fahrenheit");
    radFahrenheit.setForeground(Color.BLACK);

    ButtonGroup grpTemp = new ButtonGroup();
    grpTemp.add(radCelsius);
    grpTemp.add(radFahrenheit);

    // Auto Complete Combo Box
    StringSearchable searchable = new StringSearchable(locList);
    final AutoCompleteJComboBox combo = new AutoCompleteJComboBox(searchable);
    combo.setEditable(true);

    // Change listener for when switching between radio buttons
    radCelsius.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent arg0) {
            String msg = "Selected: " + combo.getSelectedItem() + " in Celsius";
            lblText.setText(msg);
          }
        });

    // Change listener for when switching between radio buttons
    radFahrenheit.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent arg0) {
            String msg = "Selected: " + combo.getSelectedItem() + " in Fahrenheit";
            lblText.setText(msg);
          }
        });

    // KeyListener for when hitting enter in window
    KeyListener eListener =
        new KeyListener() {
          public void keyReleased(KeyEvent event) {
            if (event.getKeyChar() == KeyEvent.VK_ENTER) {
              combo.setPopupVisible(true);
              if (!(locList.contains(combo.getSelectedItem()))) {
                String err = "Error: Incorrect Location, Please Try Again";
                lblText.setText(err);
              } else {
                String msg = "Selected: " + combo.getSelectedItem();
                if (radFahrenheit.isSelected()) msg += " in Fahrenheit";
                else msg += " in Celsius";
                lblText.setText(msg);
              }
            }
          }

          public void keyTyped(KeyEvent arg0) {}

          public void keyPressed(KeyEvent e) {}
        };

    // Action listeners for window
    radCelsius.addKeyListener(eListener);
    radFahrenheit.addKeyListener(eListener);
    combo.getEditor().getEditorComponent().addKeyListener(eListener);

    // Set Preferred width of combo box
    combo.setPrototypeDisplayValue("XXXXXXXXXXXXXXXXXX");

    // Add panes to window
    JPanel paneNorth = new JPanel();
    JPanel paneCenter = new JPanel();
    JPanel paneSouth = new JPanel();

    JButton GWButton = new JButton("Get Weather");

    // Add action listener to button "Get Local Weather"
    GWButton.addActionListener(
        new ActionListener() {

          public void actionPerformed(ActionEvent e) {
            if (!(combo.getSelectedItem().toString().equalsIgnoreCase("mars"))
                && !(locList.contains(combo.getSelectedItem()))) {
              String err = "Error: Incorrect Location, Please Try Again";
              lblText.setText(err);
              // combo.setPopupVisible(true);
            } else {
              String msg = "Selected: " + combo.getSelectedItem();
              if (radFahrenheit.isSelected()) {
                msg += " in Fahrenheit";
                dataRequester.setFahrenheit();
              } else {
                msg += " in Celsius";
                dataRequester.setCelcius();
              }
              lblText.setText(msg);

              // Print result to preferences file for secondary startup
              try {
                PrintWriter out =
                    new PrintWriter(new BufferedWriter(new FileWriter("preferences.txt", true)));
                out.println(lblText.getText().toString());
                out.close();
              } catch (IOException f) {
              }

              String city = combo.getSelectedItem().toString();
              String cityName;
              String cityId;
              if (city.equalsIgnoreCase("mars")) {
                cityName = "Mars";
                cityId = "Mars";
              } else {
                cityName = city.substring(0, city.indexOf('['));
                cityId = city.substring(city.indexOf('[') + 1, city.indexOf(']'));
              }

              if (cityId.equals("Mars")) {
                dataRequester.update(cityId);
                localWeatherView.setCityName(cityName);
                try {
                  localWeatherView.setLabels();
                } catch (IOException e1) {
                  // TODO Auto-generated catch block
                  e1.printStackTrace();
                }
                shortTermView.clear();
                lblText.setText("Weather Fetched");
              } else {
                dataRequester.update(cityId);
                localWeatherView.setCityName(cityName);
                try {
                  localWeatherView.setLabels();
                } catch (IOException e1) {
                  // TODO Auto-generated catch block
                  e1.printStackTrace();
                }
                shortTermView.display();
                lblText.setText("Weather Fetched");
              }
            }
          }
        });

    // Layout for window
    paneNorth.setLayout(new FlowLayout(FlowLayout.LEFT));
    paneNorth.add(lblHello);

    GroupLayout groupLayout = new GroupLayout(this);
    groupLayout.setHorizontalGroup(
        groupLayout
            .createParallelGroup(Alignment.TRAILING)
            .addGroup(
                groupLayout
                    .createSequentialGroup()
                    .addGroup(
                        groupLayout
                            .createParallelGroup(Alignment.LEADING)
                            .addGroup(
                                groupLayout
                                    .createSequentialGroup()
                                    .addGap(36)
                                    .addComponent(
                                        paneNorth,
                                        GroupLayout.PREFERRED_SIZE,
                                        GroupLayout.DEFAULT_SIZE,
                                        GroupLayout.PREFERRED_SIZE))
                            .addGroup(
                                groupLayout
                                    .createSequentialGroup()
                                    .addContainerGap()
                                    .addComponent(
                                        paneCenter, GroupLayout.DEFAULT_SIZE, 438, Short.MAX_VALUE))
                            .addGroup(
                                groupLayout
                                    .createSequentialGroup()
                                    .addContainerGap()
                                    .addComponent(
                                        paneSouth, GroupLayout.DEFAULT_SIZE, 438, Short.MAX_VALUE)))
                    .addContainerGap()));
    groupLayout.setVerticalGroup(
        groupLayout
            .createParallelGroup(Alignment.LEADING)
            .addGroup(
                groupLayout
                    .createSequentialGroup()
                    .addGap(5)
                    .addComponent(
                        paneNorth,
                        GroupLayout.PREFERRED_SIZE,
                        GroupLayout.DEFAULT_SIZE,
                        GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(
                        paneCenter,
                        GroupLayout.PREFERRED_SIZE,
                        GroupLayout.DEFAULT_SIZE,
                        GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(
                        paneSouth,
                        GroupLayout.PREFERRED_SIZE,
                        GroupLayout.DEFAULT_SIZE,
                        GroupLayout.PREFERRED_SIZE)
                    .addGap(181)));
    GroupLayout gl_paneCenter = new GroupLayout(paneCenter);
    gl_paneCenter.setHorizontalGroup(
        gl_paneCenter
            .createParallelGroup(Alignment.LEADING)
            .addGroup(
                gl_paneCenter
                    .createSequentialGroup()
                    .addContainerGap()
                    .addComponent(
                        combo,
                        GroupLayout.PREFERRED_SIZE,
                        GroupLayout.DEFAULT_SIZE,
                        GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(radFahrenheit)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(radCelsius)
                    .addGap(62)));
    gl_paneCenter.setVerticalGroup(
        gl_paneCenter
            .createParallelGroup(Alignment.LEADING)
            .addGroup(
                gl_paneCenter
                    .createSequentialGroup()
                    .addGap(7)
                    .addGroup(
                        gl_paneCenter
                            .createParallelGroup(Alignment.BASELINE)
                            .addComponent(
                                combo,
                                GroupLayout.PREFERRED_SIZE,
                                GroupLayout.DEFAULT_SIZE,
                                GroupLayout.PREFERRED_SIZE)
                            .addComponent(radFahrenheit)
                            .addComponent(radCelsius))));
    paneCenter.setLayout(gl_paneCenter);

    GroupLayout gl_paneSouth = new GroupLayout(paneSouth);
    gl_paneSouth.setHorizontalGroup(
        gl_paneSouth
            .createParallelGroup(Alignment.LEADING)
            .addGroup(
                Alignment.TRAILING,
                gl_paneSouth
                    .createSequentialGroup()
                    .addGap(7)
                    .addComponent(lblText, GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(GWButton)
                    .addContainerGap()));
    gl_paneSouth.setVerticalGroup(
        gl_paneSouth
            .createParallelGroup(Alignment.TRAILING)
            .addGroup(
                Alignment.LEADING,
                gl_paneSouth
                    .createSequentialGroup()
                    .addContainerGap()
                    .addGroup(
                        gl_paneSouth
                            .createParallelGroup(Alignment.TRAILING)
                            .addComponent(
                                lblText,
                                Alignment.LEADING,
                                GroupLayout.DEFAULT_SIZE,
                                29,
                                Short.MAX_VALUE)
                            .addComponent(GWButton, Alignment.LEADING))
                    .addContainerGap()));
    paneSouth.setLayout(gl_paneSouth);
    setLayout(groupLayout);
  }
  private static JPanel createOptionsPanel() {
    JLabel header = new JLabel("Options");
    header.setFont(header.getFont().deriveFont(Font.BOLD, 13));
    header.setOpaque(true);
    header.setBackground(new Color(0, 0, 128));
    header.setForeground(Color.WHITE);
    header.setBorder(
        BorderFactory.createCompoundBorder(
            BorderFactory.createBevelBorder(
                BevelBorder.LOWERED, Color.white, Color.lightGray, Color.lightGray, Color.gray),
            BorderFactory.createEmptyBorder(0, 5, 0, 0)));
    header.setPreferredSize(new Dimension(100, 30));
    final JRadioButton style1 = new JRadioButton("Toolbar Style");
    final JRadioButton style2 = new JRadioButton("Toolbox Style");
    final JRadioButton style3 = new JRadioButton("Flat Style");
    final JRadioButton style4 = new JRadioButton("Hyperlink Style");
    ButtonGroup buttonGroup = new ButtonGroup();
    buttonGroup.add(style1);
    buttonGroup.add(style2);
    buttonGroup.add(style3);
    buttonGroup.add(style4);
    JPanel switchPanel = new JPanel(new GridLayout(4, 1, 3, 3));
    switchPanel.add(style1);
    switchPanel.add(style2);
    switchPanel.add(style3);
    switchPanel.add(style4);
    style1.setSelected(true);

    style1.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            if (style1.isSelected()) {
              for (int i = 0; i < _buttons.length; i++) {
                JideButton button = _buttons[i];
                button.setButtonStyle(JideButton.TOOLBAR_STYLE);
              }
            }
          }
        });
    style2.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            if (style2.isSelected()) {
              for (int i = 0; i < _buttons.length; i++) {
                JideButton button = _buttons[i];
                button.setButtonStyle(JideButton.TOOLBOX_STYLE);
              }
            }
          }
        });
    style3.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            if (style3.isSelected()) {
              for (int i = 0; i < _buttons.length; i++) {
                JideButton button = _buttons[i];
                button.setButtonStyle(JideButton.FLAT_STYLE);
              }
            }
          }
        });
    style4.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            if (style4.isSelected()) {
              for (int i = 0; i < _buttons.length; i++) {
                JideButton button = _buttons[i];
                button.setButtonStyle(JideButton.HYPERLINK_STYLE);
              }
            }
          }
        });
    switchPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    JPanel panel = new JPanel();
    panel.setLayout(new JideBoxLayout(panel, JideBoxLayout.Y_AXIS));
    panel.add(header);
    panel.add(switchPanel);
    panel.add(Box.createGlue(), JideBoxLayout.VARY);
    return panel;
  }