Search in sources :

Example 66 with DocumentEvent

use of javax.swing.event.DocumentEvent in project knime-core by knime.

the class JavaSnippet method getDocument.

@Override
public GuardedDocument getDocument() {
    // Lazy initialization of the document
    if (m_document == null) {
        m_document = createDocument();
        m_document.addDocumentListener(new DocumentListener() {

            @Override
            public void removeUpdate(final DocumentEvent e) {
                m_dirty = true;
            }

            @Override
            public void insertUpdate(final DocumentEvent e) {
                m_dirty = true;
            }

            @Override
            public void changedUpdate(final DocumentEvent e) {
                m_dirty = true;
            }
        });
        initDocument(m_document);
    }
    return m_document;
}
Also used : DocumentListener(javax.swing.event.DocumentListener) DocumentEvent(javax.swing.event.DocumentEvent)

Example 67 with DocumentEvent

use of javax.swing.event.DocumentEvent in project vcell by virtualcell.

the class BNGLDebugger method initialize.

@Deprecated
public void initialize() {
    // -------------------------------------------------- bngl panel
    JScrollPane bnglPanel = new JScrollPane();
    bnglTextArea = new JTextArea();
    bnglTextArea.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    // bnglTextArea.setFont(new Font("monospaced", Font.PLAIN, 14));
    lineNumberArea = new JTextArea("1");
    lineNumberArea.setBackground(Color.LIGHT_GRAY);
    lineNumberArea.setEditable(false);
    lineNumberArea.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    bnglTextArea.getDocument().addDocumentListener(new DocumentListener() {

        public String getNr() {
            lines = 1;
            int caretPosition = bnglTextArea.getDocument().getLength();
            Element root = bnglTextArea.getDocument().getDefaultRootElement();
            String nr = "1" + System.getProperty("line.separator");
            for (int i = 2; i < root.getElementIndex(caretPosition) + 2; i++) {
                nr += i + System.getProperty("line.separator");
                lines++;
            }
            return nr;
        }

        @Override
        public void changedUpdate(DocumentEvent de) {
            int oldLines = lines;
            String numbers = getNr();
            if (oldLines != lines) {
                lineNumberArea.setText(numbers);
            }
            lineNumberArea.getHighlighter().removeAllHighlights();
        }

        @Override
        public void insertUpdate(DocumentEvent de) {
            int oldLines = lines;
            String numbers = getNr();
            if (oldLines != lines) {
                lineNumberArea.setText(numbers);
            }
            lineNumberArea.getHighlighter().removeAllHighlights();
        }

        @Override
        public void removeUpdate(DocumentEvent de) {
            int oldLines = lines;
            String numbers = getNr();
            if (oldLines != lines) {
                lineNumberArea.setText(numbers);
            }
            lineNumberArea.getHighlighter().removeAllHighlights();
        }
    });
    bnglPanel.getViewport().add(bnglTextArea);
    bnglPanel.setRowHeaderView(lineNumberArea);
    bnglPanel.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    JPanel upperPanel = new JPanel();
    upperPanel.setLayout(new BorderLayout());
    upperPanel.add(bnglPanel, BorderLayout.CENTER);
    // ---------------------------------------------------- exception panel
    JScrollPane exceptionPanel = new JScrollPane();
    exceptionTextArea = new JTextArea();
    exceptionTextArea.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    exceptionTextArea.setFont(new Font("monospaced", Font.PLAIN, 14));
    exceptionPanel.getViewport().add(exceptionTextArea);
    exceptionPanel.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    JPanel lowerPanel = new JPanel();
    lowerPanel.setLayout(new BorderLayout());
    lowerPanel.add(exceptionPanel, BorderLayout.CENTER);
    // ---------------------------------------------------- all together now  :)
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    splitPane.setOneTouchExpandable(true);
    splitPane.setDividerLocation(350);
    splitPane.setResizeWeight(0.9);
    splitPane.setTopComponent(upperPanel);
    splitPane.setBottomComponent(lowerPanel);
    // ... Create menubar
    JMenuBar menuBar = new JMenuBar();
    JMenu fileMenu = menuBar.add(new JMenu("File"));
    // fileMenu.setMnemonic('F');
    // fileMenu.add(openAction);       // Note use of actions, not text.
    // fileMenu.add(saveAction);
    // fileMenu.addSeparator();
    fileMenu.add(exitAction);
    JPanel buttonPane = new JPanel();
    buttonParse.addActionListener(this);
    buttonSave.addActionListener(this);
    buttonExit.addActionListener(this);
    buttonPane.add(buttonParse);
    buttonPane.add(buttonSave);
    buttonPane.add(buttonExit);
    JPanel framePanel = new JPanel();
    framePanel.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.gridwidth = 1;
    gbc.weightx = 1;
    gbc.weighty = 1;
    gbc.fill = GridBagConstraints.BOTH;
    framePanel.add(splitPane, gbc);
    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.weightx = 0;
    gbc.weighty = 0;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    framePanel.add(buttonPane, gbc);
    frame.add(framePanel);
    frame.setJMenuBar(menuBar);
    frame.pack();
    frame.setName("BnglDebugger");
    frame.setSize(900, 650);
    frame.setVisible(true);
}
Also used : JScrollPane(javax.swing.JScrollPane) DocumentListener(javax.swing.event.DocumentListener) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) JTextArea(javax.swing.JTextArea) GridBagLayout(java.awt.GridBagLayout) Element(javax.swing.text.Element) DocumentEvent(javax.swing.event.DocumentEvent) Font(java.awt.Font) BorderLayout(java.awt.BorderLayout) JSplitPane(javax.swing.JSplitPane) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Example 68 with DocumentEvent

use of javax.swing.event.DocumentEvent in project vcell by virtualcell.

the class ApplicationSpecificationsPanel method initialize.

@Override
protected void initialize() {
    super.initialize();
    InitialConditionsPanel initialConditionsPanel = new InitialConditionsPanel();
    ModelProcessSpecsPanel modelProcessSpecsPanel = new ModelProcessSpecsPanel();
    networkConstraintsPanel = new NetworkConstraintsPanel();
    networkFreePanel = new NetworkFreePanel();
    MembraneConditionsPanel membraneConditionsPanel = new MembraneConditionsPanel();
    // order of calls determines display order
    setupTab("Species", initialConditionsPanel);
    setupTab("Reaction", modelProcessSpecsPanel);
    setupTab("Membrane", membraneConditionsPanel);
    setupTab("Network", networkConstraintsPanel);
    setupTab("Network-Free", networkFreePanel);
    activate(initialConditionsPanel);
    activate(modelProcessSpecsPanel);
    if (System.getProperty("showMembrane") != null) {
        activate(membraneConditionsPanel);
    }
    JPanel searchPanel = new JPanel();
    GridBagLayout gbl_searchPanel = new GridBagLayout();
    gbl_searchPanel.columnWeights = new double[] { 0.0, 1.0 };
    searchPanel.setLayout(gbl_searchPanel);
    JLabel lblNewLabel = new JLabel("Search");
    GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
    gbc_lblNewLabel.insets = new Insets(5, 5, 5, 5);
    gbc_lblNewLabel.anchor = GridBagConstraints.EAST;
    gbc_lblNewLabel.gridx = 0;
    gbc_lblNewLabel.gridy = 0;
    searchPanel.add(lblNewLabel, gbc_lblNewLabel);
    textField_1 = new JTextField();
    textField_1.getDocument().addDocumentListener(new DocumentListener() {

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

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

        @Override
        public void changedUpdate(DocumentEvent e) {
            searchTable();
        }
    });
    textField_1.putClientProperty("JTextField.variant", "search");
    GridBagConstraints gbc_textField_1 = new GridBagConstraints();
    gbc_textField_1.insets = new Insets(5, 5, 5, 5);
    gbc_textField_1.weightx = 1.0;
    gbc_textField_1.fill = GridBagConstraints.HORIZONTAL;
    gbc_textField_1.gridx = 1;
    gbc_textField_1.gridy = 0;
    searchPanel.add(textField_1, gbc_textField_1);
    textField_1.setColumns(10);
    add(searchPanel, BorderLayout.SOUTH);
    tabbedPane.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            searchTable();
        }
    });
}
Also used : JPanel(javax.swing.JPanel) DocumentListener(javax.swing.event.DocumentListener) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) NetworkConstraintsPanel(org.vcell.model.rbm.gui.NetworkConstraintsPanel) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) DocumentEvent(javax.swing.event.DocumentEvent) NetworkFreePanel(org.vcell.model.rbm.gui.NetworkFreePanel) ModelProcessSpecsPanel(cbit.vcell.mapping.gui.ModelProcessSpecsPanel) ChangeEvent(javax.swing.event.ChangeEvent) InitialConditionsPanel(cbit.vcell.mapping.gui.InitialConditionsPanel) MembraneConditionsPanel(cbit.vcell.mapping.gui.MembraneConditionsPanel) ChangeListener(javax.swing.event.ChangeListener)

Example 69 with DocumentEvent

use of javax.swing.event.DocumentEvent in project processdash by dtuma.

the class TimeCardDialog method buildTopPanel.

private Component buildTopPanel() {
    Box result = Box.createHorizontalBox();
    result.add(new JLabel(resources.getString("Time_Card.Month_Label") + " "));
    // We have to build our own month name array because the "official"
    // one contains 13 month names, the last one empty for Gregorian
    // Calendars
    String[] monthNames = new String[12];
    String[] officialMonthNames = (new DateFormatSymbols()).getMonths();
    for (int i = 12; i-- > 0; ) monthNames[i] = officialMonthNames[i];
    monthField = new JComboBox(monthNames);
    dontGrow(monthField);
    monthField.setSelectedIndex(model.getMonth() - Calendar.JANUARY);
    monthField.setMaximumRowCount(12);
    result.add(monthField);
    monthField.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            recalc();
        }
    });
    yearField = new JTextField(5);
    dontGrow(yearField);
    yearField.setText(Integer.toString(model.getYear()));
    result.add(yearField);
    yearField.getDocument().addDocumentListener(new DocumentListener() {

        public void insertUpdate(DocumentEvent e) {
            recalc();
        }

        public void removeUpdate(DocumentEvent e) {
            recalc();
        }

        public void changedUpdate(DocumentEvent e) {
            recalc();
        }
    });
    result.add(Box.createHorizontalGlue());
    result.add(new JLabel(resources.getString("Time_Format.Label") + " "));
    formatType = new JComboBox();
    formatType.addItem(format(75, HOURS_MINUTES));
    formatType.addItem(format(75, HOURS));
    formatType.addItem(format(75, MINUTES));
    dontGrow(formatType);
    result.add(formatType);
    formatType.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            redraw();
        }
    });
    result.add(Box.createHorizontalGlue());
    hideColumns = new JCheckBox();
    result.add(new JLabel(" " + resources.getString("Time_Card.Hide_Empty_Columns_Label") + " "));
    result.add(hideColumns);
    hideColumns.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            resizeColumns();
        }
    });
    result.add(Box.createHorizontalGlue());
    JButton closeButton = new JButton(resources.getString("Close"));
    dontGrow(closeButton);
    result.add(Box.createVerticalStrut(closeButton.getPreferredSize().height + 4));
    result.add(closeButton);
    closeButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            frame.setVisible(false);
        }
    });
    return result;
}
Also used : DocumentListener(javax.swing.event.DocumentListener) JComboBox(javax.swing.JComboBox) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) JLabel(javax.swing.JLabel) JComboBox(javax.swing.JComboBox) Box(javax.swing.Box) JCheckBox(javax.swing.JCheckBox) JTextField(javax.swing.JTextField) DocumentEvent(javax.swing.event.DocumentEvent) JCheckBox(javax.swing.JCheckBox) ActionListener(java.awt.event.ActionListener) DateFormatSymbols(java.text.DateFormatSymbols)

Example 70 with DocumentEvent

use of javax.swing.event.DocumentEvent in project gephi by gephi.

the class DirectoryChooserUI method createBottomPanel.

private void createBottomPanel(JFileChooser fc) {
    bottomPanel = new JPanel();
    bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.LINE_AXIS));
    JPanel labelPanel = new JPanel();
    labelPanel.setLayout(new BoxLayout(labelPanel, BoxLayout.PAGE_AXIS));
    labelPanel.add(Box.createRigidArea(verticalStrut1));
    JLabel fnl = new JLabel(fileNameLabelText);
    fnl.setDisplayedMnemonic(fileNameLabelMnemonic);
    fnl.setAlignmentY(0);
    labelPanel.add(fnl);
    labelPanel.add(Box.createRigidArea(new Dimension(1, 12)));
    JLabel ftl = new JLabel(filesOfTypeLabelText);
    ftl.setDisplayedMnemonic(filesOfTypeLabelMnemonic);
    labelPanel.add(ftl);
    bottomPanel.add(labelPanel);
    bottomPanel.add(Box.createRigidArea(new Dimension(15, 0)));
    JPanel fileAndFilterPanel = new JPanel();
    fileAndFilterPanel.add(Box.createRigidArea(verticalStrut3));
    fileAndFilterPanel.setLayout(new BoxLayout(fileAndFilterPanel, BoxLayout.Y_AXIS));
    filenameTextField = new JTextField(24) {

        @Override
        public Dimension getMaximumSize() {
            return new Dimension(Short.MAX_VALUE, super.getPreferredSize().height);
        }
    };
    filenameTextField.getDocument().addDocumentListener(new DocumentListener() {

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

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

        @Override
        public void changedUpdate(DocumentEvent e) {
        }
    });
    filenameTextField.addKeyListener(new TextFieldKeyListener());
    fnl.setLabelFor(filenameTextField);
    filenameTextField.addFocusListener(new FocusAdapter() {

        @Override
        public void focusGained(FocusEvent e) {
            if (!getFileChooser().isMultiSelectionEnabled()) {
                tree.clearSelection();
            }
        }
    });
    // disable TAB focus transfer, we need it for completion
    Set<AWTKeyStroke> tKeys = filenameTextField.getFocusTraversalKeys(java.awt.KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS);
    Set<AWTKeyStroke> newTKeys = new HashSet<AWTKeyStroke>(tKeys);
    newTKeys.remove(AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_TAB, 0));
    // #107305: enable at least Ctrl+TAB if we have TAB for completion
    newTKeys.add(AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_TAB, KeyEvent.CTRL_DOWN_MASK));
    filenameTextField.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, newTKeys);
    fileAndFilterPanel.add(filenameTextField);
    fileAndFilterPanel.add(Box.createRigidArea(verticalStrut3));
    filterTypeComboBoxModel = createFilterComboBoxModel();
    fc.addPropertyChangeListener(filterTypeComboBoxModel);
    filterTypeComboBox = new JComboBox(filterTypeComboBoxModel);
    ftl.setLabelFor(filterTypeComboBox);
    filterTypeComboBox.setRenderer(createFilterComboBoxRenderer());
    fileAndFilterPanel.add(filterTypeComboBox);
    bottomPanel.add(fileAndFilterPanel);
    bottomPanel.add(Box.createRigidArea(horizontalStrut1));
    createButtonsPanel(fc);
}
Also used : DocumentListener(javax.swing.event.DocumentListener) FocusAdapter(java.awt.event.FocusAdapter) DocumentEvent(javax.swing.event.DocumentEvent) FocusEvent(java.awt.event.FocusEvent)

Aggregations

DocumentEvent (javax.swing.event.DocumentEvent)139 DocumentListener (javax.swing.event.DocumentListener)70 DocumentAdapter (com.intellij.ui.DocumentAdapter)64 ActionEvent (java.awt.event.ActionEvent)36 ActionListener (java.awt.event.ActionListener)34 JTextField (javax.swing.JTextField)22 JLabel (javax.swing.JLabel)18 JPanel (javax.swing.JPanel)18 Dimension (java.awt.Dimension)16 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)13 ItemEvent (java.awt.event.ItemEvent)13 ItemListener (java.awt.event.ItemListener)13 ChangeEvent (javax.swing.event.ChangeEvent)13 JButton (javax.swing.JButton)12 JCheckBox (javax.swing.JCheckBox)12 ChangeListener (javax.swing.event.ChangeListener)11 Document (javax.swing.text.Document)10 GridBagLayout (java.awt.GridBagLayout)9 NotNull (org.jetbrains.annotations.NotNull)9 GridBagConstraints (java.awt.GridBagConstraints)8