Example usage for javax.swing JScrollPane setPreferredSize

List of usage examples for javax.swing JScrollPane setPreferredSize

Introduction

In this page you can find the example usage for javax.swing JScrollPane setPreferredSize.

Prototype

@BeanProperty(preferred = true, description = "The preferred size of the component.")
public void setPreferredSize(Dimension preferredSize) 

Source Link

Document

Sets the preferred size of this component.

Usage

From source file:pl.otros.logview.filter.MultipleSelectionFilter.java

public MultipleSelectionFilter(String name, String desc, String label, char mnemonic) {
    super(name, desc);
    this.name = name;
    this.desc = desc;
    this.label = label;
    this.mnemonic = mnemonic;
    selectedItems = new HashSet<>();
    listModel = new DefaultListModel<>();
    jList = new JList<>(listModel);
    jList.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    jList.addListSelectionListener(e -> {
        if (!e.getValueIsAdjusting()) {
            selectedItems.clear();//  w  w w.ja v  a2s  .co m
            Object[] selectedValues = jList.getSelectedValues();
            for (Object selectedValue : selectedValues) {
                selectedItems.add((String) selectedValue);
            }
            listener.valueChanged();
        }
    });
    JLabel jLabel = new JLabel(label);
    jLabel.setLabelFor(jList);
    jLabel.setDisplayedMnemonic(mnemonic);
    panel = new JPanel(new MigLayout());
    panel.add(jLabel, "wrap");
    jList.setVisibleRowCount(5);
    JScrollPane jScrollPane = new JScrollPane(jList);
    jScrollPane.setPreferredSize(new Dimension(100, 100));
    jScrollPane.setMinimumSize(new Dimension(100, 100));
    panel.add(new JScrollPane(jList), "wrap, right, growx");
    panel.add(new JLabel("Use CTRL for multi selection"), "wrap");
    panel.add(new JXHyperlink(new AbstractAction("Invert selection") {
        @Override
        public void actionPerformed(ActionEvent e) {
            invertSelection();
        }
    }), "wrap");
    panel.add(new JXHyperlink(new AbstractAction("Clear selection") {
        @Override
        public void actionPerformed(ActionEvent e) {
            clearSelection();
        }
    }), "wrap");
    panel.add(new JXHyperlink(new AbstractAction("Reload threads") {
        @Override
        public void actionPerformed(ActionEvent e) {
            reloadFilterSet();
        }
    }), "wrap");
}

From source file:psidev.psi.mi.filemakers.xmlMaker.gui.XsdTreePanelImpl.java

/**
 * create a new instance of XslTree The nodes will be automaticaly
 * duplicated if the schema specify that more than one element of this type
 * are mandatory/*from  w w w  .  j  av  a 2s  . co  m*/
 */
public XsdTreePanelImpl(XsdTreeStructImpl xsdTree, JTextPane messagePane) {
    super(xsdTree);

    messagePane.setEditable(false);

    JScrollPane scrollpane = new JScrollPane(messagePane);
    scrollpane.setMaximumSize(new Dimension(Short.MAX_VALUE, 150));
    scrollpane.setMinimumSize(new Dimension(200, 150));
    scrollpane.setPreferredSize(new Dimension(200, 150));
    scrollpane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scrollpane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    scrollpane.setBorder(new TitledBorder("Messages"));

    add(scrollpane, BorderLayout.SOUTH);
    add(getButtonPanel(), BorderLayout.EAST);
    MouseListener mouseListener = new TreeMouseAdapter();
    xsdTree.tree.addMouseListener(mouseListener);
}

From source file:ro.nextreports.designer.querybuilder.QueryBuilderPanel.java

private void initUI() {
    JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    split.setDividerLocation(250);/*from   ww  w . jav  a  2  s  .  com*/
    split.setOneTouchExpandable(true);

    JToolBar toolBar = new JToolBar();
    toolBar.putClientProperty("JToolBar.isRollover", Boolean.TRUE); // hide buttons borders
    toolBar.putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH);
    toolBar.setBorderPainted(false);

    // add refresh action
    toolBar.add(new AbstractAction() {

        public Object getValue(String key) {
            if (AbstractAction.SMALL_ICON.equals(key)) {
                return ImageUtil.getImageIcon("refresh");
            } else if (AbstractAction.SHORT_DESCRIPTION.equals(key)) {
                return I18NSupport.getString("querybuilder.refresh");
            }

            return super.getValue(key);
        }

        public void actionPerformed(ActionEvent e) {
            try {
                if (Globals.getConnection() == null) {
                    return;
                }

                // refresh tables, views, procedures
                TreeUtil.refreshDatabase();

                // add new queries to tree
                TreeUtil.refreshQueries();

                // add new reports to tree
                TreeUtil.refreshReports();

                // add new charts to tree
                TreeUtil.refreshCharts();

            } catch (Exception ex) {
                Show.error(ex);
            }
        }

    });

    // add expand action
    toolBar.add(new AbstractAction() {

        public Object getValue(String key) {
            if (AbstractAction.SMALL_ICON.equals(key)) {
                return ImageUtil.getImageIcon("expandall");
            } else if (AbstractAction.SHORT_DESCRIPTION.equals(key)) {
                return I18NSupport.getString("querybuilder.expand.all");
            }

            return super.getValue(key);
        }

        public void actionPerformed(ActionEvent e) {
            TreeUtil.expandAll(dbBrowserTree);
        }

    });

    // add collapse action
    toolBar.add(new AbstractAction() {

        public Object getValue(String key) {
            if (AbstractAction.SMALL_ICON.equals(key)) {
                return ImageUtil.getImageIcon("collapseall");
            } else if (AbstractAction.SHORT_DESCRIPTION.equals(key)) {
                return I18NSupport.getString("querybuilder.collapse.all");
            }

            return super.getValue(key);
        }

        public void actionPerformed(ActionEvent e) {
            TreeUtil.collapseAll(dbBrowserTree);
        }

    });

    // add properties button
    /*
      JButton propButton = new MagicButton(new AbstractAction() {
            
      public Object getValue(String key) {
          if (AbstractAction.SMALL_ICON.equals(key)) {
              return ImageUtil.getImageIcon("properties");
          }
            
          return super.getValue(key);
      }
            
      public void actionPerformed(ActionEvent e) {
          DBBrowserPropertiesPanel joinPanel = new DBBrowserPropertiesPanel();
          JDialog dlg = new DBBrowserPropertiesDialog(joinPanel);
          dlg.pack();
          dlg.setResizable(false);
          Show.centrateComponent(Globals.getMainFrame(), dlg);
          dlg.setVisible(true);
      }
            
      });
      propButton.setToolTipText(I18NSupport.getString("querybuilder.properties"));
      */
    //browserButtonsPanel.add(propButton);

    //        ro.nextreports.designer.util.SwingUtil.registerButtonsForFocus(browserButtonsPanel);

    browserPanel = new JXPanel(new BorderLayout());
    browserPanel.add(toolBar, BorderLayout.NORTH);

    // browser tree
    JScrollPane scroll = new JScrollPane(dbBrowserTree);
    browserPanel.add(scroll, BorderLayout.CENTER);
    split.setLeftComponent(browserPanel);

    tabbedPane = new JTabbedPane(JTabbedPane.BOTTOM);
    //        tabbedPane.putClientProperty(Options.EMBEDDED_TABS_KEY, Boolean.TRUE); // look like eclipse

    JSplitPane split2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    split2.setResizeWeight(0.66);
    split2.setOneTouchExpandable(true);

    // desktop pane
    desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
    desktop.setDropTarget(
            new DropTarget(desktop, DnDConstants.ACTION_MOVE, new DesktopPaneDropTargetListener(), true));

    // create the toolbar
    JToolBar toolBar2 = new JToolBar();
    toolBar2.putClientProperty("JToolBar.isRollover", Boolean.TRUE); // hide buttons borders
    toolBar2.putClientProperty(Options.HEADER_STYLE_KEY, HeaderStyle.BOTH);
    toolBar2.setBorderPainted(false);

    Action distinctAction = new AbstractAction() {

        public void actionPerformed(ActionEvent e) {
            if (distinctButton.isSelected()) {
                selectQuery.setDistinct(true);
            } else {
                selectQuery.setDistinct(false);
            }
        }

    };
    distinctAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("query.distinct"));
    distinctAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("querybuilder.distinct"));
    toolBar2.add(distinctButton = new JToggleButton(distinctAction));

    Action groupByAction = new AbstractAction() {

        public void actionPerformed(ActionEvent e) {
            groupBy = groupByButton.isSelected();
            Globals.getEventBus().publish(new GroupByEvent(QueryBuilderPanel.this.desktop, groupBy));
        }

    };
    groupByAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("query.group_by"));
    groupByAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("querybuilder.group.by"));
    toolBar2.add(groupByButton = new JToggleButton(groupByAction));

    Action clearAction = new AbstractAction() {

        public void actionPerformed(ActionEvent e) {
            clear(false);
        }

    };
    clearAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("clear"));
    clearAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("querybuilder.clear"));
    toolBar2.add(clearAction);

    // add separator
    SwingUtil.addCustomSeparator(toolBar2);

    // add run button
    Action runQueryAction = new AbstractAction() {

        public void actionPerformed(ActionEvent e) {
            selectSQLViewTab();
            sqlView.doRun();
        }

    };
    runQueryAction.putValue(Action.SMALL_ICON, ImageUtil.getImageIcon("run"));
    KeyStroke ks = KeyStroke.getKeyStroke(ShortcutsUtil.getShortcut("query.run.accelerator", "control 4"));
    runQueryAction.putValue(Action.SHORT_DESCRIPTION, I18NSupport.getString("run.query") + " ("
            + ShortcutsUtil.getShortcut("query.run.accelerator.display", "Ctrl 4") + ")");
    runQueryAction.putValue(Action.ACCELERATOR_KEY, ks);
    toolBar2.add(runQueryAction);
    // register run query shortcut
    GlobalHotkeyManager hotkeyManager = GlobalHotkeyManager.getInstance();
    InputMap inputMap = hotkeyManager.getInputMap();
    ActionMap actionMap = hotkeyManager.getActionMap();
    inputMap.put((KeyStroke) runQueryAction.getValue(Action.ACCELERATOR_KEY), "runQueryAction");
    actionMap.put("runQueryAction", runQueryAction);

    JScrollPane scroll2 = new JScrollPane(desktop, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scroll2.setPreferredSize(DBTablesDesktopPane.PREFFERED_SIZE);
    DecoratedScrollPane.decorate(scroll2);

    JPanel topPanel = new JPanel();
    topPanel.setLayout(new GridBagLayout());
    topPanel.add(toolBar2, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    topPanel.add(scroll2, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));

    split2.setTopComponent(topPanel);
    designPanel = new DesignerTablePanel(selectQuery);
    split2.setBottomComponent(designPanel);
    split2.setDividerLocation(400);

    tabbedPane.addTab(I18NSupport.getString("querybuilder.query.designer"), ImageUtil.getImageIcon("designer"),
            split2);
    tabbedPane.setMnemonicAt(0, 'D');

    sqlView = new SQLViewPanel();
    sqlView.getEditorPane().setDropTarget(new DropTarget(sqlView.getEditorPane(), DnDConstants.ACTION_MOVE,
            new SQLViewDropTargetListener(), true));
    tabbedPane.addTab(I18NSupport.getString("querybuilder.query.editor"), ImageUtil.getImageIcon("sql"),
            sqlView);
    tabbedPane.setMnemonicAt(1, 'E');

    split.setRightComponent(tabbedPane);

    // register a change listener
    tabbedPane.addChangeListener(new ChangeListener() {

        // this method is called whenever the selected tab changes
        public void stateChanged(ChangeEvent ev) {
            if (ev.getSource() == QueryBuilderPanel.this.tabbedPane) {
                // get current tab
                int sel = QueryBuilderPanel.this.tabbedPane.getSelectedIndex();
                if (sel == 1) { // sql view
                    String query;
                    if (!synchronizedPanels) {
                        query = sqlView.getQueryString();
                        synchronizedPanels = true;
                    } else {
                        if (Globals.getConnection() != null) {
                            query = getSelectQuery().toString();
                        } else {
                            query = "";
                        }
                        //                     if (query.equals("")) {
                        //                        query = sqlView.getQueryString();
                        //                     }
                    }
                    if (resetTable) {
                        sqlView.clear();
                        resetTable = false;
                    }
                    //System.out.println("query="+query);
                    sqlView.setQueryString(query);
                } else if (sel == 0) { // design view
                    if (queryWasModified(false)) {
                        Object[] options = { I18NSupport.getString("optionpanel.yes"),
                                I18NSupport.getString("optionpanel.no") };
                        String m1 = I18NSupport.getString("querybuilder.lost");
                        String m2 = I18NSupport.getString("querybuilder.continue");
                        int option = JOptionPane.showOptionDialog(Globals.getMainFrame(),
                                "<HTML>" + m1 + "<BR>" + m2 + "</HTML>",
                                I18NSupport.getString("querybuilder.confirm"), JOptionPane.YES_NO_OPTION,
                                JOptionPane.QUESTION_MESSAGE, null, options, options[1]);

                        if (option != JOptionPane.YES_OPTION) {
                            synchronizedPanels = false;
                            tabbedPane.setSelectedIndex(1);
                        } else {
                            resetTable = true;
                        }
                    }
                } else if (sel == 2) { // report view

                }
            }
        }

    });

    //        this.add(split, BorderLayout.CENTER);

    parametersPanel = new ParametersPanel();
}

From source file:ro.nextreports.designer.querybuilder.RuntimeParametersPanel.java

private void initUI() {
    setLayout(new GridBagLayout());

    JPanel panel = new JPanel();
    panel.setLayout(new GridBagLayout());
    components = new ArrayList<JComponent>();
    checks = new ArrayList<JCheckBox>();

    int size = paramList.size();
    boolean shouldExpand = false;
    boolean needScroll = false;
    for (int i = 0; i < size; i++) {
        final int pos = i;
        final QueryParameter param = paramList.get(i);
        if (param.isHidden()) {
            components.add(null);/*from ww  w  . j  av a  2 s . co m*/
            checks.add(null);
            initHiddenParameterValues(param);
            continue;
        }
        String source = param.getSource();
        String defaultSource = param.getDefaultSource();

        if ((defaultSource != null) && !defaultSource.trim().equals("")) {
            try {
                param.setDefaultSourceValues(Globals.getDBViewer().getDefaultSourceValues(con, param));
            } catch (NextSqlException e) {
                Show.error(e);
            }
        }

        final JComponent component;
        int anchor = GridBagConstraints.WEST;
        double y = 0.0;
        int expand = GridBagConstraints.HORIZONTAL;
        if ((source != null) && !source.equals("")) {
            List<IdName> values = new ArrayList<IdName>();
            try {
                if (param.isManualSource()) {
                    if (!param.isDependent()) {
                        values = Globals.getDBViewer().getValues(con, source, true, param.getOrderBy());
                    }
                } else {
                    int index = source.indexOf(".");
                    int index2 = source.lastIndexOf(".");
                    String tableName = source.substring(0, index);
                    String columnName;
                    String shownColumnName = null;
                    if (index == index2) {
                        columnName = source.substring(index + 1);
                    } else {
                        columnName = source.substring(index + 1, index2);
                        shownColumnName = source.substring(index2 + 1);
                    }
                    values = Globals.getDBViewer().getColumnValues(con, param.getSchema(), tableName,
                            columnName, shownColumnName, param.getOrderBy());
                }
            } catch (NextSqlException e) {
                error = true;
                Show.error(e);
            } catch (InvalidSqlException e) {
                String m = I18NSupport.getString("source.dialog.valid");
                Show.info(m + " : \"select <exp1> , <exp2> from ...\"");
            }
            if (param.getSelection().equals(ParameterEditPanel.SINGLE_SELECTION)) {
                component = new JComboBox();
                final JComboBox combo = (JComboBox) component;
                combo.setRenderer(new IdNameRenderer());
                combo.addItem("-- " + I18NSupport.getString("parameter.value.select") + " --");
                for (int j = 0, len = values.size(); j < len; j++) {
                    combo.addItem(values.get(j));
                }

                combo.addItemListener(new ItemListener() {
                    public void itemStateChanged(ItemEvent e) {
                        if (e.getStateChange() == ItemEvent.SELECTED) {
                            IdName in = null;
                            if (combo.getSelectedIndex() > 0) {
                                in = (IdName) combo.getSelectedItem();
                            }
                            parameterSelection(pos, in);
                        }
                    }
                });
                AutoCompleteDecorator.decorate(combo);
                needScroll = false;
            } else {
                anchor = GridBagConstraints.NORTHWEST;
                y = 1.0;
                expand = GridBagConstraints.BOTH;

                DefaultListModel model = new DefaultListModel();
                for (int j = 0, len = values.size(); j < len; j++) {
                    model.addElement(values.get(j));
                }
                List srcList = Arrays.asList(model.toArray());
                component = new ListSelectionPanel(srcList, new ArrayList(), "", "", true, false) {
                    protected void onAdd() {
                        selection();
                    }

                    protected void onRemove() {
                        selection();
                    }

                    // needed for saved parameters on rerun
                    protected void onSetRight() {
                        selection();
                    }

                    private void selection() {
                        if (ParameterManager.getInstance().getChildDependentParameters(param).size() > 0) {
                            Object[] values = getDestinationElements().toArray();
                            if (values.length == 0) {
                                values = new Object[] { ParameterUtil.NULL };
                            }
                            parameterSelection(pos, values);
                        }
                    }
                };
                ((ListSelectionPanel) component).setListSize(scrListDim);
                ((ListSelectionPanel) component).setRenderer(new IdNameRenderer(),
                        new IdNameComparator(param.getOrderBy()));

                shouldExpand = true;
            }

        } else {
            if (param.getSelection().equals(QueryParameter.MULTIPLE_SELECTION)) {
                anchor = GridBagConstraints.NORTHWEST;
                y = 1.0;
                expand = GridBagConstraints.BOTH;
                ;
                component = new ListAddPanel(param) {
                    protected void onAdd() {
                        selection();
                    }

                    protected void onRemove() {
                        selection();
                    }

                    private void selection() {
                        if (ParameterManager.getInstance().getChildDependentParameters(param).size() > 0) {
                            Object[] values = getElements().toArray();
                            parameterSelection(pos, values);
                        }
                    }
                };
            } else {
                needScroll = false;
                if (param.getValueClassName().equals("java.util.Date")) {
                    component = new JXDatePicker();
                    ((JXDatePicker) component).addPropertyChangeListener(new PropertyChangeListener() {
                        public void propertyChange(PropertyChangeEvent e) {
                            if ("date".equals(e.getPropertyName())) {
                                parameterSelection(pos, ((JXDatePicker) component).getDate());
                            }
                        }
                    });
                    // hack to fix bug with big popup button
                    JButton popupButton = (JButton) component.getComponent(1);
                    //popupButton.setMargin(new Insets(2, 2, 2, 2));
                    popupButton.setMinimumSize(new Dimension(20, (int) getPreferredSize().getHeight()));
                    popupButton.setPreferredSize(new Dimension(20, (int) getPreferredSize().getHeight()));
                    popupButton.setBorder(BorderFactory.createLineBorder(Color.GRAY));
                } else if (param.getValueClassName().equals("java.sql.Timestamp")
                        || param.getValueClassName().equals("java.sql.Time")) {
                    component = new JDateTimePicker() {
                        protected void onChange() {
                            parameterSelection(pos, getDate());
                        }
                    };
                    // hack to fix bug with big popup button
                    JButton popupButton = (JButton) (((JDateTimePicker) component).getDatePicker())
                            .getComponent(1);
                    //popupButton.setMargin(new Insets(2, 2, 2, 2));
                    popupButton.setMinimumSize(new Dimension(20, (int) getPreferredSize().getHeight()));
                    popupButton.setPreferredSize(new Dimension(20, (int) getPreferredSize().getHeight()));
                    popupButton.setBorder(BorderFactory.createLineBorder(Color.GRAY));
                } else if (param.getValueClassName().equals("java.lang.Boolean")) {
                    component = new JCheckBox();
                    ((JCheckBox) component).addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent actionEvent) {
                            AbstractButton abstractButton = (AbstractButton) actionEvent.getSource();
                            boolean selected = abstractButton.getModel().isSelected();
                            parameterSelection(pos, selected);
                        }
                    });
                } else {
                    component = new JTextField(25);
                    ((JTextField) component).getDocument().addDocumentListener(new DocumentListener() {

                        @Override
                        public void changedUpdate(DocumentEvent e) {
                            updateFromTextField(e);
                        }

                        @Override
                        public void insertUpdate(DocumentEvent e) {
                            updateFromTextField(e);
                        }

                        @Override
                        public void removeUpdate(DocumentEvent e) {
                            updateFromTextField(e);
                        }

                        private void updateFromTextField(DocumentEvent e) {
                            java.awt.EventQueue.invokeLater(new Runnable() {

                                @Override
                                public void run() {
                                    Object value = null;
                                    try {
                                        if ("".equals(((JTextField) component).getText().trim())) {
                                            value = null;
                                        } else {
                                            value = ParameterUtil.getParameterValueFromString(
                                                    param.getValueClassName(),
                                                    ((JTextField) component).getText());
                                        }
                                        parameterSelection(pos, value);
                                    } catch (Exception e) {
                                        e.printStackTrace();
                                        LOG.error(e.getMessage(), e);
                                    }
                                }
                            });
                        }
                    });
                }
            }
        }
        components.add(component);
        final JCheckBox cb = new JCheckBox(I18NSupport.getString("run.parameter.ignore"));
        checks.add(cb);

        final JLabel label = new JLabel(getRuntimeParameterName(param));
        panel.add(label, new GridBagConstraints(0, i, 1, 1, 0.0, 0.0, anchor, GridBagConstraints.NONE,
                new Insets(5, 5, 5, 5), 0, 0));
        final JComponent addComponent;
        if (needScroll) {
            JScrollPane scr = new JScrollPane(component, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
                    JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
            scr.setPreferredSize(listDim);
            addComponent = scr;
        } else {
            addComponent = component;
        }
        panel.add(addComponent, new GridBagConstraints(1, i, 1, 1, 1.0, y, GridBagConstraints.WEST, expand,
                new Insets(5, 0, 5, 5), 0, 0));
        int checkAnchor = GridBagConstraints.WEST;
        if ((addComponent instanceof JScrollPane) || (addComponent instanceof ListSelectionPanel)) {
            checkAnchor = GridBagConstraints.NORTHWEST;
        }

        if (Globals.getParametersIgnore()) {
            panel.add(cb, new GridBagConstraints(2, i, 1, 1, 0.0, 0.0, checkAnchor, GridBagConstraints.NONE,
                    new Insets(5, 0, 5, 5), 0, 0));
        }

        cb.addChangeListener(new ChangeListener() {
            public void stateChanged(ChangeEvent e) {
                if (cb.isSelected()) {
                    if (addComponent instanceof JScrollPane) {
                        component.setEnabled(false);
                    }
                    label.setEnabled(false);
                    addComponent.setEnabled(false);
                    param.setIgnore(true);
                } else {
                    if (addComponent instanceof JScrollPane) {
                        component.setEnabled(true);
                    }
                    label.setEnabled(true);
                    addComponent.setEnabled(true);
                    param.setIgnore(false);
                }
            }
        });
    }

    // populate hidden dependent parameters (this will be done if a parameter depends only on a single hidden parameter)
    // if a parameter depends on a hidden parameter and other parameters, it cannot be populated here
    for (int i = 0; i < size; i++) {
        final QueryParameter param = paramList.get(i);
        if (param.isHidden()) {
            populateDependentParameters(param, false);
        }
    }

    if (!shouldExpand) {
        panel.add(new JLabel(), new GridBagConstraints(0, size, 3, 1, 1.0, 1.0, GridBagConstraints.WEST,
                GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    }

    JScrollPane scrPanel = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrPanel.setPreferredSize(scrDim);
    scrPanel.setMinimumSize(scrDim);

    add(scrPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 0), 0, 0));
    setParameterValues(parametersValues);
    setParameterIgnore(parametersIgnore);
}

From source file:ro.nextreports.designer.wizpublish.SelectEntityWizardPanel.java

private void add() {
    // ignore double click listener for tree (which opens the query)
    // and create our own listener (which just selects the path)
    final DBBrowserTree dbBrowserTree = new DBBrowserTree(type, false);
    dbBrowserTree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
    dbBrowserTree.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
            job(e, true);//www  . ja v a 2 s .  c o m
        }

        public void mouseReleased(MouseEvent e) {
            job(e, false);
        }

        private void job(MouseEvent e, boolean pressed) {
            TreePath[] paths = dbBrowserTree.getSelectionPaths();
            if (paths == null) {
                return;
            }
            dbBrowserTree.setSelectionPaths(paths);
        }
    });
    JScrollPane scroll = new JScrollPane(dbBrowserTree);
    scroll.setPreferredSize(scrTreeDim);

    JPanel panel = new JPanel();
    panel.add(scroll);

    JDialog dialog = new BaseDialog(panel, I18NSupport.getString("wizard.publish.entities.select"), true) {
        protected boolean ok() {
            TreePath[] paths = dbBrowserTree.getSelectionPaths();
            if (paths == null) {
                return false;
            }
            for (TreePath selPath : paths) {
                final DBBrowserNode selectedNode = (DBBrowserNode) selPath.getLastPathComponent();
                if (!selectedNode.getDBObject().isFolder()) {
                    String path = selectedNode.getDBObject().getAbsolutePath();
                    if (!listModel.contains(path)) {
                        // convert xml if needed before add to list
                        if (selectedNode.getDBObject().getType() == DBObject.REPORTS) {
                            byte result = ConverterUtil.convertIfNeeded(path);
                            if (result != ConverterUtil.TYPE_CONVERSION_EXCEPTION) {
                                listModel.addElement(path);
                            }
                        } else {
                            listModel.addElement(path);
                        }
                    }
                }
            }
            return true;
        }
    };
    dialog.setBackground(Color.WHITE);
    dialog.pack();
    Show.centrateComponent(Globals.getMainFrame(), dialog);
    dialog.setVisible(true);
}

From source file:savant.agp.HTTPBrowser.java

public HTTPBrowser(URL rootURL) throws IOException {
    host = rootURL.getHost();/*w  ww  . ja  v a 2 s  . c o  m*/
    int p = rootURL.getPort();
    port = p != -1 ? p : rootURL.getDefaultPort();
    rootDir = new File(rootURL.getPath());
    curDir = rootDir;

    setLayout(new BorderLayout());

    addressLabel = new JLabel();
    add(addressLabel, BorderLayout.NORTH);
    add(getToolBar(), BorderLayout.SOUTH);

    table = new JTable();

    updateDirectory();

    table.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent evt) {
            if (evt.getClickCount() == 2) {
                String f = ((HTTPTableModel) table.getModel()).getEntry(table.rowAtPoint(evt.getPoint()));

                if (f.equals("..")) {
                    // Going up a directory.
                    curDir = curDir.getParentFile();
                    updateDirectory();
                } else if (!f.contains(".")) {
                    if (f.startsWith("/")) {
                        curDir = new File(f);
                    } else {
                        curDir = new File(curDir, f);
                    }
                    updateDirectory();
                } else {
                    openIndexAs(table.rowAtPoint(evt.getPoint()), OpenAsOption.TRACK);
                }
            }
        }
    });

    JScrollPane scrollPane = new JScrollPane(table);
    scrollPane.getViewport().setBackground(Color.WHITE);
    scrollPane.setPreferredSize(new Dimension(800, 500));
    add(scrollPane, BorderLayout.CENTER);

    this.setPreferredSize(new Dimension(800, 500));
}

From source file:savant.plugin.Tool.java

@Override
public void init(JPanel panel) {
    mainPanel = panel;//from  w  w w.  j  a  va 2s .co m
    panel.setLayout(new CardLayout());

    JPanel settingsPanel = new ToolSettingsPanel(this);
    panel.add(new JScrollPane(settingsPanel), "Settings");

    JPanel waitCard = new JPanel();
    waitCard.setLayout(new GridBagLayout());

    // Left side filler.
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(5, 100, 0, 100);
    waitCard.add(new JLabel(getDescriptor().getName()), gbc);

    progressBar = new JProgressBar();
    progressBar.setPreferredSize(new Dimension(240, progressBar.getPreferredSize().height));
    waitCard.add(progressBar, gbc);

    progressInfo = new JLabel();
    progressInfo.setAlignmentX(1.0f);
    Font f = progressInfo.getFont();
    f = f.deriveFont(f.getSize() - 2.0f);
    progressInfo.setFont(f);
    waitCard.add(progressInfo, gbc);

    cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            if (toolProc != null) {
                Process p = toolProc;
                toolProc = null;
                p.destroy();
            }
            showCard("Settings");
        }
    });
    gbc.fill = GridBagConstraints.NONE;
    waitCard.add(cancelButton, gbc);

    // Console output at the bottom.
    console = new JTextArea();
    console.setFont(f);
    console.setLineWrap(false);
    console.setEditable(false);

    JScrollPane consolePane = new JScrollPane(console);
    consolePane.setPreferredSize(new Dimension(800, 200));
    gbc.weighty = 1.0;
    gbc.insets = new Insets(30, 5, 5, 5);
    gbc.fill = GridBagConstraints.BOTH;
    waitCard.add(consolePane, gbc);

    panel.add(waitCard, "Progress");
}

From source file:savant.thousandgenomes.FTPBrowser.java

public FTPBrowser(URL rootURL) throws IOException {
    setRoot(rootURL);/* w ww .j a v  a 2s . co m*/

    setLayout(new BorderLayout());

    addressField = new JTextField();
    addressField.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            try {
                setRoot(new URL(addressField.getText()));
                updateDirectory();
            } catch (Exception x) {
                DialogUtils.displayException("1000 Genomes Plugin", "Unable to change root directory", x);
            }
        }

    });
    add(addressField, BorderLayout.NORTH);

    table = new JTable();
    updateDirectory();

    table.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent evt) {
            if (evt.getClickCount() == 2) {
                int row = table.rowAtPoint(evt.getPoint());
                try {
                    FTPFile f = ((FTPTableModel) table.getModel()).getEntry(row);
                    if (f == null) {
                        // Going up a directory.
                        curDir = curDir.getParentFile();
                        updateDirectory();
                    } else if (f.isDirectory()) {
                        curDir = new File(curDir, f.getName());
                        updateDirectory();
                    } else {
                        TrackUtils.createTrack(new URI(
                                "ftp://" + host + new File(curDir, f.getName()).getPath().replace("\\", "/")));
                    }
                } catch (Throwable x) {
                    DialogUtils.displayException("FTP Error", "Unable to process FTP request.", x);
                }
            }
        }
    });

    JScrollPane scrollPane = new JScrollPane(table);
    scrollPane.getViewport().setBackground(Color.WHITE);
    scrollPane.setPreferredSize(new Dimension(800, 500));
    add(scrollPane, BorderLayout.CENTER);

    this.setPreferredSize(new Dimension(800, 500));
}

From source file:savant.util.swing.TrackChooser.java

private void initLayout() {

    this.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();

    //FILLER/*from w  w w  . j  a v  a 2s  .c  o m*/
    //LEFT LABEL
    JLabel leftLabel = new JLabel("All Tracks");
    leftLabel.setFont(new Font(null, Font.BOLD, 12));
    c.gridx = 0;
    c.gridy = 0;
    c.insets = new Insets(5, 5, 5, 5);
    add(leftLabel, c);

    // RIGHT LABEL
    JLabel rightLabel = new JLabel("Selected Tracks");
    rightLabel.setFont(new Font(null, Font.BOLD, 12));
    c.gridx = 2;
    c.gridwidth = GridBagConstraints.REMAINDER;
    add(rightLabel, c);

    //LEFT LIST
    leftList = new JList();
    JScrollPane leftScroll = new JScrollPane();
    leftScroll.setViewportView(leftList);
    leftScroll.setMinimumSize(new Dimension(450, 300));
    leftScroll.setPreferredSize(new Dimension(450, 300));
    c.weightx = 1.0;
    c.weighty = 1.0;
    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 1;
    c.gridheight = 4;
    add(leftScroll, c);

    //RIGHT LIST
    rightList = new JList();
    JScrollPane rightScroll = new JScrollPane();
    rightScroll.setViewportView(rightList);
    rightScroll.setMinimumSize(new Dimension(450, 300));
    rightScroll.setPreferredSize(new Dimension(450, 300));
    c.gridx = 2;
    c.gridwidth = GridBagConstraints.REMAINDER;
    this.add(rightScroll, c);

    // MOVE RIGHT
    c.weightx = 0.0;
    c.weighty = 0.5;
    c.gridx = 1;
    c.gridy = 1;
    c.gridwidth = 1;
    c.gridheight = 1;
    add(createMoveRight(), c);

    // MOVE LEFT
    c.gridy = 2;
    add(createMoveLeft(), c);

    // ALL RIGHT
    c.gridy = 3;
    add(createAllRight(), c);

    //ALL LEFT
    c.gridy = 4;
    this.add(createAllLeft(), c);

    //FILTER
    c.gridx = 0;
    c.gridy = 5;
    add(createFilterPanel(), c);

    //AUTO SELECT ALL
    c.gridx = 2;
    add(createSelectAllCheck(), c);

    //SEPARATOR
    JSeparator separator1 = new JSeparator(SwingConstants.HORIZONTAL);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.gridy = GridBagConstraints.RELATIVE;
    c.weightx = 1.0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    add(separator1, c);

    if (selectBase) {

        //SELECT BASE PANEL
        JPanel selectBasePanel = new JPanel(new BorderLayout());
        c.gridwidth = 2;
        add(selectBasePanel, c);

        //SELECT BASE LABEL
        JLabel selectBaseLabel = new JLabel("(Optional) Select Base: ");
        selectBasePanel.add(selectBaseLabel, BorderLayout.WEST);

        //SELECT BASE FIELD
        selectBaseField = new JTextField();
        selectBasePanel.add(selectBaseField, BorderLayout.CENTER);

        //SELECT BASE EXAMPLE
        JLabel selectBaseExample = new JLabel("  ex. 123,456,789");
        selectBasePanel.add(selectBaseExample, BorderLayout.EAST);

        //SEPARATOR
        JSeparator separator2 = new JSeparator(SwingConstants.HORIZONTAL);
        c.gridwidth = GridBagConstraints.REMAINDER;
        add(separator2, c);
    }

    JPanel okCancelPanel = new JPanel(new BorderLayout());
    c.anchor = GridBagConstraints.EAST;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 1.0;
    c.fill = GridBagConstraints.NONE;
    add(okCancelPanel, c);

    //OK
    okCancelPanel.add(createOKButton(), BorderLayout.CENTER);

    //CANCEL
    okCancelPanel.add(createCancelButton(), BorderLayout.EAST);

    pack();
}

From source file:storybook.toolkit.swing.SwingUtil.java

public static JPanel createNotesPanel(JTextArea taNotes) {
    MigLayout layout = new MigLayout("fill", "", "[top]");
    JPanel panel = new JPanel(layout);
    taNotes.setLineWrap(true);/*from  www. jav a  2  s  . c o m*/
    taNotes.setWrapStyleWord(true);
    taNotes.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
    JScrollPane scroller = new JScrollPane(taNotes);
    scroller.setPreferredSize(new Dimension(400, 400));
    panel.add(scroller, "grow");
    return panel;
}