@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()]);
  }
 private static int restorePanel(JPanel component, int i) {
   int removed = 0;
   while (component.getComponentCount() > i) {
     component.remove(component.getComponentCount() - 1);
     removed++;
   }
   return removed;
 }
Esempio n. 3
0
 /** Tells all the labels to draw a comma after the tag value, except for the last one */
 private void refreshCommas() {
   for (int i = 0; i < pTagValues.getComponentCount(); i++) {
     JComponent c = (JComponent) pTagValues.getComponent(i);
     if (c instanceof TagLabel) {
       ((TagLabel) c).setAddComma(i < pTagValues.getComponentCount() - 1);
     }
   }
 }
  public static void removePanel() {
    bottom.remove(bottom.getComponents()[bottom.getComponentCount() - 1]);
    if (bottom.getComponentCount() == 1) {}

    //		JPanel p = null;
    //		for (Component comp : bottom.getComponents()) {
    //			if (comp.getName().equals(name)) {
    //				p = (JPanel) comp;
    //			}
    //		}
    //		bottom.remove(p);
  }
Esempio n. 5
0
 public void showPage(int pageNumber) {
   int visadsida = pageNumber + 1; // AH* nytillagt.
   try {
     SkrivUt(4, "ShowPage i PDFReader.");
     currentPage = pageNumber; // AH* TIllagd för att hålla reda på akt sida.
     PageWrapper wrapper = new PageWrapper(this);
     wrapper.displayPage((PDPage) pages.get(pageNumber));
     // if (EasyReader) cogsumsim.setDocumentPanel( wrapper.getPanel()); //AH*
     // PageWrapper cswrapper = new PageWrapper(cogsumsim.easyreader); AH*
     // cogsumsim.wrapper.displayPage( (PDPage)pages.get(pageNumber) ); //AH*
     if (documentPanel.getComponentCount() > 0) {
       documentPanel.remove(0);
       if (EasyReader) // AH* tillagt.
       cogsumsim.getDocumentPanel().remove(0);
     }
     documentPanel.add(wrapper.getPanel());
     if (EasyReader) // AH* tillagt.
     {
       cogsumsim.setDocumentPanel(documentPanel);
       // cogsumsim.getDocumentPanel().;
     }
     pack();
     sumPan.Sidantal.setText("" + visadsida + " Av " + numberOfPages); // AH* nytt.
   } catch (IOException exception) {
     exception.printStackTrace();
   }
 }
Esempio n. 6
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);
  }
  private void setupPanels(@Nullable ProjectTemplate template) {

    restorePanel(myNamePathComponent, 4);
    restorePanel(myModulePanel, myWizardContext.isCreatingNewProject() ? 8 : 6);
    restorePanel(myExpertPanel, myWizardContext.isCreatingNewProject() ? 1 : 0);
    mySettingsStep = myModuleBuilder == null ? null : myModuleBuilder.modifySettingsStep(this);

    String description = null;
    if (template != null) {
      description = template.getDescription();
      if (StringUtil.isNotEmpty(description)) {
        StringBuilder sb = new StringBuilder("<html><body><font ");
        sb.append(SystemInfo.isMac ? "" : "face=\"Verdana\" size=\"-1\"").append('>');
        sb.append(description).append("</font></body></html>");
        description = sb.toString();
        myDescriptionPane.setText(description);
      }
    }

    myExpertPlaceholder.setVisible(
        !(myModuleBuilder instanceof TemplateModuleBuilder)
            && myExpertPanel.getComponentCount() > 0);
    for (int i = 0; i < 6; i++) {
      myModulePanel.getComponent(i).setVisible(!(myModuleBuilder instanceof EmptyModuleBuilder));
    }
    myDescriptionPanel.setVisible(StringUtil.isNotEmpty(description));

    mySettingsPanel.revalidate();
    mySettingsPanel.repaint();
  }
Esempio n. 8
0
 private JPanel addResultPane() {
   JPanel resultPane = new JPanel(new BorderLayout());
   resultPane.setOpaque(false);
   int componentCount = southPanel.getComponentCount();
   if (componentCount == 0) {
     southPanel.add(resultPane, BorderLayout.CENTER);
     southPanel.revalidate();
     southPanel.repaint();
   } else {
     JTabbedPane tabbedPane;
     Component component0 = southPanel.getComponent(0);
     if (component0 instanceof JTabbedPane) {
       tabbedPane = (JTabbedPane) component0;
     } else {
       JPanel query1Panel = (JPanel) component0;
       southPanel.remove(0);
       tabbedPane = new JTabbedPane();
       tabbedPane.addTab("Query 1", query1Panel);
       southPanel.add(tabbedPane, BorderLayout.CENTER);
       southPanel.revalidate();
       southPanel.repaint();
     }
     tabbedPane.addTab("Query " + (tabbedPane.getTabCount() + 1), resultPane);
   }
   return resultPane;
 }
Esempio n. 9
0
  public static void main(String[] args) {
    final JavaMixer sm = new JavaMixer();
    final JFrame jf = new JFrame("Mixer Test");
    final JPanel jp = new JPanel();
    jf.add(jp);
    jp.add(sm.getTree());
    jf.setSize(600, 500);
    jf.setVisible(true);
    jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    sm.getTree()
        .addTreeSelectionListener(
            e -> {
              TreePath path = e.getPath();
              if (path.getLastPathComponent() instanceof ControlNode) {
                ControlNode controlNode = (ControlNode) path.getLastPathComponent();
                if (!(controlNode.getControl() instanceof CompoundControl)) {
                  if (jp.getComponentCount() > 1) jp.remove(1);
                  jp.add(controlNode.getComponent(), 1);
                  jp.repaint();
                }
              }
            });
    jp.add(sm.getPrefferedMasterVolume());
    jp.add(sm.getPrefferedMasterVolume());
    jp.add(sm.getPrefferedInputVolume());
    jp.repaint();
    sm.setMicrophoneInput();
    sm.setMuteForMicrophoneOutput();
  }
Esempio n. 10
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();
  }
Esempio n. 11
0
  /**
   * Spusti se pri zmacknuti tlacitka. Pokud je pod mysi obraz figury, zjisti, zda se muze pohnout
   * (pokud ano, upravi ho pro tahnuti, nastavi ho do figLabel) a zobrazi kontextovou napovedu.
   */
  private void eCatcherMousePressed(
      java.awt.event.MouseEvent evt) { // GEN-FIRST:event_eCatcherMousePressed
    if (figLabel != null || finished) {
      return;
    }
    BoardSquare bsquare = (BoardSquare) eCatcher.getComponentAt(evt.getPoint());

    JPanel fsquare = (JPanel) figurePan.getComponent(bsquare.getIndex());
    sourceBSquare = bsquare;
    Point defLocation = fsquare.getLocation();
    xAdjustment = (int) defLocation.getX() - evt.getX();
    yAdjustment = (int) defLocation.getY() - evt.getY();
    if (fsquare.getComponentCount() == 0) {
      return;
    }
    figLabel = (JLabel) fsquare.getComponent(0);

    setFocus(gui.getFocus(bsquare.getColumn(), bsquare.getRow()));
    if (!gui.canMove(bsquare.getColumn(), bsquare.getRow())) {
      figLabel = null;
      return;
    }
    fsquare.remove(figLabel);
    boardPane.add(figLabel, 0);
    figLabel.setLocation(evt.getX() + xAdjustment, evt.getY() + yAdjustment);
    figLabel.setSize(figLabel.getWidth(), figLabel.getHeight());
  } // GEN-LAST:event_eCatcherMousePressed
 public JComponent getComponent(String key) {
   JPanel valuePanel = keyValueComponentMap.get(key);
   if (valuePanel.getComponentCount() > 0) {
     return (JComponent) valuePanel.getComponent(0);
   }
   return null;
 }
 public JComponent getAdditionalColumn(String key, int index) {
   JPanel p = keyExtraComponentsMap.get(key)[index];
   if (p.getComponentCount() > 0) {
     return (JComponent) p.getComponent(0);
   }
   return null;
 }
Esempio n. 14
0
  public Dimension getDocumentSize() {
    float pageViewWidth = 0;
    float pageViewHeight = 0;
    if (pagesPanel != null) {
      int currCompIndex = documentViewController.getCurrentPageIndex();
      int numComponents = pagesPanel.getComponentCount();
      if (currCompIndex >= 0 && currCompIndex < numComponents) {
        Component comp = pagesPanel.getComponent(currCompIndex);
        if (comp instanceof PageViewDecorator) {
          PageViewDecorator pvd = (PageViewDecorator) comp;
          Dimension dim = pvd.getPreferredSize();
          pageViewWidth = dim.width;
          pageViewHeight = dim.height;
        }
      }
    }
    // normalize the dimensions to a zoom level of zero.
    float currentZoom = documentViewModel.getViewZoom();
    pageViewWidth = Math.abs(pageViewWidth / currentZoom);
    pageViewHeight = Math.abs(pageViewHeight / currentZoom);

    // add any horizontal padding from layout manager
    pageViewWidth += AbstractDocumentView.horizontalSpace * 2;
    pageViewHeight += AbstractDocumentView.verticalSpace * 2;
    return new Dimension((int) pageViewWidth, (int) pageViewHeight);
  }
 private void addResult(String inputFileName, String outputModelName, String tempFileName) {
   TrafficModelingResult result =
       new TrafficModelingResult(inputFileName, outputModelName, tempFileName);
   panResults.add(result);
   panResults.setPreferredSize(new Dimension(1280, panResults.getComponentCount() * (30 + 5)));
   panResults.validate();
 }
Esempio n. 16
0
 private ComparedValuePanel addComparedValuePanel() {
   ComparedValuePanel textBoxPanel = new ComparedValuePanel();
   textBoxPanel.setColumnVisible(colValCheckBox.isSelected());
   lowerPanel.add(textBoxPanel, lowerPanel.getComponentCount() - 1);
   lowerPanel.revalidate();
   return textBoxPanel;
 }
Esempio n. 17
0
  private boolean isValidated() {

    formDate = ((SpinnerDateModel) date.getModel()).getDate();

    try {
      if (!Manager.getInstance().getInventorySheetDataManager().isValidFor(formDate)) {

        msg = "Date is invalid ";

        return false;
      }
    } catch (Exception e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    if (productsPanel.getComponentCount() == 0) {

      msg = "Put at least one product ";

      return false;
    }

    return true;
  }
  @Override
  public void setComponentValues(BaseModelObject baseModelObject) {
    for (PropertyObjectDefinition property : definitions) {
      if (propertyFields.containsKey(property) == true) {
        PropertyField propertyField = propertyFields.get(property);
        StyledLabel propertyLabel = propertyLabels.get(property);

        propertyField.setComponentValue(baseModelObject);
        propertyLabel.setVisible(propertyField.isVisible());
      }
    }

    boolean visible = false;
    for (int i = 0; i < contentPanel.getComponentCount(); i++) {
      Component component = contentPanel.getComponent(i);

      if (component.isVisible() == true) {
        visible = true;
        break;
      }
    }

    setVisible(visible);

    revalidate();

    Dimension preferredSize = contentPanel.getPreferredSize();
    contentPanel.setSize(preferredSize);
    contentPanel.setMinimumSize(preferredSize);
  }
Esempio n. 19
0
  /** Row striping */
  private void updateColors() {
    for (int i = 0; i < pnlItem.getComponentCount(); i++) {
      pnlItem.getComponents()[i].setBackground((i % 2 == 0) ? Constants.ALT_COLOR : null);
    }

    repaint();
  }
    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);
    }
Esempio n. 21
0
  private void setPreferredPanelSize() {
    Dimension ps = v.getViewport().getMinimumSize();

    jp.setPreferredSize(
        new Dimension(
            columns * (ps.width - 5) + 5,
            ((jp.getComponentCount() - 1) / columns + 1) * (ps.height - 5) + 5));
  }
Esempio n. 22
0
 /*
  * Find panel on top of MapView by class
  */
 public <T> T getTopPanel(Class<T> type) {
   int n = leftPanel.getComponentCount();
   for (int i = 0; i < n; i++) {
     Component c = leftPanel.getComponent(i);
     if (type.isInstance(c)) return type.cast(c);
   }
   return null;
 }
Esempio n. 23
0
 public void setValues() {
   // Update all field values in the tabs:
   int count = main.getComponentCount();
   Component[] comps = main.getComponents();
   for (int i = 0; i < count; i++) {
     ((PrefsTab) comps[i]).setValues();
   }
 }
Esempio n. 24
0
  private void ensureProperViewSize() {
    Dimension ps = v.getViewport().getMinimumSize();
    Dimension rs = v.getViewport().getSize();
    int nw = Math.min(4, Math.max(((rs.width - 5 + ps.width / 2) / (ps.width - 5)), 1));
    int nh = Math.min(5, Math.max(((rs.height - 5 + ps.height / 2) / (ps.height - 5)), 1));

    if (nh > (jp.getComponentCount() - 1) / nw + 1) nh = (jp.getComponentCount() - 1) / nw + 1;

    Dimension ns = new Dimension(nw * (ps.width - 5) + 5, nh * (ps.height - 5) + 5);
    if (ns.equals(rs)) return;

    columns = nw;
    setPreferredPanelSize();
    v.getViewport().setPreferredSize(ns);
    main.pack();
    v.getViewport().setViewPosition(new Point(0, jp.getPreferredSize().height));
    checkHighlightVisible();
  }
 /**
  * Overridden to make sure that all the components have the correct background.
  *
  * @see JPanel#setBackground(Color)
  */
 public void setBackground(Color color) {
   if (busyLabel != null) busyLabel.setBackground(color);
   if (namePane != null) {
     namePane.setBackground(color);
     for (int i = 0; i < namePane.getComponentCount(); i++)
       namePane.getComponent(i).setBackground(color);
   }
   super.setBackground(color);
 }
  private void refreshQueryUIComponents() throws ReportDataFactoryException {
    if (datasourcePanel.getComponentCount() <= 0) {

      KettleEmbeddedQueryEntry entry = new KettleEmbeddedQueryEntry(null, datasourceId, null);
      entry.refreshQueryUIComponents(
          datasourcePanel, getDesignTimeContext(), new PreviewChangeListener());
      setPanelEnabled(false, datasourcePanel);
    }
  }
 /**
  * Elimina un icono de la grilla
  *
  * @param album Nombre del album a quitar
  */
 public void removeAlbum(String album) {
   for (int i = grid.getComponentCount() - 1; i >= 0; i--) {
     AlbumIcon ai = (AlbumIcon) grid.getComponent(i);
     if (ai.getAlbumName() == album) {
       ai.setVisible(false);
       removeAlbum(ai);
     }
   }
 }
 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));
     }
   }
 }
Esempio n. 29
0
 public void enableToolbar() {
   final int count = editorBar.getComponentCount();
   for (int i = 0; i < count; i++) {
     final Object o = editorBar.getComponent(i);
     if (o instanceof RolloverButton) {
       final RolloverButton rb = (RolloverButton) o;
       rb.setEnabled(true);
     }
   }
 }
  public void setKeyboardFont(Font f) {
    f = f.deriveFont(fontSize);

    JPanel p = (JPanel) getContentPane();
    for (int i = 0; i < p.getComponentCount(); i++) {
      Component c = p.getComponent(i);
      c.setFont(f);
    }

    pack();
  }