List of usage examples for com.jgoodies.forms.layout CellConstraints CellConstraints
public CellConstraints()
From source file:ca.phon.csv2phon.wizard.DirectoryStep.java
License:Open Source License
private void init() { setLayout(new BorderLayout()); header = new DialogHeader("CSV Import", "Select folder containing csv files."); add(header, BorderLayout.NORTH); JPanel centerPanel = new JPanel(); centerPanel.setBorder(BorderFactory.createTitledBorder("Folder")); FormLayout layout = new FormLayout("right:pref, 3dlu, fill:pref:grow, pref", "pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref"); CellConstraints cc = new CellConstraints(); centerPanel.setLayout(layout);/* w w w . j av a2 s .c o m*/ String lblTxt = "<html><body><p>Please select the folder containing the csv files for import." + " <font color='red'>All csv files should have the same column structure and encoding</font>.</p></body></html>"; infoLbl = new JLabel(lblTxt); centerPanel.add(infoLbl, cc.xyw(1, 1, 3)); csvDirField = new FileSelectionField(); csvDirField.setMode(SelectionMode.FOLDERS); csvDirField.getTextField().setEditable(false); // setup charset chooser SortedMap<String, Charset> availableCharset = Charset.availableCharsets(); charsetBox = new JComboBox(availableCharset.keySet().toArray(new String[0])); charsetBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { charsetName = charsetBox.getSelectedItem().toString(); } } }); charsetBox.setSelectedItem("UTF-8"); textDelimField = new JTextField(); textDelimField.setDocument(new SingleCharDocument()); textDelimField.setText(textDelim + ""); fieldDelimField = new JTextField(); fieldDelimField.setDocument(new SingleCharDocument()); fieldDelimField.setText(fieldDelim + ""); centerPanel.add(new JLabel("Folder:"), cc.xy(1, 3)); centerPanel.add(csvDirField, cc.xyw(3, 3, 2)); centerPanel.add(new JLabel("File encoding:"), cc.xy(1, 5)); centerPanel.add(charsetBox, cc.xy(3, 5)); centerPanel.add(new JLabel("Field delimiter:"), cc.xy(1, 7)); centerPanel.add(fieldDelimField, cc.xy(3, 7)); centerPanel.add(new JLabel("Text delimiter:"), cc.xy(1, 9)); centerPanel.add(textDelimField, cc.xy(3, 9)); add(centerPanel, BorderLayout.CENTER); }
From source file:ca.phon.csv2phon.wizard.ParticipantsStep.java
License:Open Source License
private void init() { setLayout(new BorderLayout()); header = new DialogHeader("CSV Import", "Set up participants."); add(header, BorderLayout.NORTH); FormLayout participantLayout = new FormLayout("fill:pref:grow, 1dlu, pref", "pref, 3dlu, pref, 3dlu, pref, fill:pref:grow"); CellConstraints cc = new CellConstraints(); JPanel participantPanel = new JPanel(participantLayout); participantPanel.setBorder(BorderFactory.createTitledBorder("Participants")); JLabel infoLabel = new JLabel( "<html><body><p>(Optional) Set up participants which will be added to each imported session.</p></body></html>"); participantTable = new JXTable(); ImageIcon addIcon = IconManager.getInstance().getIcon("actions/list-add", IconSize.XSMALL); addParticipantButton = new JButton(addIcon); addParticipantButton.setFocusable(false); addParticipantButton.setToolTipText("Add participant"); addParticipantButton.addActionListener(new ActionListener() { @Override/* ww w. j a va2s .c om*/ public void actionPerformed(ActionEvent e) { newParticipant(); } }); ImageIcon editIcon = IconManager.getInstance().getIcon("actions/edit", IconSize.XSMALL); editParticipantButton = new JButton(editIcon); editParticipantButton.setFocusable(false); editParticipantButton.setToolTipText("Edit participant"); editParticipantButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { editParticipant(); } }); Action deleteParticipantAction = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { deleteParticipant(); } }; ActionMap participantActionMap = participantTable.getActionMap(); participantActionMap.put("DELETE_PARTICIPANT", deleteParticipantAction); InputMap participantInputMap = participantTable.getInputMap(); participantInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), "DELETE_PARTICIPANT"); participantInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), "DELETE_PARTICIPANT"); participantTable.setActionMap(participantActionMap); participantTable.setInputMap(JComponent.WHEN_FOCUSED, participantInputMap); participantPanel.add(infoLabel, cc.xy(1, 1)); participantPanel.add(new JScrollPane(participantTable), cc.xywh(1, 3, 1, 4)); participantPanel.add(addParticipantButton, cc.xy(3, 3)); participantPanel.add(editParticipantButton, cc.xy(3, 5)); add(participantPanel, BorderLayout.CENTER); }
From source file:ca.phon.ipamap.IpaMap.java
License:Open Source License
/** * Create the context menu based on source component */// ww w. java 2 s. c o m public void setupContextMenu(JPopupMenu menu, JComponent comp) { final CommonModuleFrame parentFrame = (CommonModuleFrame) SwingUtilities .getAncestorOfClass(CommonModuleFrame.class, comp); if (parentFrame != null) { final PhonUIAction toggleAlwaysOnTopAct = new PhonUIAction(parentFrame, "setAlwaysOnTop", !parentFrame.isAlwaysOnTop()); toggleAlwaysOnTopAct.putValue(PhonUIAction.NAME, "Always on top"); toggleAlwaysOnTopAct.putValue(PhonUIAction.SELECTED_KEY, parentFrame.isAlwaysOnTop()); final JCheckBoxMenuItem toggleAlwaysOnTopItem = new JCheckBoxMenuItem(toggleAlwaysOnTopAct); menu.add(toggleAlwaysOnTopItem); } // button options first if (comp instanceof CellButton) { CellButton btn = (CellButton) comp; Cell cell = btn.cell; // copy to clipboard options String cellData = cell.getText().replaceAll("" + (char) 0x25cc, ""); PhonUIAction copyToClipboardAct = new PhonUIAction(this, "onCopyToClipboard", cellData); copyToClipboardAct.putValue(PhonUIAction.NAME, "Copy character (" + cell.getText() + ")"); JMenuItem copyToClipboardItem = new JMenuItem(copyToClipboardAct); menu.add(copyToClipboardItem); String htmlVal = new String(); for (Character c : cellData.toCharArray()) { htmlVal += "&#" + (int) c + ";"; } PhonUIAction copyHTMLToClipboardAct = new PhonUIAction(this, "onCopyToClipboard", htmlVal); copyHTMLToClipboardAct.putValue(PhonUIAction.NAME, "Copy as HTML (" + htmlVal + ")"); JMenuItem copyHTMLToClipboardItem = new JMenuItem(copyHTMLToClipboardAct); menu.add(copyHTMLToClipboardItem); String hexVal = new String(); for (Character c : cellData.toCharArray()) { hexVal += (hexVal.length() > 0 ? " " : "") + Integer.toHexString((int) c); } hexVal = hexVal.toUpperCase(); PhonUIAction copyHEXToClipboardAct = new PhonUIAction(this, "onCopyToClipboard", hexVal); copyHEXToClipboardAct.putValue(PhonUIAction.NAME, "Copy as Unicode HEX (" + hexVal + ")"); JMenuItem copyHEXToClipboardItem = new JMenuItem(copyHEXToClipboardAct); menu.add(copyHEXToClipboardItem); menu.addSeparator(); if (isInFavorites(cell)) { PhonUIAction removeFromFavAct = new PhonUIAction(this, "onRemoveCellFromFavorites", cell); removeFromFavAct.putValue(Action.NAME, "Remove from favorites"); removeFromFavAct.putValue(Action.SHORT_DESCRIPTION, "Remove button from list of favorites"); JMenuItem removeFromFavItem = new JMenuItem(removeFromFavAct); menu.add(removeFromFavItem); } else { PhonUIAction addToFavAct = new PhonUIAction(this, "onAddCellToFavorites", cell); addToFavAct.putValue(Action.NAME, "Add to favorites"); addToFavAct.putValue(Action.SHORT_DESCRIPTION, "Add button to list of favorites"); JMenuItem addToFavItem = new JMenuItem(addToFavAct); menu.add(addToFavItem); } menu.addSeparator(); } // section scroll-tos JMenuItem gotoTitleItem = new JMenuItem("Scroll to:"); gotoTitleItem.setEnabled(false); menu.add(gotoTitleItem); for (JXButton toggleBtn : toggleButtons) { PhonUIAction gotoAct = new PhonUIAction(this, "onGoto", toggleBtn); gotoAct.putValue(Action.NAME, toggleBtn.getText()); gotoAct.putValue(Action.SHORT_DESCRIPTION, "Scroll to " + toggleBtn.getText()); JMenuItem gotoItem = new JMenuItem(gotoAct); menu.add(gotoItem); } menu.addSeparator(); // setup font scaler final JLabel smallLbl = new JLabel("A"); smallLbl.setFont(getFont().deriveFont(12.0f)); smallLbl.setHorizontalAlignment(SwingConstants.CENTER); JLabel largeLbl = new JLabel("A"); largeLbl.setFont(getFont().deriveFont(24.0f)); largeLbl.setHorizontalAlignment(SwingConstants.CENTER); final JSlider scaleSlider = new JSlider(1, 101); scaleSlider.setValue((int) (scale * 100)); scaleSlider.setMajorTickSpacing(20); scaleSlider.setMinorTickSpacing(10); scaleSlider.setSnapToTicks(true); scaleSlider.setPaintTicks(true); scaleSlider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent arg0) { int sliderVal = scaleSlider.getValue(); float scale = (float) sliderVal / (float) 100; _cFont = null; setSavedScale(scale); setScale(scale); } }); FormLayout scaleLayout = new FormLayout("3dlu, center:pref, fill:pref:grow, center:pref, 3dlu", "pref"); CellConstraints cc = new CellConstraints(); JPanel scalePanel = new JPanel(scaleLayout) { @Override public Insets getInsets() { Insets retVal = super.getInsets(); retVal.left += UIManager.getIcon("Tree.collapsedIcon").getIconWidth(); return retVal; } }; scalePanel.add(smallLbl, cc.xy(2, 1)); scalePanel.add(scaleSlider, cc.xy(3, 1)); scalePanel.add(largeLbl, cc.xy(4, 1)); JMenuItem scaleItem = new JMenuItem("Font size"); scaleItem.setEnabled(false); menu.add(scaleItem); menu.add(scalePanel); menu.addSeparator(); // highlighting PhonUIAction onToggleHighlightAct = new PhonUIAction(this, "onToggleHighlightRecent"); onToggleHighlightAct.putValue(PhonUIAction.NAME, "Highlight recently used"); onToggleHighlightAct.putValue(PhonUIAction.SELECTED_KEY, isHighlightRecent()); JCheckBoxMenuItem onToggleHighlightItm = new JCheckBoxMenuItem(onToggleHighlightAct); menu.add(onToggleHighlightItm); }
From source file:ca.phon.media.export.MediaExportPanel.java
License:Open Source License
private void init() { final FileFilter fileFilter = FileFilter.mediaFilter; inputFileField = new FileSelectionField(); inputFileField.setFileFilter(fileFilter); inputFileField.getTextField().setPrompt("Input file"); if (exporter.getInputFile() != null) inputFileField.setFile(exporter.getInputFile()); outputFileField = new FileSelectionField(); outputFileField.setFileFilter(fileFilter); outputFileField.getTextField().setPrompt("Output file"); if (exporter.getOutputFile() != null) outputFileField.setFile(exporter.getOutputFile()); final Formatter<Float> timeFormatter = new Formatter<Float>() { @Override// w w w . j a va 2s. c o m public Float parse(String text) throws ParseException { Float retVal = new Float(0.0f); try { retVal = Float.parseFloat(text); } catch (NullPointerException | NumberFormatException e) { throw new ParseException(text, 0); } return retVal; } @Override public String format(Float obj) { final NumberFormat format = NumberFormat.getNumberInstance(); format.setMaximumFractionDigits(3); return format.format(obj); } }; startTimeField = new FormatterTextField<>(timeFormatter); startTimeField.setPrompt("Enter start time in seconds, leave empty to start at beginning of media"); if (exporter.getMediaStartTime() > 0) startTimeField.setValue(exporter.getMediaStartTime()); stopTimeField = new FormatterTextField<>(timeFormatter); stopTimeField.setPrompt("Enter stop time in seconds, leave empty to stop at end of media"); if (exporter.getMediaStopTime() > 0) stopTimeField.setValue(exporter.getMediaStopTime()); duplicateButton = new JRadioButton("Keep original media encoding"); transcodeButton = new JRadioButton("Transcode media"); final ButtonGroup btnGroup = new ButtonGroup(); btnGroup.add(duplicateButton); btnGroup.add(transcodeButton); duplicateButton.setSelected(true); presetBox = new JComboBox<>(VLCMediaExporter.Preset.values()); advancedPanel = new JXCollapsiblePane(Direction.DOWN); advancedPanel.setLayout(new VerticalLayout()); optionsPane = new JTextPane(); advancedPanel.add(optionsPane); final JPanel btmPanel = new JPanel(new VerticalLayout()); final Action toggleAction = advancedPanel.getActionMap().get(JXCollapsiblePane.TOGGLE_ACTION); toggleAction.putValue(Action.NAME, "Advanced"); toggleAction.putValue(JXCollapsiblePane.COLLAPSE_ICON, UIManager.getIcon("Tree.expandedIcon")); toggleAction.putValue(JXCollapsiblePane.EXPAND_ICON, UIManager.getIcon("Tree.collapsedIcon")); final JButton toggleBtn = new JButton(toggleAction); btmPanel.add(toggleBtn); btmPanel.add(advancedPanel); // file selection panel final FormLayout fileSelectionLayout = new FormLayout("pref, 3dlu, fill:pref:grow", "pref, pref"); final CellConstraints cc = new CellConstraints(); final JPanel fileSelectionPanel = new JPanel(fileSelectionLayout); fileSelectionPanel.setBorder(BorderFactory.createTitledBorder("File Selection")); fileSelectionPanel.add(new JLabel("Input file"), cc.xy(1, 1)); fileSelectionPanel.add(inputFileField, cc.xy(3, 1)); fileSelectionPanel.add(new JLabel("Output file"), cc.xy(1, 2)); fileSelectionPanel.add(outputFileField, cc.xy(3, 2)); // time selection panel }
From source file:ca.phon.media.exportwizard.ExportSetupStep.java
License:Open Source License
private void init() { setLayout(new BorderLayout()); header = new DialogHeader("Export media", "Export media segment using ffmpeg"); add(header, BorderLayout.NORTH); // setup top panel FormLayout topLayout = new FormLayout("left:100px, 3dlu, fill:pref:grow, pref", "pref, pref, pref, pref"); CellConstraints cc = new CellConstraints(); JPanel topPanel = new JPanel(topLayout); topPanel.add(new JLabel("Input file:"), cc.xy(1, 1)); topPanel.add(getInputFileLabel(), cc.xy(3, 1)); topPanel.add(getInputBrowseButton(), cc.xy(4, 1)); topPanel.add(new JLabel("Output file:"), cc.xy(1, 2)); topPanel.add(getOutputFileLabel(), cc.xy(3, 2)); topPanel.add(getOutputBrowseButton(), cc.xy(4, 2)); topPanel.add(getPartialExtractBox(), cc.xyw(1, 3, 3)); // topPanel.add(getExtractRecordsButton(), cc.xy(1, 4)); // topPanel.add(getRecordsField(), cc.xy(3, 4)); topPanel.add(new JLabel("Segment"), cc.xy(1, 4)); topPanel.add(getSegmentField(), cc.xy(3, 4)); // setup bottom panel FormLayout btmLayout = new FormLayout("left:100px, 3dlu, fill:pref:grow", "pref, pref, pref, pref, pref, fill:pref:grow"); JPanel btmPanel = new JPanel(btmLayout); btmPanel.setBorder(BorderFactory.createTitledBorder("Advanced options")); btmPanel.add(getEncodeVideoBox(), cc.xyw(1, 1, 3)); btmPanel.add(new JLabel("Video codec:"), cc.xy(1, 2)); btmPanel.add(getVideoCodecField(), cc.xy(3, 2)); btmPanel.add(getEncodeAudioBox(), cc.xyw(1, 3, 3)); btmPanel.add(new JLabel("Audio codec:"), cc.xy(1, 4)); btmPanel.add(getAudioCodecField(), cc.xy(3, 4)); btmPanel.add(new JLabel("Other arguments:"), cc.xy(1, 5)); btmPanel.add(getOtherArgsField(), cc.xyw(1, 6, 3)); JPanel centerPanel = new JPanel(); centerPanel.setLayout(new BorderLayout()); centerPanel.add(topPanel, BorderLayout.NORTH); centerPanel.add(btmPanel, BorderLayout.CENTER); add(centerPanel, BorderLayout.CENTER); // setup actions ImageIcon brwseIcn = IconManager.getInstance().getIcon("actions/document-open", IconSize.SMALL); PhonUIAction browseForInputAct = new PhonUIAction(this, "onBrowseForInput"); browseForInputAct.putValue(Action.SMALL_ICON, brwseIcn); browseForInputAct.putValue(Action.SHORT_DESCRIPTION, "Browse for media..."); PhonUIAction showSaveDialogAct = new PhonUIAction(this, "onShowSaveDialog"); showSaveDialogAct.putValue(Action.SMALL_ICON, brwseIcn); showSaveDialogAct.putValue(Action.SHORT_DESCRIPTION, "Save media as..."); PhonUIAction togglePartialExtractAct = new PhonUIAction(this, "onTogglePartialExtract"); togglePartialExtractAct.putValue(Action.NAME, "Extract segment"); PhonUIAction toggleIncludeVideoAct = new PhonUIAction(this, "onToggleIncludeVideo"); toggleIncludeVideoAct.putValue(Action.NAME, "Include video"); PhonUIAction toggleIncludeAudioAct = new PhonUIAction(this, "onToggleIncludeAudio"); toggleIncludeAudioAct.putValue(Action.NAME, "Include audio"); PhonUIAction onRecordSelectionSwitch = new PhonUIAction(this, "onPartialExtractRecord"); onRecordSelectionSwitch.putValue(Action.NAME, "Record(s)"); PhonUIAction onTimeSelectionSwitch = new PhonUIAction(this, "onPartialExtractTime"); onTimeSelectionSwitch.putValue(Action.NAME, "Segment"); getInputBrowseButton().setAction(browseForInputAct); getOutputBrowseButton().setAction(showSaveDialogAct); getPartialExtractBox().setAction(togglePartialExtractAct); // getExtractRecordsButton().setAction(onRecordSelectionSwitch); // getExtractTimeButton().setAction(onTimeSelectionSwitch); getEncodeVideoBox().setAction(toggleIncludeVideoAct); getEncodeAudioBox().setAction(toggleIncludeAudioAct); // ButtonGroup btnGrp = new ButtonGroup(); // btnGrp.add(getExtractRecordsButton()); // btnGrp.add(getExtractTimeButton()); // check to see if we have a session // if(props.get(MediaExportWizardProp.SESSION) == null) { // // disable the record extraction selection // getExtractRecordsButton().setEnabled(false); // getRecordsField().setEnabled(false); ////from w w w .ja v a2s . c o m // getExtractTimeButton().setSelected(true); // } // set values based on wizard props if (props.get(MediaExportWizardProp.INPUT_FILE) != null) { String inputFile = (String) props.get(MediaExportWizardProp.INPUT_FILE); getInputFileLabel().setFile(new File(inputFile)); } if (props.get(MediaExportWizardProp.OUTPUT_FILE) != null) { String outputFile = (String) props.get(MediaExportWizardProp.OUTPUT_FILE); getOutputFileLabel().setFile(new File(outputFile)); } boolean isAllowPartialExtract = true; if (props.get(MediaExportWizardProp.ALLOW_PARTIAL_EXTRACT) != null) { isAllowPartialExtract = (Boolean) props.get(MediaExportWizardProp.ALLOW_PARTIAL_EXTRACT); } if (!isAllowPartialExtract) { // disable segment extraction components getPartialExtractBox().setSelected(false); getPartialExtractBox().setEnabled(false); } else { boolean isPartialExtract = false; if (props.get(MediaExportWizardProp.IS_PARTICAL_EXTRACT) != null) { isPartialExtract = (Boolean) props.get(MediaExportWizardProp.IS_PARTICAL_EXTRACT); } if (isPartialExtract) { getPartialExtractBox().setSelected(true); getSegmentField().setEnabled(true); } else { getPartialExtractBox().setSelected(false); getSegmentField().setEnabled(false); } if (props.get(MediaExportWizardProp.PARTIAL_EXTRACT_SEGMENT_START) != null && props.get(MediaExportWizardProp.PARTIAL_EXTRACT_SEGMENT_DURATION) != null) { long startTime = (Long) props.get(MediaExportWizardProp.PARTIAL_EXTRACT_SEGMENT_START); long duration = (Long) props.get(MediaExportWizardProp.PARTIAL_EXTRACT_SEGMENT_DURATION); String timeStr = MsFormatter.msToDisplayString(startTime) + "-" + MsFormatter.msToDisplayString(startTime + duration); getSegmentField().setText(timeStr); } } boolean encodeVideo = true; if (props.get(MediaExportWizardProp.ENCODE_VIDEO) != null) { encodeVideo = (Boolean) props.get(MediaExportWizardProp.ENCODE_VIDEO); } getEncodeVideoBox().setSelected(encodeVideo); getVideoCodecField().setEnabled(encodeVideo); String videoCodec = "copy"; if (props.get(MediaExportWizardProp.VIDEO_CODEC) != null) { videoCodec = (String) props.get(MediaExportWizardProp.VIDEO_CODEC); } getVideoCodecField().setText(videoCodec); boolean encodeAudio = true; if (props.get(MediaExportWizardProp.ENCODE_AUDIO) != null) { encodeAudio = (Boolean) props.get(MediaExportWizardProp.ENCODE_AUDIO); } getEncodeAudioBox().setSelected(encodeAudio); getAudioCodecField().setEnabled(encodeAudio); String audioCodec = "copy"; if (props.get(MediaExportWizardProp.AUDIO_CODEC) != null) { audioCodec = (String) props.get(MediaExportWizardProp.AUDIO_CODEC); } getAudioCodecField().setText(audioCodec); if (props.get(MediaExportWizardProp.OTHER_ARGS) != null) { String otherArgs = (String) props.get(MediaExportWizardProp.OTHER_ARGS); getOtherArgsField().setText(otherArgs); } }
From source file:ca.phon.media.player.PhonMediaPlayer.java
License:Open Source License
public JPanel getMediaControlPanel() { JPanel retVal = mediaControlPanel; if (retVal == null) { retVal = new JPanel(); playPauseBtn = getPlayPauseButton(); playPauseBtn.setEnabled(false);//from w w w . j a v a 2 s . co m positionSlider = getPositionSlider(); positionSlider.setEnabled(false); positionSlider.setUI(new TimeSliderUI()); volumeBtn = getVolumeButton(); menuBtn = getMenuButton(); // volumeSlider = new JSlider(); // volumeSlider.setOrientation(JSlider.VERTICAL); // volumeSlider.setPreferredSize(new Dimension(volumeBtn.getPreferredSize().width, 100)); // setup layout FormLayout layout = new FormLayout("pref, fill:pref:grow, pref, pref", "pref"); CellConstraints cc = new CellConstraints(); retVal.setLayout(layout); retVal.add(playPauseBtn, cc.xy(1, 1)); retVal.add(positionSlider, cc.xy(2, 1)); // retVal.add(volumePane, cc.xy(3, 1)); retVal.add(volumeBtn, cc.xy(3, 1)); retVal.add(menuBtn, cc.xy(4, 1)); } return retVal; }
From source file:ca.phon.phon2csv.sessionwizard.SelectRecordsStep.java
License:Open Source License
private void init() { setLayout(new BorderLayout()); header = new DialogHeader("CSV Export", "Select records and location for export."); add(header, BorderLayout.NORTH); JPanel centerPanel = new JPanel(new BorderLayout()); JPanel dirPanel = new JPanel(); FormLayout layout = new FormLayout("right:pref, 3dlu, fill:pref:grow, pref", "pref, 3dlu, pref"); CellConstraints cc = new CellConstraints(); dirPanel.setLayout(layout);//from w ww . j av a2 s. c o m dirPanel.setBorder(BorderFactory.createTitledBorder("Location")); dirPanel.add(new JLabel("Save as:"), cc.xy(1, 1)); saveLocationField = new FileSelectionField(); saveLocationField.setMode(SelectionMode.FILES); saveLocationField.getTextField().setEditable(false); saveLocationField.setFileFilter(FileFilter.csvFilter); saveLocationField.setFile(new File(getDefaultSaveLocation())); dirPanel.add(saveLocationField, cc.xyw(3, 1, 2)); centerPanel.add(dirPanel, BorderLayout.NORTH); // filter panel uttFilterPanel = new RecordFilterPanel(project, transcript); uttFilterPanel.setBorder(BorderFactory.createTitledBorder("Records")); centerPanel.add(uttFilterPanel, BorderLayout.CENTER); add(centerPanel, BorderLayout.CENTER); }
From source file:ca.phon.phon2csv.wizard.CSVColumnsStep.java
License:Open Source License
private void init() { setLayout(new BorderLayout()); JPanel centerPanel = new JPanel(); FormLayout centerLayout = new FormLayout("250px, fill:pref:grow, pref", "pref, pref, pref, pref, fill:pref:grow, pref"); CellConstraints cc = new CellConstraints(); centerPanel.setLayout(centerLayout); docPane = new JTextPane(); docPane.setEditorKit(new HTMLEditorKit()); docPane.setText(columnDocString);//from w w w . j av a 2s. c o m centerPanel.add(new JScrollPane(docPane), cc.xywh(1, 1, 1, 6)); reportColumnModel = new DefaultListModel(); for (CSVExportColumn rc : getInitialColumnList()) reportColumnModel.addElement(rc); columnList = new JXList(reportColumnModel); columnList.setCellRenderer(new ReportColumnCellRenderer()); centerPanel.add(new JScrollPane(columnList), cc.xywh(2, 2, 1, 5)); columnEntryField = new JTextField(); columnEntryField.addActionListener(addColumnListener); centerPanel.add(columnEntryField, cc.xy(2, 1)); ImageIcon addIcon = IconManager.getInstance().getIcon("actions/list-add", IconSize.SMALL); ImageIcon removeIcon = IconManager.getInstance().getIcon("actions/list-remove", IconSize.SMALL); ImageIcon upIcon = IconManager.getInstance().getIcon("actions/go-up", IconSize.SMALL); ImageIcon downIcon = IconManager.getInstance().getIcon("actions/go-down", IconSize.SMALL); ImageIcon resetIcon = IconManager.getInstance().getIcon("actions/reload", IconSize.SMALL); addColumnBtn = new JButton(addIcon); addColumnBtn.setToolTipText("Add column"); addColumnBtn.addActionListener(addColumnListener); centerPanel.add(addColumnBtn, cc.xy(3, 1)); upColumnBtn = new JButton(upIcon); upColumnBtn.setToolTipText("Move column up"); upColumnBtn.addActionListener(upColumnListener); centerPanel.add(upColumnBtn, cc.xy(3, 3)); downColumnBtn = new JButton(downIcon); downColumnBtn.setToolTipText("Move column down"); downColumnBtn.addActionListener(downColumnListener); centerPanel.add(downColumnBtn, cc.xy(3, 4)); removeColumnBtn = new JButton(removeIcon); removeColumnBtn.setToolTipText("Remove column"); removeColumnBtn.addActionListener(deleteColumnListener); centerPanel.add(removeColumnBtn, cc.xy(3, 2)); resetDefaultBtn = new JButton(resetIcon); resetDefaultBtn.setToolTipText("Reset to default"); resetDefaultBtn.addActionListener(resetColumnsListener); centerPanel.add(resetDefaultBtn, cc.xy(3, 6)); header = new DialogHeader("Set up Columns", "Set up columns for csv export"); add(header, BorderLayout.NORTH); add(centerPanel, BorderLayout.CENTER); }
From source file:ca.phon.phon2csv.wizard.CSVDirectoryStep.java
License:Open Source License
private void init() { setLayout(new BorderLayout()); header = new DialogHeader("CSV Export", "Select destination folder."); add(header, BorderLayout.NORTH); JPanel centerPanel = new JPanel(new BorderLayout()); JPanel dirPanel = new JPanel(); FormLayout layout = new FormLayout("right:pref, 3dlu, fill:pref:grow, pref", "pref, 3dlu, pref"); CellConstraints cc = new CellConstraints(); dirPanel.setLayout(layout);// w w w . jav a 2s. com dirPanel.setBorder(BorderFactory.createTitledBorder("Folder")); String lblTxt = "<html><body><p>" + "Select folder for exported csv files." + "</p></body></html>"; infoLbl = new JLabel(lblTxt); dirPanel.add(infoLbl, cc.xyw(1, 1, 4)); dirPanel.add(new JLabel("Destination folder:"), cc.xy(1, 3)); csvDirField = new FileSelectionField(); csvDirField.setMode(SelectionMode.FOLDERS); csvDirField.getTextField().setEditable(false); dirPanel.add(csvDirField, cc.xyw(3, 3, 2)); centerPanel.add(dirPanel, BorderLayout.NORTH); // session selection JPanel sessionPanel = new JPanel(new BorderLayout()); sessionPanel.setBorder(BorderFactory.createTitledBorder("Sessions")); sessionSelector = new SessionSelector(CommonModuleFrame.getCurrentFrame().getExtension(Project.class)); sessionPanel.add(new JScrollPane(sessionSelector), BorderLayout.CENTER); centerPanel.add(sessionPanel, BorderLayout.CENTER); add(centerPanel, BorderLayout.CENTER); }
From source file:ca.phon.phontalk.plugin.ui.PhonTalkFrame.java
License:Open Source License
private void init() { setLayout(new BorderLayout()); final DialogHeader header = new DialogHeader("PhonTalk", ""); add(header, BorderLayout.NORTH); settingsPanel = new PhonTalkSettingPanel(); final PhonUIAction saveAsCSVAct = new PhonUIAction(this, "saveAsCSV"); saveAsCSVAct.putValue(PhonUIAction.NAME, "Save log as CSV..."); final KeyStroke saveAsKs = KeyStroke.getKeyStroke(KeyEvent.VK_S, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); saveAsCSVAct.putValue(PhonUIAction.ACCELERATOR_KEY, saveAsKs); final PhonUIAction clearAct = new PhonUIAction(this, "onClear"); clearAct.putValue(PhonUIAction.NAME, "Clear log"); final KeyStroke clearKs = KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() | KeyEvent.SHIFT_MASK); clearAct.putValue(PhonUIAction.ACCELERATOR_KEY, clearKs); final PhonUIAction redoAct = new PhonUIAction(this, "onRedo"); redoAct.putValue(PhonUIAction.NAME, "Redo"); final KeyStroke redoKs = KeyStroke.getKeyStroke(KeyEvent.VK_R, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask() | KeyEvent.SHIFT_MASK); redoAct.putValue(PhonUIAction.ACCELERATOR_KEY, redoKs); saveAsCSVButton = new JButton(saveAsCSVAct); taskTableModel = new PhonTalkTaskTableModel(); taskTable = new JXTable(taskTableModel); taskTable.setColumnControlVisible(true); taskTable.setOpaque(false);/* w w w . j a va 2 s .c o m*/ taskTable.addMouseListener(taskTableContextListener); taskTable.getColumnModel().getColumn(0).setPreferredWidth(70); taskTable.getColumnModel().getColumn(1).setPreferredWidth(200); taskTable.setAutoResizeMode(JXTable.AUTO_RESIZE_OFF); JScrollPane taskScroller = new JScrollPane(taskTable); taskScroller.setOpaque(false); dropPanel = new PhonTalkDropPanel(dropListener); dropPanel.setLayout(new BorderLayout()); dropPanel.add(taskScroller, BorderLayout.CENTER); dropPanel.setFont(dropPanel.getFont().deriveFont(Font.BOLD)); final HidablePanel msgPanel = new HidablePanel(PhonTalkFrame.class.getName() + ".infoMsg"); msgPanel.setTopLabelText("<html>To convert files between Phon and TalkBank formats, <br/>" + "drop files onto the table above or use the Open button <br/> " + "to select a file/folder containing either a Phon project <br/> " + "or Talkbank .xml files.</html>"); final GridBagConstraints gbc = new GridBagConstraints(); gbc.gridwidth = 2; gbc.gridheight = 1; gbc.weightx = 1.0; gbc.weighty = 1.0; gbc.fill = GridBagConstraints.BOTH; gbc.gridx = 0; gbc.gridy = 3; settingsPanel.add(msgPanel, gbc); dropPanel.add(settingsPanel, BorderLayout.SOUTH); statusLabel = new JLabel(); busyLabel = new JXBusyLabel(new Dimension(16, 16)); JPanel topPanel = new JPanel(new FormLayout("pref, fill:pref:grow, right:pref", "pref")); final CellConstraints cc = new CellConstraints(); topPanel.setBackground(Color.white); topPanel.add(busyLabel, cc.xy(1, 1)); topPanel.add(statusLabel, cc.xy(2, 1)); topPanel.add(saveAsCSVButton, cc.xy(3, 1)); reportTableModel = new PhonTalkMessageTableModel(); reportTable = new JXTable(reportTableModel); reportTable.setColumnControlVisible(true); reportTable.getColumnModel().getColumn(0).setPreferredWidth(200); reportTable.getColumnModel().getColumn(1).setPreferredWidth(50); reportTable.getColumnModel().getColumn(2).setPreferredWidth(50); reportTable.getColumnModel().getColumn(3).setPreferredWidth(300); reportTable.setAutoResizeMode(JXTable.AUTO_RESIZE_OFF); JScrollPane scroller = new JScrollPane(reportTable); final JPanel rightPanel = new JPanel(new BorderLayout()); rightPanel.add(topPanel, BorderLayout.NORTH); rightPanel.add(scroller, BorderLayout.CENTER); final PhonUIAction act = new PhonUIAction(this, "onBrowse"); act.putValue(PhonUIAction.NAME, "Open..."); act.putValue(PhonUIAction.SHORT_DESCRIPTION, "Select folder for conversion"); act.putValue(PhonUIAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_O, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); final JButton btn = new JButton(act); dropPanel.add(btn, BorderLayout.NORTH); final JMenuBar menuBar = new JMenuBar(); final JMenu fileMenu = new JMenu("File"); menuBar.add(fileMenu); fileMenu.add(new JMenuItem(act)); fileMenu.addSeparator(); fileMenu.add(saveAsCSVAct); fileMenu.addSeparator(); final PhonUIAction exitAct = new PhonUIAction(this, "onExit"); exitAct.putValue(PhonUIAction.NAME, "Exit"); final KeyStroke exitKs = KeyStroke.getKeyStroke(KeyEvent.VK_Q, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()); exitAct.putValue(PhonUIAction.ACCELERATOR_KEY, exitKs); fileMenu.add(exitAct); final JMenu editMenu = new JMenu("Edit"); menuBar.add(editMenu); editMenu.add(redoAct); editMenu.addSeparator(); editMenu.add(clearAct); setJMenuBar(menuBar); final JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, dropPanel, rightPanel); add(splitPane, BorderLayout.CENTER); }