Example usage for java.awt.event ItemEvent getStateChange

List of usage examples for java.awt.event ItemEvent getStateChange

Introduction

In this page you can find the example usage for java.awt.event ItemEvent getStateChange.

Prototype

public int getStateChange() 

Source Link

Document

Returns the type of state change (selected or deselected).

Usage

From source file:com.funambol.admin.module.panels.DefaultSyncSourceConfigPanel.java

/**
 * Creates the panel/*from  w w  w.  j a v  a  2  s.co  m*/
 */
private void init() {

    this.setLayout(null);

    titledBorder = new TitledBorder("");

    panelName.setFont(GuiFactory.titlePanelFont);
    panelName.setText(Bundle.getMessage(Bundle.LABEL_SYNC_SOURCE_EDIT) + " " + sourceTypeDescription);
    panelName.setBounds(new Rectangle(14, 5, 316, 28));
    panelName.setAlignmentX(SwingConstants.CENTER);
    panelName.setBorder(titledBorder);

    final int LABEL_X = 14;
    final int VALUE_X = 170;
    int y = 60;
    final int GAP_Y = 30;

    sourceUriLabel.setText(Bundle.getMessage(Bundle.LABEL_SYNC_SOURCE_URI) + ": ");
    sourceUriLabel.setFont(defaultFont);
    sourceUriLabel.setBounds(new Rectangle(LABEL_X, y, 150, 18));
    sourceUriValue.setFont(defaultFont);
    sourceUriValue.setBounds(new Rectangle(VALUE_X, y, 350, 18));
    y += GAP_Y; // New line

    nameLabel.setText(Bundle.getMessage(Bundle.LABEL_SYNC_SOURCE_NAME) + ": ");
    nameLabel.setFont(defaultFont);
    nameLabel.setBounds(new Rectangle(LABEL_X, y, 150, 18));
    nameValue.setFont(defaultFont);
    nameValue.setBounds(new Rectangle(VALUE_X, y, 350, 18));
    y += GAP_Y; // New line

    infoTypesLabel.setText(Bundle.getMessage(Bundle.LABEL_SYNC_SOURCE_SUPPORTED_TYPES) + ": ");
    infoTypesLabel.setFont(defaultFont);
    infoTypesLabel.setBounds(new Rectangle(LABEL_X, y, 150, 18));
    infoTypesValue.setFont(defaultFont);
    infoTypesValue.setBounds(new Rectangle(VALUE_X, y, 350, 18));
    y += GAP_Y; // New line

    infoVersionsLabel.setText(Bundle.getMessage(Bundle.LABEL_SYNC_SOURCE_SUPPORTED_VERSIONS) + ": ");
    infoVersionsLabel.setFont(defaultFont);
    infoVersionsLabel.setBounds(new Rectangle(LABEL_X, y, 150, 18));
    infoVersionsValue.setFont(defaultFont);
    infoVersionsValue.setBounds(new Rectangle(VALUE_X, y, 350, 18));
    y += GAP_Y; // New line

    int x = LABEL_X;

    encryption.setText(Bundle.getMessage(Bundle.LABEL_SYNC_SOURCE_ENCRYPTION));
    encryption.setFont(defaultFont);
    encryption.setSelected(false);
    encryption.setBounds(x, y, 150, 25);

    // What happens if the encryption is enabled?
    encryption.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == e.SELECTED) {
                encoding.setSelected(true); // Encryption implies encoding
                encoding.setEnabled(false);
            }
            if (e.getStateChange() == e.DESELECTED) {
                encoding.setSelected(false);
                encoding.setEnabled(true);
            }
        }
    });
    y += GAP_Y; // New line

    encoding.setText(Bundle.getMessage(Bundle.LABEL_SYNC_SOURCE_ENCODING));
    encoding.setFont(defaultFont);
    encoding.setSelected(false);
    encoding.setBounds(x, y, 150, 25);
    y += GAP_Y; // New line
    y += GAP_Y; // New line

    confirmButton.setFont(defaultFont);
    confirmButton.setText(Bundle.getMessage(Bundle.LABEL_BUTTON_ADD));
    confirmButton.setBounds(VALUE_X, y, 70, 25);

    // What happens when the confirmButton is pressed?
    confirmButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            try {
                validateValues();
                getValues();
                if (getState() == STATE_INSERT) {
                    DefaultSyncSourceConfigPanel.this.actionPerformed(new ActionEvent(
                            DefaultSyncSourceConfigPanel.this, ACTION_EVENT_INSERT, event.getActionCommand()));
                } else {
                    DefaultSyncSourceConfigPanel.this.actionPerformed(new ActionEvent(
                            DefaultSyncSourceConfigPanel.this, ACTION_EVENT_UPDATE, event.getActionCommand()));
                }
            } catch (Exception e) {
                notifyError(new AdminException(e.getMessage()));
            }
        }
    });

    // Adds all components to the panel
    this.add(panelName, null);
    this.add(nameLabel, null);
    this.add(sourceUriLabel, null);
    this.add(sourceUriValue, null);
    this.add(nameValue, null);
    this.add(infoTypesLabel, null);
    this.add(infoTypesValue, null);
    this.add(infoVersionsLabel, null);
    this.add(infoVersionsValue, null);
    this.add(encryption, null);
    this.add(encoding, null);
    this.add(confirmButton, null);
}

From source file:com.sec.ose.osi.ui.frm.main.manage.ManagedProjectTableModel.java

public void itemStateChanged(ItemEvent e) {
    Object source = e.getSource();
    if (source instanceof AbstractButton == false)
        return;/*w  w w.java 2s  .  com*/

    boolean checked = e.getStateChange() == ItemEvent.SELECTED;
    if (checked == false) {
        TableModel tm = table.getModel();
        if (tm instanceof AddProjectTableModel) {
            AddProjectTableModel model = (AddProjectTableModel) tm;
            if (model.isHeaderWork())
                return;
        } else if (tm instanceof ManagedProjectTableModel) {
            ManagedProjectTableModel model = (ManagedProjectTableModel) tm;
            if (model.isHeaderWork())
                return;
        }
    }

    for (int x = 0, y = table.getRowCount(); x < y; x++) {
        table.setValueAt(checked, x, column);
    }
}

From source file:gov.llnl.lc.infiniband.opensm.plugin.gui.graph.SimpleCollapsableGraph.java

public SimpleCollapsableGraph(UndirectedSparseMultigraph<IB_Vertex, IB_Edge> graph, OSM_Node subnetManager,
        Dimension preferredSize) throws HeadlessException {
    super();/*from   ww w  .  j  a v  a  2s  .c  o m*/
    setGraph(graph);

    layout = new FRLayout<IB_Vertex, IB_Edge>(graph);

    if (preferredSize == null)
        preferredSize = new Dimension(600, 600);
    else {
        // trim 10% off the supplied size
        preferredSize = new Dimension((preferredSize.width * 9) / 10, (preferredSize.height * 9) / 10);
    }

    final VisualizationModel<IB_Vertex, IB_Edge> visualizationModel = new DefaultVisualizationModel<IB_Vertex, IB_Edge>(
            layout, preferredSize);
    VisualizationViewer<IB_Vertex, IB_Edge> vv = new VisualizationViewer<IB_Vertex, IB_Edge>(visualizationModel,
            preferredSize);

    vv.addGraphMouseListener(new SimpleGraphMouseListener<IB_Vertex>(this));

    final PickedState<IB_Vertex> picked_v_state = vv.getPickedVertexState();
    PickedState<IB_Edge> picked_e_state = vv.getPickedEdgeState();

    picked_e_state.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            Object subject = e.getItem();

            if (subject instanceof IB_Edge) {
                IB_Edge edge = (IB_Edge) subject;

                if (e.getStateChange() == ItemEvent.SELECTED) {
                    // craft a selection event, for this edge
                    GraphSelectionManager.getInstance()
                            .updateAllListeners(new IB_GraphSelectionEvent(this, subject, edge));
                    MessageManager.getInstance().postMessage(
                            new SmtMessage(SmtMessageType.SMT_MSG_INFO, "SCG - edge selected: Color it!"));
                } else if (e.getStateChange() == ItemEvent.DESELECTED) {
                    // this is deselected, do nothing
                    MessageManager.getInstance()
                            .postMessage(new SmtMessage(SmtMessageType.SMT_MSG_INFO, "SCG - edge deselected"));
                } else {
                    System.err.println(
                            "SCG - edge not selected or deselected - unknown state change: The edge itemEvent is: "
                                    + e.getStateChange());
                }
            } else {
                System.err.println("SCG - not edge??: The edge subject picked is: "
                        + subject.getClass().getCanonicalName());
            }
        }
    });

    // create decorators
    vv.getRenderContext().setVertexLabelTransformer(IB_TransformerFactory.getVertexLabelTransformer(vv));
    vv.getRenderContext().setVertexShapeTransformer(IB_TransformerFactory.getVertexShapeTransformer(vv));
    vv.getRenderContext().setVertexFillPaintTransformer(
            IB_TransformerFactory.getVertexFillPaintTransformer(vv, subnetManager));
    vv.getRenderContext().setEdgeLabelTransformer(IB_TransformerFactory.getEdgeLabelTransformer(vv));
    vv.getRenderContext().setEdgeFillPaintTransformer(IB_TransformerFactory.getEdgeFillPaintTransformer(vv));
    vv.getRenderContext().setEdgeDrawPaintTransformer(IB_TransformerFactory.getEdgeDrawPaintTransformer(vv));

    // add a listener for ToolTips
    vv.setVertexToolTipTransformer(IB_TransformerFactory.getVertexToolTipTransformer(vv));
    vv.setEdgeToolTipTransformer(IB_TransformerFactory.getEdgeToolTipTransformer(vv));

    setVisViewer(vv);

    final PredicatedParallelEdgeIndexFunction eif = PredicatedParallelEdgeIndexFunction.getInstance();
    final Set exclusions = new HashSet();
    eif.setPredicate(new Predicate() {

        public boolean evaluate(Object e) {
            return exclusions.contains(e);
        }
    });

    vv.getRenderContext().setParallelEdgeIndexFunction(eif);

    vv.setBackground(Color.white);

    /**
     * the regular graph mouse for the normal view
     */
    final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse();

    vv.setGraphMouse(graphMouse);

    // Container content = getContentPane(); // for JApplet or JFrame
    Container content = this; // for JPanel
    content.setLayout(new BorderLayout());
    GraphZoomScrollPane gzsp = new GraphZoomScrollPane(vv);
    content.add(gzsp, BorderLayout.CENTER);
}

From source file:net.pandoragames.far.ui.swing.FindFilePanel.java

private void initContentSearchPanel(SwingConfig config, ComponentRepository componentRepository) {

    this.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING)));

    String title = localizer.localize("label.content-pattern");
    contentSearchPanel = new ContentSearchPanel(title, dataModel, config, componentRepository);
    contentSearchPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    browseButtonListener.addComponentToBeDisabledForSingleFiles(contentSearchPanel);
    componentRepository.getSearchBaseListener().addToBeEnabled(contentSearchPanel);
    componentRepository.getResetDispatcher().addToBeEnabled(contentSearchPanel);
    this.add(contentSearchPanel);

    inversionFlag = new JCheckBox(localizer.localize("label.exclude-matches"));
    inversionFlag.setAlignmentX(Component.LEFT_ALIGNMENT);
    inversionFlag.setSelected(dataModel.isInvertContentFilter());
    inversionFlag.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent event) {
            dataModel.setInvertContentFilter((ItemEvent.SELECTED == event.getStateChange()));
        }//w w  w. j av  a  2  s  . com
    });
    browseButtonListener.addComponentToBeDisabledForSingleFiles(inversionFlag);
    componentRepository.getSearchBaseListener().addToBeEnabled(inversionFlag);
    componentRepository.getResetDispatcher().addToBeEnabled(inversionFlag);
    contentSearchPanel.addFlag(inversionFlag);

    this.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING)));
    this.add(Box.createVerticalGlue());

}

From source file:net.pms.newgui.NetworkTab.java

public JComponent build() {
    FormLayout layout = new FormLayout("left:pref, 2dlu, p, 2dlu , p, 2dlu, p, 2dlu, pref:grow",
            "p, 0dlu, p, 0dlu, p, 3dlu, p, 3dlu, p, 3dlu,p, 3dlu, p, 15dlu, p, 3dlu,p, 3dlu, p,  3dlu, p, 3dlu, p, 3dlu, p,3dlu, p, 3dlu, p, 15dlu, p,3dlu, p, 3dlu, p, 15dlu, p, 3dlu, p");
    PanelBuilder builder = new PanelBuilder(layout);
    builder.setBorder(Borders.DLU4_BORDER);
    builder.setOpaque(true);/*from   www  .  java  2 s  .  c  o  m*/

    CellConstraints cc = new CellConstraints();

    smcheckBox = new JCheckBox(Messages.getString("NetworkTab.3"));
    smcheckBox.setContentAreaFilled(false);
    smcheckBox.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            PMS.getConfiguration().setMinimized((e.getStateChange() == ItemEvent.SELECTED));
        }
    });
    if (PMS.getConfiguration().isMinimized()) {
        smcheckBox.setSelected(true);
    }

    JComponent cmp = builder.addSeparator(Messages.getString("NetworkTab.5"), cc.xyw(1, 1, 9));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    builder.addLabel(Messages.getString("NetworkTab.0"), cc.xy(1, 7));
    final KeyedComboBoxModel kcbm = new KeyedComboBoxModel(
            new Object[] { "bg", "ca", "zhs", "zht", "cz", "da", "nl", "en", "fi", "fr", "de", "el", "is", "it",
                    "ja", "no", "pl", "pt", "br", "ro", "ru", "sl", "es", "sv" },
            new Object[] { "Bulgarian", "Catalan", "Chinese (Simplified)", "Chinese (Traditional)", "Czech",
                    "Danish", "Dutch", "English", "Finnish", "French", "German", "Greek", "Icelandic",
                    "Italian", "Japanese", "Norwegian", "Polish", "Portuguese", "Portuguese (Brazilian)",
                    "Romanian", "Russian", "Slovenian", "Spanish", "Swedish" });
    langs = new JComboBox(kcbm);
    langs.setEditable(false);
    //langs.setSelectedIndex(0);
    String defaultLang = null;
    if (configuration.getLanguage() != null && configuration.getLanguage().length() > 0) {
        defaultLang = configuration.getLanguage();
    } else {
        defaultLang = Locale.getDefault().getLanguage();
    }
    if (defaultLang == null) {
        defaultLang = "en";
    }
    kcbm.setSelectedKey(defaultLang);
    if (langs.getSelectedIndex() == -1) {
        langs.setSelectedIndex(0);
    }

    langs.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                configuration.setLanguage((String) kcbm.getSelectedKey());

            }
        }
    });
    builder.add(langs, cc.xyw(3, 7, 7));

    builder.add(smcheckBox, cc.xyw(1, 9, 9));

    JButton service = new JButton(Messages.getString("NetworkTab.4"));
    service.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (PMS.get().installWin32Service()) {
                JOptionPane.showMessageDialog(
                        (JFrame) (SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame())),
                        Messages.getString("NetworkTab.11") + Messages.getString("NetworkTab.12"),
                        "Information", JOptionPane.INFORMATION_MESSAGE);

            } else {
                JOptionPane.showMessageDialog(
                        (JFrame) (SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame())),
                        Messages.getString("NetworkTab.14"), "Error", JOptionPane.ERROR_MESSAGE);
            }
        }
    });
    builder.add(service, cc.xy(1, 11));
    if (System.getProperty(LooksFrame.START_SERVICE) != null || !Platform.isWindows()) {
        service.setEnabled(false);
    }

    host = new JTextField(PMS.getConfiguration().getServerHostname());
    host.addKeyListener(new KeyListener() {

        @Override
        public void keyPressed(KeyEvent e) {
        }

        @Override
        public void keyTyped(KeyEvent e) {
        }

        @Override
        public void keyReleased(KeyEvent e) {
            configuration.setHostname(host.getText());
            PMS.get().getFrame().setReloadable(true);
        }
    });
    // host.setEnabled( StringUtils.isBlank(configuration.getNetworkInterface())) ;
    port = new JTextField(configuration.getServerPort() != 5001 ? "" + configuration.getServerPort() : "");
    port.addKeyListener(new KeyListener() {

        @Override
        public void keyPressed(KeyEvent e) {
        }

        @Override
        public void keyTyped(KeyEvent e) {
        }

        @Override
        public void keyReleased(KeyEvent e) {
            try {
                String p = port.getText();
                if (StringUtils.isEmpty(p)) {
                    p = "5001";
                }
                int ab = Integer.parseInt(p);
                configuration.setServerPort(ab);
                PMS.get().getFrame().setReloadable(true);
            } catch (NumberFormatException nfe) {
            }

        }
    });

    cmp = builder.addSeparator(Messages.getString("NetworkTab.22"), cc.xyw(1, 21, 9));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    ArrayList<String> names = new ArrayList<String>();
    names.add("");
    ArrayList<String> interfaces = new ArrayList<String>();
    interfaces.add("");
    Enumeration<NetworkInterface> enm;
    try {
        enm = NetworkInterface.getNetworkInterfaces();
        while (enm.hasMoreElements()) {
            NetworkInterface ni = enm.nextElement();
            // check for interface has at least one ip address.
            if (ni.getInetAddresses().hasMoreElements()) {
                names.add(ni.getName());
                String displayName = ni.getDisplayName();
                if (displayName == null) {
                    displayName = ni.getName();
                }
                interfaces.add(displayName.trim());
            }
        }
    } catch (SocketException e1) {
        logger.error(null, e1);
    }

    final KeyedComboBoxModel networkInterfaces = new KeyedComboBoxModel(names.toArray(), interfaces.toArray());
    networkinterfacesCBX = new JComboBox(networkInterfaces);
    networkInterfaces.setSelectedKey(configuration.getNetworkInterface());
    networkinterfacesCBX.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                configuration.setNetworkInterface((String) networkInterfaces.getSelectedKey());
                //host.setEnabled( StringUtils.isBlank(configuration.getNetworkInterface())) ;
                PMS.get().getFrame().setReloadable(true);
            }
        }
    });

    ip_filter = new JTextField(PMS.getConfiguration().getIpFilter());
    ip_filter.addKeyListener(new KeyListener() {

        @Override
        public void keyPressed(KeyEvent e) {
        }

        @Override
        public void keyTyped(KeyEvent e) {
        }

        @Override
        public void keyReleased(KeyEvent e) {
            configuration.setIpFilter(ip_filter.getText());
            PMS.get().getFrame().setReloadable(true);
        }
    });

    builder.addLabel(Messages.getString("NetworkTab.20"), cc.xy(1, 23));
    builder.add(networkinterfacesCBX, cc.xyw(3, 23, 7));
    builder.addLabel(Messages.getString("NetworkTab.23"), cc.xy(1, 25));
    builder.add(host, cc.xyw(3, 25, 7));
    builder.addLabel(Messages.getString("NetworkTab.24"), cc.xy(1, 27));
    builder.add(port, cc.xyw(3, 27, 7));
    builder.addLabel(Messages.getString("NetworkTab.30"), cc.xy(1, 29));
    builder.add(ip_filter, cc.xyw(3, 29, 7));

    cmp = builder.addSeparator(Messages.getString("NetworkTab.31"), cc.xyw(1, 31, 9));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    newHTTPEngine = new JCheckBox(Messages.getString("NetworkTab.32"));
    newHTTPEngine.setSelected(PMS.getConfiguration().isHTTPEngineV2());
    newHTTPEngine.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            PMS.getConfiguration().setHTTPEngineV2((e.getStateChange() == ItemEvent.SELECTED));
        }
    });
    builder.add(newHTTPEngine, cc.xyw(1, 33, 9));

    preventSleep = new JCheckBox(Messages.getString("NetworkTab.33"));
    preventSleep.setSelected(PMS.getConfiguration().isPreventsSleep());
    preventSleep.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            PMS.getConfiguration().setPreventsSleep((e.getStateChange() == ItemEvent.SELECTED));
        }
    });
    builder.add(preventSleep, cc.xyw(1, 35, 9));

    cmp = builder.addSeparator(Messages.getString("NetworkTab.34"), cc.xyw(1, 37, 9));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    JPanel panel = builder.getPanel();
    JScrollPane scrollPane = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    return scrollPane;
}

From source file:com.tiempometa.muestradatos.JProgramTags.java

private void checkBox2ItemStateChanged(ItemEvent e) {
    if (e.getStateChange() == ItemEvent.SELECTED) {
        accessPasswordTextField.setEnabled(true);
        killPasswordTextField.setEnabled(true);
    } else if (e.getStateChange() == ItemEvent.DESELECTED) {
        accessPasswordTextField.setEnabled(false);
        killPasswordTextField.setEnabled(false);
    }/*from  w w  w . j  av a2s.  c  o m*/
}

From source file:net.pms.encoders.AviSynthMEncoder.java

@Override
public JComponent config() {
    FormLayout layout = new FormLayout("left:pref, 0:grow",
            "p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 12dlu, p, 3dlu, 0:grow");
    PanelBuilder builder = new PanelBuilder(layout);
    builder.border(Borders.EMPTY);/*from  w w w .j a  va  2 s.  c  o  m*/
    builder.opaque(false);

    CellConstraints cc = new CellConstraints();

    JComponent cmp = builder.addSeparator(Messages.getString("NetworkTab.5"), cc.xyw(2, 1, 1));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    multithreading = new JCheckBox(Messages.getString("MEncoderVideo.35"),
            configuration.getAvisynthMultiThreading());
    multithreading.setContentAreaFilled(false);
    multithreading.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setAvisynthMultiThreading((e.getStateChange() == ItemEvent.SELECTED));
        }
    });
    builder.add(GuiUtil.getPreferredSizeComponent(multithreading), cc.xy(2, 3));

    interframe = new JCheckBox(Messages.getString("AviSynthMEncoder.13"),
            configuration.getAvisynthInterFrame());
    interframe.setContentAreaFilled(false);
    interframe.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            configuration.setAvisynthInterFrame(interframe.isSelected());
            if (configuration.getAvisynthInterFrame()) {
                JOptionPane.showMessageDialog(
                        SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame()),
                        Messages.getString("AviSynthMEncoder.16"), Messages.getString("Dialog.Information"),
                        JOptionPane.INFORMATION_MESSAGE);
            }
        }
    });
    builder.add(GuiUtil.getPreferredSizeComponent(interframe), cc.xy(2, 5));

    interframegpu = new JCheckBox(Messages.getString("AviSynthMEncoder.15"),
            configuration.getAvisynthInterFrameGPU());
    interframegpu.setContentAreaFilled(false);
    interframegpu.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setAvisynthInterFrameGPU((e.getStateChange() == ItemEvent.SELECTED));
        }
    });
    builder.add(GuiUtil.getPreferredSizeComponent(interframegpu), cc.xy(2, 7));

    convertfps = new JCheckBox(Messages.getString("AviSynthMEncoder.3"), configuration.getAvisynthConvertFps());
    convertfps.setContentAreaFilled(false);
    convertfps.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            configuration.setAvisynthConvertFps((e.getStateChange() == ItemEvent.SELECTED));
        }
    });
    builder.add(GuiUtil.getPreferredSizeComponent(convertfps), cc.xy(2, 9));

    String aviSynthScriptInstructions = Messages.getString("AviSynthMEncoder.4")
            + Messages.getString("AviSynthMEncoder.5") + Messages.getString("AviSynthMEncoder.6")
            + Messages.getString("AviSynthMEncoder.7") + Messages.getString("AviSynthMEncoder.8");
    JTextArea aviSynthScriptInstructionsContainer = new JTextArea(aviSynthScriptInstructions);
    aviSynthScriptInstructionsContainer.setEditable(false);
    aviSynthScriptInstructionsContainer.setBorder(BorderFactory.createEtchedBorder());
    aviSynthScriptInstructionsContainer.setBackground(new Color(255, 255, 192));
    aviSynthScriptInstructionsContainer.setBorder(
            BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(new Color(130, 135, 144)),
                    BorderFactory.createEmptyBorder(3, 5, 3, 5)));
    builder.add(aviSynthScriptInstructionsContainer, cc.xy(2, 11));

    String clip = configuration.getAvisynthScript();
    if (clip == null) {
        clip = "";
    }
    StringBuilder sb = new StringBuilder();
    StringTokenizer st = new StringTokenizer(clip, PMS.AVS_SEPARATOR);
    int i = 0;
    while (st.hasMoreTokens()) {
        if (i > 0) {
            sb.append("\n");
        }
        sb.append(st.nextToken());
        i++;
    }
    textArea = new JTextArea(sb.toString());
    textArea.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            StringBuilder sb = new StringBuilder();
            StringTokenizer st = new StringTokenizer(textArea.getText(), "\n");
            int i = 0;
            while (st.hasMoreTokens()) {
                if (i > 0) {
                    sb.append(PMS.AVS_SEPARATOR);
                }
                sb.append(st.nextToken());
                i++;
            }
            configuration.setAvisynthScript(sb.toString());
        }
    });

    JScrollPane pane = new JScrollPane(textArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    pane.setPreferredSize(new Dimension(500, 350));
    builder.add(pane, cc.xy(2, 13));

    configuration.addConfigurationListener(new ConfigurationListener() {
        @Override
        public void configurationChanged(ConfigurationEvent event) {
            if (event.getPropertyName() == null) {
                return;
            }
            if ((!event.isBeforeUpdate())
                    && event.getPropertyName().equals(PmsConfiguration.KEY_GPU_ACCELERATION)) {
                interframegpu.setEnabled(configuration.isGPUAcceleration());
            }
        }
    });

    return builder.getPanel();
}

From source file:net.pandoragames.far.ui.swing.FindFilePanel.java

private void initFileNamePatternPanel(SwingConfig config, ComponentRepository componentRepository) {

    JLabel labelPattern = new JLabel(localizer.localize("label.file-name-pattern"));
    labelPattern.setAlignmentX(Component.LEFT_ALIGNMENT);
    this.add(labelPattern);

    listPattern = new JComboBox(config.getFileNamePatternListModel());
    listPattern.setEditable(true);//ww w  .  j ava  2  s  .  co m
    listPattern
            .setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, config.getStandardComponentHight()));

    JButton buttonSavePattern = new JButton(localizer.localize("button.save-pattern"));
    buttonSavePattern.setEnabled(false);
    TwoComponentsPanel linePattern = new TwoComponentsPanel(listPattern, buttonSavePattern);
    linePattern.setAlignmentX(Component.LEFT_ALIGNMENT);
    this.add(linePattern);

    patternFlag = new JCheckBox(localizer.localize("label.regular-expression"));
    patternFlag.setAlignmentX(Component.LEFT_ALIGNMENT);
    patternFlag.setSelected(dataModel.getFileNamePattern().isRegex());
    patternFlag.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent event) {
            dataModel.getFileNamePattern().setRegex((ItemEvent.SELECTED == event.getStateChange()));
        }
    });
    patternFlag.addItemListener(componentRepository.getSearchBaseListener());
    browseButtonListener.setRegexCheckBox(patternFlag);
    browseButtonListener.addComponentToBeDisabledForSingleFiles(patternFlag);
    componentRepository.getSearchBaseListener().addToBeEnabled(patternFlag);
    componentRepository.getResetDispatcher().addToBeEnabled(patternFlag);
    listPattern.addActionListener(new PatternListListener(patternFlag, componentRepository.getMessageBox()));
    listPattern.addActionListener(componentRepository.getSearchBaseListener());
    ComboBoxEditor comboBoxEditor = new FileNamePatternEditor(buttonSavePattern);
    listPattern.setEditor(comboBoxEditor);
    browseButtonListener.setComboBox(listPattern);
    browseButtonListener.addComponentToBeDisabledForSingleFiles(listPattern);
    componentRepository.getSearchBaseListener().addToBeEnabled(listPattern);
    componentRepository.getResetDispatcher().addToBeEnabled(listPattern);
    buttonSavePattern.addActionListener(
            new SaveFileNamePatternListener(listPattern, patternFlag, config, componentRepository));
    this.add(patternFlag);

    datePanel = new DateRestrictionPanel(dataModel, componentRepository, config);
    componentRepository.getResetDispatcher().addResetable(datePanel);
    datePanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    this.add(datePanel);

    this.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING)));
    this.add(Box.createVerticalGlue());
}

From source file:net.pandoragames.far.ui.swing.FindFilePanel.java

private void initBaseDirPanel(SwingConfig config, ComponentRepository componentRepository) {

    this.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING)));

    JLabel labelBaseDir = new JLabel(config.getLocalizer().localize("label.base-directory"));
    labelBaseDir.setAlignmentX(Component.LEFT_ALIGNMENT);
    this.add(labelBaseDir);

    baseDirPathTextField//from  ww  w .ja v a  2  s .c o  m
            .setPreferredSize(new Dimension(SwingConfig.COMPONENT_WIDTH, config.getStandardComponentHight()));
    baseDirPathTextField
            .setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, config.getStandardComponentHight()));
    // baseDirPathTextField.setText( dataModel.getBaseDirectory().getPath() );
    baseDirPathTextField.addItem(dataModel.getBaseDirectory().getPath());
    baseDirPathTextField.setSelectedItem(dataModel.getBaseDirectory().getPath());
    baseDirPathTextField.setToolTipText(dataModel.getBaseDirectory().getPath());
    baseDirPathTextField.setEditable(false);
    baseDirPathTextField.addItemListener(new BaseDirectoryComboBoxListener(config, dataModel));

    JButton openBaseDirFileChooserButton = new JButton(localizer.localize("button.browse"));
    openBaseDirFileChooserButton.requestFocusInWindow();
    class BaseDirectoryRepository extends AbstractFileRepository {
        public BaseDirectoryRepository(FARConfig cfg, ComponentRepository repository) {
            super(cfg, repository.getFindForm(), repository.getReplaceForm(), repository.getMessageBox());
        }

        public File getFile() {
            return farconfig.getBaseDirectory();
        }

        public boolean setFile(File file) {
            if (isSubdirectory(replaceForm.getBackupDirectory(), file)) {
                messageBox.error(localizer.localize("message.nested-base-child"));
                return false;
            } else if (isSubdirectory(file, replaceForm.getBackupDirectory())) {
                messageBox.error(localizer.localize("message.nested-base-parent"));
                return false;
            } else {
                baseDirPathTextField.addItem(file.getPath());
                baseDirPathTextField.setSelectedItem(file.getPath());
                baseDirPathTextField.setToolTipText(file.getPath());
                farconfig.setBaseDirectory(file);
                findForm.setBaseDirectory(file);
                return true;
            }
        }
    }
    browseButtonListener = new FindFilePanelBrowseButtonListener(baseDirPathTextField,
            new BaseDirectoryRepository(config, componentRepository),
            localizer.localize("label.choose-base-directory"), componentRepository.getFindCommand(),
            componentRepository.getResetDispatcher());
    browseButtonListener.addActionListener(componentRepository.getSearchBaseListener());
    openBaseDirFileChooserButton.addActionListener(browseButtonListener);
    TwoComponentsPanel lineBaseDir = new TwoComponentsPanel(baseDirPathTextField, openBaseDirFileChooserButton);
    lineBaseDir.setAlignmentX(Component.LEFT_ALIGNMENT);
    this.add(lineBaseDir);

    subdirFlag = new JCheckBox(localizer.localize("label.include-subdir") + ":");
    subdirFlag.setSelected(dataModel.isIncludeSubDirs());
    subdirFlag.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent event) {
            dataModel.setIncludeSubDirs((ItemEvent.SELECTED == event.getStateChange()));
            if (ItemEvent.SELECTED != event.getStateChange())
                subdirButton.reset();
        }
    });
    subdirFlag.addItemListener(componentRepository.getSearchBaseListener());
    componentRepository.getResetDispatcher().addToBeSelected(subdirFlag);
    browseButtonListener.setSubdirCheckBox(subdirFlag);
    subdirButton = new SubdirPatternLink(dataModel, localizer, componentRepository.getSearchBaseListener(),
            componentRepository.getRootWindow());
    componentRepository.getResetDispatcher().addResetable(subdirButton);
    TwoComponentsPanel subdirpanel = new TwoComponentsPanel(subdirFlag, subdirButton);
    subdirpanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    this.add(subdirpanel);

    this.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING)));
    this.add(Box.createVerticalGlue());
}

From source file:net.pandoragames.far.ui.swing.RenameFilesPanel.java

private void init(SwingConfig config, ComponentRepository componentRepository) {

    this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    this.setBorder(
            BorderFactory.createEmptyBorder(0, SwingConfig.PADDING, SwingConfig.PADDING, SwingConfig.PADDING));

    this.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING)));
    JLabel patternLabel = new JLabel(localizer.localize("label.find-pattern"));
    this.add(patternLabel);
    filenamePattern = new JTextField();
    filenamePattern.setPreferredSize(/*from  w  ww  . j a v  a  2s.c  o  m*/
            new Dimension(SwingConfig.COMPONENT_WIDTH_LARGE, config.getStandardComponentHight()));
    filenamePattern
            .setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, config.getStandardComponentHight()));
    filenamePattern.setAlignmentX(Component.LEFT_ALIGNMENT);
    UndoHistory findUndoManager = new UndoHistory();
    findUndoManager.registerUndoHistory(filenamePattern);
    findUndoManager.registerSnapshotHistory(filenamePattern);
    componentRepository.getReplaceCommand().addResetable(findUndoManager);
    filenamePattern.getDocument().addDocumentListener(new DocumentChangeListener() {
        public void documentUpdated(DocumentEvent e, String text) {
            dataModel.setPatternString(text);
            updateFileTable();
        }
    });
    componentRepository.getResetDispatcher().addToBeCleared(filenamePattern);
    this.add(filenamePattern);
    JCheckBox caseBox = new JCheckBox(localizer.localize("label.ignore-case"));
    caseBox.setSelected(true);
    caseBox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent event) {
            dataModel.setIgnoreCase((ItemEvent.SELECTED == event.getStateChange()));
            updateFileTable();
        }
    });
    this.add(caseBox);
    JCheckBox regexBox = new JCheckBox(localizer.localize("label.regular-expression"));
    regexBox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent event) {
            dataModel.setRegexPattern((ItemEvent.SELECTED == event.getStateChange()));
            updateFileTable();
        }
    });
    this.add(regexBox);
    JPanel extensionPanel = new JPanel();
    extensionPanel.setBorder(BorderFactory.createTitledBorder(localizer.localize("label.modify-extension")));
    extensionPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
    extensionPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    extensionPanel.setPreferredSize(new Dimension(SwingConfig.COMPONENT_WIDTH_LARGE, 60));
    extensionPanel.setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, 100));
    ButtonGroup extensionGroup = new ButtonGroup();
    JRadioButton protectButton = new JRadioButton(localizer.localize("label.protect-extension"));
    protectButton.setSelected(true);
    protectButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            dataModel.setProtectExtension(true);
            updateFileTable();
        }
    });
    extensionGroup.add(protectButton);
    extensionPanel.add(protectButton);
    JRadioButton includeButton = new JRadioButton(localizer.localize("label.include-extension"));
    includeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            dataModel.setExtensionOnly(false);
            dataModel.setProtectExtension(false);
            updateFileTable();
        }
    });
    extensionGroup.add(includeButton);
    extensionPanel.add(includeButton);
    JRadioButton onlyButton = new JRadioButton(localizer.localize("label.only-extension"));
    onlyButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            dataModel.setExtensionOnly(true);
            updateFileTable();
        }
    });
    extensionGroup.add(onlyButton);
    extensionPanel.add(onlyButton);
    this.add(extensionPanel);

    this.add(Box.createVerticalGlue());
    this.add(Box.createRigidArea(new Dimension(1, SwingConfig.PADDING)));

    // replace
    JLabel replaceLabel = new JLabel(localizer.localize("label.replacement-pattern"));
    this.add(replaceLabel);
    replacePattern = new JTextField();
    replacePattern.setPreferredSize(
            new Dimension(SwingConfig.COMPONENT_WIDTH_LARGE, config.getStandardComponentHight()));
    replacePattern
            .setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, config.getStandardComponentHight()));
    replacePattern.setAlignmentX(Component.LEFT_ALIGNMENT);
    UndoHistory undoManager = new UndoHistory();
    undoManager.registerUndoHistory(replacePattern);
    undoManager.registerSnapshotHistory(replacePattern);
    componentRepository.getReplaceCommand().addResetable(undoManager);
    replacePattern.getDocument().addDocumentListener(new DocumentChangeListener() {
        public void documentUpdated(DocumentEvent e, String text) {
            dataModel.setReplacementString(text);
            updateFileTable();
        }
    });
    componentRepository.getResetDispatcher().addToBeCleared(replacePattern);
    this.add(replacePattern);

    // treat case
    JPanel modifyCasePanel = new JPanel();
    modifyCasePanel.setBorder(BorderFactory.createTitledBorder(localizer.localize("label.modify-case")));
    modifyCasePanel.setLayout(new BoxLayout(modifyCasePanel, BoxLayout.Y_AXIS));
    modifyCasePanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    modifyCasePanel.setPreferredSize(new Dimension(SwingConfig.COMPONENT_WIDTH_LARGE, 100));
    modifyCasePanel.setMaximumSize(new Dimension(SwingConfig.COMPONENT_WIDTH_MAX, 200));
    ButtonGroup modifyCaseGroup = new ButtonGroup();
    ActionListener radioButtonListener = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String cmd = e.getActionCommand();
            dataModel.setTreatCase(RenameForm.CASEHANDLING.valueOf(cmd));
            updateFileTable();
        }
    };
    JRadioButton lowerButton = new JRadioButton(localizer.localize("label.to-lower-case"));
    lowerButton.setActionCommand(RenameForm.CASEHANDLING.LOWER.name());
    lowerButton.addActionListener(radioButtonListener);
    modifyCaseGroup.add(lowerButton);
    modifyCasePanel.add(lowerButton);
    JRadioButton upperButton = new JRadioButton(localizer.localize("label.to-upper-case"));
    upperButton.setActionCommand(RenameForm.CASEHANDLING.UPPER.name());
    upperButton.addActionListener(radioButtonListener);
    modifyCaseGroup.add(upperButton);
    modifyCasePanel.add(upperButton);
    JRadioButton keepButton = new JRadioButton(localizer.localize("label.preserve-case"));
    keepButton.setActionCommand(RenameForm.CASEHANDLING.PRESERVE.name());
    keepButton.setSelected(true);
    keepButton.addActionListener(radioButtonListener);
    modifyCaseGroup.add(keepButton);
    modifyCasePanel.add(keepButton);
    this.add(modifyCasePanel);

    // prevent case conflict
    JCheckBox caseConflictBox = new JCheckBox(localizer.localize("label.prevent-case-conflict"));
    caseConflictBox.setAlignmentX(Component.LEFT_ALIGNMENT);
    caseConflictBox.setSelected(true);
    caseConflictBox.setEnabled(!SwingConfig.isWindows()); // disabled on windows
    caseConflictBox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent event) {
            dataModel.setPreventCaseConflict((ItemEvent.SELECTED == event.getStateChange()));
            updateFileTable();
        }
    });
    this.add(caseConflictBox);

    this.add(Box.createVerticalGlue());

}