List of usage examples for com.jgoodies.forms.layout CellConstraints CellConstraints
public CellConstraints()
From source file:ca.phon.app.query.QueryInfoPanel.java
License:Open Source License
private void init() { setLayout(new BorderLayout()); starBox = new StarBox(IconSize.SMALL); starBox.addActionListener(new ActionListener() { @Override//from w w w . j a va 2s . com public void actionPerformed(ActionEvent e) { toggleStarred(); } }); // query name nameLabel = new JXLabel(); Font nameFont = nameLabel.getFont().deriveFont(Font.BOLD, 14.0f); nameLabel.setFont(nameFont); final ImageIcon searchIcon = IconManager.getInstance().getIcon("actions/system-search", IconSize.SMALL); final PhonUIAction openAction = new PhonUIAction(this, "onOpenQuery"); openAction.putValue(PhonUIAction.NAME, "Open Query"); openAction.putValue(PhonUIAction.SMALL_ICON, searchIcon); openAction.putValue(PhonUIAction.SHORT_DESCRIPTION, "Open query in editor"); openButton = new JButton(openAction); nameField = new JTextField(); nameField.setFont(nameFont); uuidLabel = new JLabel(); dateLabel = new JLabel(); commentsArea = new JTextArea(); commentsArea.setRows(5); commentsArea.setLineWrap(true); commentsArea.setEditable(false); commentsArea.setFont(Font.getFont("dialog")); final JScrollPane commentsLabelScroller = new JScrollPane(commentsArea); // layout form components final FormLayout layout = new FormLayout("right:pref, 3dlu, fill:pref:grow, right:pref", "pref, 3dlu, pref, 3dlu, pref, 3dlu, top:pref, fill:pref:grow"); final CellConstraints cc = new CellConstraints(); infoSection = new JPanel(layout); infoSection.setBorder(BorderFactory.createTitledBorder("Information")); infoSection.add(starBox, cc.xy(1, 1)); infoSection.add(nameLabel, cc.xy(3, 1)); infoSection.add(openButton, cc.xy(4, 1)); infoSection.add(new JLabel("UUID:"), cc.xy(1, 3)); infoSection.add(uuidLabel, cc.xyw(3, 3, 2)); infoSection.add(new JLabel("Date:"), cc.xy(1, 5)); infoSection.add(dateLabel, cc.xyw(3, 5, 2)); infoSection.add(new JLabel("Comments:"), cc.xy(1, 7)); infoSection.add(commentsLabelScroller, cc.xywh(3, 7, 2, 2)); resultsModel = new ResultSetTableModel(project, null); resultsModel.addPropertyChangeListener(bgTaskPropertyListener); resultsTable = new JXTable(resultsModel); resultsTable.getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION); resultsTable.addMouseListener(resultsMouseListener); resultsRowSorter = new TableRowSorter<ResultSetTableModel>(resultsModel); resultsRowSorter.setSortsOnUpdates(true); final RowSorter.SortKey sortKey = new RowSorter.SortKey(ResultSetTableModel.Columns.ID.ordinal(), SortOrder.ASCENDING); resultsRowSorter.setSortKeys(Collections.singletonList(sortKey)); resultsTable.setRowSorter(resultsRowSorter); resultsTable.setColumnControlVisible(true); resultsTable.addHighlighter(HighlighterFactory.createSimpleStriping()); resultsTable.setVisibleRowCount(10); // remove selection column resultsTable.getColumnModel().removeColumn(resultsTable.getColumn(0)); JScrollPane resultsScroller = new JScrollPane(resultsTable); final ImageIcon reportIcon = IconManager.getInstance().getIcon("mimetypes/x-office-spreadsheet", IconSize.SMALL); final PhonUIAction reportAction = new PhonUIAction(this, "onReport"); reportAction.putValue(PhonUIAction.NAME, "Report"); reportAction.putValue(PhonUIAction.SHORT_DESCRIPTION, "Create report"); reportAction.putValue(PhonUIAction.SMALL_ICON, reportIcon); reportButton = new JButton(reportAction); busyLabel = new JXBusyLabel(new Dimension(16, 16)); busyLabel.setBusy(false); hideResultsBox = new JCheckBox("Hide empty result sets"); hideResultsBox.setSelected(false); hideResultsBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { toggleRowFilter(); } }); // system preference openEditorBox = new JCheckBox("Open session with result set"); openEditorBox.setSelected(true); resultsSection = new JPanel(new BorderLayout()); resultsSection.setBorder(BorderFactory.createTitledBorder("Results")); final FormLayout topLayout = new FormLayout("pref, left:pref, left:pref, fill:pref:grow, right:pref", "pref"); final JPanel topResultsPanel = new JPanel(); topResultsPanel.setLayout(topLayout); topResultsPanel.add(busyLabel, cc.xy(1, 1)); topResultsPanel.add(hideResultsBox, cc.xy(2, 1)); topResultsPanel.add(openEditorBox, cc.xy(3, 1)); topResultsPanel.add(reportButton, cc.xy(5, 1)); resultsSection.add(topResultsPanel, BorderLayout.NORTH); resultsSection.add(resultsScroller, BorderLayout.CENTER); openButton.setEnabled(false); reportButton.setEnabled(false); add(infoSection, BorderLayout.NORTH); add(resultsSection, BorderLayout.CENTER); }
From source file:ca.phon.app.query.QueryRunnerPanel.java
License:Open Source License
private void init() { setLayout(new BorderLayout()); // top panel//from w w w.j ava 2 s . co m FormLayout topLayout = new FormLayout("pref, 3dlu, left:pref, left:pref, fill:pref:grow, pref, right:pref", "pref"); CellConstraints cc = new CellConstraints(); topPanel = new JPanel(topLayout); saveButton = new JButton("Save results"); ImageIcon saveIcon = IconManager.getInstance().getIcon("actions/document-save-as", IconSize.SMALL); saveButton.setIcon(saveIcon); saveButton.setEnabled(false); saveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { showSaveQueryDialog(); } }); reportButton = new JButton("Report"); ImageIcon ssIcon = IconManager.getInstance().getIcon("mimetypes/x-office-spreadsheet", IconSize.SMALL); reportButton.setIcon(ssIcon); reportButton.setEnabled(false); reportButton.setVisible(true); reportButton.addActionListener((e) -> { // show menu final JMenu menu = new JMenu(); final ReportLibrary library = new ReportLibrary(); library.setupMenu(tempProject, query.getUUID().toString(), menu); menu.getPopupMenu().show(reportButton, 0, reportButton.getHeight()); }); hideRowsBox = new JCheckBox("Hide empty results"); hideRowsBox.setEnabled(false); hideRowsBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (hideRowsBox.isSelected()) { final RowFilter<RunnerTableModel, Integer> filter = RowFilter.regexFilter("[1-9][0-9]*", 3); resultsTableSorter.setRowFilter(filter); } else { resultsTableSorter.setRowFilter(null); } } }); openEditorBox = new JCheckBox("Open session with results"); openEditorBox.setSelected(true); openEditorBox.setVisible(false); busyLabel = new JXBusyLabel(new Dimension(16, 16)); busyLabel.setBusy(true); String labelText = "Completed: 0/" + tableModel.getRowCount(); completedLabel = new JLabel(labelText); topPanel.add(completedLabel, cc.xy(3, 1)); topPanel.add(busyLabel, cc.xy(1, 1)); topPanel.add(openEditorBox, cc.xy(4, 1)); topPanel.add(saveButton, cc.xy(6, 1)); topPanel.add(reportButton, cc.xy(7, 1)); // table resultsTable = new JXTable(tableModel); resultsTable.addHighlighter(HighlighterFactory.createSimpleStriping()); resultsTable.setRowSorter(resultsTableSorter); resultsTable.getColumn(1).setCellRenderer(statusCellRenderer); resultsTable.getColumn(2).setCellRenderer(progressCellRenderer); resultsTable.setColumnControlVisible(true); resultsTable.setVisibleRowCount(15); resultsTable.packAll(); resultsTable.addMouseListener(tableMouseListener); add(new JScrollPane(resultsTable), BorderLayout.CENTER); add(topPanel, BorderLayout.NORTH); }
From source file:ca.phon.app.query.report.GroupSectionPanel.java
License:Open Source License
private void init() { super.setInformationText(getClass().getName() + ".info", INFO_TEXT); Group gt = getSection();/*from w w w . j a v a2s . c o m*/ FormLayout layout = new FormLayout("5dlu, fill:pref:grow", "pref, pref"); JPanel panel = new JPanel(layout); CellConstraints cc = new CellConstraints(); printSessionInfoBox = new JCheckBox("Include session information"); printSessionInfoBox.setSelected(gt.isPrintSessionHeader()); printSessionInfoBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { getSection().setPrintSessionHeader(printSessionInfoBox.isSelected()); printParticipantInfoBox.setEnabled(printSessionInfoBox.isSelected()); } }); printParticipantInfoBox = new JCheckBox("Include participant information"); printParticipantInfoBox.setSelected(gt.isPrintParticipantInformation()); printParticipantInfoBox.setEnabled(printSessionInfoBox.isSelected()); printParticipantInfoBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { getSection().setPrintParticipantInformation(printParticipantInfoBox.isSelected()); } }); panel.add(printSessionInfoBox, cc.xyw(1, 1, 2)); panel.add(printParticipantInfoBox, cc.xy(2, 2)); panel.setBorder(BorderFactory.createTitledBorder("Options")); add(panel, BorderLayout.CENTER); }
From source file:ca.phon.app.query.report.InventorySectionPanel.java
License:Open Source License
private void init() { super.setInformationText(getClass().getName() + ".info", INFO_TEXT); InventorySection invData = getSection(); caseSensitiveBox = new JCheckBox("Case sensitive"); caseSensitiveBox.setSelected(invData.isCaseSensitive()); caseSensitiveBox.addActionListener(new ActionListener() { @Override/*from w ww . j av a2 s. c o m*/ public void actionPerformed(ActionEvent arg0) { getSection().setCaseSensitive(caseSensitiveBox.isSelected()); } }); ignoreDiacriticsBox = new JCheckBox("Ignore diacritics (i.e., diacritics are removed from result values)"); ignoreDiacriticsBox.setSelected(invData.isIgnoreDiacritics()); ignoreDiacriticsBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { getSection().setIgnoreDiacritics(ignoreDiacriticsBox.isSelected()); } }); groupByFormatBox = new JCheckBox( "Group results by format (e.g., for 'Data Tiers' queries this will group results by tier)"); groupByFormatBox.setSelected(invData.isGroupByFormat()); groupByFormatBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { getSection().setGroupByFormat(groupByFormatBox.isSelected()); } }); includeResultValueBox = new JCheckBox("Include result value (i.e., data matched in the result set)"); includeResultValueBox.setSelected(invData.isIncludeResultValue()); includeResultValueBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { getSection().setIncludeResultValue(includeResultValueBox.isSelected()); } }); includeMetadataBox = new JCheckBox("Include metadata in result value when counting"); includeMetadataBox.setSelected(invData.isIncludeMetadata()); includeMetadataBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { getSection().setIncludeMetadata(includeMetadataBox.isSelected()); } }); includeExcludedBox = new JCheckBox("Include excluded results"); includeExcludedBox.setSelected(invData.isIncludeExcluded()); includeExcludedBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { getSection().setIncludeExcluded(includeExcludedBox.isSelected()); } }); JPanel resultFormatPanel = new JPanel(new GridLayout(0, 1)); resultFormatPanel.setBorder(BorderFactory.createTitledBorder("Result Data")); resultFormatPanel.add(includeResultValueBox); resultFormatPanel.add(includeMetadataBox); resultFormatPanel.add(includeExcludedBox); JPanel dataOptionsPanel = new JPanel(new GridLayout(0, 1)); dataOptionsPanel.setBorder(BorderFactory.createTitledBorder("Options")); dataOptionsPanel.add(caseSensitiveBox); dataOptionsPanel.add(ignoreDiacriticsBox); JPanel groupingOptions = new JPanel(new GridLayout(0, 1)); groupingOptions.setBorder(BorderFactory.createTitledBorder("Grouping")); groupingOptions.add(groupByFormatBox); FormLayout layout = new FormLayout("fill:pref:grow", "pref, pref, pref"); CellConstraints cc = new CellConstraints(); optionsPanel = new JPanel(layout); optionsPanel.add(dataOptionsPanel, cc.xy(1, 2)); optionsPanel.add(resultFormatPanel, cc.xy(1, 1)); optionsPanel.add(groupingOptions, cc.xy(1, 3)); add(optionsPanel, BorderLayout.CENTER); }
From source file:ca.phon.app.query.report.ReportEditor.java
License:Open Source License
private void initPanel() { CellConstraints cc = new CellConstraints(); setLayout(new BorderLayout()); panels = new JPanel(new CardLayout()); ImageIcon addIcon = IconManager.getInstance().getIcon("actions/list-add", IconSize.XSMALL); ImageIcon removeIcon = IconManager.getInstance().getIcon("actions/list-remove", IconSize.XSMALL); ImageIcon upIcon = IconManager.getInstance().getIcon("actions/go-up", IconSize.XSMALL); ImageIcon downIcon = IconManager.getInstance().getIcon("actions/go-down", IconSize.XSMALL); ImageIcon saveIcon = IconManager.getInstance().getIcon("actions/document-save", IconSize.XSMALL); ImageIcon openIcon = IconManager.getInstance().getIcon("actions/document-open", IconSize.XSMALL); ImageIcon newIcon = IconManager.getInstance().getIcon("actions/document-new", IconSize.XSMALL); addSectionButton = new JButton(addIcon); addSectionButton.setToolTipText("Add section"); addSectionButton.addActionListener(new ActionListener() { @Override/*from w w w. ja v a 2s .c om*/ public void actionPerformed(ActionEvent arg0) { JPopupMenu menu = createContextMenu(); menu.show(addSectionButton, 0, 0); } }); removeSectionButton = new JButton(removeIcon); removeSectionButton.setToolTipText("Remove section"); removeSectionButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { TreePath tp = reportTree.getSelectionPath(); if (tp != null) { removeSectionAtPath(tp); } } }); moveUpButton = new JButton(upIcon); moveUpButton.setToolTipText("Move section up"); moveUpButton.setEnabled(false); moveUpButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { TreePath tp = reportTree.getSelectionPath(); if (tp != null) { moveSectionUp(tp); } } }); moveDownButton = new JButton(downIcon); moveDownButton.setToolTipText("Move section down"); moveDownButton.setEnabled(false); moveDownButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { TreePath tp = reportTree.getSelectionPath(); if (tp != null) { moveSectionDown(tp); } } }); saveButton = new JButton(saveIcon); saveButton.setToolTipText("Save report design..."); saveButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { saveReportFormat(); } }); newButton = new JButton(newIcon); newButton.setToolTipText("New empty report design..."); newButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { newReportFormat(); } }); openButton = new JButton(openIcon); openButton.setToolTipText("Open report design..."); openButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { openReportFormat(); } }); FormLayout btnLayout = new FormLayout( "left:pref, left:pref, left:pref, fill:pref:grow, right:pref, right:pref" + ("," + removeSectionButton.getPreferredSize().width + "px"), "pref"); JPanel btnPanel = new JPanel(btnLayout); // if(PhonUtilities.isDebugMode()) { btnPanel.add(newButton, cc.xy(1, 1)); btnPanel.add(saveButton, cc.xy(2, 1)); btnPanel.add(openButton, cc.xy(3, 1)); // } btnPanel.add(addSectionButton, cc.xy(5, 1)); btnPanel.add(removeSectionButton, cc.xy(6, 1)); FormLayout btnLayout2 = new FormLayout("pref", "pref, 3dlu, pref, fill:pref:grow"); JPanel btnPanel2 = new JPanel(btnLayout2); btnPanel2.add(moveUpButton, cc.xy(1, 1)); btnPanel2.add(moveDownButton, cc.xy(1, 3)); JPanel leftPanel = new JPanel(new BorderLayout()); reportTreeModel = new ReportTreeModel(report); reportTree = new JXTree(reportTreeModel); reportTree.addMouseListener(new TreeMouseListener()); reportTree.expandAll(); reportTree.setCellRenderer(new ReportTreeCellRenderer()); reportTree.getSelectionModel().addTreeSelectionListener(new TreeSelectionListener() { @Override public void valueChanged(TreeSelectionEvent e) { Object section = e.getPath().getLastPathComponent(); CardLayout cl = (CardLayout) panels.getLayout(); cl.show(panels, sectionPanels.get(section)); setupMovementButtonsForPath(e.getPath()); } }); ActionMap actionMap = reportTree.getActionMap(); InputMap inputMap = reportTree.getInputMap(WHEN_FOCUSED); KeyStroke ks1 = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0); KeyStroke ks2 = KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0); String remId = "remove_section"; PhonUIAction removeSectionAct = new PhonUIAction(this, "onRemoveSection"); removeSectionAct.putValue(Action.NAME, "Remove section"); actionMap.put(remId, removeSectionAct); inputMap.put(ks1, remId); inputMap.put(ks2, remId); reportTree.setActionMap(actionMap); reportTree.setInputMap(WHEN_FOCUSED, inputMap); leftPanel.add(btnPanel, BorderLayout.NORTH); leftPanel.add(new JScrollPane(reportTree), BorderLayout.CENTER); leftPanel.add(btnPanel2, BorderLayout.EAST); leftPanel.setBorder(BorderFactory.createTitledBorder("Report Outline")); // add(leftPanel, cc.xy(1,1)); SectionPanelFactory panelFactory = new SectionPanelFactory(); addSectionPanel(report, panelFactory); // add(panels, cc.xy(3,1)); FormLayout splitLayout = new FormLayout("300px:nogrow, fill:default:grow", "fill:default:grow"); JPanel splitPane = new JPanel(splitLayout); splitPane.add(leftPanel, cc.xy(1, 1)); // JScrollPane panelsScroller = new JScrollPane(panels); // panelsScroller.setBorder(BorderFactory.createEmptyBorder()); splitPane.add(panels, cc.xy(2, 1)); // JSplitPane splitPane = new JSplitPane(); // splitPane.setLeftComponent(leftPanel); // splitPane.setRightComponent(panels); // splitPane.setDividerLocation(300); add(splitPane, BorderLayout.CENTER); // setup bottom panel FormLayout btmLayout = new FormLayout("left:pref, pref, fill:pref:grow, right:pref", "pref, pref"); JPanel btmPanel = new JPanel(btmLayout); reportTree.setSelectionPath(new TreePath(report)); }
From source file:ca.phon.app.query.report.ResultListingSectionPanel.java
License:Open Source License
private void init() { // get absolute locations of icons String addImgRelPath = "data" + File.separator + "icons" + File.separator + "16x16" + File.separator + "actions" + File.separator + "list-add.png"; File addImgFile = new File(addImgRelPath); String addImgURI = addImgFile.toURI().toASCIIString(); String removeImgRelPath = "data" + File.separator + "icons" + File.separator + "16x16" + File.separator + "actions" + File.separator + "list-remove.png"; File remImgFile = new File(removeImgRelPath); String remImgURI = remImgFile.toURI().toASCIIString(); String infoTxt = INFO_TEXT.replaceAll("\\$\\{field_add_img\\}", addImgURI) .replaceAll("\\$\\{field_remove_img\\}", remImgURI); super.setInformationText(getClass().getName() + ".info", infoTxt); // list panel FormLayout listLayout = new FormLayout("fill:pref:grow, pref", "pref, fill:pref:grow"); JPanel listPanel = new JPanel(listLayout); CellConstraints cc = new CellConstraints(); ResultListing resList = getSection(); fieldList = new JXList(resList.getField().toArray(new ResultListingField[0])); fieldList.setCellRenderer(new FieldListCellRenderer()); fieldList.addListSelectionListener(new FieldListSelectionListener()); fieldList.setMinimumSize(new Dimension(200, 0)); ActionMap fieldActionMap = fieldList.getActionMap(); InputMap fieldInputMap = fieldList.getInputMap(JComponent.WHEN_FOCUSED); PhonUIAction showListAction = new PhonUIAction(this, "onShowPopup"); ImageIcon addIcn = IconManager.getInstance().getIcon("actions/list-add", IconSize.XSMALL); showListAction.putValue(PhonUIAction.SMALL_ICON, addIcn); showListAction.putValue(PhonUIAction.SHORT_DESCRIPTION, "Add field..."); addFieldButton = new JButton(showListAction); PhonUIAction removeFieldAction = new PhonUIAction(this, "onDelField"); ImageIcon delIcn = IconManager.getInstance().getIcon("actions/list-remove", IconSize.XSMALL); removeFieldAction.putValue(PhonUIAction.SMALL_ICON, delIcn); removeFieldAction.putValue(PhonUIAction.SHORT_DESCRIPTION, "Remove selected field"); delFieldButton = new JButton(removeFieldAction); String delActID = "_remove_field_"; fieldActionMap.put(delActID, removeFieldAction); KeyStroke delKs1 = KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0); KeyStroke delKs2 = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0); fieldInputMap.put(delKs1, delActID); fieldInputMap.put(delKs2, delActID); PhonUIAction moveFieldUpAction = new PhonUIAction(this, "onMoveFieldUp"); ImageIcon upIcn = IconManager.getInstance().getIcon("actions/go-up", IconSize.XSMALL); moveFieldUpAction.putValue(PhonUIAction.SMALL_ICON, upIcn); moveFieldUpAction.putValue(PhonUIAction.SHORT_DESCRIPTION, "Move selected field up"); upFieldButton = new JButton(moveFieldUpAction); PhonUIAction moveFieldDownAction = new PhonUIAction(this, "onMoveFieldDown"); ImageIcon downIcn = IconManager.getInstance().getIcon("actions/go-down", IconSize.XSMALL); moveFieldDownAction.putValue(PhonUIAction.SMALL_ICON, downIcn); moveFieldDownAction.putValue(PhonUIAction.SHORT_DESCRIPTION, "Move selected field down"); downFieldButton = new JButton(moveFieldDownAction); FormLayout topBtnLayout = new FormLayout( "fill:pref:grow, right:pref, right:pref, " + (upFieldButton.getPreferredSize().width) + "px", "pref"); JPanel topBtnPanel = new JPanel(topBtnLayout); FormLayout sideBtnLayout = new FormLayout("pref", "pref, 3dlu, pref, fill:pref:grow"); JPanel sideBtnPanel = new JPanel(sideBtnLayout); JScrollPane listScroller = new JScrollPane(fieldList); topBtnPanel.add(addFieldButton, cc.xy(2, 1)); topBtnPanel.add(delFieldButton, cc.xy(3, 1)); sideBtnPanel.add(upFieldButton, cc.xy(1, 1)); sideBtnPanel.add(downFieldButton, cc.xy(1, 3)); listPanel.add(topBtnPanel, cc.xyw(1, 1, 2)); listPanel.add(sideBtnPanel, cc.xywh(2, 2, 1, 1)); listPanel.add(listScroller, cc.xy(1, 2)); // field form fieldOptionsPanel = new JPanel(new BorderLayout()); fieldOptionsPanel.setBorder(BorderFactory.createTitledBorder("Options")); namePanel = new JPanel(new FormLayout("left:pref, 3dlu, fill:pref:grow", "pref")); nameField = new JTextField(); nameField.getDocument().addDocumentListener(new NameFieldListener()); namePanel.add(new JLabel("Field name:"), cc.xy(1, 1)); namePanel.add(nameField, cc.xy(3, 1)); fieldOptionsPanel.add(namePanel, BorderLayout.NORTH); // format selection tableOptBox = new JRadioButton("Table"); listOptBox = new JRadioButton("List"); ButtonGroup btnGroup = new ButtonGroup(); FormatHandler formatHandler = new FormatHandler(); tableOptBox.setSelected(resList.getFormat() == ResultListingFormatType.TABLE); tableOptBox.addActionListener(formatHandler); listOptBox.setSelected(!tableOptBox.isSelected()); listOptBox.addActionListener(formatHandler); includeExcludedBox = new JCheckBox("Include excluded results"); includeExcludedBox.setSelected(getSection().isIncludeExcluded()); includeExcludedBox.addActionListener(new ActionListener() { @Override//from w ww.j a v a 2s . c o m public void actionPerformed(ActionEvent arg0) { getSection().setIncludeExcluded(includeExcludedBox.isSelected()); } }); btnGroup.add(tableOptBox); btnGroup.add(listOptBox); FormLayout splitLayout = new FormLayout("200px:nogrow, fill:default:grow", "fill:default:grow"); fieldPanel = new JPanel(splitLayout); fieldPanel.add(listPanel, cc.xy(1, 1)); fieldPanel.add(fieldOptionsPanel, cc.xy(2, 1)); fieldPanel.setBorder(BorderFactory.createTitledBorder("Field Outline")); JPanel formatPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); formatPanel.add(new JLabel("Display data as:")); formatPanel.add(tableOptBox); formatPanel.add(listOptBox); formatPanel.add(includeExcludedBox); formatPanel.setBorder(BorderFactory.createTitledBorder("Options")); JPanel cPanel = new JPanel(new BorderLayout()); cPanel.add(formatPanel, BorderLayout.NORTH); cPanel.add(fieldPanel, BorderLayout.CENTER); add(cPanel, BorderLayout.CENTER); nameField.setEnabled(false); }
From source file:ca.phon.app.query.ResultSetEditor.java
License:Open Source License
private void init() { setupToolbar();// ww w . j a v a 2 s . c om setupResultTable(); final JPanel resultsPanel = new JPanel(); resultsPanel.setLayout(new BorderLayout()); final FormLayout topLayout = new FormLayout("left:pref, right:pref:grow", "pref"); final CellConstraints cc = new CellConstraints(); final JPanel topPanel = new JPanel(topLayout); topPanel.add(showExcludedBox, cc.xy(1, 1)); topPanel.add(tableSearchField, cc.xy(2, 1)); final JScrollPane tblScroller = new JScrollPane(resultTable, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); resultsPanel.add(topPanel, BorderLayout.NORTH); resultsPanel.add(tblScroller, BorderLayout.CENTER); setLayout(new BorderLayout()); add(toolbar, BorderLayout.NORTH); add(resultsPanel, BorderLayout.CENTER); add(statusBar, BorderLayout.SOUTH); updateStatus(); }
From source file:ca.phon.app.query.SaveQueryDialog.java
License:Open Source License
private void init() { // final PathExpander pe = new PathExpander(); nameField = new JTextField(); nameField.getDocument().addDocumentListener(new DocumentListener() { @Override//from w w w . j a v a 2 s .co m 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:ca.phon.app.session.editor.NavigationPanel.java
License:Open Source License
private void init() { final ButtonGroup btnGroup = new ButtonGroup(); final List<JButton> buttons = (new SegmentedButtonBuilder<JButton>(JButton::new)).createSegmentedButtons(4, btnGroup);//www . j av a 2 s .co m final Action firstRecordAction = new FirstRecordAction(getEditor()); firstRecordButton = buttons.get(0); firstRecordButton.setAction(firstRecordAction); firstRecordButton.setText(null); firstRecordButton.setFocusable(false); final Action lastRecordAction = new LastRecordAction(getEditor()); lastRecordButton = buttons.get(3); lastRecordButton.setAction(lastRecordAction); lastRecordButton.setText(null); lastRecordButton.setFocusable(false); final Action prevRecordAction = new PreviousRecordAction(getEditor()); prevRecordButton = buttons.get(1); prevRecordButton.setAction(prevRecordAction); prevRecordButton.setText(null); prevRecordButton.setFocusable(false); final Action nextRecordAction = new NextRecordAction(getEditor()); nextRecordButton = buttons.get(2); nextRecordButton.setAction(nextRecordAction); nextRecordButton.setText(null); nextRecordButton.setFocusable(false); recordNumberField = new RecordNumberField(); recordNumberField.setMinNumber(1); recordNumberField.setMaxNumber(getEditor().getDataModel().getRecordCount()); recordNumberField.setColumns(3); recordNumberField.setEditable(true); recordNumberField.setText("1"); recordNumberField.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent arg0) { } @Override public void focusGained(FocusEvent arg0) { recordNumberField.selectAll(); } }); recordNumberField.addKeyListener(new KeyListener() { @Override public void keyTyped(KeyEvent e) { } @Override public void keyReleased(KeyEvent e) { final String txt = recordNumberField.getText(); if (txt.length() > 0) { final Integer v = Integer.parseInt(txt); if (getEditor().getCurrentRecordIndex() != v - 1) getEditor().setCurrentRecordIndex(v - 1); } } @Override public void keyPressed(KeyEvent e) { } }); final PhonUIAction gotoRecordAct = new PhonUIAction(this, "gotoRecord"); recordNumberField.setAction(gotoRecordAct); numRecordsLabel = new JLabel(""); numRecordsLabel.setText("" + getEditor().getDataModel().getRecordCount() + " "); numRecordsLabel.setOpaque(false); currentTierLabel = new JLabel(""); currentTierLabel.setOpaque(false); currentCharPosLabel = new JLabel(""); currentCharPosLabel.setOpaque(false); FormLayout layout = new FormLayout("pref, pref, pref, pref, 5dlu, pref", "pref"); setLayout(layout); CellConstraints cc = new CellConstraints(); final JComponent btnComp = (new SegmentedButtonBuilder<JButton>(JButton::new)) .createLayoutComponent(buttons); JLabel rl = new JLabel(" Record: "); add(rl, cc.xy(1, 1)); add(recordNumberField, cc.xy(2, 1)); JLabel ol = new JLabel(" of "); add(ol, cc.xy(3, 1)); add(numRecordsLabel, cc.xy(4, 1)); add(btnComp, cc.xy(6, 1)); }
From source file:ca.phon.app.session.editor.RecordSortDialog.java
License:Open Source License
private void init() { setLayout(new BorderLayout()); header = new DialogHeader("Sort Records", "Sort records by one or more tiers."); createComboBoxes();//from ww w . j av a 2 s . c o m createCheckBoxes(); FormLayout layout = new FormLayout("3dlu, pref, fill:pref:grow, pref, 3dlu", "pref, pref, pref, pref, 3dlu"); JPanel formPanel = new JPanel(layout); CellConstraints cc = new CellConstraints(); for (int i = 0; i < 3; i++) { String lblText = (i == 0 ? "Sort by:" : "then by:"); formPanel.add(new JLabel(lblText), cc.xy(2, i + 1)); formPanel.add(comboBoxes[i], cc.xy(3, i + 1)); formPanel.add(checkBoxes[i], cc.xy(4, i + 1)); } PhonUIAction okAct = new PhonUIAction(this, "onOk"); okAct.putValue(Action.NAME, "Ok"); okAct.putValue(Action.SHORT_DESCRIPTION, "Sort records and close"); okButton = new JButton(okAct); PhonUIAction cancelAct = new PhonUIAction(this, "onCancel"); cancelAct.putValue(Action.NAME, "Cancel"); cancelAct.putValue(Action.SHORT_DESCRIPTION, "Close dialog"); cancelButton = new JButton(cancelAct); // bind cancel action to ESC key KeyStroke escKs = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); InputMap inputMap = getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); ActionMap actionMap = getRootPane().getActionMap(); actionMap.put("_CANCEL_DIALOG_", cancelAct); inputMap.put(escKs, "_CANCEL_DIALOG_"); getRootPane().setInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW, inputMap); getRootPane().setActionMap(actionMap); JComponent btnBar = ButtonBarBuilder.buildOkCancelBar(okButton, cancelButton); formPanel.add(btnBar, cc.xyw(2, 4, 3)); add(header, BorderLayout.NORTH); add(formPanel, BorderLayout.CENTER); super.getRootPane().setDefaultButton(okButton); // setup default button // add(btnBar, BorderLayout.SOUTH); }