Example usage for javax.swing JLabel setToolTipText

List of usage examples for javax.swing JLabel setToolTipText

Introduction

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

Prototype

@BeanProperty(bound = false, preferred = true, description = "The text to display in a tool tip.")
public void setToolTipText(String text) 

Source Link

Document

Registers the text to display in a tool tip.

Usage

From source file:org.javaswift.cloudie.CloudiePanel.java

private void createLists() {
    containersList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    containersList.setCellRenderer(new DefaultListCellRenderer() {
        @Override/*from  w w  w  .  java 2  s  . c o  m*/
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
                boolean cellHasFocus) {
            JLabel lbl = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected,
                    cellHasFocus);
            lbl.setBorder(LR_PADDING);
            Container c = (Container) value;
            lbl.setText(c.getName());
            lbl.setToolTipText(lbl.getText());
            return lbl;
        }
    });
    containersList.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            enableDisableContainerMenu();
            updateStatusPanelForContainer();
        }
    });
    //
    storedObjectsList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    storedObjectsList.setCellRenderer(new DefaultListCellRenderer() {
        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
                boolean cellHasFocus) {
            JLabel lbl = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected,
                    cellHasFocus);
            lbl.setBorder(LR_PADDING);
            StoredObject so = (StoredObject) value;
            lbl.setText(so.getName());
            lbl.setToolTipText(lbl.getText());
            return lbl;
        }
    });
    storedObjectsList.addListSelectionListener(new ListSelectionListener() {

        @Override
        public void valueChanged(ListSelectionEvent e) {
            enableDisableStoredObjectMenu();
            updateStatusPanelForStoredObject();
        }
    });
}

From source file:org.jtrfp.trcl.gui.ConfigWindow.java

public ConfigWindow() {
    setTitle("Settings");
    setSize(340, 540);//from w  w  w.ja  va 2  s . c  o m
    if (config == null)
        config = new TRConfiguration();
    JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
    getContentPane().add(tabbedPane, BorderLayout.CENTER);

    JPanel generalTab = new JPanel();
    tabbedPane.addTab("General",
            new ImageIcon(ConfigWindow.class
                    .getResource("/org/freedesktop/tango/22x22/mimetypes/application-x-executable.png")),
            generalTab, null);
    GridBagLayout gbl_generalTab = new GridBagLayout();
    gbl_generalTab.columnWidths = new int[] { 0, 0 };
    gbl_generalTab.rowHeights = new int[] { 0, 188, 222, 0 };
    gbl_generalTab.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
    gbl_generalTab.rowWeights = new double[] { 0.0, 1.0, 0.0, Double.MIN_VALUE };
    generalTab.setLayout(gbl_generalTab);

    JPanel settingsLoadSavePanel = new JPanel();
    GridBagConstraints gbc_settingsLoadSavePanel = new GridBagConstraints();
    gbc_settingsLoadSavePanel.insets = new Insets(0, 0, 5, 0);
    gbc_settingsLoadSavePanel.anchor = GridBagConstraints.WEST;
    gbc_settingsLoadSavePanel.gridx = 0;
    gbc_settingsLoadSavePanel.gridy = 0;
    generalTab.add(settingsLoadSavePanel, gbc_settingsLoadSavePanel);
    settingsLoadSavePanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null),
            "Overall Settings", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    FlowLayout flowLayout_1 = (FlowLayout) settingsLoadSavePanel.getLayout();
    flowLayout_1.setAlignment(FlowLayout.LEFT);

    JButton btnSave = new JButton("Export...");
    btnSave.setToolTipText("Export these settings to an external file");
    settingsLoadSavePanel.add(btnSave);
    btnSave.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            exportSettings();
        }
    });

    JButton btnLoad = new JButton("Import...");
    btnLoad.setToolTipText("Import an external settings file");
    settingsLoadSavePanel.add(btnLoad);
    btnLoad.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            importSettings();
        }
    });

    JButton btnConfigReset = new JButton("Reset");
    btnConfigReset.setToolTipText("Reset all settings to defaults");
    settingsLoadSavePanel.add(btnConfigReset);
    btnConfigReset.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            defaultSettings();
        }
    });

    JPanel registeredPODsPanel = new JPanel();
    registeredPODsPanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null),
            "Registered PODs", TitledBorder.LEFT, TitledBorder.TOP, null, null));
    GridBagConstraints gbc_registeredPODsPanel = new GridBagConstraints();
    gbc_registeredPODsPanel.insets = new Insets(0, 0, 5, 0);
    gbc_registeredPODsPanel.fill = GridBagConstraints.BOTH;
    gbc_registeredPODsPanel.gridx = 0;
    gbc_registeredPODsPanel.gridy = 1;
    generalTab.add(registeredPODsPanel, gbc_registeredPODsPanel);
    GridBagLayout gbl_registeredPODsPanel = new GridBagLayout();
    gbl_registeredPODsPanel.columnWidths = new int[] { 272, 0 };
    gbl_registeredPODsPanel.rowHeights = new int[] { 76, 0, 0 };
    gbl_registeredPODsPanel.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
    gbl_registeredPODsPanel.rowWeights = new double[] { 1.0, 1.0, Double.MIN_VALUE };
    registeredPODsPanel.setLayout(gbl_registeredPODsPanel);

    JPanel podListPanel = new JPanel();
    GridBagConstraints gbc_podListPanel = new GridBagConstraints();
    gbc_podListPanel.insets = new Insets(0, 0, 5, 0);
    gbc_podListPanel.fill = GridBagConstraints.BOTH;
    gbc_podListPanel.gridx = 0;
    gbc_podListPanel.gridy = 0;
    registeredPODsPanel.add(podListPanel, gbc_podListPanel);
    podListPanel.setLayout(new BorderLayout(0, 0));

    JScrollPane podListScrollPane = new JScrollPane();
    podListPanel.add(podListScrollPane, BorderLayout.CENTER);

    podList = new JList(podLM);
    podList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    podListScrollPane.setViewportView(podList);

    JPanel podListOpButtonPanel = new JPanel();
    podListOpButtonPanel.setBorder(null);
    GridBagConstraints gbc_podListOpButtonPanel = new GridBagConstraints();
    gbc_podListOpButtonPanel.anchor = GridBagConstraints.NORTH;
    gbc_podListOpButtonPanel.gridx = 0;
    gbc_podListOpButtonPanel.gridy = 1;
    registeredPODsPanel.add(podListOpButtonPanel, gbc_podListOpButtonPanel);
    FlowLayout flowLayout = (FlowLayout) podListOpButtonPanel.getLayout();
    flowLayout.setAlignment(FlowLayout.LEFT);

    JButton addPodButton = new JButton("Add...");
    addPodButton.setIcon(
            new ImageIcon(ConfigWindow.class.getResource("/org/freedesktop/tango/16x16/actions/list-add.png")));
    addPodButton.setToolTipText("Add a POD to the registry to be considered when running a game.");
    podListOpButtonPanel.add(addPodButton);
    addPodButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            addPOD();
        }
    });

    JButton removePodButton = new JButton("Remove");
    removePodButton.setIcon(new ImageIcon(
            ConfigWindow.class.getResource("/org/freedesktop/tango/16x16/actions/list-remove.png")));
    removePodButton.setToolTipText("Remove a POD file from being considered when playing a game");
    podListOpButtonPanel.add(removePodButton);
    removePodButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            podLM.removeElement(podList.getSelectedValue());
        }
    });

    JButton podEditButton = new JButton("Edit...");
    podEditButton.setIcon(null);
    podEditButton.setToolTipText("Edit the selected POD path");
    podListOpButtonPanel.add(podEditButton);
    podEditButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            editPODPath();
        }
    });

    JPanel missionPanel = new JPanel();
    GridBagConstraints gbc_missionPanel = new GridBagConstraints();
    gbc_missionPanel.fill = GridBagConstraints.BOTH;
    gbc_missionPanel.gridx = 0;
    gbc_missionPanel.gridy = 2;
    generalTab.add(missionPanel, gbc_missionPanel);
    missionPanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "Missions",
            TitledBorder.LEADING, TitledBorder.TOP, null, null));
    GridBagLayout gbl_missionPanel = new GridBagLayout();
    gbl_missionPanel.columnWidths = new int[] { 0, 0 };
    gbl_missionPanel.rowHeights = new int[] { 0, 0, 0 };
    gbl_missionPanel.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
    gbl_missionPanel.rowWeights = new double[] { 1.0, 0.0, Double.MIN_VALUE };
    missionPanel.setLayout(gbl_missionPanel);

    JScrollPane scrollPane = new JScrollPane();
    GridBagConstraints gbc_scrollPane = new GridBagConstraints();
    gbc_scrollPane.insets = new Insets(0, 0, 5, 0);
    gbc_scrollPane.fill = GridBagConstraints.BOTH;
    gbc_scrollPane.gridx = 0;
    gbc_scrollPane.gridy = 0;
    missionPanel.add(scrollPane, gbc_scrollPane);

    missionList = new JList(missionLM);
    missionList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    scrollPane.setViewportView(missionList);

    JPanel missionListOpButtonPanel = new JPanel();
    GridBagConstraints gbc_missionListOpButtonPanel = new GridBagConstraints();
    gbc_missionListOpButtonPanel.anchor = GridBagConstraints.NORTH;
    gbc_missionListOpButtonPanel.gridx = 0;
    gbc_missionListOpButtonPanel.gridy = 1;
    missionPanel.add(missionListOpButtonPanel, gbc_missionListOpButtonPanel);

    JButton addVOXButton = new JButton("Add...");
    addVOXButton.setIcon(
            new ImageIcon(ConfigWindow.class.getResource("/org/freedesktop/tango/16x16/actions/list-add.png")));
    addVOXButton.setToolTipText("Add an external VOX file as a mission");
    missionListOpButtonPanel.add(addVOXButton);
    addVOXButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            addVOX();
        }
    });

    final JButton removeVOXButton = new JButton("Remove");
    removeVOXButton.setIcon(new ImageIcon(
            ConfigWindow.class.getResource("/org/freedesktop/tango/16x16/actions/list-remove.png")));
    removeVOXButton.setToolTipText("Remove the selected mission");
    missionListOpButtonPanel.add(removeVOXButton);
    removeVOXButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            missionLM.remove(missionList.getSelectedIndex());
        }
    });

    final JButton editVOXButton = new JButton("Edit...");
    editVOXButton.setToolTipText("Edit the selected Mission's VOX path");
    missionListOpButtonPanel.add(editVOXButton);
    editVOXButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            editVOXPath();
        }
    });

    missionList.addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent evt) {
            final String val = (String) missionList.getSelectedValue();
            if (val == null)
                missionList.setSelectedIndex(0);
            else if (isBuiltinVOX(val)) {
                removeVOXButton.setEnabled(false);
                editVOXButton.setEnabled(false);
            } else {
                removeVOXButton.setEnabled(true);
                editVOXButton.setEnabled(true);
            }
        }
    });

    JPanel soundTab = new JPanel();
    tabbedPane.addTab("Sound",
            new ImageIcon(
                    ConfigWindow.class.getResource("/org/freedesktop/tango/22x22/devices/audio-card.png")),
            soundTab, null);
    GridBagLayout gbl_soundTab = new GridBagLayout();
    gbl_soundTab.columnWidths = new int[] { 0, 0 };
    gbl_soundTab.rowHeights = new int[] { 65, 51, 70, 132, 0, 0, 0 };
    gbl_soundTab.columnWeights = new double[] { 1.0, Double.MIN_VALUE };
    gbl_soundTab.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE };
    soundTab.setLayout(gbl_soundTab);

    JPanel checkboxPanel = new JPanel();
    GridBagConstraints gbc_checkboxPanel = new GridBagConstraints();
    gbc_checkboxPanel.insets = new Insets(0, 0, 5, 0);
    gbc_checkboxPanel.fill = GridBagConstraints.BOTH;
    gbc_checkboxPanel.gridx = 0;
    gbc_checkboxPanel.gridy = 0;
    soundTab.add(checkboxPanel, gbc_checkboxPanel);

    chckbxLinearInterpolation = new JCheckBox("Linear Filtering");
    chckbxLinearInterpolation.setToolTipText("Use the GPU's TMU to smooth playback of low-rate samples.");
    chckbxLinearInterpolation.setHorizontalAlignment(SwingConstants.LEFT);
    checkboxPanel.add(chckbxLinearInterpolation);

    chckbxLinearInterpolation.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            needRestart = true;
        }
    });

    chckbxBufferLag = new JCheckBox("Buffer Lag");
    chckbxBufferLag.setToolTipText("Improves efficiency, doubles latency.");
    checkboxPanel.add(chckbxBufferLag);

    JPanel modStereoWidthPanel = new JPanel();
    FlowLayout flowLayout_2 = (FlowLayout) modStereoWidthPanel.getLayout();
    flowLayout_2.setAlignment(FlowLayout.LEFT);
    modStereoWidthPanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null),
            "MOD Stereo Width", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    GridBagConstraints gbc_modStereoWidthPanel = new GridBagConstraints();
    gbc_modStereoWidthPanel.anchor = GridBagConstraints.NORTH;
    gbc_modStereoWidthPanel.insets = new Insets(0, 0, 5, 0);
    gbc_modStereoWidthPanel.fill = GridBagConstraints.HORIZONTAL;
    gbc_modStereoWidthPanel.gridx = 0;
    gbc_modStereoWidthPanel.gridy = 1;
    soundTab.add(modStereoWidthPanel, gbc_modStereoWidthPanel);

    modStereoWidthSlider = new JSlider();
    modStereoWidthSlider.setPaintTicks(true);
    modStereoWidthSlider.setMinorTickSpacing(25);
    modStereoWidthPanel.add(modStereoWidthSlider);

    final JLabel modStereoWidthLbl = new JLabel("NN%");
    modStereoWidthPanel.add(modStereoWidthLbl);

    JPanel bufferSizePanel = new JPanel();
    FlowLayout flowLayout_3 = (FlowLayout) bufferSizePanel.getLayout();
    flowLayout_3.setAlignment(FlowLayout.LEFT);
    bufferSizePanel.setBorder(
            new TitledBorder(null, "Buffer Size", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    GridBagConstraints gbc_bufferSizePanel = new GridBagConstraints();
    gbc_bufferSizePanel.anchor = GridBagConstraints.NORTH;
    gbc_bufferSizePanel.insets = new Insets(0, 0, 5, 0);
    gbc_bufferSizePanel.fill = GridBagConstraints.HORIZONTAL;
    gbc_bufferSizePanel.gridx = 0;
    gbc_bufferSizePanel.gridy = 2;
    soundTab.add(bufferSizePanel, gbc_bufferSizePanel);

    audioBufferSizeCB = new JComboBox();
    audioBufferSizeCB.setModel(new DefaultComboBoxModel(AudioBufferSize.values()));
    bufferSizePanel.add(audioBufferSizeCB);

    soundOutputSelectorGUI = new SoundOutputSelectorGUI();
    soundOutputSelectorGUI.setBorder(
            new TitledBorder(null, "Output Driver", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    GridBagConstraints gbc_soundOutputSelectorGUI = new GridBagConstraints();
    gbc_soundOutputSelectorGUI.anchor = GridBagConstraints.NORTH;
    gbc_soundOutputSelectorGUI.insets = new Insets(0, 0, 5, 0);
    gbc_soundOutputSelectorGUI.fill = GridBagConstraints.HORIZONTAL;
    gbc_soundOutputSelectorGUI.gridx = 0;
    gbc_soundOutputSelectorGUI.gridy = 3;
    soundTab.add(soundOutputSelectorGUI, gbc_soundOutputSelectorGUI);

    modStereoWidthSlider.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent arg0) {
            modStereoWidthLbl.setText(modStereoWidthSlider.getValue() + "%");
            needRestart = true;
        }
    });

    JPanel okCancelPanel = new JPanel();
    getContentPane().add(okCancelPanel, BorderLayout.SOUTH);
    okCancelPanel.setLayout(new BorderLayout(0, 0));

    JButton btnOk = new JButton("OK");
    btnOk.setToolTipText("Apply these settings and close the window");
    okCancelPanel.add(btnOk, BorderLayout.WEST);
    btnOk.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            applySettings();
            ConfigWindow.this.setVisible(false);
        }
    });

    JButton btnCancel = new JButton("Cancel");
    btnCancel.setToolTipText("Close the window without applying settings");
    okCancelPanel.add(btnCancel, BorderLayout.EAST);

    JLabel lblConfigpath = new JLabel(TRConfiguration.getConfigFilePath().getAbsolutePath());
    lblConfigpath.setIcon(null);
    lblConfigpath.setToolTipText("Default config file path");
    lblConfigpath.setHorizontalAlignment(SwingConstants.CENTER);
    lblConfigpath.setFont(new Font("Dialog", Font.BOLD, 6));
    okCancelPanel.add(lblConfigpath, BorderLayout.CENTER);
    btnCancel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            ConfigWindow.this.setVisible(false);
        }
    });
}

From source file:org.kalypso.ogc.sensor.tableview.swing.marker.ForecastLabelMarker.java

/**
 * @see org.kalypso.ogc.sensor.tableview.swing.marker.ILabelMarker#apply(javax.swing.JLabel)
 *//*from   w w  w.j  a v  a 2 s .c om*/
@Override
public void apply(final JLabel label) {
    label.setBackground(FORECAST_BG);
    label.setToolTipText(FORECAST_TT);
    // label.setIcon( FORECAST_ICON );
}

From source file:org.kalypso.ogc.sensor.tableview.swing.marker.ForecastLabelMarker.java

/**
 * @see org.kalypso.ogc.sensor.tableview.swing.marker.ILabelMarker#reset(javax.swing.JLabel)
 */// w  w  w  .j  a  v a  2s .c  om
@Override
public void reset(final JLabel label) {
    label.setBackground(m_defaultBackground);
    label.setToolTipText(""); //$NON-NLS-1$
    label.setIcon(null);
}

From source file:org.languagetool.gui.LanguageToolSupport.java

private void showPopup(MouseEvent event) {
    if (documentSpans.isEmpty() && languageTool.getDisabledRules().isEmpty()) {
        //No errors and no disabled Rules
        return;/*from  w  w w . j  a  v a  2s.  c  o  m*/
    }

    int offset = this.textComponent.viewToModel(event.getPoint());
    Span span = getSpan(offset);
    JPopupMenu popup = new JPopupMenu("Grammar Menu");
    if (span != null) {
        JLabel msgItem = new JLabel("<html>"
                + span.msg.replace("<suggestion>", "<b>").replace("</suggestion>", "</b>") + "</html>");
        msgItem.setToolTipText(span.desc.replace("<suggestion>", "").replace("</suggestion>", ""));
        msgItem.setBorder(new JMenuItem().getBorder());
        popup.add(msgItem);

        popup.add(new JSeparator());

        for (String r : span.replacement) {
            ReplaceMenuItem item = new ReplaceMenuItem(r, span);
            popup.add(item);
            item.addActionListener(actionListener);
        }

        popup.add(new JSeparator());

        JMenuItem moreItem = new JMenuItem(messages.getString("guiMore"));
        moreItem.addActionListener(e -> showDialog(textComponent, span.msg, span.desc, span.rule, span.url));
        popup.add(moreItem);

        JMenuItem ignoreItem = new JMenuItem(messages.getString("guiTurnOffRule"));
        ignoreItem.addActionListener(e -> disableRule(span.rule.getId()));
        popup.add(ignoreItem);
        popup.applyComponentOrientation(ComponentOrientation.getOrientation(Locale.getDefault()));
    }

    List<Rule> disabledRules = getDisabledRules();
    if (!disabledRules.isEmpty()) {
        JMenu activateRuleMenu = new JMenu(messages.getString("guiActivateRule"));
        addDisabledRulesToMenu(disabledRules, activateRuleMenu);
        popup.add(activateRuleMenu);
    }

    if (span != null) {
        textComponent.setCaretPosition(span.start);
        textComponent.moveCaretPosition(span.end);
    }

    popup.addPopupMenuListener(new PopupMenuListener() {
        @Override
        public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
        }

        @Override
        public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
        }

        @Override
        public void popupMenuCanceled(PopupMenuEvent e) {
            if (span != null) {
                textComponent.setCaretPosition(span.start);
            }
        }
    });
    popup.show(textComponent, event.getPoint().x, event.getPoint().y);

}

From source file:org.nuclos.client.dbtransfer.DBTransferImport.java

private boolean setupPreviewPanel(List<PreviewPart> previewParts) {
    boolean blnTransferWithWarnings = false;
    jpnPreviewHeader.removeAll();/*from   ww w .  j a v  a2s.c o m*/
    jpnPreviewFooter.removeAll();

    // setup parameter scroll pane
    jpnPreviewContent.removeAll();

    double[] rowContraints = new double[previewParts.size()];
    for (int i = 0; i < previewParts.size(); i++)
        rowContraints[i] = TableLayout.PREFERRED;
    final int iWidthBeginnigSpace = 3;
    final int iWidthSeparator = 6;

    final SpringLocaleDelegate localeDelegate = getSpringLocaleDelegate();
    JLabel lbPreviewHeaderEntity = new JLabel(
            localeDelegate.getMessage("dbtransfer.import.step1.11", "Entit\u00e4t"));
    JLabel lbPreviewHeaderTable = new JLabel(
            localeDelegate.getMessage("dbtransfer.import.step1.12", "Tabellenname"));
    JLabel lbPreviewHeaderRecords = new JLabel(
            localeDelegate.getMessage("dbtransfer.import.step1.4", "Datens\u00e4tze"));
    lbPreviewHeaderRecords.setToolTipText(
            localeDelegate.getMessage("dbtransfer.import.step1.5", "Anzahl der betroffenen Datens\u00e4tze"));
    utils.initJPanel(jpnPreviewContent,
            new double[] { iWidthBeginnigSpace, TableLayout.PREFERRED, iWidthSeparator, TableLayout.PREFERRED,
                    iWidthSeparator, TableLayout.PREFERRED, iWidthSeparator, TableLayout.PREFERRED,
                    TableLayout.PREFERRED, iWidthSeparator, TableLayout.PREFERRED },
            rowContraints);

    int iWidthEntityLabelSize = 0;
    int iWidthTableLabelSize = 0;
    int iWidthRecordsLabelSize = 0;

    int iCountNew = 0;
    int iCountDeleted = 0;
    int iCountChanged = 0;

    int iRow = 0;
    for (final PreviewPart pp : previewParts) {
        String tooltip = "";
        JLabel lbEntity = new JLabel(pp.getEntity());
        JLabel lbTable = new JLabel(pp.getTable());
        JLabel lbRecords = new JLabel(String.valueOf(pp.getDataRecords()));
        lbRecords.setHorizontalAlignment(SwingConstants.RIGHT);
        if (lbEntity.getPreferredSize().width < lbPreviewHeaderEntity.getPreferredSize().width)
            lbEntity.setPreferredSize(lbPreviewHeaderEntity.getPreferredSize());
        if (lbTable.getPreferredSize().width < lbPreviewHeaderTable.getPreferredSize().width)
            lbTable.setPreferredSize(lbPreviewHeaderTable.getPreferredSize());
        if (lbRecords.getPreferredSize().width < lbPreviewHeaderRecords.getPreferredSize().width)
            lbRecords.setPreferredSize(lbPreviewHeaderRecords.getPreferredSize());
        iWidthEntityLabelSize = iWidthEntityLabelSize < lbEntity.getPreferredSize().width
                ? lbEntity.getPreferredSize().width
                : iWidthEntityLabelSize;
        iWidthTableLabelSize = iWidthTableLabelSize < lbTable.getPreferredSize().width
                ? lbTable.getPreferredSize().width
                : iWidthTableLabelSize;
        iWidthRecordsLabelSize = iWidthRecordsLabelSize < lbRecords.getPreferredSize().width
                ? lbRecords.getPreferredSize().width
                : iWidthRecordsLabelSize;

        Icon icoStatement = null;
        switch (pp.getType()) {
        case PreviewPart.NEW:
            tooltip = localeDelegate.getMessage("dbtransfer.import.step1.6",
                    "Entit\u00e4t wird hinzugef\u00fcgt");
            icoStatement = ParameterEditor.COMPARE_ICON_NEW;
            iCountNew++;
            break;
        case PreviewPart.CHANGE:
            tooltip = localeDelegate.getMessage("dbtransfer.import.step1.7", "Entit\u00e4t wird ge\u00e4ndert");
            icoStatement = ParameterEditor.COMPARE_ICON_VALUE_CHANGED;
            iCountChanged++;
            break;
        case PreviewPart.DELETE:
            tooltip = localeDelegate.getMessage("dbtransfer.import.step1.8", "Entit\u00e4t wird gel\u00f6scht");
            icoStatement = ParameterEditor.COMPARE_ICON_DELETED;
            iCountDeleted++;
            break;
        }

        JLabel lbIcon = new JLabel(icoStatement);
        JLabel lbStatemnts = new JLabel("<html><u>"
                + localeDelegate.getMessage("dbtransfer.import.step1.9", "Script anzeigen") + "...</u></html>");
        lbStatemnts.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
        lbStatemnts.addMouseListener(new MouseListener() {
            @Override
            public void mouseReleased(MouseEvent e) {
            }

            @Override
            public void mousePressed(MouseEvent e) {
            }

            @Override
            public void mouseExited(MouseEvent e) {
            }

            @Override
            public void mouseEntered(MouseEvent e) {
            }

            @Override
            public void mouseClicked(MouseEvent e) {
                String statements = "";
                for (String statement : pp.getStatements()) {
                    statements = statements + statement + ";\n\n";
                }
                JTextArea txtArea = new JTextArea(statements);

                txtArea.setEditable(false);
                txtArea.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
                JScrollPane scroll = new JScrollPane(txtArea);
                scroll.getVerticalScrollBar().setUnitIncrement(20);
                scroll.setPreferredSize(new Dimension(600, 300));
                scroll.setBorder(BorderFactory.createEmptyBorder());
                MainFrameTab overlayFrame = new MainFrameTab(
                        localeDelegate.getMessage("dbtransfer.import.step1.10", "Script f\u00fcr") + " "
                                + pp.getEntity() + " (" + pp.getTable() + ")");
                overlayFrame.setLayeredComponent(scroll);
                ifrm.add(overlayFrame);
            }
        });

        lbIcon.setToolTipText(tooltip);
        lbStatemnts.setToolTipText(tooltip);
        lbEntity.setToolTipText(tooltip);
        lbTable.setToolTipText(tooltip);

        jpnPreviewContent.add(lbEntity, "1," + iRow + ",l,c");
        jpnPreviewContent.add(lbTable, "3," + iRow + ",l,c");
        jpnPreviewContent.add(lbRecords, "5," + iRow + ",r,c");
        jpnPreviewContent.add(lbIcon, "7," + iRow + ",l,c");
        jpnPreviewContent.add(lbStatemnts, "8," + iRow + ",l,c");
        if (pp.getWarning() > 0) {
            lbIcon.setIcon(Icons.getInstance().getIconPriorityCancel16());
            blnTransferWithWarnings = true;
        }
        iRow++;
    }

    jpnPreviewContent.add(new JSeparator(JSeparator.VERTICAL), "2,0,2," + (iRow - 1));
    jpnPreviewContent.add(new JSeparator(JSeparator.VERTICAL), "4,0,4," + (iRow - 1));
    jpnPreviewContent.add(new JSeparator(JSeparator.VERTICAL), "6,0,6," + (iRow - 1));

    // setup preview header   
    utils.initJPanel(jpnPreviewHeader,
            new double[] { iWidthBeginnigSpace, iWidthEntityLabelSize, iWidthSeparator, iWidthTableLabelSize,
                    iWidthSeparator, iWidthRecordsLabelSize, iWidthSeparator, TableLayout.PREFERRED,
                    iWidthSeparator, TableLayout.PREFERRED, TableLayout.PREFERRED },
            new double[] { TableLayout.PREFERRED });

    if (previewParts.isEmpty()) {
        jpnPreviewHeader.add(new JLabel(localeDelegate.getMessage("dbtransfer.import.step1.18",
                "Keine Struktur\u00e4nderungen am Datenbankschema.")), "0,0,8,0");
        return blnTransferWithWarnings;
    }

    jpnPreviewHeader.add(lbPreviewHeaderEntity, "1,0");
    jpnPreviewHeader.add(lbPreviewHeaderTable, "3,0");
    jpnPreviewHeader.add(lbPreviewHeaderRecords, "5,0");

    jpnPreviewHeader.add(new JLabel(localeDelegate.getMessage("dbtransfer.import.step1.13", "\u00c4nderung")),
            "7,0");

    // setup preview footer
    utils.initJPanel(jpnPreviewFooter, new double[] { TableLayout.FILL, TableLayout.PREFERRED,
            TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED },
            new double[] { TableLayout.PREFERRED });

    final JLabel lbCompare = new JLabel(
            localeDelegate.getMessage("dbtransfer.import.step1.14", "\u00c4nderungen") + ":");
    final JLabel lbCompareNew = new JLabel(iCountNew + "");
    final JLabel lbCompareDeleted = new JLabel(iCountDeleted + "");
    final JLabel lbCompareValueChanged = new JLabel(iCountChanged + "");

    lbCompareNew.setIcon(ParameterEditor.COMPARE_ICON_NEW);
    lbCompareDeleted.setIcon(ParameterEditor.COMPARE_ICON_DELETED);
    lbCompareValueChanged.setIcon(ParameterEditor.COMPARE_ICON_VALUE_CHANGED);

    lbCompareNew.setToolTipText(localeDelegate.getMessage("dbtransfer.import.step1.15", "Neue Entit\u00e4ten"));
    lbCompareDeleted.setToolTipText(
            localeDelegate.getMessage("dbtransfer.import.step1.17", "Gel\u00f6schte Entit\u00e4ten"));
    lbCompareValueChanged.setToolTipText(
            localeDelegate.getMessage("dbtransfer.import.step1.16", "Ge\u00e4nderte Entit\u00e4ten"));

    jpnPreviewFooter.add(lbCompare, "1,0,r,c");
    jpnPreviewFooter.add(lbCompareNew, "2,0,r,c");
    jpnPreviewFooter.add(lbCompareValueChanged, "3,0,r,c");
    jpnPreviewFooter.add(lbCompareDeleted, "4,0,r,c");

    return blnTransferWithWarnings;
}

From source file:org.nuclos.client.dbtransfer.DBTransferImport.java

private void setupParameterPanel(Collection<EntityObjectVO> incomingParameterVOs) {
    final String entity = NuclosEntity.PARAMETER.getEntityName();
    List<EntityObjectVO> currentParameterVOs = new ArrayList<EntityObjectVO>(
            CollectionUtils.transform(MasterDataDelegate.getInstance().getMasterData(entity),
                    DalSupportForMD.getTransformerToEntityObjectVO(entity)));
    int iCountNew = 0;
    int iCountDeleted = 0;
    int iCountValueChanged = 0;

    final SpringLocaleDelegate localeDelegate = getSpringLocaleDelegate();

    // find new parameter and existing
    List<ParameterComparison> allParameter = new ArrayList<ParameterComparison>();
    for (EntityObjectVO incomingParameterVO : incomingParameterVOs) {
        boolean blnParamFound = false;
        String sCurrentValue = null;
        for (EntityObjectVO currentParameterVO : currentParameterVOs) {
            if ((incomingParameterVO.getField("name", String.class))
                    .equals(currentParameterVO.getField("name", String.class))) {
                blnParamFound = true;/* w w w  . jav  a 2 s.com*/
                sCurrentValue = currentParameterVO.getField("value", String.class);
                break;
            }
        }
        if (!blnParamFound) {
            allParameter.add(new ParameterComparison(incomingParameterVO, true, false, null));
            iCountNew++;
        } else {
            ParameterComparison parameter = new ParameterComparison(incomingParameterVO, false, false,
                    sCurrentValue);
            allParameter.add(parameter);
            if (parameter.isValueChanged())
                iCountValueChanged++;
        }
    }

    // find deleted parameter
    for (EntityObjectVO currentParameterVO : currentParameterVOs) {
        boolean blnParamFound = false;
        for (EntityObjectVO incomingParamVO : incomingParameterVOs) {
            if ((incomingParamVO.getField("name", String.class))
                    .equals(currentParameterVO.getField("name", String.class))) {
                blnParamFound = true;
                break;
            }
        }
        if (!blnParamFound) {
            allParameter.add(new ParameterComparison(currentParameterVO, false, true,
                    currentParameterVO.getField("value", String.class)));
            iCountDeleted++;
        }
    }

    // sort parameter VOs
    List<ParameterComparison> allParameterSorted = new ArrayList<ParameterComparison>(allParameter);
    Collections.sort(allParameterSorted, new Comparator<ParameterComparison>() {
        @Override
        public int compare(ParameterComparison o1, ParameterComparison o2) {
            return StringUtils.emptyIfNull(o1.getField("name", String.class))
                    .compareTo(StringUtils.emptyIfNull(o2.getField("name", String.class)));
        }
    });

    jpnParameterHeader.removeAll();
    jpnParameterFooter.removeAll();

    // setup parameter scroll pane
    jpnParameter.removeAll();

    double[] rowContraints = new double[allParameterSorted.size()];
    for (int i = 0; i < allParameterSorted.size(); i++)
        rowContraints[i] = TableLayout.PREFERRED;
    final int iWidthBeginnigSpace = 3;
    final int iWidthSeparator = 6;
    final int iWidthRadioButton = 20;

    utils.initJPanel(jpnParameter, new double[] { iWidthBeginnigSpace, TableLayout.PREFERRED, iWidthSeparator,
            iWidthRadioButton, iWidthRadioButton, iWidthRadioButton, TableLayout.FILL }, rowContraints);

    int iWidthLabelSize = 0;

    int iRow = 0;
    lstParameterEditors.clear();
    for (ParameterComparison parameter : allParameterSorted) {
        final ParameterEditor pe = new ParameterEditor(parameter);

        // init last state
        if (setSelectedCurrentParameter.contains(pe.getName()))
            pe.setCurrentValue();
        if (setSelectedIncomingParameter.contains(pe.getName()))
            pe.setIncomingValue();
        if (mapSelectedOtherParameter.containsKey(pe.getName()))
            pe.setOtherValue(mapSelectedOtherParameter.get(pe.getName()));

        // add change listener to update the radio buttons in footer
        pe.addChangeListener(new ChangeListener() {
            @Override
            public void stateChanged(ChangeEvent e) {
                updateParameterAllSelection();
            }
        });

        pe.addToStepContent(jpnParameter, iRow);
        lstParameterEditors.add(pe);

        if (pe.getLabelPrefferedSize().width > iWidthLabelSize)
            iWidthLabelSize = pe.getLabelPrefferedSize().width;
        iRow++;
    }
    updateParameterAllSelection();
    jpnParameter.add(new JSeparator(JSeparator.VERTICAL), "2,0,2," + (iRow - 1));

    // setup parameter header   
    utils.initJPanel(jpnParameterHeader,
            new double[] { iWidthBeginnigSpace,
                    iWidthLabelSize + iWidthSeparator + (iWidthRadioButton / 2) + utils.TABLE_LAYOUT_H_GAP
                            + 1/*Border*/,
                    iWidthRadioButton, iWidthRadioButton, TableLayout.FILL },
            new double[] { TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED, 4 });

    if (allParameterSorted.isEmpty()) {
        jpnParameterHeader.add(new JLabel(
                localeDelegate.getMessage("dbtransfer.import.parameterpanel.18", "Keine Parameter vorhanden.")),
                "1,2,4,2");
        return;
    }

    jpnParameterHeader.add(
            new JLabel(localeDelegate.getMessage("dbtransfer.import.parameterpanel.1", "Parameter")), "1,2");
    jpnParameterHeader.add(new JLabel(
            localeDelegate.getMessage("dbtransfer.import.parameterpanel.2", "aktuellen Zustand beibehalten")),
            "2,0,4,0");
    jpnParameterHeader.add(new JSeparator(JSeparator.VERTICAL), "2,1,2,3");
    jpnParameterHeader.add(new JLabel(localeDelegate.getMessage("dbtransfer.import.parameterpanel.3",
            "importierten Zustand \u00fcbernehmen")), "3,1,4,1");
    jpnParameterHeader.add(new JSeparator(JSeparator.VERTICAL), "3,2,3,3");
    jpnParameterHeader.add(
            new JLabel(localeDelegate.getMessage("dbtransfer.import.parameterpanel.4", "anderen Wert setzen")),
            "4,2");
    jpnParameterHeader.add(new JSeparator(JSeparator.VERTICAL), "4,3");

    // setup parameter footer      
    utils.initJPanel(jpnParameterFooter,
            new double[] { iWidthBeginnigSpace,
                    iWidthLabelSize + iWidthSeparator + utils.TABLE_LAYOUT_H_GAP + 1/*Border*/,
                    iWidthRadioButton, iWidthRadioButton, TableLayout.FILL, TableLayout.PREFERRED,
                    TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED },
            new double[] { TableLayout.PREFERRED });

    final JLabel lbCompare = new JLabel(
            localeDelegate.getMessage("dbtransfer.import.parameterpanel.5", "\u00c4nderungen") + ":");
    final JLabel lbCompareNew = new JLabel(iCountNew + "");
    final JLabel lbCompareDeleted = new JLabel(iCountDeleted + "");
    final JLabel lbCompareValueChanged = new JLabel(iCountValueChanged + "");

    lbCompareNew.setIcon(ParameterEditor.COMPARE_ICON_NEW);
    lbCompareDeleted.setIcon(ParameterEditor.COMPARE_ICON_DELETED);
    lbCompareValueChanged.setIcon(ParameterEditor.COMPARE_ICON_VALUE_CHANGED);

    lbCompare.setToolTipText(localeDelegate.getMessage("dbtransfer.import.parameterpanel.6",
            "Vergleich von Aktueller- und Importkonfiguration"));
    lbCompareNew.setToolTipText(ParameterEditor.COMPARE_DESCRIPTION_NEW);
    lbCompareDeleted.setToolTipText(ParameterEditor.COMPARE_DESCRIPTION_DELETED);
    lbCompareValueChanged.setToolTipText(ParameterEditor.COMPARE_DESCRIPTION_VALUE_CHANGED);

    jpnParameterFooter.add(new JLabel(
            localeDelegate.getMessage("dbtransfer.import.parameterpanel.7", "auf alle Parameter anwenden")),
            "1,0,r,c");
    jpnParameterFooter.add(rbCurrentAll, "2,0,l,c");
    jpnParameterFooter.add(rbIncomingAll, "3,0,l,c");
    jpnParameterFooter.add(lbCompare, "4,0,r,c");
    jpnParameterFooter.add(lbCompareNew, "5,0,r,c");
    jpnParameterFooter.add(lbCompareValueChanged, "6,0,r,c");
    jpnParameterFooter.add(lbCompareDeleted, "7,0,r,c");
}

From source file:org.openmicroscopy.shoola.agents.metadata.editor.PropertiesUI.java

/**
 * Returns the pixels size as a string./*www  . j  av a 2s .co m*/
 * 
 * @param details The map to convert.
 * @param component The component displaying the information.
 * @return See above.
 */
private String formatPixelsSize(Map details, JLabel component) {
    String x = (String) details.get(EditorUtil.PIXEL_SIZE_X);
    String y = (String) details.get(EditorUtil.PIXEL_SIZE_Y);
    String z = (String) details.get(EditorUtil.PIXEL_SIZE_Z);
    Double dx = null, dy = null, dz = null;
    boolean number = true;
    NumberFormat nf = NumberFormat.getInstance();
    String units = null;
    UnitsObject o;
    try {
        dx = Double.parseDouble(x);
        o = EditorUtil.transformSize(dx);
        units = o.getUnits();
        dx = o.getValue();
    } catch (Exception e) {
        number = false;
    }
    try {
        dy = Double.parseDouble(y);
        o = EditorUtil.transformSize(dy);
        if (units == null)
            units = o.getUnits();
        dy = o.getValue();
    } catch (Exception e) {
        number = false;
    }
    try {
        dz = Double.parseDouble(z);
        o = EditorUtil.transformSize(dz);
        if (units == null)
            units = o.getUnits();
        dz = o.getValue();
    } catch (Exception e) {
        number = false;
    }

    String label = "Pixels Size (";
    String value = "";
    String tooltip = "<html><body>";
    if (dx != null && dx.doubleValue() > 0) {
        value += nf.format(dx);
        tooltip += "X: " + x + "<br>";
        label += "X";
    }
    if (dy != null && dy.doubleValue() > 0) {
        if (value.length() == 0)
            value += nf.format(dy);
        else
            value += "x" + nf.format(dy);
        ;
        tooltip += "Y: " + y + "<br>";
        label += "Y";
    }
    if (dz != null && dz.doubleValue() > 0) {
        if (value.length() == 0)
            value += nf.format(dz);
        else
            value += "x" + nf.format(dz);
        tooltip += "Z: " + z + "<br>";
        label += "Z";
    }
    label += ") ";
    if (!number) {
        component.setForeground(AnnotationUI.WARNING);
        component.setToolTipText("Values stored in the file...");
    } else {
        component.setToolTipText(tooltip);
    }
    if (value.length() == 0)
        return null;
    component.setText(value);
    if (units == null)
        units = UnitsObject.MICRONS;
    label += units;
    return label;
}

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

/**
 * Update the list of locations/*from   w  w w.  j av  a 2 s. c o m*/
 */
protected void updateLocations() {
    locationsBuilder.getPanel().removeAll();
    for (final DumpContainer curContainer : controller.getDumpContainers()) {
        //Initialize components
        if (curContainer.getGuiHeader() == null) {
            String longLocation = Utils.getLongLocation(curContainer);
            JLabel headerLabel = new JLabel(longLocation);
            headerLabel.setToolTipText(longLocation);
            headerLabel.setIcon(UIManager.getIcon("Tree.collapsedIcon"));
            JPopupMenu popupMenu = new JPopupMenu();
            JMenuItem deleteItem = new JMenuItem("Delete");
            deleteItem.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    log.info("Removing " + curContainer.getType() + " " + curContainer.getLocation());
                    controller.getDumpContainers().remove(curContainer);
                    updateLocations();
                }
            });
            popupMenu.add(deleteItem);
            headerLabel.setComponentPopupMenu(popupMenu);
            curContainer.setGuiHeader(headerLabel);
            //Handlers
            headerLabel.addMouseListener(new MouseAdapter() {
                boolean visible = true;

                @Override
                public void mouseClicked(MouseEvent e) {
                    //Update labels
                    visible = !visible;
                    for (DumpEntry curEntry : curContainer.getEntries()) {
                        curEntry.getGuiName().setVisible(visible);
                        curEntry.getGuiSize().setVisible(visible);
                        curEntry.getGuiLog().setVisible(visible);
                        if (curEntry.getGuiSeparator() != null)
                            curEntry.getGuiSeparator().setVisible(visible);
                    }

                    //Change icon
                    if (visible)
                        curContainer.getGuiHeader().setIcon(UIManager.getIcon("Tree.expandedIcon"));
                    else
                        curContainer.getGuiHeader().setIcon(UIManager.getIcon("Tree.collapsedIcon"));
                    locationsPane.revalidate();
                }
            });
        }
        if (curContainer.getGuiTablePrefix() == null) {
            JTextField headerPrefix = new JTextField(6);
            curContainer.setGuiTablePrefix(headerPrefix);
            headerPrefix.setText(Utils.genTablePrefix(curContainer.getName()));
            if (StringUtils.isBlank(headerPrefix.getText()))
                log.warn("Unable to generate a table prefix for {}", curContainer.getLocation());
        }

        //Start adding to panel
        locationsBuilder.leadingColumnOffset(0);
        locationsBuilder.append(curContainer.getGuiHeader(), 7);
        locationsBuilder.append(curContainer.getGuiTablePrefix());
        locationsBuilder.nextLine();
        locationsBuilder.leadingColumnOffset(2);

        Iterator<DumpEntry> entriesItr = curContainer.getEntries().iterator();
        while (entriesItr.hasNext()) {
            DumpEntry curEntry = entriesItr.next();
            if (curEntry.getGuiName() == null)
                curEntry.setGuiName(new JLabel(curEntry.getName()));
            locationsBuilder.append(curEntry.getGuiName());
            if (curEntry.getGuiSize() == null)
                curEntry.setGuiSize(new JLabel(sizeInMegabytes(curEntry.getSizeBytes())));
            locationsBuilder.append(curEntry.getGuiSize());
            if (curEntry.getGuiLog() == null)
                curEntry.setGuiLog(new JLabel("Waiting..."));
            locationsBuilder.append(curEntry.getGuiLog(), 3);
            locationsBuilder.nextLine();
            if (entriesItr.hasNext()) {
                if (curEntry.getGuiSeparator() == null)
                    curEntry.setGuiSeparator(new JSeparator());
                locationsBuilder.append(curEntry.getGuiSeparator(), 7);
                locationsBuilder.nextLine();
            }
        }
    }

    locationsPane.validate();
}

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

/**
 * Instantiates a new movie batch editor.
 * /*from   ww  w  . j  a  v  a 2  s .  c  om*/
 * @param movies
 *          the movies
 */
public MovieBatchEditorDialog(final List<Movie> movies) {
    super(BUNDLE.getString("movie.edit"), "movieBatchEditor"); //$NON-NLS-1$
    setBounds(5, 5, 350, 230);
    getContentPane().setLayout(new BorderLayout(0, 0));

    {
        JPanel panelContent = new JPanel();
        getContentPane().add(panelContent, BorderLayout.CENTER);
        panelContent.setLayout(new FormLayout(new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC,
                FormSpecs.DEFAULT_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC,
                ColumnSpec.decode("default:grow"), FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC, FormSpecs.RELATED_GAP_COLSPEC, },
                new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.RELATED_GAP_ROWSPEC, 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.LABEL_COMPONENT_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, }));

        JLabel lblGenres = new JLabel(BUNDLE.getString("metatag.genre")); //$NON-NLS-1$
        panelContent.add(lblGenres, "2, 2, 2, 1, right, default");

        // cbGenres = new JComboBox(MediaGenres2.values());
        cbGenres = new AutocompleteComboBox(MediaGenres.values());
        cbGenres.setEditable(true);
        panelContent.add(cbGenres, "5, 2, fill, default");

        JButton btnAddGenre = new JButton("");
        btnAddGenre.setIcon(IconManager.LIST_ADD);
        btnAddGenre.setMargin(new Insets(2, 2, 2, 2));
        btnAddGenre.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                changed = true;
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                MediaGenres genre = null;
                Object item = cbGenres.getSelectedItem();

                // genre
                if (item instanceof MediaGenres) {
                    genre = (MediaGenres) item;
                }

                // newly created genre?
                if (item instanceof String) {
                    genre = MediaGenres.getGenre((String) item);
                }
                // MediaGenres2 genre = (MediaGenres2) cbGenres.getSelectedItem();
                if (genre != null) {
                    for (Movie movie : moviesToEdit) {
                        movie.addGenre(genre);
                    }
                }
                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        });
        panelContent.add(btnAddGenre, "7, 2");

        JButton btnRemoveGenre = new JButton("");
        btnRemoveGenre.setIcon(IconManager.LIST_REMOVE);
        btnRemoveGenre.setMargin(new Insets(2, 2, 2, 2));
        btnRemoveGenre.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                changed = true;
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                MediaGenres genre = (MediaGenres) cbGenres.getSelectedItem();
                for (Movie movie : moviesToEdit) {
                    movie.removeGenre(genre);
                }
                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        });
        panelContent.add(btnRemoveGenre, "9, 2");

        JLabel lblTags = new JLabel(BUNDLE.getString("metatag.tags")); //$NON-NLS-1$
        panelContent.add(lblTags, "2, 4, 2, 1, right, default");

        cbTags = new AutocompleteComboBox(movieList.getTagsInMovies().toArray());
        cbTags.setEditable(true);
        panelContent.add(cbTags, "5, 4, fill, default");

        JButton btnAddTag = new JButton("");
        btnAddTag.setIcon(IconManager.LIST_ADD);
        btnAddTag.setMargin(new Insets(2, 2, 2, 2));
        btnAddTag.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                changed = true;
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                String tag = (String) cbTags.getSelectedItem();
                if (StringUtils.isBlank(tag)) {
                    return;
                }

                for (Movie movie : moviesToEdit) {
                    movie.addToTags(tag);
                }
                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        });
        panelContent.add(btnAddTag, "7, 4");

        JButton btnRemoveTag = new JButton("");
        btnRemoveTag.setIcon(IconManager.LIST_REMOVE);
        btnRemoveTag.setMargin(new Insets(2, 2, 2, 2));
        btnRemoveTag.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                changed = true;
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                String tag = (String) cbTags.getSelectedItem();
                for (Movie movie : moviesToEdit) {
                    movie.removeFromTags(tag);
                }
                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        });
        panelContent.add(btnRemoveTag, "9, 4");

        JLabel lblCertification = new JLabel(BUNDLE.getString("metatag.certification")); //$NON-NLS-1$
        panelContent.add(lblCertification, "2, 6, 2, 1, right, default");

        final JComboBox cbCertification = new JComboBox();
        for (Certification cert : Certification
                .getCertificationsforCountry(MovieModuleManager.MOVIE_SETTINGS.getCertificationCountry())) {
            cbCertification.addItem(cert);
        }
        panelContent.add(cbCertification, "5, 6, fill, default");

        JButton btnCertification = new JButton("");
        btnCertification.setMargin(new Insets(2, 2, 2, 2));
        btnCertification.setIcon(IconManager.APPLY);
        btnCertification.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                changed = true;
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                Certification cert = (Certification) cbCertification.getSelectedItem();
                for (Movie movie : moviesToEdit) {
                    movie.setCertification(cert);
                    ;
                }
                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        });
        panelContent.add(btnCertification, "7, 6");

        JLabel lblMovieSet = new JLabel(BUNDLE.getString("metatag.movieset")); //$NON-NLS-1$
        panelContent.add(lblMovieSet, "2, 8, 2, 1, right, default");

        cbMovieSet = new JComboBox();
        panelContent.add(cbMovieSet, "5, 8, fill, default");

        JButton btnSetMovieSet = new JButton("");
        btnSetMovieSet.setMargin(new Insets(2, 2, 2, 2));
        btnSetMovieSet.setIcon(IconManager.APPLY);
        btnSetMovieSet.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                changed = true;
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                // movie set
                Object obj = cbMovieSet.getSelectedItem();
                for (Movie movie : moviesToEdit) {
                    if (obj instanceof String) {
                        movie.removeFromMovieSet();
                    }
                    if (obj instanceof MovieSet) {
                        MovieSet movieSet = (MovieSet) obj;

                        if (movie.getMovieSet() != movieSet) {
                            movie.removeFromMovieSet();
                            movie.setMovieSet(movieSet);
                            movieSet.insertMovie(movie);
                        }
                    }
                }
                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        });
        panelContent.add(btnSetMovieSet, "7, 8");

        JButton btnNewMovieset = new JButton("");
        btnNewMovieset.setMargin(new Insets(2, 2, 2, 2));
        btnNewMovieset.setAction(new MovieSetAddAction(false));
        panelContent.add(btnNewMovieset, "9, 8");

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

        chckbxWatched = new JCheckBox("");
        panelContent.add(chckbxWatched, "5, 10");

        JButton btnWatched = new JButton("");
        btnWatched.setMargin(new Insets(2, 2, 2, 2));
        btnWatched.setIcon(IconManager.APPLY);
        btnWatched.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                changed = true;
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                for (Movie movie : moviesToEdit) {
                    movie.setWatched(chckbxWatched.isSelected());
                }
                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        });
        panelContent.add(btnWatched, "7, 10");

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

        final JCheckBox chckbxVideo3D = new JCheckBox("");
        panelContent.add(chckbxVideo3D, "5, 12");

        JButton btnVideo3D = new JButton("");
        btnVideo3D.setMargin(new Insets(2, 2, 2, 2));
        btnVideo3D.setIcon(IconManager.APPLY);
        btnVideo3D.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                changed = true;
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                for (Movie movie : moviesToEdit) {
                    movie.setVideoIn3D(chckbxVideo3D.isSelected());
                }
                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        });
        panelContent.add(btnVideo3D, "7, 12");

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

        final JComboBox cbMediaSource = new JComboBox(MediaSource.values());
        panelContent.add(cbMediaSource, "5, 14, fill, default");

        JButton btnMediaSource = new JButton("");
        btnMediaSource.setMargin(new Insets(2, 2, 2, 2));
        btnMediaSource.setIcon(IconManager.APPLY);
        btnMediaSource.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                changed = true;
                Object obj = cbMediaSource.getSelectedItem();
                if (obj instanceof MediaSource) {
                    MediaSource mediaSource = (MediaSource) obj;
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    for (Movie movie : moviesToEdit) {
                        movie.setMediaSource(mediaSource);
                    }
                    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                }
            }
        });
        panelContent.add(btnMediaSource, "7, 14");

        JLabel lblLanguage = new JLabel(BUNDLE.getString("metatag.language")); //$NON-NLS-1$
        panelContent.add(lblLanguage, "2, 16, 2, 1, right, default");

        tfLanguage = new JTextField();
        panelContent.add(tfLanguage, "5, 16, fill, default");
        tfLanguage.setColumns(10);

        JButton btnLanguage = new JButton("");
        btnLanguage.setMargin(new Insets(2, 2, 2, 2));
        btnLanguage.setIcon(IconManager.APPLY);
        btnLanguage.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                changed = true;
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                for (Movie movie : moviesToEdit) {
                    movie.setSpokenLanguages(tfLanguage.getText());
                }
                setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
            }
        });
        panelContent.add(btnLanguage, "7, 16");
        {

            JLabel lblSorttitleT = new JLabel(BUNDLE.getString("metatag.sorttitle")); //$NON-NLS-1$
            panelContent.add(lblSorttitleT, "2, 18, right, default");

            JButton btnSetSorttitle = new JButton(BUNDLE.getString("edit.setsorttitle")); //$NON-NLS-1$
            btnSetSorttitle.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    changed = true;
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    for (Movie movie : moviesToEdit) {
                        movie.setSortTitle(movie.getTitleSortable());
                    }
                    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                }
            });

            JLabel lblSorttitleInfo = new JLabel(IconManager.HINT);
            lblSorttitleInfo.setToolTipText(BUNDLE.getString("edit.setsorttitle.desc")); //$NON-NLS-1$
            panelContent.add(lblSorttitleInfo, "3, 18");
            panelContent.add(btnSetSorttitle, "5, 18");

            JButton btnClearSorttitle = new JButton(BUNDLE.getString("edit.clearsorttitle")); //$NON-NLS-1$
            btnClearSorttitle.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    changed = true;
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    for (Movie movie : moviesToEdit) {
                        movie.setSortTitle("");
                    }
                    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                }
            });
            panelContent.add(btnClearSorttitle, "5, 20");
        }
    }

    {
        JPanel panelButtons = new JPanel();
        FlowLayout flowLayout = (FlowLayout) panelButtons.getLayout();
        flowLayout.setAlignment(FlowLayout.RIGHT);
        getContentPane().add(panelButtons, BorderLayout.SOUTH);

        JButton btnClose = new JButton(BUNDLE.getString("Button.close")); //$NON-NLS-1$
        btnClose.setIcon(IconManager.APPLY);
        btnClose.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                // rewrite movies, if anything changed
                if (changed) {
                    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                    for (Movie movie : moviesToEdit) {
                        movie.writeNFO();
                        movie.saveToDb();
                    }
                    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
                }
                setVisible(false);
            }
        });
        panelButtons.add(btnClose);

        // add window listener to write changes (if the window close button "X" is
        // pressed)
        addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                // rewrite movies, if anything changed
                if (changed) {
                    for (Movie movie : moviesToEdit) {
                        movie.writeNFO();
                        movie.saveToDb();
                    }
                    // if configured - sync with trakt.tv
                    if (MovieModuleManager.MOVIE_SETTINGS.getSyncTrakt()) {
                        TmmTask task = new SyncTraktTvTask(moviesToEdit, null);
                        TmmTaskManager.getInstance().addUnnamedTask(task);
                    }
                }
            }
        });
    }

    {
        setMovieSets();
        moviesToEdit = movies;

        PropertyChangeListener listener = new PropertyChangeListener() {
            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                if ("addedMovieSet".equals(evt.getPropertyName())) {
                    setMovieSets();
                }
            }
        };
        movieList.addPropertyChangeListener(listener);
    }
}