public static void instantiateDownloaded(JLabel update) {
    // These are found in the downloadedListenerClasses list
    for (Class<?> clazz : downloadedListenerClasses) {
      ExternalListener instance;

      try {
        doUpdate(update, Messages.getString("NetworkTab.48") + " " + clazz.getSimpleName());
        postInstall(clazz);
        LOGGER.debug("do inst of " + clazz.getSimpleName());
        instance = (ExternalListener) clazz.newInstance();
        doUpdate(update, instance.name() + " " + Messages.getString("NetworkTab.49"));
        registerListener(instance);

        if (PMS.get().getFrame() instanceof LooksFrame) {
          LooksFrame frame = (LooksFrame) PMS.get().getFrame();

          if (!frame.getPt().appendPlugin(instance)) {
            LOGGER.warn("Plugin limit of 30 has been reached");
          }
        }
      } catch (InstantiationException | IllegalAccessException e) {
        LOGGER.error("Error instantiating plugin", e);
      }
    }

    downloadedListenerClasses.clear();
  }
  @Override
  public JComponent config() {
    FormLayout layout =
        new FormLayout("left:pref, 3dlu, p, 3dlu, 0:grow", "p, 3dlu, p, 3dlu, 0:grow");
    PanelBuilder builder = new PanelBuilder(layout);
    builder.setBorder(Borders.EMPTY_BORDER);
    builder.setOpaque(false);

    CellConstraints cc = new CellConstraints();

    JComponent cmp = builder.addSeparator(Messages.getString("NetworkTab.5"), cc.xyw(1, 1, 5));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    builder.addLabel(Messages.getString("FFMpegDVRMSRemux.0"), cc.xy(1, 3));
    altffpath = new JTextField(PMS.getConfiguration().getFfmpegAlternativePath());
    altffpath.addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyTyped(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {
            PMS.getConfiguration().setFfmpegAlternativePath(altffpath.getText());
          }
        });
    builder.add(altffpath, cc.xyw(3, 3, 3));

    return builder.getPanel();
  }
 public static String getMsgString(String key, HttpExchange t) {
   if (PMS.getConfiguration().useWebLang()) {
     String lang = getFirstSupportedLanguage(t);
     if (!lang.isEmpty()) {
       return Messages.getString(key, Locale.forLanguageTag(lang));
     }
   }
   return Messages.getString(key);
 }
  public void cleanup() {
    Connection conn = null;
    PreparedStatement ps = null;
    ResultSet rs = null;

    try {
      conn = getConnection();
      ps = conn.prepareStatement("SELECT COUNT(*) FROM FILES");
      rs = ps.executeQuery();
      dbCount = 0;

      if (rs.next()) {
        dbCount = rs.getInt(1);
      }

      rs.close();
      ps.close();
      PMS.get().getFrame().setStatusLine(Messages.getString("DLNAMediaDatabase.2") + " 0%");
      int i = 0;
      int oldpercent = 0;

      if (dbCount > 0) {
        ps =
            conn.prepareStatement(
                "SELECT FILENAME, MODIFIED, ID FROM FILES",
                ResultSet.TYPE_FORWARD_ONLY,
                ResultSet.CONCUR_UPDATABLE);
        rs = ps.executeQuery();
        while (rs.next()) {
          String filename = rs.getString("FILENAME");
          long modified = rs.getTimestamp("MODIFIED").getTime();
          File file = new File(filename);
          if (!file.exists() || file.lastModified() != modified) {
            rs.deleteRow();
          }
          i++;
          int newpercent = i * 100 / dbCount;
          if (newpercent > oldpercent) {
            PMS.get()
                .getFrame()
                .setStatusLine(Messages.getString("DLNAMediaDatabase.2") + newpercent + "%");
            oldpercent = newpercent;
          }
        }
      }
    } catch (SQLException se) {
      LOGGER.error(null, se);
    } finally {
      close(rs);
      close(ps);
      close(conn);
    }
  }
示例#5
0
  /**
   * Constructor
   *
   * @param tagValues the initial tag values
   * @param canDelete
   */
  public TagLabelPanel(String tagName, List<String> tagValues, boolean canDelete) {
    setLayout(new BorderLayout(5, 3));

    this.tagName = tagName;

    // add add button
    initImageIcons();

    JLabel lAdd = new JLabel(iiAdd);
    lAdd.setToolTipText(Messages.getString("ML.TagLabelPanel.toolTipAdd"));
    lAdd.setCursor(new Cursor(Cursor.HAND_CURSOR));
    lAdd.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            createNewLabel();
          }
        });

    if (canDelete) {
      JPanel pOptions = new JPanel(new GridLayout(1, 2, 4, 0));
      pOptions.add(lAdd);

      JLabel lDelete = new JLabel(iiDelete);
      lDelete.setToolTipText(Messages.getString("ML.TagLabelPanel.toolTipDelete"));
      lDelete.setCursor(new Cursor(Cursor.HAND_CURSOR));
      lDelete.addMouseListener(
          new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
              fireActionEvent(ACTION_COMMAND_DELETE);
            }
          });
      pOptions.add(lDelete);

      add(pOptions, BorderLayout.LINE_START);
    } else {
      add(lAdd, BorderLayout.LINE_START);
    }

    // add all the tag values
    pTagValues = new JPanel(new WrapLayout(FlowLayout.LEFT, 0, 0));
    for (String tagValue : tagValues) {
      final TagLabel tl = createTagLabel(tagValue);
      pTagValues.add(tl);
    }
    add(pTagValues, BorderLayout.CENTER);
    refreshCommas();
  }
  private MultiselectJlist buildActivePluginsPanel(DOFileImportTemplate template) {
    // initialize the active plugins list view
    final MultiselectJlist newList =
        new MultiselectJlist(FileImportHelper.getAvailableEngineNames(fileType));
    newList.setCellRenderer(new ActiveEnginesListCellRenderer());
    newList.setBorder(
        new TitledBorder(Messages.getString("ML.FileImportPropertiesPanel.title.ActivePlugins")));
    newList.setBackground(getBackground());
    List<String> activeEngines = template.getEnabledEngines().get(fileType);
    if (activeEngines != null) {
      // collect the indexes to select in a List<Integer>
      List<Integer> engineIndexesToSelect = new ArrayList<Integer>();
      ListModel model = newList.getModel();
      for (String engineName : activeEngines) {
        for (int i = 0; i < model.getSize(); i++) {
          String currentEngine = model.getElementAt(i).toString();
          if (currentEngine.equals(engineName)) {
            engineIndexesToSelect.add(i);
            break;
          }
        }
      }

      // convert the List<Integer to int[]
      int[] indexesToSelect = new int[engineIndexesToSelect.size()];
      for (int i = 0; i < engineIndexesToSelect.size(); i++) {
        indexesToSelect[i] = engineIndexesToSelect.get(i);
      }
      newList.setSelectedIndices(indexesToSelect);
    }

    newList.addListSelectionListener(
        new ListSelectionListener() {

          @Override
          public void valueChanged(ListSelectionEvent e) {
            synchronized (this) {
              if (isHandlingPluginSelectionChange) return;
              isHandlingPluginSelectionChange = true;
            }

            try {
              ListModel model = newList.getModel();
              for (ActionListener l : activePluginsChangedListeners) {
                for (int i = e.getFirstIndex(); i < e.getLastIndex(); i++) {
                  l.actionPerformed(
                      new ActionEvent(
                          this,
                          newList.isSelectedIndex(i) ? 0 : 1,
                          model.getElementAt(i).toString()));
                }
              }
            } finally {
              isHandlingPluginSelectionChange = false;
            }
          }
        });

    return newList;
  }
示例#7
0
  @Override
  public JComponent config() {
    FormLayout layout =
        new FormLayout("left:pref, 0:grow", "p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, p, 3dlu, 0:grow");
    PanelBuilder builder = new PanelBuilder(layout);
    builder.setBorder(Borders.EMPTY_BORDER);
    builder.setOpaque(false);

    CellConstraints cc = new CellConstraints();

    JComponent cmp = builder.addSeparator("Audio settings", cc.xyw(2, 1, 1));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    noresample = new JCheckBox(Messages.getString("TrTab2.22"));
    noresample.setContentAreaFilled(false);
    noresample.setSelected(configuration.isAudioResample());
    noresample.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            configuration.setAudioResample(e.getStateChange() == ItemEvent.SELECTED);
          }
        });
    builder.add(noresample, cc.xy(2, 3));

    return builder.getPanel();
  }
  private void addChapterFolder(DLNAResource dlna) {
    if (!dlna.getFormat().isVideo()) {
      return;
    }

    int chapterInterval =
        configuration.isChapterSupport() ? configuration.getChapterInterval() : -1;

    if ((chapterInterval > 0) && isSeekable(dlna)) {
      // don't add a chapter folder if the duration of the video
      // is less than the chapter length.
      double duration = dlna.getMedia().getDurationInSeconds(); // 0 if the duration is unknown
      if (duration != 0 && duration <= (chapterInterval * 60)) {
        return;
      }

      ChapterFileTranscodeVirtualFolder chapterFolder =
          new ChapterFileTranscodeVirtualFolder(
              String.format(
                  Messages.getString("FileTranscodeVirtualFolder.1"), dlna.getDisplayName()),
              null,
              chapterInterval);
      DLNAResource copy = dlna.clone();
      copy.setNoName(true);
      chapterFolder.addChildInternal(copy);
      addChildInternal(chapterFolder);
    }
  }
 public void scanLibrary() {
   if (isScanLibraryRunning()) {
     LOGGER.info(Messages.getString("NetworkTab.70"));
   } else {
     scanner = new Thread(this, "Library Scanner");
     scanner.start();
   }
 }
示例#10
0
  private void init(DOQuickTagEntry entry, FileType fileType) {
    tfName = new JTextField(entry.getName());
    tfName.setEditable(true);

    cbTagValue = new TagValueComboBox(entry.getTagName());
    cbTagValue.setEditable(true);

    cbTagName = new TagNameComboBox(fileType);
    cbTagName.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            if (cbTagName.getSelectedItem() != null) {
              cbTagValue.setTagName(cbTagName.getSelectedItem().toString());
            }
          }
        });
    cbTagName.setEditable(true);

    cbTagName.setSelectedItem(entry.getTagName());
    cbTagValue.setSelectedItem(entry.getTagValue());

    cbKeyCombination = new JComboBox(keyCombinations);
    cbKeyCombination.setSelectedItem(new KeyCombinationCBItem(entry.getKeyCombination()));

    List<String> virtualKeys = new ArrayList<String>();
    // add numbers
    for (int i = 0; i < 10; i++) {
      virtualKeys.add(String.valueOf(i));
    }
    // add chars
    for (int i = (int) 'A'; i <= (int) 'Z'; i++) {
      virtualKeys.add(String.valueOf((char) i));
    }
    cbVirtualKey = new JComboBox(virtualKeys.toArray());
    cbVirtualKey.setSelectedItem(String.valueOf((char) entry.getKeyCode()));

    bDelete = new JButton();
    bDelete.setIcon(new ImageIcon(getClass().getResource("/resources/images/tp_remove.png")));
    bDelete.setToolTipText(Messages.getString("ML.QuickTagDialog.bRemoveToolTip"));
    bDelete.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            fireDelete();
          }
        });
  }
示例#11
0
  private void init() {
    this.typeOperators = new HashMap<ConditionType, ConditionOperatorCBItem[]>();

    for (ConditionType ct : ConditionType.values()) {
      ConditionOperator[] operators = getConditionOperatorForType(ct);
      ConditionOperatorCBItem[] op = new ConditionOperatorCBItem[operators.length];
      int i = 0;
      for (ConditionOperator co : operators) {
        try {
          String name;
          if (ct.toString().contains("_CONTAINS_")) {
            // use a different localization string for these conditions
            name = Messages.getString("ML.Condition.Operator.Contains." + co.toString());
          } else {
            name = Messages.getString("ML.Condition.Operator." + co.toString());
          }
          op[i++] = new ConditionOperatorCBItem(co, name);
        } catch (Exception ex) {
          log.error("Failed to initialize FolderHelper", ex);
        }
      }
      this.typeOperators.put(ct, op);
    }
  }
 public void compact() {
   LOGGER.info("Compacting database...");
   PMS.get().getFrame().setStatusLine(Messages.getString("DLNAMediaDatabase.3"));
   String filename = "database/backup.sql";
   try {
     Script.execute(url, "sa", "", filename);
     DeleteDbFiles.execute(dbDir, dbName, true);
     RunScript.execute(url, "sa", "", filename, null, false);
   } catch (SQLException se) {
     LOGGER.error("Error in compacting database: ", se);
   } finally {
     File testsql = new File(filename);
     if (testsql.exists() && !testsql.delete()) {
       testsql.deleteOnExit();
     }
   }
   PMS.get().getFrame().setStatusLine(null);
 }
  public JComponent buildEmpty() {
    String colSpec = FormLayoutUtil.getColSpec(EMPTY_COL_SPEC, orientation);
    FormLayout layout = new FormLayout(colSpec, EMPTY_ROW_SPEC);
    PanelBuilder builder = new PanelBuilder(layout);
    builder.setBorder(Borders.EMPTY_BORDER);
    builder.setOpaque(false);

    CellConstraints cc = new CellConstraints();

    builder.addSeparator(
        Messages.getString("TrTab2.1"), FormLayoutUtil.flip(cc.xyw(1, 1, 3), colSpec, orientation));

    JPanel panel = builder.getPanel();

    // Apply the orientation to the panel and all components in it
    panel.applyComponentOrientation(orientation);

    return panel;
  }
  @Override
  public synchronized void reset() {
    if (debugOutput != null) {
      try {
        debugOutput.close();
      } catch (IOException ex) {
        LOGGER.warn("Caught exception", ex);
      }
    }

    timer.cancel();

    if (buffer != null) {
      LOGGER.info("Destroying buffer");
      buffer = null;
    }

    buffered = false;

    if (maxMemorySize != 1048576) {
      PMS.get().getFrame().setValue(0, Messages.getString("StatusTab.5"));
    }
  }
示例#15
0
 public ConditionUnitCBItem getConditionUnitCBItem(ConditionUnit unit) {
   return new ConditionUnitCBItem(unit, Messages.getString("ML.Condition.Unit." + unit));
 }
  /**
   * This method must be called in a context synchronized on {@link #translationsStatistics}.
   *
   * <p>The sorting places the default/recommended choice on top of the list, and then tried to
   * place other relevant choices close to the top in descending order by relevance. The rest of the
   * list is alphabetical by the preferred/currently selected language's language names. The sorting
   * is done following these rules:
   *
   * <ul>
   *   <li>The base language (en-US) and the language closest matching <code>preferredLocale</code>
   *       is looked up. If the closest matching language has a coverage greater or equal to {@link
   *       #recommendedTranslatePct} or an approval greater or equal to {@link
   *       #recommendedApprovedPct} it will be placed on top. If not, the base language will be
   *       placed on top. Whichever of these is not placed on top is placed second. If a closely
   *       matching language cannot be found, only the base language will be placed on top.
   *   <li>A search for related languages is performed. Related is defined by either having the same
   *       language code (e.g "en") or the same country code as <code>preferredLocale</code>.
   *       Related languages are then sorted descending by coverage and put after that or those
   *       language(s) placed on top.
   *   <li>The rest of the languages are listed alphabetically based on their localized (from
   *       currently chosen language) names.
   * </ul>
   *
   * If the localized language name differs from the English language name, the English language
   * name is shown in parenthesis. This is to help in case the localized names are incomprehensible
   * to the user.
   */
  private static void createSortedList(Locale preferredLocale) {
    if (preferredLocale == null) {
      throw new IllegalArgumentException("preferredLocale cannot be null");
    }
    if (lastpreferredLocale == null || !lastpreferredLocale.equals(preferredLocale)) {
      // Populate
      lastpreferredLocale = preferredLocale;
      sortedLanguages.clear();
      populateTranslationsStatistics();
      for (String tag : UMS_BCP47_CODES) {
        LanguageEntry entry = new LanguageEntry();
        entry.tag = tag;
        entry.name = Messages.getString("Language." + tag, preferredLocale);
        if (!entry.name.equals(Messages.getRootString("Language." + tag))) {
          entry.name += " (" + Messages.getRootString("Language." + tag) + ")";
        }
        entry.locale = Locale.forLanguageTag(tag);
        if (tag.equals("en-US")) {
          entry.coveragePercent = 100;
          entry.approvedPercent = 100;
        } else {
          TranslationStatistics stats = translationsStatistics.get(tag);
          if (stats != null) {
            if (entry.locale.getLanguage().equals("en") && stats.wordsTranslated > 0) {
              /* Special case for English language variants that only
               * overrides the strings that differ from US English.
               * We cannot find coverage for these */
              entry.coveragePercent = 100;
              entry.approvedPercent = 100;
            } else {
              entry.coveragePercent = stats.translated;
              entry.approvedPercent = stats.approved;
            }
          } else {
            entry.coveragePercent = 0;
            entry.approvedPercent = 0;
            LOGGER.debug("Warning: Could not find language statistics for {}", entry.name);
          }
        }

        if (entry.coveragePercent >= minimumTranslatePct) {
          sortedLanguages.add(entry);
        }
      }

      // Sort
      Collections.sort(sortedLanguages);

      // Put US English first
      LanguageEntry baseLanguage = getSortedLanguageByTag("en-US");
      if (baseLanguage == null) {
        throw new IllegalStateException(
            "Languages.createSortedList encountered an impossible situation");
      }
      if (sortedLanguages.remove(baseLanguage)) {
        sortedLanguages.add(0, baseLanguage);
      }
      ;

      // Put matched language first or second depending on coverage
      LanguageEntry preferredLanguage = getSortedLanguageByLocale(preferredLocale);
      if (preferredLanguage != null && !preferredLanguage.tag.equals("en-US")) {
        if (sortedLanguages.remove(preferredLanguage) && isRecommended(preferredLanguage)) {
          sortedLanguages.add(0, preferredLanguage);
        } else {
          /* This could constitute a bug if sortedLanguages.remove(entry)
           * returned false, but that should be impossible */
          sortedLanguages.add(1, preferredLanguage);
        }
      }

      // Put related language(s) close to top
      List<LanguageEntry> relatedLanguages = new ArrayList<>();
      for (LanguageEntry entry : sortedLanguages) {
        if (entry != baseLanguage
            && entry != preferredLanguage
            && (!preferredLocale.getCountry().isEmpty()
                    && preferredLocale.getCountry().equals(entry.locale.getCountry())
                || !preferredLocale.getLanguage().isEmpty()
                    && preferredLocale.getLanguage().equals(entry.locale.getLanguage()))) {
          relatedLanguages.add(entry);
        }
      }
      if (relatedLanguages.size() > 0) {
        sortedLanguages.removeAll(relatedLanguages);
        Collections.sort(relatedLanguages, new LanguageEntryCoverageComparator());
        sortedLanguages.addAll(
            preferredLanguage == null || preferredLanguage.equals(baseLanguage) ? 1 : 2,
            relatedLanguages);
      }
    }
  }
示例#17
0
  private void refresh() {
    if (isInitializing) {
      return;
    }

    // create the rows string
    String rowsString = "5px, p, 5px, ";
    if (quickTagEntryPanels.size() > 0) {
      for (int i = 0; i < quickTagEntryPanels.size(); i++) {
        rowsString += "p, 3px, ";
      }
      rowsString = rowsString.substring(0, rowsString.length() - 5);
    }
    rowsString += "5px";

    FormLayout layout =
        new FormLayout(
            "5px, 135, 5px, 135, 5px, f:210:g, 5px, p, 2px, p, 2px, p, 5px, p, 5px", rowsString);
    PanelBuilder builder = new PanelBuilder(layout);
    builder.opaque(true);

    CellConstraints cc = new CellConstraints();

    // add the headers
    int rowIndex = 2;
    builder.add(
        new JHeader(Messages.getString("ML.QuickTagDialog.Header.Name")),
        cc.xy(2, rowIndex, CellConstraints.CENTER, CellConstraints.DEFAULT));
    builder.add(
        new JHeader(Messages.getString("ML.QuickTagDialog.Header.TagName")),
        cc.xy(4, rowIndex, CellConstraints.CENTER, CellConstraints.DEFAULT));
    builder.add(
        new JHeader(Messages.getString("ML.QuickTagDialog.Header.TagValue")),
        cc.xy(6, rowIndex, CellConstraints.CENTER, CellConstraints.DEFAULT));
    builder.add(
        new JHeader(Messages.getString("ML.QuickTagDialog.Header.HotKey")),
        cc.xyw(8, rowIndex, 5, CellConstraints.CENTER, CellConstraints.DEFAULT));

    // add the entries
    for (QuickTagEntryPanel pEntry : quickTagEntryPanels) {
      rowIndex += 2;

      builder.add(pEntry.getTfName(), cc.xy(2, rowIndex));
      builder.add(pEntry.getCbTagName(), cc.xy(4, rowIndex));
      builder.add(pEntry.getCbTagValue(), cc.xy(6, rowIndex));
      builder.add(pEntry.getCbKeyCombination(), cc.xy(8, rowIndex));
      builder.addLabel("+", cc.xy(10, rowIndex));
      builder.add(pEntry.getCbVirtualKey(), cc.xy(12, rowIndex));
      builder.add(pEntry.getbDelete(), cc.xy(14, rowIndex));
    }

    removeAll();

    JScrollPane spMain = new JScrollPane(builder.getPanel());
    spMain.setBorder(BorderFactory.createEmptyBorder());

    add(spMain);

    validate();
    repaint();
  }
  public JComponent buildCommon() {
    String colSpec = FormLayoutUtil.getColSpec(COMMON_COL_SPEC, orientation);
    FormLayout layout = new FormLayout(colSpec, COMMON_ROW_SPEC);
    PanelBuilder builder = new PanelBuilder(layout);
    builder.setBorder(Borders.EMPTY_BORDER);
    builder.setOpaque(false);

    CellConstraints cc = new CellConstraints();

    maxbuffer = new JTextField("" + configuration.getMaxMemoryBufferSize());
    maxbuffer.addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyTyped(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {
            try {
              int ab = Integer.parseInt(maxbuffer.getText());
              configuration.setMaxMemoryBufferSize(ab);
            } catch (NumberFormatException nfe) {
              LOGGER.debug(
                  "Could not parse max memory buffer size from \"" + maxbuffer.getText() + "\"");
            }
          }
        });

    JComponent cmp =
        builder.addSeparator(
            Messages.getString("NetworkTab.5"),
            FormLayoutUtil.flip(cc.xyw(1, 1, 3), colSpec, orientation));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    builder.addLabel(
        Messages.getString("TrTab2.23")
            .replaceAll("MAX_BUFFER_SIZE", configuration.getMaxMemoryBufferSizeStr()),
        FormLayoutUtil.flip(cc.xy(1, 3), colSpec, orientation));
    builder.add(maxbuffer, FormLayoutUtil.flip(cc.xy(3, 3), colSpec, orientation));

    builder.addLabel(
        Messages.getString("TrTab2.24") + Runtime.getRuntime().availableProcessors() + ")",
        FormLayoutUtil.flip(cc.xy(1, 5), colSpec, orientation));

    String[] guiCores = new String[MAX_CORES];
    for (int i = 0; i < MAX_CORES; i++) {
      guiCores[i] = Integer.toString(i + 1);
    }
    nbcores = new JComboBox(guiCores);
    nbcores.setEditable(false);
    int nbConfCores = configuration.getNumberOfCpuCores();
    if (nbConfCores > 0 && nbConfCores <= MAX_CORES) {
      nbcores.setSelectedItem(Integer.toString(nbConfCores));
    } else {
      nbcores.setSelectedIndex(0);
    }

    nbcores.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            configuration.setNumberOfCpuCores(Integer.parseInt(e.getItem().toString()));
          }
        });
    builder.add(nbcores, FormLayoutUtil.flip(cc.xy(3, 5), colSpec, orientation));

    chapter_interval = new JTextField("" + configuration.getChapterInterval());
    chapter_interval.setEnabled(configuration.isChapterSupport());
    chapter_interval.addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyTyped(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {
            try {
              int ab = Integer.parseInt(chapter_interval.getText());
              configuration.setChapterInterval(ab);
            } catch (NumberFormatException nfe) {
              LOGGER.debug(
                  "Could not parse chapter interval from \"" + chapter_interval.getText() + "\"");
            }
          }
        });

    chapter_support = new JCheckBox(Messages.getString("TrTab2.52"));
    chapter_support.setContentAreaFilled(false);
    chapter_support.setSelected(configuration.isChapterSupport());

    chapter_support.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            configuration.setChapterSupport((e.getStateChange() == ItemEvent.SELECTED));
            chapter_interval.setEnabled(configuration.isChapterSupport());
          }
        });

    builder.add(chapter_support, FormLayoutUtil.flip(cc.xy(1, 7), colSpec, orientation));

    builder.add(chapter_interval, FormLayoutUtil.flip(cc.xy(3, 7), colSpec, orientation));

    cmp =
        builder.addSeparator(
            Messages.getString("TrTab2.3"),
            FormLayoutUtil.flip(cc.xyw(1, 11, 3), colSpec, orientation));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    channels =
        new JComboBox(
            new Object[] {
              Messages.getString("TrTab2.55"),
              Messages.getString("TrTab2.56") /*, "8 channels 7.1" */
            }); // 7.1 not supported by MPlayer :\
    channels.setEditable(false);
    if (configuration.getAudioChannelCount() == 2) {
      channels.setSelectedIndex(0);
    } else {
      channels.setSelectedIndex(1);
    }
    channels.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            configuration.setAudioChannelCount(
                Integer.parseInt(e.getItem().toString().substring(0, 1)));
          }
        });

    builder.addLabel(
        Messages.getString("TrTab2.50"), FormLayoutUtil.flip(cc.xy(1, 13), colSpec, orientation));
    builder.add(channels, FormLayoutUtil.flip(cc.xy(3, 13), colSpec, orientation));

    forcePCM = new JCheckBox(Messages.getString("TrTab2.27"));
    forcePCM.setContentAreaFilled(false);
    if (configuration.isMencoderUsePcm()) {
      forcePCM.setSelected(true);
    }
    forcePCM.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            configuration.setMencoderUsePcm(e.getStateChange() == ItemEvent.SELECTED);
          }
        });

    builder.add(forcePCM, FormLayoutUtil.flip(cc.xyw(1, 15, 3), colSpec, orientation));

    ac3remux =
        new JCheckBox(
            Messages.getString("TrTab2.26")
                + " "
                + (Platform.isWindows() ? Messages.getString("TrTab2.21") : ""));
    ac3remux.setContentAreaFilled(false);
    if (configuration.isRemuxAC3()) {
      ac3remux.setSelected(true);
    }
    ac3remux.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            configuration.setRemuxAC3((e.getStateChange() == ItemEvent.SELECTED));
          }
        });

    builder.add(ac3remux, FormLayoutUtil.flip(cc.xyw(1, 17, 3), colSpec, orientation));

    forceDTSinPCM =
        new JCheckBox(
            Messages.getString("TrTab2.28")
                + " "
                + (Platform.isWindows() ? Messages.getString("TrTab2.21") : ""));
    forceDTSinPCM.setContentAreaFilled(false);
    if (configuration.isDTSEmbedInPCM()) {
      forceDTSinPCM.setSelected(true);
    }
    forceDTSinPCM.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            configuration.setDTSEmbedInPCM(forceDTSinPCM.isSelected());
            if (configuration.isDTSEmbedInPCM()) {
              JOptionPane.showMessageDialog(
                  (JFrame) (SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame())),
                  Messages.getString("TrTab2.10"),
                  "Information",
                  JOptionPane.INFORMATION_MESSAGE);
            }
          }
        });

    builder.add(forceDTSinPCM, FormLayoutUtil.flip(cc.xyw(1, 19, 3), colSpec, orientation));

    abitrate = new JTextField("" + configuration.getAudioBitrate());
    abitrate.addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyTyped(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {
            try {
              int ab = Integer.parseInt(abitrate.getText());
              configuration.setAudioBitrate(ab);
            } catch (NumberFormatException nfe) {
              LOGGER.debug("Could not parse audio bitrate from \"" + abitrate.getText() + "\"");
            }
          }
        });

    builder.addLabel(
        Messages.getString("TrTab2.29"), FormLayoutUtil.flip(cc.xy(1, 21), colSpec, orientation));
    builder.add(abitrate, FormLayoutUtil.flip(cc.xy(3, 21), colSpec, orientation));

    mpeg2remux =
        new JCheckBox(
            Messages.getString("MEncoderVideo.39")
                + (Platform.isWindows() ? Messages.getString("TrTab2.21") : ""));
    mpeg2remux.setContentAreaFilled(false);
    if (configuration.isMencoderRemuxMPEG2()) {
      mpeg2remux.setSelected(true);
    }
    mpeg2remux.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            configuration.setMencoderRemuxMPEG2((e.getStateChange() == ItemEvent.SELECTED));
          }
        });

    builder.add(mpeg2remux, FormLayoutUtil.flip(cc.xyw(1, 23, 3), colSpec, orientation));

    cmp =
        builder.addSeparator(
            Messages.getString("TrTab2.4"),
            FormLayoutUtil.flip(cc.xyw(1, 25, 3), colSpec, orientation));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    builder.addLabel(
        Messages.getString("TrTab2.32"),
        FormLayoutUtil.flip(cc.xyw(1, 29, 3), colSpec, orientation));

    Object data[] =
        new Object[] {
          configuration.getMencoderMainSettings(), /* default */
          String.format(
              "keyint=5:vqscale=1:vqmin=2  /* %s */", Messages.getString("TrTab2.60")), /* great */
          String.format(
              "keyint=5:vqscale=1:vqmin=1  /* %s */",
              Messages.getString("TrTab2.61")), /* lossless */
          String.format(
              "keyint=5:vqscale=2:vqmin=3  /* %s */",
              Messages.getString("TrTab2.62")), /* good (wired) */
          String.format(
              "keyint=25:vqmax=5:vqmin=2  /* %s */",
              Messages.getString("TrTab2.63")), /* good (wireless) */
          String.format(
              "keyint=25:vqmax=7:vqmin=2  /* %s */",
              Messages.getString("TrTab2.64")), /* medium (wireless) */
          String.format(
              "keyint=25:vqmax=8:vqmin=3  /* %s */", Messages.getString("TrTab2.65")) /* low */
        };

    MyComboBoxModel cbm = new MyComboBoxModel(data);

    vq = new JComboBox(cbm);
    vq.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
              String s = (String) e.getItem();
              if (s.indexOf("/*") > -1) {
                s = s.substring(0, s.indexOf("/*")).trim();
              }
              configuration.setMencoderMainSettings(s);
            }
          }
        });
    vq.getEditor()
        .getEditorComponent()
        .addKeyListener(
            new KeyListener() {
              @Override
              public void keyPressed(KeyEvent e) {}

              @Override
              public void keyTyped(KeyEvent e) {}

              @Override
              public void keyReleased(KeyEvent e) {
                vq.getItemListeners()[0].itemStateChanged(
                    new ItemEvent(vq, 0, vq.getEditor().getItem(), ItemEvent.SELECTED));
              }
            });
    vq.setEditable(true);
    builder.add(vq, FormLayoutUtil.flip(cc.xyw(1, 31, 3), colSpec, orientation));

    String help1 = Messages.getString("TrTab2.39");
    help1 += Messages.getString("TrTab2.40");
    help1 += Messages.getString("TrTab2.41");
    help1 += Messages.getString("TrTab2.42");
    help1 += Messages.getString("TrTab2.43");
    help1 += Messages.getString("TrTab2.44");

    JTextArea decodeTips = new JTextArea(help1);
    decodeTips.setEditable(false);
    decodeTips.setBorder(BorderFactory.createEtchedBorder());
    decodeTips.setBackground(new Color(255, 255, 192));
    builder.add(decodeTips, FormLayoutUtil.flip(cc.xyw(1, 41, 3), colSpec, orientation));

    disableSubs = new JCheckBox(Messages.getString("TrTab2.51"));
    disableSubs.setContentAreaFilled(false);

    cmp =
        builder.addSeparator(
            Messages.getString("TrTab2.7"),
            FormLayoutUtil.flip(cc.xyw(1, 33, 3), colSpec, orientation));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    builder.add(disableSubs, FormLayoutUtil.flip(cc.xy(1, 35), colSpec, orientation));

    builder.addLabel(
        Messages.getString("TrTab2.8"), FormLayoutUtil.flip(cc.xy(1, 37), colSpec, orientation));

    notranscode = new JTextField(configuration.getNoTranscode());
    notranscode.addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyTyped(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {
            configuration.setNoTranscode(notranscode.getText());
          }
        });
    builder.add(notranscode, FormLayoutUtil.flip(cc.xy(3, 37), colSpec, orientation));

    builder.addLabel(
        Messages.getString("TrTab2.9"), FormLayoutUtil.flip(cc.xy(1, 39), colSpec, orientation));

    forcetranscode = new JTextField(configuration.getForceTranscode());
    forcetranscode.addKeyListener(
        new KeyListener() {
          @Override
          public void keyPressed(KeyEvent e) {}

          @Override
          public void keyTyped(KeyEvent e) {}

          @Override
          public void keyReleased(KeyEvent e) {
            configuration.setForceTranscode(forcetranscode.getText());
          }
        });
    builder.add(forcetranscode, FormLayoutUtil.flip(cc.xy(3, 39), colSpec, orientation));

    JPanel panel = builder.getPanel();

    // Apply the orientation to the panel and all components in it
    panel.applyComponentOrientation(orientation);

    return panel;
  }
  public JComponent buildLeft() {
    String colSpec = FormLayoutUtil.getColSpec(LEFT_COL_SPEC, orientation);
    FormLayout layout = new FormLayout(colSpec, LEFT_ROW_SPEC);
    PanelBuilder builder = new PanelBuilder(layout);
    builder.setBorder(Borders.EMPTY_BORDER);
    builder.setOpaque(false);

    CellConstraints cc = new CellConstraints();

    JButton but = new JButton(LooksFrame.readImageIcon("kdevelop_down-32.png"));
    but.setToolTipText(Messages.getString("TrTab2.6"));
    but.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            TreePath path = tree.getSelectionModel().getSelectionPath();
            if (path != null && path.getLastPathComponent() instanceof TreeNodeSettings) {
              TreeNodeSettings node = ((TreeNodeSettings) path.getLastPathComponent());
              if (node.getPlayer() != null) {
                DefaultTreeModel dtm = (DefaultTreeModel) tree.getModel(); // get the tree model
                // now get the index of the selected node in the DefaultTreeModel
                int index = dtm.getIndexOfChild(node.getParent(), node);
                // if selected node is first, return (can't move it up)
                if (index < node.getParent().getChildCount() - 1) {
                  dtm.insertNodeInto(
                      node, (DefaultMutableTreeNode) node.getParent(), index + 1); // move the node
                  dtm.reload();
                  for (int i = 0; i < tree.getRowCount(); i++) {
                    tree.expandRow(i);
                  }
                  tree.getSelectionModel().setSelectionPath(new TreePath(node.getPath()));
                  updateEngineModel();
                }
              }
            }
          }
        });
    builder.add(but, FormLayoutUtil.flip(cc.xy(2, 3), colSpec, orientation));

    JButton but2 = new JButton(LooksFrame.readImageIcon("up-32.png"));
    but2.setToolTipText(Messages.getString("TrTab2.6"));
    but2.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            TreePath path = tree.getSelectionModel().getSelectionPath();
            if (path != null && path.getLastPathComponent() instanceof TreeNodeSettings) {
              TreeNodeSettings node = ((TreeNodeSettings) path.getLastPathComponent());
              if (node.getPlayer() != null) {
                DefaultTreeModel dtm = (DefaultTreeModel) tree.getModel(); // get the tree model
                // now get the index of the selected node in the DefaultTreeModel
                int index = dtm.getIndexOfChild(node.getParent(), node);
                // if selected node is first, return (can't move it up)
                if (index != 0) {
                  dtm.insertNodeInto(
                      node, (DefaultMutableTreeNode) node.getParent(), index - 1); // move the node
                  dtm.reload();
                  for (int i = 0; i < tree.getRowCount(); i++) {
                    tree.expandRow(i);
                  }
                  tree.getSelectionModel().setSelectionPath(new TreePath(node.getPath()));
                  updateEngineModel();
                }
              }
            }
          }
        });
    builder.add(but2, FormLayoutUtil.flip(cc.xy(3, 3), colSpec, orientation));

    JButton but3 = new JButton(LooksFrame.readImageIcon("connect_no-32.png"));
    but3.setToolTipText(Messages.getString("TrTab2.0"));
    but3.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            TreePath path = tree.getSelectionModel().getSelectionPath();
            if (path != null
                && path.getLastPathComponent() instanceof TreeNodeSettings
                && ((TreeNodeSettings) path.getLastPathComponent()).getPlayer() != null) {
              ((TreeNodeSettings) path.getLastPathComponent())
                  .setEnable(!((TreeNodeSettings) path.getLastPathComponent()).isEnable());
              updateEngineModel();
              tree.updateUI();
            }
          }
        });
    builder.add(but3, FormLayoutUtil.flip(cc.xy(4, 3), colSpec, orientation));

    DefaultMutableTreeNode root = new DefaultMutableTreeNode(Messages.getString("TrTab2.11"));
    TreeNodeSettings commonEnc =
        new TreeNodeSettings(Messages.getString("TrTab2.5"), null, buildCommon());
    commonEnc
        .getConfigPanel()
        .addComponentListener(
            new ComponentAdapter() {
              @Override
              public void componentShown(ComponentEvent e) {
                handleCardComponentChange(e.getComponent());
              }
            });
    tabbedPane.add(commonEnc.id(), commonEnc.getConfigPanel());
    root.add(commonEnc);

    parent = new DefaultMutableTreeNode[5];
    parent[0] = new DefaultMutableTreeNode(Messages.getString("TrTab2.14"));
    parent[1] = new DefaultMutableTreeNode(Messages.getString("TrTab2.15"));
    parent[2] = new DefaultMutableTreeNode(Messages.getString("TrTab2.16"));
    parent[3] = new DefaultMutableTreeNode(Messages.getString("TrTab2.17"));
    parent[4] = new DefaultMutableTreeNode(Messages.getString("TrTab2.18"));
    root.add(parent[0]);
    root.add(parent[1]);
    root.add(parent[2]);
    root.add(parent[3]);
    root.add(parent[4]);

    tree =
        new JTree(new DefaultTreeModel(root)) {
          private static final long serialVersionUID = -6703434752606636290L;
        };
    tree.setRootVisible(false);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.addTreeSelectionListener(
        new TreeSelectionListener() {
          @Override
          public void valueChanged(TreeSelectionEvent e) {
            if (e.getNewLeadSelectionPath() != null
                && e.getNewLeadSelectionPath().getLastPathComponent() instanceof TreeNodeSettings) {
              TreeNodeSettings tns =
                  (TreeNodeSettings) e.getNewLeadSelectionPath().getLastPathComponent();
              cl.show(tabbedPane, tns.id());
            }
          }
        });

    tree.setCellRenderer(new TreeRenderer());
    JScrollPane pane =
        new JScrollPane(
            tree, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);

    builder.add(pane, FormLayoutUtil.flip(cc.xyw(2, 1, 4), colSpec, orientation));

    builder.addLabel(
        Messages.getString("TrTab2.19"),
        FormLayoutUtil.flip(cc.xyw(2, 5, 4), colSpec, orientation));
    builder.addLabel(
        Messages.getString("TrTab2.20"),
        FormLayoutUtil.flip(cc.xyw(2, 7, 4), colSpec, orientation));

    JPanel panel = builder.getPanel();

    // Apply the orientation to the panel and all components in it
    panel.applyComponentOrientation(orientation);

    return panel;
  }
  public void init(boolean force) {
    dbCount = -1;
    String version = null;
    Connection conn = null;
    ResultSet rs = null;
    Statement stmt = null;

    try {
      conn = getConnection();
    } catch (SQLException se) {
      final File dbFile = new File(dbDir + File.separator + dbName + ".data.db");
      final File dbDirectory = new File(dbDir);
      if (dbFile.exists()
          || (se.getErrorCode() == 90048)) { // Cache is corrupt or a wrong version, so delete it
        FileUtils.deleteQuietly(dbDirectory);
        if (!dbDirectory.exists()) {
          LOGGER.info(
              "The database has been deleted because it was corrupt or had the wrong version");
        } else {
          if (!net.pms.PMS.isHeadless()) {
            JOptionPane.showMessageDialog(
                SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame()),
                String.format(Messages.getString("DLNAMediaDatabase.5"), dbDir),
                Messages.getString("Dialog.Error"),
                JOptionPane.ERROR_MESSAGE);
          }
          LOGGER.error(
              "Damaged cache can't be deleted. Stop the program and delete the folder \""
                  + dbDir
                  + "\" manually");
          PMS.get().getRootFolder(null).stopScan();
          configuration.setUseCache(false);
          return;
        }
      } else {
        LOGGER.error("Database connection error: " + se.getMessage());
        LOGGER.trace("", se);
        RootFolder rootFolder = PMS.get().getRootFolder(null);
        if (rootFolder != null) {
          rootFolder.stopScan();
        }
        configuration.setUseCache(false);
        return;
      }
    } finally {
      close(conn);
    }

    try {
      conn = getConnection();

      stmt = conn.createStatement();
      rs = stmt.executeQuery("SELECT count(*) FROM FILES");
      if (rs.next()) {
        dbCount = rs.getInt(1);
      }
      rs.close();
      stmt.close();

      stmt = conn.createStatement();
      rs = stmt.executeQuery("SELECT VALUE FROM METADATA WHERE KEY = 'VERSION'");
      if (rs.next()) {
        version = rs.getString(1);
      }
    } catch (SQLException se) {
      if (se.getErrorCode()
          != 42102) { // Don't log exception "Table "FILES" not found" which will be corrected in
                      // following step
        LOGGER.error(null, se);
      }
    } finally {
      close(rs);
      close(stmt);
      close(conn);
    }

    // Recreate database if it is not the latest version.
    boolean force_reinit = !latestVersion.equals(version);
    if (force || dbCount == -1 || force_reinit) {
      LOGGER.debug("Database will be (re)initialized");
      try {
        conn = getConnection();
        executeUpdate(conn, "DROP TABLE FILES");
        executeUpdate(conn, "DROP TABLE METADATA");
        executeUpdate(conn, "DROP TABLE REGEXP_RULES");
        executeUpdate(conn, "DROP TABLE AUDIOTRACKS");
        executeUpdate(conn, "DROP TABLE SUBTRACKS");
      } catch (SQLException se) {
        if (se.getErrorCode()
            != 42102) { // Don't log exception "Table "FILES" not found" which will be corrected in
                        // following step
          LOGGER.error(null, se);
        }
      }
      try {
        StringBuilder sb = new StringBuilder();
        sb.append("CREATE TABLE FILES (");
        sb.append("  ID                      INT AUTO_INCREMENT");
        sb.append(", FILENAME                VARCHAR2(1024)   NOT NULL");
        sb.append(", MODIFIED                TIMESTAMP        NOT NULL");
        sb.append(", TYPE                    INT");
        sb.append(", DURATION                DOUBLE");
        sb.append(", BITRATE                 INT");
        sb.append(", WIDTH                   INT");
        sb.append(", HEIGHT                  INT");
        sb.append(", SIZE                    NUMERIC");
        sb.append(", CODECV                  VARCHAR2(").append(SIZE_CODECV).append(')');
        sb.append(", FRAMERATE               VARCHAR2(").append(SIZE_FRAMERATE).append(')');
        sb.append(", ASPECT                  VARCHAR2(")
            .append(SIZE_ASPECTRATIO_DVDISO)
            .append(')');
        sb.append(", ASPECTRATIOCONTAINER    VARCHAR2(")
            .append(SIZE_ASPECTRATIO_CONTAINER)
            .append(')');
        sb.append(", ASPECTRATIOVIDEOTRACK   VARCHAR2(")
            .append(SIZE_ASPECTRATIO_VIDEOTRACK)
            .append(')');
        sb.append(", REFRAMES                TINYINT");
        sb.append(", AVCLEVEL                VARCHAR2(").append(SIZE_AVC_LEVEL).append(')');
        sb.append(", BITSPERPIXEL            INT");
        sb.append(", THUMB                   BINARY");
        sb.append(", CONTAINER               VARCHAR2(").append(SIZE_CONTAINER).append(')');
        sb.append(", MODEL                   VARCHAR2(").append(SIZE_MODEL).append(')');
        sb.append(", EXPOSURE                INT");
        sb.append(", ORIENTATION             INT");
        sb.append(", ISO                     INT");
        sb.append(", MUXINGMODE              VARCHAR2(").append(SIZE_MUXINGMODE).append(')');
        sb.append(", FRAMERATEMODE           VARCHAR2(").append(SIZE_FRAMERATE_MODE).append(')');
        sb.append(", STEREOSCOPY             VARCHAR2(").append(SIZE_STEREOSCOPY).append(')');
        sb.append(", MATRIXCOEFFICIENTS      VARCHAR2(")
            .append(SIZE_MATRIX_COEFFICIENTS)
            .append(')');
        sb.append(", TITLECONTAINER          VARCHAR2(").append(SIZE_TITLE).append(')');
        sb.append(", TITLEVIDEOTRACK         VARCHAR2(").append(SIZE_TITLE).append(')');
        sb.append(", VIDEOTRACKCOUNT         INT");
        sb.append(", IMAGECOUNT              INT");
        sb.append(", BITDEPTH                INT");
        sb.append(", constraint PK1 primary key (FILENAME, MODIFIED, ID))");
        executeUpdate(conn, sb.toString());
        sb = new StringBuilder();
        sb.append("CREATE TABLE AUDIOTRACKS (");
        sb.append("  FILEID            INT              NOT NULL");
        sb.append(", ID                INT              NOT NULL");
        sb.append(", LANG              VARCHAR2(").append(SIZE_LANG).append(')');
        sb.append(", TITLE             VARCHAR2(").append(SIZE_TITLE).append(')');
        sb.append(", NRAUDIOCHANNELS   NUMERIC");
        sb.append(", SAMPLEFREQ        VARCHAR2(").append(SIZE_SAMPLEFREQ).append(')');
        sb.append(", CODECA            VARCHAR2(").append(SIZE_CODECA).append(')');
        sb.append(", BITSPERSAMPLE     INT");
        sb.append(", ALBUM             VARCHAR2(").append(SIZE_ALBUM).append(')');
        sb.append(", ARTIST            VARCHAR2(").append(SIZE_ARTIST).append(')');
        sb.append(", SONGNAME          VARCHAR2(").append(SIZE_SONGNAME).append(')');
        sb.append(", GENRE             VARCHAR2(").append(SIZE_GENRE).append(')');
        sb.append(", YEAR              INT");
        sb.append(", TRACK             INT");
        sb.append(", DELAY             INT");
        sb.append(", MUXINGMODE        VARCHAR2(").append(SIZE_MUXINGMODE).append(')');
        sb.append(", BITRATE           INT");
        sb.append(", constraint PKAUDIO primary key (FILEID, ID))");
        executeUpdate(conn, sb.toString());
        sb = new StringBuilder();
        sb.append("CREATE TABLE SUBTRACKS (");
        sb.append("  FILEID   INT              NOT NULL");
        sb.append(", ID       INT              NOT NULL");
        sb.append(", LANG     VARCHAR2(").append(SIZE_LANG).append(')');
        sb.append(", TITLE    VARCHAR2(").append(SIZE_TITLE).append(')');
        sb.append(", TYPE     INT");
        sb.append(", constraint PKSUB primary key (FILEID, ID))");

        executeUpdate(conn, sb.toString());
        executeUpdate(
            conn,
            "CREATE TABLE METADATA (KEY VARCHAR2(255) NOT NULL, VALUE VARCHAR2(255) NOT NULL)");
        executeUpdate(conn, "INSERT INTO METADATA VALUES ('VERSION', '" + latestVersion + "')");
        executeUpdate(conn, "CREATE INDEX IDXARTIST on AUDIOTRACKS (ARTIST asc);");
        executeUpdate(conn, "CREATE INDEX IDXALBUM on AUDIOTRACKS (ALBUM asc);");
        executeUpdate(conn, "CREATE INDEX IDXGENRE on AUDIOTRACKS (GENRE asc);");
        executeUpdate(conn, "CREATE INDEX IDXYEAR on AUDIOTRACKS (YEAR asc);");
        executeUpdate(
            conn,
            "CREATE TABLE REGEXP_RULES ( ID VARCHAR2(255) PRIMARY KEY, RULE VARCHAR2(255), ORDR NUMERIC);");
        executeUpdate(conn, "INSERT INTO REGEXP_RULES VALUES ( '###', '(?i)^\\W.+', 0 );");
        executeUpdate(conn, "INSERT INTO REGEXP_RULES VALUES ( '0-9', '(?i)^\\d.+', 1 );");

        // Retrieve the alphabet property value and split it
        String[] chars = Messages.getString("DLNAMediaDatabase.1").split(",");

        for (int i = 0; i < chars.length; i++) {
          // Create regexp rules for characters with a sort order based on the property value
          executeUpdate(
              conn,
              "INSERT INTO REGEXP_RULES VALUES ( '"
                  + chars[i]
                  + "', '(?i)^"
                  + chars[i]
                  + ".+', "
                  + (i + 2)
                  + " );");
        }

        LOGGER.debug("Database initialized");
      } catch (SQLException se) {
        LOGGER.info("Error in table creation: " + se.getMessage());
      } finally {
        close(conn);
      }
    } else {
      LOGGER.debug("Database file count: " + dbCount);
      LOGGER.debug("Database version: " + latestVersion);
    }
  }
示例#21
0
 public FileTypeCBItem getFileTypeCBItem(FileType fileType) {
   return new FileTypeCBItem(fileType, Messages.getString("ML.FileType." + fileType));
 }
示例#22
0
  public JComponent build() {
    FormLayout layout =
        new FormLayout(
            "0:grow, pref, 0:grow",
            "pref, 3dlu, pref, 3dlu, pref, 12dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, pref, 3dlu, p, 3dlu, p");

    PanelBuilder builder = new PanelBuilder(layout);
    builder.setDefaultDialogBorder();
    builder.setOpaque(true);
    CellConstraints cc = new CellConstraints();

    String projectName = PropertiesUtil.getProjectProperties().get("project.name");

    final LinkMouseListener pms3Link =
        new LinkMouseListener(
            projectName + " " + PMS.getVersion(), "http://www.ps3mediaserver.org/");
    JLabel lPms3Link = builder.addLabel(pms3Link.getLabel(), cc.xy(2, 1, "center, fill"));
    lPms3Link.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    lPms3Link.addMouseListener(pms3Link);

    // Create a build name from the available git properties
    String commitId = PropertiesUtil.getProjectProperties().get("git.commit.id");
    String commitTime = PropertiesUtil.getProjectProperties().get("git.commit.time");
    String shortCommitId = commitId.substring(0, 9);
    String commitUrl = "https://github.com/ps3mediaserver/ps3mediaserver/commit/" + commitId;
    String buildLabel =
        Messages.getString("LinksTab.6") + " " + shortCommitId + " (" + commitTime + ")";

    final LinkMouseListener commitLink = new LinkMouseListener(buildLabel, commitUrl);
    JLabel lCommitLink = builder.addLabel(commitLink.getLabel(), cc.xy(2, 3, "center, fill"));
    lCommitLink.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    lCommitLink.addMouseListener(commitLink);

    imagePanel = buildImagePanel();
    builder.add(imagePanel, cc.xy(2, 5, "center, fill"));

    builder.addLabel(Messages.getString("LinksTab.5"), cc.xy(2, 7, "center, fill"));

    final LinkMouseListener ffmpegLink =
        new LinkMouseListener("FFmpeg", "http://ffmpeg.mplayerhq.hu");
    JLabel lFfmpegLink = builder.addLabel(ffmpegLink.getLabel(), cc.xy(2, 9, "center, fill"));
    lFfmpegLink.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    lFfmpegLink.addMouseListener(ffmpegLink);

    final LinkMouseListener mplayerLink =
        new LinkMouseListener("MPlayer", "http://www.mplayerhq.hu");
    JLabel lMplayerLink = builder.addLabel(mplayerLink.getLabel(), cc.xy(2, 11, "center, fill"));
    lMplayerLink.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    lMplayerLink.addMouseListener(mplayerLink);

    final LinkMouseListener vlcLink =
        new LinkMouseListener("VLC media player", "http://www.videolan.org/vlc/");
    JLabel lVlcLink = builder.addLabel(vlcLink.getLabel(), cc.xy(2, 13, "center, fill"));
    lVlcLink.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    lVlcLink.addMouseListener(vlcLink);

    final LinkMouseListener mediaInfoLink =
        new LinkMouseListener("MediaInfo", "http://mediainfo.sourceforge.net/en");
    JLabel lMediaInfoLink =
        builder.addLabel(mediaInfoLink.getLabel(), cc.xy(2, 15, "center, fill"));
    lMediaInfoLink.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    lMediaInfoLink.addMouseListener(mediaInfoLink);

    JScrollPane scrollPane = new JScrollPane(builder.getPanel());
    scrollPane.setBorder(BorderFactory.createEmptyBorder());
    return scrollPane;
  }
示例#23
0
 public ConditionTypeCBItem getMaskCBItem(ConditionType conditionType) {
   return new ConditionTypeCBItem(
       conditionType, Messages.getString("ML.Condition.Header.Type." + conditionType));
 }
示例#24
0
 public ConditionTypeCBItem getConditionTypeCBItem(ConditionType conditionType) {
   String name = Messages.getString("ML.Condition.Type." + conditionType.toString());
   return new ConditionTypeCBItem(conditionType, name);
 }
示例#25
0
 public ConditionOperatorCBItem getConditionOperatorCBItem(ConditionOperator conditionOperator) {
   String name = Messages.getString("ML.Condition.Operator." + conditionOperator.toString());
   return new ConditionOperatorCBItem(conditionOperator, name);
 }