Example usage for javax.swing SpinnerNumberModel SpinnerNumberModel

List of usage examples for javax.swing SpinnerNumberModel SpinnerNumberModel

Introduction

In this page you can find the example usage for javax.swing SpinnerNumberModel SpinnerNumberModel.

Prototype

public SpinnerNumberModel(double value, double minimum, double maximum, double stepSize) 

Source Link

Document

Constructs a SpinnerNumberModel with the specified value, minimum/maximum bounds, and stepSize.

Usage

From source file:org.pentaho.reporting.ui.datasources.pmd.PmdDataSourceEditor.java

private void init(final DesignTimeContext context) {
    if (context == null) {
        throw new NullPointerException();
    }// ww  w  . j  a v a 2s.  c  o  m

    this.context = context;
    setModal(true);
    setTitle(Messages.getString("PmdDataSourceEditor.Title"));

    maxPreviewRowsSpinner = new JSpinner(new SpinnerNumberModel(10000, 1, Integer.MAX_VALUE, 1));
    previewAction = new PreviewAction();
    globalTemplateAction = new GlobalTemplateAction();
    queryTemplateAction = new QueryTemplateAction();

    filenameField = new JTextField(null, 0);
    filenameField.setColumns(30);
    filenameField.getDocument().addDocumentListener(new FilenameDocumentListener());

    queryNameList = new JList();
    queryNameList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    queryNameList.setVisibleRowCount(5);
    queryNameList.addListSelectionListener(new QueryNameListSelectionListener());
    queryNameList.setCellRenderer(new QueryNameListCellRenderer());

    queryAddButton = new BorderlessButton(new AddQueryAction());
    queryRemoveButton = new BorderlessButton(new RemoveQueryAction());

    queryNameTextField = new JTextField(null, 0);
    queryNameTextField.setColumns(35);
    queryNameTextField.getDocument().addDocumentListener(new QueryNameTextFieldDocumentListener());

    domainIdTextField = new JTextField(null, 0);
    domainIdTextField.setColumns(35);
    domainIdTextField.getDocument().addDocumentListener(new DomainTextFieldDocumentListener());

    queryTextArea = new RSyntaxTextArea();
    queryTextArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_XML);
    queryTextArea.setWrapStyleWord(true);
    queryTextArea.setLineWrap(true);
    queryTextArea.setRows(5);
    queryTextArea.getDocument().addDocumentListener(new QueryDocumentListener());

    queryDesignerButton = new JButton(new QueryDesignerAction());
    queryDesignerButton.setEnabled(false);
    queryDesignerButton.setBorder(new EmptyBorder(0, 0, 0, 0));

    globalScriptTextArea = new RSyntaxTextArea();
    globalScriptTextArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_NONE);

    globalLanguageField = new SmartComboBox(new DefaultComboBoxModel(getScriptEngineLanguages()));
    globalLanguageField.setRenderer(new QueryLanguageListCellRenderer());
    globalLanguageField.addActionListener(new UpdateScriptLanguageHandler());

    queryScriptTextArea = new RSyntaxTextArea();
    queryScriptTextArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_NONE);
    queryScriptTextArea.getDocument().addDocumentListener(new QueryScriptDocumentListener());

    queryLanguageListCellRenderer = new QueryLanguageListCellRenderer();

    queryLanguageField = new SmartComboBox(new DefaultComboBoxModel(getScriptEngineLanguages()));
    queryLanguageField.setRenderer(queryLanguageListCellRenderer);
    queryLanguageField.addActionListener(new UpdateScriptLanguageHandler());

    super.init();
}

From source file:org.processmining.framework.log.filter.LogEventLogFilterEnh.java

/**
 * Returns a Panel for the setting of parameters. When a LogFilter can be
 * added to a list in the framework. This panel is shown, and parameters can
 * be set. When the dialog is closed, a new instance of a LogFilter is
 * created by the framework by calling the <code>getNewLogFilter</code>
 * method of the dialog.//from ww w  .  j a  v  a  2  s .c  om
 * 
 * @param summary
 *            A LogSummary to be used for setting parameters.
 * @return JPanel
 */
public LogFilterParameterDialog getParameterDialog(LogSummary summary) {
    return new LogFilterParameterDialog(summary, LogEventLogFilterEnh.this) {

        LogEventCheckBoxEnh[] checks;
        JSpinner percTaskSpinner;
        JSpinner percPiSpinner;
        JComboBox choiceBox;

        /**
         * Keep the statistics for all the tasks
         */
        SummaryStatistics taskStatistics = null;

        /**
         * Keep the statistics for the occurrence of tasks in process
         * instances
         */
        SummaryStatistics piStatistics = null;

        public LogFilter getNewLogFilter() {
            LogEvents e = new LogEvents();
            for (int i = 0; i < checks.length; i++) {
                if (checks[i].isSelected()) {
                    e.add(checks[i].getLogEvent());
                }
            }
            return new LogEventLogFilterEnh(e, getDoubleValueFromSpinner(percTaskSpinner.getValue()),
                    getDoubleValueFromSpinner(percPiSpinner.getValue()),
                    choiceBox.getSelectedItem().toString());
        }

        protected JPanel getPanel() {
            // add message to the test log for this plugin
            Message.add("<EnhEvtLogFilter>", Message.TEST);
            // statistics
            taskStatistics = SummaryStatistics.newInstance();
            piStatistics = SummaryStatistics.newInstance();
            // Set up an percentformatter
            NumberFormat percentFormatter = NumberFormat.getPercentInstance();
            percentFormatter.setMinimumFractionDigits(2);
            percentFormatter.setMaximumFractionDigits(2);
            // Instantiate the spinners
            percTaskSpinner = new JSpinner(new SpinnerNumberModel(5.0, 0.0, 100.0, 1.0));
            percPiSpinner = new JSpinner(new SpinnerNumberModel(5.0, 0.0, 100.0, 1.0));
            // generate the buttons that are needed
            JButton jButtonCalculate = new JButton("Calculate");
            JButton jButtonInvert = new JButton("Invert selection");
            // set up a choicebox to indicate whether the relationship
            // between the two
            // percentages is AND or OR.

            percTaskSpinner.setValue(new Double(percentageTask));
            percPiSpinner.setValue(new Double(percentagePI));

            choiceBox = new JComboBox();
            choiceBox.addItem("AND");
            choiceBox.addItem("OR");
            choiceBox.setSelectedItem(selectedItemComboBox);

            // Some values that are needed for the sequel.
            int size = summary.getLogEvents().size();
            // For the new log reader sumATEs should be calculated in
            // another way
            int sumATEs = 0;
            if (summary instanceof ExtendedLogSummary) {
                sumATEs = summary.getNumberOfAuditTrailEntries();
            } else if (summary instanceof LightweightLogSummary) {
                HashSet<ProcessInstance> pis = new HashSet<ProcessInstance>();
                Iterator logEvents = summary.getLogEvents().iterator();
                while (logEvents.hasNext()) {
                    LogEvent evt = (LogEvent) logEvents.next();
                    pis.addAll(summary.getInstancesForEvent(evt));
                }
                Iterator pis2 = pis.iterator();
                while (pis2.hasNext()) {
                    ProcessInstance pi = (ProcessInstance) pis2.next();
                    int simPis = MethodsForWorkflowLogDataStructures.getNumberSimilarProcessInstances(pi);
                    int numberATEs = pi.getAuditTrailEntryList().size();
                    sumATEs += simPis * numberATEs;
                    pi.isEmpty();
                }
            } else {

            }
            // calculate the number of process Instances, taking into
            // account
            // the number of similar instances
            int sumPIs = 0;
            if (summary instanceof LightweightLogSummary) {
                sumPIs = calculateSumPIs(summary);
            }
            checks = new LogEventCheckBoxEnh[size];

            // create panels and labels
            JPanel global = new JPanel(new BorderLayout());
            JPanel sub2 = new JPanel(new BorderLayout());
            sub2.setBackground(Color.white);
            JLabel labelPercTask = new JLabel("percentage task");
            JLabel labelPercPI = new JLabel("percentage PI");

            // create panel sub1 to put the checkboxes on
            JPanel sub1 = new JPanel(new SpringLayout());
            sub1.setBackground(Color.lightGray);

            // Get percentage of task in the log and percentage of in how
            // many
            // different PIs it appears.
            Iterator it = summary.getLogEvents().iterator();
            int i = 0;
            while (it.hasNext()) {
                LogEvent evt = (LogEvent) it.next();
                double percent = 0.0;
                if (summary instanceof ExtendedLogSummary) {
                    percent = ((double) evt.getOccurrenceCount() / (double) sumATEs);
                } else if (summary instanceof LightweightLogSummary) {
                    Set instances = summary.getInstancesForEvent(evt);
                    // getFrequencyTasks(evt, instances)
                    percent = (double) getFrequencyTasks(evt, instances) / (double) sumATEs;
                } else {

                }
                // String percString = percentFormatter.format(percent);
                LogEventCheckBoxEnh check = new LogEventCheckBoxEnh(evt);
                check.setPercentageTask(percent * 100);
                // add percentage to the statistics for the tasks
                taskStatistics.addValue(percent);
                // Get percentage of in how many different PIs a task
                // appears,
                // taking into account whether the new or old logreader is
                // used
                if (summary instanceof LightweightLogSummary) {
                    Set<ProcessInstance> pis = summary.getInstancesForEvent(evt);
                    int numberInstancesTask = 0;
                    Iterator it2 = pis.iterator();
                    while (it2.hasNext()) {
                        ProcessInstance pi = (ProcessInstance) it2.next();
                        numberInstancesTask += MethodsForWorkflowLogDataStructures
                                .getNumberSimilarProcessInstances(pi);
                    }
                    double fPI = (double) numberInstancesTask / (double) sumPIs;

                    check.setPercentagePI(fPI * 100);
                    // add percentage to the statistics for the PIs
                    piStatistics.addValue(fPI);
                } else if (summary instanceof ExtendedLogSummary) {
                    double percPIcheck = getPercentagePI(evt);
                    check.setPercentagePI(percPIcheck);
                    piStatistics.addValue(percPIcheck / 100);
                } else {
                    // raise exception, unknown logreader
                }
                // add to the checks array
                checks[i++] = check;
            }
            // fill sub1 with statistics information
            sub1.add(new JLabel(" Statistics    ( #tasks = " + taskStatistics.getN() + " )"));
            sub1.add(new JLabel(" "));
            sub1.add(new JLabel(" "));
            sub1.add(new JLabel(" Arithmetic Mean "));
            sub1.add(new JLabel(percentFormatter.format(taskStatistics.getMean())));
            sub1.add(new JLabel(percentFormatter.format(piStatistics.getMean())));
            sub1.add(new JLabel(" Geometric Mean "));
            sub1.add(new JLabel(percentFormatter.format(taskStatistics.getGeometricMean())));
            sub1.add(new JLabel(percentFormatter.format(piStatistics.getGeometricMean())));
            sub1.add(new JLabel(" Standard Deviation "));
            sub1.add(new JLabel(percentFormatter.format(taskStatistics.getStandardDeviation())));
            sub1.add(new JLabel(percentFormatter.format(piStatistics.getStandardDeviation())));
            sub1.add(new JLabel(" Min "));
            sub1.add(new JLabel(percentFormatter.format(taskStatistics.getMin())));
            sub1.add(new JLabel(percentFormatter.format(piStatistics.getMin())));
            sub1.add(new JLabel(" Max "));
            sub1.add(new JLabel(percentFormatter.format(taskStatistics.getMax())));
            sub1.add(new JLabel(percentFormatter.format(piStatistics.getMax())));
            sub1.add(new JLabel(" ------------------ "));
            sub1.add(new JLabel(" --------------- "));
            sub1.add(new JLabel(" --------------- "));
            sub1.add(new JLabel(" Tasks "));
            sub1.add(new JLabel(" percentage task "));
            sub1.add(new JLabel(" percentage PI "));
            // generate messages for the test case for this plugin
            Message.add("number tasks: " + taskStatistics.getN(), Message.TEST);
            Message.add("<percentage task>", Message.TEST);
            Message.add("arithmetic mean: " + taskStatistics.getMean(), Message.TEST);
            Message.add("geometric mean: " + taskStatistics.getGeometricMean(), Message.TEST);
            Message.add("standard deviation: " + taskStatistics.getStandardDeviation(), Message.TEST);
            Message.add("min: " + taskStatistics.getMin(), Message.TEST);
            Message.add("max: " + taskStatistics.getMax(), Message.TEST);
            Message.add("<percentage task/>", Message.TEST);
            Message.add("<percentage PI>", Message.TEST);
            Message.add("arithmetic mean: " + piStatistics.getMean(), Message.TEST);
            Message.add("geometric mean: " + piStatistics.getGeometricMean(), Message.TEST);
            Message.add("standard deviation: " + piStatistics.getStandardDeviation(), Message.TEST);
            Message.add("min: " + piStatistics.getMin(), Message.TEST);
            Message.add("max: " + piStatistics.getMax(), Message.TEST);
            Message.add("<percentage PI/>", Message.TEST);
            // add the checkboxes to the GUI.
            Arrays.sort(checks);
            for (i = 0; i < checks.length; i++) {
                sub1.add(checks[i]);
                if ((eventsToKeep != null) && (!eventsToKeep.contains(checks[i].getLogEvent()))) {
                    checks[i].setSelected(false);
                }
                // put the percentages on the GUI
                sub1.add(new JLabel(percentFormatter.format(checks[i].getPercentageTask() / 100)));
                sub1.add(new JLabel(percentFormatter.format(checks[i].getPercentagePI() / 100)));
            }
            //
            SpringUtilities util = new SpringUtilities();
            util.makeCompactGrid(sub1, checks.length + 8, 3, 3, 3, 8, 3);
            // put the contents on the respective panels
            global.add(sub2, java.awt.BorderLayout.CENTER);
            global.add(sub1, java.awt.BorderLayout.SOUTH);
            //
            JPanel sub21 = new JPanel(new SpringLayout());
            // sub21.setLayout(new BoxLayout(sub21, BoxLayout.PAGE_AXIS));
            sub2.setBackground(Color.red);
            JPanel textPanel = new JPanel(new BorderLayout());
            textPanel.setBackground(Color.yellow);
            JPanel sub221 = new JPanel(new FlowLayout());
            sub221.setBackground(Color.yellow);
            JPanel sub222 = new JPanel(new FlowLayout());
            sub222.setBackground(Color.yellow);
            // two different panels to be places on sub21
            // JPanel sub21First = new JPanel();
            // sub21First.setLayout(new BoxLayout(sub21First,
            // BoxLayout.LINE_AXIS));
            // sub21First.setMaximumSize(new Dimension(1000, 25));
            // sub21First.add(Box.createHorizontalGlue());
            // sub21First.add(labelPercTask);
            // sub21First.add(percTaskSpinner, null);
            // percTaskSpinner.setMaximumSize(new Dimension(10, 20));
            // sub21First.add(jButtonCalculate);
            // jButtonCalculate.setMaximumSize(new Dimension(10, 20));
            // sub21First.add(labelPercPI);
            // sub21First.add(percPiSpinner, null);
            // percPiSpinner.setMaximumSize(new Dimension(10, 20));
            // sub21First.add(choiceBox);
            // choiceBox.setMaximumSize(new Dimension(10, 20));
            // sub21First.add(Box.createHorizontalGlue());
            // JPanel sub21Second = new JPanel();
            // sub21Second.setLayout(new BoxLayout(sub21Second,
            // BoxLayout.LINE_AXIS));
            // sub21Second.setMaximumSize(new Dimension(1000, 25));
            // sub21Second.add(Box.createHorizontalGlue());
            // sub21Second.add(jButtonInvert);
            // sub21Second.add(Box.createHorizontalGlue());
            //
            // sub21.add(sub21First);
            // sub21.add(sub21Second);

            sub21.add(labelPercTask);
            sub21.add(percTaskSpinner, null);
            sub21.add(jButtonCalculate);
            sub21.add(labelPercPI);
            sub21.add(percPiSpinner, null);
            sub21.add(choiceBox);
            // add the invert button
            sub21.add(new JLabel(" "));
            sub21.add(new JLabel(" "));
            sub21.add(jButtonInvert);
            sub21.add(new JLabel(" "));
            sub21.add(new JLabel(" "));
            sub21.add(new JLabel(" "));
            sub21.setMaximumSize(sub21.getPreferredSize());
            sub2.add(sub21, java.awt.BorderLayout.CENTER);
            sub2.add(textPanel, java.awt.BorderLayout.SOUTH);
            textPanel.add(new JLabel(
                    "The Calculate button needs to be clicked to calculate which tasks need to be selected!!!"),
                    java.awt.BorderLayout.CENTER);
            textPanel.add(
                    new JLabel("Clicking the OK button only accepts, but nothing is again calculated!!!!"),
                    java.awt.BorderLayout.SOUTH);
            util.makeCompactGrid(sub21, 2, 6, 3, 3, 8, 3);
            //

            // specify button action for the button ButtonPreview
            jButtonCalculate.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    // The preview button is clicked
                    buttonClicked();
                    // end for
                }
            });

            // specify button action for the button Invert
            jButtonInvert.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    invertButtonClicked();
                }
            });

            return global;

        }

        /**
         * When the preview button is clicked
         */
        public void buttonClicked() {
            for (int k = 0; k < checks.length; k++) {
                boolean firstCheck = false;
                boolean secondCheck = false;
                LogEventCheckBoxEnh c = checks[k];
                // check for the task in c whether its percentage is higher
                // than
                // perc
                firstCheck = checkTask(c, percTaskSpinner.getValue());

                // Also check whether the task occurs in more than percTr
                // percent of the traces
                secondCheck = checkPI(c, percPiSpinner.getValue());

                // Check whether for choiceBox OR or AND is selected
                boolean logicalResult = true;
                if (((String) choiceBox.getSelectedItem()).equals("AND")) {
                    logicalResult = firstCheck && secondCheck;
                } else if (((String) choiceBox.getSelectedItem()).equals("OR")) {
                    logicalResult = firstCheck || secondCheck;
                }
                // set the checkbox selected or not
                if (logicalResult == true) {
                    c.setSelected(true);
                } else {
                    c.setSelected(false);
                }
            }
            // add messages to the test log for this case
            int numberCheckedBoxes = 0;
            for (int i = 0; i < checks.length; i++) {
                if (checks[i].isSelected()) {
                    numberCheckedBoxes++;
                }
            }
            Message.add("number of selected tasks: " + numberCheckedBoxes, Message.TEST);
            Message.add("<EnhEvtLogFilter/>", Message.TEST);
        }

        /**
         *
         */
        public void invertButtonClicked() {
            for (int i = 0; i < checks.length; i++) {
                checks[i].setSelected(!checks[i].isSelected());
            }
        }

        /**
         * Checks whether the task in c occurs with a lower percentage in
         * the log than the percentage given by percTask.
         * 
         * @param c
         *            LogEventCheckBoxEnh the checkbox that contains the
         *            task.
         * @param percTask
         *            Object the percentage
         * @return boolean True if the percentage of which the task in c
         *         occurs in the log is greater or equal than percTaks,
         *         false otherwise.
         */
        private boolean checkTask(LogEventCheckBoxEnh c, Object percTask) {
            boolean returnBoolean = false;
            double percT = 0.0;
            percT = getDoubleValueFromSpinner(percTask);
            // check whether its percentage is higher than percT
            if (c.getPercentageTask() >= percT) {
                returnBoolean = true;
            } else {
                returnBoolean = false;
            }

            return returnBoolean;
        }

        /**
         * Checks whether the task in c occurs with a lower percentage in
         * different process instances than the percentage given by
         * percTrace.
         * 
         * @param c
         *            LogEventCheckBoxEnh the checkbox that contains the
         *            task.
         * @param percTrace
         *            Object the percentage.
         * @return boolean True, if the percentage of which the task in
         *         different process instances occurs in the log is greater
         *         or equal than percTrace, false otherwise.
         */
        private boolean checkPI(LogEventCheckBoxEnh c, Object percPIobj) {
            boolean returnBoolean = false;
            double percPI = 0.0;

            percPI = getDoubleValueFromSpinner(percPIobj);
            // check whether its percentage is higher than percPI
            if (c.getPercentagePI() >= percPI) {
                returnBoolean = true;
            } else {
                returnBoolean = false;
            }

            return returnBoolean;
        }

        /**
         * Get the percentage of that this task occurs in different PIs
         * 
         * @param evt
         *            LogEvent the logEvent in which the task can be found
         * @return double the percentage of which this task in the log
         *         occurs
         */
        private double getPercentagePI(LogEvent evt) {
            double returnPercent = 0.0;
            HashMap mapping = ((ExtendedLogSummary) summary).getMappingAtesToNumberPIs();
            int numberPI = summary.getNumberOfProcessInstances();

            // Get the frequency of PI in which the task occurs
            Object value = null;
            Iterator it = mapping.keySet().iterator();
            while (it.hasNext()) {
                Object keyObj = it.next();
                String key = (String) keyObj;
                if (key.equals(
                        evt.getModelElementName().trim() + " " + "(" + evt.getEventType().trim() + ")")) {
                    value = mapping.get(keyObj);
                    break;
                }
            }

            if (value != null) {
                // calculate frequency
                returnPercent = (((Integer) value).doubleValue() / new Double(numberPI).doubleValue()) * 100;
            }

            return returnPercent;
        }

        private int getFrequencyTasks(LogEvent evt, Set instances) {
            int returnFrequency = 0;
            Iterator instIterator = instances.iterator();
            while (instIterator.hasNext()) {
                ProcessInstance pi = (ProcessInstance) instIterator.next();
                Iterator ates = pi.getAuditTrailEntryList().iterator();
                while (ates.hasNext()) {
                    AuditTrailEntry ate = (AuditTrailEntry) ates.next();
                    if (ate.getElement().trim().equals(evt.getModelElementName().trim())
                            && ate.getType().equals(evt.getEventType())) {
                        returnFrequency += MethodsForWorkflowLogDataStructures
                                .getNumberSimilarProcessInstances(pi);
                    }
                }
            }
            return returnFrequency;
        }

        /**
         * Gets the double value of an object, provided that value is a
         * Double or Long object
         * 
         * @param value
         *            Object
         * @return double the double value
         */
        private double getDoubleValueFromSpinner(Object value) {
            double returnDouble = 0.0;

            if (value instanceof Long) {
                returnDouble = (((Long) value).doubleValue());
            } else if (value instanceof Double) {
                returnDouble = (((Double) value).doubleValue());
            }

            return returnDouble;
        }

        /**
         * Returns the number of process instances, taking into account the
         * number of similar instances
         * 
         * @param summary
         *            LogSummary the log summary
         * @return int the number of process instances
         */
        private int calculateSumPIs(LogSummary summary) {
            int returnSum = 0;
            HashSet pis = new HashSet<ProcessInstance>();
            Iterator it = summary.getLogEvents().iterator();
            while (it.hasNext()) {
                LogEvent evt = (LogEvent) it.next();
                pis.addAll(summary.getInstancesForEvent(evt));
            }
            // for each process instance in pis, get the number of similar
            // instances
            Iterator it2 = pis.iterator();
            while (it2.hasNext()) {
                ProcessInstance pi = (ProcessInstance) it2.next();
                returnSum += MethodsForWorkflowLogDataStructures.getNumberSimilarProcessInstances(pi);
            }
            return returnSum;
        }

        protected boolean getAllParametersSet() {
            // calculate values
            // buttonClicked();
            return true;
        }

    };
}

From source file:org.prom5.framework.log.filter.LogEventLogFilterEnh.java

/**
 * Returns a Panel for the setting of parameters. When a LogFilter can be
 * added to a list in the framework. This panel is shown, and parameters can
 * be set. When the dialog is closed, a new instance of a LogFilter is
 * created by the framework by calling the <code>getNewLogFilter</code> method
 * of the dialog.//from w  w w .  j  a  va2s  . co m
 *
 * @param summary A LogSummary to be used for setting parameters.
 * @return JPanel
 */
public LogFilterParameterDialog getParameterDialog(LogSummary summary) {
    return new LogFilterParameterDialog(summary, LogEventLogFilterEnh.this) {

        LogEventCheckBoxEnh[] checks;
        JSpinner percTaskSpinner;
        JSpinner percPiSpinner;
        JComboBox choiceBox;

        /**
         * Keep the statistics for all the tasks
         */
        SummaryStatistics taskStatistics = null;

        /**
         * Keep the statistics for the occurrence of tasks in process instances
         */
        SummaryStatistics piStatistics = null;

        public LogFilter getNewLogFilter() {
            LogEvents e = new LogEvents();
            for (int i = 0; i < checks.length; i++) {
                if (checks[i].isSelected()) {
                    e.add(checks[i].getLogEvent());
                }
            }
            return new LogEventLogFilterEnh(e, getDoubleValueFromSpinner(percTaskSpinner.getValue()),
                    getDoubleValueFromSpinner(percPiSpinner.getValue()),
                    choiceBox.getSelectedItem().toString());
        }

        protected JPanel getPanel() {
            // add message to the test log for this plugin
            Message.add("<EnhEvtLogFilter>", Message.TEST);
            // statistics
            taskStatistics = SummaryStatistics.newInstance();
            piStatistics = SummaryStatistics.newInstance();
            // Set up an percentformatter
            NumberFormat percentFormatter = NumberFormat.getPercentInstance();
            percentFormatter.setMinimumFractionDigits(2);
            percentFormatter.setMaximumFractionDigits(2);
            // Instantiate the spinners
            percTaskSpinner = new JSpinner(new SpinnerNumberModel(5.0, 0.0, 100.0, 1.0));
            percPiSpinner = new JSpinner(new SpinnerNumberModel(5.0, 0.0, 100.0, 1.0));
            // generate the buttons that are needed
            JButton jButtonCalculate = new JButton("Calculate");
            JButton jButtonInvert = new JButton("Invert selection");
            // set up a choicebox to indicate whether the relationship between the two
            // percentages is AND or OR.

            percTaskSpinner.setValue(new Double(percentageTask));
            percPiSpinner.setValue(new Double(percentagePI));

            choiceBox = new JComboBox();
            choiceBox.addItem("AND");
            choiceBox.addItem("OR");
            choiceBox.setSelectedItem(selectedItemComboBox);

            // Some values that are needed for the sequel.
            int size = summary.getLogEvents().size();
            // For the new log reader sumATEs should be calculated in another way
            int sumATEs = 0;
            if (summary instanceof ExtendedLogSummary) {
                sumATEs = summary.getNumberOfAuditTrailEntries();
            } else if (summary instanceof LightweightLogSummary) {
                HashSet<ProcessInstance> pis = new HashSet<ProcessInstance>();
                Iterator logEvents = summary.getLogEvents().iterator();
                while (logEvents.hasNext()) {
                    LogEvent evt = (LogEvent) logEvents.next();
                    pis.addAll(summary.getInstancesForEvent(evt));
                }
                Iterator pis2 = pis.iterator();
                while (pis2.hasNext()) {
                    ProcessInstance pi = (ProcessInstance) pis2.next();
                    int simPis = MethodsForWorkflowLogDataStructures.getNumberSimilarProcessInstances(pi);
                    int numberATEs = pi.getAuditTrailEntryList().size();
                    sumATEs += simPis * numberATEs;
                    pi.isEmpty();
                }
            } else {

            }
            // calculate the number of process Instances, taking into account
            // the number of similar instances
            int sumPIs = 0;
            if (summary instanceof LightweightLogSummary) {
                sumPIs = calculateSumPIs(summary);
            }
            checks = new LogEventCheckBoxEnh[size];

            // create panels and labels
            JPanel global = new JPanel(new BorderLayout());
            JPanel sub2 = new JPanel(new BorderLayout());
            sub2.setBackground(Color.white);
            JLabel labelPercTask = new JLabel("percentage task");
            JLabel labelPercPI = new JLabel("percentage PI");

            // create panel sub1 to put the checkboxes on
            JPanel sub1 = new JPanel(new SpringLayout());
            sub1.setBackground(Color.lightGray);

            // Get percentage of task in the log and percentage of in how many
            // different PIs it appears.
            Iterator it = summary.getLogEvents().iterator();
            int i = 0;
            while (it.hasNext()) {
                LogEvent evt = (LogEvent) it.next();
                double percent = 0.0;
                if (summary instanceof ExtendedLogSummary) {
                    percent = ((double) evt.getOccurrenceCount() / (double) sumATEs);
                } else if (summary instanceof LightweightLogSummary) {
                    Set instances = summary.getInstancesForEvent(evt);
                    // getFrequencyTasks(evt, instances)
                    percent = (double) getFrequencyTasks(evt, instances) / (double) sumATEs;
                } else {

                }
                //String percString = percentFormatter.format(percent);
                LogEventCheckBoxEnh check = new LogEventCheckBoxEnh(evt);
                check.setPercentageTask(percent * 100);
                // add percentage to the statistics for the tasks
                taskStatistics.addValue(percent);
                // Get percentage of in how many different PIs a task appears,
                // taking into account whether the new or old logreader is used
                if (summary instanceof LightweightLogSummary) {
                    Set<ProcessInstance> pis = summary.getInstancesForEvent(evt);
                    int numberInstancesTask = 0;
                    Iterator it2 = pis.iterator();
                    while (it2.hasNext()) {
                        ProcessInstance pi = (ProcessInstance) it2.next();
                        numberInstancesTask += MethodsForWorkflowLogDataStructures
                                .getNumberSimilarProcessInstances(pi);
                    }
                    double fPI = (double) numberInstancesTask / (double) sumPIs;

                    check.setPercentagePI(fPI * 100);
                    // add percentage to the statistics for the PIs
                    piStatistics.addValue(fPI);
                } else if (summary instanceof ExtendedLogSummary) {
                    double percPIcheck = getPercentagePI(evt);
                    check.setPercentagePI(percPIcheck);
                    piStatistics.addValue(percPIcheck / 100);
                } else {
                    // raise exception, unknown logreader
                }
                // add to the checks array
                checks[i++] = check;
            }
            // fill sub1 with statistics information
            sub1.add(new JLabel(" Statistics    ( #tasks = " + taskStatistics.getN() + " )"));
            sub1.add(new JLabel(" "));
            sub1.add(new JLabel(" "));
            sub1.add(new JLabel(" Arithmetic Mean "));
            sub1.add(new JLabel(percentFormatter.format(taskStatistics.getMean())));
            sub1.add(new JLabel(percentFormatter.format(piStatistics.getMean())));
            sub1.add(new JLabel(" Geometric Mean "));
            sub1.add(new JLabel(percentFormatter.format(taskStatistics.getGeometricMean())));
            sub1.add(new JLabel(percentFormatter.format(piStatistics.getGeometricMean())));
            sub1.add(new JLabel(" Standard Deviation "));
            sub1.add(new JLabel(percentFormatter.format(taskStatistics.getStandardDeviation())));
            sub1.add(new JLabel(percentFormatter.format(piStatistics.getStandardDeviation())));
            sub1.add(new JLabel(" Min "));
            sub1.add(new JLabel(percentFormatter.format(taskStatistics.getMin())));
            sub1.add(new JLabel(percentFormatter.format(piStatistics.getMin())));
            sub1.add(new JLabel(" Max "));
            sub1.add(new JLabel(percentFormatter.format(taskStatistics.getMax())));
            sub1.add(new JLabel(percentFormatter.format(piStatistics.getMax())));
            sub1.add(new JLabel(" ------------------ "));
            sub1.add(new JLabel(" --------------- "));
            sub1.add(new JLabel(" --------------- "));
            sub1.add(new JLabel(" Tasks "));
            sub1.add(new JLabel(" percentage task "));
            sub1.add(new JLabel(" percentage PI "));
            // generate messages for the test case for this plugin
            Message.add("number tasks: " + taskStatistics.getN(), Message.TEST);
            Message.add("<percentage task>", Message.TEST);
            Message.add("arithmetic mean: " + taskStatistics.getMean(), Message.TEST);
            Message.add("geometric mean: " + taskStatistics.getGeometricMean(), Message.TEST);
            Message.add("standard deviation: " + taskStatistics.getStandardDeviation(), Message.TEST);
            Message.add("min: " + taskStatistics.getMin(), Message.TEST);
            Message.add("max: " + taskStatistics.getMax(), Message.TEST);
            Message.add("<percentage task/>", Message.TEST);
            Message.add("<percentage PI>", Message.TEST);
            Message.add("arithmetic mean: " + piStatistics.getMean(), Message.TEST);
            Message.add("geometric mean: " + piStatistics.getGeometricMean(), Message.TEST);
            Message.add("standard deviation: " + piStatistics.getStandardDeviation(), Message.TEST);
            Message.add("min: " + piStatistics.getMin(), Message.TEST);
            Message.add("max: " + piStatistics.getMax(), Message.TEST);
            Message.add("<percentage PI/>", Message.TEST);
            // add the checkboxes to the GUI.
            Arrays.sort(checks);
            for (i = 0; i < checks.length; i++) {
                sub1.add(checks[i]);
                if ((eventsToKeep != null) && (!eventsToKeep.contains(checks[i].getLogEvent()))) {
                    checks[i].setSelected(false);
                }
                // put the percentages on the GUI
                sub1.add(new JLabel(percentFormatter.format(checks[i].getPercentageTask() / 100)));
                sub1.add(new JLabel(percentFormatter.format(checks[i].getPercentagePI() / 100)));
            }
            //
            SpringUtilities util = new SpringUtilities();
            util.makeCompactGrid(sub1, checks.length + 8, 3, 3, 3, 8, 3);
            // put the contents on the respective panels
            global.add(sub2, java.awt.BorderLayout.CENTER);
            global.add(sub1, java.awt.BorderLayout.SOUTH);
            //
            JPanel sub21 = new JPanel(new SpringLayout());
            //sub21.setLayout(new BoxLayout(sub21, BoxLayout.PAGE_AXIS));
            sub2.setBackground(Color.red);
            JPanel textPanel = new JPanel(new BorderLayout());
            textPanel.setBackground(Color.yellow);
            JPanel sub221 = new JPanel(new FlowLayout());
            sub221.setBackground(Color.yellow);
            JPanel sub222 = new JPanel(new FlowLayout());
            sub222.setBackground(Color.yellow);
            // two different panels to be places on sub21
            //JPanel sub21First = new JPanel();
            //sub21First.setLayout(new BoxLayout(sub21First, BoxLayout.LINE_AXIS));
            //sub21First.setMaximumSize(new Dimension(1000, 25));
            //sub21First.add(Box.createHorizontalGlue());
            //sub21First.add(labelPercTask);
            //sub21First.add(percTaskSpinner, null);
            //percTaskSpinner.setMaximumSize(new Dimension(10, 20));
            //sub21First.add(jButtonCalculate);
            //jButtonCalculate.setMaximumSize(new Dimension(10, 20));
            //sub21First.add(labelPercPI);
            //sub21First.add(percPiSpinner, null);
            //percPiSpinner.setMaximumSize(new Dimension(10, 20));
            //sub21First.add(choiceBox);
            //choiceBox.setMaximumSize(new Dimension(10, 20));
            //sub21First.add(Box.createHorizontalGlue());
            //JPanel sub21Second = new JPanel();
            //sub21Second.setLayout(new BoxLayout(sub21Second, BoxLayout.LINE_AXIS));
            //sub21Second.setMaximumSize(new Dimension(1000, 25));
            //sub21Second.add(Box.createHorizontalGlue());
            //sub21Second.add(jButtonInvert);
            //sub21Second.add(Box.createHorizontalGlue());
            //
            //sub21.add(sub21First);
            //sub21.add(sub21Second);

            sub21.add(labelPercTask);
            sub21.add(percTaskSpinner, null);
            sub21.add(jButtonCalculate);
            sub21.add(labelPercPI);
            sub21.add(percPiSpinner, null);
            sub21.add(choiceBox);
            // add the invert button
            sub21.add(new JLabel(" "));
            sub21.add(new JLabel(" "));
            sub21.add(jButtonInvert);
            sub21.add(new JLabel(" "));
            sub21.add(new JLabel(" "));
            sub21.add(new JLabel(" "));
            sub21.setMaximumSize(sub21.getPreferredSize());
            sub2.add(sub21, java.awt.BorderLayout.CENTER);
            sub2.add(textPanel, java.awt.BorderLayout.SOUTH);
            textPanel.add(new JLabel(
                    "The Calculate button needs to be clicked to calculate which tasks need to be selected!!!"),
                    java.awt.BorderLayout.CENTER);
            textPanel.add(
                    new JLabel("Clicking the OK button only accepts, but nothing is again calculated!!!!"),
                    java.awt.BorderLayout.SOUTH);
            util.makeCompactGrid(sub21, 2, 6, 3, 3, 8, 3);
            //

            // specify button action for the button ButtonPreview
            jButtonCalculate.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    // The preview button is clicked
                    buttonClicked();
                    // end for
                }
            });

            // specify button action for the button Invert
            jButtonInvert.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    invertButtonClicked();
                }
            });

            return global;

        }

        /**
         * When the preview button is clicked
         */
        public void buttonClicked() {
            for (int k = 0; k < checks.length; k++) {
                boolean firstCheck = false;
                boolean secondCheck = false;
                LogEventCheckBoxEnh c = checks[k];
                // check for the task in c whether its percentage is higher than
                // perc
                firstCheck = checkTask(c, percTaskSpinner.getValue());

                // Also check whether the task occurs in more than percTr
                // percent of the traces
                secondCheck = checkPI(c, percPiSpinner.getValue());

                // Check whether for choiceBox OR or AND is selected
                boolean logicalResult = true;
                if (((String) choiceBox.getSelectedItem()).equals("AND")) {
                    logicalResult = firstCheck && secondCheck;
                } else if (((String) choiceBox.getSelectedItem()).equals("OR")) {
                    logicalResult = firstCheck || secondCheck;
                }
                // set the checkbox selected or not
                if (logicalResult == true) {
                    c.setSelected(true);
                } else {
                    c.setSelected(false);
                }
            }
            // add messages to the test log for this case
            int numberCheckedBoxes = 0;
            for (int i = 0; i < checks.length; i++) {
                if (checks[i].isSelected()) {
                    numberCheckedBoxes++;
                }
            }
            Message.add("number of selected tasks: " + numberCheckedBoxes, Message.TEST);
            Message.add("<EnhEvtLogFilter/>", Message.TEST);
        }

        /**
         *
         */
        public void invertButtonClicked() {
            for (int i = 0; i < checks.length; i++) {
                checks[i].setSelected(!checks[i].isSelected());
            }
        }

        /**
         * Checks whether the task in c occurs with a lower percentage in the log
         * than the percentage given by percTask.
         * @param c LogEventCheckBoxEnh the checkbox that contains the task.
         * @param percTask Object the percentage
         * @return boolean True if the percentage of which the task in c occurs
         * in the log is greater or equal than percTaks, false otherwise.
         */
        private boolean checkTask(LogEventCheckBoxEnh c, Object percTask) {
            boolean returnBoolean = false;
            double percT = 0.0;
            percT = getDoubleValueFromSpinner(percTask);
            // check whether its percentage is higher than percT
            if (c.getPercentageTask() >= percT) {
                returnBoolean = true;
            } else {
                returnBoolean = false;
            }

            return returnBoolean;
        }

        /**
         * Checks whether the task in c occurs with a lower percentage in different
         * process instances than the percentage given by percTrace.
         * @param c LogEventCheckBoxEnh the checkbox that contains the task.
         * @param percTrace Object the percentage.
         * @return boolean True, if the percentage of which the task in different
         * process instances occurs in the log is greater or equal than percTrace,
         * false otherwise.
         */
        private boolean checkPI(LogEventCheckBoxEnh c, Object percPIobj) {
            boolean returnBoolean = false;
            double percPI = 0.0;

            percPI = getDoubleValueFromSpinner(percPIobj);
            // check whether its percentage is higher than percPI
            if (c.getPercentagePI() >= percPI) {
                returnBoolean = true;
            } else {
                returnBoolean = false;
            }

            return returnBoolean;
        }

        /**
         * Get the percentage of that this task occurs in different PIs
         * @param evt LogEvent the logEvent in which the task can be found
         * @return double the percentage of which this task in the log occurs
         */
        private double getPercentagePI(LogEvent evt) {
            double returnPercent = 0.0;
            HashMap mapping = ((ExtendedLogSummary) summary).getMappingAtesToNumberPIs();
            int numberPI = summary.getNumberOfProcessInstances();

            // Get the frequency of PI in which the task occurs
            Object value = null;
            Iterator it = mapping.keySet().iterator();
            while (it.hasNext()) {
                Object keyObj = it.next();
                String key = (String) keyObj;
                if (key.equals(
                        evt.getModelElementName().trim() + " " + "(" + evt.getEventType().trim() + ")")) {
                    value = mapping.get(keyObj);
                    break;
                }
            }

            if (value != null) {
                // calculate frequency
                returnPercent = (((Integer) value).doubleValue() / new Double(numberPI).doubleValue()) * 100;
            }

            return returnPercent;
        }

        private int getFrequencyTasks(LogEvent evt, Set instances) {
            int returnFrequency = 0;
            Iterator instIterator = instances.iterator();
            while (instIterator.hasNext()) {
                ProcessInstance pi = (ProcessInstance) instIterator.next();
                Iterator ates = pi.getAuditTrailEntryList().iterator();
                while (ates.hasNext()) {
                    AuditTrailEntry ate = (AuditTrailEntry) ates.next();
                    if (ate.getElement().trim().equals(evt.getModelElementName().trim())
                            && ate.getType().equals(evt.getEventType())) {
                        returnFrequency += MethodsForWorkflowLogDataStructures
                                .getNumberSimilarProcessInstances(pi);
                    }
                }
            }
            return returnFrequency;
        }

        /**
         * Gets the double value of an object, provided that value is a
         * Double or Long object
         * @param value Object
         * @return double the double value
         */
        private double getDoubleValueFromSpinner(Object value) {
            double returnDouble = 0.0;

            if (value instanceof Long) {
                returnDouble = (((Long) value).doubleValue());
            } else if (value instanceof Double) {
                returnDouble = (((Double) value).doubleValue());
            }

            return returnDouble;
        }

        /**
         * Returns the number of process instances, taking into account the
         * number of similar instances
         * @param summary LogSummary the log summary
         * @return int the number of process instances
         */
        private int calculateSumPIs(LogSummary summary) {
            int returnSum = 0;
            HashSet pis = new HashSet<ProcessInstance>();
            Iterator it = summary.getLogEvents().iterator();
            while (it.hasNext()) {
                LogEvent evt = (LogEvent) it.next();
                pis.addAll(summary.getInstancesForEvent(evt));
            }
            // for each process instance in pis, get the number of similar instances
            Iterator it2 = pis.iterator();
            while (it2.hasNext()) {
                ProcessInstance pi = (ProcessInstance) it2.next();
                returnSum += MethodsForWorkflowLogDataStructures.getNumberSimilarProcessInstances(pi);
            }
            return returnSum;
        }

        protected boolean getAllParametersSet() {
            // calculate values
            //buttonClicked();
            return true;
        }

    };
}

From source file:org.squidy.designer.zoom.impl.VisualizationShape.java

/**
 * /*  w w w.  ja  v a2  s.  c om*/
 */
private final void initTimeSpinner() {
    PBounds bounds = getBoundsReference();

    final JSpinner spinner = new JSpinner(new SpinnerNumberModel(sampleTime, 1000, 10000, 500));
    spinner.addChangeListener(new ChangeListener() {

        /*
         * (non-Javadoc)
         * 
         * @see
         * javax.swing.event.ChangeListener#stateChanged(javax.swing.event
         * .ChangeEvent)
         */
        public void stateChanged(ChangeEvent e) {
            sampleTime = ((Double) spinner.getValue()).longValue();
            invalidatePaint();
        }
    });

    timeSpinner = new JComponentWrapper(spinner);
    timeSpinner.setOffset((bounds.getWidth() * 0.25) - (timeSpinner.getWidth() / 2),
            bounds.getHeight() * 0.75 + 0.25);
    addChild(timeSpinner);
}

From source file:org.thelq.stackexchange.dbimport.gui.GUI.java

public GUI(Controller passedController) {
    //Initialize logger
    logAppender = new GUILogAppender(this);

    //Set our Look&Feel
    try {//w ww.  j  a  v  a  2  s.co m
        if (SystemUtils.IS_OS_WINDOWS)
            UIManager.setLookAndFeel(new WindowsLookAndFeel());
        else
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
        log.warn("Defaulting to Swing L&F due to exception", e);
    }

    this.controller = passedController;
    frame = new JFrame();
    frame.setTitle("Unified StackExchange Data Dump Importer v" + Controller.VERSION);
    frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

    //Setup menu
    JMenuBar menuBar = new JMenuBar();
    menuAdd = new JMenuItem("Add Folders/Archives");
    menuAdd.setMnemonic(KeyEvent.VK_F);
    menuBar.add(menuAdd);
    frame.setJMenuBar(menuBar);

    //Primary panel
    FormLayout primaryLayout = new FormLayout("5dlu, pref:grow, 5dlu, 5dlu, pref",
            "pref, top:pref, pref, fill:140dlu:grow, pref, fill:80dlu");
    PanelBuilder primaryBuilder = new PanelBuilder(primaryLayout)
            .border(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    //DB Config panel
    primaryBuilder.addSeparator("Database Configuration", CC.xyw(1, 1, 2));
    FormLayout configLayout = new FormLayout("pref, 3dlu, pref:grow, 6dlu, pref",
            "pref, pref:grow, 3dlu, pref:grow, 3dlu, pref:grow, 3dlu, pref:grow, 3dlu, pref:grow, 3dlu, pref:grow");
    configLayout.setHonorsVisibility(true);
    final PanelBuilder configBuilder = new PanelBuilder(configLayout);
    configBuilder.addLabel("Server", CC.xy(1, 2), dbType = new JComboBox<DatabaseOption>(), CC.xy(3, 2));
    configBuilder.add(dbAdvanced = new JCheckBox("Show advanced options"), CC.xy(5, 2));
    configBuilder.addLabel("JDBC Connection", CC.xy(1, 4), jdbcString = new JTextField(15), CC.xyw(3, 4, 3));
    configBuilder.addLabel("Username", CC.xy(1, 6), username = new JTextField(10), CC.xy(3, 6));
    configBuilder.addLabel("Password", CC.xy(1, 8), password = new JPasswordField(10), CC.xy(3, 8));
    configBuilder.add(importButton = new JButton("Import"), CC.xywh(5, 6, 1, 3));
    //Add hidden
    JLabel dialectLabel = new JLabel("Dialect");
    dialectLabel.setVisible(false);
    configBuilder.add(dialectLabel, CC.xy(1, 10), dialect = new JTextField(10), CC.xyw(3, 10, 3));
    dialect.setVisible(false);
    JLabel driverLabel = new JLabel("Driver");
    driverLabel.setVisible(false);
    configBuilder.add(driverLabel, CC.xy(1, 12), driver = new JTextField(10) {
        @Override
        public void setText(String text) {
            if (StringUtils.isBlank(text))
                log.debug("Text is blank", new RuntimeException("Text " + text + " is blank"));
            super.setText(text);
        }
    }, CC.xyw(3, 12, 3));
    driver.setVisible(false);
    primaryBuilder.add(configBuilder.getPanel(), CC.xy(2, 2));

    //Options
    primaryBuilder.addSeparator("Options", CC.xyw(4, 1, 2));
    FormLayout optionsLayout = new FormLayout("pref, 3dlu, pref:grow", "");
    DefaultFormBuilder optionsBuilder = new DefaultFormBuilder(optionsLayout);
    optionsBuilder.append(disableCreateTables = new JCheckBox("Disable Creating Tables"), 3);
    optionsBuilder.append("Global Table Prefix", globalTablePrefix = new JTextField(7));
    optionsBuilder.append("Threads", threads = new JSpinner());
    //Save a core for the database
    int numThreads = Runtime.getRuntime().availableProcessors();
    numThreads = (numThreads != 1) ? numThreads - 1 : numThreads;
    threads.setModel(new SpinnerNumberModel(numThreads, 1, 100, 1));
    optionsBuilder.append("Batch Size", batchSize = new JSpinner());
    batchSize.setModel(new SpinnerNumberModel(500, 1, 500000, 1));
    primaryBuilder.add(optionsBuilder.getPanel(), CC.xy(5, 2));

    //Locations
    primaryBuilder.addSeparator("Dump Locations", CC.xyw(1, 3, 5));
    FormLayout locationsLayout = new FormLayout("pref, 15dlu, pref, 5dlu, pref, 5dlu, pref:grow, 2dlu, pref",
            "");
    locationsBuilder = new DefaultFormBuilder(locationsLayout, new ScrollablePanel()).background(Color.WHITE)
            .lineGapSize(Sizes.ZERO);
    locationsPane = new JScrollPane(locationsBuilder.getPanel());
    locationsPane.getViewport().setBackground(Color.white);
    locationsPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    locationsPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    primaryBuilder.add(locationsPane, CC.xyw(2, 4, 4));

    //Logger
    primaryBuilder.addSeparator("Log", CC.xyw(1, 5, 5));
    loggerText = new JTextPane();
    loggerText.setEditable(false);
    JPanel loggerTextPanel = new JPanel(new BorderLayout());
    loggerTextPanel.add(loggerText);
    JScrollPane loggerPane = new JScrollPane(loggerTextPanel);
    loggerPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    loggerPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    JPanel loggerPanePanel = new JPanel(new BorderLayout());
    loggerPanePanel.add(loggerPane);
    primaryBuilder.add(loggerPanePanel, CC.xyw(2, 6, 4));

    menuAdd.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            //TODO: Allow 7z files but handle corner cases
            final JFileChooser fc = new JFileChooser();
            fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
            fc.setMultiSelectionEnabled(true);
            fc.setDialogTitle("Select Folders/Archives");
            fc.addChoosableFileFilter(new FileNameExtensionFilter("Archives", "7z", "zip"));
            fc.addChoosableFileFilter(new FileFilter() {
                @Getter
                protected String description = "Folders";

                @Override
                public boolean accept(File file) {
                    return file.isDirectory();
                }
            });

            if (fc.showOpenDialog(frame) != JFileChooser.APPROVE_OPTION)
                return;

            //Add files and folders in a seperate thread while updating gui in EDT
            importButton.setEnabled(false);
            for (File curFile : fc.getSelectedFiles()) {
                DumpContainer dumpContainer = null;
                try {
                    if (curFile.isDirectory())
                        dumpContainer = new FolderDumpContainer(curFile);
                    else
                        dumpContainer = new ArchiveDumpContainer(controller, curFile);
                    controller.addDumpContainer(dumpContainer);
                } catch (Exception ex) {
                    String type = (dumpContainer != null) ? dumpContainer.getType() : "";
                    LoggerFactory.getLogger(getClass()).error("Cannot open " + type, ex);
                    String location = (dumpContainer != null) ? Utils.getLongLocation(dumpContainer) : "";
                    showErrorDialog(ex, "Cannot open " + location, curFile.getAbsolutePath());
                    continue;
                }
            }
            updateLocations();
            importButton.setEnabled(true);
        }
    });

    //Add options (Could be in a map, but this is cleaner)
    dbType.addItem(new DatabaseOption().name("MySQL 5.5.3+")
            .jdbcString("jdbc:mysql://127.0.0.1:3306/stackexchange?rewriteBatchedStatements=true")
            .dialect("org.hibernate.dialect.MySQL5Dialect").driver("com.mysql.jdbc.Driver"));
    dbType.addItem(new DatabaseOption().name("PostgreSQL 8.1")
            .jdbcString("jdbc:postgresql://127.0.0.1:5432/stackexchange")
            .dialect("org.hibernate.dialect.PostgreSQL81Dialect").driver("org.postgresql.Driver"));
    dbType.addItem(new DatabaseOption().name("PostgreSQL 8.2+")
            .jdbcString("jdbc:postgresql://127.0.0.1:5432/stackexchange")
            .dialect("org.hibernate.dialect.PostgreSQL82Dialect").driver("org.postgresql.Driver"));
    dbType.addItem(new DatabaseOption().name("SQL Server")
            .jdbcString("jbdc:jtds:mssql://127.0.0.1:1433/stackexchange")
            .dialect("org.hibernate.dialect.SQLServerDialect").driver("net.sourceforge.jtds.jdbc.Driver"));
    dbType.addItem(new DatabaseOption().name("SQL Server 2005+")
            .jdbcString("jbdc:jtds:mssql://127.0.0.1:1433/stackexchange")
            .dialect("org.hibernate.dialect.SQLServer2005Dialect").driver("net.sourceforge.jtds.jdbc.Driver"));
    dbType.addItem(new DatabaseOption().name("SQL Server 2008+")
            .jdbcString("jbdc:jtds:mssql://127.0.0.1:1433/stackexchange")
            .dialect("org.hibernate.dialect.SQLServer2008Dialect").driver("net.sourceforge.jtds.jdbc.Driver"));
    dbType.addItem(new DatabaseOption().name("H2").jdbcString("jdbc:h2:stackexchange")
            .dialect("org.hibernate.dialect.H2Dialect").driver("org.h2.Driver"));
    dbType.setSelectedItem(null);
    dbType.addItemListener(new ItemListener() {
        boolean shownMysqlWarning = false;

        public void itemStateChanged(ItemEvent e) {
            //Don't run this twice for a single select
            if (e.getStateChange() == ItemEvent.DESELECTED)
                return;

            DatabaseOption selectedOption = (DatabaseOption) dbType.getSelectedItem();
            if (selectedOption.name().startsWith("MySQL") && !shownMysqlWarning) {
                //Hide popup so you don't have to click twice on the dialog 
                dbType.setPopupVisible(false);
                JOptionPane.showMessageDialog(frame,
                        "Warning: Your server must be configured with character_set_server=utf8mb4"
                                + "\nOtherwise, data dumps that contain 4 byte UTF-8 characters will fail",
                        "MySQL Warning", JOptionPane.WARNING_MESSAGE);
                shownMysqlWarning = true;
            }

            setDbOption(selectedOption);
        }
    });

    //Show and hide advanced options with checkbox
    dbAdvanced.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            boolean selected = ((JCheckBox) e.getSource()).isSelected();
            driver.setVisible(selected);
            ((JLabel) driver.getClientProperty("labeledBy")).setVisible(selected);
            dialect.setVisible(selected);
            ((JLabel) dialect.getClientProperty("labeledBy")).setVisible(selected);
        }
    });

    importButton.addActionListener(new ActionListener() {
        protected void showImportError(String error) {
            JOptionPane.showMessageDialog(frame, error, "Configuration Error", JOptionPane.ERROR_MESSAGE);
        }

        protected void showInputErrorDatabase(String error) {
            if (dbType.getSelectedItem() == null)
                showImportError("No dbType specified, " + StringUtils.uncapitalize(error));
            else
                showImportError(error);
        }

        public void actionPerformed(ActionEvent e) {
            boolean validationPassed = false;
            if (controller.getDumpContainers().isEmpty())
                showImportError("Please add dump folders/archives");
            else if (StringUtils.isBlank(jdbcString.getText()))
                showInputErrorDatabase("Must specify JDBC String");
            else if (StringUtils.isBlank(driver.getText()))
                showInputErrorDatabase("Must specify driver");
            else if (StringUtils.isBlank(dialect.getText()))
                showInputErrorDatabase("Must specify hibernate dialect");
            else
                validationPassed = true;

            if (!validationPassed)
                return;

            //Disable all GUI components so they can't change anything during processing
            setGuiEnabled(false);

            //Run in new thread
            controller.getGeneralThreadPool().execute(new Runnable() {
                public void run() {
                    try {
                        start();
                    } catch (final Exception e) {
                        //Show an error message box
                        SwingUtilities.invokeLater(new Runnable() {
                            public void run() {
                                LoggerFactory.getLogger(getClass()).error("Cannot import", e);
                                showErrorDialog(e, "Cannot import", null);
                            }
                        });
                    }
                    //Renable GUI
                    SwingUtilities.invokeLater(new Runnable() {
                        public void run() {
                            setGuiEnabled(true);
                        }
                    });
                }
            });
        }
    });

    //Done, init logger
    logAppender.init();
    log.info("Finished creating GUI");

    //Display
    frame.setContentPane(primaryBuilder.getPanel());
    frame.pack();
    frame.setMinimumSize(frame.getSize());

    frame.setVisible(true);
}

From source file:org.tinymediamanager.ui.movies.dialogs.MovieEditorDialog.java

/**
 * Create the dialog./* www  . ja v  a 2 s.  c om*/
 * 
 * @param movie
 *          the movie
 * @param inQueue
 *          the in queue
 */
public MovieEditorDialog(Movie movie, boolean inQueue) {
    super(BUNDLE.getString("movie.edit"), "movieEditor"); //$NON-NLS-1$
    setBounds(5, 5, 950, 650);

    movieToEdit = movie;
    ids = MediaIdTable.convertIdMapToEventList(movieToEdit.getIds());
    for (MediaFile mf : movie.getMediaFiles()) {
        mediaFiles.add(new MediaFile(mf));
    }

    getContentPane().setLayout(new BorderLayout());
    {
        JPanel panelPath = new JPanel();
        getContentPane().add(panelPath, BorderLayout.NORTH);
        panelPath.setLayout(new FormLayout(
                new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                        FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC,
                        FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, },
                new RowSpec[] { FormFactory.LINE_GAP_ROWSPEC, RowSpec.decode("15px"),
                        FormFactory.RELATED_GAP_ROWSPEC, }));

        JLabel lblMoviePathT = new JLabel(BUNDLE.getString("metatag.path")); //$NON-NLS-1$
        panelPath.add(lblMoviePathT, "2, 2, left, top");

        lblMoviePath = new JLabel("");
        TmmFontHelper.changeFont(lblMoviePath, 1.166, Font.BOLD);
        panelPath.add(lblMoviePath, "5, 2, left, top");
    }

    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.NORTH);
    getContentPane().add(tabbedPane, BorderLayout.CENTER);

    /**
     * DetailsPanel 1
     */
    {
        details1Panel.setBorder(new EmptyBorder(5, 5, 5, 5));
        details1Panel.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC,
                ColumnSpec.decode("max(40dlu;default)"), FormSpecs.RELATED_GAP_COLSPEC,
                FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("7dlu:grow"),
                FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
                ColumnSpec.decode("25dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("24dlu"),
                FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("7dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC,
                FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.UNRELATED_GAP_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
                FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("100dlu:grow(2)"),
                FormSpecs.RELATED_GAP_COLSPEC, },
                new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, RowSpec.decode("50px:grow"),
                        FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                        RowSpec.decode("15dlu"), FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC,
                        RowSpec.decode("fill:50dlu:grow"), FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC,
                        RowSpec.decode("50px"), FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC,
                        RowSpec.decode("fill:default:grow"), }));

        {
            JLabel lblTitle = new JLabel(BUNDLE.getString("metatag.title")); //$NON-NLS-1$
            details1Panel.add(lblTitle, "2, 4, right, default");
        }
        {
            tfTitle = new JTextField();
            details1Panel.add(tfTitle, "4, 4, 15, 1, fill, default");
            tfTitle.setColumns(10);
        }
        {
            // JLabel lblPoster = new JLabel("");
            lblPoster = new ImageLabel();
            lblPoster.setAlternativeText(BUNDLE.getString("image.notfound.poster")); //$NON-NLS-1$
            lblPoster.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    ImageChooserDialog dialog = new ImageChooserDialog(movieToEdit.getIds(), ImageType.POSTER,
                            movieList.getDefaultArtworkScrapers(), lblPoster, null, null, MediaType.MOVIE);
                    dialog.setLocationRelativeTo(MainWindow.getActiveInstance());
                    dialog.setVisible(true);
                }
            });
            lblPoster.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            details1Panel.add(lblPoster, "22, 4, 3, 23, fill, fill");
        }
        {
            JLabel lblOriginalTitle = new JLabel(BUNDLE.getString("metatag.originaltitle")); //$NON-NLS-1$
            details1Panel.add(lblOriginalTitle, "2, 6, right, default");
        }
        {
            tfOriginalTitle = new JTextField();
            details1Panel.add(tfOriginalTitle, "4, 6, 15, 1, fill, top");
            tfOriginalTitle.setColumns(10);
        }
        {
            JLabel lblSorttitle = new JLabel(BUNDLE.getString("metatag.sorttitle")); //$NON-NLS-1$
            details1Panel.add(lblSorttitle, "2, 8, right, default");
        }
        {
            tfSorttitle = new JTextField();
            details1Panel.add(tfSorttitle, "4, 8, 15, 1, fill, default");
            tfSorttitle.setColumns(10);
        }
        {
            JLabel lblTagline = new JLabel(BUNDLE.getString("metatag.tagline")); //$NON-NLS-1$
            details1Panel.add(lblTagline, "2, 10, right, top");
        }
        {
            JScrollPane scrollPaneTagline = new JScrollPane();
            tpTagline = new JTextPane();
            scrollPaneTagline.setViewportView(tpTagline);
            details1Panel.add(scrollPaneTagline, "4, 10, 15, 1, fill, fill");
        }
        {
            JLabel lblYear = new JLabel(BUNDLE.getString("metatag.year")); //$NON-NLS-1$
            details1Panel.add(lblYear, "2, 12, right, default");
        }
        {
            spYear = new YearSpinner();
            details1Panel.add(spYear, "4, 12, fill, top");
        }
        {
            JLabel lblRuntime = new JLabel(BUNDLE.getString("metatag.runtime")); //$NON-NLS-1$
            details1Panel.add(lblRuntime, "8, 12, right, default");
        }
        {
            spRuntime = new JSpinner();
            details1Panel.add(spRuntime, "10, 12, fill, default");
        }
        {
            JLabel lblMin = new JLabel(BUNDLE.getString("metatag.minutes")); //$NON-NLS-1$
            details1Panel.add(lblMin, "12, 12");
        }
        {
            JLabel lblRating = new JLabel(BUNDLE.getString("metatag.rating")); //$NON-NLS-1$
            details1Panel.add(lblRating, "16, 12, right, default");
        }
        {
            spRating = new JSpinner();
            details1Panel.add(spRating, "18, 12");
        }

        spRating.setModel(new SpinnerNumberModel(movie.getRating(), 0.0, 10.0, 0.1));
        {
            JLabel lblReleaseDate = new JLabel(BUNDLE.getString("metatag.releasedate")); //$NON-NLS-1$
            details1Panel.add(lblReleaseDate, "2, 14, right, default");
        }
        {
            dpReleaseDate = new DatePicker(movie.getReleaseDate());
            details1Panel.add(dpReleaseDate, "4, 14");
        }
        {
            JLabel lblCertification = new JLabel(BUNDLE.getString("metatag.certification")); //$NON-NLS-1$
            details1Panel.add(lblCertification, "8, 14, right, default");
        }
        cbCertification = new JComboBox();
        details1Panel.add(cbCertification, "10, 14, 3, 1, fill, default");
        {
            JLabel lblTop = new JLabel(BUNDLE.getString("metatag.top250")); //$NON-NLS-1$
            details1Panel.add(lblTop, "16, 14, right, default");
        }
        {
            spTop250 = new JSpinner();
            details1Panel.add(spTop250, "18, 14");
        }
        spTop250.setValue(movie.getTop250());
        {
            JLabel lblIds = new JLabel("Ids");
            details1Panel.add(lblIds, "2, 16, right, bottom");
        }
        {
            JScrollPane scrollPaneIds = new JScrollPane();
            details1Panel.add(scrollPaneIds, "4, 16, 9, 5, fill, fill");
            {
                tableIds = new MediaIdTable(ids, ScraperType.MOVIE);
                scrollPaneIds.setViewportView(tableIds);
            }
        }
        {
            JButton btnAddId = new JButton("");
            btnAddId.setAction(new AddIdAction());
            btnAddId.setIcon(IconManager.LIST_ADD);
            btnAddId.setMargin(new Insets(2, 2, 2, 2));
            details1Panel.add(btnAddId, "2, 18, right, top");
        }
        {
            JButton btnRemoveId = new JButton("");
            btnRemoveId.setAction(new RemoveIdAction());
            btnRemoveId.setIcon(IconManager.LIST_REMOVE);
            btnRemoveId.setMargin(new Insets(2, 2, 2, 2));
            details1Panel.add(btnRemoveId, "2, 20, right, top");
        }
        {
            JLabel lblSpokenLanguages = new JLabel(BUNDLE.getString("metatag.spokenlanguages")); //$NON-NLS-1$
            details1Panel.add(lblSpokenLanguages, "2, 22, right, default");
        }
        {
            tfSpokenLanguages = new JTextField();
            details1Panel.add(tfSpokenLanguages, "4, 22, fill, default");
            tfSpokenLanguages.setColumns(10);
        }
        {
            JLabel lblCountry = new JLabel(BUNDLE.getString("metatag.country")); //$NON-NLS-1$
            details1Panel.add(lblCountry, "8, 22, right, default");
        }
        {
            tfCountry = new JTextField();
            details1Panel.add(tfCountry, "10, 22, 3, 1, fill, default");
            tfCountry.setColumns(10);
        }
        {
            JLabel lblMovieSet = new JLabel(BUNDLE.getString("metatag.movieset")); //$NON-NLS-1$
            details1Panel.add(lblMovieSet, "2, 24, right, default");
        }
        {
            cbMovieSet = new JComboBox();
            cbMovieSet.addItem("");
            details1Panel.add(cbMovieSet, "4, 24, 9, 1, fill, default");
        }
        {
            JLabel lblDateAdded = new JLabel(BUNDLE.getString("metatag.dateadded")); //$NON-NLS-1$
            details1Panel.add(lblDateAdded, "2, 26, right, default");
        }
        {
            spDateAdded = new JSpinner(new SpinnerDateModel());
            // JSpinner.DateEditor timeEditor = new JSpinner.DateEditor(spDateAdded,
            // "dd.MM.yyyy HH:mm:ss");
            // spDateAdded.setEditor(timeEditor);
            details1Panel.add(spDateAdded, "4, 26");
        }
        spDateAdded.setValue(movie.getDateAdded());
        JLabel lblWatched = new JLabel(BUNDLE.getString("metatag.watched")); //$NON-NLS-1$
        details1Panel.add(lblWatched, "8, 26, right, default");
        {
            cbWatched = new JCheckBox("");
            details1Panel.add(cbWatched, "10, 26");
        }
        cbWatched.setSelected(movie.isWatched());
        lblWatched.setLabelFor(cbWatched);
        {
            JLabel lblSourceT = new JLabel(BUNDLE.getString("metatag.source")); //$NON-NLS-1$
            details1Panel.add(lblSourceT, "2, 28, right, default");
        }
        {
            cbSource = new JComboBox(MediaSource.values());
            details1Panel.add(cbSource, "4, 28, fill, default");
        }
        cbSource.setSelectedItem(movie.getMediaSource());
        {
            final JLabel lblEditionT = new JLabel(BUNDLE.getString("metatag.edition")); //$NON-NLS-1$
            details1Panel.add(lblEditionT, "8, 28, right, default");
        }
        {
            cbEdition = new JComboBox(MovieEdition.values());
            details1Panel.add(cbEdition, "10, 28, 3, 1, fill, default");
        }
        {
            JLabel lblVideod = new JLabel(BUNDLE.getString("metatag.3d")); //$NON-NLS-1$
            details1Panel.add(lblVideod, "16, 28, right, default");
        }
        {
            chckbxVideo3D = new JCheckBox("");
            details1Panel.add(chckbxVideo3D, "18, 28");
        }
        chckbxVideo3D.setSelected(movie.isVideoIn3D());
        {
            JLabel lblPlot = new JLabel(BUNDLE.getString("metatag.plot")); //$NON-NLS-1$
            details1Panel.add(lblPlot, "2, 30, right, top");
        }
        {
            JScrollPane scrollPanePlot = new JScrollPane();
            details1Panel.add(scrollPanePlot, "4, 30, 15, 1, fill, fill");
            {
                tpPlot = new JTextPane();
                scrollPanePlot.setViewportView(tpPlot);
            }
        }
        {
            lblFanart = new ImageLabel();
            lblFanart.setAlternativeText(BUNDLE.getString("image.notfound.fanart")); //$NON-NLS-1$
            lblFanart.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            lblFanart.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    ImageChooserDialog dialog = new ImageChooserDialog(movieToEdit.getIds(), ImageType.FANART,
                            movieList.getDefaultArtworkScrapers(), lblFanart, extrathumbs, extrafanarts,
                            MediaType.MOVIE);
                    dialog.setLocationRelativeTo(MainWindow.getActiveInstance());
                    dialog.setVisible(true);
                }
            });
            details1Panel.add(lblFanart, "22, 30, 3, 5, fill, fill");
        }
        lblFanart.setImagePath(movie.getArtworkFilename(MediaFileType.FANART));
        {
            JLabel lblDirector = new JLabel(BUNDLE.getString("metatag.director")); //$NON-NLS-1$
            details1Panel.add(lblDirector, "2, 32, right, default");
        }
        {
            tfDirector = new JTextField();
            details1Panel.add(tfDirector, "4, 32, 15, 1, fill, top");
            tfDirector.setColumns(10);
        }
        {
            JLabel lblWriter = new JLabel(BUNDLE.getString("metatag.writer")); //$NON-NLS-1$
            details1Panel.add(lblWriter, "2, 34, right, default");
        }
        {
            tfWriter = new JTextField();
            details1Panel.add(tfWriter, "4, 34, 15, 1, fill, top");
            tfWriter.setColumns(10);
        }
        {
            JLabel lblCompany = new JLabel(BUNDLE.getString("metatag.production")); //$NON-NLS-1$
            details1Panel.add(lblCompany, "2, 36, right, top");
        }
        {
            JScrollPane scrollPaneProduction = new JScrollPane();
            details1Panel.add(scrollPaneProduction, "4, 36, 15, 1, fill, fill");
            tfProductionCompanies = new JTextPane();
            scrollPaneProduction.setViewportView(tfProductionCompanies);
        }
        tabbedPane.addTab(BUNDLE.getString("metatag.details"), details1Panel); //$NON-NLS-1$
    }

    /**
     * DetailsPanel 2
     */
    {
        tabbedPane.addTab(BUNDLE.getString("metatag.details2"), details2Panel); //$NON-NLS-1$
        details2Panel.setBorder(new EmptyBorder(5, 5, 5, 5));
        details2Panel.setLayout(new FormLayout(
                new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(40dlu;default)"),
                        FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("50px:grow"),
                        FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                        FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("100px:grow"),
                        FormFactory.RELATED_GAP_COLSPEC, },
                new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("fill:default"),
                        FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"),
                        FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"),
                        FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"),
                        FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow(2)"), }));
        {
            JLabel lblActors = new JLabel(BUNDLE.getString("metatag.actors")); //$NON-NLS-1$
            details2Panel.add(lblActors, "2, 2, right, default");
        }
        {
            JScrollPane scrollPane = new JScrollPane();
            details2Panel.add(scrollPane, "4, 2, 1, 11");
            tableActors = new JTable();
            tableActors.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
            scrollPane.setViewportView(tableActors);
        }
        {
            JLabel lblProducers = new JLabel(BUNDLE.getString("metatag.producers")); //$NON-NLS-1$
            details2Panel.add(lblProducers, "6, 2, right, default");
        }
        {
            JScrollPane scrollPane = new JScrollPane();
            details2Panel.add(scrollPane, "8, 2, 1, 11");
            tableProducers = new JTable();
            tableProducers.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
            scrollPane.setViewportView(tableProducers);
        }
        {
            JButton btnAddActor = new JButton(BUNDLE.getString("cast.actor.add")); //$NON-NLS-1$
            btnAddActor.setMargin(new Insets(2, 2, 2, 2));
            btnAddActor.setAction(new AddActorAction());
            btnAddActor.setIcon(IconManager.LIST_ADD);
            details2Panel.add(btnAddActor, "2, 4, right, top");
        }
        {
            JButton btnAddProducer = new JButton((String) null);
            btnAddProducer.setMargin(new Insets(2, 2, 2, 2));
            btnAddProducer.setAction(new AddProducerAction());
            btnAddProducer.setIcon(IconManager.LIST_ADD);
            details2Panel.add(btnAddProducer, "6, 4, right, top");
        }
        {
            JButton btnRemoveActor = new JButton(BUNDLE.getString("cast.actor.remove")); //$NON-NLS-1$
            btnRemoveActor.setMargin(new Insets(2, 2, 2, 2));
            btnRemoveActor.setAction(new RemoveActorAction());
            btnRemoveActor.setIcon(IconManager.LIST_REMOVE);
            details2Panel.add(btnRemoveActor, "2,6, right, top");
        }
        {
            JButton btnRemoveProducer = new JButton((String) null);
            btnRemoveProducer.setMargin(new Insets(2, 2, 2, 2));
            btnRemoveProducer.setAction(new RemoveProducerAction());
            btnRemoveProducer.setIcon(IconManager.LIST_REMOVE);
            details2Panel.add(btnRemoveProducer, "6, 6, right, top");
        }
        {
            JButton btnMoveActorUp = new JButton((String) null);
            btnMoveActorUp.setMargin(new Insets(2, 2, 2, 2));
            btnMoveActorUp.setAction(new MoveActorUpAction());
            btnMoveActorUp.setIcon(IconManager.ARROW_UP);
            details2Panel.add(btnMoveActorUp, "2, 8, right, top");
        }
        {
            JButton btnMoveProducerUp = new JButton((String) null);
            btnMoveProducerUp.setMargin(new Insets(2, 2, 2, 2));
            btnMoveProducerUp.setAction(new MoveProducerUpAction());
            btnMoveProducerUp.setIcon(IconManager.ARROW_UP);
            details2Panel.add(btnMoveProducerUp, "6, 8, right, top");
        }
        {
            JButton btnMoveActorDown = new JButton((String) null);
            btnMoveActorDown.setMargin(new Insets(2, 2, 2, 2));
            btnMoveActorDown.setAction(new MoveActorDownAction());
            btnMoveActorDown.setIcon(IconManager.ARROW_DOWN);
            details2Panel.add(btnMoveActorDown, "2, 10, right, top");
        }
        {
            JButton btnMoveProducerDown = new JButton((String) null);
            btnMoveProducerDown.setMargin(new Insets(2, 2, 2, 2));
            btnMoveProducerDown.setAction(new MoveProducerDownAction());
            btnMoveProducerDown.setIcon(IconManager.ARROW_DOWN);
            details2Panel.add(btnMoveProducerDown, "6, 10, right, top");
        }
        {
            JLabel lblGenres = new JLabel(BUNDLE.getString("metatag.genre")); //$NON-NLS-1$
            details2Panel.add(lblGenres, "2, 14, right, default");
        }
        {
            JScrollPane scrollPaneGenres = new JScrollPane();
            details2Panel.add(scrollPaneGenres, "4, 14, 1, 5");
            {
                listGenres = new JList();
                scrollPaneGenres.setViewportView(listGenres);
            }
        }
        {
            JLabel lblTags = new JLabel(BUNDLE.getString("metatag.tags")); //$NON-NLS-1$
            details2Panel.add(lblTags, "6, 14, right, default");
        }
        {
            JScrollPane scrollPaneTags = new JScrollPane();
            details2Panel.add(scrollPaneTags, "8, 14, 1, 5");
            listTags = new JList();
            scrollPaneTags.setViewportView(listTags);
        }
        {
            JButton btnAddGenre = new JButton("");
            btnAddGenre.setAction(new AddGenreAction());
            btnAddGenre.setIcon(IconManager.LIST_ADD);
            btnAddGenre.setMargin(new Insets(2, 2, 2, 2));
            details2Panel.add(btnAddGenre, "2, 16, right, top");
        }
        {
            JButton btnAddTag = new JButton("");
            btnAddTag.setAction(new AddTagAction());
            btnAddTag.setIcon(IconManager.LIST_ADD);
            btnAddTag.setMargin(new Insets(2, 2, 2, 2));
            details2Panel.add(btnAddTag, "6, 16, right, top");
        }

        {
            JButton btnRemoveGenre = new JButton("");
            btnRemoveGenre.setAction(new RemoveGenreAction());
            btnRemoveGenre.setMargin(new Insets(2, 2, 2, 2));
            btnRemoveGenre.setIcon(IconManager.LIST_REMOVE);
            details2Panel.add(btnRemoveGenre, "2, 18, right, top");
        }
        {
            JButton btnRemoveTag = new JButton("");
            btnRemoveTag.setAction(new RemoveTagAction());
            btnRemoveTag.setIcon(IconManager.LIST_REMOVE);
            btnRemoveTag.setMargin(new Insets(2, 2, 2, 2));
            details2Panel.add(btnRemoveTag, "6, 18, right, top");
        }
        {
            cbGenres = new AutocompleteComboBox(MediaGenres.values());
            details2Panel.add(cbGenres, "4, 20");
        }
        {
            cbTags = new AutocompleteComboBox(movieList.getTagsInMovies());
            details2Panel.add(cbTags, "8, 20");
        }

        {
            JLabel lblTrailer = new JLabel(BUNDLE.getString("metatag.trailer")); //$NON-NLS-1$
            details2Panel.add(lblTrailer, "2, 22, right, default");
        }
        {
            JScrollPane scrollPaneTrailer = new JScrollPane();
            details2Panel.add(scrollPaneTrailer, "4, 22, 5, 5");
            tableTrailer = new JTable();
            tableTrailer.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
            scrollPaneTrailer.setViewportView(tableTrailer);
        }
        {
            JButton btnAddTrailer = new JButton("");
            btnAddTrailer.setAction(new AddTrailerAction());
            btnAddTrailer.setIcon(IconManager.LIST_ADD);
            btnAddTrailer.setMargin(new Insets(2, 2, 2, 2));
            details2Panel.add(btnAddTrailer, "2, 24, right, top");
        }
        {
            JButton btnRemoveTrailer = new JButton("");
            btnRemoveTrailer.setAction(new RemoveTrailerAction());
            btnRemoveTrailer.setIcon(IconManager.LIST_REMOVE);
            btnRemoveTrailer.setMargin(new Insets(2, 2, 2, 2));
            details2Panel.add(btnRemoveTrailer, "2, 26, right, top");
        }
    }

    /**
     * extra artwork pane
     */
    {
        JPanel artworkPanel = new JPanel();
        tabbedPane.addTab(BUNDLE.getString("metatag.extraartwork"), null, artworkPanel, null); //$NON-NLS-1$
        artworkPanel.setLayout(new FormLayout(
                new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("250px:grow"),
                        FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("250px:grow"),
                        FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("150px:grow"),
                        FormSpecs.RELATED_GAP_COLSPEC, },
                new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("50px:grow(2)"),
                        FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                        RowSpec.decode("50px:grow(2)"), FormSpecs.RELATED_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                        RowSpec.decode("200px:grow(2)"), FormSpecs.RELATED_GAP_ROWSPEC,
                        RowSpec.decode("default:grow"), }));
        {
            JLabel lblLogoT = new JLabel(BUNDLE.getString("mediafiletype.logo")); //$NON-NLS-1$
            artworkPanel.add(lblLogoT, "2, 2");
        }
        {
            lblLogo = new ImageLabel();
            lblLogo.setAlternativeText(BUNDLE.getString("image.notfound.logo")); //$NON-NLS-1$
            lblLogo.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    ImageChooserDialog dialog = new ImageChooserDialog(movieToEdit.getIds(), ImageType.LOGO,
                            movieList.getDefaultArtworkScrapers(), lblLogo, null, null, MediaType.MOVIE);
                    dialog.setLocationRelativeTo(MainWindow.getActiveInstance());
                    dialog.setVisible(true);
                }
            });
            lblLogo.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            artworkPanel.add(lblLogo, "2, 4, fill, fill");
        }
        {
            final JLabel lblClearlogoT = new JLabel(BUNDLE.getString("mediafiletype.clearlogo")); //$NON-NLS-1$
            artworkPanel.add(lblClearlogoT, "4, 2");
        }
        {
            lblClearlogo = new ImageLabel();
            lblClearlogo.setAlternativeText(BUNDLE.getString("image.notfound.clearlogo")); //$NON-NLS-1$
            lblClearlogo.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    ImageChooserDialog dialog = new ImageChooserDialog(movieToEdit.getIds(),
                            ImageType.CLEARLOGO, movieList.getDefaultArtworkScrapers(), lblClearlogo, null,
                            null, MediaType.MOVIE);
                    dialog.setLocationRelativeTo(MainWindow.getActiveInstance());
                    dialog.setVisible(true);
                }
            });
            lblClearlogo.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            artworkPanel.add(lblClearlogo, "4, 4, fill, fill");
        }
        {
            JLabel lblBannerT = new JLabel(BUNDLE.getString("mediafiletype.banner")); //$NON-NLS-1$
            artworkPanel.add(lblBannerT, "2, 6");
        }
        {
            lblBanner = new ImageLabel();
            lblBanner.setAlternativeText(BUNDLE.getString("image.notfound.banner")); //$NON-NLS-1$
            lblBanner.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    ImageChooserDialog dialog = new ImageChooserDialog(movieToEdit.getIds(), ImageType.BANNER,
                            movieList.getDefaultArtworkScrapers(), lblBanner, null, null, MediaType.MOVIE);
                    dialog.setLocationRelativeTo(MainWindow.getActiveInstance());
                    dialog.setVisible(true);
                }
            });
            lblBanner.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            artworkPanel.add(lblBanner, "2, 8, 3, 1, fill, fill");
        }

        {
            JLabel lblClearartT = new JLabel("ClearArt");
            artworkPanel.add(lblClearartT, "2, 10");
        }
        {
            lblClearart = new ImageLabel();
            lblClearart.setAlternativeText(BUNDLE.getString("image.notfound.clearart")); //$NON-NLS-1$
            lblClearart.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    ImageChooserDialog dialog = new ImageChooserDialog(movieToEdit.getIds(), ImageType.CLEARART,
                            movieList.getDefaultArtworkScrapers(), lblClearart, null, null, MediaType.MOVIE);
                    dialog.setLocationRelativeTo(MainWindow.getActiveInstance());
                    dialog.setVisible(true);
                }
            });
            lblClearart.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            artworkPanel.add(lblClearart, "2, 12, fill, fill");
        }
        {
            JLabel lblThumbT = new JLabel("Thumb");
            artworkPanel.add(lblThumbT, "4, 10");
        }
        {
            lblThumb = new ImageLabel();
            lblThumb.setAlternativeText(BUNDLE.getString("image.notfound.thumb")); //$NON-NLS-1$
            lblThumb.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    ImageChooserDialog dialog = new ImageChooserDialog(movieToEdit.getIds(), ImageType.THUMB,
                            movieList.getDefaultArtworkScrapers(), lblThumb, null, null, MediaType.MOVIE);
                    dialog.setLocationRelativeTo(MainWindow.getActiveInstance());
                    dialog.setVisible(true);
                }
            });
            lblThumb.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            artworkPanel.add(lblThumb, "4, 12, fill, fill");
        }
        {
            JLabel lblDiscT = new JLabel("Disc");
            artworkPanel.add(lblDiscT, "6, 10");
        }
        {
            lblDisc = new ImageLabel();
            lblDisc.setAlternativeText(BUNDLE.getString("image.notfound.disc")); //$NON-NLS-1$
            lblDisc.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    ImageChooserDialog dialog = new ImageChooserDialog(movieToEdit.getIds(), ImageType.DISC,
                            movieList.getDefaultArtworkScrapers(), lblDisc, null, null, MediaType.MOVIE);
                    dialog.setLocationRelativeTo(MainWindow.getActiveInstance());
                    dialog.setVisible(true);
                }
            });
            lblDisc.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            artworkPanel.add(lblDisc, "6, 12, fill, fill");
        }
    }

    /**
     * Media Files
     */
    {
        mediaFilesPanel = new MediaFileEditorPanel(mediaFiles);
        tabbedPane.addTab(BUNDLE.getString("metatag.mediafiles"), null, mediaFilesPanel, null); //$NON-NLS-1$
    }

    /**
     * Button pane
     */
    {
        JPanel bottomPane = new JPanel();
        getContentPane().add(bottomPane, BorderLayout.SOUTH);
        bottomPane.setLayout(new FormLayout(
                new ColumnSpec[] { ColumnSpec.decode("371px:grow"), FormFactory.DEFAULT_COLSPEC,
                        FormFactory.RELATED_GAP_COLSPEC, },
                new RowSpec[] { FormFactory.LINE_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.LINE_GAP_ROWSPEC, }));

        JPanel buttonPane = new JPanel();
        bottomPane.add(buttonPane, "2, 2, left, top");
        EqualsLayout layout = new EqualsLayout(5);
        layout.setMinWidth(100);
        buttonPane.setLayout(layout);
        {
            JButton okButton = new JButton(BUNDLE.getString("Button.ok")); //$NON-NLS-1$
            buttonPane.add(okButton, "2, 1, fill, top");
            okButton.setAction(new ChangeMovieAction());
            okButton.setActionCommand("OK");
            getRootPane().setDefaultButton(okButton);
        }
        {
            JButton cancelButton = new JButton(BUNDLE.getString("Button.cancel")); //$NON-NLS-1$
            buttonPane.add(cancelButton, "4, 1, fill, top");
            cancelButton.setAction(new DiscardAction());
            cancelButton.setActionCommand("Cancel");
        }
        if (inQueue) {
            JButton btnAbort = new JButton(BUNDLE.getString("Button.abortqueue")); //$NON-NLS-1$
            btnAbort.setAction(new AbortQueueAction());
            buttonPane.add(btnAbort, "6, 1, fill, top");
        }

    }
    initDataBindings();

    {
        int year = 0;
        try {
            year = Integer.parseInt(movieToEdit.getYear());
        } catch (Exception ignored) {
        }

        SimpleDateFormat dateFormat = (SimpleDateFormat) DateFormat.getDateInstance(DateFormat.MEDIUM);

        for (Certification cert : Certification
                .getCertificationsforCountry(MovieModuleManager.MOVIE_SETTINGS.getCertificationCountry())) {
            cbCertification.addItem(cert);
        }

        tfTitle.setText(movieToEdit.getTitle());
        tfOriginalTitle.setText(movieToEdit.getOriginalTitle());
        tfSorttitle.setText(movieToEdit.getSortTitle());
        tpTagline.setText(movieToEdit.getTagline());
        tpPlot.setText(movieToEdit.getPlot());
        tpPlot.setCaretPosition(0);
        tfDirector.setText(movieToEdit.getDirector());
        tfWriter.setText(movieToEdit.getWriter());
        lblPoster.setImagePath(movieToEdit.getArtworkFilename(MediaFileType.POSTER));
        tfProductionCompanies.setText(movieToEdit.getProductionCompany());
        spRuntime.setValue(movieToEdit.getRuntime());
        cbEdition.setSelectedItem(movieToEdit.getEdition());

        tfSpokenLanguages.setText(movieToEdit.getSpokenLanguages());
        tfCountry.setText(movieToEdit.getCountry());
        spYear.setValue(year);
        cbCertification.setSelectedItem(movieToEdit.getCertification());

        lblMoviePath.setText(movieToEdit.getPath());
        lblLogo.setImagePath(movieToEdit.getArtworkFilename(MediaFileType.LOGO));
        lblClearlogo.setImagePath(movieToEdit.getArtworkFilename(MediaFileType.CLEARLOGO));
        lblClearart.setImagePath(movieToEdit.getArtworkFilename(MediaFileType.CLEARART));
        lblThumb.setImagePath(movieToEdit.getArtworkFilename(MediaFileType.THUMB));
        lblDisc.setImagePath(movieToEdit.getArtworkFilename(MediaFileType.DISCART));
        lblBanner.setImagePath(movieToEdit.getArtworkFilename(MediaFileType.BANNER));

        for (MovieActor origCast : movieToEdit.getActors()) {
            MovieActor actor = new MovieActor();
            actor.setName(origCast.getName());
            actor.setCharacter(origCast.getCharacter());
            actor.setThumbUrl(origCast.getThumbUrl());
            cast.add(actor);
        }

        for (MovieProducer origProducer : movieToEdit.getProducers()) {
            MovieProducer producer = new MovieProducer();
            producer.setName(origProducer.getName());
            producer.setRole(origProducer.getRole());
            producer.setThumbUrl(origProducer.getThumbUrl());
            producers.add(producer);
        }

        for (MediaGenres genre : movieToEdit.getGenres()) {
            genres.add(genre);
        }

        for (MovieTrailer trailer : movieToEdit.getTrailer()) {
            trailers.add(trailer);
        }

        for (String tag : movieToEdit.getTags()) {
            if (StringUtils.isNotBlank(tag)) {
                tags.add(tag);
            }
        }

        extrathumbs.addAll(movieToEdit.getExtraThumbs());
        extrafanarts.addAll(movieToEdit.getExtraFanarts());
        for (MovieSet movieSet : movieList.getSortedMovieSetList()) {
            cbMovieSet.addItem(movieSet);
            if (movieToEdit.getMovieSet() == movieSet) {
                cbMovieSet.setSelectedItem(movieSet);
            }
        }
    }
    // adjust columnn titles - we have to do it this way - thx to windowbuilder pro
    tableActors.getColumnModel().getColumn(0).setHeaderValue(BUNDLE.getString("metatag.name")); //$NON-NLS-1$
    tableActors.getColumnModel().getColumn(1).setHeaderValue(BUNDLE.getString("metatag.role")); //$NON-NLS-1$
    tableProducers.getColumnModel().getColumn(0).setHeaderValue(BUNDLE.getString("metatag.name")); //$NON-NLS-1$
    tableProducers.getColumnModel().getColumn(1).setHeaderValue(BUNDLE.getString("metatag.role")); //$NON-NLS-1$

    tableTrailer.getColumnModel().getColumn(0).setHeaderValue(BUNDLE.getString("metatag.nfo")); //$NON-NLS-1$
    tableTrailer.getColumnModel().getColumn(1).setHeaderValue(BUNDLE.getString("metatag.name")); //$NON-NLS-1$
    tableTrailer.getColumnModel().getColumn(2).setHeaderValue(BUNDLE.getString("metatag.source")); //$NON-NLS-1$
    tableTrailer.getColumnModel().getColumn(3).setHeaderValue(BUNDLE.getString("metatag.quality")); //$NON-NLS-1$
    tableTrailer.getColumnModel().getColumn(4).setHeaderValue(BUNDLE.getString("metatag.url")); //$NON-NLS-1$

    // adjust table columns
    tableTrailer.getColumnModel().getColumn(0).setMaxWidth(55);

    // implement listener to simulate button group
    tableTrailer.getModel().addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent arg0) {
            // click on the checkbox
            if (arg0.getColumn() == 0) {
                int row = arg0.getFirstRow();
                MovieTrailer changedTrailer = trailers.get(row);
                // if flag inNFO was changed, change all other trailers flags
                if (changedTrailer.getInNfo()) {
                    for (MovieTrailer trailer : trailers) {
                        if (trailer != changedTrailer) {
                            trailer.setInNfo(Boolean.FALSE);
                        }
                    }
                }
            }
        }
    });
}

From source file:org.tinymediamanager.ui.movies.MovieExtendedSearchPanel.java

/**
 * Instantiates a new movie extended search
 * //from w  w w. j  ava 2  s  .c  o  m
 * @param model
 *          the model
 */
public MovieExtendedSearchPanel(MovieSelectionModel model) {
    super();
    setOpaque(false);
    shadowAlpha = 100;
    arcs = new Dimension(10, 10);

    this.movieSelectionModel = model;
    Map<MovieSearchOptions, Object> savedSearchOptions = MovieModuleManager.MOVIE_SETTINGS.getUiFilters();

    // add a dummy mouse listener to prevent clicking through
    addMouseListener(new MouseAdapter() {
    });

    listCheckListener = new ListCheckListener() {
        @Override
        public void removeCheck(ListEvent event) {
            actionFilter.actionPerformed(new ActionEvent(event.getSource(), 1, "checked"));
        }

        @Override
        public void addCheck(ListEvent event) {
            actionFilter.actionPerformed(new ActionEvent(event.getSource(), 1, "checked"));
        }
    };

    setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
            FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC,
            ColumnSpec.decode("default:grow"), FormSpecs.UNRELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.UNRELATED_GAP_ROWSPEC, }));

    JLabel lblFilterBy = new JLabel(BUNDLE.getString("movieextendedsearch.filterby")); //$NON-NLS-1$
    setComponentFont(lblFilterBy);
    add(lblFilterBy, "2, 2, 3, 1");

    cbFilterNewMovies = new JCheckBox("");
    cbFilterNewMovies.setUI(CHECKBOX_UI); // $hide$
    cbFilterNewMovies.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.NEW_MOVIES));
    cbFilterNewMovies.setAction(actionFilter);
    add(cbFilterNewMovies, "2, 4");

    lblNewMovies = new JLabel(BUNDLE.getString("movieextendedsearch.newmovies")); //$NON-NLS-1$
    setComponentFont(lblNewMovies);
    add(lblNewMovies, "4, 4, right, default");

    cbFilterDuplicates = new JCheckBox("");
    cbFilterDuplicates.setUI(CHECKBOX_UI); // $hide$
    cbFilterDuplicates.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.DUPLICATES));
    cbFilterDuplicates.setAction(actionFilter);
    add(cbFilterDuplicates, "2, 5");

    JLabel lblShowDuplicates = new JLabel(BUNDLE.getString("movieextendedsearch.duplicates")); //$NON-NLS-1$
    setComponentFont(lblShowDuplicates);
    add(lblShowDuplicates, "4, 5, right, default");

    cbFilterWatched = new JCheckBox("");
    cbFilterWatched.setUI(CHECKBOX_UI); // $hide$
    cbFilterWatched.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.WATCHED));
    cbFilterWatched.setAction(actionFilter);
    add(cbFilterWatched, "2, 6");

    JLabel lblWatchedFlag = new JLabel(BUNDLE.getString("movieextendedsearch.watched")); //$NON-NLS-1$
    setComponentFont(lblWatchedFlag);
    add(lblWatchedFlag, "4, 6, right, default");

    cbWatched = new SmallComboBox(WatchedFlag.values());
    setComponentFont(cbWatched);
    cbWatched.setAction(actionFilter);
    add(cbWatched, "6, 6, fill, default");

    cbFilterGenre = new JCheckBox("");
    cbFilterGenre.setUI(CHECKBOX_UI); // $hide$
    cbFilterGenre.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.GENRE));
    cbFilterGenre.setAction(actionFilter);
    add(cbFilterGenre, "2, 7");

    JLabel lblGenre = new JLabel(BUNDLE.getString("movieextendedsearch.genre")); //$NON-NLS-1$
    setComponentFont(lblGenre);
    add(lblGenre, "4, 7, right, default");

    cbGenre = new SmallComboBox(MediaGenres.values());
    setComponentFont(cbGenre);
    cbGenre.setAction(actionFilter);
    add(cbGenre, "6, 7, fill, default");

    cbFilterCertification = new JCheckBox("");
    cbFilterCertification.setUI(CHECKBOX_UI); // $hide$
    cbFilterCertification.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.CERTIFICATION));
    cbFilterCertification.setAction(actionFilter);
    add(cbFilterCertification, "2, 8");

    lblCertification = new JLabel(BUNDLE.getString("metatag.certification")); //$NON-NLS-1$
    setComponentFont(lblCertification);
    add(lblCertification, "4, 8, right, default");

    cbCertification = new SmallComboBox();
    setComponentFont(cbCertification);
    cbCertification.setAction(actionFilter);
    add(cbCertification, "6, 8, fill, default");

    cbFilterYear = new JCheckBox("");
    cbFilterYear.setUI(CHECKBOX_UI); // $hide$
    cbFilterYear.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.YEAR));
    cbFilterYear.setAction(actionFilter);
    add(cbFilterYear, "2, 9");

    lblYear = new JLabel(BUNDLE.getString("metatag.year")); //$NON-NLS-1$
    setComponentFont(lblYear);
    add(lblYear, "4, 9, right, default");

    int year = Calendar.getInstance().get(Calendar.YEAR);
    spYear = new JSpinner();
    setComponentFont(spYear);
    spYear.setUI(new SmallSpinnerUI());// $hide$
    spYear.setModel(new SpinnerNumberModel(year, 0, 3000, 1));
    spYear.setEditor(new JSpinner.NumberEditor(spYear, "#"));
    spYear.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            actionFilter.actionPerformed(null);
        }
    });
    add(spYear, "6, 9");

    cbFilterCast = new JCheckBox("");
    cbFilterCast.setUI(CHECKBOX_UI); // $hide$
    cbFilterCast.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.CAST));
    cbFilterCast.setAction(actionFilter);
    add(cbFilterCast, "2, 10");

    JLabel lblCastMember = new JLabel(BUNDLE.getString("movieextendedsearch.cast")); //$NON-NLS-1$
    setComponentFont(lblCastMember);
    add(lblCastMember, "4, 10, right, default");

    tfCastMember = new JTextField();
    setComponentFont(tfCastMember);
    tfCastMember.setBorder(new SmallTextFieldBorder());
    add(tfCastMember, "6, 10, fill, default");
    tfCastMember.setColumns(10);
    tfCastMember.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(DocumentEvent e) {
            actionFilter.actionPerformed(null);
        }

        public void insertUpdate(DocumentEvent e) {
            actionFilter.actionPerformed(null);
        }

        public void removeUpdate(DocumentEvent e) {
            actionFilter.actionPerformed(null);
        }
    });

    cbFilterTag = new JCheckBox("");
    cbFilterTag.setUI(CHECKBOX_UI); // $hide$
    cbFilterTag.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.TAG));
    cbFilterTag.setAction(actionFilter);
    add(cbFilterTag, "2, 11");

    JLabel lblTag = new JLabel(BUNDLE.getString("movieextendedsearch.tag")); //$NON-NLS-1$
    setComponentFont(lblTag);
    add(lblTag, "4, 11, right, default");

    cbTag = new SmallCheckComboBox();
    cbTag.setTextFor(CheckComboBox.NONE, BUNDLE.getString("movieextendedsearch.tags.selected.none")); //$NON-NLS-1$
    cbTag.setTextFor(CheckComboBox.MULTIPLE, BUNDLE.getString("movieextendedsearch.tags.selected.multiple")); //$NON-NLS-1$
    cbTag.setTextFor(CheckComboBox.ALL, BUNDLE.getString("movieextendedsearch.tags.selected.all")); //$NON-NLS-1$
    cbTag.getModel().addListCheckListener(listCheckListener);
    add(cbTag, "6, 11, fill, default");

    cbFilterMovieset = new JCheckBox("");
    cbFilterMovieset.setUI(CHECKBOX_UI); // $hide$
    cbFilterMovieset.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.MOVIESET));
    cbFilterMovieset.setAction(actionFilter);
    add(cbFilterMovieset, "2, 12");

    JLabel lblMoviesInMovieset = new JLabel(BUNDLE.getString("movieextendedsearch.movieset")); //$NON-NLS-1$
    setComponentFont(lblMoviesInMovieset);
    add(lblMoviesInMovieset, "4, 12, right, default");

    cbMovieset = new SmallComboBox(MovieInMovieSet.values());
    setComponentFont(cbMovieset);
    cbMovieset.setAction(actionFilter);
    add(cbMovieset, "6, 12, fill, default");

    cbFilterVideoFormat = new JCheckBox("");
    cbFilterVideoFormat.setUI(CHECKBOX_UI); // $hide$
    cbFilterVideoFormat.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.VIDEO_FORMAT));
    cbFilterVideoFormat.setAction(actionFilter);
    add(cbFilterVideoFormat, "2, 13");

    JLabel lblVideoFormat = new JLabel(BUNDLE.getString("metatag.resolution")); //$NON-NLS-1$
    setComponentFont(lblVideoFormat);
    add(lblVideoFormat, "4, 13, right, default");

    cbVideoFormat = new SmallComboBox(getVideoFormats());
    setComponentFont(cbVideoFormat);
    cbVideoFormat.setAction(actionFilter);
    add(cbVideoFormat, "6, 13, fill, default");

    cbFilterVideoCodec = new JCheckBox("");
    cbFilterVideoCodec.setUI(CHECKBOX_UI); // $hide$
    cbFilterVideoCodec.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.VIDEO_CODEC));
    cbFilterVideoCodec.setAction(actionFilter);
    add(cbFilterVideoCodec, "2, 14");

    JLabel lblVideoCodec = new JLabel(BUNDLE.getString("metatag.videocodec")); //$NON-NLS-1$
    setComponentFont(lblVideoCodec);
    add(lblVideoCodec, "4, 14, right, default");

    cbVideoCodec = new SmallComboBox();
    setComponentFont(cbVideoCodec);
    cbVideoCodec.setAction(actionFilter);
    add(cbVideoCodec, "6, 14, fill, default");

    cbFilterVideo3D = new JCheckBox("");
    cbFilterVideo3D.setUI(CHECKBOX_UI); // $hide$
    cbFilterVideo3D.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.VIDEO_3D));
    cbFilterVideo3D.addActionListener(actionFilter);
    add(cbFilterVideo3D, "2, 15");

    JLabel lblVideo3D = new JLabel(BUNDLE.getString("metatag.3d")); //$NON-NLS-1$
    setComponentFont(lblVideo3D);
    add(lblVideo3D, "4, 15, right, default");

    cbFilterAudioCodec = new JCheckBox("");
    cbFilterAudioCodec.setUI(CHECKBOX_UI); // $hide$
    cbFilterAudioCodec.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.AUDIO_CODEC));
    cbFilterAudioCodec.setAction(actionFilter);
    add(cbFilterAudioCodec, "2, 16");

    JLabel lblAudioCodec = new JLabel(BUNDLE.getString("metatag.audiocodec")); //$NON-NLS-1$
    setComponentFont(lblAudioCodec);
    add(lblAudioCodec, "4, 16, right, default");

    cbAudioCodec = new SmallComboBox();
    setComponentFont(cbAudioCodec);
    cbAudioCodec.setAction(actionFilter);
    add(cbAudioCodec, "6, 16, fill, default");

    cbFilterDatasource = new JCheckBox("");
    cbFilterDatasource.setUI(CHECKBOX_UI); // $hide$
    cbFilterDatasource.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.DATASOURCE));
    cbFilterDatasource.setAction(actionFilter);
    add(cbFilterDatasource, "2, 17");

    JLabel lblDatasource = new JLabel(BUNDLE.getString("metatag.datasource")); //$NON-NLS-1$
    setComponentFont(lblDatasource);
    add(lblDatasource, "4, 17, right, default");

    cbDatasource = new SmallCheckComboBox();
    cbDatasource.setTextFor(CheckComboBox.NONE, BUNDLE.getString("checkcombobox.selected.none")); //$NON-NLS-1$
    cbDatasource.setTextFor(CheckComboBox.MULTIPLE, BUNDLE.getString("checkcombobox.selected.multiple")); //$NON-NLS-1$
    cbDatasource.setTextFor(CheckComboBox.ALL, BUNDLE.getString("checkcombobox.selected.all")); //$NON-NLS-1$
    cbDatasource.getModel().addListCheckListener(listCheckListener);
    add(cbDatasource, "6, 17, fill, default");

    cbFilterMediaSource = new JCheckBox("");
    cbFilterMediaSource.setUI(CHECKBOX_UI); // $hide$
    cbFilterMediaSource.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.MEDIA_SOURCE));
    cbFilterMediaSource.addActionListener(actionFilter);
    add(cbFilterMediaSource, "2, 18");

    JLabel lblMediaSource = new JLabel(BUNDLE.getString("metatag.source")); //$NON-NLS-1$
    setComponentFont(lblMediaSource);
    add(lblMediaSource, "4, 18, right, default");

    cbMediaSource = new SmallComboBox(MediaSource.values());
    setComponentFont(cbMediaSource);
    cbMediaSource.setAction(actionFilter);
    add(cbMediaSource, "6, 18, fill, default");

    cbFilterMissingMetadata = new JCheckBox("");
    cbFilterMissingMetadata.setUI(CHECKBOX_UI); // $hide$
    cbFilterMissingMetadata.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.MISSING_METADATA));
    cbFilterMissingMetadata.setAction(actionFilter);
    add(cbFilterMissingMetadata, "2, 19");

    JLabel lblMissingMetadata = new JLabel(BUNDLE.getString("movieextendedsearch.missingmetadata")); //$NON-NLS-1$
    setComponentFont(lblMissingMetadata);
    add(lblMissingMetadata, "4, 19, right, default");

    cbFilterMissingArtwork = new JCheckBox("");
    cbFilterMissingArtwork.setUI(CHECKBOX_UI); // $hide$
    cbFilterMissingArtwork.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.MISSING_ARTWORK));
    cbFilterMissingArtwork.setAction(actionFilter);
    add(cbFilterMissingArtwork, "2, 20");

    JLabel lblMissingArtwork = new JLabel(BUNDLE.getString("movieextendedsearch.missingartwork")); //$NON-NLS-1$
    setComponentFont(lblMissingArtwork);
    add(lblMissingArtwork, "4, 20, right, default");

    cbFilterMissingSubtitles = new JCheckBox("");
    cbFilterMissingSubtitles.setUI(CHECKBOX_UI); // $hide$
    cbFilterMissingSubtitles.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.MISSING_SUBTITLES));
    cbFilterMissingSubtitles.setAction(actionFilter);
    add(cbFilterMissingSubtitles, "2, 21");

    JLabel lblMissingSubtitles = new JLabel(BUNDLE.getString("movieextendedsearch.missingsubtitles")); //$NON-NLS-1$
    setComponentFont(lblMissingSubtitles);
    add(lblMissingSubtitles, "4, 21, right, default");

    cbFilterOffline = new JCheckBox("");
    cbFilterOffline.setUI(CHECKBOX_UI); // $hide$
    cbFilterOffline.setSelected(savedSearchOptions.containsKey(MovieSearchOptions.OFFLINE));
    cbFilterOffline.setAction(actionFilter);
    add(cbFilterOffline, "2, 22");

    lblOffline = new JLabel(BUNDLE.getString("movieextendedsearch.offline")); //$NON-NLS-1$
    setComponentFont(lblOffline);
    add(lblOffline, "4, 22, right, default");

    cbOffline = new SmallComboBox(OfflineMovie.values());
    cbOffline.setAction(actionFilter);
    add(cbOffline, "6, 22, fill, default");

    JSeparator separator = new JSeparator();
    add(separator, "2, 24, 5, 1");

    JLabel lblSortBy = new JLabel(BUNDLE.getString("movieextendedsearch.sortby")); //$NON-NLS-1$
    setComponentFont(lblSortBy);
    add(lblSortBy, "2, 26, 3, 1");

    cbSortColumn = new SmallComboBox(SortColumn.values());
    setComponentFont(cbSortColumn);
    cbSortColumn.setAction(actionSort);
    add(cbSortColumn, "2, 28, 3, 1, fill, default");

    cbSortOrder = new SmallComboBox(SortOrder.values());
    setComponentFont(cbSortOrder);
    cbSortOrder.setAction(actionSort);
    add(cbSortOrder, "6, 28, fill, default");

    PropertyChangeListener propertyChangeListener = new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getSource() instanceof MovieList && "tag".equals(evt.getPropertyName())) {
                buildAndInstallTagsArray();
            }
            if (evt.getSource() instanceof MovieList && "videoCodec".equals(evt.getPropertyName())) {
                buildAndInstallCodecArray();
            }
            if (evt.getSource() instanceof MovieList && "audioCodec".equals(evt.getPropertyName())) {
                buildAndInstallCodecArray();
            }
            if (evt.getSource() instanceof MovieSettings && "movieDataSource".equals(evt.getPropertyName())) {
                buildAndInstallDatasourceArray();
            }
            if (evt.getSource() instanceof MovieList && "certification".equals(evt.getPropertyName())) {
                buildAndInstallCertificationArray();
            }
        }
    };
    movieList.addPropertyChangeListener(propertyChangeListener);
    MovieModuleManager.MOVIE_SETTINGS.addPropertyChangeListener(propertyChangeListener);
    buildAndInstallTagsArray();
    buildAndInstallCodecArray();
    buildAndInstallDatasourceArray();
    buildAndInstallCertificationArray();
}

From source file:org.tinymediamanager.ui.tvshows.dialogs.TvShowEditorDialog.java

/**
 * Instantiates a new tv show editor dialog.
 * /*from ww w.j  ava2s  .  c o m*/
 * @param tvShow
 *          the tv show
 * @param inQueue
 *          the in queue
 */
public TvShowEditorDialog(TvShow tvShow, boolean inQueue) {
    super(BUNDLE.getString("tvshow.edit"), "tvShowEditor"); //$NON-NLS-1$
    setBounds(5, 5, 950, 700);

    tvShowToEdit = tvShow;
    ids = MediaIdTable.convertIdMapToEventList(tvShowToEdit.getIds());

    getContentPane().setLayout(new BorderLayout());
    {
        JPanel panelPath = new JPanel();
        getContentPane().add(panelPath, BorderLayout.NORTH);
        panelPath.setLayout(new FormLayout(
                new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                        FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC,
                        FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, },
                new RowSpec[] { FormFactory.LINE_GAP_ROWSPEC, RowSpec.decode("15px"),
                        FormFactory.RELATED_GAP_ROWSPEC, }));

        JLabel lblTvShowPathT = new JLabel(BUNDLE.getString("metatag.path")); //$NON-NLS-1$
        panelPath.add(lblTvShowPathT, "2, 2, left, top");

        lvlTvShowPath = new JLabel("");
        TmmFontHelper.changeFont(lblTvShowPathT, 1.166, Font.BOLD);
        panelPath.add(lvlTvShowPath, "5, 2, left, top");
    }

    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.NORTH);
    tabbedPane.addTab(BUNDLE.getString("metatag.details"), details1Panel); //$NON-NLS-1$
    getContentPane().add(tabbedPane, BorderLayout.CENTER);

    details1Panel.setBorder(new EmptyBorder(5, 5, 5, 5));
    details1Panel.setLayout(new FormLayout(
            new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(40dlu;default)"),
                    FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("50px:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
                    FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("50px:grow"),
                    FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
                    ColumnSpec.decode("30dlu"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                    FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
                    FormSpecs.UNRELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
                    ColumnSpec.decode("250px:grow"), FormSpecs.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                    FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("15dlu:grow"), FormSpecs.RELATED_GAP_ROWSPEC,
                    RowSpec.decode("top:max(30dlu;default)"), FormSpecs.RELATED_GAP_ROWSPEC,
                    RowSpec.decode("20dlu:grow"), FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                    FormSpecs.LABEL_COMPONENT_GAP_ROWSPEC, RowSpec.decode("default:grow"),
                    FormSpecs.RELATED_GAP_ROWSPEC, RowSpec.decode("fill:30px:grow(2)"), }));

    {
        JLabel lblTitle = new JLabel(BUNDLE.getString("metatag.title")); //$NON-NLS-1$
        details1Panel.add(lblTitle, "2, 2, right, default");
    }
    {
        tfTitle = new JTextField();
        details1Panel.add(tfTitle, "4, 2, 15, 1, fill, default");
        tfTitle.setColumns(10);
    }
    {
        lblPoster = new ImageLabel();
        lblPoster.setAlternativeText(BUNDLE.getString("image.notfound.poster")); //$NON-NLS-1$
        lblPoster.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                ImageChooserDialog dialog = new ImageChooserDialog(tvShowToEdit.getIds(), ImageType.POSTER,
                        tvShowList.getAvailableArtworkScrapers(), lblPoster, null, null, MediaType.TV_SHOW);
                dialog.setLocationRelativeTo(MainWindow.getActiveInstance());
                dialog.setVisible(true);
            }
        });
        lblPoster.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        details1Panel.add(lblPoster, "22, 2, 3, 19, fill, fill");
    }
    {
        JLabel lblSortTitle = new JLabel(BUNDLE.getString("metatag.sorttitle")); //$NON-NLS-1$
        details1Panel.add(lblSortTitle, "2, 4, right, default");
    }
    {
        tfSorttitle = new JTextField();
        details1Panel.add(tfSorttitle, "4, 4, 15, 1, fill, default");
        tfSorttitle.setColumns(10);
    }
    {
        JLabel lblYear = new JLabel(BUNDLE.getString("metatag.year")); //$NON-NLS-1$
        details1Panel.add(lblYear, "2, 6, right, default");
    }
    {
        spYear = new YearSpinner();
        details1Panel.add(spYear, "4, 6, fill, top");
    }
    {
        JLabel lblpremiered = new JLabel(BUNDLE.getString("metatag.premiered")); //$NON-NLS-1$
        details1Panel.add(lblpremiered, "8, 6, right, default");
    }
    {
        dpPremiered = new DatePicker(tvShow.getFirstAired());
        details1Panel.add(dpPremiered, "10, 6, fill, default");
    }
    {
        JLabel lblRuntime = new JLabel(BUNDLE.getString("metatag.runtime")); //$NON-NLS-1$
        details1Panel.add(lblRuntime, "14, 6, right, default");
    }
    {
        spRuntime = new JSpinner();
        details1Panel.add(spRuntime, "16, 6, fill, default");
    }
    spRuntime.setValue(tvShow.getRuntime());

    {
        JLabel lblMin = new JLabel(BUNDLE.getString("metatag.minutes")); //$NON-NLS-1$
        details1Panel.add(lblMin, "18, 6");
    }
    {
        JLabel lblRating = new JLabel(BUNDLE.getString("metatag.rating")); //$NON-NLS-1$
        details1Panel.add(lblRating, "2, 8, right, default");
    }
    {
        spRating = new JSpinner();
        details1Panel.add(spRating, "4, 8");
    }
    spRating.setModel(new SpinnerNumberModel(tvShow.getRating(), 0.0, 10.0, 0.1));
    {
        {
            JLabel lblCertification = new JLabel(BUNDLE.getString("metatag.certification")); //$NON-NLS-1$
            details1Panel.add(lblCertification, "8, 8, right, default");
        }
    }
    cbCertification = new JComboBox();
    for (Certification cert : Certification
            .getCertificationsforCountry(TvShowModuleManager.SETTINGS.getCertificationCountry())) {
        cbCertification.addItem(cert);
    }
    details1Panel.add(cbCertification, "10, 8, fill, default");
    cbCertification.setSelectedItem(tvShow.getCertification());
    {
        JLabel lblStatus = new JLabel(BUNDLE.getString("metatag.status")); //$NON-NLS-1$
        details1Panel.add(lblStatus, "14, 8, right, default");
    }
    {
        cbStatus = new JComboBox(new String[] { "", "Continuing", "Ended" });
        details1Panel.add(cbStatus, "16, 8, 3, 1, fill, default");
    }
    cbStatus.setSelectedItem(tvShow.getStatus());
    {
        JLabel lblDateAdded = new JLabel(BUNDLE.getString("metatag.dateadded")); //$NON-NLS-1$
        details1Panel.add(lblDateAdded, "2, 10, right, default");
    }
    {
        spDateAdded = new JSpinner(new SpinnerDateModel());
        details1Panel.add(spDateAdded, "4, 10");
    }

    {
        JLabel lblIds = new JLabel("Ids");
        details1Panel.add(lblIds, "2, 12, right, default");
    }
    {
        JScrollPane scrollPaneIds = new JScrollPane();
        details1Panel.add(scrollPaneIds, "4, 12, 9, 5, fill, fill");
        {
            tableIds = new MediaIdTable(ids, ScraperType.TV_SHOW);
            scrollPaneIds.setViewportView(tableIds);
        }
    }
    {
        JButton btnAddId = new JButton("");
        btnAddId.setAction(new AddIdAction());
        btnAddId.setIcon(IconManager.LIST_ADD);
        btnAddId.setMargin(new Insets(2, 2, 2, 2));
        details1Panel.add(btnAddId, "2, 14, right, top");
    }
    {
        JButton btnRemoveId = new JButton("RemoveId");
        btnRemoveId.setAction(new RemoveIdAction());
        btnRemoveId.setIcon(IconManager.LIST_REMOVE);
        btnRemoveId.setMargin(new Insets(2, 2, 2, 2));
        details1Panel.add(btnRemoveId, "2, 16, right, top");
    }
    {
        JLabel lblPlot = new JLabel(BUNDLE.getString("metatag.plot")); //$NON-NLS-1$
        details1Panel.add(lblPlot, "2, 18, right, top");
    }
    {
        JScrollPane scrollPanePlot = new JScrollPane();
        details1Panel.add(scrollPanePlot, "4, 18, 15, 3, fill, fill");
        {
            tpPlot = new JTextPane();
            scrollPanePlot.setViewportView(tpPlot);
        }
    }
    {
        JLabel lblStudio = new JLabel(BUNDLE.getString("metatag.studio")); //$NON-NLS-1$
        details1Panel.add(lblStudio, "2, 22, right, top");
    }
    {
        tfStudio = new JTextField();
        details1Panel.add(tfStudio, "4, 22, 15, 1");
    }

    /**
     * DetailsPanel 2
     */
    tabbedPane.addTab(BUNDLE.getString("metatag.details2"), details2Panel); //$NON-NLS-1$
    details2Panel.setBorder(new EmptyBorder(5, 5, 5, 5));
    details2Panel.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("max(40dlu;default)"),
                    FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("100px:grow(2)"),
                    FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                    FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("100px:grow"),
                    FormFactory.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("fill:30px:grow"),
                    FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"),
                    FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow(2)"), }));
    {
        JLabel lblActors = new JLabel(BUNDLE.getString("metatag.actors")); //$NON-NLS-1$
        details2Panel.add(lblActors, "2, 2, right, default");
    }
    {
        JScrollPane scrollPane = new JScrollPane();
        details2Panel.add(scrollPane, "4, 2, 1, 7");
        {
            tableActors = new JTable();
            tableActors.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
            scrollPane.setViewportView(tableActors);
        }
    }
    {
        JLabel lblGenres = new JLabel(BUNDLE.getString("metatag.genre")); //$NON-NLS-1$
        details2Panel.add(lblGenres, "6, 2");
    }
    {
        JButton btnAddActor = new JButton("Add Actor");
        btnAddActor.setMargin(new Insets(2, 2, 2, 2));
        btnAddActor.setAction(new AddActorAction());
        btnAddActor.setIcon(IconManager.LIST_ADD);
        details2Panel.add(btnAddActor, "2, 4, right, top");
    }
    {
        JScrollPane scrollPaneGenres = new JScrollPane();
        details2Panel.add(scrollPaneGenres, "8, 2, 1, 5");
        {
            listGenres = new JList();
            scrollPaneGenres.setViewportView(listGenres);
        }
    }
    {
        JButton btnAddGenre = new JButton("");
        btnAddGenre.setAction(new AddGenreAction());
        btnAddGenre.setIcon(IconManager.LIST_ADD);
        btnAddGenre.setMargin(new Insets(2, 2, 2, 2));
        details2Panel.add(btnAddGenre, "6, 4, right, top");
    }
    {
        JButton btnRemoveActor = new JButton(BUNDLE.getString("cast.actor.remove")); //$NON-NLS-1$
        btnRemoveActor.setMargin(new Insets(2, 2, 2, 2));
        btnRemoveActor.setAction(new RemoveActorAction());
        btnRemoveActor.setIcon(IconManager.LIST_REMOVE);
        details2Panel.add(btnRemoveActor, "2,6, right, top");
    }

    {
        JButton btnRemoveGenre = new JButton("");
        btnRemoveGenre.setAction(new RemoveGenreAction());
        btnRemoveGenre.setMargin(new Insets(2, 2, 2, 2));
        btnRemoveGenre.setIcon(IconManager.LIST_REMOVE);
        details2Panel.add(btnRemoveGenre, "6, 6, right, top");
    }
    {
        cbGenres = new AutocompleteComboBox(MediaGenres.values());
        cbGenres.setEditable(true);
        details2Panel.add(cbGenres, "8,8");
    }
    {
        JLabel lblTags = new JLabel(BUNDLE.getString("metatag.tags")); //$NON-NLS-1$
        details2Panel.add(lblTags, "2, 10, right, default");
    }
    {
        JScrollPane scrollPaneTags = new JScrollPane();
        details2Panel.add(scrollPaneTags, "4, 10, 1, 5");
        listTags = new JList();
        scrollPaneTags.setViewportView(listTags);
    }
    {
        JButton btnAddTag = new JButton("");
        btnAddTag.setAction(new AddTagAction());
        btnAddTag.setIcon(IconManager.LIST_ADD);
        btnAddTag.setMargin(new Insets(2, 2, 2, 2));
        details2Panel.add(btnAddTag, "2, 12, right, top");
    }
    {
        JButton btnRemoveTag = new JButton("");
        btnRemoveTag.setAction(new RemoveTagAction());
        btnRemoveTag.setIcon(IconManager.LIST_REMOVE);
        btnRemoveTag.setMargin(new Insets(2, 2, 2, 2));
        details2Panel.add(btnRemoveTag, "2, 14, right, top");
    }
    {
        cbTags = new AutocompleteComboBox(tvShowList.getTagsInTvShows().toArray());
        cbTags.setEditable(true);
        details2Panel.add(cbTags, "4, 16");
    }

    /**
     * extra artwork pane
     */
    {
        JPanel artworkPanel = new JPanel();
        tabbedPane.addTab(BUNDLE.getString("metatag.extraartwork"), null, artworkPanel, null); //$NON-NLS-1$
        artworkPanel.setLayout(new FormLayout(
                new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("250px:grow"),
                        FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("250px:grow"),
                        FormFactory.RELATED_GAP_COLSPEC, },
                new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("50px:grow(2)"),
                        FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                        FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("200px:grow(2)"),
                        FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), }));
        {
            JLabel lblLogoT = new JLabel(BUNDLE.getString("mediafiletype.logo")); //$NON-NLS-1$
            artworkPanel.add(lblLogoT, "2, 2");
        }
        {
            lblLogo = new ImageLabel();
            lblLogo.setAlternativeText(BUNDLE.getString("image.notfound.logo")); //$NON-NLS-1$
            lblLogo.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    ImageChooserDialog dialog = new ImageChooserDialog(tvShowToEdit.getIds(), ImageType.LOGO,
                            tvShowList.getAvailableArtworkScrapers(), lblLogo, null, null, MediaType.TV_SHOW);
                    dialog.setLocationRelativeTo(MainWindow.getActiveInstance());
                    dialog.setVisible(true);
                }
            });
            {
                final JLabel lblClearlogoT = new JLabel(BUNDLE.getString("mediafiletype.clearlogo")); //$NON-NLS-1$
                artworkPanel.add(lblClearlogoT, "4, 2");
            }
            lblLogo.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            artworkPanel.add(lblLogo, "2, 4, fill, fill");
        }
        {
            lblClearlogo = new ImageLabel();
            lblClearlogo.setAlternativeText(BUNDLE.getString("image.notfound.clearlogo")); //$NON-NLS-1$
            lblClearlogo.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    ImageChooserDialog dialog = new ImageChooserDialog(tvShowToEdit.getIds(),
                            ImageType.CLEARLOGO, tvShowList.getAvailableArtworkScrapers(), lblClearlogo, null,
                            null, MediaType.TV_SHOW);
                    dialog.setLocationRelativeTo(MainWindow.getActiveInstance());
                    dialog.setVisible(true);
                }
            });
            lblClearlogo.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            artworkPanel.add(lblClearlogo, "4, 4, fill, fill");
        }
        {
            JLabel lblClearartT = new JLabel(BUNDLE.getString("mediafiletype.clearart")); //$NON-NLS-1$
            artworkPanel.add(lblClearartT, "2, 6");
        }
        {
            lblClearart = new ImageLabel();
            lblClearart.setAlternativeText(BUNDLE.getString("image.notfound.clearart")); //$NON-NLS-1$
            lblClearart.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    ImageChooserDialog dialog = new ImageChooserDialog(tvShowToEdit.getIds(),
                            ImageType.CLEARART, tvShowList.getAvailableArtworkScrapers(), lblClearart, null,
                            null, MediaType.TV_SHOW);
                    dialog.setLocationRelativeTo(MainWindow.getActiveInstance());
                    dialog.setVisible(true);
                }
            });
            lblClearart.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            artworkPanel.add(lblClearart, "2, 8, fill, fill");
        }
        {
            JLabel lblThumbT = new JLabel(BUNDLE.getString("mediafiletype.thumb")); //$NON-NLS-1$
            artworkPanel.add(lblThumbT, "4, 6");
        }
        {
            lblThumb = new ImageLabel();
            lblThumb.setAlternativeText(BUNDLE.getString("image.notfound.thumb")); //$NON-NLS-1$
            lblThumb.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    ImageChooserDialog dialog = new ImageChooserDialog(tvShowToEdit.getIds(), ImageType.THUMB,
                            tvShowList.getAvailableArtworkScrapers(), lblThumb, null, null, MediaType.TV_SHOW);
                    dialog.setLocationRelativeTo(MainWindow.getActiveInstance());
                    dialog.setVisible(true);
                }
            });
            lblThumb.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            artworkPanel.add(lblThumb, "4, 8, fill, fill");
        }

    }
    tabbedPane.addTab(BUNDLE.getString("metatag.episodes"), episodesPanel); //$NON-NLS-1$
    episodesPanel.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                    FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                    FormFactory.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("default:grow"), }));
    {
        JButton btnCloneEpisode = new JButton("");
        btnCloneEpisode.setAction(new CloneEpisodeAction());
        episodesPanel.add(btnCloneEpisode, "2, 2");
    }
    {
        JScrollPane scrollPaneEpisodes = new JScrollPane();
        episodesPanel.add(scrollPaneEpisodes, "4, 2, 1, 3, fill, fill");
        {
            tableEpisodes = new JTable();
            scrollPaneEpisodes.setViewportView(tableEpisodes);
        }
    }
    {
        JButton btnRemoveEpisode = new JButton("");
        btnRemoveEpisode.setAction(new RemoveEpisodeAction());
        btnRemoveEpisode.setIcon(IconManager.LIST_REMOVE);
        episodesPanel.add(btnRemoveEpisode, "2, 4, default, top");
    }

    /**
     * Button pane
     */
    {
        JPanel bottomPane = new JPanel();
        getContentPane().add(bottomPane, BorderLayout.SOUTH);
        bottomPane.setLayout(new FormLayout(
                new ColumnSpec[] { ColumnSpec.decode("371px:grow"), FormFactory.DEFAULT_COLSPEC,
                        FormFactory.RELATED_GAP_COLSPEC, },
                new RowSpec[] { FormFactory.LINE_GAP_ROWSPEC, RowSpec.decode("25px"),
                        FormFactory.RELATED_GAP_ROWSPEC, }));

        JPanel buttonPane = new JPanel();
        bottomPane.add(buttonPane, "2, 2, left, top");
        EqualsLayout layout = new EqualsLayout(5);
        layout.setMinWidth(100);
        buttonPane.setLayout(layout);
        {
            JButton okButton = new JButton(BUNDLE.getString("Button.ok")); //$NON-NLS-1$
            buttonPane.add(okButton);
            okButton.setAction(new OKAction());
            okButton.setActionCommand("OK");
            getRootPane().setDefaultButton(okButton);
        }
        {
            JButton cancelButton = new JButton(BUNDLE.getString("Button.cancel")); //$NON-NLS-1$
            buttonPane.add(cancelButton);
            cancelButton.setAction(new CancelAction());
            cancelButton.setActionCommand("Cancel");
        }
        if (inQueue) {
            JButton btnAbort = new JButton(BUNDLE.getString("Button.abortqueue")); //$NON-NLS-1$
            btnAbort.setAction(new AbortAction());
            buttonPane.add(btnAbort);
        }

    }

    initDataBindings();

    {
        lvlTvShowPath.setText(tvShow.getPath());
        tfTitle.setText(tvShow.getTitle());
        tfSorttitle.setText(tvShow.getSortTitle());
        tpPlot.setText(tvShow.getPlot());
        lblPoster.setImagePath(tvShow.getArtworkFilename(MediaFileType.POSTER));
        lblThumb.setImagePath(tvShowToEdit.getArtworkFilename(MediaFileType.THUMB));
        lblLogo.setImagePath(tvShowToEdit.getArtworkFilename(MediaFileType.LOGO));
        lblClearlogo.setImagePath(tvShowToEdit.getArtworkFilename(MediaFileType.CLEARLOGO));
        lblClearart.setImagePath(tvShowToEdit.getArtworkFilename(MediaFileType.CLEARART));
        tfStudio.setText(tvShow.getProductionCompany());

        int year = 0;
        try {
            year = Integer.parseInt(tvShow.getYear());
        } catch (Exception e) {
        }
        spYear.setValue(year);
        spDateAdded.setValue(tvShow.getDateAdded());

        for (TvShowActor origCast : tvShow.getActors()) {
            TvShowActor actor = new TvShowActor();
            actor.setName(origCast.getName());
            actor.setCharacter(origCast.getCharacter());
            actor.setThumbUrl(origCast.getThumbUrl());
            actors.add(actor);
        }

        for (MediaGenres genre : tvShow.getGenres()) {
            genres.add(genre);
        }

        // for (MediaTrailer trailer : tvShow.getTrailers()) {
        // trailers.add(trailer);
        // }

        for (String tag : tvShowToEdit.getTags()) {
            tags.add(tag);
        }

        List<TvShowEpisode> epl = new ArrayList<>(tvShowToEdit.getEpisodes());
        // custom sort per filename (just this time)
        // for unknown EPs (-1/-1) this is extremely useful to sort like on filesystem
        // and for already renamed ones, it makes no difference
        Collections.sort(epl, new Comparator<TvShowEpisode>() {
            public int compare(TvShowEpisode s1, TvShowEpisode s2) {
                return s1.getMediaFiles(MediaFileType.VIDEO).get(0).getFile()
                        .compareTo(s2.getMediaFiles(MediaFileType.VIDEO).get(0).getFile());
            }
        });

        for (TvShowEpisode episode : epl) {
            TvShowEpisodeEditorContainer container = new TvShowEpisodeEditorContainer();
            container.tvShowEpisode = episode;
            container.dvdOrder = episode.isDvdOrder();
            container.season = episode.getSeason();
            container.episode = episode.getEpisode();
            episodes.add(container);
        }

        if (((DefaultComboBoxModel) cbCertification.getModel()).getIndexOf(tvShow.getCertification()) == -1) {
            cbCertification.addItem(tvShow.getCertification());
        }

    }
    lblBanner = new ImageLabel();
    lblBanner.setAlternativeText(BUNDLE.getString("image.notfound.banner")); //$NON-NLS-1$
    lblBanner.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    lblBanner.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            ImageChooserDialog dialog = new ImageChooserDialog(tvShowToEdit.getIds(), ImageType.BANNER,
                    tvShowList.getAvailableArtworkScrapers(), lblBanner, null, null, MediaType.TV_SHOW);
            dialog.setLocationRelativeTo(MainWindow.getActiveInstance());
            dialog.setVisible(true);
        }
    });
    details1Panel.add(lblBanner, "4, 24, 15, 3, fill, fill");
    lblBanner.setImagePath(tvShow.getArtworkFilename(MediaFileType.BANNER));
    {
        // JLabel lblFanart = new JLabel("");
        lblFanart = new ImageLabel();
        lblFanart.setAlternativeText(BUNDLE.getString("image.notfound.fanart")); //$NON-NLS-1$
        lblFanart.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        lblFanart.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                ImageChooserDialog dialog = new ImageChooserDialog(tvShowToEdit.getIds(), ImageType.FANART,
                        tvShowList.getAvailableArtworkScrapers(), lblFanart, null, null, MediaType.TV_SHOW);
                dialog.setLocationRelativeTo(MainWindow.getActiveInstance());
                dialog.setVisible(true);
            }
        });
        details1Panel.add(lblFanart, "22, 22, 3, 5, fill, fill");
    }
    lblFanart.setImagePath(tvShow.getArtworkFilename(MediaFileType.FANART));

    // adjust columnn titles - we have to do it this way - thx to windowbuilder pro
    tableActors.getColumnModel().getColumn(0).setHeaderValue(BUNDLE.getString("metatag.name")); //$NON-NLS-1$
    tableActors.getColumnModel().getColumn(1).setHeaderValue(BUNDLE.getString("metatag.role")); //$NON-NLS-1$

    tableEpisodes.getColumnModel().getColumn(0).setHeaderValue(BUNDLE.getString("metatag.title")); //$NON-NLS-1$
    tableEpisodes.getColumnModel().getColumn(1).setHeaderValue(BUNDLE.getString("metatag.filename")); //$NON-NLS-1$
    tableEpisodes.getColumnModel().getColumn(2).setHeaderValue(BUNDLE.getString("metatag.season")); //$NON-NLS-1$
    tableEpisodes.getColumnModel().getColumn(3).setHeaderValue(BUNDLE.getString("metatag.episode")); //$NON-NLS-1$
    tableEpisodes.getColumnModel().getColumn(4).setHeaderValue(BUNDLE.getString("metatag.dvdorder")); //$NON-NLS-1$
    tableEpisodes.getColumnModel().getColumn(2).setMaxWidth(150);
    tableEpisodes.getColumnModel().getColumn(3).setMaxWidth(150);
    tableEpisodes.getColumnModel().getColumn(2).setCellEditor(new TableSpinnerEditor());
    tableEpisodes.getColumnModel().getColumn(3).setCellEditor(new TableSpinnerEditor());

    // adjust table columns
    TableColumnResizer.adjustColumnPreferredWidths(tableActors, 6);
    // TableColumnResizer.adjustColumnPreferredWidths(tableTrailer, 6);
    TableColumnResizer.adjustColumnPreferredWidths(tableEpisodes, 6);
}

From source file:org.tinymediamanager.ui.tvshows.dialogs.TvShowEpisodeEditorDialog.java

/**
 * Instantiates a new tv show episode scrape dialog.
 * /*from  w  w  w.  j a va2 s.  co m*/
 * @param episode
 *          the episode
 * @param inQueue
 *          the in queue
 */
public TvShowEpisodeEditorDialog(TvShowEpisode episode, boolean inQueue) {
    super(BUNDLE.getString("tvshowepisode.scrape"), "tvShowEpisodeScraper"); //$NON-NLS-1$
    setBounds(5, 5, 964, 632);

    for (MediaFile mf : episode.getMediaFiles()) {
        mediaFiles.add(new MediaFile(mf));
    }

    this.episodeToEdit = episode;
    getContentPane().setLayout(new BorderLayout());

    {
        JPanel panelFilename = new JPanel();
        getContentPane().add(panelFilename, BorderLayout.NORTH);
        panelFilename.setLayout(new FormLayout(
                new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                        FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC,
                        FormFactory.DEFAULT_COLSPEC, FormFactory.RELATED_GAP_COLSPEC, },
                new RowSpec[] { FormFactory.LINE_GAP_ROWSPEC, RowSpec.decode("15px"),
                        FormFactory.RELATED_GAP_ROWSPEC, }));

        JLabel lblFilenameT = new JLabel(BUNDLE.getString("metatag.path")); //$NON-NLS-1$
        panelFilename.add(lblFilenameT, "2, 2, left, top");

        lblFilename = new JLabel("");
        TmmFontHelper.changeFont(lblFilename, 1.166, Font.BOLD);
        panelFilename.add(lblFilename, "5, 2, left, top");
    }

    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.NORTH);
    getContentPane().add(tabbedPane, BorderLayout.CENTER);

    /**
     * DetailsPanel
     */
    {
        JPanel detailsPanel = new JPanel();
        tabbedPane.addTab(BUNDLE.getString("metatag.details"), detailsPanel); //$NON-NLS-1$
        detailsPanel.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,
                FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("40dlu:grow"),
                FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("7dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC,
                FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("20dlu"),
                FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("30dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC,
                FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("7dlu:grow"), FormSpecs.RELATED_GAP_COLSPEC,
                FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("100dlu:grow"),
                FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, },
                new RowSpec[] { FormSpecs.LINE_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, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                        RowSpec.decode("35dlu:grow"), 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, RowSpec.decode("default:grow"),
                        FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.RELATED_GAP_ROWSPEC, }));

        JLabel lblTitle = new JLabel(BUNDLE.getString("metatag.title")); //$NON-NLS-1$
        detailsPanel.add(lblTitle, "2, 4, right, default");

        tfTitle = new JTextField();
        detailsPanel.add(tfTitle, "4, 4, 19, 1");
        tfTitle.setColumns(10);

        JLabel lblSeason = new JLabel(BUNDLE.getString("metatag.season")); //$NON-NLS-1$
        detailsPanel.add(lblSeason, "2, 6, right, default");

        spSeason = new JSpinner();
        detailsPanel.add(spSeason, "4, 6");

        JLabel lblEpisode = new JLabel(BUNDLE.getString("metatag.episode")); //$NON-NLS-1$
        detailsPanel.add(lblEpisode, "8, 6, right, default");

        spEpisode = new JSpinner();
        detailsPanel.add(spEpisode, "10, 6");

        JLabel lblDvdSeason = new JLabel(BUNDLE.getString("metatag.dvdseason")); //$NON-NLS-1$
        detailsPanel.add(lblDvdSeason, "2, 8, right, default");

        spDvdSeason = new JSpinner();
        detailsPanel.add(spDvdSeason, "4, 8");

        JLabel lblDvdEpisode = new JLabel(BUNDLE.getString("metatag.dvdepisode")); //$NON-NLS-1$
        detailsPanel.add(lblDvdEpisode, "8, 8, right, default");

        spDvdEpisode = new JSpinner();
        detailsPanel.add(spDvdEpisode, "10, 8");

        JLabel lblDvdOrder = new JLabel(BUNDLE.getString("metatag.dvdorder")); //$NON-NLS-1$
        detailsPanel.add(lblDvdOrder, "14, 8, right, default");

        cbDvdOrder = new JCheckBox("");
        detailsPanel.add(cbDvdOrder, "16, 8");
        cbDvdOrder.setSelected(episodeToEdit.isDvdOrder());

        JLabel lblDisplaySeason = new JLabel(BUNDLE.getString("metatag.displayseason")); //$NON-NLS-1$
        detailsPanel.add(lblDisplaySeason, "2, 10, right, default");

        spDisplaySeason = new JSpinner();
        detailsPanel.add(spDisplaySeason, "4, 10");

        JLabel lblDisplayEpisode = new JLabel(BUNDLE.getString("metatag.displayepisode")); //$NON-NLS-1$
        detailsPanel.add(lblDisplayEpisode, "8, 10, right, default");

        spDisplayEpisode = new JSpinner();
        detailsPanel.add(spDisplayEpisode, "10, 10");

        JLabel lblRating = new JLabel(BUNDLE.getString("metatag.rating")); //$NON-NLS-1$
        detailsPanel.add(lblRating, "2, 12, right, default");

        spRating = new JSpinner();
        detailsPanel.add(spRating, "4, 12");

        JLabel lblFirstAired = new JLabel(BUNDLE.getString("metatag.aired")); //$NON-NLS-1$
        detailsPanel.add(lblFirstAired, "8, 12, right, default");

        dpFirstAired = new DatePicker(episode.getFirstAired());
        detailsPanel.add(dpFirstAired, "10, 12, 3, 1, fill, default");

        JLabel lblWatched = new JLabel(BUNDLE.getString("metatag.watched")); //$NON-NLS-1$
        detailsPanel.add(lblWatched, "2, 14, right, default");

        chckbxWatched = new JCheckBox("");
        detailsPanel.add(chckbxWatched, "4, 14");

        JLabel lblDateAdded = new JLabel(BUNDLE.getString("metatag.dateadded")); //$NON-NLS-1$
        detailsPanel.add(lblDateAdded, "8, 14, right, default");

        spDateAdded = new JSpinner(new SpinnerDateModel());
        detailsPanel.add(spDateAdded, "10, 14, 3, 1, fill, default");

        JLabel lblMediasource = new JLabel(BUNDLE.getString("metatag.source")); //$NON-NLS-1$
        detailsPanel.add(lblMediasource, "2, 16, right, default");

        cbMediaSource = new JComboBox(MediaSource.values());
        detailsPanel.add(cbMediaSource, "4, 16, 4, 1, fill, default");

        JLabel lblPlot = new JLabel(BUNDLE.getString("metatag.plot")); //$NON-NLS-1$
        detailsPanel.add(lblPlot, "2, 18, right, top");

        JScrollPane scrollPane = new JScrollPane();
        detailsPanel.add(scrollPane, "4, 18, 13, 1, fill, fill");

        taPlot = new JTextArea();
        taPlot.setLineWrap(true);
        taPlot.setWrapStyleWord(true);
        scrollPane.setViewportView(taPlot);

        lblThumb = new ImageLabel();
        lblThumb.setAlternativeText(BUNDLE.getString("image.notfound.thumb")); //$NON-NLS-1$
        lblThumb.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                Path file = TmmUIHelper.selectFile(BUNDLE.getString("image.choose")); //$NON-NLS-1$
                if (file != null && Utils.isRegularFile(file)) {
                    String fileName = file.toAbsolutePath().toString();
                    lblThumb.setImageUrl("file:/" + fileName);
                }
            }
        });
        lblThumb.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        detailsPanel.add(lblThumb, "20, 6, 3, 13");

        JLabel lblDirector = new JLabel(BUNDLE.getString("metatag.director")); //$NON-NLS-1$
        detailsPanel.add(lblDirector, "2, 20, right, default");

        tfDirector = new JTextField();
        tfDirector.setText((String) null);
        tfDirector.setColumns(10);
        detailsPanel.add(tfDirector, "4, 20, 13, 1, fill, default");

        JLabel lblWriter = new JLabel(BUNDLE.getString("metatag.writer")); //$NON-NLS-1$
        detailsPanel.add(lblWriter, "2, 22, right, default");

        tfWriter = new JTextField();
        tfWriter.setText((String) null);
        tfWriter.setColumns(10);
        detailsPanel.add(tfWriter, "4, 22, 13, 1, fill, default");

        JLabel lblGuests = new JLabel(BUNDLE.getString("metatag.guests")); //$NON-NLS-1$
        detailsPanel.add(lblGuests, "2, 24, right, top");

        JScrollPane scrollPaneGuests = new JScrollPane();
        detailsPanel.add(scrollPaneGuests, "4, 24, 13, 7, fill, fill");

        tableGuests = new JTable();
        tableGuests.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);
        scrollPaneGuests.setViewportView(tableGuests);

        JLabel lblTags = new JLabel(BUNDLE.getString("metatag.tags")); //$NON-NLS-1$
        detailsPanel.add(lblTags, "20, 24, default, top");

        JScrollPane scrollPaneTags = new JScrollPane();
        detailsPanel.add(scrollPaneTags, "22, 24, 1, 5, fill, fill");

        listTags = new JList();
        scrollPaneTags.setViewportView(listTags);

        JButton btnAddActor = new JButton("");
        btnAddActor.setMargin(new Insets(2, 2, 2, 2));
        btnAddActor.setAction(new AddActorAction());
        btnAddActor.setIcon(IconManager.LIST_ADD);
        detailsPanel.add(btnAddActor, "2, 26, right, top");

        JButton btnAddTag = new JButton("");
        btnAddTag.setMargin(new Insets(2, 2, 2, 2));
        btnAddTag.setAction(new AddTagAction());
        btnAddTag.setIcon(IconManager.LIST_ADD);
        detailsPanel.add(btnAddTag, "20, 26, right, top");

        JButton btnRemoveActor = new JButton("");
        btnRemoveActor.setMargin(new Insets(2, 2, 2, 2));
        btnRemoveActor.setAction(new RemoveActorAction());
        btnRemoveActor.setIcon(IconManager.LIST_REMOVE);
        detailsPanel.add(btnRemoveActor, "2, 28, right, top");

        JButton btnRemoveTag = new JButton("");
        btnRemoveTag.setMargin(new Insets(2, 2, 2, 2));
        btnRemoveTag.setAction(new RemoveTagAction());
        btnRemoveTag.setIcon(IconManager.LIST_REMOVE);
        detailsPanel.add(btnRemoveTag, "20, 28, right, top");

        cbTags = new AutocompleteComboBox(tvShowList.getTagsInEpisodes().toArray());
        cbTags.setEditable(true);
        detailsPanel.add(cbTags, "22, 30, fill, default");
    }

    /**
     * Media Files panel
     */
    {
        mediaFilesPanel = new MediaFileEditorPanel(mediaFiles);
        tabbedPane.addTab(BUNDLE.getString("metatag.mediafiles"), null, mediaFilesPanel, null); //$NON-NLS-1$
    }

    {
        JPanel bottomPanel = new JPanel();
        getContentPane().add(bottomPanel, BorderLayout.SOUTH);

        bottomPanel.setLayout(new FormLayout(
                new ColumnSpec[] { FormFactory.LABEL_COMPONENT_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                        FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                        FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                        FormFactory.RELATED_GAP_COLSPEC, FormFactory.DEFAULT_COLSPEC,
                        FormFactory.RELATED_GAP_COLSPEC, },
                new RowSpec[] { FormFactory.LINE_GAP_ROWSPEC, RowSpec.decode("25px"),
                        FormFactory.RELATED_GAP_ROWSPEC, }));

        cbScraper = new MediaScraperComboBox(tvShowList.getAvailableMediaScrapers());
        MediaScraper defaultScraper = tvShowList.getDefaultMediaScraper();
        cbScraper.setSelectedItem(defaultScraper);
        bottomPanel.add(cbScraper, "2, 2, fill, default");

        JButton btnScrape = new JButton(BUNDLE.getString("Button.scrape")); //$NON-NLS-1$
        btnScrape.setPreferredSize(new Dimension(100, 23));
        btnScrape.setMaximumSize(new Dimension(0, 0));
        btnScrape.setMinimumSize(new Dimension(100, 23));
        btnScrape.setActionCommand("Scrape");
        btnScrape.addActionListener(this);
        bottomPanel.add(btnScrape, "4, 2, left, fill");

        JButton btnSearch = new JButton(BUNDLE.getString("tvshowepisodechooser.search")); //$NON-NLS-1$
        btnSearch.setActionCommand("Search");
        btnSearch.addActionListener(this);
        btnSearch.setIcon(IconManager.SEARCH);
        bottomPanel.add(btnSearch, "6, 2, left, fill");
        {
            JPanel buttonPane = new JPanel();
            bottomPanel.add(buttonPane, "8, 2, fill, fill");
            EqualsLayout layout = new EqualsLayout(5);
            layout.setMinWidth(100);
            buttonPane.setLayout(layout);
            JButton okButton = new JButton(BUNDLE.getString("Button.ok")); //$NON-NLS-1$
            okButton.setToolTipText(BUNDLE.getString("tvshow.change"));
            okButton.setIcon(IconManager.APPLY);
            buttonPane.add(okButton);
            okButton.setActionCommand("OK");
            okButton.addActionListener(this);

            JButton cancelButton = new JButton(BUNDLE.getString("Button.cancel")); //$NON-NLS-1$
            cancelButton.setToolTipText(BUNDLE.getString("edit.discard"));
            cancelButton.setIcon(IconManager.CANCEL);
            buttonPane.add(cancelButton);
            cancelButton.setActionCommand("Cancel");
            cancelButton.addActionListener(this);

            if (inQueue) {
                JButton abortButton = new JButton(BUNDLE.getString("Button.abortqueue")); //$NON-NLS-1$
                abortButton.setToolTipText(BUNDLE.getString("tvshow.edit.abortqueue.desc")); //$NON-NLS-1$
                abortButton.setIcon(IconManager.PROCESS_STOP);
                buttonPane.add(abortButton);
                abortButton.setActionCommand("Abort");
                abortButton.addActionListener(this);
            }
        }
    }

    initDataBindings();

    // fill data
    {
        MediaFile mediaFile = episodeToEdit.getMediaFiles().get(0);
        lblFilename.setText(mediaFile.getFileAsPath().toString());
        tfTitle.setText(episodeToEdit.getTitle());

        spSeason.setModel(new SpinnerNumberModel(episodeToEdit.getAiredSeason(), -1, Integer.MAX_VALUE, 1));
        spEpisode.setModel(new SpinnerNumberModel(episodeToEdit.getAiredEpisode(), -1, Integer.MAX_VALUE, 1));
        spDvdSeason.setModel(new SpinnerNumberModel(episodeToEdit.getDvdSeason(), -1, Integer.MAX_VALUE, 1));
        spDvdEpisode.setModel(new SpinnerNumberModel(episodeToEdit.getDvdEpisode(), -1, Integer.MAX_VALUE, 1));
        spDisplaySeason
                .setModel(new SpinnerNumberModel(episodeToEdit.getDisplaySeason(), -1, Integer.MAX_VALUE, 1));
        spDisplayEpisode
                .setModel(new SpinnerNumberModel(episodeToEdit.getDisplayEpisode(), -1, Integer.MAX_VALUE, 1));
        spDateAdded.setValue(episodeToEdit.getDateAdded());

        lblThumb.setImagePath(episodeToEdit.getArtworkFilename(MediaFileType.THUMB));
        spRating.setModel(new SpinnerNumberModel(episodeToEdit.getRating(), 0.0, 10.0, 0.1));
        spRating.addChangeListener(new ChangeListener() {
            @Override
            public void stateChanged(ChangeEvent e) {
                voteCount = 1;
            }
        });
        voteCount = episodeToEdit.getVotes();
        chckbxWatched.setSelected(episodeToEdit.isWatched());
        taPlot.setText(episodeToEdit.getPlot());
        taPlot.setCaretPosition(0);
        tfDirector.setText(episodeToEdit.getDirector());
        tfWriter.setText(episodeToEdit.getWriter());
        cbMediaSource.setSelectedItem(episodeToEdit.getMediaSource());

        for (TvShowActor origCast : episodeToEdit.getGuests()) {
            TvShowActor actor = new TvShowActor();
            actor.setName(origCast.getName());
            actor.setCharacter(origCast.getCharacter());
            actor.setThumbUrl(origCast.getThumbUrl());
            cast.add(actor);
        }

        for (String tag : episodeToEdit.getTags()) {
            tags.add(tag);
        }
    }

    // adjust table columns
    tableGuests.getColumnModel().getColumn(0).setHeaderValue(BUNDLE.getString("metatag.name")); //$NON-NLS-1$
    tableGuests.getColumnModel().getColumn(1).setHeaderValue(BUNDLE.getString("metatag.role")); //$NON-NLS-1$

}

From source file:pcgen.gui2.dialog.PostLevelUpDialog.java

private void initComponents() {
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    Container pane = getContentPane();
    pane.setLayout(new BorderLayout());
    JTable table = new JTable(tableModel) {

        @Override//  ww  w  .  java 2  s .  c  om
        public TableCellEditor getCellEditor(int row, int column) {
            if (column == LevelTableModel.COL_ROLLED_HP && row < numLevels) {//TODO: the max roll should be calculated in a different manner
                String hd = levels.getClassTaken(levels.getElementAt(row + oldLevel)).getHD();
                int max = NumberUtils.toInt(hd);
                return new SpinnerEditor(new SpinnerNumberModel(1, 1, max, 1));
            }
            return super.getCellEditor(row, column);
        }

        @Override
        public TableCellRenderer getCellRenderer(int row, int column) {
            if (column == LevelTableModel.COL_ROLLED_HP && row < numLevels) {
                return new SpinnerRenderer();
            }
            return super.getCellRenderer(row, column);
        }

    };
    table.setCellSelectionEnabled(false);
    table.setRowHeight(new JSpinner().getPreferredSize().height);
    JTableHeader header = table.getTableHeader();
    header.setReorderingAllowed(false);

    JScrollPane scrollPane = new JScrollPane(table);
    pane.add(scrollPane, BorderLayout.CENTER);

    Box box = Box.createHorizontalBox();
    box.add(Box.createHorizontalGlue());
    JButton button = new JButton(LanguageBundle.getString("in_close")); //$NON-NLS-1$
    button.setMnemonic(LanguageBundle.getMnemonic("in_mn_close")); //$NON-NLS-1$
    button.setActionCommand("Close"); //$NON-NLS-1$
    button.addActionListener(this);
    box.add(button);
    pane.add(box, BorderLayout.SOUTH);
    addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosed(WindowEvent e) {
            //Make sure to remove the listeners so that the garbage collector can
            //dispose of this dialog and prevent a memory leak
            levels.removeHitPointListener(tableModel);
        }

    });

    Utility.installEscapeCloseOperation(this);
}