@NotNull
  EditorWindow[] getOrderedWindows() {
    final List<EditorWindow> res = new ArrayList<EditorWindow>();

    // Collector for windows in tree ordering:
    class Inner {
      private void collect(final JPanel panel) {
        final Component comp = panel.getComponent(0);
        if (comp instanceof Splitter) {
          final Splitter splitter = (Splitter) comp;
          collect((JPanel) splitter.getFirstComponent());
          collect((JPanel) splitter.getSecondComponent());
        } else if (comp instanceof JPanel || comp instanceof JBTabs) {
          final EditorWindow window = findWindowWith(comp);
          if (window != null) {
            res.add(window);
          }
        }
      }
    }

    // get root component and traverse splitters tree:
    if (getComponentCount() != 0) {
      final Component comp = getComponent(0);
      LOG.assertTrue(comp instanceof JPanel);
      final JPanel panel = (JPanel) comp;
      if (panel.getComponentCount() != 0) {
        new Inner().collect(panel);
      }
    }

    LOG.assertTrue(res.size() == myWindows.size());
    return res.toArray(new EditorWindow[res.size()]);
  }
Exemplo n.º 2
0
  public void enableControlPanel() {
    boolean bVisible = false;

    int nmembers = buttonPane.getComponentCount();
    for (int k = 0; k < nmembers; k++) {
      Component comp = buttonPane.getComponent(k);
      if (comp != null) {
        if (comp.isVisible() || comp.isEnabled()) {
          bVisible = true;
          break;
        }
      }
    }

    if (bVisible && !buttonPane.isVisible()) {
      Dimension dim = getSize();
      Dimension dim1 = buttonPane.getPreferredSize();
      int w = dim.width;
      int h = dim.height + dim1.height;
      if (dim1.width > w) w = dim1.width;
      if (w < 300) w = 300;
      if (h < 200) h = 200;
      setSize(w, h);
    }
    buttonPane.setVisible(bVisible);
  }
Exemplo n.º 3
0
  void install() {
    Vector components = new Vector();
    Vector indicies = new Vector();
    int size = 0;

    JPanel comp = selectComponents.comp;
    Vector ids = selectComponents.filesets;

    for (int i = 0; i < comp.getComponentCount(); i++) {
      if (((JCheckBox) comp.getComponent(i)).getModel().isSelected()) {
        size += installer.getIntegerProperty("comp." + ids.elementAt(i) + ".real-size");
        components.addElement(installer.getProperty("comp." + ids.elementAt(i) + ".fileset"));
        indicies.addElement(new Integer(i));
      }
    }

    String installDir = chooseDirectory.installDir.getText();

    Map osTaskDirs = chooseDirectory.osTaskDirs;
    Iterator keys = osTaskDirs.keySet().iterator();
    while (keys.hasNext()) {
      OperatingSystem.OSTask osTask = (OperatingSystem.OSTask) keys.next();
      String dir = ((JTextField) osTaskDirs.get(osTask)).getText();
      if (dir != null && dir.length() != 0) {
        osTask.setEnabled(true);
        osTask.setDirectory(dir);
      } else osTask.setEnabled(false);
    }

    InstallThread thread =
        new InstallThread(installer, progress, installDir, osTasks, size, components, indicies);
    progress.setThread(thread);
    thread.start();
  }
    public void createColorPanel() {
      JPanel colorPanel = new JPanel(new GridLayout(0, 1));
      int curRow = 0;
      for (int i = 0; i < colorString.length / 5; i++) {
        JPanel row = new JPanel(new GridLayout(1, 0, 2, 1));
        row.setBorder(new EmptyBorder(2, 2, 2, 2));

        for (int j = curRow; j < curRow + 5; j++) {
          final JLabel colorLabel =
              new JLabel(null, new ColoredIcon(color[j], 14, 14), JLabel.CENTER);
          colorLabel.setOpaque(true);
          final Border emb = BorderFactory.createEmptyBorder(2, 1, 2, 1);
          final Border lnb = BorderFactory.createLineBorder(Color.black);
          final Border cmb = BorderFactory.createCompoundBorder(lnb, emb);
          colorLabel.setBorder(emb);
          colorLabel.addMouseListener(
              new MouseAdapter() {

                public void mouseClicked(MouseEvent e) {
                  JButton btn = (JButton) getTarget();
                  Color selColor = ((ColoredIcon) colorLabel.getIcon()).getCurrentColor();
                  btn.setIcon(new ColoredIcon(selColor));
                  setVisible(false);
                  btn.doClick();
                  oldLabel.setBackground(null);
                  colorLabel.setBackground(new Color(150, 150, 200));
                  colorLabel.setBorder(emb);
                  oldLabel = colorLabel;
                }

                public void mouseEntered(MouseEvent e) {
                  colorLabel.setBorder(cmb);
                  colorLabel.setBackground(new Color(150, 150, 200));
                }

                public void mouseExited(MouseEvent e) {
                  colorLabel.setBorder(emb);
                  colorLabel.setBackground(null);
                }
              });
          row.add(colorLabel);
        }
        colorPanel.add(row);
        curRow += row.getComponentCount();
        // System.out.println(curRow);
      }

      add(colorPanel, BorderLayout.CENTER);

      // More Colors Button
      moreColors = new JButton(new ColorChooserAction((JButton) target));
      moreColors.setText("More Colors...");
      moreColors.setIcon(null);
      moreColors.setFont(new Font("Verdana", Font.PLAIN, 10));
      //
      JPanel c = new JPanel(new FlowLayout(FlowLayout.CENTER));
      c.add(moreColors);
      add(c, BorderLayout.SOUTH);
    }
 public void writeExternal(final Element element) {
   if (getComponentCount() != 0) {
     final Component comp = getComponent(0);
     LOG.assertTrue(comp instanceof JPanel);
     final JPanel panel = (JPanel) comp;
     if (panel.getComponentCount() != 0) {
       element.addContent(writePanel(panel));
     }
   }
 }
Exemplo n.º 6
0
  protected void doSysValidation() {
    int nComps = m_pnlDisplay.getComponentCount();
    JTextArea txaMsg = null;

    for (int i = 0; i < nComps; i++) {
      Component comp = m_pnlDisplay.getComponent(i);
      if (comp instanceof JTextArea) txaMsg = (JTextArea) comp;
    }

    if (txaMsg != null) {
      txaMsg.append("VALIDATING SYSTEM FILES...\n");
      txaMsg.append("\n");
    }
    runScripts(txaMsg);
  }
Exemplo n.º 7
0
  public int getOpenCount() {
    int num = tabbedToolPanel.getComponentCount();
    if (num != 1) return num;
    Component comp = tabbedToolPanel.getComponent(0);
    if (comp instanceof JTabbedPane) {
      JTabbedPane tp = (JTabbedPane) comp;
      num = tp.getTabCount();
      if (num != 1) return num;
      comp = tp.getComponentAt(0);
    }
    if (comp instanceof VToolPanel) num = ((VToolPanel) comp).getOpenCount();
    else if (comp instanceof PushpinIF) {
      if (!((PushpinIF) comp).isOpen()) num = 0;
    }

    return num;
  }
Exemplo n.º 8
0
  private Component getSelectedObj() {
    if (tabbedToolPanel.getComponentCount() < 1) return null;
    Component comp = tabbedToolPanel.getComponent(0);
    if (comp instanceof JTabbedPane) {
      JTabbedPane tp = (JTabbedPane) comp;
      if (tp.getTabCount() == 1) {
        comp = tp.getComponentAt(0);
      } else if (tp.getTabCount() > 1) {
        comp = tp.getSelectedComponent();
      }
    }
    if (comp instanceof VToolPanel) return comp;

    if (!(comp instanceof XMLToolPanel)) {
      if (comp instanceof PushpinIF) comp = ((PushpinIF) comp).getPinObj();
    }
    return comp;
  }
Exemplo n.º 9
0
  private boolean containTool(JComponent obj) {
    int k, num;

    if (obj == null) return false;
    Component src = (Component) obj;
    Component comp;
    if (tabbedPane != null) {
      num = tabbedPane.getTabCount();
      for (k = 0; k < num; k++) {
        comp = tabbedPane.getComponentAt(k);
        if (src == comp) return true;
      }
    }
    if (tabbedToolPanel != null) {
      num = tabbedToolPanel.getComponentCount();
      for (k = 0; k < num; k++) {
        comp = tabbedToolPanel.getComponent(k);
        if (src == comp) return true;
      }
    }
    return false;
  }
Exemplo n.º 10
0
  // new TemplatesGroup selected
  public void projectTypeChanged() {
    TemplatesGroup group = getSelectedGroup();
    if (group == null || group == myLastSelectedGroup) return;
    myLastSelectedGroup = group;
    PropertiesComponent.getInstance().setValue(PROJECT_WIZARD_GROUP, group.getId());
    ModuleBuilder groupModuleBuilder = group.getModuleBuilder();

    mySettingsStep = null;
    myHeaderPanel.removeAll();
    if (groupModuleBuilder != null && groupModuleBuilder.getModuleType() != null) {
      mySettingsStep = groupModuleBuilder.modifyProjectTypeStep(this);
    }

    if (groupModuleBuilder == null || groupModuleBuilder.isTemplateBased()) {
      showTemplates(group);
    } else if (!showCustomOptions(groupModuleBuilder)) {
      List<FrameworkSupportInModuleProvider> providers =
          FrameworkSupportUtil.getProviders(groupModuleBuilder);
      final ProjectCategory category = group.getProjectCategory();
      if (category != null) {
        List<FrameworkSupportInModuleProvider> filtered =
            ContainerUtil.filter(
                providers,
                new Condition<FrameworkSupportInModuleProvider>() {
                  @Override
                  public boolean value(FrameworkSupportInModuleProvider provider) {
                    return matchFramework(category, provider);
                  }
                });
        // add associated
        Map<String, FrameworkSupportInModuleProvider> map =
            ContainerUtil.newMapFromValues(providers.iterator(), PROVIDER_STRING_CONVERTOR);
        Set<FrameworkSupportInModuleProvider> set =
            new HashSet<FrameworkSupportInModuleProvider>(filtered);
        for (FrameworkSupportInModuleProvider provider : filtered) {
          for (FrameworkSupportInModuleProvider.FrameworkDependency depId :
              provider.getDependenciesFrameworkIds()) {
            FrameworkSupportInModuleProvider dependency = map.get(depId.getFrameworkId());
            set.add(dependency);
          }
        }

        myFrameworksPanel.setProviders(
            new ArrayList<FrameworkSupportInModuleProvider>(set),
            new HashSet<String>(Arrays.asList(category.getAssociatedFrameworkIds())),
            new HashSet<String>(Arrays.asList(category.getPreselectedFrameworkIds())));
      } else {
        myFrameworksPanel.setProviders(providers);
      }
      getSelectedBuilder().addModuleConfigurationUpdater(myConfigurationUpdater);

      showCard(FRAMEWORKS_CARD);
    }

    myHeaderPanel.setVisible(myHeaderPanel.getComponentCount() > 0);
    // align header labels
    List<JLabel> labels = UIUtil.findComponentsOfType(myHeaderPanel, JLabel.class);
    int width = 0;
    for (JLabel label : labels) {
      int width1 = label.getPreferredSize().width;
      width = Math.max(width, width1);
    }
    for (JLabel label : labels) {
      label.setPreferredSize(new Dimension(width, label.getPreferredSize().height));
    }
    myHeaderPanel.revalidate();
    myHeaderPanel.repaint();

    updateSelection();
  }