List of usage examples for com.jgoodies.forms.layout CellConstraints xy
public CellConstraints xy(int col, int row)
Examples:
cc.xy(1, 1); cc.xy(1, 3);
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 ww . j av a2s. c o m 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// w w w . j a va 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();/*from w ww .ja v a 2 s . co m*/ 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/* w ww . j av a 2 s . c o 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);/*from ww w. j av a 2s . c o 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 w ww . jav 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); }
From source file:ca.phon.app.session.editor.SessionEditorToolbar.java
License:Open Source License
private void init() { final FormLayout layout = new FormLayout( "3dlu, pref, 3dlu, pref, 3dlu, pref, " + "fill:pref:grow, right:pref, 5dlu, right:pref, 3dlu", "3dlu, pref"); setLayout(layout);/* ww w. ja v a 2s . c om*/ final CellConstraints cc = new CellConstraints(); // save button final SaveSessionAction saveAction = new SaveSessionAction(getEditor()); saveButton = new JButton(saveAction); saveButton.setText(null); saveButton.setEnabled(getEditor().isModified()); add(saveButton, cc.xy(2, 2)); final EditorAction modifiedAct = new DelegateEditorAction(this, "onModifiedChanged"); getEditor().getEventManager().registerActionForEvent(EditorEventType.MODIFIED_FLAG_CHANGED, modifiedAct); final ButtonGroup btnGrp = new ButtonGroup(); final List<JButton> buttons = SegmentedButtonBuilder.createSegmentedButtons(3, btnGrp); final NewRecordAction newRecordAct = new NewRecordAction(getEditor()); buttons.get(0).setAction(newRecordAct); buttons.get(0).setText(null); buttons.get(0).setFocusable(false); final DuplicateRecordAction dupRecordAct = new DuplicateRecordAction(getEditor()); buttons.get(1).setAction(dupRecordAct); buttons.get(1).setText(null); buttons.get(1).setFocusable(false); final DeleteRecordAction delRecordAct = new DeleteRecordAction(getEditor()); buttons.get(2).setAction(delRecordAct); buttons.get(2).setText(null); buttons.get(2).setFocusable(false); final JComponent btnComp = SegmentedButtonBuilder.createLayoutComponent(buttons); add(btnComp, cc.xy(6, 2)); navigationPanel = new NavigationPanel(getEditor()); add(navigationPanel, cc.xy(8, 2)); quickSearch = new SessionEditorQuickSearch(getEditor()); add(quickSearch.getSearchField(), cc.xy(10, 2)); }
From source file:ca.phon.app.session.editor.TranscriberSelectionDialog.java
License:Open Source License
/** Init display and listeners */ private void initDialog() { // setup layout // layout will be seperated into two sections, existing // and new transcripts FormLayout outerLayout = new FormLayout("3dlu, pref, right:pref:grow, 3dlu", "pref, 3dlu, top:pref:noGrow, 3dlu, pref, 3dlu, fill:pref:grow, 3dlu, pref"); this.getContentPane().setLayout(outerLayout); // create the 'new' panel first FormLayout newLayout = new FormLayout("left:pref:noGrow, 3dlu, fill:pref:grow", "bottom:pref:noGrow, 3dlu, bottom:pref:noGrow, 3dlu, bottom:pref:noGrow, 3dlu, bottom:pref:noGrow, 3dlu, bottom:pref:noGrow, fill:pref:grow"); JPanel newPanel = new JPanel(newLayout); this.newTranscriptButton = new JRadioButton(); this.newTranscriptButton.setText("New Transcriber"); this.newTranscriptButton.setSelected(true); this.newTranscriptButton.addActionListener(new ActionListener() { @Override//from w ww.j a v a 2s. c om public void actionPerformed(ActionEvent arg0) { realNameField.setEnabled(true); usernameField.setEnabled(true); passwordRequiredBox.setEnabled(true); if (passwordRequiredBox.isSelected()) { passwordField.setEnabled(true); checkField.setEnabled(true); } existingUserList.setEnabled(false); } }); this.existingTranscriptButton = new JRadioButton(); this.existingTranscriptButton.setText("Existing Transcriber"); this.existingTranscriptButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { realNameField.setEnabled(false); usernameField.setEnabled(false); passwordRequiredBox.setEnabled(false); passwordField.setEnabled(false); checkField.setEnabled(false); existingUserList.setEnabled(true); } }); ButtonGroup bg = new ButtonGroup(); bg.add(this.newTranscriptButton); bg.add(this.existingTranscriptButton); this.realNameField = new JTextField(); this.usernameField = new JTextField(); this.passwordRequiredBox = new JCheckBox(); this.passwordRequiredBox.setText("Use password"); this.passwordRequiredBox.setSelected(false); this.passwordRequiredBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { passwordField.setEnabled(passwordRequiredBox.isSelected()); checkField.setEnabled(passwordRequiredBox.isSelected()); } }); this.passwordField = new JPasswordField(); this.passwordField.setEnabled(false); this.checkField = new JPasswordField(); this.checkField.setEnabled(false); CellConstraints cc = new CellConstraints(); newPanel.add(new JLabel("Full Name:"), cc.xy(1, 1)); newPanel.add(this.realNameField, cc.xy(3, 1)); newPanel.add(new JLabel("Username:"), cc.xy(1, 3)); newPanel.add(this.usernameField, cc.xy(3, 3)); newPanel.add(this.passwordRequiredBox, cc.xyw(1, 5, 3)); newPanel.add(new JLabel("Password:"), cc.xy(1, 7)); newPanel.add(this.passwordField, cc.xy(3, 7)); newPanel.add(this.checkField, cc.xy(3, 9)); // create the 'existing' panel FormLayout existingLayout = new FormLayout( // just a list "fill:pref:grow", "fill:pref:grow"); JPanel existingPanel = new JPanel(existingLayout); List<String> existingUserData = new ArrayList<String>(); for (Transcriber t : session.getTranscribers()) existingUserData.add(t.getRealName() + " - " + t.getUsername()); this.existingUserList = new JList(existingUserData.toArray()); this.existingUserList.setEnabled(false); existingPanel.add(this.existingUserList, cc.xy(1, 1)); // create the button panel this.okButton = new JButton("OK"); this.okButton.setDefaultCapable(true); this.okButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { if (checkDialog()) { okHandler(); } } }); getRootPane().setDefaultButton(okButton); this.cancelButton = new JButton("Cancel"); this.cancelButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { cancelHandler(); } }); final JComponent bar = ButtonBarBuilder.buildOkCancelBar(okButton, cancelButton); this.getContentPane().add(bar, cc.xy(3, 9)); this.getContentPane().add(this.newTranscriptButton, cc.xy(2, 1)); this.getContentPane().add(newPanel, cc.xyw(2, 3, 2)); this.getContentPane().add(this.existingTranscriptButton, cc.xy(2, 5)); this.getContentPane().add(new JScrollPane(existingPanel), cc.xyw(2, 7, 2)); }
From source file:ca.phon.app.session.editor.view.ipa_lookup.AutoTranscriptionForm.java
License:Open Source License
private void init(Project project, Session t) { FormLayout layout = new FormLayout("fill:pref:grow", "pref, pref"); setLayout(layout);/*from w w w . j a v a 2s . c om*/ CellConstraints cc = new CellConstraints(); overwriteBox = new JCheckBox("Overwrite"); overwriteBox.setSelected(true); setIPATargetBox = new JCheckBox("IPA Target"); setIPATargetBox.setSelected(true); // PhonUIAction toggleSetIPATargetAct = // new PhonUIAction(this, "toggleIPABox", setIPATargetBox); // toggleSetIPATargetAct.putValue(PhonUIAction.NAME, "Auto transcribe IPA Target"); // setIPATargetBox.setAction(toggleSetIPATargetAct); setIPAActualBox = new JCheckBox("IPA Actual"); // PhonUIAction toggleSetIPAActualAct = // new PhonUIAction(this, "toggleIPABox", setIPAActualBox); // toggleSetIPAActualAct.putValue(PhonUIAction.NAME, "Auto transcribe IPA Actual"); // setIPAActualBox.setAction(toggleSetIPAActualAct); // dictBox = new JComboBox(IPADictionary.getAvailableLanguages()); // dictBox.setSelectedItem(IPADictionary.getDefaultLanguage()); // PhonUIAction selectDictionaryAct = // new PhonUIAction(this, "selectDictionary"); // dictBox.setAction(selectDictionaryAct); final SyllabifierLibrary syllabifierLibrary = SyllabifierLibrary.getInstance(); final Language syllLangPref = syllabifierLibrary.defaultSyllabifierLanguage(); Syllabifier defSyllabifier = null; final Iterator<Syllabifier> syllabifiers = syllabifierLibrary.availableSyllabifiers(); List<Syllabifier> sortedSyllabifiers = new ArrayList<Syllabifier>(); while (syllabifiers.hasNext()) { final Syllabifier syllabifier = syllabifiers.next(); if (syllabifier.getLanguage().equals(syllLangPref)) defSyllabifier = syllabifier; sortedSyllabifiers.add(syllabifier); } Collections.sort(sortedSyllabifiers, new SyllabifierComparator()); syllabifierBox = new JComboBox(sortedSyllabifiers.toArray(new Syllabifier[0])); syllabifierBox.setRenderer(new SyllabifierCellRenderer()); if (defSyllabifier != null) syllabifierBox.setSelectedItem(defSyllabifier); FormLayout topLayout = new FormLayout("right:pref, fill:pref:grow", "pref, pref, pref, pref, pref"); JPanel topPanel = new JPanel(); topPanel.setLayout(topLayout); topPanel.setBorder(BorderFactory.createTitledBorder("Tier Options")); topPanel.add(new JLabel("Transcribe:"), cc.xy(1, 2)); topPanel.add(overwriteBox, cc.xy(2, 1)); topPanel.add(setIPATargetBox, cc.xy(2, 2)); topPanel.add(setIPAActualBox, cc.xy(2, 3)); // topPanel.add(new JLabel("IPA Dicitonary:"), cc.xy(1,3)); // topPanel.add(dictBox, cc.xy(2, 3)); topPanel.add(new JLabel("Syllabifier:"), cc.xy(1, 4)); topPanel.add(syllabifierBox, cc.xy(2, 4)); filterPanel = new RecordFilterPanel(project, t); filterPanel.setBorder(BorderFactory.createTitledBorder("Record Selection")); add(topPanel, cc.xy(1, 1)); add(filterPanel, cc.xy(1, 2)); }
From source file:ca.phon.app.session.editor.view.ipa_lookup.RecordLookupPanel.java
License:Open Source License
private void updatePanel() { candidatePanel.removeAll();/* w w w . jav a 2 s .c om*/ groupPanel.removeAll(); final Record r = getRecord(); if (r == null) return; int row = 0; int col = 0; candidatePanel.add(controlPanel, new TierDataConstraint(TierDataConstraint.FLAT_TIER_PREF_COLUMN, row)); ++row; final JLabel transLbl = new JLabel("Transcription"); transLbl.setHorizontalAlignment(SwingConstants.RIGHT); candidatePanel.add(transLbl, new TierDataConstraint(TierDataConstraint.TIER_LABEL_COLUMN, row)); for (int i = 0; i < lookupTier.numberOfGroups(); i++) { final IPAGroupField ipaField = new IPAGroupField(lookupTier, i); ipaField.setFont(FontPreferences.getTierFont()); ipaField.addTierEditorListener(tierListener); candidatePanel.add(ipaField, new TierDataConstraint(TierDataConstraint.GROUP_START_COLUMN + i, row)); } candidatePanel.add(setButton, new TierDataConstraint(TierDataConstraint.GROUP_START_COLUMN + lookupTier.numberOfGroups(), row)); row = 0; col = 0; // create group sections final Tier<Orthography> orthoTier = r.getOrthography(); final TierDataLayout groupLayout = (TierDataLayout) groupPanel.getLayout(); for (int i = 0; i < lookupTier.numberOfGroups(); i++) { if (i > 0) { final JSeparator sep = new JSeparator(SwingConstants.HORIZONTAL); groupPanel.add(sep, new TierDataConstraint(TierDataConstraint.FULL_TIER_COLUMN, row++)); } final JLabel groupLabel = new JLabel("<html><b>Group #" + (i + 1) + "</b></html>"); final JLabel tLbl = new JLabel("Transcription"); tLbl.setHorizontalAlignment(SwingConstants.RIGHT); final JPanel pnl = new JPanel(new BorderLayout()); pnl.setOpaque(false); pnl.add(groupLabel, BorderLayout.WEST); pnl.add(tLbl, BorderLayout.EAST); groupPanel.add(pnl, new TierDataConstraint(TierDataConstraint.TIER_LABEL_COLUMN, row)); final IPAGroupField grpField = new IPAGroupField(lookupTier, i); grpField.setFont(FontPreferences.getTierFont()); grpField.addTierEditorListener(tierListener); final PhonUIAction setGrpAct = new PhonUIAction(this, "onSetGroup", i); setGrpAct.putValue(PhonUIAction.NAME, "Set"); setGrpAct.putValue(PhonUIAction.SHORT_DESCRIPTION, "Set transcription for group " + (i + 1)); final JButton setGrpBtn = new JButton(setGrpAct); final String colLayout = "pref, " + groupLayout.getHorizontalGap() + "px, pref"; final FormLayout formLayout = new FormLayout(colLayout, "pref"); final CellConstraints cc = new CellConstraints(); final JPanel grpPanel = new JPanel(formLayout); grpPanel.setOpaque(false); grpPanel.add(grpField, cc.xy(1, 1)); grpPanel.add(setGrpBtn, cc.xy(3, 1)); groupPanel.add(grpPanel, new TierDataConstraint(TierDataConstraint.FLAT_TIER_PREF_COLUMN, row)); ++row; final int startRows = groupLayout.getRowCount(); final Orthography ortho = orthoTier.getGroup(i); final OptionBoxVisitior visitor = new OptionBoxVisitior(this, groupPanel, row); ortho.accept(visitor); final int endRows = groupLayout.getRowCount(); row += (endRows - startRows); } repaint(); }