List of usage examples for javax.swing.event DocumentListener DocumentListener
DocumentListener
From source file:com.sciaps.view.SpectrumShotPanel.java
/** * List Creates new form LibzListPanel/*from w ww . jav a 2 s.c o m*/ * * @param callback */ public SpectrumShotPanel(RegionFinderIntf callback) { initComponents(); callback_ = callback; baselineSettingPanel_ = new BaselineRemovalSettingsPanel(); shotListTableModel_ = new ShotListTableModel(callback); tblShots_.setModel(shotListTableModel_); tblShots_.getTableHeader().setReorderingAllowed(false); tblShots_.getColumnModel().getColumn(0).setPreferredWidth(45); tblShots_.getColumnModel().getColumn(0).setMinWidth(45); tblShots_.getColumnModel().getColumn(0).setMaxWidth(45); tblShots_.getColumnModel().getColumn(0).setResizable(false); sorter_ = new TableRowSorter<ShotListTableModel>(shotListTableModel_); tblShots_.setRowSorter(sorter_); txtFilterText_.getDocument().addDocumentListener(new DocumentListener() { @Override public void changedUpdate(DocumentEvent e) { filterTable(); } @Override public void insertUpdate(DocumentEvent e) { filterTable(); } @Override public void removeUpdate(DocumentEvent e) { filterTable(); } }); }
From source file:com.joey.software.Launcher.microneedleAnalysis.DataAnalysisViewer.java
public void createJPanel() { setLayout(new BorderLayout()); JPanel pan = new JPanel(new GridLayout(4, 1)); pan.add(SwingToolkit.getLabel(modeBox, "Mode : ", 100)); pan.add(SwingToolkit.getLabel(expFilter, "Exp : ", 100)); pan.add(SwingToolkit.getLabel(viewFilter, "View : ", 100)); pan.add(debugButton);//from w w w .j a v a2 s. c o m JPanel showPanel = new JPanel(new GridLayout(1, 3)); showPanel.add(useSkin); showPanel.add(usePore); showPanel.add(usePoreSkin); showPanel.add(useTotal); JPanel temp = new JPanel(new BorderLayout()); temp.add(pan, BorderLayout.CENTER); temp.add(showPanel, BorderLayout.SOUTH); add(temp, BorderLayout.NORTH); add(chartHolder, BorderLayout.CENTER); add(replot, BorderLayout.SOUTH); debugButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { saveDataAsCSV(); } }); ActionListener action = new ActionListener() { @Override public void actionPerformed(ActionEvent e) { replotData(); } }; useSkin.addActionListener(action); usePore.addActionListener(action); usePoreSkin.addActionListener(action); useTotal.addActionListener(action); modeBox.addActionListener(action); expFilter.getDocument().addDocumentListener(new DocumentListener() { @Override public void changedUpdate(DocumentEvent e) { replotData(); } @Override public void insertUpdate(DocumentEvent e) { replotData(); } @Override public void removeUpdate(DocumentEvent e) { replotData(); } }); viewFilter.getDocument().addDocumentListener(new DocumentListener() { @Override public void changedUpdate(DocumentEvent e) { replotData(); } @Override public void insertUpdate(DocumentEvent e) { replotData(); } @Override public void removeUpdate(DocumentEvent e) { replotData(); } }); replot.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { replotData(); } }); }
From source file:ca.phon.app.query.SaveQueryDialog.java
private void init() { // final PathExpander pe = new PathExpander(); nameField = new JTextField(); nameField.getDocument().addDocumentListener(new DocumentListener() { @Override/*from ww w . j a v a 2s.c om*/ public void insertUpdate(DocumentEvent de) { updateLocationFields(); } @Override public void removeUpdate(DocumentEvent de) { updateLocationFields(); } @Override public void changedUpdate(DocumentEvent de) { updateLocationFields(); } }); includeFormOptionsBox = new JCheckBox("Include current form settings"); includeFormOptionsBox.setSelected(true); ButtonGroup btnGrp = new ButtonGroup(); saveInProjectBtn = new JRadioButton("Save in project resources"); btnGrp.add(saveInProjectBtn); saveInUserDirBtn = new JRadioButton("Save in user library"); btnGrp.add(saveInUserDirBtn); saveOtherBtn = new JRadioButton("Save in another location..."); btnGrp.add(saveOtherBtn); saveInUserDirBtn.setSelected(true); projSaveLocField = new JLabel(); // projSaveLocField.setFont(projSaveLocField.getFont().deriveFont(10.0f)); libSaveLocField = new JLabel(); // libSaveLocField.setFont(libSaveLocField.getFont().deriveFont(10.0f)); updateLocationFields(); saveBtn = new JButton("Save"); saveBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { save(); } }); super.getRootPane().setDefaultButton(saveBtn); cancelBtn = new JButton("Cancel"); cancelBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { setVisible(false); } }); final DialogHeader header = new DialogHeader("Save Query", ""); JComponent btnBar = ButtonBarBuilder.buildOkCancelBar(saveBtn, cancelBtn); final FormLayout formLayout = new FormLayout("3dlu, 12dlu, fill:pref:grow, 3dlu", "pref, pref, pref, pref, pref, pref, pref, pref, pref, pref"); final CellConstraints cc = new CellConstraints(); setLayout(formLayout); add(header, cc.xyw(2, 1, 2)); add(new JLabel("Name: (without extension)"), cc.xyw(2, 2, 2)); add(nameField, cc.xy(3, 3)); add(includeFormOptionsBox, cc.xy(3, 4)); add(saveInUserDirBtn, cc.xyw(2, 5, 2)); // add(libSaveLocField, cc.xy(3, 6)); add(saveInProjectBtn, cc.xyw(2, 7, 2)); // add(projSaveLocField, cc.xy(3, 8)); add(saveOtherBtn, cc.xyw(2, 9, 2)); add(btnBar, cc.xyw(2, 10, 2)); }
From source file:com.mirth.connect.client.ui.codetemplate.BasicCodeTemplatePropertiesPanel.java
private void initComponents() { containerPanel = new JPanel(); containerPanel.setBackground(UIConstants.BACKGROUND_COLOR); templateCodeLabel = new JLabel("Code:"); templateCodeTextArea = new MirthRTextScrollPane(ContextType.GLOBAL_DEPLOY); templateCodeTextArea.getDocument().addDocumentListener(codeChangeListener); templateCodeTextArea.getDocument().addDocumentListener(new DocumentListener() { @Override//from w w w.j a v a 2s . co m public void removeUpdate(DocumentEvent evt) { codeChanged(evt); } @Override public void insertUpdate(DocumentEvent evt) { codeChanged(evt); } @Override public void changedUpdate(DocumentEvent evt) { codeChanged(evt); } private void codeChanged(DocumentEvent evt) { try { if (evt.getDocument().getLength() >= 3 && StringUtils.equals(evt.getDocument().getText(0, 3), "/**")) { templateAutoGenerateDocumentationButton.setText("Update JSDoc"); } else { templateAutoGenerateDocumentationButton.setText("Generate JSDoc"); } } catch (BadLocationException e) { } } }); templateAutoGenerateDocumentationButton = new JButton("Update JSDoc"); templateAutoGenerateDocumentationButton.setToolTipText( "<html>Generates/updates a JSDoc at the beginning of your<br/>code, with parameter/return annotations as needed.</html>"); templateAutoGenerateDocumentationButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent evt) { String currentText = templateCodeTextArea.getText(); String newText = CodeTemplateUtil.updateCode(templateCodeTextArea.getText()); templateCodeTextArea.setText(newText, false); if (!currentText.equals(newText)) { parent.setSaveEnabled(true); } } }); }
From source file:com.diversityarrays.kdxplore.trialmgr.trait.TraitExportDialog.java
public TraitExportDialog(Window owner, List<Trait> traits) { super(owner, "Export Traits", ModalityType.APPLICATION_MODAL); this.traits = traits; setDefaultCloseOperation(DISPOSE_ON_CLOSE); setGlassPane(backgroundRunner.getBlockingPane()); JPanel mainPanel = new JPanel(); GBH gbh = new GBH(mainPanel, 2, 1, 2, 1); int y = 0;/*from w w w. j a v a 2s .c o m*/ gbh.add(0, y, 1, 1, GBH.NONE, 1, 1, GBH.EAST, "CSV file:"); gbh.add(1, y, 1, 1, GBH.HORZ, 2, 1, GBH.CENTER, filepathField); gbh.add(2, y, 1, 1, GBH.NONE, 1, 1, GBH.WEST, new JButton(browseAction)); ++y; exportAction.setEnabled(false); filepathField.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { updateExportAction(); } @Override public void insertUpdate(DocumentEvent e) { updateExportAction(); } @Override public void changedUpdate(DocumentEvent e) { updateExportAction(); } private void updateExportAction() { exportAction.setEnabled(!Check.isEmpty(filepathField.getText().trim())); } }); File outdir = KdxplorePreferences.getInstance().getOutputDirectory(); if (outdir != null) { File outfile = new File(outdir, "traits.csv"); filepathField.setText(outfile.getPath()); } Box buttons = Box.createHorizontalBox(); buttons.add(openAfterExport); buttons.add(Box.createHorizontalGlue()); buttons.add(new JButton(cancelAction)); buttons.add(new JButton(exportAction)); Container cp = getContentPane(); cp.add(mainPanel, BorderLayout.CENTER); cp.add(buttons, BorderLayout.SOUTH); pack(); Dimension sz = getSize(); setSize(600, sz.height); }
From source file:au.org.ala.delta.intkey.ui.FindInCharactersDialog.java
public FindInCharactersDialog(Intkey intkeyApp, IntkeyContext context) { super(intkeyApp.getMainFrame(), false); setResizable(false);//from ww w . j a v a 2 s . c o m ResourceMap resourceMap = Application.getInstance().getContext() .getResourceMap(FindInCharactersDialog.class); resourceMap.injectFields(this); ActionMap actionMap = Application.getInstance().getContext().getActionMap(this); _intkeyApp = intkeyApp; _numMatchedCharacters = 0; _currentMatchedCharacter = -1; _findAction = actionMap.get("findCharacters"); _nextAction = actionMap.get("nextCharacter"); this.setTitle(windowTitle); _pnlMain = new JPanel(); _pnlMain.setBorder(new EmptyBorder(20, 20, 20, 20)); getContentPane().add(_pnlMain, BorderLayout.CENTER); _pnlMain.setLayout(new BorderLayout(0, 0)); _pnlMainTop = new JPanel(); _pnlMain.add(_pnlMainTop, BorderLayout.NORTH); _pnlMainTop.setLayout(new BoxLayout(_pnlMainTop, BoxLayout.Y_AXIS)); _lblEnterSearchString = new JLabel(enterSearchStringCaption); _lblEnterSearchString.setBorder(new EmptyBorder(0, 0, 5, 0)); _pnlMainTop.add(_lblEnterSearchString); _textField = new JTextField(); _pnlMainTop.add(_textField); _textField.setColumns(10); _textField.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { reset(); } @Override public void insertUpdate(DocumentEvent e) { reset(); } @Override public void changedUpdate(DocumentEvent e) { reset(); } }); _pnlMainBottom = new JPanel(); _pnlMainBottom.setBorder(new EmptyBorder(20, 0, 0, 0)); _pnlMain.add(_pnlMainBottom, BorderLayout.CENTER); _pnlMainBottom.setLayout(new BoxLayout(_pnlMainBottom, BoxLayout.Y_AXIS)); _chckbxSearchStates = new JCheckBox(searchStatesCaption); _chckbxSearchStates.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { reset(); } }); _pnlMainBottom.add(_chckbxSearchStates); _chckbxSearchUsedCharacters = new JCheckBox(searchUsedCharactersCaption); _chckbxSearchUsedCharacters.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { reset(); } }); _pnlMainBottom.add(_chckbxSearchUsedCharacters); _pnlButtons = new JPanel(); _pnlButtons.setBorder(new EmptyBorder(20, 0, 0, 10)); getContentPane().add(_pnlButtons, BorderLayout.EAST); _pnlButtons.setLayout(new BorderLayout(0, 0)); _pnlInnerButtons = new JPanel(); _pnlButtons.add(_pnlInnerButtons, BorderLayout.NORTH); GridBagLayout gbl__pnlInnerButtons = new GridBagLayout(); gbl__pnlInnerButtons.columnWidths = new int[] { 0, 0 }; gbl__pnlInnerButtons.rowHeights = new int[] { 0, 0, 0, 0 }; gbl__pnlInnerButtons.columnWeights = new double[] { 0.0, Double.MIN_VALUE }; gbl__pnlInnerButtons.rowWeights = new double[] { 0.0, 0.0, 0.0, Double.MIN_VALUE }; _pnlInnerButtons.setLayout(gbl__pnlInnerButtons); _btnFindNext = new JButton(); _btnFindNext.setAction(_findAction); GridBagConstraints gbc__btnFindNext = new GridBagConstraints(); gbc__btnFindNext.fill = GridBagConstraints.HORIZONTAL; gbc__btnFindNext.insets = new Insets(0, 0, 5, 0); gbc__btnFindNext.gridx = 0; gbc__btnFindNext.gridy = 0; _pnlInnerButtons.add(_btnFindNext, gbc__btnFindNext); _btnPrevious = new JButton(); _btnPrevious.setAction(actionMap.get("previousCharacter")); _btnPrevious.setEnabled(false); GridBagConstraints gbc__btnPrevious = new GridBagConstraints(); gbc__btnPrevious.insets = new Insets(0, 0, 5, 0); gbc__btnPrevious.gridx = 0; gbc__btnPrevious.gridy = 1; _pnlInnerButtons.add(_btnPrevious, gbc__btnPrevious); _btnDone = new JButton(); _btnDone.setAction(actionMap.get("findCharactersDone")); GridBagConstraints gbc__btnDone = new GridBagConstraints(); gbc__btnDone.fill = GridBagConstraints.HORIZONTAL; gbc__btnDone.gridx = 0; gbc__btnDone.gridy = 2; _pnlInnerButtons.add(_btnDone, gbc__btnDone); this.pack(); this.setLocationRelativeTo(_intkeyApp.getMainFrame()); }
From source file:jeplus.gui.JPanel_EPlusProjectFiles.java
/** * Creates new form JPanel_EPlusProjectFiles with parameters *//*from w ww . j av a 2 s .c o m*/ public JPanel_EPlusProjectFiles(JEPlusFrameMain frame, JEPlusProject project) { initComponents(); MainGUI = frame; Project = project; this.txtGroupID.setText(Project.getProjectID()); this.txtGroupNotes.setText(Project.getProjectNotes()); txtIdfDir.setText(Project.getIDFDir()); if (Project.getIDFTemplate() != null) { cboTemplateFile.setModel(new DefaultComboBoxModel(Project.getIDFTemplate().split("\\s*;\\s*"))); } else { cboTemplateFile.setModel(new DefaultComboBoxModel(new String[] { "Select files..." })); } txtWthrDir.setText(Project.getWeatherDir()); if (Project.getWeatherFile() != null) { cboWeatherFile.setModel(new DefaultComboBoxModel(Project.getWeatherFile().split("\\s*;\\s*"))); } else { cboWeatherFile.setModel(new DefaultComboBoxModel(new String[] { "Select files..." })); } chkReadVar.setSelected(Project.isUseReadVars()); txtRviDir.setText(Project.getRVIDir()); if (Project.getRVIFile() != null) { cboRviFile.setModel(new DefaultComboBoxModel(new String[] { Project.getRVIFile() })); } else { cboRviFile.setModel(new DefaultComboBoxModel(new String[] { "Select a file..." })); } this.chkReadVarActionPerformed(null); // Set listeners to text fields DL = new DocumentListener() { Document DocProjID = txtGroupID.getDocument(); Document DocProjNotes = txtGroupNotes.getDocument(); Document DocIdfDir = txtIdfDir.getDocument(); Document DocWthrDir = txtWthrDir.getDocument(); Document DocRviDir = txtRviDir.getDocument(); @Override public void insertUpdate(DocumentEvent e) { Document src = e.getDocument(); if (src == DocProjID) { Project.setProjectID(txtGroupID.getText()); } else if (src == DocProjNotes) { Project.setProjectNotes(txtGroupNotes.getText()); } else if (src == DocIdfDir) { Project.setIDFDir(txtIdfDir.getText()); } else if (src == DocWthrDir) { Project.setWeatherDir(txtWthrDir.getText()); } else if (src == DocRviDir) { Project.setRVIDir(txtRviDir.getText()); } } @Override public void removeUpdate(DocumentEvent e) { insertUpdate(e); } @Override public void changedUpdate(DocumentEvent e) { // not applicable } }; txtGroupID.getDocument().addDocumentListener(DL); txtGroupNotes.getDocument().addDocumentListener(DL); txtIdfDir.getDocument().addDocumentListener(DL); txtWthrDir.getDocument().addDocumentListener(DL); txtRviDir.getDocument().addDocumentListener(DL); }
From source file:burlov.ultracipher.swing.MainPanel.java
public MainPanel(Translator translator) { editDataPanel = new EditDataPanel(translator); translator.addToComponent(searchField); listPopup.add(getNewEntryAction());/*from w w w. j a v a 2 s . c o m*/ listPopup.add(getDeleteEntryAction()); setLayout(new BorderLayout()); add(splitPane); /* * Suchpanel initialisieren */ JPanel panel = new JPanel(new BorderLayout()); JPanel searchPanel = new JPanel(new BorderLayout()); searchPanel.add(new JLabel(new ImageIcon(getClass().getResource("find.png"))), BorderLayout.WEST); searchPanel.add(searchField, BorderLayout.CENTER); searchField.setToolTipText("Search"); panel.add(searchPanel, BorderLayout.NORTH); panel.add(new JScrollPane(searchResults), BorderLayout.CENTER); splitPane.setLeftComponent(panel); /* * Anzeigepanel initialisieren */ panel = new JPanel(new BorderLayout()); panel.add(editDataPanel, BorderLayout.CENTER); panel.add(new PassGeneratorPanel(), BorderLayout.SOUTH); splitPane.setRightComponent(panel); searchResults.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { showDeletePopup(e); } @Override public void mouseReleased(MouseEvent e) { showDeletePopup(e); } private void showDeletePopup(MouseEvent e) { if (!e.isPopupTrigger()) { return; } int index = searchResults.locationToIndex(e.getPoint()); if (index > -1) { searchResults.setSelectedIndex(index); } listPopup.show(e.getComponent(), e.getX(), e.getY()); } }); searchResults.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { editDataPanel.editData((DataEntry) searchResults.getSelectedValue(), false); } }); searchField.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { initResultList(); } @Override public void insertUpdate(DocumentEvent e) { initResultList(); } @Override public void changedUpdate(DocumentEvent e) { initResultList(); } }); editDataPanel.addNameChangeListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { int index = searchResultModel.indexOf(editDataPanel.getData()); if (index >= 0) { searchResultModel.set(index, editDataPanel.getData()); } } @Override public void insertUpdate(DocumentEvent e) { int index = searchResultModel.indexOf(editDataPanel.getData()); if (index >= 0) { searchResultModel.set(index, editDataPanel.getData()); } } @Override public void changedUpdate(DocumentEvent e) { int index = searchResultModel.indexOf(editDataPanel.getData()); if (index >= 0) { searchResultModel.set(index, editDataPanel.getData()); } } }); searchField.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if (e.isPopupTrigger()) { showTextPopup(e); } else { // searchField.selectAll(); } } @Override public void mouseReleased(MouseEvent e) { showTextPopup(e); } }); // searchField.addFocusListener(new FocusListener() { // @Override // public void focusLost(FocusEvent e) { // System.out.println("MainPanel.MainPanel().new FocusListener() {...}.focusLost()"); // } // // @Override // public void focusGained(FocusEvent e) { // System.out.println("MainPanel.MainPanel().new FocusListener() {...}.focusGained()"); // //searchField.selectAll(); // } // }); }
From source file:TableFilterDemo.java
public TableFilterDemo() { super();//w w w . jav a2 s . c om setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); // Create a table with a sorter. MyTableModel model = new MyTableModel(); sorter = new TableRowSorter<MyTableModel>(model); table = new JTable(model); table.setRowSorter(sorter); table.setPreferredScrollableViewportSize(new Dimension(500, 70)); table.setFillsViewportHeight(true); // For the purposes of this example, better to have a single // selection. table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // When selection changes, provide user with row numbers for // both view and model. table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent event) { int viewRow = table.getSelectedRow(); if (viewRow < 0) { // Selection got filtered away. statusText.setText(""); } else { int modelRow = table.convertRowIndexToModel(viewRow); statusText.setText(String.format("Selected Row in view: %d. " + "Selected Row in model: %d.", viewRow, modelRow)); } } }); // Create the scroll pane and add the table to it. JScrollPane scrollPane = new JScrollPane(table); // Add the scroll pane to this panel. add(scrollPane); // Create a separate form for filterText and statusText JPanel form = new JPanel(new SpringLayout()); JLabel l1 = new JLabel("Filter Text:", SwingConstants.TRAILING); form.add(l1); filterText = new JTextField(); // Whenever filterText changes, invoke newFilter. filterText.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { newFilter(); } public void insertUpdate(DocumentEvent e) { newFilter(); } public void removeUpdate(DocumentEvent e) { newFilter(); } }); l1.setLabelFor(filterText); form.add(filterText); JLabel l2 = new JLabel("Status:", SwingConstants.TRAILING); form.add(l2); statusText = new JTextField(); l2.setLabelFor(statusText); form.add(statusText); SpringUtilities.makeCompactGrid(form, 2, 2, 6, 6, 6, 6); add(form); }
From source file:ca.sqlpower.wabit.swingui.enterprise.UserPanel.java
public UserPanel(User baseUser) { final MessageDigest digester; try {//ww w. java2s.co m digester = MessageDigest.getInstance("SHA-256"); } catch (NoSuchAlgorithmException e1) { throw new RuntimeException(e1); } this.user = baseUser; this.workspace = (WabitWorkspace) this.user.getParent(); this.loginTextField = new JTextField(); this.loginTextField.setText(user.getName()); this.loginLabel = new JLabel("User name"); this.loginTextField.getDocument().addDocumentListener(new DocumentListener() { public void textChanged(DocumentEvent e) { user.setName(loginTextField.getText()); } public void changedUpdate(DocumentEvent e) { textChanged(e); } public void insertUpdate(DocumentEvent e) { textChanged(e); } public void removeUpdate(DocumentEvent e) { textChanged(e); } }); this.passwordTextField = new JPasswordField(); this.passwordLabel = new JLabel("Password"); this.passwordTextField.getDocument().addDocumentListener(new DocumentListener() { public void textChanged(DocumentEvent e) { try { String pass = new String(passwordTextField.getPassword()); String encoded = new String(Hex.encodeHex(digester.digest(pass.getBytes("UTF-8")))); user.setPassword(encoded); } catch (UnsupportedEncodingException e1) { throw new RuntimeException(e1); } } public void changedUpdate(DocumentEvent e) { textChanged(e); } public void insertUpdate(DocumentEvent e) { textChanged(e); } public void removeUpdate(DocumentEvent e) { textChanged(e); } }); this.fullNameTextField = new JTextField(); this.fullNameTextField.setText(user.getFullName()); this.fullNameLabel = new JLabel("Full name"); this.fullNameTextField.getDocument().addDocumentListener(new DocumentListener() { public void textChanged(DocumentEvent e) { user.setFullName(fullNameTextField.getText()); } public void changedUpdate(DocumentEvent e) { textChanged(e); } public void insertUpdate(DocumentEvent e) { textChanged(e); } public void removeUpdate(DocumentEvent e) { textChanged(e); } }); this.emailTextField = new JTextField(); this.emailTextField.setText(user.getEmail()); this.emailLabel = new JLabel("Email"); this.emailTextField.getDocument().addDocumentListener(new DocumentListener() { public void textChanged(DocumentEvent e) { user.setEmail(emailTextField.getText()); } public void changedUpdate(DocumentEvent e) { textChanged(e); } public void insertUpdate(DocumentEvent e) { textChanged(e); } public void removeUpdate(DocumentEvent e) { textChanged(e); } }); this.availableGroupsLabel = new JLabel("Available Groups"); this.availableGroupsListModel = new GroupsListModel(user, workspace, false); this.availableGroupsList = new JList(this.availableGroupsListModel); this.availableGroupsList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); this.availableGroupsList.setCellRenderer(new DefaultListCellRenderer() { final JTree dummyTree = new JTree(); final WorkspaceTreeCellRenderer delegate = new WorkspaceTreeCellRenderer(); @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { return delegate.getTreeCellRendererComponent(dummyTree, value, isSelected, false, true, 0, cellHasFocus); } }); this.availableGroupsScrollPane = new JScrollPane(this.availableGroupsList); this.currentGroupsLabel = new JLabel("Current Memberships"); this.currentGroupsListModel = new GroupsListModel(user, workspace, true); this.currentGroupsList = new JList(this.currentGroupsListModel); this.currentGroupsList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); this.currentGroupsList.setCellRenderer(new DefaultListCellRenderer() { final JTree dummyTree = new JTree(); final WorkspaceTreeCellRenderer delegate = new WorkspaceTreeCellRenderer(); @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { return delegate.getTreeCellRendererComponent(dummyTree, value, isSelected, false, true, 0, cellHasFocus); } }); this.groupsLabel = new JLabel("Edit user memberships"); this.currentGroupsScrollPane = new JScrollPane(this.currentGroupsList); this.addButton = new JButton(">"); this.addButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Object[] selection = availableGroupsList.getSelectedValues(); if (selection.length == 0) { return; } try { workspace.begin("Add user to groups"); for (Object object : selection) { ((Group) object).addMember(new GroupMember(user)); } } finally { workspace.commit(); } } }); this.removeButton = new JButton("<"); this.removeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { Object[] selection = currentGroupsList.getSelectedValues(); if (selection.length == 0) { return; } try { workspace.begin("Remove user from groups"); Map<Group, GroupMember> toRemove = new ArrayMap<Group, GroupMember>(); for (Object object : selection) { for (GroupMember membership : ((Group) object).getChildren(GroupMember.class)) { if (membership.getUser().getUUID().equals(user.getUUID())) { toRemove.put((Group) object, membership); } } } for (Entry<Group, GroupMember> entry : toRemove.entrySet()) { entry.getKey().removeMember(entry.getValue()); } } finally { workspace.commit(); } } }); Action deleteAction = new DeleteFromTreeAction(this.workspace, this.user, this.panel, this.workspace.getSession().getContext()); this.toolbarBuilder.add(deleteAction, "Delete this user", WabitIcons.DELETE_ICON_32); // Panel building time JPanel namePassPanel = new JPanel(new MigLayout()); namePassPanel.add(this.loginLabel, "align right, gaptop 20"); namePassPanel.add(this.loginTextField, "span, wrap, wmin 600"); namePassPanel.add(this.passwordLabel, "align right"); namePassPanel.add(this.passwordTextField, "span, wrap, wmin 600"); namePassPanel.add(this.fullNameLabel, "align right, gaptop 20"); namePassPanel.add(this.fullNameTextField, "span, wrap, wmin 600"); namePassPanel.add(this.emailLabel, "align right"); namePassPanel.add(this.emailTextField, "span, wrap, wmin 600"); this.panel.add(namePassPanel, "north"); this.panel.add(this.groupsLabel, "span, wrap, gaptop 20, align center"); JPanel buttonsPanel = new JPanel(new MigLayout()); buttonsPanel.add(this.addButton, "wrap"); buttonsPanel.add(this.removeButton); JPanel availablePanel = new JPanel(new MigLayout()); availablePanel.add(this.availableGroupsLabel, "wrap, align center"); availablePanel.add(this.availableGroupsScrollPane, "wmin 300"); JPanel currentPanel = new JPanel(new MigLayout()); currentPanel.add(this.currentGroupsLabel, "wrap, align center"); currentPanel.add(this.currentGroupsScrollPane, "wmin 300"); this.panel.add(availablePanel); this.panel.add(buttonsPanel, "shrink, span 1 2"); this.panel.add(currentPanel); }