Exemplo n.º 1
0
  public SplitPaneDemo() {

    // Create the list of images and put it in a scroll pane.

    list = new JList(imageNames);
    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list.setSelectedIndex(0);
    list.addListSelectionListener(this);

    JScrollPane listScrollPane = new JScrollPane(list);
    picture = new JLabel();
    picture.setFont(picture.getFont().deriveFont(Font.ITALIC));
    picture.setHorizontalAlignment(JLabel.CENTER);

    JScrollPane pictureScrollPane = new JScrollPane(picture);

    // Create a split pane with the two scroll panes in it.
    splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, listScrollPane, pictureScrollPane);
    splitPane.setOneTouchExpandable(true);
    splitPane.setDividerLocation(150);

    // Provide minimum sizes for the two components in the split pane.
    Dimension minimumSize = new Dimension(100, 50);
    listScrollPane.setMinimumSize(minimumSize);
    pictureScrollPane.setMinimumSize(minimumSize);

    // Provide a preferred size for the split pane.
    splitPane.setPreferredSize(new Dimension(400, 200));
    updateLabel(imageNames[list.getSelectedIndex()]);
  }
  private void initGUI() {

    JPanel pCommand = new JPanel();

    pResult = new JPanel();
    nsSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, pCommand, pResult);

    pCommand.setLayout(new BorderLayout());
    pResult.setLayout(new BorderLayout());

    Font fFont = new Font("Dialog", Font.PLAIN, 12);

    txtCommand = new JTextArea(5, 40);

    txtCommand.setMargin(new Insets(5, 5, 5, 5));
    txtCommand.addKeyListener(this);

    txtCommandScroll = new JScrollPane(txtCommand);
    txtResult = new JTextArea(20, 40);

    txtResult.setMargin(new Insets(5, 5, 5, 5));

    txtResultScroll = new JScrollPane(txtResult);

    txtCommand.setFont(fFont);
    txtResult.setFont(new Font("Courier", Font.PLAIN, 12));
    /*
    // button replaced by toolbar
            butExecute = new JButton("Execute");

            butExecute.addActionListener(this);
            pCommand.add(butExecute, BorderLayout.EAST);
    */
    pCommand.add(txtCommandScroll, BorderLayout.CENTER);

    gResult = new GridSwing();
    gResultTable = new JTable(gResult);
    gScrollPane = new JScrollPane(gResultTable);

    // getContentPane().setLayout(new BorderLayout());
    pResult.add(gScrollPane, BorderLayout.CENTER);

    // Set up the tree
    rootNode = new DefaultMutableTreeNode("Connection");
    treeModel = new DefaultTreeModel(rootNode);
    tTree = new JTree(treeModel);
    tScrollPane = new JScrollPane(tTree);

    tScrollPane.setPreferredSize(new Dimension(120, 400));
    tScrollPane.setMinimumSize(new Dimension(70, 100));
    txtCommandScroll.setPreferredSize(new Dimension(360, 100));
    txtCommandScroll.setMinimumSize(new Dimension(180, 100));
    gScrollPane.setPreferredSize(new Dimension(460, 300));

    ewSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, tScrollPane, nsSplitPane);

    fMain.getContentPane().add(ewSplitPane, BorderLayout.CENTER);
    doLayout();
    fMain.pack();
  }
Exemplo n.º 3
0
  // {{{ BrowserView constructor
  BrowserView(final VFSBrowser browser) {
    this.browser = browser;

    tmpExpanded = new HashSet<String>();
    DockableWindowManager dwm = jEdit.getActiveView().getDockableWindowManager();
    KeyListener keyListener = dwm.closeListener(VFSBrowser.NAME);

    parentDirectories = new ParentDirectoryList();
    parentDirectories.addKeyListener(keyListener);
    parentDirectories.setName("parent");

    parentDirectories.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    parentDirectories.setCellRenderer(new ParentDirectoryRenderer());
    parentDirectories.setVisibleRowCount(5);
    parentDirectories.addMouseListener(new ParentMouseHandler());

    final JScrollPane parentScroller = new JScrollPane(parentDirectories);
    parentScroller.setMinimumSize(new Dimension(0, 0));

    table = new VFSDirectoryEntryTable(this);
    table.addMouseListener(new TableMouseHandler());
    table.addKeyListener(new TableKeyListener());
    table.setName("file");
    JScrollPane tableScroller = new JScrollPane(table);
    tableScroller.setMinimumSize(new Dimension(0, 0));
    tableScroller.getViewport().setBackground(table.getBackground());
    tableScroller.getViewport().addMouseListener(new TableMouseHandler());
    splitPane =
        new JSplitPane(
            browser.isHorizontalLayout() ? JSplitPane.HORIZONTAL_SPLIT : JSplitPane.VERTICAL_SPLIT,
            parentScroller,
            tableScroller);
    splitPane.setOneTouchExpandable(true);

    EventQueue.invokeLater(
        new Runnable() {
          public void run() {
            String prop =
                browser.isHorizontalLayout()
                    ? "vfs.browser.horizontalSplitter"
                    : "vfs.browser.splitter";
            int loc = jEdit.getIntegerProperty(prop, -1);
            if (loc == -1) loc = parentScroller.getPreferredSize().height;

            splitPane.setDividerLocation(loc);
            parentDirectories.ensureIndexIsVisible(parentDirectories.getModel().getSize());
          }
        });

    if (browser.isMultipleSelectionEnabled())
      table.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    else table.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    setLayout(new BorderLayout());

    add(BorderLayout.CENTER, splitPane);

    propertiesChanged();
  } // }}}
  // Initializes this component.
  private void jbInit() {
    segmentTable.addFocusListener(
        new FocusListener() {
          public void focusGained(FocusEvent e) {
            segmentTable_focusGained(e);
          }

          public void focusLost(FocusEvent e) {
            segmentTable_focusLost(e);
          }
        });
    segmentTable.setTableHeader(null);
    scrollPane = new JScrollPane(segmentTable);
    scrollPane.setMinimumSize(new Dimension(getTableWidth(), 0));

    setLayout(new BorderLayout(0, 0));

    determineColumnWidth();
    nameLbl.setPreferredSize(new Dimension(getTableWidth(), 25));
    nameLbl.setMinimumSize(new Dimension(getTableWidth(), 0));
    nameLbl.setFont(Utilities.labelsFont);

    segmentTable.setFont(Utilities.valueFont);
    setBorder(BorderFactory.createEtchedBorder());

    setMinimumSize(new Dimension(getTableWidth(), 0));

    this.add(nameLbl, BorderLayout.NORTH);
    this.add(scrollPane, BorderLayout.CENTER);
  }
 public void actionPerformed(final AnActionEvent e) {
   @NonNls final String delim = "&nbsp;-&gt;&nbsp;";
   final StringBuffer buf = new StringBuffer();
   processDependencies(
       getSelectedScope(myLeftTree),
       getSelectedScope(myRightTree),
       new Processor<List<PsiFile>>() {
         public boolean process(final List<PsiFile> path) {
           if (buf.length() > 0) buf.append("<br>");
           buf.append(
               StringUtil.join(
                   path,
                   new Function<PsiFile, String>() {
                     public String fun(final PsiFile psiFile) {
                       return psiFile.getName();
                     }
                   },
                   delim));
           return true;
         }
       });
   final JEditorPane pane =
       new JEditorPane(UIUtil.HTML_MIME, "<html>" + buf.toString() + "</html>");
   pane.setForeground(Color.black);
   pane.setBackground(HintUtil.INFORMATION_COLOR);
   pane.setOpaque(true);
   final JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(pane);
   final Dimension dimension = pane.getPreferredSize();
   scrollPane.setMinimumSize(new Dimension(dimension.width, dimension.height + 20));
   scrollPane.setPreferredSize(new Dimension(dimension.width, dimension.height + 20));
   JBPopupFactory.getInstance()
       .createComponentPopupBuilder(scrollPane, pane)
       .setTitle("Dependencies")
       .setMovable(true)
       .createPopup()
       .showInBestPositionFor(e.getDataContext());
 }
Exemplo n.º 6
0
 private void jbInit() throws Exception {
   panel1.setLayout(borderLayout1);
   okButton.setText("OK");
   okButton.addActionListener(new MimeTypeEditor_okButton_actionAdapter(this));
   filtersTable.setRowSelectionAllowed(true);
   filtersTable.setPreferredSize(new Dimension(418, 200));
   filtersTable.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
   filtersTable.setCellSelectionEnabled(true);
   filtersTable.setColumnSelectionAllowed(false);
   filtersTable.setModel(m_model);
   addButton.setToolTipText(
       "Add a new " + mimeTypeEditorBuilder.getValueName() + " for a MIME type");
   addButton.setText("Add");
   addButton.addActionListener(new MimeTypeEditor_addButton_actionAdapter(this));
   cancelButton.setText("Cancel");
   cancelButton.addActionListener(new MimeTypeEditor_cancelButton_actionAdapter(this));
   deleteButton.setToolTipText("Delete the currently selected item.");
   deleteButton.setText("Delete");
   deleteButton.addActionListener(new MimeTypeEditor_deleteButton_actionAdapter(this));
   upButton.setText("Up");
   upButton.addActionListener(new MimeTypeEditor_upButton_actionAdapter(this));
   dnButton.setText("Down");
   dnButton.addActionListener(new MimeTypeEditor_dnButton_actionAdapter(this));
   panel1.setPreferredSize(new Dimension(418, 200));
   jScrollPane1.setMinimumSize(new Dimension(200, 80));
   jScrollPane1.setOpaque(true);
   buttonPanel.add(dnButton, null);
   buttonPanel.add(upButton, null);
   buttonPanel.add(addButton, null);
   buttonPanel.add(deleteButton, null);
   buttonPanel.add(okButton, null);
   buttonPanel.add(cancelButton, null);
   getContentPane().add(panel1);
   panel1.add(buttonPanel, BorderLayout.SOUTH);
   panel1.add(jScrollPane1, BorderLayout.CENTER);
   jScrollPane1.getViewport().add(filtersTable, null);
 }
Exemplo n.º 7
0
  /**
   * Draws the GUI that allows a user to select assets to be updated.
   *
   * @return true if the user made a valid choice of assets to replace.
   * @throws PipelineException
   */
  private boolean buildUpdateGUI() throws PipelineException {
    Box finalBox = new Box(BoxLayout.Y_AXIS);
    top = new Box(BoxLayout.Y_AXIS);

    JScrollPane scroll;

    {
      scroll = new JScrollPane(finalBox);

      scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
      scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

      Dimension size = new Dimension(sVSize + sVSize + sTSize + 52, 500);
      scroll.setMinimumSize(size);
      scroll.setPreferredSize(size);
      scroll.getViewport().setScrollMode(JViewport.BACKINGSTORE_SCROLL_MODE);
    }

    /* query the user */
    diag = new JToolDialog("Propagate Asset", scroll, "Continue");

    areas = mclient.getWorkingAreas();
    {
      Box hbox = new Box(BoxLayout.X_AXIS);
      Component comps[] = UIFactory.createTitledPanels();
      JPanel tpanel = (JPanel) comps[0];
      JPanel vpanel = (JPanel) comps[1];
      {
        userField =
            UIFactory.createTitledCollectionField(
                tpanel,
                "User:"******"The user whose area the node is being created in.");
        userField.setActionCommand("user");
        userField.setSelected(PackageInfo.sUser);
        userField.addActionListener(this);
      }
      UIFactory.addVerticalSpacer(tpanel, vpanel, 3);
      {
        viewField =
            UIFactory.createTitledCollectionField(
                tpanel,
                "View:",
                sTSize,
                vpanel,
                areas.get(PackageInfo.sUser),
                diag,
                sVSize,
                "The working area to create the nodes in.");
        viewField.setActionCommand("wrap");
        viewField.addActionListener(this);
      }
      UIFactory.addVerticalSpacer(tpanel, vpanel, 3);
      {
        toolsetField =
            UIFactory.createTitledCollectionField(
                tpanel,
                "Toolset:",
                sTSize,
                vpanel,
                mclient.getActiveToolsetNames(),
                diag,
                sVSize,
                "The toolset to set on all the nodes.");
        toolsetField.setSelected(mclient.getDefaultToolsetName());
        toolsetField.setActionCommand("wrap");
        toolsetField.addActionListener(this);
      }
      UIFactory.addVerticalSpacer(tpanel, vpanel, 3);

      w =
          new Wrapper(
              userField.getSelected(),
              viewField.getSelected(),
              toolsetField.getSelected(),
              mclient);

      charList = SonyConstants.getAssetList(w, project, AssetType.CHARACTER);
      setsList = SonyConstants.getAssetList(w, project, AssetType.SET);
      propsList = SonyConstants.getAssetList(w, project, AssetType.PROP);

      {
        projectField =
            UIFactory.createTitledCollectionField(
                tpanel,
                "Project:",
                sTSize,
                vpanel,
                Globals.getChildrenDirs(w, "/projects"),
                diag,
                sVSize,
                "All the projects in pipeline.");
        projectField.setActionCommand("proj");
        projectField.addActionListener(this);
      }
      hbox.add(comps[2]);
      top.add(hbox);
    }

    {
      Box vbox = new Box(BoxLayout.Y_AXIS);
      Box hbox = new Box(BoxLayout.X_AXIS);
      JButton button = new JButton("Propagate Additional Asset");
      button.setName("ValuePanelButton");
      button.setRolloverEnabled(false);
      button.setFocusable(false);
      Dimension d = new Dimension(sVSize, 25);
      button.setPreferredSize(d);
      button.setMinimumSize(d);
      button.setMaximumSize(new Dimension(Integer.MAX_VALUE, 25));

      vbox.add(Box.createRigidArea(new Dimension(0, 5)));
      hbox.add(button);
      hbox.add(Box.createRigidArea(new Dimension(4, 0)));
      vbox.add(hbox);
      vbox.add(Box.createRigidArea(new Dimension(0, 5)));

      button.setActionCommand("add");
      button.addActionListener(this);

      top.add(vbox);
    }

    list = new Box(BoxLayout.Y_AXIS);
    test = new JDrawer("Propagate Additional Asset", list, false);

    top.add(test);
    list.add(assetChoiceBox());

    finalBox.add(top);

    {
      JPanel spanel = new JPanel();
      spanel.setName("Spacer");
      spanel.setMinimumSize(new Dimension(sTSize + sVSize, 7));
      spanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
      spanel.setPreferredSize(new Dimension(sTSize + sVSize, 7));
      finalBox.add(spanel);
    }

    diag.setVisible(true);
    if (diag.wasConfirmed()) {
      // get list of things to change.
      for (Component comp : list.getComponents()) {
        if (comp instanceof Box) {
          Box can = (Box) comp;
          JCollectionField oldOne = (JCollectionField) can.getComponent(2);
          JCollectionField newOne = (JCollectionField) can.getComponent(4);

          TreeMap<String, String> assetList = new TreeMap<String, String>();
          assetList.putAll(charList);
          assetList.putAll(propsList);
          assetList.putAll(setsList);

          String key = assetList.get(oldOne.getSelected()) + lr;
          String value = assetList.get(newOne.getSelected()) + lr;
          if (!key.equals(value)) {
            potentialUpdates.add(key);
            pAssetManager.put(key, new AssetInfo(key, value));
          }
          // System.err.println("bUG: "+pAssetManager.get(key).getHiLoResShots());
        }
      }

      if (!pAssetManager.isEmpty()) return true;
    }
    return false;
  } // end buildReplacementGUI
Exemplo n.º 8
0
  /**
   * Present a GUI allowing the user to select shots in which each previously selected asset should
   * be updated.
   *
   * @return
   * @throws PipelineException
   */
  private String confirmShotsToUpdate() throws PipelineException {

    /* DO GUI DRAWING STUFF*/
    JScrollPane scroll = null;
    {
      Box ibox = new Box(BoxLayout.Y_AXIS);
      if (pAssetManager.isEmpty()) {
        Component comps[] = UIFactory.createTitledPanels();
        JPanel tpanel = (JPanel) comps[0];
        JPanel vpanel = (JPanel) comps[1];

        tpanel.add(Box.createRigidArea(new Dimension(sTSize - 7, 0)));
        vpanel.add(Box.createHorizontalGlue());

        ibox.add(comps[2]);
      } else {

        for (String assetName : pAssetManager.keySet()) {
          String name = getShortName(assetName);
          AssetInfo info = pAssetManager.get(assetName);

          Component comps[] = UIFactory.createTitledPanels();
          JPanel tpanel = (JPanel) comps[0];
          JPanel vpanel = (JPanel) comps[1];
          String title = "Replace " + name + " with ";
          title += getShortName(info.getNewAsset());

          JDrawer shotList = new JDrawer(title, (JComponent) comps[2], true);
          ibox.add(shotList);

          for (String shot : info.getLoHiResShots().keySet()) {

            String shortShot = getShortName(shot);
            JBooleanField field =
                UIFactory.createTitledBooleanField(
                    tpanel,
                    shortShot,
                    sVSize,
                    vpanel,
                    sTSize,
                    "Whether to replace this asset source for the node.");
            field.setName(shot);
            field.setValue(true);

            if (!pSubstituteFields.containsKey(assetName))
              pSubstituteFields.put(assetName, new LinkedList<JBooleanField>());

            pSubstituteFields.get(assetName).add(field);
            UIFactory.addVerticalSpacer(tpanel, vpanel, 3);
          }
        }
      }

      {
        JPanel spanel = new JPanel();
        spanel.setName("Spacer");

        spanel.setMinimumSize(new Dimension(sTSize + sVSize, 7));
        spanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
        spanel.setPreferredSize(new Dimension(sTSize + sVSize, 7));

        ibox.add(spanel);
      }

      {
        scroll = new JScrollPane(ibox);
        scroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        scroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

        Dimension size = new Dimension(sTSize + sVSize + 52, 300);
        scroll.setMinimumSize(size);
        scroll.setPreferredSize(size);

        scroll.getViewport().setScrollMode(JViewport.BACKINGSTORE_SCROLL_MODE);
      }
    }

    /* query the user */
    JToolDialog diag = new JToolDialog("Update Assets Per Shot", scroll, "Confirm");
    diag.setVisible(true);

    /* Process User Input */
    if (diag.wasConfirmed()) {

      for (String asset : pSubstituteFields.keySet()) {
        for (JBooleanField field : pSubstituteFields.get(asset)) {
          Boolean bUpdate = field.getValue();
          if ((bUpdate == null) || !bUpdate) {
            pAssetManager.get(asset).getLoHiResShots().remove(field.getName());

            // logLine("\tRemoving: "+ getShortName(field.getName())
            // TODO		+" from list for "+ getShortName(asset));
          }
        }
      }
      return ": Modifying Nodes...";
    }
    return null;
  } // end confirmShotsToUpdate
Exemplo n.º 9
0
  void jbInit() throws Exception {
    titledBorder1 =
        new TitledBorder(
            BorderFactory.createLineBorder(new Color(153, 153, 153), 2), "Assembler messages");
    this.getContentPane().setLayout(borderLayout1);

    this.setIconifiable(true);
    this.setMaximizable(true);
    this.setResizable(true);

    this.setTitle("EDIT");

    splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    splitPane.setDividerLocation(470);
    sourceArea.setFont(new java.awt.Font("Monospaced", 0, 12));
    controlPanel.setLayout(gridBagLayout1);
    controlPanel.setBorder(BorderFactory.createLoweredBevelBorder());
    positionPanel.setLayout(gridBagLayout2);
    fileLabel.setText("Source file:");
    fileText.setEditable(false);
    browseButton.setSelected(false);
    browseButton.setText("Browse ...");
    assembleButton.setEnabled(false);
    assembleButton.setText("Assemble file");
    saveButton.setEnabled(false);
    saveButton.setText("Save file");
    lineLabel.setText("Line:");
    lineText.setMinimumSize(new Dimension(50, 20));
    lineText.setPreferredSize(new Dimension(50, 20));
    lineText.setEditable(false);
    columnLabel.setText("Column:");
    columnText.setMinimumSize(new Dimension(41, 20));
    columnText.setPreferredSize(new Dimension(41, 20));
    columnText.setEditable(false);
    columnText.setText("");
    messageScrollPane.setBorder(titledBorder1);
    messageScrollPane.setMinimumSize(new Dimension(33, 61));
    messageScrollPane.setPreferredSize(new Dimension(60, 90));
    optionsButton.setEnabled(false);
    optionsButton.setText("Assembler options ...");
    messageScrollPane.getViewport().add(messageList, null);
    messageList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    this.getContentPane().add(splitPane, BorderLayout.CENTER);
    splitPane.add(textScrollPane, JSplitPane.TOP);
    splitPane.add(controlPanel, JSplitPane.BOTTOM);
    textScrollPane.getViewport().add(sourceArea, null);

    controlPanel.add(
        fileLabel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.WEST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 0, 0),
            0,
            0));
    controlPanel.add(
        fileText,
        new GridBagConstraints(
            1,
            0,
            3,
            1,
            1.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 0, 0),
            0,
            0));
    controlPanel.add(
        browseButton,
        new GridBagConstraints(
            4,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 0, 5),
            0,
            0));
    controlPanel.add(
        optionsButton,
        new GridBagConstraints(
            2,
            1,
            1,
            1,
            1.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 0, 0),
            0,
            0));
    controlPanel.add(
        assembleButton,
        new GridBagConstraints(
            3,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(5, 5, 0, 0),
            0,
            0));
    controlPanel.add(
        saveButton,
        new GridBagConstraints(
            4,
            1,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL,
            new Insets(5, 5, 0, 5),
            0,
            0));
    controlPanel.add(
        positionPanel,
        new GridBagConstraints(
            0,
            1,
            2,
            1,
            0.0,
            0.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.NONE,
            new Insets(5, 5, 0, 0),
            0,
            0));
    positionPanel.add(
        lineLabel,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 0, 0, 0),
            0,
            0));
    positionPanel.add(
        lineText,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 5, 0, 0),
            0,
            0));
    positionPanel.add(
        columnLabel,
        new GridBagConstraints(
            2,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 10, 0, 0),
            0,
            0));
    positionPanel.add(
        columnText,
        new GridBagConstraints(
            3,
            0,
            1,
            1,
            0.0,
            0.0,
            GridBagConstraints.EAST,
            GridBagConstraints.NONE,
            new Insets(0, 5, 0, 0),
            0,
            0));
    controlPanel.add(
        messageScrollPane,
        new GridBagConstraints(
            0,
            2,
            5,
            1,
            1.0,
            1.0,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            new Insets(5, 5, 5, 5),
            0,
            0));
  }
Exemplo n.º 10
0
  private void init() {
    input = new JTextField[nInputs];

    double[] rowWeights =
        new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
    rowWeights[nInputs + 2] = 1.0;

    GridBagLayout gbl_functionPanel = new GridBagLayout();
    gbl_functionPanel.columnWidths = new int[] {5, 0, 50, 50, 30, 25, 5, 0};
    gbl_functionPanel.rowHeights = new int[] {10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10};
    gbl_functionPanel.columnWeights =
        new double[] {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
    gbl_functionPanel.rowWeights = rowWeights;
    this.setLayout(gbl_functionPanel);

    // Function input field.
    for (int i = 0; i < nInputs; i++) {
      // Creation.
      input[i] = new JTextField();
      GridBagConstraints gbc_stdFuncInput = new GridBagConstraints();
      gbc_stdFuncInput.gridwidth = 4;
      gbc_stdFuncInput.insets = new Insets(0, 0, 5, 5);
      gbc_stdFuncInput.fill = GridBagConstraints.HORIZONTAL;
      gbc_stdFuncInput.anchor = GridBagConstraints.NORTH;
      gbc_stdFuncInput.gridx = 2;
      gbc_stdFuncInput.gridy = i + 1;

      // Setup.
      GuiUtil.setupUndoListener(input[i]);
      setupInputListeners(input[i]);
      this.add(input[i], gbc_stdFuncInput);
    }

    // Labels for the input fields
    String[] labelNames = labelNames();
    for (int i = 0; i < labelNames.length; i++) {
      GridBagConstraints gbc_FuncLabel = new GridBagConstraints();
      gbc_FuncLabel.gridwidth = 1;
      gbc_FuncLabel.insets = new Insets(0, 0, 5, 5);
      gbc_FuncLabel.fill = GridBagConstraints.HORIZONTAL;
      gbc_FuncLabel.anchor = GridBagConstraints.CENTER;
      gbc_FuncLabel.gridx = 1;
      gbc_FuncLabel.gridy = i + 1;

      JLabel label = new JLabel(labelNames[i]);
      this.add(label, gbc_FuncLabel);
    }

    // OptionPanel.
    mainOP = new JPanel();
    mainOP.setBorder(BorderFactory.createEtchedBorder());
    GridBagConstraints gbc_mainOP = new GridBagConstraints();
    gbc_mainOP.fill = GridBagConstraints.BOTH;
    gbc_mainOP.gridwidth = 5;
    gbc_mainOP.insets = new Insets(0, 0, 5, 5);
    gbc_mainOP.gridx = 1;
    gbc_mainOP.gridy = nInputs + 1;
    this.add(mainOP, gbc_mainOP);

    gridOP = getGridOptionPanel();
    gridOP.addFunctionListener(createGridOptionPanelListener());
    apperanceOP = new AppearanceOptionPanel(colorList, map);
    mainOP.setLayout(new BoxLayout(mainOP, BoxLayout.Y_AXIS));
    mainOP.add((Component) gridOP);
    mainOP.add(apperanceOP);

    // The standard function list
    outerFuncTab = new JPanel();
    funcPanelWrapper = new JScrollPane(outerFuncTab);
    funcPanelWrapper.setBorder(BorderFactory.createEtchedBorder());
    funcPanelWrapper.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    funcPanelWrapper.setMinimumSize(new Dimension(310, 500));
    GridBagConstraints gbc_funcPanelWrapper = new GridBagConstraints();
    gbc_funcPanelWrapper.fill = GridBagConstraints.BOTH;
    gbc_funcPanelWrapper.gridwidth = 5;
    gbc_funcPanelWrapper.insets = new Insets(0, 0, 5, 5);
    gbc_funcPanelWrapper.gridx = 1;
    gbc_funcPanelWrapper.gridy = nInputs + 2;
    ;
    this.add(funcPanelWrapper, gbc_funcPanelWrapper);

    GridBagLayout gbl_stdFuncPanel = new GridBagLayout();
    gbl_stdFuncPanel.columnWidths = new int[] {0, 0};
    gbl_stdFuncPanel.rowHeights = new int[] {0, 0};
    gbl_stdFuncPanel.columnWeights = new double[] {1.0, Double.MIN_VALUE};
    gbl_stdFuncPanel.rowWeights = new double[] {1.0, Double.MIN_VALUE};
    outerFuncTab.setLayout(gbl_stdFuncPanel);

    innerFuncTab = new JPanel();
    GridBagConstraints gbc_innerFuncPanel = new GridBagConstraints();
    gbc_innerFuncPanel.anchor = GridBagConstraints.NORTH;
    gbc_innerFuncPanel.fill = GridBagConstraints.HORIZONTAL;
    gbc_innerFuncPanel.gridx = 0;
    gbc_innerFuncPanel.gridy = 0;
    outerFuncTab.add(innerFuncTab, gbc_innerFuncPanel);
    innerFuncTab.setLayout(new BoxLayout(innerFuncTab, BoxLayout.Y_AXIS));
  }
Exemplo n.º 11
0
  /**
   * Customization of external program paths.
   *
   * @param prefs a <code>JabRefPreferences</code> value
   */
  public TableColumnsTab(JabRefPreferences prefs, JabRefFrame frame) {
    _prefs = prefs;
    this.frame = frame;
    setLayout(new BorderLayout());

    TableModel tm =
        new AbstractTableModel() {
          public int getRowCount() {
            return rowCount;
          }

          public int getColumnCount() {
            return 2;
          }

          public Object getValueAt(int row, int column) {
            if (row == 0) return (column == 0 ? GUIGlobals.NUMBER_COL : "" + ncWidth);
            row--;
            if (row >= tableRows.size()) return "";
            Object rowContent = tableRows.elementAt(row);
            if (rowContent == null) return "";
            TableRow tr = (TableRow) rowContent;
            switch (column) {
              case 0:
                return tr.name;
              case 1:
                return ((tr.length > 0) ? Integer.toString(tr.length) : "");
            }
            return null; // Unreachable.
          }

          public String getColumnName(int col) {
            return (col == 0 ? Globals.lang("Field name") : Globals.lang("Column width"));
          }

          public Class<?> getColumnClass(int column) {
            if (column == 0) return String.class;
            else return Integer.class;
          }

          public boolean isCellEditable(int row, int col) {
            return !((row == 0) && (col == 0));
          }

          public void setValueAt(Object value, int row, int col) {
            tableChanged = true;
            // Make sure the vector is long enough.
            while (row >= tableRows.size()) tableRows.add(new TableRow("", -1));

            if ((row == 0) && (col == 1)) {
              ncWidth = Integer.parseInt(value.toString());
              return;
            }

            TableRow rowContent = tableRows.elementAt(row - 1);

            if (col == 0) {
              rowContent.name = value.toString();
              if (((String) getValueAt(row, 1)).equals(""))
                setValueAt("" + GUIGlobals.DEFAULT_FIELD_LENGTH, row, 1);
            } else {
              if (value == null) rowContent.length = -1;
              else rowContent.length = Integer.parseInt(value.toString());
            }
          }
        };

    colSetup = new JTable(tm);
    TableColumnModel cm = colSetup.getColumnModel();
    cm.getColumn(0).setPreferredWidth(140);
    cm.getColumn(1).setPreferredWidth(80);

    FormLayout layout =
        new FormLayout(
            "1dlu, 8dlu, left:pref, 4dlu, fill:pref", // , 4dlu, fill:60dlu, 4dlu, fill:pref",
            "");
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    JPanel pan = new JPanel();
    JPanel tabPanel = new JPanel();
    tabPanel.setLayout(new BorderLayout());
    JScrollPane sp =
        new JScrollPane(
            colSetup,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    colSetup.setPreferredScrollableViewportSize(new Dimension(250, 200));
    sp.setMinimumSize(new Dimension(250, 300));
    tabPanel.add(sp, BorderLayout.CENTER);
    JToolBar tlb = new JToolBar(SwingConstants.VERTICAL);
    tlb.setFloatable(false);
    // tlb.setRollover(true);
    // tlb.setLayout(gbl);
    AddRowAction ara = new AddRowAction();
    DeleteRowAction dra = new DeleteRowAction();
    MoveRowUpAction moveUp = new MoveRowUpAction();
    MoveRowDownAction moveDown = new MoveRowDownAction();
    tlb.setBorder(null);
    tlb.add(ara);
    tlb.add(dra);
    tlb.addSeparator();
    tlb.add(moveUp);
    tlb.add(moveDown);
    // tlb.addSeparator();
    // tlb.add(new UpdateWidthsAction());
    tabPanel.add(tlb, BorderLayout.EAST);

    showOneLetterHeadingForIconColumns =
        new JCheckBox(Globals.lang("Show one letter heading for icon columns"));

    fileColumn = new JCheckBox(Globals.lang("Show file column"));
    pdfColumn = new JCheckBox(Globals.lang("Show PDF/PS column"));
    urlColumn = new JCheckBox(Globals.lang("Show URL/DOI column"));
    preferUrl = new JRadioButton(Globals.lang("Show URL first"));
    preferDoi = new JRadioButton(Globals.lang("Show DOI first"));
    preferUrlDoiGroup = new ButtonGroup();
    preferUrlDoiGroup.add(preferUrl);
    preferUrlDoiGroup.add(preferDoi);

    urlColumn.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent arg0) {
            preferUrl.setEnabled(urlColumn.isSelected());
            preferDoi.setEnabled(urlColumn.isSelected());
          }
        });
    arxivColumn = new JCheckBox(Globals.lang("Show ArXiv column"));

    /** * begin: special table columns and special fields ** */
    HelpAction help = new HelpAction(frame.helpDiag, GUIGlobals.specialFieldsHelp);
    hlb = new JButton(GUIGlobals.getImage("helpSmall"));
    hlb.setToolTipText(Globals.lang("Help on special fields"));
    hlb.addActionListener(help);

    specialFieldsEnabled = new JCheckBox(Globals.lang("Enable special fields"));
    //		.concat(". ").concat(Globals.lang("You must restart JabRef for this to come into
    // effect.")));
    specialFieldsEnabled.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent event) {
            boolean isEnabled = specialFieldsEnabled.isSelected();
            rankingColumn.setEnabled(isEnabled);
            compactRankingColumn.setEnabled(isEnabled ? rankingColumn.isSelected() : false);
            qualityColumn.setEnabled(isEnabled);
            priorityColumn.setEnabled(isEnabled);
            relevanceColumn.setEnabled(isEnabled);
            syncKeywords.setEnabled(isEnabled);
            writeSpecialFields.setEnabled(isEnabled);
          }
        });
    rankingColumn = new JCheckBox(Globals.lang("Show rank"));
    rankingColumn.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent event) {
            compactRankingColumn.setEnabled(rankingColumn.isSelected());
          }
        });
    compactRankingColumn = new JCheckBox(Globals.lang("Compact rank"));
    qualityColumn = new JCheckBox(Globals.lang("Show quality"));
    priorityColumn = new JCheckBox(Globals.lang("Show priority"));
    relevanceColumn = new JCheckBox(Globals.lang("Show relevance"));

    // "sync keywords" and "write special" fields may be configured mutually exclusive only
    // The implementation supports all combinations (TRUE+TRUE and FALSE+FALSE, even if the latter
    // does not make sense)
    // To avoid confusion, we opted to make the setting mutually exclusive
    syncKeywords = new JRadioButton(Globals.lang("Synchronize with keywords"));
    writeSpecialFields =
        new JRadioButton(
            Globals.lang("Write values of special fields as separate fields to BibTeX"));
    ButtonGroup group = new ButtonGroup();
    group.add(syncKeywords);
    group.add(writeSpecialFields);

    builder.appendSeparator(Globals.lang("Special table columns"));
    builder.nextLine();
    builder.append(pan);

    DefaultFormBuilder specialTableColumnsBuilder =
        new DefaultFormBuilder(
            new FormLayout(
                "8dlu, 8dlu, 8cm, 8dlu, 8dlu, left:pref:grow",
                "pref, pref, pref, pref, pref, pref, pref, pref, pref, pref"));
    CellConstraints cc = new CellConstraints();

    specialTableColumnsBuilder.add(specialFieldsEnabled, cc.xyw(1, 1, 3));
    specialTableColumnsBuilder.add(rankingColumn, cc.xyw(2, 2, 2));
    specialTableColumnsBuilder.add(compactRankingColumn, cc.xy(3, 3));
    specialTableColumnsBuilder.add(relevanceColumn, cc.xyw(2, 4, 2));
    specialTableColumnsBuilder.add(qualityColumn, cc.xyw(2, 5, 2));
    specialTableColumnsBuilder.add(priorityColumn, cc.xyw(2, 6, 2));
    specialTableColumnsBuilder.add(syncKeywords, cc.xyw(2, 7, 2));
    specialTableColumnsBuilder.add(writeSpecialFields, cc.xyw(2, 8, 2));
    specialTableColumnsBuilder.add(showOneLetterHeadingForIconColumns, cc.xyw(1, 9, 5));
    specialTableColumnsBuilder.add(hlb, cc.xyw(1, 10, 2));

    specialTableColumnsBuilder.add(fileColumn, cc.xyw(5, 1, 2));
    specialTableColumnsBuilder.add(pdfColumn, cc.xyw(5, 2, 2));
    specialTableColumnsBuilder.add(urlColumn, cc.xyw(5, 3, 2));
    specialTableColumnsBuilder.add(preferUrl, cc.xy(6, 4));
    specialTableColumnsBuilder.add(preferDoi, cc.xy(6, 5));
    specialTableColumnsBuilder.add(arxivColumn, cc.xyw(5, 6, 2));

    builder.append(specialTableColumnsBuilder.getPanel());
    builder.nextLine();

    /** * end: special table columns and special fields ** */
    builder.appendSeparator(Globals.lang("Entry table columns"));
    builder.nextLine();
    builder.append(pan);
    builder.append(tabPanel);
    builder.nextLine();
    //	lab = new JLabel("<HTML>("+Globals.lang("this button will update the column width
    // settings<BR>"
    //						+"to match the current widths in your table")+")</HTML>");
    //        lab = new JLabel("<HTML>("+Globals.lang("this_button_will_update") +")</HTML>") ;
    builder.append(pan);
    JButton buttonWidth = new JButton(new UpdateWidthsAction());
    JButton buttonOrder = new JButton(new UpdateOrderAction());
    builder.append(buttonWidth);
    builder.nextLine();
    builder.append(pan);
    builder.append(buttonOrder);
    builder.nextLine();
    builder.append(pan);
    // builder.append(lab);
    builder.nextLine();
    pan = builder.getPanel();
    pan.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    add(pan, BorderLayout.CENTER);
  }