@Inject
  protected LicenceAndEditionStatusLabel(DCGlassPane glassPane) {
    super(EDITION);

    setForeground(WidgetUtils.BG_COLOR_BRIGHTEST);

    if (Version.isCommunityEdition()) {
      _communityEditionInformationPanel = new CommunityEditionInformationPanel(glassPane);
      setIcon(
          ImageManager.getInstance()
              .getImageIcon("images/editions/community.png", IconUtils.ICON_SIZE_SMALL));
      setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
      addMouseListener(
          new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
              onMouseClick();
            }
          });
    } else {
      setIcon(
          ImageManager.getInstance()
              .getImageIcon("images/window/app-icon.png", IconUtils.ICON_SIZE_SMALL));
      _communityEditionInformationPanel = null;
    }
  }
  private JButton createButton(String imagePath, String description) {
    final JButton button = WidgetFactory.createImageButton(imageManager.getImageIcon(imagePath));

    final DCPopupBubble popupBubble = new DCPopupBubble(_glassPane, description, 0, 0, imagePath);
    popupBubble.attachTo(button);

    return button;
  }
  @Override
  protected JComponent getDialogContent() {
    CloseableTabbedPane tabbedPane = new CloseableTabbedPane(true);

    tabbedPane.addTab(
        "About DataCleaner",
        imageManager.getImageIcon("images/window/app-icon.png", IconUtils.ICON_SIZE_LARGE),
        getAboutPanel(),
        "About DataCleaner");
    tabbedPane.setUnclosableTab(0);

    tabbedPane.addTab(
        "Licensing",
        imageManager.getImageIcon("images/menu/license.png"),
        getLicensingPanel(),
        "Licensing");
    tabbedPane.setUnclosableTab(1);

    tabbedPane.setPreferredSize(new Dimension(getDialogWidth(), 500));

    return tabbedPane;
  }
public class StringPatternListPanel extends DCPanel implements StringPatternChangeListener {

  private static final long serialVersionUID = 1L;

  private static final ImageManager imageManager = ImageManager.get();
  private final AnalyzerBeansConfiguration _configuration;
  private final MutableReferenceDataCatalog _catalog;
  private final DCPanel _listPanel;
  private final DCGlassPane _glassPane;
  private final WindowContext _windowContext;
  private final UserPreferences _userPreferences;

  @Inject
  protected StringPatternListPanel(
      DCGlassPane glassPane,
      AnalyzerBeansConfiguration configuration,
      WindowContext windowContext,
      UserPreferences userPreferences) {
    super(WidgetUtils.BG_COLOR_BRIGHT, WidgetUtils.BG_COLOR_BRIGHTEST);
    _glassPane = glassPane;
    _configuration = configuration;
    _windowContext = windowContext;
    _userPreferences = userPreferences;
    _catalog = (MutableReferenceDataCatalog) _configuration.getReferenceDataCatalog();
    _catalog.addStringPatternListener(this);

    _listPanel = new DCPanel();
    _listPanel.setLayout(new VerticalLayout(4));

    updateComponents();

    final DCLabel newStringPatternsLabel = DCLabel.dark("Create new string pattern:");
    newStringPatternsLabel.setFont(WidgetUtils.FONT_HEADER1);

    final DCLabel existingStringPatternsLabel = DCLabel.dark("Existing string patterns:");
    existingStringPatternsLabel.setFont(WidgetUtils.FONT_HEADER1);

    setLayout(new VerticalLayout(10));
    add(newStringPatternsLabel);
    add(createNewStringPatternsPanel());
    add(Box.createVerticalStrut(10));
    add(existingStringPatternsLabel);
    setBorder(new EmptyBorder(10, 10, 10, 0));
    add(_listPanel);
  }

  private DCPanel createNewStringPatternsPanel() {

    final JButton simpleStringPatternButton =
        createButton(
            IconUtils.STRING_PATTERN_SIMPLE_IMAGEPATH,
            "<html><b>Simple string pattern</b><br/>A string pattern based on simple string tokens, eg. 'Aaaaa 999'.</html>");
    simpleStringPatternButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            new SimpleStringPatternDialog(_catalog, _windowContext).setVisible(true);
          }
        });

    final JButton regexStringPatternButton =
        createButton(
            IconUtils.STRING_PATTERN_REGEX_IMAGEPATH,
            "<html><b>Regular expression string pattern</b><br/>A very flexible string pattern, based on regular expressions.</html>");
    regexStringPatternButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            new RegexStringPatternDialog(_catalog, _windowContext).setVisible(true);
          }
        });

    final JButton regexSwapStringPatternButton =
        createButton(
            IconUtils.STRING_PATTERN_REGEXSWAP_IMAGEPATH,
            "<html><b>Browse the RegexSwap</b><br/>Download patterns from DataCleaner's online RegexSwap.</html>");
    regexSwapStringPatternButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            new RegexSwapDialog(_catalog, _windowContext, _userPreferences).setVisible(true);
          }
        });

    final HelpIcon helpIcon =
        new HelpIcon(
            "<b>String patterns</b><br>"
                + "String pattern provides a way to match string values against patterns. This is often useful for validation or categorization of values in semi- or unstructured columns.");

    final DCPanel panel =
        DCPanel.flow(
            simpleStringPatternButton,
            regexStringPatternButton,
            regexSwapStringPatternButton,
            Box.createHorizontalStrut(100),
            helpIcon);
    panel.setBorder(WidgetUtils.BORDER_LIST_ITEM);
    return panel;
  }

  private JButton createButton(String imagePath, String description) {
    final JButton button = WidgetFactory.createImageButton(imageManager.getImageIcon(imagePath));

    final DCPopupBubble popupBubble = new DCPopupBubble(_glassPane, description, 0, 0, imagePath);
    popupBubble.attachTo(button);

    return button;
  }

  private void updateComponents() {
    _listPanel.removeAll();

    final String[] names = _catalog.getStringPatternNames();
    Arrays.sort(names);

    final Icon icon = imageManager.getImageIcon("images/model/stringpattern.png");

    for (final String name : names) {
      final StringPattern stringPattern = _catalog.getStringPattern(name);

      final DCLabel stringPatternLabel =
          DCLabel.dark(
              "<html><b>" + name + "</b><br/>" + getDescription(stringPattern) + "</html>");
      stringPatternLabel.setIcon(icon);
      stringPatternLabel.setMaximumWidth(ReferenceDataDialog.REFERENCE_DATA_ITEM_MAX_WIDTH);

      final JButton editButton = WidgetFactory.createSmallButton("images/actions/edit.png");
      editButton.setToolTipText("Edit string pattern");

      if (stringPattern instanceof RegexStringPattern) {
        editButton.addActionListener(
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                RegexStringPatternDialog dialog =
                    new RegexStringPatternDialog(
                        (RegexStringPattern) stringPattern, _catalog, _windowContext);
                dialog.setVisible(true);
              }
            });
      } else if (stringPattern instanceof SimpleStringPattern) {
        editButton.addActionListener(
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                SimpleStringPatternDialog dialog =
                    new SimpleStringPatternDialog(
                        (SimpleStringPattern) stringPattern, _catalog, _windowContext);
                dialog.setVisible(true);
              }
            });
      } else {
        editButton.setEnabled(false);
      }

      final JButton removeButton = WidgetFactory.createSmallButton(IconUtils.ACTION_REMOVE);
      removeButton.setToolTipText("Remove string pattern");
      removeButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              int result =
                  JOptionPane.showConfirmDialog(
                      StringPatternListPanel.this,
                      "Are you sure you wish to remove the string pattern '" + name + "'?",
                      "Confirm remove",
                      JOptionPane.YES_NO_OPTION);
              if (result == JOptionPane.YES_OPTION) {
                _catalog.removeStringPattern(stringPattern);
              }
            }
          });

      if (!_catalog.isStringPatternMutable(name)) {
        editButton.setEnabled(false);
        removeButton.setEnabled(false);
      }

      final DCPanel stringPatternPanel = new DCPanel();
      stringPatternPanel.setBorder(WidgetUtils.BORDER_LIST_ITEM);
      WidgetUtils.addToGridBag(stringPatternLabel, stringPatternPanel, 0, 0, 1.0, 0.0);
      WidgetUtils.addToGridBag(editButton, stringPatternPanel, 1, 0, GridBagConstraints.EAST);
      WidgetUtils.addToGridBag(removeButton, stringPatternPanel, 2, 0, GridBagConstraints.EAST);
      _listPanel.add(stringPatternPanel);
    }

    if (names.length == 0) {
      _listPanel.add(DCLabel.dark("(none)"));
    }

    updateUI();
  }

  private static String getDescription(StringPattern stringPattern) {
    if (stringPattern.getDescription() != null) {
      return stringPattern.getDescription();
    }
    final String description;
    if (stringPattern instanceof RegexSwapStringPattern) {
      description = ((RegexSwapStringPattern) stringPattern).getRegex().getExpression();
    } else if (stringPattern instanceof RegexStringPattern) {
      description = ((RegexStringPattern) stringPattern).getExpression();
    } else if (stringPattern instanceof SimpleStringPattern) {
      description = ((SimpleStringPattern) stringPattern).getExpression();
    } else {
      description = "";
    }

    if (description == null) {
      return "";
    }
    if (description.length() > 30) {
      return description.substring(0, 27) + "...";
    }
    return description;
  }

  @Override
  public void onAdd(StringPattern stringPattern) {
    SwingUtilities.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            updateComponents();
          }
        });
  }

  @Override
  public void onRemove(StringPattern stringPattern) {
    SwingUtilities.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            updateComponents();
          }
        });
  }

  @Override
  public void removeNotify() {
    super.removeNotify();
    _catalog.removeStringPatternListener(this);
  }
}
  private void updateComponents() {
    _listPanel.removeAll();

    final String[] names = _catalog.getStringPatternNames();
    Arrays.sort(names);

    final Icon icon = imageManager.getImageIcon("images/model/stringpattern.png");

    for (final String name : names) {
      final StringPattern stringPattern = _catalog.getStringPattern(name);

      final DCLabel stringPatternLabel =
          DCLabel.dark(
              "<html><b>" + name + "</b><br/>" + getDescription(stringPattern) + "</html>");
      stringPatternLabel.setIcon(icon);
      stringPatternLabel.setMaximumWidth(ReferenceDataDialog.REFERENCE_DATA_ITEM_MAX_WIDTH);

      final JButton editButton = WidgetFactory.createSmallButton("images/actions/edit.png");
      editButton.setToolTipText("Edit string pattern");

      if (stringPattern instanceof RegexStringPattern) {
        editButton.addActionListener(
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                RegexStringPatternDialog dialog =
                    new RegexStringPatternDialog(
                        (RegexStringPattern) stringPattern, _catalog, _windowContext);
                dialog.setVisible(true);
              }
            });
      } else if (stringPattern instanceof SimpleStringPattern) {
        editButton.addActionListener(
            new ActionListener() {
              @Override
              public void actionPerformed(ActionEvent e) {
                SimpleStringPatternDialog dialog =
                    new SimpleStringPatternDialog(
                        (SimpleStringPattern) stringPattern, _catalog, _windowContext);
                dialog.setVisible(true);
              }
            });
      } else {
        editButton.setEnabled(false);
      }

      final JButton removeButton = WidgetFactory.createSmallButton(IconUtils.ACTION_REMOVE);
      removeButton.setToolTipText("Remove string pattern");
      removeButton.addActionListener(
          new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
              int result =
                  JOptionPane.showConfirmDialog(
                      StringPatternListPanel.this,
                      "Are you sure you wish to remove the string pattern '" + name + "'?",
                      "Confirm remove",
                      JOptionPane.YES_NO_OPTION);
              if (result == JOptionPane.YES_OPTION) {
                _catalog.removeStringPattern(stringPattern);
              }
            }
          });

      if (!_catalog.isStringPatternMutable(name)) {
        editButton.setEnabled(false);
        removeButton.setEnabled(false);
      }

      final DCPanel stringPatternPanel = new DCPanel();
      stringPatternPanel.setBorder(WidgetUtils.BORDER_LIST_ITEM);
      WidgetUtils.addToGridBag(stringPatternLabel, stringPatternPanel, 0, 0, 1.0, 0.0);
      WidgetUtils.addToGridBag(editButton, stringPatternPanel, 1, 0, GridBagConstraints.EAST);
      WidgetUtils.addToGridBag(removeButton, stringPatternPanel, 2, 0, GridBagConstraints.EAST);
      _listPanel.add(stringPatternPanel);
    }

    if (names.length == 0) {
      _listPanel.add(DCLabel.dark("(none)"));
    }

    updateUI();
  }
/**
 * The "About" dialog of the DataCleaner application.
 *
 * @author Kasper Sørensen
 */
public class AboutDialog extends AbstractDialog {

  private static final long serialVersionUID = 1L;

  public static class LicensedProject {
    public String name;
    public String websiteUrl;
    public String license;
  }

  private static final ResourceManager resourceManager = ResourceManager.get();
  private static final ImageManager imageManager = ImageManager.get();

  public AboutDialog(WindowContext windowContext) {
    super(windowContext);
  }

  @Override
  public void toFront() {
    super.toFront();
  }

  @Override
  protected String getBannerTitle() {
    return "About DataCleaner";
  }

  @Override
  protected int getDialogWidth() {
    return 600;
  }

  @Override
  protected boolean isWindowResizable() {
    return true;
  }

  @Override
  protected JComponent getDialogContent() {
    CloseableTabbedPane tabbedPane = new CloseableTabbedPane(true);

    tabbedPane.addTab(
        "About DataCleaner",
        imageManager.getImageIcon("images/window/app-icon.png", IconUtils.ICON_SIZE_LARGE),
        getAboutPanel(),
        "About DataCleaner");
    tabbedPane.setUnclosableTab(0);

    tabbedPane.addTab(
        "Licensing",
        imageManager.getImageIcon("images/menu/license.png"),
        getLicensingPanel(),
        "Licensing");
    tabbedPane.setUnclosableTab(1);

    tabbedPane.setPreferredSize(new Dimension(getDialogWidth(), 500));

    return tabbedPane;
  }

  private JComponent getLicensingPanel() {
    final String dcLicense = getLicense("lgpl");

    final DCLabel licenseHeader = DCLabel.dark("");
    licenseHeader.setFont(WidgetUtils.FONT_HEADER1);

    final DCLabel licenseLabel = DCLabel.darkMultiLine("");
    licenseLabel.setBackground(WidgetUtils.BG_COLOR_BRIGHTEST);
    licenseLabel.setFont(WidgetUtils.FONT_MONOSPACE);
    licenseLabel.setOpaque(true);

    final JButton dcLicenseButton = WidgetFactory.createSmallButton("images/menu/license.png");
    dcLicenseButton.setToolTipText("DataCleaner's license: GNU LGPL");
    dcLicenseButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            licenseHeader.setText("Displaying license of DataCleaner");
            licenseLabel.setText(dcLicense);
          }
        });

    final JComboBox librariesComboBox = new JComboBox();
    final JButton visitProjectButton = WidgetFactory.createSmallButton(IconUtils.WEBSITE);

    librariesComboBox.setRenderer(
        new DCListCellRenderer() {

          private static final long serialVersionUID = 1L;

          @Override
          public Component getListCellRendererComponent(
              JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            if (value instanceof LicensedProject) {
              LicensedProject project = (LicensedProject) value;
              String name = project.name;
              return super.getListCellRendererComponent(
                  list, name, index, isSelected, cellHasFocus);
            } else if (value instanceof String) {
              return super.getListCellRendererComponent(
                  list, value, index, isSelected, cellHasFocus);
            }
            throw new UnsupportedOperationException();
          }
        });
    librariesComboBox.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            Object item = e.getItem();
            if (item instanceof LicensedProject) {
              visitProjectButton.setEnabled(true);
              LicensedProject project = (LicensedProject) item;
              licenseLabel.setText(project.license);
              licenseHeader.setText("Displaying license of " + project.name + "");
            } else {
              visitProjectButton.setEnabled(false);
              licenseHeader.setText("Displaying license of DataCleaner");
              licenseLabel.setText(dcLicense);
            }
          }
        });

    visitProjectButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            Object item = librariesComboBox.getSelectedItem();
            LicensedProject project = (LicensedProject) item;
            String websiteUrl = project.websiteUrl;
            if (!StringUtils.isNullOrEmpty(websiteUrl)) {
              new OpenBrowserAction(websiteUrl).actionPerformed(e);
            }
          }
        });

    librariesComboBox.addItem("- select project -");
    final List<LicensedProject> licensedProjects = getLicensedProjects();
    for (LicensedProject licensedProject : licensedProjects) {
      librariesComboBox.addItem(licensedProject);
    }

    final JToolBar toolBar = WidgetFactory.createToolBar();
    toolBar.add(DCLabel.dark("DataCleaners license: "));
    toolBar.add(dcLicenseButton);
    toolBar.add(WidgetFactory.createToolBarSeparator());
    toolBar.add(DCLabel.dark("Included libraries: "));
    toolBar.add(librariesComboBox);
    toolBar.add(visitProjectButton);

    final JScrollPane licenseLabelScroll = WidgetUtils.scrolleable(licenseLabel);
    licenseLabelScroll.setBorder(
        new CompoundBorder(new EmptyBorder(10, 0, 10, 0), WidgetUtils.BORDER_THIN));

    final DCPanel headerPanel = new DCPanel();
    headerPanel.setLayout(new VerticalLayout());
    headerPanel.add(toolBar);
    headerPanel.add(Box.createVerticalStrut(20));
    headerPanel.add(licenseHeader);

    final DCPanel panel = new DCPanel(WidgetUtils.BG_COLOR_BRIGHT, WidgetUtils.BG_COLOR_BRIGHTEST);
    panel.setBorder(new EmptyBorder(4, 4, 4, 4));
    panel.setLayout(new BorderLayout());
    panel.add(headerPanel, BorderLayout.NORTH);
    panel.add(licenseLabelScroll, BorderLayout.CENTER);

    return panel;
  }

  private JComponent getAboutPanel() {
    final DCLabel headerLabel =
        DCLabel.dark("DataCleaner " + Version.getEdition() + " " + Version.getVersion());

    headerLabel.setFont(WidgetUtils.FONT_HEADER1);

    final ImageManager imageManager = ImageManager.get();

    final JButton datacleanerButton =
        new JButton(imageManager.getImageIcon("images/links/datacleaner.png"));
    datacleanerButton.addActionListener(new OpenBrowserAction("http://datacleaner.org"));
    datacleanerButton.setToolTipText("Visit the DataCleaner website");
    datacleanerButton.setBorder(null);

    final JButton bloggerButton =
        new JButton(imageManager.getImageIcon("images/links/blogger.png"));
    bloggerButton.addActionListener(new OpenBrowserAction("http://kasper.eobjects.org"));
    bloggerButton.setToolTipText("Follow along at our blog");
    bloggerButton.setBorder(null);

    final JButton linkedInButton =
        new JButton(imageManager.getImageIcon("images/links/linkedin.png"));
    linkedInButton.addActionListener(
        new OpenBrowserAction("http://www.linkedin.com/groups?gid=3352784"));
    linkedInButton.setToolTipText("Join the DataCleaner LinkedIn group");
    linkedInButton.setBorder(null);

    final DCPanel buttonPanel = new DCPanel();
    buttonPanel.setLayout(new HorizontalLayout());
    buttonPanel.add(datacleanerButton);
    buttonPanel.add(Box.createHorizontalStrut(10));
    buttonPanel.add(bloggerButton);
    buttonPanel.add(Box.createHorizontalStrut(10));
    buttonPanel.add(linkedInButton);

    final HumanInferenceToolbarButton humanInferenceButton =
        new HumanInferenceToolbarButton(
            imageManager.getImageIcon("images/powered-by-human-inference-bright.png"));

    final DCPanel contentPanel = new DCPanel();
    contentPanel.setLayout(new VerticalLayout());
    contentPanel.add(headerLabel);
    contentPanel.add(
        DCLabel.dark(
            "Copyright (C) " + Calendar.getInstance().get(Calendar.YEAR) + " Human Inference"));
    contentPanel.add(Box.createVerticalStrut(20));
    contentPanel.add(DCPanel.around(humanInferenceButton));

    if (Version.isCommunityEdition()) {
      contentPanel.add(Box.createVerticalStrut(20));
      contentPanel.add(DCLabel.dark("Licensed under the LGPL license"));
      contentPanel.add(DCLabel.dark("(see Licensing tab)."));
    } else {
      final String licenseKey = Version.getLicenseKey();
      contentPanel.add(Box.createVerticalStrut(20));
      contentPanel.add(DCLabel.dark("License key: " + licenseKey));
    }

    contentPanel.add(Box.createVerticalStrut(30));
    contentPanel.add(DCLabel.dark("Java runtime information:"));
    contentPanel.add(DCLabel.dark("  " + System.getProperty("java.vm.name")));
    contentPanel.add(DCLabel.dark("  by " + System.getProperty("java.vm.vendor")));
    contentPanel.add(DCLabel.dark("  version " + System.getProperty("java.runtime.version")));
    contentPanel.add(Box.createVerticalStrut(30));
    contentPanel.add(buttonPanel);

    final DCPanel mainPanel =
        new DCPanel(
            imageManager.getImage("images/window/app-icon-hires.png"),
            97,
            10,
            WidgetUtils.BG_COLOR_BRIGHT,
            WidgetUtils.BG_COLOR_BRIGHTEST);
    mainPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
    mainPanel.setLayout(new VerticalLayout());
    mainPanel.add(contentPanel);

    return mainPanel;
  }

  @Override
  public String getWindowTitle() {
    return "About DataCleaner | DataCleaner";
  }

  public static List<LicensedProject> getLicensedProjects() {
    final List<LicensedProject> result = new ArrayList<AboutDialog.LicensedProject>();
    final URL url = resourceManager.getUrl("licenses/dependency-licenses.csv");
    if (url == null) {
      throw new IllegalStateException("Could not find dependencies file");
    }
    try {
      DataContext dc = DataContextFactory.createCsvDataContext(url.openStream(), ',', '"');
      Table table = dc.getDefaultSchema().getTables()[0];
      Column projectColumn = table.getColumnByName("Project");
      Column websiteColumn = table.getColumnByName("Website");
      Column licenseColumn = table.getColumnByName("License");
      Query q =
          dc.query().from(table).select(table.getColumns()).orderBy(projectColumn).asc().toQuery();
      DataSet ds = dc.executeQuery(q);
      while (ds.next()) {
        final LicensedProject licensedProject = new LicensedProject();
        final Row row = ds.getRow();
        final String licenseName = row.getValue(licenseColumn).toString();

        licensedProject.name = row.getValue(projectColumn).toString();
        licensedProject.websiteUrl = row.getValue(websiteColumn).toString();
        licensedProject.license = getLicense(licenseName);

        result.add(licensedProject);
      }

    } catch (IOException e) {
      throw new IllegalStateException("Error occurred while reading dependencies file", e);
    }

    return result;
  }

  public static String getLicense(final String licenseName) {
    URL url = resourceManager.getUrl("licenses/" + licenseName + ".txt");
    if (url == null) {
      throw new IllegalArgumentException("Could not find license file for license: " + licenseName);
    }
    BufferedReader reader = null;
    try {
      reader =
          new BufferedReader(new InputStreamReader(url.openStream(), FileHelper.UTF_8_ENCODING));
      final StringBuilder sb = new StringBuilder();
      for (String line = reader.readLine(); line != null; line = reader.readLine()) {
        if (sb.length() != 0) {
          sb.append('\n');
        }
        sb.append(line);
      }

      return sb.toString();
    } catch (Exception e) {
      throw new IllegalStateException(
          "Error occurred while reading license file: " + licenseName, e);
    } finally {
      if (reader != null) {
        try {
          reader.close();
        } catch (IOException e) {
          // do nothing
        }
      }
    }
  }

  public static void main(String[] args) {
    new AboutDialog(new DCWindowContext(null, null, null)).setVisible(true);
  }
}
  private JComponent getAboutPanel() {
    final DCLabel headerLabel =
        DCLabel.dark("DataCleaner " + Version.getEdition() + " " + Version.getVersion());

    headerLabel.setFont(WidgetUtils.FONT_HEADER1);

    final ImageManager imageManager = ImageManager.get();

    final JButton datacleanerButton =
        new JButton(imageManager.getImageIcon("images/links/datacleaner.png"));
    datacleanerButton.addActionListener(new OpenBrowserAction("http://datacleaner.org"));
    datacleanerButton.setToolTipText("Visit the DataCleaner website");
    datacleanerButton.setBorder(null);

    final JButton bloggerButton =
        new JButton(imageManager.getImageIcon("images/links/blogger.png"));
    bloggerButton.addActionListener(new OpenBrowserAction("http://kasper.eobjects.org"));
    bloggerButton.setToolTipText("Follow along at our blog");
    bloggerButton.setBorder(null);

    final JButton linkedInButton =
        new JButton(imageManager.getImageIcon("images/links/linkedin.png"));
    linkedInButton.addActionListener(
        new OpenBrowserAction("http://www.linkedin.com/groups?gid=3352784"));
    linkedInButton.setToolTipText("Join the DataCleaner LinkedIn group");
    linkedInButton.setBorder(null);

    final DCPanel buttonPanel = new DCPanel();
    buttonPanel.setLayout(new HorizontalLayout());
    buttonPanel.add(datacleanerButton);
    buttonPanel.add(Box.createHorizontalStrut(10));
    buttonPanel.add(bloggerButton);
    buttonPanel.add(Box.createHorizontalStrut(10));
    buttonPanel.add(linkedInButton);

    final HumanInferenceToolbarButton humanInferenceButton =
        new HumanInferenceToolbarButton(
            imageManager.getImageIcon("images/powered-by-human-inference-bright.png"));

    final DCPanel contentPanel = new DCPanel();
    contentPanel.setLayout(new VerticalLayout());
    contentPanel.add(headerLabel);
    contentPanel.add(
        DCLabel.dark(
            "Copyright (C) " + Calendar.getInstance().get(Calendar.YEAR) + " Human Inference"));
    contentPanel.add(Box.createVerticalStrut(20));
    contentPanel.add(DCPanel.around(humanInferenceButton));

    if (Version.isCommunityEdition()) {
      contentPanel.add(Box.createVerticalStrut(20));
      contentPanel.add(DCLabel.dark("Licensed under the LGPL license"));
      contentPanel.add(DCLabel.dark("(see Licensing tab)."));
    } else {
      final String licenseKey = Version.getLicenseKey();
      contentPanel.add(Box.createVerticalStrut(20));
      contentPanel.add(DCLabel.dark("License key: " + licenseKey));
    }

    contentPanel.add(Box.createVerticalStrut(30));
    contentPanel.add(DCLabel.dark("Java runtime information:"));
    contentPanel.add(DCLabel.dark("  " + System.getProperty("java.vm.name")));
    contentPanel.add(DCLabel.dark("  by " + System.getProperty("java.vm.vendor")));
    contentPanel.add(DCLabel.dark("  version " + System.getProperty("java.runtime.version")));
    contentPanel.add(Box.createVerticalStrut(30));
    contentPanel.add(buttonPanel);

    final DCPanel mainPanel =
        new DCPanel(
            imageManager.getImage("images/window/app-icon-hires.png"),
            97,
            10,
            WidgetUtils.BG_COLOR_BRIGHT,
            WidgetUtils.BG_COLOR_BRIGHTEST);
    mainPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
    mainPanel.setLayout(new VerticalLayout());
    mainPanel.add(contentPanel);

    return mainPanel;
  }