List of usage examples for javax.swing JButton setEnabled
public void setEnabled(boolean b)
From source file:org.nuclos.client.dbtransfer.DBTransferImport.java
private PanelWizardStep newStep4(final MainFrameTab ifrm) { final SpringLocaleDelegate localeDelegate = getSpringLocaleDelegate(); final PanelWizardStep step = new PanelWizardStep( localeDelegate.getMessage("dbtransfer.import.step4.1", "Import"), localeDelegate.getMessage( "dbtransfer.import.step4.2", "Der Import der Konfiguration kann nun gestartet werden.")); utils.initJPanel(step, new double[] { 180, TableLayout.FILL }, new double[] { TableLayout.PREFERRED, 10, TableLayout.PREFERRED, TableLayout.PREFERRED }); final JLabel lbWarning = new JLabel("<html>" + localeDelegate.getMessage("dbtransfer.import.step4.3", " <b>Achtung</b>: Durch den Konfigurationsimport werden Teile der Konfiguration auf diesem System \u00fcberschrieben!<br>" + "Vor dem Import wird dringend empfohlen ein Backup der Datenbank durchzuf\u00fchren.<br><br>" + "Wollen Sie fortfahren und den Konfigurationimport starten?") + "</html>"); final JButton btnStartImport = new JButton( localeDelegate.getMessage("dbtransfer.import.step4.4", "importieren") + "..."); // final JProgressBar progressBar = new JProgressBar(0, 200); step.add(lbWarning, "0,0,1,0"); step.add(btnStartImport, "0,2"); // step.add(progressBar, "0,3"); btnStartImport.addActionListener(new ActionListener() { @Override//from w w w . j a v a 2s .c om public void actionPerformed(ActionEvent ae) { // progressBar.setValue(0); ifrm.lockLayerWithProgress(Transfer.TOPIC_CORRELATIONID_RUN); Thread t = new Thread() { @Override public void run() { try { btnStartImport.setEnabled(false); blnImportStarted = true; wizard.getModel().refreshModelState(); // progressBar.setVisible(true); // start configuration import if (chbxIncludeUser.isSelected()) { importTransferObject.getTransferOptions().put(TransferOption.IMPORT_USER, null); } else { importTransferObject.getTransferOptions().remove(TransferOption.IMPORT_USER); } if (chbxIncludeLDAP.isSelected()) { importTransferObject.getTransferOptions().put(TransferOption.IMPORT_USER, null); } else { importTransferObject.getTransferOptions().remove(TransferOption.IMPORT_USER); } if (chbxIncludeObjectimport.isSelected()) { importTransferObject.getTransferOptions().put(TransferOption.IMPORT_USER, null); } else { importTransferObject.getTransferOptions().remove(TransferOption.IMPORT_USER); } if (chbxAlternativeDBLogin.isSelected()) { importTransferObject.getTransferOptions().put(TransferOption.DBADMIN, tfAlternativeDBLogin.getText()); importTransferObject.getTransferOptions().put(TransferOption.DBADMIN_PASSWORD, new String(pfAlternativeDBPassword.getPassword())); } else { importTransferObject.getTransferOptions().remove(TransferOption.DBADMIN); importTransferObject.getTransferOptions().remove(TransferOption.DBADMIN_PASSWORD); } // create new parameter list Collection<EntityObjectVO> parameterSelection = new ArrayList<EntityObjectVO>(); for (ParameterEditor pe : lstParameterEditors) { if (pe.getParameter().isDeleted() && pe.isIncomingValue()) { // nothing to do. if parameter not in list runTransfer would delete it. } else { EntityObjectVO parameterCopy = new EntityObjectVO(); parameterCopy.initFields(pe.getParameter().getFields().size(), 0); parameterCopy.getFields().putAll(pe.getParameter().getFields()); parameterCopy.getFields().put("value", pe.getValue()); parameterSelection.add(parameterCopy); } } // copy transfer to add parameter list. // only temporary in case we go back one step, then we need the old list. Transfer transfer = new Transfer(importTransferObject); transfer.setParameter(parameterSelection); importTransferResult = getTransferFacadeRemote().runTransfer(transfer); // Nicht invalidateAllClientCaches() aufrufen! Nach einem Aufruf sind die Menus solange deaktiviert, // bis alle NovabitInternalFrames geschlossen wurden... BUG? // // Main.getMainController().invalidateAllClientCaches(); notifyParent .actionPerformed(new ActionEvent(DBTransferImport.this, 0, IMPORT_EXECUTED)); step.setComplete(true); model.nextStep(); } catch (Exception e) { // progressBar.setVisible(false); btnStartImport.setEnabled(true); blnImportStarted = false; wizard.getModel().refreshModelState(); Errors.getInstance().showExceptionDialog(ifrm, e); } finally { // progressBar.setVisible(false); ifrm.unlockLayer(); //invalidateAllCaches muss mit runCommandLater aufgerufen werden, da irgendeine Methode setzt den GlassPane //auf visible und nach dem Beenden der Aktion nicht mehr auf invisible. Aus disem Grund ist der Men\u00fc nicht "erreichbar". UIUtils.runCommandLater(Main.getInstance().getMainFrame(), new CommonRunnable() { @Override public void run() throws CommonBusinessException { Main.getInstance().getMainController().invalidateAllClientCaches(); } }); } } }; t.start(); } }); // progressBar.setVisible(false); return step; }
From source file:org.p_vcd.ui.VcdDialog.java
public VcdDialog() { setSize(700, 450);/*from ww w . j ava 2s . c o m*/ setTitle("P-VCD - Video Copy Detection"); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); this.currentStep = 1; getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, BorderLayout.CENTER); contentPanel.setLayout(new CardLayout(0, 0)); { JPanel panel_Step1 = new JPanel(); contentPanel.add(panel_Step1, "card_step1"); panel_Step1.setLayout(new BorderLayout(0, 0)); JLabel lblTitle = new JLabel("STEP 1 - Video Database (the \"known\")"); panel_Step1.add(lblTitle, BorderLayout.NORTH); lblTitle.setHorizontalAlignment(SwingConstants.CENTER); lblTitle.setFont(new Font("Tahoma", Font.PLAIN, 18)); JPanel panel_1 = new JPanel(); panel_Step1.add(panel_1, BorderLayout.CENTER); panel_1.setLayout(new MigLayout("", "[250px,grow][20px][250px,grow]", "[][][230px,grow][][][]")); JLabel lblNewLabel = new JLabel("Please select the video databases to search in:"); panel_1.add(lblNewLabel, "cell 0 0"); panel_1.add(lbl_refDbTitle, "cell 2 1"); JScrollPane scrollPane_1 = new JScrollPane(); panel_1.add(scrollPane_1, "cell 0 1 1 3,grow"); panel_refDatabasesList.setBackground(Color.WHITE); scrollPane_1.setViewportView(panel_refDatabasesList); panel_refDatabasesList.setLayout(new MigLayout("gapy 10", "[200px]", "[][]")); JScrollPane scrollPane = new JScrollPane(); scrollPane.setBorder(null); panel_1.add(scrollPane, "cell 2 2,grow"); scrollPane.setViewportView(lbl_refDbFiles); panel_1.add(lbl_refDbMetadata, "cell 2 3"); JButton btnNewDatabase = new JButton("New database..."); panel_1.add(btnNewDatabase, "cell 0 4"); btnNewDatabase.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { newDatabaseButton(); } }); } { JPanel panel_Step2 = new JPanel(); contentPanel.add(panel_Step2, "card_step2"); panel_Step2.setLayout(new BorderLayout(0, 0)); JLabel lblTitle = new JLabel("STEP 2 - Query (the \"unknown\")"); panel_Step2.add(lblTitle, BorderLayout.NORTH); lblTitle.setHorizontalAlignment(SwingConstants.CENTER); lblTitle.setFont(new Font("Tahoma", Font.PLAIN, 18)); JPanel panel = new JPanel(); panel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Query", TitledBorder.LEADING, TitledBorder.TOP, null, null)); panel_Step2.add(panel, BorderLayout.CENTER); panel.setLayout( new MigLayout("", "[160px][grow]", "[25px][grow,top][25px][grow,top][25px][grow,top][grow]")); ButtonGroup queryButtonGroup = new ButtonGroup(); queryButtonGroup.add(radio_queryFile); radio_queryFile.setFont(new Font("Tahoma", Font.PLAIN, 13)); panel.add(radio_queryFile, "cell 0 0"); lbl_queryFile.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { radio_queryFile.setSelected(true); } }); panel.add(lbl_queryFile, "flowy,cell 1 0"); JButton btnSelectFile = new JButton("Select File..."); btnSelectFile.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { selectFileButton(); } }); panel.add(btnSelectFile, "cell 1 0"); JLabel lblIumageOrVideo = new JLabel("Select an image or video in the local machine."); panel.add(lblIumageOrVideo, "cell 1 1"); queryButtonGroup.add(radio_queryUrl); radio_queryUrl.setFont(new Font("Tahoma", Font.PLAIN, 13)); panel.add(radio_queryUrl, "cell 0 2"); txt_queryUrl.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { radio_queryUrl.setSelected(true); } }); txt_queryUrl.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { radio_queryUrl.setSelected(true); } }); txt_queryUrl.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { radio_queryUrl.setSelected(true); } }); txt_queryUrl.setText("http://"); panel.add(txt_queryUrl, "flowy,cell 1 2"); txt_queryUrl.setColumns(50); JLabel lblUrlToA = new JLabel( "<html>Enter the URL to download an image or video.<br>You can use a URL like: http://www.youtube.com/watch?v=... </html>"); panel.add(lblUrlToA, "flowy,cell 1 3"); queryButtonGroup.add(radio_queryDb); radio_queryDb.setFont(new Font("Tahoma", Font.PLAIN, 13)); panel.add(radio_queryDb, "cell 0 4"); comboBox_queryDb.setMaximumRowCount(12); comboBox_queryDb.setPreferredSize(new Dimension(100, 20)); comboBox_queryDb.setMinimumSize(new Dimension(100, 20)); comboBox_queryDb.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (comboBox_queryDb.getSelectedIndex() > 0) radio_queryDb.setSelected(true); updateQueryDbDetail(); } }); comboBox_queryDb.addKeyListener(new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { if (comboBox_queryDb.getSelectedIndex() > 0) radio_queryDb.setSelected(true); updateQueryDbDetail(); } }); panel.add(comboBox_queryDb, "flowx,cell 1 4"); panel.add(lbl_queryDb, "cell 1 4"); JLabel lblPleaseNopteThe = new JLabel("<html>A search is run for each video in the database.</html>"); panel.add(lblPleaseNopteThe, "cell 1 5"); } { JPanel panel_Step3 = new JPanel(); contentPanel.add(panel_Step3, "card_step3"); panel_Step3.setLayout(new BorderLayout(0, 0)); JLabel lblTitle = new JLabel("STEP 3 - Search Options"); lblTitle.setFont(new Font("Tahoma", Font.PLAIN, 18)); lblTitle.setHorizontalAlignment(SwingConstants.CENTER); panel_Step3.add(lblTitle, BorderLayout.NORTH); JPanel panel2 = new JPanel(); panel2.setLayout(new FlowLayout()); panel_Step3.add(panel2, BorderLayout.CENTER); JPanel panel = new JPanel(); panel2.add(panel); panel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Basic Options", TitledBorder.LEADING, TitledBorder.TOP, null, null)); panel.setLayout(new MigLayout("gapy 5px", "[30px][101px]", "[][][][][][][20px]")); ButtonGroup buttonGroup = new ButtonGroup(); buttonGroup.add(radio_searchByGlobal); radio_searchByGlobal.setFont(new Font("Tahoma", Font.PLAIN, 13)); radio_searchByGlobal.setSelected(true); panel.add(radio_searchByGlobal, "cell 0 0 2 1,alignx left,aligny top"); JLabel lblNewLabel_2 = new JLabel( "Detects most of the copies that are visually alike to the original."); panel.add(lblNewLabel_2, "cell 1 1"); JButton btnOptions = new JButton("Advanced Options..."); btnOptions.setEnabled(false); panel.add(btnOptions, "cell 1 2"); buttonGroup.add(radio_searchByLocal); radio_searchByLocal.setFont(new Font("Tahoma", Font.PLAIN, 13)); panel.add(radio_searchByLocal, "cell 0 4 2 1,alignx left,aligny top"); JLabel lblNewLabel_3 = new JLabel( "Requires more resources (disk space, search time, memory) but can detect more copies."); panel.add(lblNewLabel_3, "cell 1 5"); JButton btnOptions_1 = new JButton("Advanced Options..."); btnOptions_1.setEnabled(false); panel.add(btnOptions_1, "cell 1 6"); } { JPanel panel_Step4 = new JPanel(); contentPanel.add(panel_Step4, "card_step4"); panel_Step4.setLayout(new BorderLayout(0, 0)); JLabel lblTitle = new JLabel("STEP 4 - Search"); lblTitle.setHorizontalAlignment(SwingConstants.CENTER); lblTitle.setFont(new Font("Tahoma", Font.PLAIN, 18)); panel_Step4.add(lblTitle, BorderLayout.NORTH); JScrollPane scrollPane = new JScrollPane(); panel_Step4.add(scrollPane, BorderLayout.CENTER); textConsole.setFont(new Font("Monospaced", Font.PLAIN, 11)); textConsole.setForeground(Color.WHITE); textConsole.setBackground(Color.BLACK); textConsole.setEditable(false); textConsole.setCursor(new Cursor(Cursor.TEXT_CURSOR)); textConsole.setText( "Press 'Next' button to start the search...\nNote: Depending on the selected options, the search may take up to several hours."); scrollPane.setViewportView(textConsole); JPanel panel = new JPanel(); panel_Step4.add(panel, BorderLayout.SOUTH); panel.setLayout(new GridLayout(0, 1, 0, 0)); JSeparator separator = new JSeparator(); separator.setPreferredSize(new Dimension(0, 1)); panel.add(separator); progressBar.setStringPainted(true); progressBar.setPreferredSize(new Dimension(350, 20)); panel.add(progressBar); lblProgress.setHorizontalAlignment(SwingConstants.CENTER); lblProgress.setFont(new Font("Tahoma", Font.PLAIN, 14)); panel.add(lblProgress); } { JPanel panel_Step5 = new JPanel(); contentPanel.add(panel_Step5, "card_step5"); panel_Step5.setLayout(new BorderLayout(0, 0)); JLabel lblTitle = new JLabel("STEP 5 - Results"); lblTitle.setHorizontalAlignment(SwingConstants.CENTER); lblTitle.setFont(new Font("Tahoma", Font.PLAIN, 18)); panel_Step5.add(lblTitle, BorderLayout.NORTH); JScrollPane scrollPane = new JScrollPane(); panel_Step5.add(scrollPane, BorderLayout.CENTER); scrollPane.setViewportView(panelResults); panelResults.setLayout(new MigLayout("gapy 10, gapx 20", "[120px,center][150px,center,grow][150px,center,grow]", "[25px][]")); } { JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); getContentPane().add(buttonPane, BorderLayout.SOUTH); { JButton prevButton = new JButton("Previous"); prevButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { previousButton(); } }); prevButton.setActionCommand("Previous"); buttonPane.add(prevButton); } { JButton okButton = new JButton("Next"); okButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { nextButton(); } }); okButton.setActionCommand("OK"); buttonPane.add(okButton); getRootPane().setDefaultButton(okButton); } { JButton cancelButton = new JButton("Cancel"); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { cancelButton(); } }); cancelButton.setActionCommand("Cancel"); buttonPane.add(cancelButton); } } this.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent e) { closeWindow(); } }); updateDatabases(null); }
From source file:org.revager.gui.findings_list.FindingsListFrame.java
private void createToolBar() { JButton tbConfirmProt = GUITools.newImageButton(Data.getInstance().getIcon("confirmProtocol_50x50_0.png"), Data.getInstance().getIcon("confirmProtocol_50x50.png")); tbConfirmProt.setToolTipText(translate("Confirm and close list of findings")); tbConfirmProt.addActionListener(e -> { if (StringUtils.isBlank(protCommTxtArea.getText())) { currentProt.setComments(""); }/*ww w.j a va 2 s. com*/ GUITools.executeSwingWorker(new ImageEditorWriteWorker(currentProt)); setVisible(false); UI.getInstance().getPresentationFrame().setVisible(false); }); addTopComponent(tbConfirmProt); JButton sepBttn = GUITools.newImageButton(); sepBttn.setIcon(Data.getInstance().getIcon("sep_50x50.png")); sepBttn.setEnabled(false); addTopComponent(sepBttn); JButton tbPdfExport = GUITools.newImageButton(Data.getInstance().getIcon("PDFExport_50x50_0.png"), Data.getInstance().getIcon("PDFExport_50x50.png")); tbPdfExport.setToolTipText(translate("Export List of Findings as PDF File")); tbPdfExport.addActionListener(e -> UI.getInstance().getExportPDFProtocolDialog().setVisible(true)); addTopComponent(tbPdfExport); JButton tbCsvExport = GUITools.newImageButton(Data.getInstance().getIcon("CSVExport_50x50_0.png"), Data.getInstance().getIcon("CSVExport_50x50.png")); tbCsvExport.setToolTipText(translate("Export List of Findings as CSV File")); tbCsvExport.addActionListener(e -> UI.getInstance().getExportCSVDialog().setVisible(true)); addTopComponent(tbCsvExport); JButton tbPresenationView = GUITools.newImageButton(Data.getInstance().getIcon("tv_50x50_0.png"), Data.getInstance().getIcon("tv_50x50.png")); tbPresenationView.setToolTipText(translate("Open Presentation View")); tbPresenationView.addActionListener((ActionEvent e) -> { PresentationFrame presentationFrame = UI.getInstance().getPresentationFrame(); presentationFrame.setVisible(!presentationFrame.isVisible()); }); addTopComponent(tbPresenationView); /* * Fullscreen */ tbFullscreen = GUITools.newImageButton(); if (fullscreen) { tbFullscreen.setIcon(Data.getInstance().getIcon("fullscreenClose_50x50_0.png")); tbFullscreen.setRolloverIcon(Data.getInstance().getIcon("fullscreenClose_50x50.png")); tbFullscreen.setToolTipText(translate("Exit Fullscreen")); } else { tbFullscreen.setIcon(Data.getInstance().getIcon("fullscreen_50x50_0.png")); tbFullscreen.setRolloverIcon(Data.getInstance().getIcon("fullscreen_50x50.png")); tbFullscreen.setToolTipText(translate("Change to Fullscreen mode")); } tbFullscreen.addActionListener(e -> UI.getInstance().getProtocolFrame(!isFullscreen()).setVisible(true)); addTopComponent(tbFullscreen); /* * current time */ clockCurrentTime.setFont(UI.VERY_LARGE_FONT); addTopRightComp(clockCurrentTime); /* * The clock */ addTopRightComp(new JLabel(Data.getInstance().getIcon("blank_50x50.png"))); clockLabel.setFont(UI.VERY_LARGE_FONT); clockButtonStart = GUITools.newImageButton(); clockButtonStart.addActionListener(e -> { if (clockWorker.isClockRunning()) { clockWorker.stopClock(); } else { clockWorker.startClock(); } updateClockButtons(); }); JButton clockButtonReset = GUITools.newImageButton(Data.getInstance().getIcon("clockReset_24x24_0.png"), Data.getInstance().getIcon("clockReset_24x24.png")); clockButtonReset.setToolTipText(translate("Reset Stop Watch")); clockButtonReset.addActionListener(e -> { clockWorker.resetClock(); updateClockButtons(); }); addTopRightComp(clockButtonReset); addTopRightComp(clockLabel); addTopRightComp(clockButtonStart); /* * Update clock elements */ updateClock(0); updateClockButtons(); updateCurrentTime(); }
From source file:org.revager.tools.GUITools.java
/** * Creates a new invisible strut button. * //ww w . j a v a2 s . com * @return the newly created button */ public static JButton newInvisibleStrutButton() { JButton button = new JButton(" "); button.setContentAreaFilled(false); button.setBorder(null); button.setBorderPainted(false); button.setFocusable(false); button.setEnabled(false); return button; }
From source file:org.tinymediamanager.ui.dialogs.RegisterDonatorVersionDialog.java
public RegisterDonatorVersionDialog() { super(BUNDLE.getString("tmm.registerdonator"), "registerDonator"); //$NON-NLS-1$ setBounds(166, 5, 400, 300);/*from w ww . j av a 2 s . co m*/ boolean isDonator = Globals.isDonator(); Properties props = null; if (isDonator) { props = License.decrypt(); } { JPanel panelContent = new JPanel(); getContentPane().add(panelContent, BorderLayout.CENTER); panelContent.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("250px:grow"), FormFactory.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormFactory.PARAGRAPH_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.UNRELATED_GAP_ROWSPEC, })); { JTextArea textArea = new JTextArea(); textArea.setOpaque(false); textArea.setLineWrap(true); textArea.setWrapStyleWord(true); textArea.setEditable(false); panelContent.add(textArea, "2, 2, 3, 1, default, center"); if (isDonator) { textArea.setText(BUNDLE.getString("tmm.registerdonator.thanks")); //$NON-NLS-1$ } else { textArea.setText(BUNDLE.getString("tmm.registerdonator.hint")); //$NON-NLS-1$ } } { JLabel lblName = new JLabel(BUNDLE.getString("tmm.registerdonator.name")); //$NON-NLS-1$ panelContent.add(lblName, "2, 4, right, default"); tfName = new JTextField(""); lblName.setLabelFor(tfName); panelContent.add(tfName, "4, 4, fill, default"); tfName.setColumns(10); if (isDonator) { tfName.setText(props.getProperty("user")); tfName.setEnabled(false); } } { JLabel lblEmailAddress = new JLabel(BUNDLE.getString("tmm.registerdonator.email")); //$NON-NLS-1$ panelContent.add(lblEmailAddress, "2, 6, right, default"); tfEmailAddress = new JTextField(""); lblEmailAddress.setLabelFor(tfEmailAddress); panelContent.add(tfEmailAddress, "4, 6, fill, default"); tfEmailAddress.setColumns(10); if (isDonator) { tfEmailAddress.setText(props.getProperty("email")); tfEmailAddress.setEnabled(false); } } } { JPanel panelButtons = new JPanel(); panelButtons.setBorder(new EmptyBorder(4, 4, 4, 4)); getContentPane().add(panelButtons, BorderLayout.SOUTH); EqualsLayout layout = new EqualsLayout(5); layout.setMinWidth(100); panelButtons.setLayout(layout); { JButton btnRegister = new JButton(BUNDLE.getString("Button.register")); //$NON-NLS-1$ btnRegister.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); try { LOGGER.debug("registering for donator version: ", tfEmailAddress.getText()); Properties p = new Properties(); p.setProperty("user", tfName.getText()); p.setProperty("email", tfEmailAddress.getText()); p.setProperty("generated", String.valueOf(new Date().getTime())); p.setProperty("uuid", FileUtils.readFileToString(new File("tmm.uuid"))); // get encrypted string and write tmm.lic if (License.encrypt(p) && License.isValid()) { JOptionPane.showMessageDialog(RegisterDonatorVersionDialog.this, BUNDLE.getString("tmm.registerdonator.success")); //$NON-NLS-1$ setVisible(false); } else { JOptionPane.showMessageDialog(RegisterDonatorVersionDialog.this, BUNDLE.getString("tmm.registerdonator.error")); //$NON-NLS-1$ } } catch (Exception ex) { LOGGER.error("Error registering donator version: " + ex.getMessage()); } setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } }); if (isDonator) { btnRegister.setEnabled(false); } panelButtons.add(btnRegister); } { JButton btnClose = new JButton(BUNDLE.getString("Button.close")); //$NON-NLS-1$ btnClose.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { setVisible(false); } }); panelButtons.add(btnClose); } } addWindowListener(new WindowAdapter() { @Override public void windowOpened(WindowEvent e) { tfName.requestFocus(); } }); }
From source file:org.tinymediamanager.ui.movies.settings.MovieSettingsPanel.java
/** * Instantiates a new movie settings panel. *///from w w w . j a v a 2 s . c om public MovieSettingsPanel() { setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), 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, RowSpec.decode("default:grow"), })); JPanel panelGeneral = new JPanel(); panelGeneral.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.general"), TitledBorder.LEADING, //$NON-NLS-1$ TitledBorder.TOP, null, null)); add(panelGeneral, "2, 2, fill, fill"); panelGeneral.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_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.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.UNRELATED_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, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); JLabel lblVisiblecolumns = new JLabel(BUNDLE.getString("Settings.movie.visiblecolumns")); //$NON-NLS-1$ panelGeneral.add(lblVisiblecolumns, "2, 2, right, default"); chckbxYear = new JCheckBox(BUNDLE.getString("metatag.year")); //$NON-NLS-1$ panelGeneral.add(chckbxYear, "4, 2"); chckbxRating = new JCheckBox(BUNDLE.getString("metatag.rating")); //$NON-NLS-1$ panelGeneral.add(chckbxRating, "6, 2"); chckbxNfo = new JCheckBox(BUNDLE.getString("metatag.nfo")); //$NON-NLS-1$ panelGeneral.add(chckbxNfo, "8, 2"); chckbxMetadata = new JCheckBox(BUNDLE.getString("tmm.metadata")); //$NON-NLS-1$ panelGeneral.add(chckbxMetadata, "10, 2"); chckbxDateAdded = new JCheckBox(BUNDLE.getString("metatag.dateadded")); //$NON-NLS-1$ panelGeneral.add(chckbxDateAdded, "12, 2"); chckbxImages = new JCheckBox(BUNDLE.getString("metatag.images")); //$NON-NLS-1$ panelGeneral.add(chckbxImages, "4, 4"); chckbxTrailer = new JCheckBox(BUNDLE.getString("metatag.trailer")); //$NON-NLS-1$ panelGeneral.add(chckbxTrailer, "6, 4"); chckbxSubtitles = new JCheckBox(BUNDLE.getString("metatag.subtitles")); //$NON-NLS-1$ panelGeneral.add(chckbxSubtitles, "8, 4"); chckbxWatched = new JCheckBox(BUNDLE.getString("metatag.watched")); //$NON-NLS-1$ panelGeneral.add(chckbxWatched, "10, 4"); JLabel lblSaveUiFilter = new JLabel(BUNDLE.getString("Settings.movie.persistuifilter")); //$NON-NLS-1$ panelGeneral.add(lblSaveUiFilter, "2, 6, right, default"); chckbxSaveUiFilter = new JCheckBox(""); panelGeneral.add(chckbxSaveUiFilter, "4, 6"); JSeparator separator_4 = new JSeparator(); panelGeneral.add(separator_4, "2, 8, 11, 1"); JLabel lblImageCache = new JLabel(BUNDLE.getString("Settings.imagecacheimport")); panelGeneral.add(lblImageCache, "2, 10, right, default"); chckbxImageCache = new JCheckBox(BUNDLE.getString("Settings.imagecacheimporthint")); //$NON-NLS-1$ TmmFontHelper.changeFont(chckbxImageCache, 0.833); panelGeneral.add(chckbxImageCache, "4, 10, 7, 1"); JLabel lblRuntimeFromMedia = new JLabel(BUNDLE.getString("Settings.runtimefrommediafile")); panelGeneral.add(lblRuntimeFromMedia, "2, 12, right, default"); chckbxRuntimeFromMf = new JCheckBox(""); panelGeneral.add(chckbxRuntimeFromMf, "4, 12"); JSeparator separator = new JSeparator(); panelGeneral.add(separator, "2, 14, 11, 1"); final JLabel lblAutomaticRename = new JLabel(BUNDLE.getString("Settings.movie.automaticrename")); //$NON-NLS-1$ panelGeneral.add(lblAutomaticRename, "2, 16, right, default"); chckbxRename = new JCheckBox(BUNDLE.getString("Settings.movie.automaticrename.desc")); //$NON-NLS-1$ panelGeneral.add(chckbxRename, "4, 16, 7, 1"); JLabel lblTraktTv = new JLabel(BUNDLE.getString("Settings.trakt"));//$NON-NLS-1$ panelGeneral.add(lblTraktTv, "2, 18"); chckbxTraktTv = new JCheckBox(""); panelGeneral.add(chckbxTraktTv, "4, 18"); JButton btnClearTraktTvMovies = new JButton(BUNDLE.getString("Settings.trakt.clearmovies"));//$NON-NLS-1$ btnClearTraktTvMovies.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int confirm = JOptionPane.showOptionDialog(null, BUNDLE.getString("Settings.trakt.clearmovies.hint"), BUNDLE.getString("Settings.trakt.clearmovies"), JOptionPane.YES_NO_OPTION, //$NON-NLS-1$ JOptionPane.QUESTION_MESSAGE, null, null, null); if (confirm == JOptionPane.YES_OPTION) { TmmTask task = new ClearTraktTvTask(true, false); TmmTaskManager.getInstance().addUnnamedTask(task); } } }); panelGeneral.add(btnClearTraktTvMovies, "6, 18, 3, 1, left, default"); JPanel panelMovieDataSources = new JPanel(); panelMovieDataSources.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.movie.datasource"), //$NON-NLS-1$ TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelMovieDataSources, "2, 4, 3, 1, fill, fill"); panelMovieDataSources.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("150dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.UNRELATED_GAP_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("150dlu:grow(2)"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, RowSpec.decode("100px:grow"), FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); JLabel lblDataSource = new JLabel(BUNDLE.getString("Settings.source")); //$NON-NLS-1$ panelMovieDataSources.add(lblDataSource, "2, 2, 5, 1"); JLabel lblIngore = new JLabel(BUNDLE.getString("Settings.ignore")); //$NON-NLS-1$ panelMovieDataSources.add(lblIngore, "12, 2"); JScrollPane scrollPaneDataSources = new JScrollPane(); panelMovieDataSources.add(scrollPaneDataSources, "2, 4, 5, 1, fill, fill"); listDataSources = new JList<>(); scrollPaneDataSources.setViewportView(listDataSources); JPanel panelMovieSourcesButtons = new JPanel(); panelMovieDataSources.add(panelMovieSourcesButtons, "8, 4, fill, top"); panelMovieSourcesButtons .setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, }, new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); JButton btnAdd = new JButton(IconManager.LIST_ADD); btnAdd.setToolTipText(BUNDLE.getString("Button.add")); //$NON-NLS-1$ btnAdd.setMargin(new Insets(2, 2, 2, 2)); btnAdd.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { Path file = TmmUIHelper.selectDirectory(BUNDLE.getString("Settings.datasource.folderchooser")); //$NON-NLS-1$ if (file != null && Files.isDirectory(file)) { settings.addMovieDataSources(file.toAbsolutePath().toString()); } } }); panelMovieSourcesButtons.add(btnAdd, "1, 1, fill, top"); JButton btnRemove = new JButton(IconManager.LIST_REMOVE); btnRemove.setToolTipText(BUNDLE.getString("Button.remove")); //$NON-NLS-1$ btnRemove.setMargin(new Insets(2, 2, 2, 2)); btnRemove.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { int row = listDataSources.getSelectedIndex(); if (row != -1) { // nothing selected String path = MovieModuleManager.MOVIE_SETTINGS.getMovieDataSource().get(row); String[] choices = { BUNDLE.getString("Button.continue"), BUNDLE.getString("Button.abort") }; //$NON-NLS-1$ int decision = JOptionPane.showOptionDialog(null, String.format(BUNDLE.getString("Settings.movie.datasource.remove.info"), path), BUNDLE.getString("Settings.datasource.remove"), JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE, null, choices, BUNDLE.getString("Button.abort")); //$NON-NLS-1$ if (decision == 0) { setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); MovieModuleManager.MOVIE_SETTINGS.removeMovieDataSources(path); setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); } } } }); panelMovieSourcesButtons.add(btnRemove, "1, 3, fill, top"); JScrollPane scrollPaneIgnore = new JScrollPane(); panelMovieDataSources.add(scrollPaneIgnore, "12, 4, fill, fill"); listIgnore = new JList<>(); scrollPaneIgnore.setViewportView(listIgnore); JPanel panelIgnoreButtons = new JPanel(); panelMovieDataSources.add(panelIgnoreButtons, "14, 4, fill, fill"); panelIgnoreButtons.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, }, new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); JButton btnAddIgnore = new JButton(IconManager.LIST_ADD); btnAddIgnore.setToolTipText(BUNDLE.getString("Settings.addignore")); //$NON-NLS-1$ btnAddIgnore.setMargin(new Insets(2, 2, 2, 2)); btnAddIgnore.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Path file = TmmUIHelper.selectDirectory(BUNDLE.getString("Settings.ignore")); //$NON-NLS-1$ if (file != null && Files.isDirectory(file)) { settings.addMovieSkipFolder(file.toAbsolutePath().toString()); } } }); panelIgnoreButtons.add(btnAddIgnore, "1, 1"); JButton btnRemoveIgnore = new JButton(IconManager.LIST_REMOVE); btnRemoveIgnore.setToolTipText(BUNDLE.getString("Settings.removeignore")); //$NON-NLS-1$ btnRemoveIgnore.setMargin(new Insets(2, 2, 2, 2)); btnRemoveIgnore.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { int row = listIgnore.getSelectedIndex(); if (row != -1) { // nothing selected String ingore = settings.getMovieSkipFolders().get(row); settings.removeMovieSkipFolder(ingore); } } }); panelIgnoreButtons.add(btnRemoveIgnore, "1, 3"); JPanel panel = new JPanel(); panelMovieDataSources.add(panel, "2, 8, 13, 1, fill, fill"); panel.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("20dlu"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, }, new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, })); JLabel lblNfoFormat = new JLabel(BUNDLE.getString("Settings.nfoFormat")); panel.add(lblNfoFormat, "1, 1, right, default"); cbNfoFormat = new JComboBox(MovieConnectors.values()); panel.add(cbNfoFormat, "3, 1, fill, default"); JLabel lblNfoFileNaming = new JLabel(BUNDLE.getString("Settings.nofFileNaming")); //$NON-NLS-1$ panel.add(lblNfoFileNaming, "7, 1, right, default"); cbMovieNfoFilename1 = new JCheckBox(BUNDLE.getString("Settings.moviefilename") + ".nfo"); //$NON-NLS-1$ panel.add(cbMovieNfoFilename1, "9, 1"); cbMovieNfoFilename2 = new JCheckBox("movie.nfo"); panel.add(cbMovieNfoFilename2, "9, 2"); cbMovieNfoFilename2.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { checkChanges(); } }); cbMovieNfoFilename3 = new JCheckBox(BUNDLE.getString("Settings.nfo.discstyle")); //$NON-NLS-1$ panel.add(cbMovieNfoFilename3, "9, 3"); cbMovieNfoFilename3.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { checkChanges(); } }); final JLabel lblCertificationStyle = new JLabel(BUNDLE.getString("Settings.certificationformat")); //$NON-NLS-1$ panel.add(lblCertificationStyle, "1, 5, right, default"); cbCertificationStyle = new JComboBox(); panel.add(cbCertificationStyle, "3, 5, 7, 1, fill, default"); JPanel panelBadWords = new JPanel(); panelBadWords.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.movie.badwords"), //$NON-NLS-1$ TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelBadWords, "4, 2, fill, fill"); panelBadWords.setLayout(new FormLayout( new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("50px:grow"), FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC, }, new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, })); JTextPane txtpntBadWordsHint = new JTextPane(); txtpntBadWordsHint.setBackground(UIManager.getColor("Panel.background")); txtpntBadWordsHint.setText(BUNDLE.getString("Settings.movie.badwords.hint")); //$NON-NLS-1$ TmmFontHelper.changeFont(txtpntBadWordsHint, 0.833); panelBadWords.add(txtpntBadWordsHint, "2, 2, 3, 1, fill, default"); JScrollPane scpBadWords = new JScrollPane(); panelBadWords.add(scpBadWords, "2, 4, fill, fill"); listBadWords = new JList<>(); scpBadWords.setViewportView(listBadWords); JButton btnRemoveBadWord = new JButton(IconManager.LIST_REMOVE); btnRemoveBadWord.setToolTipText(BUNDLE.getString("Button.remove")); //$NON-NLS-1$ btnRemoveBadWord.setMargin(new Insets(2, 2, 2, 2)); btnRemoveBadWord.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { int row = listBadWords.getSelectedIndex(); if (row != -1) { String badWord = MovieModuleManager.MOVIE_SETTINGS.getBadWords().get(row); MovieModuleManager.MOVIE_SETTINGS.removeBadWord(badWord); } } }); panelBadWords.add(btnRemoveBadWord, "4, 4, default, bottom"); tfAddBadword = new JTextField(); tfAddBadword.setColumns(10); panelBadWords.add(tfAddBadword, "2, 6, fill, default"); JButton btnAddBadWord = new JButton(IconManager.LIST_ADD); btnAddBadWord.setToolTipText(BUNDLE.getString("Button.add")); //$NON-NLS-1$ btnAddBadWord.setMargin(new Insets(2, 2, 2, 2)); btnAddBadWord.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (StringUtils.isNotEmpty(tfAddBadword.getText())) { MovieModuleManager.MOVIE_SETTINGS.addBadWord(tfAddBadword.getText()); tfAddBadword.setText(""); } } }); panelBadWords.add(btnAddBadWord, "4, 6"); initDataBindings(); { // NFO filenames List<MovieNfoNaming> movieNfoFilenames = settings.getMovieNfoFilenames(); if (movieNfoFilenames.contains(MovieNfoNaming.FILENAME_NFO)) { cbMovieNfoFilename1.setSelected(true); } if (movieNfoFilenames.contains(MovieNfoNaming.MOVIE_NFO)) { cbMovieNfoFilename2.setSelected(true); } if (movieNfoFilenames.contains(MovieNfoNaming.DISC_NFO)) { cbMovieNfoFilename3.setSelected(true); } if (!Globals.isDonator()) { chckbxTraktTv.setSelected(false); chckbxTraktTv.setEnabled(false); btnClearTraktTvMovies.setEnabled(false); } // set default certification style cbNfoFormat.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (cbNfoFormat.getSelectedItem() == MovieConnectors.MP) { for (int i = 0; i < cbCertificationStyle.getItemCount(); i++) { CertificationStyleWrapper wrapper = cbCertificationStyle.getItemAt(i); if (wrapper.style == CertificationStyle.TECHNICAL) { cbCertificationStyle.setSelectedItem(wrapper); break; } } } else if (cbNfoFormat.getSelectedItem() == MovieConnectors.XBMC || cbNfoFormat.getSelectedItem() == MovieConnectors.KODI) { for (int i = 0; i < cbCertificationStyle.getItemCount(); i++) { CertificationStyleWrapper wrapper = cbCertificationStyle.getItemAt(i); if (wrapper.style == CertificationStyle.LARGE) { cbCertificationStyle.setSelectedItem(wrapper); break; } } } } }); // certification examples for (CertificationStyle style : CertificationStyle.values()) { CertificationStyleWrapper wrapper = new CertificationStyleWrapper(); wrapper.style = style; cbCertificationStyle.addItem(wrapper); if (style == settings.getMovieCertificationStyle()) { cbCertificationStyle.setSelectedItem(wrapper); } } cbCertificationStyle.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { checkChanges(); } }); // item listener cbMovieNfoFilename1.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { checkChanges(); } }); } }
From source file:org.tinymediamanager.ui.settings.ExternalServicesSettingsPanel.java
public ExternalServicesSettingsPanel() { setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, }, new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, })); {/*w ww .j a v a2 s .c om*/ JPanel panelTrakttv = new JPanel(); panelTrakttv.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.trakttv"), TitledBorder.LEADING, TitledBorder.TOP, null, null)); add(panelTrakttv, "2, 2, fill, fill"); panelTrakttv.setLayout(new FormLayout( new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(25dlu;default)"), 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, })); final JLabel lblTraktStatus = new JLabel(""); //$NON-NLS-1$ panelTrakttv.add(lblTraktStatus, "2, 2, 5, 1"); JButton btnGetTraktPin = new JButton(BUNDLE.getString("Settings.trakt.getpin")); //$NON-NLS-1$ panelTrakttv.add(btnGetTraktPin, "2, 4"); JButton btnTestTraktConnection = new JButton(BUNDLE.getString("Settings.trakt.testconnection")); //$NON-NLS-1$ panelTrakttv.add(btnTestTraktConnection, "4, 4"); if (!Globals.isDonator()) { btnGetTraktPin.setEnabled(false); btnTestTraktConnection.setEnabled(false); String msg = "<html><body>" + BUNDLE.getString("tmm.donatorfunction.hint") + "</body></html>"; //$NON-NLS-1$ JLabel lblTraktDonator = new JLabel(msg); lblTraktDonator.setForeground(Color.RED); panelTrakttv.add(lblTraktDonator, "2, 8, 3, 1, default, default"); } else { if (StringUtils.isNoneBlank(Globals.settings.getTraktAccessToken(), Globals.settings.getTraktRefreshToken())) { lblTraktStatus.setText(BUNDLE.getString("Settings.trakt.status.good")); //$NON-NLS-1$ } else { lblTraktStatus.setText(BUNDLE.getString("Settings.trakt.status.bad")); //$NON-NLS-1$ } btnGetTraktPin.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { // open the pin url in a browser try { TmmUIHelper.browseUrl("https://trakt.tv/pin/799"); } catch (Exception e1) { // browser could not be opened, show a dialog box JOptionPane.showMessageDialog(MainWindow.getFrame(), BUNDLE.getString("Settings.trakt.getpin.fallback"), //$NON-NLS-1$ BUNDLE.getString("Settings.trakt.getpin"), JOptionPane.INFORMATION_MESSAGE); } // let the user insert the pin String pin = JOptionPane.showInputDialog(MainWindow.getFrame(), BUNDLE.getString("Settings.trakt.getpin.entercode")); //$NON-NLS-1$ // try to get the tokens String accessToken = ""; String refreshToken = ""; try { Map<String, String> tokens = TraktTv.authenticateViaPin(pin); accessToken = tokens.get("accessToken") == null ? "" : tokens.get("accessToken"); refreshToken = tokens.get("refreshToken") == null ? "" : tokens.get("refreshToken"); } catch (Exception e1) { } Globals.settings.setTraktAccessToken(accessToken); Globals.settings.setTraktRefreshToken(refreshToken); if (StringUtils.isNoneBlank(Globals.settings.getTraktAccessToken(), Globals.settings.getTraktRefreshToken())) { lblTraktStatus.setText(BUNDLE.getString("Settings.trakt.status.good")); //$NON-NLS-1$ } else { JOptionPane.showMessageDialog(MainWindow.getFrame(), BUNDLE.getString("Settings.trakt.getpin.problem"), BUNDLE.getString("Settings.trakt.getpin"), JOptionPane.ERROR_MESSAGE);//$NON-NLS-1$ lblTraktStatus.setText(BUNDLE.getString("Settings.trakt.status.bad")); //$NON-NLS-1$ } } }); btnTestTraktConnection.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { try { TraktTv.refreshAccessToken(); JOptionPane.showMessageDialog(MainWindow.getFrame(), BUNDLE.getString("Settings.trakt.testconnection.good"), BUNDLE.getString("Settings.trakt.testconnection"), JOptionPane.ERROR_MESSAGE);//$NON-NLS-1$ } catch (Exception e1) { JOptionPane.showMessageDialog(MainWindow.getFrame(), BUNDLE.getString("Settings.trakt.testconnection.bad"), BUNDLE.getString("Settings.trakt.testconnection"), JOptionPane.ERROR_MESSAGE);//$NON-NLS-1$ } } }); } } initDataBindings(); }
From source file:org.ut.biolab.medsavant.client.cohort.CohortDetailedView.java
public synchronized void setPatientList(List<SimplePatient> patients) { members.removeAll();//from ww w. ja v a2 s . c om final Object[][] data = new Object[patients.size()][1]; for (int i = 0; i < patients.size(); i++) { data[i][0] = patients.get(i); } list = new StripyTable(data, new String[] { "Member Hospital IDs" }); list.setFont(FontFactory.getGeneralFont().deriveFont(16)); list.setBorder(null); list.setShowGrid(false); list.setRowHeight(21); list.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { if (SwingUtilities.isRightMouseButton(e)) { int[] selection = list.getSelectedRows(); String[] hosIds = new String[selection.length]; for (int i = 0; i < selection.length; i++) { int j = list.convertRowIndexToModel(selection[i]); hosIds[i] = ((SimplePatient) data[j][0]).getHospitalId(); } createHospitalPopup(hosIds).show(e.getComponent(), e.getX(), e.getY()); } } }); final JButton removeButton = removeIndividualsButton(); removeButton.setEnabled(false); list.getSelectionModel().addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { int count = list.getSelectedRowCount(); removeButton.setEnabled(count > 0); if (count == 0) { removeButton.setText("Remove selected member"); } else { if (count == 1) { removeButton.setText("Remove selected member"); } else { removeButton.setText(String.format("Remove %d selected members", count)); } } } }); members.setLayout(new MigLayout("fillx, insets 0, wrap")); members.add(new JLabel(ViewUtil.numToString(list.getRowCount()) + " " + MiscUtils.pluralize(list.getRowCount(), "member", "members")), "split, growx 1.0"); members.add(removeButton, "right,wrap"); members.add(list, "width 100%"); members.updateUI(); }
From source file:org.ut.biolab.medsavant.client.project.ProjectWizard.java
private AbstractWizardPage getPatientFieldsPage() { //setup page// w ww. j av a2 s . c om final DefaultWizardPage page = new DefaultWizardPage(PAGENAME_PATIENTS) { @Override public void setupWizardButtons() { fireButtonEvent(ButtonEvent.SHOW_BUTTON, ButtonNames.BACK); fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.BACK); fireButtonEvent(ButtonEvent.HIDE_BUTTON, ButtonNames.FINISH); fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.NEXT); } }; page.addText("Add relevant fields for patients. "); JScrollPane scrollpane = new JScrollPane(); scrollpane.setPreferredSize(new Dimension(300, 250)); scrollpane.getViewport().setBackground(Color.white); final JTable table = new JTable() { @Override public Class<?> getColumnClass(int column) { if (column == 2) { return Boolean.class; } else { return String.class; } } }; patientFormatModel = new DefaultTableModel() { @Override public boolean isCellEditable(int row, int col) { return row >= 8; } }; patientFormatModel.addColumn("Name"); patientFormatModel.addColumn("Type"); patientFormatModel.addColumn("Filterable"); patientFormatModel.addColumn("Alias"); patientFormatModel.addColumn("Description"); patientFormatModel.addRow(new Object[] { FAMILY_ID.getColumnName(), FAMILY_ID.getTypeString(), true, FAMILY_ID.getAlias(), "" }); patientFormatModel.addRow(new Object[] { HOSPITAL_ID.getColumnName(), HOSPITAL_ID.getTypeString(), true, HOSPITAL_ID.getAlias(), "" }); patientFormatModel.addRow( new Object[] { IDBIOMOM.getColumnName(), IDBIOMOM.getTypeString(), true, IDBIOMOM.getAlias(), "" }); patientFormatModel.addRow( new Object[] { IDBIODAD.getColumnName(), IDBIODAD.getTypeString(), true, IDBIODAD.getAlias(), "" }); patientFormatModel.addRow( new Object[] { GENDER.getColumnName(), GENDER.getTypeString(), true, GENDER.getAlias(), "" }); patientFormatModel.addRow( new Object[] { AFFECTED.getColumnName(), AFFECTED.getTypeString(), true, AFFECTED.getAlias(), "" }); patientFormatModel.addRow( new Object[] { DNA_IDS.getColumnName(), DNA_IDS.getTypeString(), true, DNA_IDS.getAlias(), "" }); patientFormatModel.addRow( new Object[] { BAM_URL.getColumnName(), BAM_URL.getTypeString(), true, BAM_URL.getAlias(), "" }); patientFormatModel.addRow(new Object[] { PHENOTYPES.getColumnName(), PHENOTYPES.getTypeString(), true, PHENOTYPES.getAlias(), "" }); if (modify) { for (CustomField f : customFields) { patientFormatModel.addRow(new Object[] { f.getColumnName(), f.getTypeString(), f.isFilterable(), f.getAlias(), f.getDescription() }); } } table.setModel(patientFormatModel); table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); scrollpane.getViewport().add(table); page.addComponent(scrollpane); JButton addFieldButton = new JButton("Add Field"); addFieldButton.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { patientFormatModel.addRow(new Object[5]); table.setModel(patientFormatModel); } }); page.addComponent(addFieldButton); JButton removeFieldButton = new JButton("Remove Field"); removeFieldButton.setEnabled(false); removeFieldButton.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { int row = table.getSelectedRow(); // Minus one because patient_id isn't in the table. if (row >= BasicPatientColumns.REQUIRED_PATIENT_FIELDS.length - 1) { patientFormatModel.removeRow(row); } table.setModel(patientFormatModel); } }); table.getSelectionModel().addListSelectionListener( new RemovalEnabler(BasicPatientColumns.REQUIRED_PATIENT_FIELDS.length - 1, removeFieldButton)); page.addComponent(removeFieldButton); return page; }
From source file:org.ut.biolab.medsavant.client.project.ProjectWizard.java
private AbstractWizardPage getVCFFieldsPage() { //setup page// w ww.j a v a 2 s . c o m final DefaultWizardPage page = new DefaultWizardPage(PAGENAME_VCF) { @Override public void setupWizardButtons() { fireButtonEvent(ButtonEvent.SHOW_BUTTON, ButtonNames.BACK); fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.BACK); fireButtonEvent(ButtonEvent.HIDE_BUTTON, ButtonNames.FINISH); fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.NEXT); } }; page.addText("Add extra fields to parse from INFO text in VCF files. "); JScrollPane scrollpane = new JScrollPane(); scrollpane.setPreferredSize(new Dimension(300, 250)); scrollpane.getViewport().setBackground(Color.white); final JTable table = new JTable() { @Override public Class<?> getColumnClass(int column) { if (column == 2) { return Boolean.class; } else { return String.class; } } }; variantFormatModel = new DefaultTableModel(); variantFormatModel.addColumn("Key"); variantFormatModel.addColumn("Type"); variantFormatModel.addColumn("Filterable"); variantFormatModel.addColumn("Alias"); variantFormatModel.addColumn("Description"); if (modify) { try { int firstRef = manager.getReferenceIDsForProject(LoginController.getSessionID(), projectID)[0]; CustomField[] fields = manager.getCustomVariantFields(LoginController.getSessionID(), projectID, firstRef, manager.getNewestUpdateID(LoginController.getSessionID(), projectID, firstRef, false)); for (CustomField f : fields) { //casing of f.getColumnName should match database. variantFormatModel.addRow(new Object[] { f.getColumnName(), f.getTypeString(), f.isFilterable(), f.getAlias(), f.getDescription() }); } } catch (Exception ex) { LOG.error("Error getting reference IDs for project.", ex); } } else { variantFormatModel .addRow(new Object[] { AA.getColumnName(), AA.getTypeString(), true, AA.getAlias(), "" }); variantFormatModel .addRow(new Object[] { AC.getColumnName(), AC.getTypeString(), true, AC.getAlias(), "" }); variantFormatModel .addRow(new Object[] { AF.getColumnName(), AF.getTypeString(), true, AF.getAlias(), "" }); variantFormatModel .addRow(new Object[] { AN.getColumnName(), AN.getTypeString(), true, AN.getAlias(), "" }); variantFormatModel .addRow(new Object[] { BQ.getColumnName(), BQ.getTypeString(), true, BQ.getAlias(), "" }); variantFormatModel.addRow( new Object[] { CIGAR.getColumnName(), CIGAR.getTypeString(), true, CIGAR.getAlias(), "" }); variantFormatModel .addRow(new Object[] { DB.getColumnName(), DB.getTypeString(), true, DB.getAlias(), "" }); variantFormatModel .addRow(new Object[] { DP.getColumnName(), DP.getTypeString(), true, DP.getAlias(), "" }); //variantFormatModel.addRow(new Object[]{END.getColumnName(), END.getTypeString(), true, END.getAlias(), ""}); variantFormatModel .addRow(new Object[] { H2.getColumnName(), H2.getTypeString(), true, H2.getAlias(), "" }); variantFormatModel .addRow(new Object[] { MQ.getColumnName(), MQ.getTypeString(), true, MQ.getAlias(), "" }); variantFormatModel .addRow(new Object[] { MQ0.getColumnName(), MQ0.getTypeString(), true, MQ0.getAlias(), "" }); variantFormatModel .addRow(new Object[] { NS.getColumnName(), NS.getTypeString(), true, NS.getAlias(), "" }); variantFormatModel .addRow(new Object[] { SB.getColumnName(), SB.getTypeString(), true, SB.getAlias(), "" }); variantFormatModel.addRow(new Object[] { SOMATIC.getColumnName(), SOMATIC.getTypeString(), true, SOMATIC.getAlias(), "" }); variantFormatModel.addRow(new Object[] { VALIDATED.getColumnName(), VALIDATED.getTypeString(), true, VALIDATED.getAlias(), "" }); variantFormatModel .addRow(new Object[] { JANNOVAR_EFFECT.getColumnName(), JANNOVAR_EFFECT.getTypeString(), JANNOVAR_EFFECT.isFilterable(), JANNOVAR_EFFECT.getAlias(), "" }); variantFormatModel .addRow(new Object[] { JANNOVAR_SYMBOL.getColumnName(), JANNOVAR_SYMBOL.getTypeString(), JANNOVAR_SYMBOL.isFilterable(), JANNOVAR_SYMBOL.getAlias(), "" }); variantFormatModel.addRow(new Object[] { FORMAT.getColumnName(), FORMAT.getTypeString(), FORMAT.isFilterable(), FORMAT.getAlias(), "" }); variantFormatModel.addRow(new Object[] { SAMPLE_INFO.getColumnName(), SAMPLE_INFO.getTypeString(), SAMPLE_INFO.isFilterable(), SAMPLE_INFO.getAlias(), "" }); } table.setModel(variantFormatModel); table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE); scrollpane.getViewport().add(table); page.addComponent(scrollpane); table.addKeyListener(new KeyListener() { @Override public void keyTyped(KeyEvent e) { variantFieldsChanged = true; } @Override public void keyPressed(KeyEvent e) { variantFieldsChanged = true; } @Override public void keyReleased(KeyEvent e) { variantFieldsChanged = true; } }); JButton addFieldButton = new JButton("Add Field"); addFieldButton.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { variantFormatModel.addRow(new Object[2]); table.setModel(variantFormatModel); variantFieldsChanged = true; } }); page.addComponent(addFieldButton); JButton removeFieldButton = new JButton("Remove Field"); removeFieldButton.setEnabled(false); removeFieldButton.addMouseListener(new MouseAdapter() { @Override public void mouseReleased(MouseEvent e) { int row = table.getSelectedRow(); if (row >= 0) { variantFormatModel.removeRow(row); table.setModel(variantFormatModel); variantFieldsChanged = true; } } }); table.getSelectionModel().addListSelectionListener(new RemovalEnabler(0, removeFieldButton)); page.addComponent(removeFieldButton); return page; }