List of usage examples for javax.swing JLabel setLabelFor
@BeanProperty(description = "The component this is labelling.") public void setLabelFor(Component c)
From source file:org.tinymediamanager.ui.movies.settings.MovieRenamerSettingsPanel.java
public MovieRenamerSettingsPanel() { setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("250dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("fill:default"), FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("fill:default:grow"), FormSpecs.RELATED_GAP_ROWSPEC, })); // the panel renamer JPanel panelRenamer = new JPanel(); panelRenamer.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.movie.renamer.title"), //$NON-NLS-1$ TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelRenamer, "2, 2, fill, fill"); panelRenamer.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("75dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.UNRELATED_GAP_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.UNRELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow(3)"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); chckbxSpaceSubstitution = new JCheckBox(BUNDLE.getString("Settings.movie.renamer.spacesubstitution")); //$NON-NLS-1$ chckbxSpaceSubstitution.addActionListener(actionCreateRenamerExample); tfMoviePath = new JTextField(); tfMoviePath.getDocument().addDocumentListener(new DocumentListener() { @Override/* w w w .ja v a2 s . c o m*/ public void removeUpdate(DocumentEvent arg0) { createRenamerExample(); } @Override public void insertUpdate(DocumentEvent arg0) { createRenamerExample(); } @Override public void changedUpdate(DocumentEvent arg0) { createRenamerExample(); } }); JLabel lblMoviePath = new JLabel(BUNDLE.getString("Settings.renamer.folder")); //$NON-NLS-1$ panelRenamer.add(lblMoviePath, "2, 4, right, default"); panelRenamer.add(tfMoviePath, "4, 4, fill, default"); tfMoviePath.setColumns(10); panelRenamer.add(chckbxSpaceSubstitution, "8, 4"); cbSeparator = new JComboBox(separators.toArray()); panelRenamer.add(cbSeparator, "10, 4, fill, default"); cbSeparator.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { checkChanges(); createRenamerExample(); } }); lblDefault1T = new JLabel(BUNDLE.getString("Settings.default")); TmmFontHelper.changeFont(lblDefault1T, 0.833); panelRenamer.add(lblDefault1T, "2, 6, right, top"); lblDefaultFolderPattern = new JLabel(MovieSettings.DEFAULT_RENAMER_FOLDER_PATTERN); TmmFontHelper.changeFont(lblDefaultFolderPattern, 0.833); panelRenamer.add(lblDefaultFolderPattern, "4, 6, default, top"); chckbxMoviesetSingleMovie = new JCheckBox(BUNDLE.getString("Settings.renamer.moviesetsinglemovie")); //$NON-NLS-1$ chckbxMoviesetSingleMovie.addActionListener(actionCreateRenamerExample); panelRenamer.add(chckbxMoviesetSingleMovie, "8, 6, 5, 1, fill, default"); lblMMDWarning = new JLabel(BUNDLE.getString("Settings.renamer.folder.warning")); //$NON-NLS-1$ panelRenamer.add(lblMMDWarning, "2, 8, 11, 1"); JLabel lblMovieFilename = new JLabel(BUNDLE.getString("Settings.renamer.file")); //$NON-NLS-1$ panelRenamer.add(lblMovieFilename, "2, 10, right, fill"); tfMovieFilename = new JTextField(); tfMovieFilename.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent arg0) { createRenamerExample(); } @Override public void insertUpdate(DocumentEvent arg0) { createRenamerExample(); } @Override public void changedUpdate(DocumentEvent arg0) { createRenamerExample(); } }); panelRenamer.add(tfMovieFilename, "4, 10, fill, default"); tfMovieFilename.setColumns(10); lblMovieFilename.setLabelFor(tfMovieFilename); chckbxAsciiReplacement = new JCheckBox(BUNDLE.getString("Settings.renamer.asciireplacement")); //$NON-NLS-1$ chckbxAsciiReplacement.addActionListener(actionCreateRenamerExample); panelRenamer.add(chckbxAsciiReplacement, "8, 10, 5, 1"); lblDefault2T = new JLabel(BUNDLE.getString("Settings.default")); TmmFontHelper.changeFont(lblDefault2T, 0.833); panelRenamer.add(lblDefault2T, "2, 12, right, top"); lblDefaultFilePattern = new JLabel(MovieSettings.DEFAULT_RENAMER_FILE_PATTERN); TmmFontHelper.changeFont(lblDefaultFilePattern, 0.833); panelRenamer.add(lblDefaultFilePattern, "4, 12, default, top"); JTextPane txtpntAsciiHint = new JTextPane(); txtpntAsciiHint.setOpaque(false); txtpntAsciiHint.setEditable(false); txtpntAsciiHint.setText(BUNDLE.getString("Settings.renamer.asciireplacement.hint")); //$NON-NLS-1$ TmmFontHelper.changeFont(txtpntAsciiHint, 0.833); txtpntAsciiHint.setBackground(UIManager.getColor("Panel.background")); panelRenamer.add(txtpntAsciiHint, "8, 12, 5, 1, fill, fill"); JTextPane txtrChooseAFolder = new JTextPane(); txtrChooseAFolder.setOpaque(false); txtrChooseAFolder.setEditable(false); TmmFontHelper.changeFont(txtrChooseAFolder, 0.833); txtrChooseAFolder.setText(BUNDLE.getString("Settings.movie.renamer.example")); //$NON-NLS-1$ txtrChooseAFolder.setBackground(UIManager.getColor("Panel.background")); panelRenamer.add(txtrChooseAFolder, "2, 14, 3, 3, fill, top"); chckbxRemoveOtherNfos = new JCheckBox(BUNDLE.getString("Settings.renamer.removenfo")); //$NON-NLS-1$ panelRenamer.add(chckbxRemoveOtherNfos, "8, 14, 5, 1"); lblSubtitleLanguage = new JLabel(BUNDLE.getString("Settings.renamer.language")); //$NON-NLS-1$ panelRenamer.add(lblSubtitleLanguage, "8, 16, right, default"); cbSubtitleLanguage = new JComboBox(LanguageStyle.values()); panelRenamer.add(cbSubtitleLanguage, "10, 16, 3, 1, fill, default"); exampleEventList = GlazedLists.threadSafeList(new ObservableElementList<>( new BasicEventList<MovieRenamerExample>(), GlazedLists.beanConnector(MovieRenamerExample.class))); DefaultEventTableModel<MovieRenamerExample> exampleTableModel = new DefaultEventTableModel<>( GlazedListsSwing.swingThreadProxyList(exampleEventList), new MovieRenamerExampleTableFormat()); panelExample = new JPanel(); panelExample.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.example"), TitledBorder.LEADING, //$NON-NLS-1$ TitledBorder.TOP, null, null)); add(panelExample, "2, 4, fill, fill"); panelExample.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormFactory.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("50dlu:grow"), FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, })); JLabel lblExampleT = new JLabel(BUNDLE.getString("tmm.movie")); //$NON-NLS-1$ panelExample.add(lblExampleT, "2, 2"); cbMovieForPreview = new JComboBox(); panelExample.add(cbMovieForPreview, "4, 2"); lblExample = new JLabel(""); panelExample.add(lblExample, "2, 4, 3, 1"); TmmFontHelper.changeFont(lblExample, 0.916, Font.BOLD); tableExamples = new ZebraJTable(exampleTableModel); scrollPane = ZebraJTable.createStripedJScrollPane(tableExamples); scrollPane.setViewportView(tableExamples); panelExample.add(scrollPane, "2, 6, 3, 1, fill, fill"); JTextPane txtpntTitle = new JTextPane(); txtpntTitle.setOpaque(false); panelExample.add(txtpntTitle, "2, 8, 3, 1"); TmmFontHelper.changeFont(txtpntTitle, 0.833); txtpntTitle.setBackground(UIManager.getColor("Panel.background")); txtpntTitle.setText(BUNDLE.getString("Settings.movie.renamer.optional")); //$NON-NLS-1$ txtpntTitle.setEditable(false); cbMovieForPreview.addActionListener(actionCreateRenamerExample); initDataBindings(); // space separator String replacement = settings.getMovieRenamerSpaceReplacement(); int index = separators.indexOf(replacement); if (index >= 0) { cbSeparator.setSelectedIndex(index); } // language style cbSubtitleLanguage.setSelectedItem(settings.getMovieRenamerLanguageStyle()); // examples exampleEventList.add(new MovieRenamerExample("$T")); exampleEventList.add(new MovieRenamerExample("$O")); exampleEventList.add(new MovieRenamerExample("$1")); exampleEventList.add(new MovieRenamerExample("$E")); exampleEventList.add(new MovieRenamerExample("$2")); exampleEventList.add(new MovieRenamerExample("$Y")); exampleEventList.add(new MovieRenamerExample("$M")); exampleEventList.add(new MovieRenamerExample("$N")); exampleEventList.add(new MovieRenamerExample("$I")); exampleEventList.add(new MovieRenamerExample("$C")); exampleEventList.add(new MovieRenamerExample("$D")); exampleEventList.add(new MovieRenamerExample("$G")); exampleEventList.add(new MovieRenamerExample("$L")); exampleEventList.add(new MovieRenamerExample("$R")); exampleEventList.add(new MovieRenamerExample("$A")); exampleEventList.add(new MovieRenamerExample("$V")); exampleEventList.add(new MovieRenamerExample("$F")); exampleEventList.add(new MovieRenamerExample("$S")); exampleEventList.add(new MovieRenamerExample("$#")); exampleEventList.add(new MovieRenamerExample("$3")); exampleEventList.add(new MovieRenamerExample("$U")); }
From source file:org.tinymediamanager.ui.settings.GeneralSettingsPanel.java
/** * Instantiates a new general settings panel. *//* ww w. j av a 2 s. com*/ public GeneralSettingsPanel() { setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("left:max(200px;min):grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(200px;default):grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); JPanel panelUI = new JPanel(); panelUI.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.ui"), TitledBorder.LEADING, //$NON-NLS-1$ TitledBorder.TOP, null, null)); add(panelUI, "2, 2, 3, 1, fill, fill"); panelUI.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("100dlu"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.UNRELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.UNRELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); LocaleComboBox actualLocale = null; // cbLanguage = new JComboBox(Utils.getLanguages().toArray()); Locale settingsLang = Utils.getLocaleFromLanguage(Globals.settings.getLanguage()); for (Locale l : Utils.getLanguages()) { LocaleComboBox localeComboBox = new LocaleComboBox(l); locales.add(localeComboBox); if (l.equals(settingsLang)) { actualLocale = localeComboBox; } } JLabel lblUiLanguage = new JLabel(BUNDLE.getString("Settings.language")); panelUI.add(lblUiLanguage, "2, 2"); cbLanguage = new JComboBox(locales.toArray()); panelUI.add(cbLanguage, "4, 2"); if (actualLocale != null) { cbLanguage.setSelectedItem(actualLocale); } JSeparator separator = new JSeparator(); separator.setOrientation(SwingConstants.VERTICAL); panelUI.add(separator, "8, 2, 1, 7"); JLabel lblFontFamily = new JLabel(BUNDLE.getString("Settings.fontfamily")); //$NON-NLS-1$ panelUI.add(lblFontFamily, "10, 2, right, default"); GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment(); cbFontFamily = new JComboBox(env.getAvailableFontFamilyNames()); cbFontFamily.setSelectedItem(Globals.settings.getFontFamily()); int index = cbFontFamily.getSelectedIndex(); if (index < 0) { cbFontFamily.setSelectedItem("Dialog"); index = cbFontFamily.getSelectedIndex(); } if (index < 0) { cbFontFamily.setSelectedIndex(0); } panelUI.add(cbFontFamily, "12, 2, fill, default"); JLabel lblFontSize = new JLabel(BUNDLE.getString("Settings.fontsize")); //$NON-NLS-1$ panelUI.add(lblFontSize, "10, 4, right, default"); cbFontSize = new JComboBox(DEFAULT_FONT_SIZES); cbFontSize.setSelectedItem(Globals.settings.getFontSize()); index = cbFontSize.getSelectedIndex(); if (index < 0) { cbFontSize.setSelectedIndex(0); } panelUI.add(cbFontSize, "12, 4, fill, default"); JPanel panel = new JPanel(); panelUI.add(panel, "2, 6, 5, 1, fill, fill"); panel.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("100dlu"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), }, new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); JLabel lblMissingTranslation = new JLabel(BUNDLE.getString("tmm.helptranslate")); panel.add(lblMissingTranslation, "1, 1, 5, 1"); lblLinkTransifex = new LinkLabel("https://www.transifex.com/projects/p/tinymediamanager/"); panel.add(lblLinkTransifex, "1, 3, 5, 1"); lblLinkTransifex.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { try { TmmUIHelper.browseUrl(lblLinkTransifex.getNormalText()); } catch (Exception e) { LOGGER.error(e.getMessage()); MessageManager.instance .pushMessage(new Message(MessageLevel.ERROR, lblLinkTransifex.getNormalText(), "message.erroropenurl", new String[] { ":", e.getLocalizedMessage() }));//$NON-NLS-2$ } } }); tpFontHint = new JTextPane(); tpFontHint.setOpaque(false); TmmFontHelper.changeFont(tpFontHint, 0.833); tpFontHint.setText(BUNDLE.getString("Settings.fonts.hint")); //$NON-NLS-1$ panelUI.add(tpFontHint, "10, 6, 5, 1"); lblLanguageHint = new JLabel(""); TmmFontHelper.changeFont(lblLanguageHint, Font.BOLD); panelUI.add(lblLanguageHint, "2, 8, 5, 1"); lblFontChangeHint = new JLabel(""); TmmFontHelper.changeFont(lblFontChangeHint, Font.BOLD); panelUI.add(lblFontChangeHint, "10, 8, 5, 1"); JPanel panelMemory = new JPanel(); panelMemory.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.memoryborder"), //$NON-NLS-1$ TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelMemory, "2, 4, fill, fill"); panelMemory.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("250px:grow(4)"), FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(20dlu;default)"), ColumnSpec.decode("left:default:grow(5)"), }, new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormFactory.RELATED_GAP_ROWSPEC, })); JLabel lblMemoryT = new JLabel(BUNDLE.getString("Settings.memory")); //$NON-NLS-1$ panelMemory.add(lblMemoryT, "2, 1"); sliderMemory = new JSlider(); sliderMemory.setPaintLabels(true); sliderMemory.setPaintTicks(true); sliderMemory.setSnapToTicks(true); sliderMemory.setMajorTickSpacing(512); sliderMemory.setMinorTickSpacing(128); sliderMemory.setMinimum(256); sliderMemory.setMaximum(1536); sliderMemory.setValue(512); panelMemory.add(sliderMemory, "4, 1, fill, default"); lblMemory = new JLabel("512"); //$NON-NLS-1$ panelMemory.add(lblMemory, "6, 1, right, default"); JLabel lblMb = new JLabel("MB"); panelMemory.add(lblMb, "7, 1, left, default"); tpMemoryHint = new JTextPane(); tpMemoryHint.setOpaque(false); tpMemoryHint.setText(BUNDLE.getString("Settings.memory.hint")); //$NON-NLS-1$ TmmFontHelper.changeFont(tpMemoryHint, 0.833); panelMemory.add(tpMemoryHint, "2, 3, 6, 1, fill, fill"); JPanel panelProxySettings = new JPanel(); panelProxySettings.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.proxy"), //$NON-NLS-1$ TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelProxySettings, "4, 4, fill, fill"); panelProxySettings.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, })); JLabel lblProxyHost = new JLabel(BUNDLE.getString("Settings.proxyhost")); //$NON-NLS-1$ panelProxySettings.add(lblProxyHost, "2, 2, right, default"); tfProxyHost = new JTextField(); lblProxyHost.setLabelFor(tfProxyHost); panelProxySettings.add(tfProxyHost, "4, 2, fill, default"); tfProxyHost.setColumns(10); JLabel lblProxyPort = new JLabel(BUNDLE.getString("Settings.proxyport")); //$NON-NLS-1$ panelProxySettings.add(lblProxyPort, "2, 4, right, default"); tfProxyPort = new JTextField(); lblProxyPort.setLabelFor(tfProxyPort); panelProxySettings.add(tfProxyPort, "4, 4, fill, default"); tfProxyPort.setColumns(10); JLabel lblProxyUser = new JLabel(BUNDLE.getString("Settings.proxyuser")); //$NON-NLS-1$ panelProxySettings.add(lblProxyUser, "2, 6, right, default"); tfProxyUsername = new JTextField(); lblProxyUser.setLabelFor(tfProxyUsername); panelProxySettings.add(tfProxyUsername, "4, 6, fill, default"); tfProxyUsername.setColumns(10); JLabel lblProxyPassword = new JLabel(BUNDLE.getString("Settings.proxypass")); //$NON-NLS-1$ panelProxySettings.add(lblProxyPassword, "2, 8, right, default"); tfProxyPassword = new JPasswordField(); lblProxyPassword.setLabelFor(tfProxyPassword); panelProxySettings.add(tfProxyPassword, "4, 8, fill, default"); JPanel panelMediaPlayer = new JPanel(); panelMediaPlayer.setBorder( new TitledBorder(null, "MediaPlayer", TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelMediaPlayer, "2, 6, fill, fill"); panelMediaPlayer.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); tpMediaPlayer = new JTextPane(); tpMediaPlayer.setOpaque(false); TmmFontHelper.changeFont(tpMediaPlayer, 0.833); tpMediaPlayer.setText(BUNDLE.getString("Settings.mediaplayer.hint")); //$NON-NLS-1$ panelMediaPlayer.add(tpMediaPlayer, "2, 2, 3, 1, fill, fill"); tfMediaPlayer = new JTextField(); panelMediaPlayer.add(tfMediaPlayer, "2, 4, fill, default"); tfMediaPlayer.setColumns(10); btnSearchMediaPlayer = new JButton(BUNDLE.getString("Button.chooseplayer")); //$NON-NLS-1$ btnSearchMediaPlayer.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { Path file = TmmUIHelper.selectFile(BUNDLE.getString("Button.chooseplayer")); //$NON-NLS-1$ if (file != null && Utils.isRegularFile(file) || Platform.isMac()) { tfMediaPlayer.setText(file.toAbsolutePath().toString()); } } }); panelMediaPlayer.add(btnSearchMediaPlayer, "4, 4"); JPanel panelCache = new JPanel(); panelCache.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.cache"), TitledBorder.LEADING, //$NON-NLS-1$ TitledBorder.TOP, null, null)); add(panelCache, "4, 6, fill, fill"); panelCache.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); chckbxImageCache = new JCheckBox(BUNDLE.getString("Settings.imagecache"));//$NON-NLS-1$ panelCache.add(chckbxImageCache, "2, 2, 3, 1"); JLabel lblImageCacheQuality = new JLabel(BUNDLE.getString("Settings.imagecachetype"));//$NON-NLS-1$ panelCache.add(lblImageCacheQuality, "2, 4, right, default"); cbImageCacheQuality = new JComboBox(ImageCache.CacheType.values()); panelCache.add(cbImageCacheQuality, "4, 4, fill, default"); JPanel panelAnalytics = new JPanel(); panelAnalytics.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.analytics.border"), //$NON-NLS-1$ TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelAnalytics, "2, 8, fill, fill"); panelAnalytics.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LINE_GAP_ROWSPEC, })); chckbxAnalytics = new JCheckBox(BUNDLE.getString("Settings.analytics"));//$NON-NLS-1$ panelAnalytics.add(chckbxAnalytics, "2, 2"); JTextPane tpAnalyticsDescription = new JTextPane(); tpAnalyticsDescription.setText(BUNDLE.getString("Settings.analytics.desc"));//$NON-NLS-1$ tpAnalyticsDescription.setOpaque(false); panelAnalytics.add(tpAnalyticsDescription, "2, 4, fill, fill"); JPanel panelMisc = new JPanel(); panelMisc.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.misc"), TitledBorder.LEADING, //$NON-NLS-1$ TitledBorder.TOP, null, null)); add(panelMisc, "4, 8, fill, fill"); panelMisc.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormFactory.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, })); chckbxDeleteTrash = new JCheckBox(BUNDLE.getString("Settings.deletetrash")); panelMisc.add(chckbxDeleteTrash, "2, 2, 3, 1"); initDataBindings(); initMemorySlider(); // listen to changes of the combo box ItemListener listener = new ItemListener() { public void itemStateChanged(ItemEvent e) { checkChanges(); } }; cbLanguage.addItemListener(listener); cbFontSize.addItemListener(listener); cbFontFamily.addItemListener(listener); }
From source file:org.tinymediamanager.ui.tvshows.TvShowDetailsPanel.java
/** * Instantiates a new tv show details panel. * //w w w . j av a 2s . co m * @param selectionModel * the selection model */ public TvShowDetailsPanel(TvShowSelectionModel selectionModel) { this.selectionModel = selectionModel; setLayout(new FormLayout(new ColumnSpec[] { FormFactory.DEFAULT_COLSPEC, ColumnSpec.decode("25px"), ColumnSpec.decode("default:grow"), FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, ColumnSpec.decode("25px"), ColumnSpec.decode("default:grow(2)"), }, new RowSpec[] { FormFactory.NARROW_LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.NARROW_LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.NARROW_LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.NARROW_LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.NARROW_LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.NARROW_LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.NARROW_LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, })); JLabel lblPremieredT = new JLabel(BUNDLE.getString("metatag.premiered")); //$NON-NLS-1$ setBoldLabel(lblPremieredT); add(lblPremieredT, "1, 2"); lblPremiered = new JLabel(""); add(lblPremiered, "3, 2"); JLabel lblYearT = new JLabel(BUNDLE.getString("metatag.year")); //$NON-NLS-1$ setBoldLabel(lblYearT); add(lblYearT, "5, 2"); lblYear = new JLabel(""); add(lblYear, "7, 2"); JLabel lblStatusT = new JLabel(BUNDLE.getString("metatag.status")); //$NON-NLS-1$ setBoldLabel(lblStatusT); add(lblStatusT, "1, 4"); lblStatus = new JLabel(""); add(lblStatus, "3, 4"); JLabel lblImdbIdT = new JLabel("IMDB Id"); setBoldLabel(lblImdbIdT); add(lblImdbIdT, "5, 4"); lblImdbId = new LinkLabel(""); lblImdbId.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { String url = "http://www.imdb.com/title/" + lblImdbId.getNormalText(); try { TmmUIHelper.browseUrl(url); } catch (Exception e) { LOGGER.error("browse to imdbid", e); MessageManager.instance.pushMessage(new Message(MessageLevel.ERROR, url, "message.erroropenurl", new String[] { ":", e.getLocalizedMessage() })); } } }); add(lblImdbId, "7, 4"); lblImdbIdT.setLabelFor(lblImdbId); JLabel lblStudioT = new JLabel(BUNDLE.getString("metatag.studio")); //$NON-NLS-1$ setBoldLabel(lblStudioT); add(lblStudioT, "1, 6"); lblStudio = new JLabel(""); add(lblStudio, "3, 6"); JLabel lblThetvdbIdT = new JLabel("TheTVDB Id"); setBoldLabel(lblThetvdbIdT); add(lblThetvdbIdT, "5, 6"); lblThetvdbId = new LinkLabel(""); lblThetvdbId.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { String url = "http://thetvdb.com/?tab=series&id=" + lblThetvdbId.getNormalText(); try { TmmUIHelper.browseUrl(url); } catch (Exception e) { LOGGER.error("browse to thetvdb", e); MessageManager.instance.pushMessage(new Message(MessageLevel.ERROR, url, "message.erroropenurl", new String[] { ":", e.getLocalizedMessage() })); } } }); add(lblThetvdbId, "7, 6"); lblThetvdbIdT.setLabelFor(lblThetvdbId); JLabel lblCertificationT = new JLabel(BUNDLE.getString("metatag.certification")); //$NON-NLS-1$ setBoldLabel(lblCertificationT); add(lblCertificationT, "1, 8"); lblCertificationT.setLabelFor(lblCertification); lblCertification = new JLabel(""); add(lblCertification, "3, 8, 5, 1"); JLabel lblGenresT = new JLabel(BUNDLE.getString("metatag.genre")); //$NON-NLS-1$ setBoldLabel(lblGenresT); add(lblGenresT, "1, 10"); lblGenresT.setLabelFor(lblGenres); lblGenres = new JLabel(""); add(lblGenres, "3, 10, 5, 1"); JLabel lblTagsT = new JLabel(BUNDLE.getString("metatag.tags")); //$NON-NLS-1$ setBoldLabel(lblTagsT); add(lblTagsT, "1, 12"); lblGenresT.setLabelFor(lblTags); lblTags = new JLabel(""); add(lblTags, "3, 12, 5, 1"); JLabel lblPathT = new JLabel(BUNDLE.getString("metatag.path")); //$NON-NLS-1$ setBoldLabel(lblPathT); add(lblPathT, "1, 14"); lblPath = new LinkLabel(""); lblPathT.setLabelFor(lblPath); lblPath.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (!StringUtils.isEmpty(lblPath.getNormalText())) { // get the location from the label Path path = Paths.get(lblPath.getNormalText()); try { // check whether this location exists if (Files.exists(path)) { TmmUIHelper.openFile(path); } } catch (Exception ex) { LOGGER.error("open filemanager", ex); MessageManager.instance.pushMessage(new Message(MessageLevel.ERROR, path, "message.erroropenfolder", new String[] { ":", ex.getLocalizedMessage() })); } } } }); add(lblPath, "3, 14, 5, 1"); initDataBindings(); }
From source file:org.tinymediamanager.ui.tvshows.TvShowEpisodeDetailsPanel.java
/** * Instantiates a new tv show episode details panel. * //w w w.j ava2s .c om * @param model * the selection model */ public TvShowEpisodeDetailsPanel(TvShowEpisodeSelectionModel model) { this.selectionModel = model; setLayout(new FormLayout(new ColumnSpec[] { FormFactory.LABEL_COMPONENT_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, ColumnSpec.decode("25px"), ColumnSpec.decode("default:grow"), FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("55px"), FormFactory.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormFactory.DEFAULT_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.NARROW_LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.NARROW_LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.NARROW_LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.NARROW_LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, })); JLabel lblSeasonT = new JLabel(BUNDLE.getString("metatag.season")); //$NON-NLS-1$ TmmFontHelper.changeFont(lblSeasonT, 1.166, Font.BOLD); add(lblSeasonT, "2, 1"); lblSeason = new JLabel(""); TmmFontHelper.changeFont(lblSeason, 1.166); add(lblSeason, "4, 1"); btnPlay = new JButton(""); btnPlay.setIcon(IconManager.PLAY); btnPlay.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { MediaFile mf = selectionModel.getSelectedTvShowEpisode().getMediaFiles(MediaFileType.VIDEO).get(0); try { TmmUIHelper.openFile(mf.getFileAsPath()); } catch (Exception e) { LOGGER.error("open file", e); MessageManager.instance.pushMessage(new Message(MessageLevel.ERROR, mf, "message.erroropenfile", new String[] { ":", e.getLocalizedMessage() })); } } }); add(btnPlay, "6, 1, 1, 4"); JLabel lblEpisodeT = new JLabel(BUNDLE.getString("metatag.episode")); //$NON-NLS-1$ TmmFontHelper.changeFont(lblEpisodeT, 1.166, Font.BOLD); add(lblEpisodeT, "2, 2"); lblEpisode = new JLabel(""); TmmFontHelper.changeFont(lblEpisode, 1.166); add(lblEpisode, "4, 2"); JLabel lblAiredT = new JLabel(BUNDLE.getString("metatag.aired")); //$NON-NLS-1$ lblAiredT.setFont(lblAiredT.getFont().deriveFont(Font.BOLD)); add(lblAiredT, "2, 4"); lblAired = new JLabel(""); add(lblAired, "4, 4"); JLabel lblTagsT = new JLabel(BUNDLE.getString("metatag.tags")); //$NON-NLS-1$ lblTagsT.setFont(lblTagsT.getFont().deriveFont(Font.BOLD)); add(lblTagsT, "2, 6"); lblTags = new JLabel(""); add(lblTags, "4, 6"); JLabel lblDateAddedT = new JLabel(BUNDLE.getString("metatag.dateadded")); //$NON-NLS-1$ lblDateAddedT.setFont(lblDateAddedT.getFont().deriveFont(Font.BOLD)); add(lblDateAddedT, "2, 8"); lblDateAdded = new JLabel(""); add(lblDateAdded, "4, 8"); JLabel lblPathT = new JLabel(BUNDLE.getString("metatag.path")); //$NON-NLS-1$ lblPathT.setFont(lblPathT.getFont().deriveFont(Font.BOLD)); add(lblPathT, "2, 10"); lblPath = new LinkLabel(""); lblPathT.setLabelFor(lblPath); lblPath.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { if (!StringUtils.isEmpty(lblPath.getNormalText())) { // get the location from the label Path path = Paths.get(lblPath.getNormalText()); try { // check whether this location exists if (Files.exists(path)) { TmmUIHelper.openFile(path); } } catch (Exception ex) { LOGGER.error("open filemanager", ex); MessageManager.instance.pushMessage(new Message(MessageLevel.ERROR, path, "message.erroropenfolder", new String[] { ":", ex.getLocalizedMessage() })); } } } }); add(lblPath, "4, 10, 3, 1"); initDataBindings(); }
From source file:pl.otros.logview.filter.MultipleSelectionFilter.java
public MultipleSelectionFilter(String name, String desc, String label, char mnemonic) { super(name, desc); this.name = name; this.desc = desc; this.label = label; this.mnemonic = mnemonic; selectedItems = new HashSet<>(); listModel = new DefaultListModel<>(); jList = new JList<>(listModel); jList.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); jList.addListSelectionListener(e -> { if (!e.getValueIsAdjusting()) { selectedItems.clear();/* w w w.jav a 2 s.co m*/ Object[] selectedValues = jList.getSelectedValues(); for (Object selectedValue : selectedValues) { selectedItems.add((String) selectedValue); } listener.valueChanged(); } }); JLabel jLabel = new JLabel(label); jLabel.setLabelFor(jList); jLabel.setDisplayedMnemonic(mnemonic); panel = new JPanel(new MigLayout()); panel.add(jLabel, "wrap"); jList.setVisibleRowCount(5); JScrollPane jScrollPane = new JScrollPane(jList); jScrollPane.setPreferredSize(new Dimension(100, 100)); jScrollPane.setMinimumSize(new Dimension(100, 100)); panel.add(new JScrollPane(jList), "wrap, right, growx"); panel.add(new JLabel("Use CTRL for multi selection"), "wrap"); panel.add(new JXHyperlink(new AbstractAction("Invert selection") { @Override public void actionPerformed(ActionEvent e) { invertSelection(); } }), "wrap"); panel.add(new JXHyperlink(new AbstractAction("Clear selection") { @Override public void actionPerformed(ActionEvent e) { clearSelection(); } }), "wrap"); panel.add(new JXHyperlink(new AbstractAction("Reload threads") { @Override public void actionPerformed(ActionEvent e) { reloadFilterSet(); } }), "wrap"); }
From source file:pl.otros.logview.filter.ThreadFilter.java
public ThreadFilter() { super(NAME, DESCRIPTION); selectedThread = new HashSet<String>(); listModel = new DefaultListModel(); jList = new JList(listModel); jList.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); jList.addListSelectionListener(new ListSelectionListener() { @Override// w ww .j av a 2s. com public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { selectedThread.clear(); Object[] selectedValues = jList.getSelectedValues(); for (Object selectedValue : selectedValues) { selectedThread.add((String) selectedValue); } listener.valueChanged(); } } }); JLabel jLabel = new JLabel("Threads:"); jLabel.setLabelFor(jList); jLabel.setDisplayedMnemonic('t'); panel = new JPanel(new MigLayout()); panel.add(jLabel, "wrap"); panel.add(new JScrollPane(jList), "wrap, right, growx"); panel.add(new JLabel("Use CTRL for multi selection"), "wrap"); panel.add(new JXHyperlink(new AbstractAction("Invert selection") { @Override public void actionPerformed(ActionEvent e) { invertSelection(); } }), "wrap"); panel.add(new JXHyperlink(new AbstractAction("Clear selection") { @Override public void actionPerformed(ActionEvent e) { clearSelection(); } }), "wrap"); panel.add(new JXHyperlink(new AbstractAction("Reload threads") { @Override public void actionPerformed(ActionEvent e) { reloadThreads(); } }), "wrap"); }
From source file:pl.otros.vfs.browser.VfsBrowser.java
License:asdf
private void initGui(final String initialPath) { this.setLayout(new BorderLayout()); JLabel pathLabel = new JLabel(Messages.getMessage("browser.location")); pathLabel.setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 3)); pathField = new JTextField(80); pathField.setFont(pathLabel.getFont().deriveFont(pathLabel.getFont().getSize() * 1.2f)); pathField.setToolTipText(Messages.getMessage("nav.pathTooltip")); GuiUtils.addBlinkOnFocusGain(pathField); pathLabel.setLabelFor(pathField); pathLabel.setDisplayedMnemonic(Messages.getMessage("browser.location.mnemonic").charAt(0)); InputMap inputMapPath = pathField.getInputMap(JComponent.WHEN_FOCUSED); inputMapPath.put(KeyStroke.getKeyStroke("ENTER"), "OPEN_PATH"); inputMapPath.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), ACTION_FOCUS_ON_TABLE); pathField.getActionMap().put("OPEN_PATH", new BaseNavigateAction(this) { @Override//from w ww. j ava 2 s.com protected void performLongOperation(CheckBeforeActionResult actionResult) { try { FileObject resolveFile = VFSUtils.resolveFileObject(pathField.getText().trim()); if (resolveFile != null && resolveFile.getType() == FileType.FILE) { loadAndSelSingleFile(resolveFile); pathField.setText(resolveFile.getURL().toString()); actionApproveDelegate.actionPerformed( // TODO: Does actionResult provide an ID for 2nd param here, // or should use a Random number? new ActionEvent(actionResult, (int) new java.util.Date().getTime(), "SELECTED_FILE")); return; } } catch (FileSystemException fse) { // Intentionally empty } goToUrl(pathField.getText().trim()); } @Override protected boolean canGoUrl() { return true; } @Override protected boolean canExecuteDefaultAction() { return false; } }); actionFocusOnTable = new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { tableFiles.requestFocusInWindow(); if (tableFiles.getSelectedRow() < 0 && tableFiles.getRowCount() == 0) { tableFiles.getSelectionModel().setSelectionInterval(0, 0); } } }; pathField.getActionMap().put(ACTION_FOCUS_ON_TABLE, actionFocusOnTable); BaseNavigateActionGoUp goUpAction = new BaseNavigateActionGoUp(this); goUpButton = new JButton(goUpAction); BaseNavigateActionRefresh refreshAction = new BaseNavigateActionRefresh(this); JButton refreshButton = new JButton(refreshAction); JToolBar upperPanel = new JToolBar(Messages.getMessage("nav.ToolBarName")); upperPanel.setRollover(true); upperPanel.add(pathLabel); upperPanel.add(pathField, "growx"); upperPanel.add(goUpButton); upperPanel.add(refreshButton); AddCurrentLocationToFavoriteAction addCurrentLocationToFavoriteAction = new AddCurrentLocationToFavoriteAction( this); JButton addCurrentLocationToFavoriteButton = new JButton(addCurrentLocationToFavoriteAction); addCurrentLocationToFavoriteButton.setText(""); upperPanel.add(addCurrentLocationToFavoriteButton); previewComponent = new PreviewComponent(); vfsTableModel = new VfsTableModel(); tableFiles = new JTable(vfsTableModel); tableFiles.setFillsViewportHeight(true); tableFiles.getColumnModel().getColumn(0).setMinWidth(140); tableFiles.getColumnModel().getColumn(1).setMaxWidth(80); tableFiles.getColumnModel().getColumn(2).setMaxWidth(80); tableFiles.getColumnModel().getColumn(3).setMaxWidth(180); tableFiles.getColumnModel().getColumn(3).setMinWidth(120); sorter = new TableRowSorter<VfsTableModel>(vfsTableModel); final FileNameWithTypeComparator fileNameWithTypeComparator = new FileNameWithTypeComparator(); sorter.addRowSorterListener(new RowSorterListener() { @Override public void sorterChanged(RowSorterEvent e) { RowSorterEvent.Type type = e.getType(); if (type.equals(RowSorterEvent.Type.SORT_ORDER_CHANGED)) { List<? extends RowSorter.SortKey> sortKeys = e.getSource().getSortKeys(); for (RowSorter.SortKey sortKey : sortKeys) { if (sortKey.getColumn() == VfsTableModel.COLUMN_NAME) { fileNameWithTypeComparator.setSortOrder(sortKey.getSortOrder()); } } } } }); sorter.setComparator(VfsTableModel.COLUMN_NAME, fileNameWithTypeComparator); tableFiles.setRowSorter(sorter); tableFiles.setShowGrid(false); tableFiles.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { try { selectionChanged(); } catch (FileSystemException e1) { LOGGER.error("Error during update state", e); } } }); tableFiles.setColumnSelectionAllowed(false); vfsTableModel.addTableModelListener(new TableModelListener() { @Override public void tableChanged(TableModelEvent e) { updateStatusText(); } }); tableFiles.setDefaultRenderer(FileSize.class, new FileSizeTableCellRenderer()); tableFiles.setDefaultRenderer(FileNameWithType.class, new FileNameWithTypeTableCellRenderer()); tableFiles.setDefaultRenderer(Date.class, new MixedDateTableCellRenderer()); tableFiles.setDefaultRenderer(FileType.class, new FileTypeTableCellRenderer()); tableFiles.getSelectionModel().addListSelectionListener(new PreviewListener(this, previewComponent)); JPanel favoritesPanel = new JPanel(new MigLayout("wrap, fillx", "[grow]")); favoritesUserListModel = new MutableListModel<Favorite>(); List<Favorite> favSystemLocations = FavoritesUtils.getSystemLocations(); List<Favorite> favUser = FavoritesUtils.loadFromProperties(configuration); List<Favorite> favJVfsFileChooser = FavoritesUtils.getJvfsFileChooserBookmarks(); for (Favorite favorite : favUser) { favoritesUserListModel.add(favorite); } favoritesUserListModel.addListDataListener(new ListDataListener() { @Override public void intervalAdded(ListDataEvent e) { saveFavorites(); } @Override public void intervalRemoved(ListDataEvent e) { saveFavorites(); } @Override public void contentsChanged(ListDataEvent e) { saveFavorites(); } protected void saveFavorites() { FavoritesUtils.storeFavorites(configuration, favoritesUserListModel.getList()); } }); favoritesUserList = new JList(favoritesUserListModel); favoritesUserList.setTransferHandler(new MutableListDropHandler(favoritesUserList)); new MutableListDragListener(favoritesUserList); favoritesUserList.setCellRenderer(new FavoriteListCellRenderer()); favoritesUserList.addFocusListener(new SelectFirstElementFocusAdapter()); addOpenActionToList(favoritesUserList); addEditActionToList(favoritesUserList, favoritesUserListModel); favoritesUserList.getActionMap().put(ACTION_DELETE, new AbstractAction( Messages.getMessage("favorites.deleteButtonText"), Icons.getInstance().getMinusButton()) { @Override public void actionPerformed(ActionEvent e) { Favorite favorite = favoritesUserListModel.getElementAt(favoritesUserList.getSelectedIndex()); if (!Favorite.Type.USER.equals(favorite.getType())) { return; } int response = JOptionPane.showConfirmDialog(VfsBrowser.this, Messages.getMessage("favorites.areYouSureToDeleteConnections"), Messages.getMessage("favorites.confirm"), JOptionPane.YES_NO_OPTION); if (response == JOptionPane.YES_OPTION) { favoritesUserListModel.remove(favoritesUserList.getSelectedIndex()); } } }); InputMap favoritesListInputMap = favoritesUserList.getInputMap(JComponent.WHEN_FOCUSED); favoritesListInputMap.put(KeyStroke.getKeyStroke("DELETE"), ACTION_DELETE); ActionMap actionMap = tableFiles.getActionMap(); actionMap.put(ACTION_OPEN, new BaseNavigateActionOpen(this)); actionMap.put(ACTION_GO_UP, goUpAction); actionMap.put(ACTION_APPROVE, new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { if (actionApproveButton.isEnabled()) { actionApproveDelegate.actionPerformed(e); } } }); InputMap inputMap = tableFiles.getInputMap(JComponent.WHEN_FOCUSED); inputMap.put(KeyStroke.getKeyStroke("ENTER"), ACTION_OPEN); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, InputEvent.CTRL_MASK), ACTION_APPROVE); inputMap.put(KeyStroke.getKeyStroke("BACK_SPACE"), ACTION_GO_UP); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), ACTION_GO_UP); addPopupMenu(favoritesUserList, ACTION_OPEN, ACTION_EDIT, ACTION_DELETE); JList favoriteSystemList = new JList(new Vector<Object>(favSystemLocations)); favoriteSystemList.setCellRenderer(new FavoriteListCellRenderer()); addOpenActionToList(favoriteSystemList); addPopupMenu(favoriteSystemList, ACTION_OPEN); favoriteSystemList.addFocusListener(new SelectFirstElementFocusAdapter()); JList favoriteJVfsList = new JList(new Vector<Object>(favJVfsFileChooser)); addOpenActionToList(favoriteJVfsList); favoriteJVfsList.setCellRenderer(new FavoriteListCellRenderer()); addPopupMenu(favoriteJVfsList, ACTION_OPEN); favoriteJVfsList.addFocusListener(new SelectFirstElementFocusAdapter()); JLabel favoritesSystemLocationsLabel = getTitleListLabel(Messages.getMessage("favorites.systemLocations"), COMPUTER_ICON); favoritesSystemLocationsLabel.setLabelFor(favoriteSystemList); favoritesSystemLocationsLabel .setDisplayedMnemonic(Messages.getMessage("favorites.systemLocations.mnemonic").charAt(0)); favoritesPanel.add(favoritesSystemLocationsLabel, "gapleft 16"); favoritesPanel.add(favoriteSystemList, "growx"); JLabel favoritesFavoritesLabel = getTitleListLabel(Messages.getMessage("favorites.favorites"), Icons.getInstance().getStar()); favoritesFavoritesLabel.setLabelFor(favoritesUserList); favoritesFavoritesLabel.setDisplayedMnemonic(Messages.getMessage("favorites.favorites.mnemonic").charAt(0)); favoritesPanel.add(favoritesFavoritesLabel, "gapleft 16"); favoritesPanel.add(favoritesUserList, "growx"); if (favoriteJVfsList.getModel().getSize() > 0) { JLabel favoritesJVfsFileChooser = getTitleListLabel( Messages.getMessage("favorites.JVfsFileChooserBookmarks"), null); favoritesJVfsFileChooser.setDisplayedMnemonic( Messages.getMessage("favorites.JVfsFileChooserBookmarks.mnemonic").charAt(0)); favoritesJVfsFileChooser.setLabelFor(favoriteJVfsList); favoritesPanel.add(favoritesJVfsFileChooser, "gapleft 16"); favoritesPanel.add(favoriteJVfsList, "growx"); } tableFiles.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) { tableFiles.getActionMap().get(ACTION_OPEN).actionPerformed(null); } } }); tableFiles.addKeyListener(new QuickSearchKeyAdapter()); cardLayout = new CardLayout(); tablePanel = new JPanel(cardLayout); loadingProgressBar = new JProgressBar(); loadingProgressBar.setStringPainted(true); loadingProgressBar.setString(Messages.getMessage("browser.loading")); loadingProgressBar.setIndeterminate(true); loadingIconLabel = new JLabel(Icons.getInstance().getNetworkStatusOnline()); skipCheckingLinksButton = new JToggleButton(Messages.getMessage("browser.skipCheckingLinks")); skipCheckingLinksButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent actionEvent) { if (taskContext != null) { taskContext.setStop(skipCheckingLinksButton.isSelected()); } } }); showHidCheckBox = new JCheckBox(Messages.getMessage("browser.showHidden.label"), showHidden); showHidCheckBox.setToolTipText(Messages.getMessage("browser.showHidden.tooltip")); showHidCheckBox.setMnemonic(Messages.getMessage("browser.showHidden.mnemonic").charAt(0)); Font tmpFont = showHidCheckBox.getFont(); showHidCheckBox.setFont(tmpFont.deriveFont(tmpFont.getSize() * 0.9f)); showHidCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateUiFilters(); } }); final String defaultFilterText = Messages.getMessage("browser.nameFilter.defaultText"); filterField = new JTextField("", 16); filterField.setForeground(filterField.getDisabledTextColor()); filterField.setToolTipText(Messages.getMessage("browser.nameFilter.tooltip")); PromptSupport.setPrompt(defaultFilterText, filterField); filterField.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { documentChanged(); } void documentChanged() { if (filterField.getText().length() == 0) { updateUiFilters(); } } @Override public void removeUpdate(DocumentEvent e) { documentChanged(); } @Override public void changedUpdate(DocumentEvent e) { documentChanged(); } }); filterField.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { updateUiFilters(); } }); AbstractAction actionClearRegexFilter = new AbstractAction(Messages.getMessage("browser.nameFilter.clearFilterText")) { @Override public void actionPerformed(ActionEvent e) { filterField.setText(""); } }; filterField.getActionMap().put(ACTION_FOCUS_ON_TABLE, actionFocusOnTable); filterField.getActionMap().put(ACTION_CLEAR_REGEX_FILTER, actionClearRegexFilter); filterField.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke("ENTER"), ACTION_FOCUS_ON_TABLE); filterField.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0), ACTION_FOCUS_ON_TABLE); filterField.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0), ACTION_FOCUS_ON_TABLE); filterField.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), ACTION_FOCUS_ON_TABLE); filterField.getInputMap(WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), ACTION_CLEAR_REGEX_FILTER); JLabel nameFilterLabel = new JLabel(Messages.getMessage("browser.nameFilter")); nameFilterLabel.setLabelFor(filterField); nameFilterLabel.setDisplayedMnemonic(Messages.getMessage("browser.nameFilter.mnemonic").charAt(0)); sorter.setRowFilter(createFilter()); statusLabel = new JLabel(); actionApproveButton = new JButton(); actionApproveButton.setFont(actionApproveButton.getFont().deriveFont(Font.BOLD)); actionCancelButton = new JButton(); ActionMap browserActionMap = this.getActionMap(); browserActionMap.put(ACTION_FOCUS_ON_REGEX_FILTER, new AbstractAction() { @Override public void actionPerformed(ActionEvent e) { filterField.requestFocus(); filterField.selectAll(); GuiUtils.blinkComponent(filterField); } }); browserActionMap.put(ACTION_FOCUS_ON_PATH, new SetFocusOnAction(pathField)); browserActionMap.put(ACTION_SWITCH_SHOW_HIDDEN, new ClickOnJComponentAction(showHidCheckBox)); browserActionMap.put(ACTION_REFRESH, refreshAction); browserActionMap.put(ACTION_ADD_CURRENT_LOCATION_TO_FAVORITES, addCurrentLocationToFavoriteAction); browserActionMap.put(ACTION_GO_UP, goUpAction); browserActionMap.put(ACTION_FOCUS_ON_TABLE, new SetFocusOnAction(tableFiles)); InputMap browserInputMap = this.getInputMap(WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); browserInputMap.put(KeyStroke.getKeyStroke("control F"), ACTION_FOCUS_ON_REGEX_FILTER); browserInputMap.put(KeyStroke.getKeyStroke("control L"), ACTION_FOCUS_ON_PATH); browserInputMap.put(KeyStroke.getKeyStroke("F4"), ACTION_FOCUS_ON_PATH); browserInputMap.put(KeyStroke.getKeyStroke("control H"), ACTION_SWITCH_SHOW_HIDDEN); browserInputMap.put(KeyStroke.getKeyStroke("control R"), ACTION_REFRESH); browserInputMap.put(KeyStroke.getKeyStroke("F5"), ACTION_REFRESH); browserInputMap.put(KeyStroke.getKeyStroke("control D"), ACTION_ADD_CURRENT_LOCATION_TO_FAVORITES); browserInputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, KeyEvent.ALT_DOWN_MASK), ACTION_GO_UP); browserInputMap.put(KeyStroke.getKeyStroke("control T"), ACTION_FOCUS_ON_TABLE); //DO layout // create the layer for the panel using our custom layerUI tableScrollPane = new JScrollPane(tableFiles); JPanel tableScrollPaneWithFilter = new JPanel(new BorderLayout()); tableScrollPaneWithFilter.add(tableScrollPane); JToolBar filtersToolbar = new JToolBar("Filters"); filtersToolbar.setFloatable(false); filtersToolbar.setBorderPainted(true); tableScrollPaneWithFilter.add(filtersToolbar, BorderLayout.SOUTH); filtersToolbar.add(nameFilterLabel); filtersToolbar.add(filterField); filtersToolbar.add(showHidCheckBox); JSplitPane tableWithPreviewPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, tableScrollPaneWithFilter, previewComponent); tableWithPreviewPane.setOneTouchExpandable(true); JPanel loadingPanel = new JPanel(new MigLayout()); loadingPanel.add(loadingIconLabel, "right"); loadingPanel.add(loadingProgressBar, "left, w 420:420:500,wrap"); loadingPanel.add(skipCheckingLinksButton, "span, right"); tablePanel.add(loadingPanel, LOADING); tablePanel.add(tableWithPreviewPane, TABLE); JSplitPane jSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(favoritesPanel), tablePanel); jSplitPane.setOneTouchExpandable(true); jSplitPane.setDividerLocation(180); JPanel southPanel = new JPanel(new MigLayout("", "[]push[][]", "")); southPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); southPanel.add(statusLabel); southPanel.add(actionApproveButton); southPanel.add(actionCancelButton); this.add(upperPanel, BorderLayout.NORTH); this.add(jSplitPane, BorderLayout.CENTER); this.add(southPanel, BorderLayout.SOUTH); try { selectionChanged(); } catch (FileSystemException e) { LOGGER.error("Can't initialize default selection mode", e); } // Why this not done in EDT? // Is it assume that constructor is invoked from an EDT? try { if (initialPath == null) { goToUrl(VFSUtils.getUserHome()); } else { try { FileObject resolveFile = VFSUtils.resolveFileObject(initialPath); if (resolveFile != null && resolveFile.getType() == FileType.FILE) { loadAndSelSingleFile(resolveFile); pathField.setText(resolveFile.getURL().toString()); targetFileSelected = true; return; } } catch (FileSystemException fse) { // Intentionally empty } goToUrl(initialPath); } } catch (FileSystemException e1) { LOGGER.error("Can't initialize default location", e1); } showTable(); }
From source file:zxmax.tools.timerreview.gui.StartTimerWindow.java
private Component getPnlNewTimer() { setTitle(I18N.getLabel(getClass(), "window.title")); JPanel pnlNewTimer = new JPanel(); LayoutManager layout = new MigLayout("flowy", "[328.00][grow,fill]", "[][][][][]"); taFocusOn = new JTextArea(); taFocusOn.setWrapStyleWord(true);// ww w . jav a 2s. co m JScrollPane spFocusOn = new JScrollPane(); tfTitle = new JTextField(30); JButton btnStart = new JButton(); pnlNewTimer.setLayout(layout); btnStart.setText(I18N.getLabel(this.getClass(), TAB_NEW_TIMER_BTN_START_LABEL)); taFocusOn.setColumns(20); taFocusOn.setForeground(new Color(0, 153, 0)); taFocusOn.setRows(5); taFocusOn.setTabSize(2); taFocusOn.setText(I18N.getLabel(this.getClass(), TAB_NEW_TIMER_FOCUS_ON_TEXT_AREA_TEXT)); taFocusOn.setToolTipText(I18N.getLabel(this.getClass(), TAB_NEW_TIMER_FOCUS_ON_TEXT_AREA_TOOL_TIP)); spFocusOn.setViewportView(taFocusOn); taFocusOn.getAccessibleContext().setAccessibleName("taFocusOn"); btnStart.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent evt) { storeDataAndStartTimer(); } }); btnStart.addKeyListener(new KeyAdapter() { @Override public void keyPressed(KeyEvent evt) { logger.debug(evt.getKeyCode() + ", " + evt.getKeyChar()); if (KeyEvent.VK_ENTER == evt.getKeyCode()) { storeDataAndStartTimer(); } } }); JLabel lblTitle = new JLabel(I18N.getLabel(this.getClass(), TAB_NEW_TIMER_TITLE_LABEL)); pnlNewTimer.add(lblTitle, "cell 0 0"); pnlNewTimer.add(tfTitle, "cell 0 1 2 1,growx"); JLabel lblFocusOn = new JLabel(I18N.getLabel(this.getClass(), TAB_NEW_TIMER_FOCUS_ON_LABEL)); pnlNewTimer.add(lblFocusOn, "cell 0 2"); pnlNewTimer.add(spFocusOn, "cell 0 3 2 1,growx"); pnlNewTimer.add(btnStart, "cell 0 4 2 1,growx"); Box horizontalBox = Box.createHorizontalBox(); pnlNewTimer.add(horizontalBox, "flowx,cell 1 0"); JLabel lblDurata = new JLabel(I18N.getLabel(this.getClass(), TAB_NEW_TIMER_DURATA_LABEL)); lblDurata.setHorizontalAlignment(SwingConstants.RIGHT); pnlNewTimer.add(lblDurata, "cell 1 0,alignx right"); lblDurata.setLabelFor(txtDurata); txtDurata = new JTextField("20"); txtDurata.setToolTipText(I18N.getLabel(this.getClass(), TAB_NEW_TIMER_DURATA_TOOL_TIP)); pnlNewTimer.add(txtDurata, "cell 1 0,alignx center"); txtDurata.setColumns(2); return pnlNewTimer; }