Example usage for java.awt Cursor WAIT_CURSOR

List of usage examples for java.awt Cursor WAIT_CURSOR

Introduction

In this page you can find the example usage for java.awt Cursor WAIT_CURSOR.

Prototype

int WAIT_CURSOR

To view the source code for java.awt Cursor WAIT_CURSOR.

Click Source Link

Document

The wait cursor type.

Usage

From source file:org.sleuthkit.autopsy.casemodule.Case.java

/**
 * Updates the current case to the given case and fires off the appropriate
 * property-change//www.ja  va 2s .  co  m
 *
 * @param newCase the new current case or null if case is being closed
 *
 */
private static void changeCase(Case newCase) {
    // close the existing case
    Case oldCase = Case.currentCase;
    Case.currentCase = null;
    if (oldCase != null) {
        SwingUtilities.invokeLater(() -> {
            WindowManager.getDefault().getMainWindow()
                    .setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
        });
        IngestManager.getInstance().cancelAllIngestJobs();
        doCaseChange(null); //closes windows, etc   
        if (null != oldCase.tskErrorReporter) {
            oldCase.tskErrorReporter.shutdown(); // stop listening for TSK errors for the old case
            oldCase.tskErrorReporter = null;
        }
        eventPublisher.publishLocally(new AutopsyEvent(Events.CURRENT_CASE.toString(), oldCase, null));
        if (CaseType.MULTI_USER_CASE == oldCase.getCaseType()) {
            if (null != oldCase.collaborationMonitor) {
                oldCase.collaborationMonitor.shutdown();
            }
            eventPublisher.closeRemoteEventChannel();
        }
    }

    if (newCase != null) {
        currentCase = newCase;
        Logger.setLogDirectory(currentCase.getLogDirectoryPath());
        // sanity check
        if (null != currentCase.tskErrorReporter) {
            currentCase.tskErrorReporter.shutdown();
        }
        // start listening for TSK errors for the new case
        currentCase.tskErrorReporter = new IntervalErrorReportData(currentCase,
                MIN_SECONDS_BETWEEN_ERROR_REPORTS,
                NbBundle.getMessage(Case.class, "IntervalErrorReport.ErrorText"));
        doCaseChange(currentCase);
        SwingUtilities.invokeLater(() -> {
            RecentCases.getInstance().addRecentCase(currentCase.name, currentCase.configFilePath); // update the recent cases
        });
        if (CaseType.MULTI_USER_CASE == newCase.getCaseType()) {
            try {
                /**
                 * Use the text index name as the remote event channel name
                 * prefix since it is unique, the same as the case database
                 * name for a multiuser case, and is readily available
                 * through the Case.getTextIndexName() API.
                 */
                eventPublisher
                        .openRemoteEventChannel(String.format(EVENT_CHANNEL_NAME, newCase.getTextIndexName()));
                currentCase.collaborationMonitor = new CollaborationMonitor();
            } catch (AutopsyEventException | CollaborationMonitor.CollaborationMonitorException ex) {
                logger.log(Level.SEVERE, "Failed to setup for collaboration", ex);
                MessageNotifyUtil.Notify.error(
                        NbBundle.getMessage(Case.class, "Case.CollaborationSetup.FailNotify.Title"),
                        NbBundle.getMessage(Case.class, "Case.CollaborationSetup.FailNotify.ErrMsg"));
            }
        }
        eventPublisher.publishLocally(new AutopsyEvent(Events.CURRENT_CASE.toString(), null, currentCase));

    } else {
        Logger.setLogDirectory(PlatformUtil.getLogDirectory());
    }
    SwingUtilities.invokeLater(() -> {
        WindowManager.getDefault().getMainWindow().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    });
}

From source file:edu.harvard.mcz.imagecapture.MainFrame.java

/**
 * This method initializes the main frame.
 * /*from   w  ww  .  j av a2 s.c  o  m*/
 */
private void initialize() {
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    this.setDefaultCloseOperation(EXIT_ON_CLOSE);
    this.setSize(new Dimension(1280, 750));
    this.setPreferredSize(new Dimension(1280, 800));
    this.setMinimumSize(new Dimension(300, 200));
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    this.setLocation((screenSize.width - this.getWidth()) / 2, (screenSize.height - this.getHeight()) / 2);
    //String iconFile = this.getClass().getResource("resources/icon.ico").getFile();
    URL iconFile = this.getClass().getResource("/edu/harvard/mcz/imagecapture/resources/icon.png");
    try {
        setIconImage(new ImageIcon(iconFile).getImage());
    } catch (Exception e) {
        log.error("Can't open icon file: " + iconFile);
        log.error(e);
    }
    this.setTitle(ImageCaptureApp.APP_NAME + ": MCZ Rapid Data Capture Application.  Configured For: "
            + Singleton.getSingletonInstance().getProperties().getProperties()
                    .getProperty(ImageCaptureProperties.KEY_COLLECTION));
    this.setJMenuBar(getJJMenuBar());
    this.setContentPane(getJPanel());

}

From source file:semgen.extraction.RadialGraph.Clusterer.java

public String clusterAndRecolor(AggregateLayout<String, Number> layout, int numEdgesToRemove, Color[] colors,
        boolean groupClusters) {

    setCursor(new Cursor(Cursor.WAIT_CURSOR));
    String moduletable = "";
    Graph<String, Number> g = layout.getGraph();
    layout.removeAll();/*from w w  w . ja v  a  2 s .c o m*/

    EdgeBetweennessClusterer<String, Number> clusterer = new EdgeBetweennessClusterer<String, Number>(
            numEdgesToRemove);
    Set<Set<String>> clusterSet = clusterer.transform(g);
    List<Number> edges = clusterer.getEdgesRemoved();
    sempanel.removeAll();
    int i = 0;
    // Set the colors of each node so that each cluster's vertices have the same color
    extractor.clusterpanel.checkboxpanel.removeAll();
    for (Iterator<Set<String>> cIt = clusterSet.iterator(); cIt.hasNext();) {
        moduletable = moduletable + "\nCLUSTER " + (i + 1);
        Set<String> vertices = cIt.next();
        Color c = colors[i % colors.length];
        Set<DataStructure> datastrs = new HashSet<DataStructure>();
        for (String vertex : vertices) {
            datastrs.add(extractor.semsimmodel.getDataStructure(vertex));
        }

        JLabel modulelabel = new JLabel("Cluster " + (i + 1));
        modulelabel.setOpaque(true);
        modulelabel.setFont(SemGenFont.defaultBold());
        modulelabel.setBackground(c);
        modulelabel.setAlignmentX(LEFT_ALIGNMENT);
        sempanel.add(modulelabel);

        // Update the semantics panel
        Set<String> addedterms = new HashSet<String>();
        for (String ver : vertices) {
            if (extractor.semsimmodel.getDataStructure(ver).hasPhysicalProperty()) {
                if (extractor.semsimmodel.getDataStructure(ver).getPhysicalProperty()
                        .getPhysicalPropertyOf() != null) {
                    PhysicalModelComponent pmc = extractor.semsimmodel.getDataStructure(ver)
                            .getPhysicalProperty().getPhysicalPropertyOf();
                    String name = null;
                    if (pmc.hasRefersToAnnotation()) {
                        name = pmc.getFirstRefersToReferenceOntologyAnnotation().getValueDescription();
                    } else {
                        name = pmc.getName();
                    }
                    if (!addedterms.contains(name)) {
                        addedterms.add(name);
                        JTextArea enttext = new JTextArea(name);
                        enttext.setOpaque(true);
                        enttext.setBackground(c);
                        enttext.setFont(SemGenFont.defaultPlain(-2));
                        if (pmc instanceof PhysicalProcess) {
                            enttext.setFont(SemGenFont.defaultItalic(-2));
                            name = "Process: " + name;
                        } else
                            name = "Entity: " + name;
                        enttext.setWrapStyleWord(true);
                        enttext.setLineWrap(true);
                        enttext.setBorder(BorderFactory.createEmptyBorder(7, 7, 0, 0));
                        enttext.setAlignmentX(LEFT_ALIGNMENT);
                        sempanel.add(enttext);
                        moduletable = moduletable + "\n   " + name;
                    }
                }
            }
        }
        sempanel.validate();
        sempanel.repaint();
        semscroller.repaint();
        semscroller.validate();
        this.repaint();
        this.validate();

        colorCluster(vertices, c);
        ExtractorJCheckBox box = new ExtractorJCheckBox("Cluster " + (i + 1), datastrs);
        box.setBackground(c);
        box.setOpaque(true);
        box.addItemListener(extractor);
        extractor.clusterpanel.checkboxpanel.add(box);
        if (groupClusters == true)
            groupCluster(layout, vertices);
        i++;
    }
    refreshModulePanel();

    for (Number e : g.getEdges()) {
        if (edges.contains(e))
            edgePaints.put(e, Color.lightGray);
        else
            edgePaints.put(e, Color.black);
    }
    nummodules = i;
    setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    return moduletable;
}

From source file:edu.ucla.stat.SOCR.analyses.util.moduls.frm.Panels.Jpan_btn.java

@Override
public void actionPerformed(final ActionEvent evt) {
    String action = null;/*from  w  ww . j a  v  a  2  s .c o m*/
    FitxerDades fitxTmp;
    boolean ambDades = false;
    InternalFrameData ifd;
    double minBase;
    MDComputation mdComputation;

    if (evt.getActionCommand().equals(strLoad)) {
        // LOAD

        if (currentInternalFrame != null)
            currentInternalFrame = null;

        buttonClicked = true;
        action = "Load";
        // Load data from file
        if (fitx == null) {
            fitxTmp = getFitxerDades();
        } else {
            // Last directory
            fitxTmp = getFitxerDades(fitx.getPath());
        }
        if (fitxTmp == null) {
            // Cancel pressed
            ambDades = false;
        } else {
            fitx = fitxTmp;
            ambDades = true;
        }
    } else if (evt.getActionCommand().equals(strUpdate)) {
        // UPDATE        
        buttonClicked = true;

        if (action1 == "Calculate") {
            action = "CalUpdate";

            doLoad(action);
            return;
        }

        ifd = currentInternalFrame.getInternalFrameData();
        if ((Jpan_Menu.getTypeData() == ifd.getTypeData()) && (Jpan_Menu.getMethod() == ifd.getMethod())
                && (Jpan_Menu.getPrecision() == ifd.getPrecision())) {
            action = "Redraw";
        } else {
            action = "Reload";
        }
        ambDades = true;
    }
    if (ambDades && (action.equals("Load") || action.equals("Reload"))) {
        try {
            de = new DadesExternes(fitx);
            if (action.equals("Load")) {
                Jpan_Menu.setPrecision(de.getPrecisio());
            }
            multiDendro = null;
            try {
                multiDendro = de.getMatriuDistancies();
                minBase = Double.MAX_VALUE;
                progressBar.setBorderPainted(true);
                progressBar.setString(null);
                fr.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                // Instances of javax.swing.SwingWorker are not reusable,
                // so we create new instances as needed.
                mdComputation = new MDComputation(action, Jpan_Menu.getTypeData(), Jpan_Menu.getMethod(),
                        Jpan_Menu.getPrecision(), multiDendro.getCardinalitat(), minBase);
                mdComputation.addPropertyChangeListener(this);
                mdComputation.execute();
            } catch (final Exception e2) {
                buttonClicked = false;
                showError(e2.getMessage());
            }
        } catch (Exception e1) {
            buttonClicked = false;
            showError(e1.getMessage());
        }
    } else if (ambDades && action.equals("Redraw")) {
        showCalls(action);
    } else {
        buttonClicked = false;
    }
}

From source file:org.tinymediamanager.ui.tvshows.settings.TvShowSettingsPanel.java

/**
 * Instantiates a new tv show settings panel.
 *//*from   w  w w. j  ava2s .c  om*/
public TvShowSettingsPanel() {
    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, RowSpec.decode("default:grow"),
                    FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow(3)"), }));

    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, 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, }));

    lblImageCache = new JLabel(BUNDLE.getString("Settings.imagecacheimport"));
    panelGeneral.add(lblImageCache, "2, 2");

    chckbxImageCache = new JCheckBox("");
    panelGeneral.add(chckbxImageCache, "4, 2");

    lblImageCacheHint = new JLabel(BUNDLE.getString("Settings.imagecacheimporthint")); //$NON-NLS-1$
    panelGeneral.add(lblImageCacheHint, "6, 2, 3, 1");
    TmmFontHelper.changeFont(lblImageCacheHint, 0.833);

    final JSeparator separator = new JSeparator();
    panelGeneral.add(separator, "2, 4, 7, 1");

    JLabel lblTraktTv = new JLabel(BUNDLE.getString("Settings.trakt"));//$NON-NLS-1$
    panelGeneral.add(lblTraktTv, "2, 6");

    chckbxTraktTv = new JCheckBox("");
    panelGeneral.add(chckbxTraktTv, "4, 6");
    btnClearTraktTvShows = new JButton(BUNDLE.getString("Settings.trakt.cleartvshows"));//$NON-NLS-1$
    btnClearTraktTvShows.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            int confirm = JOptionPane.showOptionDialog(null,
                    BUNDLE.getString("Settings.trakt.cleartvshows.hint"),
                    BUNDLE.getString("Settings.trakt.cleartvshows"), JOptionPane.YES_NO_OPTION, //$NON-NLS-1$
                    JOptionPane.QUESTION_MESSAGE, null, null, null);
            if (confirm == JOptionPane.YES_OPTION) {
                TmmTask task = new ClearTraktTvTask(false, true);
                TmmTaskManager.getInstance().addUnnamedTask(task);
            }
        }
    });
    panelGeneral.add(btnClearTraktTvShows, "6, 6");

    JPanel panelBadWords = new JPanel();
    panelBadWords.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.tvshow.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.tvshow.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 = TvShowModuleManager.SETTINGS.getBadWords().get(row);
                TvShowModuleManager.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())) {
                TvShowModuleManager.SETTINGS.addBadWord(tfAddBadword.getText());
                tfAddBadword.setText("");
            }
        }
    });
    panelBadWords.add(btnAddBadWord, "4, 6");

    {
        JPanel panelTvShowDataSources = new JPanel();

        panelTvShowDataSources.setBorder(new TitledBorder(null, BUNDLE.getString("Settings.tvshowdatasource"), //$NON-NLS-1$
                TitledBorder.LEADING, TitledBorder.TOP, null, null));
        add(panelTvShowDataSources, "2, 4, 3, 1, fill, top");
        panelTvShowDataSources.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("50dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC,
                FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.UNRELATED_GAP_COLSPEC,
                FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("200dlu:grow(2)"),
                FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
                FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, },
                new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("160px:grow"),
                        FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.RELATED_GAP_ROWSPEC, }));

        JLabel lblDataSource = new JLabel(BUNDLE.getString("Settings.source")); //$NON-NLS-1$
        panelTvShowDataSources.add(lblDataSource, "2, 2, 5, 1");

        JLabel lblSkipFolders = new JLabel(BUNDLE.getString("Settings.ignore"));//$NON-NLS-1$
        panelTvShowDataSources.add(lblSkipFolders, "12, 2, 3, 1");

        JScrollPane scrollPaneDatasource = new JScrollPane();
        panelTvShowDataSources.add(scrollPaneDatasource, "2, 4, 5, 1, fill, fill");

        listDatasources = new JList<>();
        scrollPaneDatasource.setViewportView(listDatasources);

        JPanel panelTvShowSourcesButtons = new JPanel();
        panelTvShowDataSources.add(panelTvShowSourcesButtons, "8, 4, default, top");
        panelTvShowSourcesButtons.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() {
            public void actionPerformed(ActionEvent arg0) {
                Path file = TmmUIHelper
                        .selectDirectory(BUNDLE.getString("Settings.tvshowdatasource.folderchooser")); //$NON-NLS-1$
                if (file != null && Files.isDirectory(file)) {
                    settings.addTvShowDataSources(file.toAbsolutePath().toString());
                }
            }
        });

        panelTvShowSourcesButtons.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 = settings.getTvShowDataSource().get(row);
                    String[] choices = { BUNDLE.getString("Button.continue"), //$NON-NLS-1$
                            BUNDLE.getString("Button.abort") };
                    int decision = JOptionPane.showOptionDialog(null,
                            String.format(BUNDLE.getString("Settings.tvshowdatasource.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));
                        settings.removeTvShowDataSources(path);
                        setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                    }
                }
            }
        });
        panelTvShowSourcesButtons.add(btnRemove, "1, 3, fill, top");

        JScrollPane scrollPane = new JScrollPane();
        panelTvShowDataSources.add(scrollPane, "12, 4, fill, fill");

        listExclude = new JList<>();
        scrollPane.setViewportView(listExclude);

        JPanel panelSkipFolderButtons = new JPanel();
        panelTvShowDataSources.add(panelSkipFolderButtons, "14, 4, fill, fill");
        panelSkipFolderButtons.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, },
                new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, }));

        JButton btnAddSkipFolder = new JButton(IconManager.LIST_ADD);
        btnAddSkipFolder.setToolTipText(BUNDLE.getString("Settings.addignore")); //$NON-NLS-1$
        btnAddSkipFolder.setMargin(new Insets(2, 2, 2, 2));
        btnAddSkipFolder.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.addTvShowSkipFolder(file.toAbsolutePath().toString());
                }
            }
        });
        panelSkipFolderButtons.add(btnAddSkipFolder, "1, 1");

        JButton btnRemoveSkipFolder = new JButton(IconManager.LIST_REMOVE);
        btnRemoveSkipFolder.setToolTipText(BUNDLE.getString("Settings.removeignore")); //$NON-NLS-1$
        btnRemoveSkipFolder.setMargin(new Insets(2, 2, 2, 2));
        btnRemoveSkipFolder.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                int row = listExclude.getSelectedIndex();
                if (row != -1) { // nothing selected
                    String ingore = settings.getTvShowSkipFolders().get(row);
                    settings.removeTvShowSkipFolder(ingore);
                }
            }
        });
        panelSkipFolderButtons.add(btnRemoveSkipFolder, "1, 3");

        JLabel lblDvdOrder = new JLabel(BUNDLE.getString("Settings.dvdorder")); //$NON-NLS-1$
        panelTvShowDataSources.add(lblDvdOrder, "2, 6, right, default");

        cbDvdOrder = new JCheckBox("");
        panelTvShowDataSources.add(cbDvdOrder, "4, 6");
    }

    initDataBindings();

    if (!Globals.isDonator()) {
        chckbxTraktTv.setSelected(false);
        chckbxTraktTv.setEnabled(false);
        btnClearTraktTvShows.setEnabled(false);
    }
}

From source file:com.qspin.qtaste.ui.TestCaseTree.java

public void loadSelectedTestCase(TreePath path) {
    if (path != null) {
        FileNode fn = getFileNode(path);
        if (fn != null && fn.isTestcaseDir()) {
            File testcaseFile = fn.getTestcaseFile();
            if (testCasePane.getTestScripPane() != null) {
                try {
                    if (testcaseFile.getAbsoluteFile().getCanonicalPath()
                            .equals(testCasePane.getTestScripPane().getFileName())) {
                        return;
                    }/*from w ww . j av  a 2s  .c o m*/
                } catch (IOException e) {
                    logger.error(e.getMessage());
                    return;
                }
            }
            if (testcaseFile != null) {
                testCasePane.setCurrentSelectedFileNode(fn);
                if (fn.getFile().getName().equals("TestSuite")) {
                    testCasePane.setCurrentSelectedTestsuite("TestSuite");
                } else {
                    String parentDir = testcaseFile.getParent();
                    testCasePane.setCurrentSelectedTestsuite(parentDir);
                }
                setTestCaseSource(testcaseFile, false);

            }
            File testcaseData = fn.getPythonTestScript().getTestcaseData();
            if (testcaseData != null) {
                setTestCaseData(testcaseData, false);
            }
            File testcaseRequirement = fn.getPythonTestScript().getTestcaseRequirements();
            if (testcaseRequirement != null) {
                setTestCaseRequirement(testcaseRequirement, false);
            }
            //  regenerate the doc if file date of script > file date of doc
            PythonTestScript script = fn.getPythonTestScript();
            boolean generateDoc = testCasePane.isDocTabSelected() && !script.isDocSynchronized();

            if (generateDoc) {
                testCasePane.parent.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                script.generateDoc();
                // Generate the documentation
                setTestCaseDoc(script.getTestcaseDoc(), false);
                testCasePane.parent.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            } else
                // update the screen with the doc of the selected test script
                setTestCaseDoc(script.getTestcaseDoc(), false);
            // Get the user preferences to display the testcase tab
            GUIConfiguration guiConfiguration = GUIConfiguration.getInstance();
            String testCaseTabOnSelect = "none"; // default
            if (guiConfiguration.containsKey(TEST_CASE_TAB_ON_SELECT_PROPERTY)) {
                testCaseTabOnSelect = guiConfiguration.getString(TEST_CASE_TAB_ON_SELECT_PROPERTY)
                        .toLowerCase();
            } else {
                guiConfiguration.setProperty(TEST_CASE_TAB_ON_SELECT_PROPERTY, testCaseTabOnSelect);
                try {
                    guiConfiguration.save();
                } catch (ConfigurationException ex) {
                    logger.error("Error while saving GUI configuration: " + ex.getMessage());
                }
            }
            if (testCaseTabOnSelect.equals("doc")) {
                testCasePane.getTabbedPane().setSelectedIndex(TestCasePane.DOC_INDEX);
            } else if (testCaseTabOnSelect.equals("source")) {
                testCasePane.getTabbedPane().setSelectedIndex(TestCasePane.SOURCE_INDEX);
            } else if (testCaseTabOnSelect.equals("results")) {
                testCasePane.getTabbedPane().setSelectedIndex(TestCasePane.RESULTS_INDEX);
            } else if (testCaseTabOnSelect.equals("logs")) {
                testCasePane.getTabbedPane().setSelectedIndex(TestCasePane.LOGS_INDEX);
            } else if (!testCaseTabOnSelect.equals("none")) {
                logger.warn("Invalid value for GUI configuration property " + TEST_CASE_TAB_ON_SELECT_PROPERTY
                        + " (" + guiConfiguration.getString(TEST_CASE_TAB_ON_SELECT_PROPERTY) + ")");
            }
        }
    }
}

From source file:br.ufrgs.enq.jcosmo.ui.COSMOSACDialog.java

private void rebuildChart() {
    if (listModel.getSize() < 2) {
        JOptionPane.showMessageDialog(this, "Select 2 compounds.", "Error", JOptionPane.OK_OPTION);
        err = true;/*from ww w  .j ava 2s .  com*/
        return;
    }
    if (listModel.getSize() > 2) {
        JOptionPane.showMessageDialog(this, "Select only 2 compounds.", "Error", JOptionPane.OK_OPTION);
        return;
    }
    double T = Double.parseDouble(temperature.getText());
    if (T <= 0) {
        JOptionPane.showMessageDialog(this, "Invalid Temperature.", "Error", JOptionPane.OK_OPTION);
        return;
    }

    COSMOSAC cosmosac = (COSMOSAC) modelBox.getSelectedItem();
    COSMOSACCompound comps[] = new COSMOSACCompound[2];
    try {
        comps[0] = db.getComp((String) listModel.getElementAt(0));
        comps[1] = db.getComp((String) listModel.getElementAt(1));
        cosmosac.setComponents(comps);
    } catch (Exception e1) {
        e1.printStackTrace();
        return;
    }
    if (comps[0] == null || comps[1] == null)
        return;

    cosmosac.setSigmaHB(Double.parseDouble(sigmaHB.getText()));
    cosmosac.setSigmaHB2(Double.parseDouble(sigmaHB2.getText()));
    cosmosac.setSigmaHB3(Double.parseDouble(sigmaHB3.getText()));
    //      cosmosac.setSigmaHBUpper(Double.parseDouble(sigmaHBUpper.getText()));
    cosmosac.setCHB(Double.parseDouble(chargeHB.getText()));
    cosmosac.setSigmaDisp(Double.parseDouble(sigmaDisp.getText()));
    cosmosac.setCDisp(Double.parseDouble(chargeDisp.getText()));
    cosmosac.setBeta(Double.parseDouble(beta.getText()));
    cosmosac.setFpol(Double.parseDouble(fpol.getText()));
    cosmosac.setAnorm(Double.parseDouble(anorm.getText()));
    cosmosac.parametersChanged();

    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));

    //      cosmosac.setParameters(cavityVolume, c1.charge, sigma);

    cosmosac.setTemperature(T);

    // testing several compositions
    XYSeriesCollection dataset = new XYSeriesCollection();
    int n = 20;
    XYSeries lnGamma1 = new XYSeries(comps[0].name);
    XYSeries lnGamma2 = new XYSeries(comps[1].name);
    XYSeries ge_RT = new XYSeries("gE/RT");

    for (int i = 0; i <= n; ++i) {
        z[0] = (double) i / n;
        z[1] = 1 - z[0];
        cosmosac.setComposition(z);
        cosmosac.activityCoefficient(lnGamma);

        lnGamma1.add(z[0], lnGamma[0]);
        lnGamma2.add(z[0], lnGamma[1]);
        ge_RT.add(z[0], z[0] * lnGamma[0] + z[1] * lnGamma[1]);

        if (z[0] == 0) {
            lnGammaInf1Label.setText(String.format("%6.3g", lnGamma[0]));
            gammaInf1Label.setText(String.format("%6.3g", Math.exp(lnGamma[0])));
        }
        if (z[1] == 0) {
            lnGammaInf2Label.setText(String.format("%6.3g", lnGamma[1]));
            gammaInf2Label.setText(String.format("%6.3g", Math.exp(lnGamma[1])));
        }
    }
    dataset.addSeries(lnGamma1);
    dataset.addSeries(lnGamma2);
    dataset.addSeries(ge_RT);

    plot.setDataset(dataset);

    // now the segment gamma
    dataset = new XYSeriesCollection();
    double[][] seggamma = cosmosac.getPureSegmentGamma();

    n = comps[0].charge.length;
    XYSeries g1 = new XYSeries(comps[0].name);
    XYSeries g2 = new XYSeries(comps[1].name);
    XYSeries g1s = new XYSeries(comps[0].name + " * sigma");
    XYSeries g2s = new XYSeries(comps[1].name + " * sigma");

    for (int j = 0; j < n; ++j) {
        g1.add(comps[0].charge[j], Math.log(seggamma[0][j]));
        g2.add(comps[1].charge[j], Math.log(seggamma[1][j]));
        g1s.add(comps[0].charge[j], comps[0].area[j] * (Math.log(seggamma[1][j]) - Math.log(seggamma[0][j])));
        g2s.add(comps[1].charge[j], comps[1].area[j] * (Math.log(seggamma[0][j]) - Math.log(seggamma[1][j])));
    }
    dataset.addSeries(g1);
    dataset.addSeries(g2);
    dataset.addSeries(g1s);
    dataset.addSeries(g2s);
    plotSegGamma.setDataset(dataset);

    // adjust the plot properties
    plotSegGamma.getDomainAxis().setAutoRange(false);
    plotSegGamma.getDomainAxis().setRange(new Range(-0.025, 0.025));
    XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) plotSegGamma.getRenderer();
    r.setSeriesStroke(0, new BasicStroke(2.5f));
    r.setSeriesStroke(1, new BasicStroke(2.5f));
    BasicStroke dashed = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
            new float[] { 6.0f, 6.0f }, 0.0f);

    r.setSeriesStroke(2, dashed);
    r.setSeriesStroke(3, dashed);
    r.setSeriesPaint(0, Color.RED);
    r.setSeriesPaint(1, Color.BLUE);
    r.setSeriesPaint(2, Color.RED);
    r.setSeriesPaint(3, Color.BLUE);
    //      plotSegGamma.setRenderer(stepRenderer);
    //      plotSegGamma.setRenderer(3, stepRenderer);

    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}

From source file:au.org.ala.delta.editor.ui.CharacterTree.java

public void expandAll() {

    try {//from  ww w . jav  a  2 s .  c  om
        setCursor(new Cursor(Cursor.WAIT_CURSOR));
        for (int i = 0; i < getRowCount(); i++) {
            expandRow(i);
        }
    } finally {
        setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    }
}

From source file:org.tinymediamanager.ui.movies.settings.MovieSettingsPanel.java

/**
 * Instantiates a new movie settings panel.
 *//*from  w w w.  ja  va  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:AltiConsole.AltiConsoleMainScreen.java

public AltiConfigData retrieveAltiConfig() {
    this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    AltiConfigData Alticonfig = null;/*from   w w w.  j  a  va  2s  . c  o m*/
    Alticonfig = new AltiConfigData();

    if (Serial.getConnected() == false) {
        boolean ret = false;
        ret = ConnectToAlti();
        if (!ret) {
            System.out.println("retrieveAltiConfig - Data retrieval timed out1\n");
            this.setCursor(Cursor.getDefaultCursor());
            return null;
        }
    }
    Serial.clearInput();
    //Serial.DataReady = false;
    Serial.setDataReady(false);
    // send command to switch off the continuity test
    Serial.writeData("b;\n");
    System.out.println("b;\n");
    long timeOut = 10000;
    if (UserPref.getRetrievalTimeout() != null && UserPref.getRetrievalTimeout() != "")
        timeOut = Long.decode(UserPref.getRetrievalTimeout());
    long startTime = System.currentTimeMillis();
    //while (!Serial.getDataReady()) {
    while (true) {
        long currentTime = System.currentTimeMillis();
        if (Serial.getDataReady())
            break;
        if ((currentTime - startTime) > timeOut) {
            // This is some sort of data retrieval timeout
            System.out.println("retrieveAltiConfig - Data retrieval timed out2\n");
            if (Serial.getDataReady())
                System.out.println("Data is true\n");
            else
                System.out.println("Data is false\n");
            JOptionPane.showMessageDialog(null, trans.get("AltiConsoleMainScreen.dataTimeOut") + "0",
                    trans.get("AltiConsoleMainScreen.ConnectionError"), JOptionPane.ERROR_MESSAGE);
            this.setCursor(Cursor.getDefaultCursor());

            return null;
        }
    }
    if (Serial.AltiCfg != null) {
        System.out.println("Reading altimeter config\n");
        System.out.println(Serial.AltiCfg.getUnits() + "\n");
        Alticonfig = Serial.AltiCfg;

    }
    this.setCursor(Cursor.getDefaultCursor());
    return Alticonfig;
}