示例#1
0
  public static WebTabbedPane createExampleTabs(WebLookAndFeelDemo owner, WebProgressDialog load) {
    // All example groups
    load.setText("Loading groups list");
    List<ExampleGroup> exampleGroups = getExampleGroups();
    load.setMinimum(0);
    load.setMaximum(exampleGroups.size() + 1);
    load.setProgress(0);

    // Example tabs
    WebTabbedPane exampleTabs = new WebTabbedPane();
    exampleTabs.setTabbedPaneStyle(TabbedPaneStyle.attached);
    // exampleTabs.setTabLayoutPolicy ( WebTabbedPane.SCROLL_TAB_LAYOUT );

    // Progress component
    IconProgress ip = (IconProgress) load.getMiddleComponent();

    // Creating all examples
    int progress = 1;
    for (ExampleGroup group : exampleGroups) {
      // Updating progress state
      load.setText("Loading group: " + group.getGroupName());
      load.setProgress(progress);
      progress++;

      // Updating progress icons
      Icon gi = group.getGroupIcon();
      ip.addLoadedElement(gi);

      // Adding group view to new tab
      exampleTabs.addTab(group.getGroupName(), gi, createGroupView(owner, group));

      // Applying foreground settings
      exampleTabs.setSelectedForegroundAt(
          exampleTabs.getTabCount() - 1, group.getPreferredForeground());

      // Applying specific group settings to tab
      group.modifyExampleTab(exampleTabs.getTabCount() - 1, exampleTabs);
    }
    load.setProgress(progress);

    return exampleTabs;
  }
示例#2
0
  public static JarStructure createJarStructure(final WebProgressDialog progress) {
    // Download listener in case of remote jar-file (for e.g. demo loaded from .jnlp)
    FileDownloadListener listener =
        new FileDownloadListener() {
          private int totalSize = 0;

          @Override
          public void sizeDetermined(int totalSize) {
            // Download started
            this.totalSize = totalSize;
            updateProgress(0);
          }

          @Override
          public void partDownloaded(int totalBytesDownloaded) {
            // Some part loaded
            updateProgress(totalBytesDownloaded);
          }

          @Override
          public boolean shouldStopDownload() {
            return false;
          }

          private void updateProgress(int downloaded) {
            // Updating progress text
            progress.setText(
                "<html>Loading source files... <b>"
                    + FileUtils.getFileSizeString(downloaded, 1)
                    + "</b> of <b>"
                    + FileUtils.getFileSizeString(totalSize, 1)
                    + "</b> done</html>");
          }

          @Override
          public void fileDownloaded(File file) {
            // Updating progress text
            progress.setText("Creating source files structure...");
          }

          @Override
          public void fileDownloadFailed(Throwable e) {
            // Updating progress text
            progress.setText("Filed to download source files");
          }
        };

    // Creating structure using any of classes contained inside jar
    progress.setText("Creating source files structure...");
    List<String> extensions = Arrays.asList(".java", ".png", ".gif", ".jpg", ".txt", ".xml");
    List<String> packages = Arrays.asList("com/alee", "licenses");
    JarStructure jarStructure =
        ReflectUtils.getJarStructure(ExamplesManager.class, extensions, packages, listener);

    // Updating some of package icons
    jarStructure.setPackageIcon(
        WebLookAndFeelDemo.class.getPackage(), new ImageIcon(WebLookAndFeel.getImages().get(0)));
    for (ExampleGroup exampleGroup : getExampleGroups()) {
      jarStructure.setClassIcon(exampleGroup.getClass(), (ImageIcon) exampleGroup.getGroupIcon());
    }

    return jarStructure;
  }