Example usage for com.jgoodies.forms.layout CellConstraints CellConstraints

List of usage examples for com.jgoodies.forms.layout CellConstraints CellConstraints

Introduction

In this page you can find the example usage for com.jgoodies.forms.layout CellConstraints CellConstraints.

Prototype

public CellConstraints() 

Source Link

Document

Constructs a default instance of CellConstraints .

Usage

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);/*w w  w .j a v  a 2s. com*/
    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//w w  w. jav  a2  s. co m
        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);/*  w w  w . jav  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 2s  .c o m
    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();
}

From source file:ca.phon.app.session.editor.view.ipa_validation.AutoValidateDialog.java

License:Open Source License

private void init() {
    header = new DialogHeader("Auto-validate Session", "Fill IPA tiers for the session.");

    FormLayout tierLayout = new FormLayout("fill:pref:grow", "pref, pref, pref");
    CellConstraints cc = new CellConstraints();

    JPanel tierPanel = new JPanel(tierLayout);

    validateTargetBox = new JCheckBox("Auto-validate IPA Target");
    validateTargetBox.setSelected(true);

    validateActualBox = new JCheckBox("Auto-validate IPA Actual");
    validateActualBox.setSelected(true);

    overwriteDataBox = new JCheckBox("Overwrite existing data");
    overwriteDataBox.setSelected(false);

    tierPanel.add(validateTargetBox, cc.xy(1, 1));
    tierPanel.add(validateActualBox, cc.xy(1, 2));
    tierPanel.add(overwriteDataBox, cc.xy(1, 3));
    tierPanel.setBorder(BorderFactory.createTitledBorder("Tiers"));

    FormLayout trLayout = new FormLayout("fill:pref:grow", "pref, pref, pref");
    JPanel trPanel = new JPanel(trLayout);

    trGroup = new JXRadioGroup<String>();
    trGroup.setLayoutAxis(BoxLayout.Y_AXIS);

    List<String> trNames = new ArrayList<String>();
    for (Transcriber tr : session.getTranscribers()) {
        trNames.add(getTrDisplayString(tr));
    }/*from  w w w  .j  a  va2  s  .  c o m*/

    //      ITranscriber[] trs = session.getTranscribers().toArray(new ITranscriber[0]);
    trGroup.setValues(trNames.toArray(new String[0]));
    if (trNames.size() > 0)
        trGroup.setSelectedValue(trNames.get(0));

    trPanel.add(new JLabel("If only one IPA transcript exists it is selected."), cc.xy(1, 1));
    trPanel.add(new JLabel("If more than one IPA transcript exists, choose IPA for transcriber:"), cc.xy(1, 2));
    trPanel.add(trGroup, cc.xy(1, 3));

    trPanel.setBorder(BorderFactory.createTitledBorder("IPA Selection"));

    recordFilterPanel = new RecordFilterPanel(project, session);
    recordFilterPanel.setBorder(BorderFactory.createTitledBorder("Record Selection"));
    FormLayout centerLayout = new FormLayout("fill:pref:grow", "pref, pref, pref");
    JPanel centerPanel = new JPanel(centerLayout);

    centerPanel.add(tierPanel, cc.xy(1, 1));
    centerPanel.add(trPanel, cc.xy(1, 2));
    centerPanel.add(recordFilterPanel, cc.xy(1, 3));

    // button bar
    PhonUIAction okAction = new PhonUIAction(this, "onOk");
    okAction.putValue(Action.NAME, "Ok");
    okAction.putValue(Action.SHORT_DESCRIPTION, "Perform auto-validation and close dialog");

    okButton = new JButton(okAction);

    PhonUIAction cancelAction = new PhonUIAction(this, "onCancel");
    cancelAction.putValue(Action.NAME, "Cancel");
    cancelAction.putValue(Action.SHORT_DESCRIPTION, "Cancel auto-validation and close dialog");

    cancelButton = new JButton(cancelAction);

    final JComponent buttonBar = ButtonBarBuilder.buildOkCancelBar(okButton, cancelButton);

    setLayout(new BorderLayout());
    add(header, BorderLayout.NORTH);
    add(centerPanel, BorderLayout.CENTER);
    add(buttonBar, BorderLayout.SOUTH);

    getRootPane().setDefaultButton(okButton);
}

From source file:ca.phon.app.session.editor.view.media_player.PlayCustomSegmentDialog.java

License:Open Source License

private void init() {
    final FormLayout layout = new FormLayout("10dlu, fill:pref:grow",
            "pref, pref, pref, pref, pref, pref, pref, pref, pref, pref");
    final CellConstraints cc = new CellConstraints();
    setLayout(layout);//from  w  ww .  ja  v  a  2 s. c om

    final SessionEditor editor = editorRef.get();
    final Session session = editor.getSession();

    btnGrp = new ButtonGroup();

    currentSegmentBtn = new JRadioButton("Current segment");
    currentSegmentBtn.addActionListener(radioListener);
    currentSegmentBtn.setSelected(true);
    btnGrp.add(currentSegmentBtn);

    contiguousSegmentBtn = new JRadioButton("Speaker turn");
    contiguousSegmentBtn.addActionListener(radioListener);
    btnGrp.add(contiguousSegmentBtn);

    //      periodBtn = new JRadioButton("Adjacency sequence");
    //      periodBtn.addActionListener(radioListener);
    //      btnGrp.add(periodBtn);

    recordRangeBtn = new JRadioButton("Record range");
    recordRangeBtn.addActionListener(radioListener);
    btnGrp.add(recordRangeBtn);
    rangeField = new JTextField();
    rangeField.setText((editor.getCurrentRecordIndex() + 1) + ".." + (editor.getCurrentRecordIndex() + 1));
    rangeField.setInputVerifier(new RangeVerifier());
    rangeField.setEnabled(false);
    rangeField.getDocument().addDocumentListener(rangeListener);

    segmentTimeBtn = new JRadioButton("Time range");
    segmentTimeBtn.addActionListener(radioListener);
    btnGrp.add(segmentTimeBtn);
    segmentField = new MediaSegmentField();
    segmentField.setEnabled(false);
    updateSegmentTimes();

    final DialogHeader header = new DialogHeader("Play Custom Segment", "Play a custom defined segment");

    add(header, cc.xyw(1, 1, 2));
    add(currentSegmentBtn, cc.xyw(1, 2, 2));
    add(contiguousSegmentBtn, cc.xyw(1, 3, 2));
    //      add(periodBtn, cc.xyw(1, 4, 2));
    add(recordRangeBtn, cc.xyw(1, 5, 2));
    add(rangeField, cc.xy(2, 6));
    add(segmentTimeBtn, cc.xyw(1, 7, 2));
    add(segmentField, cc.xy(2, 8));

    final ImageIcon playIcon = IconManager.getInstance().getIcon("actions/media-playback-start",
            IconSize.SMALL);
    final ImageIcon cancelIcon = IconManager.getInstance().getIcon("actions/button_cancel", IconSize.SMALL);

    final PhonUIAction playAct = new PhonUIAction(this, "onPlay");
    playAct.putValue(PhonUIAction.NAME, "Play");
    playAct.putValue(PhonUIAction.SHORT_DESCRIPTION, "Play segment");
    playAct.putValue(PhonUIAction.SMALL_ICON, playIcon);
    playBtn = new JButton(playAct);

    final PhonUIAction cancelAct = new PhonUIAction(this, "onCancel");
    cancelAct.putValue(PhonUIAction.NAME, "Close");
    cancelAct.putValue(PhonUIAction.SMALL_ICON, cancelIcon);
    cancelBtn = new JButton(cancelAct);

    final JPanel btnPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    btnPanel.add(cancelBtn);
    btnPanel.add(playBtn);
    add(btnPanel, cc.xyw(1, 9, 2));
}

From source file:ca.phon.app.session.editor.view.record_data.RecordDataEditorView.java

License:Open Source License

private void init() {
    setLayout(new BorderLayout());

    setBackground(Color.white);/*from  w  w  w .j  a va  2s  . co m*/

    contentPane = new TierDataLayoutPanel();
    contentPane.setBackground(Color.white);

    final JScrollPane scroller = new JScrollPane(contentPane);
    scroller.setBackground(Color.white);
    add(scroller, BorderLayout.CENTER);

    final JPanel panel = getTopPanel();
    add(panel, BorderLayout.NORTH);

    final FormLayout statusLayout = new FormLayout("pref, pref, fill:pref:grow, "
            + "right:pref, right:pref, right:pref, right:pref, right:pref, right:pref", "pref");
    final CellConstraints cc = new CellConstraints();
    statusPanel = new JPanel(statusLayout);

    final Font font = Font.decode("monospace-PLAIN-10");
    final JLabel idLbl = new JLabel("Id: ");
    idLbl.setFont(font);

    recordIdLbl = new JLabel();
    recordIdLbl.setFont(font);

    statusPanel.add(idLbl, cc.xy(1, 1));
    statusPanel.add(recordIdLbl, cc.xy(2, 1));

    final JLabel tierLbl = new JLabel("Tier: ");
    tierLbl.setFont(font);

    currentTierLbl = new JLabel();
    currentTierLbl.setFont(font);

    statusPanel.add(tierLbl, cc.xy(4, 1));
    statusPanel.add(currentTierLbl, cc.xy(5, 1));

    final JLabel grpLbl = new JLabel(" Group: ");
    grpLbl.setFont(font);

    currentGroupLbl = new JLabel();
    currentGroupLbl.setFont(font);

    statusPanel.add(grpLbl, cc.xy(6, 1));
    statusPanel.add(currentGroupLbl, cc.xy(7, 1));

    final JLabel charLbl = new JLabel(" Character: ");
    charLbl.setFont(font);

    currentCharLbl = new JLabel();
    currentCharLbl.setFont(font);

    statusPanel.add(charLbl, cc.xy(8, 1));
    statusPanel.add(currentCharLbl, cc.xy(9, 1));

    add(statusPanel, BorderLayout.SOUTH);

    update();
    updateStatus();
    setupEditorActions();
    getEditor().getSelectionModel().addSelectionModelListener(selectionListener);
}

From source file:ca.phon.app.session.editor.view.record_data.RecordDataEditorView.java

License:Open Source License

private JPanel getTopPanel() {
    if (topPanel == null) {
        final TierDataLayout tdl = (TierDataLayout) contentPane.getLayout();
        final TierDataLayoutButtons layoutButtons = new TierDataLayoutButtons(contentPane, tdl);

        final SessionEditor editor = getEditor();
        final Session session = editor.getSession();

        final FormLayout layout = new FormLayout(
                "pref, pref, 3dlu, pref, fill:pref:grow(0.5), 5dlu, pref, fill:pref:grow, right:pref, 5dlu, right:pref",
                "pref");
        topPanel = new JPanel(layout);

        final JLabel recNumLbl = new JLabel("<html><u>#</u></html>");
        recNumLbl.setForeground(Color.blue);
        recNumLbl.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        recNumLbl.setToolTipText("Click to edit record position (i.e., move record)");
        recNumLbl.addMouseListener(new MouseInputAdapter() {

            @Override// ww  w . ja  v  a 2 s .  c  o  m
            public void mouseClicked(MouseEvent e) {
                recNumField.setEnabled(true);
                recNumField.requestFocus();
            }

        });

        recNumField = new RecordNumberField(1, getEditor().getSession().getRecordCount());
        recNumField.setColumns(3);
        recNumField.setText("" + (getEditor().getCurrentRecordIndex() + 1));
        final PhonUIAction moveRecordAct = new PhonUIAction(this, "moveRecord");
        moveRecordAct.putValue(PhonUIAction.SHORT_DESCRIPTION, "Edit to set this record's position in session");
        recNumField.setAction(moveRecordAct);
        recNumField.addFocusListener(new FocusListener() {

            int initialNum = 0;

            @Override
            public void focusLost(FocusEvent e) {
                if (recNumField.getText().length() == 0) {
                    recNumField.setText((getEditor().getCurrentRecordIndex() + 1) + "");
                } else {
                    final Integer newNum = Integer.parseInt(recNumField.getText()) - 1;
                    if (newNum != initialNum && newNum != getEditor().getCurrentRecordIndex())
                        moveRecord();
                }
                recNumField.setEnabled(false);
            }

            @Override
            public void focusGained(FocusEvent e) {
                initialNum = getEditor().getCurrentRecordIndex();
            }

        });
        recNumField.setEnabled(false);

        final CellConstraints cc = new CellConstraints();
        int rowIdx = 1;
        int colIdx = 1;

        topPanel.add(recNumLbl, cc.xy(colIdx++, rowIdx));
        topPanel.add(recNumField, cc.xy(colIdx++, rowIdx));
        colIdx++; // 3dlu spacer

        final DefaultComboBoxModel speakerBoxModel = new DefaultComboBoxModel();
        speakerBoxModel.addElement(null);
        for (Participant participant : session.getParticipants()) {
            speakerBoxModel.addElement(participant);
        }
        speakerBox = new JComboBox(speakerBoxModel);
        speakerBox.setRenderer(speakerRenderer);
        speakerBox.addItemListener(speakerListener);

        final PhonUIAction excludeAct = new PhonUIAction(this, "onExclude");
        excludeAct.putValue(PhonUIAction.NAME, excludeFromSearchesText);
        excludeFromSearchesBox = new JCheckBox(excludeAct);

        topPanel.add(new JLabel("Speaker: "), cc.xy(colIdx++, rowIdx));
        topPanel.add(speakerBox, cc.xy(colIdx++, rowIdx));
        colIdx++; // spacer

        topPanel.add(excludeFromSearchesBox, cc.xy(colIdx++, rowIdx));
        colIdx++; // filler

        // create group management buttons
        final JPanel btnPanel = new JPanel(new HorizontalLayout());

        final NewGroupCommand newGroupAct = new NewGroupCommand(this);
        newGroupAct.putValue(NewGroupCommand.SHORT_DESCRIPTION, newGroupAct.getValue(NewGroupCommand.NAME));
        newGroupAct.putValue(NewGroupCommand.NAME, null);
        final JButton newGroupBtn = new JButton(newGroupAct);
        newGroupBtn.setFocusable(false);
        btnPanel.add(newGroupBtn);

        final MergeGroupCommand mergeGroupAct = new MergeGroupCommand(this);
        mergeGroupAct.putValue(MergeGroupCommand.SHORT_DESCRIPTION,
                mergeGroupAct.getValue(MergeGroupCommand.NAME));
        mergeGroupAct.putValue(MergeGroupCommand.NAME, null);
        final JButton mergeGroupBtn = new JButton(mergeGroupAct);
        mergeGroupBtn.setFocusable(false);
        btnPanel.add(mergeGroupBtn);

        final SplitGroupCommand splitGroupAct = new SplitGroupCommand(this);
        splitGroupAct.putValue(SplitGroupCommand.SHORT_DESCRIPTION,
                splitGroupAct.getValue(SplitGroupCommand.NAME));
        splitGroupAct.putValue(SplitGroupCommand.NAME, null);
        final JButton splitGroupBtn = new JButton(splitGroupAct);
        splitGroupBtn.setFocusable(false);
        btnPanel.add(splitGroupBtn);

        /*
         * XXX removed in Phon 2.2
         */
        /*
        final DeleteGroupCommand delGroupAct = new DeleteGroupCommand(this);
        delGroupAct.putValue(DeleteGroupCommand.SHORT_DESCRIPTION, delGroupAct.getValue(DeleteGroupCommand.NAME));
        delGroupAct.putValue(DeleteGroupCommand.NAME, null);
        final JButton delGroupBtn = new JButton(delGroupAct);
        delGroupBtn.setFocusable(false);
        btnPanel.add(delGroupBtn);
        */

        topPanel.add(btnPanel, cc.xy(colIdx++, rowIdx));
        colIdx++; // spacer

        topPanel.add(layoutButtons, cc.xy(colIdx++, rowIdx));
    }

    return topPanel;
}

From source file:ca.phon.app.session.editor.view.segmentation.SegmentationEditorView.java

License:Open Source License

private void init() {
    segmentWindowField = new JTextField();
    SegmentWindowDocument segDoc = new SegmentWindowDocument();
    segmentWindowField.setDocument(segDoc);
    segmentWindowField.setText(DEFAULT_SEGMENT_WINDOW + "");
    segDoc.addDocumentListener(new SegmentWindowListener());

    segmentLabel = new SegmentLabel();
    segmentLabel.setSegmentWindow(DEFAULT_SEGMENT_WINDOW);
    segmentLabel.setCurrentTime(0L);//from  ww w. j av a2  s .com
    segmentLabel.lockSegmentStartTime(-1L);

    modeBox = new JComboBox(SegmentationMode.values());
    modeBox.setSelectedItem(SegmentationMode.INSERT_AFTER_CURRENT);

    JPanel topPanel = new JPanel();
    FormLayout topLayout = new FormLayout("right:pref, 3dlu, fill:default:grow, pref",
            "pref, pref, pref, pref");
    topPanel.setLayout(topLayout);
    CellConstraints cc = new CellConstraints();
    topPanel.add(new JLabel("Segment Window"), cc.xy(1, 1));
    topPanel.add(segmentWindowField, cc.xy(3, 1));
    topPanel.add(new JLabel("ms"), cc.xy(4, 1));

    JLabel infoLabel = new JLabel("Set to 0 for unlimited segment time");
    infoLabel.setFont(infoLabel.getFont().deriveFont(10.0f));

    topPanel.add(infoLabel, cc.xy(3, 2));
    topPanel.add(new JLabel("Current Window"), cc.xy(1, 3));
    topPanel.add(segmentLabel, cc.xy(3, 3));

    topPanel.add(new JLabel("Mode"), cc.xy(1, 4));
    topPanel.add(modeBox, cc.xyw(3, 4, 2));

    setLayout(new BorderLayout());
    add(topPanel, BorderLayout.NORTH);

    participantPanel = new JPanel();

    participantPanel.setBackground(Color.white);
    participantPanel.setOpaque(true);

    JScrollPane participantScroller = new JScrollPane(participantPanel);
    Dimension prefSize = participantScroller.getPreferredSize();
    prefSize.height = 150;
    participantScroller.setPreferredSize(prefSize);
    Dimension maxSize = participantScroller.getMaximumSize();
    maxSize.height = 200;
    participantScroller.setMaximumSize(maxSize);
    Dimension minSize = participantScroller.getMinimumSize();
    minSize.height = 100;
    participantScroller.setMinimumSize(minSize);
    participantScroller.setBorder(BorderFactory.createTitledBorder("Participants"));

    add(participantScroller, BorderLayout.CENTER);

    updateParticipantPanel();
    setupEditorActions();
}

From source file:ca.phon.app.session.editor.view.segmentation.SegmentationEditorView.java

License:Open Source License

private void updateParticipantPanel() {
    participantPanel.removeAll();/*www. ja  v  a  2  s  .  c om*/

    // setup layout
    String colLayout = "fill:default";
    String rowLayout = "pref, 5px";
    for (int i = 0; i <= getEditor().getSession().getParticipantCount(); i++) {
        rowLayout += ", pref, 5px";
    }
    FormLayout layout = new FormLayout(colLayout, rowLayout);
    participantPanel.setLayout(layout);
    CellConstraints cc = new CellConstraints();
    int currentRow = 1;

    String ksStr = (OSInfo.isMacOs() ? "\u2318" : "CTRL +") + "0";
    PhonUIAction noPartSegmentAct = new PhonUIAction(this, "performSegmentation", null);
    noPartSegmentAct.putValue(Action.NAME, ksStr + " speaker undefined");

    // setup labels to be used like buttons
    String segMsg = "Click name to create a new record:";
    JLabel segLbl = new JLabel(segMsg);

    participantPanel.add(segLbl, cc.xy(1, currentRow));
    currentRow += 2;

    JLabel noPartLbl = new JLabel();
    String noPartMsg = ksStr + " <no speaker>";
    noPartLbl.setText(noPartMsg);
    noPartLbl.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    noPartLbl.addMouseListener(new SegmentLabelMouseHandler());
    noPartLbl.setOpaque(false);
    participantPanel.add(noPartLbl, cc.xy(1, currentRow));
    currentRow += 2;

    final Session session = getEditor().getSession();
    int pIdx = 1;
    for (Participant p : session.getParticipants()) {
        ksStr = (OSInfo.isMacOs() ? "\u2318" : "CTRL +") + pIdx;

        final NewSegmentAction segmentAction = new NewSegmentAction(getEditor(), this, p);
        segmentAction.putValue(Action.NAME, ksStr + " " + p.toString());

        JLabel participantLbl = new JLabel();
        String participantStr = ksStr + " " + (p.getName() != null ? p.getName() : p.getId());
        participantLbl.setText(participantStr);
        participantLbl.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        participantLbl.addMouseListener(new SegmentLabelMouseHandler(p));
        participantLbl.setOpaque(false);
        participantPanel.add(participantLbl, cc.xy(1, currentRow));
        currentRow += 2;

        pIdx++;
    }
}