private JPanel readSplitter(
      JPanel panel, Element splitterElement, Ref<EditorWindow> currentWindow) {
    final boolean orientation =
        "vertical".equals(splitterElement.getAttributeValue("split-orientation"));
    final float proportion =
        Float.valueOf(splitterElement.getAttributeValue("split-proportion")).floatValue();
    final Element first = splitterElement.getChild("split-first");
    final Element second = splitterElement.getChild("split-second");

    Splitter splitter;
    if (panel == null) {
      panel = new JPanel(new BorderLayout());
      panel.setOpaque(false);
      splitter = new Splitter(orientation, proportion, 0.1f, 0.9f);
      panel.add(splitter, BorderLayout.CENTER);
      splitter.setFirstComponent(readExternalPanel(first, null, currentWindow));
      splitter.setSecondComponent(readExternalPanel(second, null, currentWindow));
    } else if (panel.getComponent(0) instanceof Splitter) {
      splitter = (Splitter) panel.getComponent(0);
      readExternalPanel(first, (JPanel) splitter.getFirstComponent(), currentWindow);
      readExternalPanel(second, (JPanel) splitter.getSecondComponent(), currentWindow);
    } else {
      readExternalPanel(first, panel, currentWindow);
      readExternalPanel(second, panel, currentWindow);
    }
    return panel;
  }
  public void testGridBagSpacer() throws Exception {
    JPanel panel = (JPanel) getInstrumentedRootComponent("TestGridBagSpacer.form", "BindingTest");
    assertTrue(panel.getLayout() instanceof GridBagLayout);
    assertTrue(panel.getComponent(0) instanceof JLabel);
    assertTrue(panel.getComponent(1) instanceof JPanel);

    GridBagLayout gridBag = (GridBagLayout) panel.getLayout();
    GridBagConstraints gbc = gridBag.getConstraints(panel.getComponent(0));
    assertEquals(0.0, gbc.weightx, 0.01);
    assertEquals(0.0, gbc.weighty, 0.01);
    gbc = gridBag.getConstraints(panel.getComponent(1));
    assertEquals(0.0, gbc.weightx, 0.01);
    assertEquals(1.0, gbc.weighty, 0.01);
  }
 @SuppressWarnings({"HardCodedStringLiteral"})
 private Element writePanel(final JPanel panel) {
   final Component comp = panel.getComponent(0);
   if (comp instanceof Splitter) {
     final Splitter splitter = (Splitter) comp;
     final Element res = new Element("splitter");
     res.setAttribute("split-orientation", splitter.getOrientation() ? "vertical" : "horizontal");
     res.setAttribute("split-proportion", Float.toString(splitter.getProportion()));
     final Element first = new Element("split-first");
     first.addContent(writePanel((JPanel) splitter.getFirstComponent()));
     final Element second = new Element("split-second");
     second.addContent(writePanel((JPanel) splitter.getSecondComponent()));
     res.addContent(first);
     res.addContent(second);
     return res;
   } else if (comp instanceof JBTabs) {
     final Element res = new Element("leaf");
     final EditorWindow window = findWindowWith(comp);
     writeWindow(res, window);
     return res;
   } else if (comp instanceof EditorWindow.TCompForTablessMode) {
     final EditorWithProviderComposite composite =
         ((EditorWindow.TCompForTablessMode) comp).myEditor;
     final Element res = new Element("leaf");
     writeComposite(res, composite.getFile(), composite, false, composite);
     return res;
   } else {
     LOG.error(comp != null ? comp.getClass().getName() : null);
     return null;
   }
 }
示例#4
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 JComponent getAdditionalColumn(String key, int index) {
   JPanel p = keyExtraComponentsMap.get(key)[index];
   if (p.getComponentCount() > 0) {
     return (JComponent) p.getComponent(0);
   }
   return null;
 }
 public JComponent getComponent(String key) {
   JPanel valuePanel = keyValueComponentMap.get(key);
   if (valuePanel.getComponentCount() > 0) {
     return (JComponent) valuePanel.getComponent(0);
   }
   return null;
 }
  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 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();
  }
示例#9
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);
  }
 public void testMnemonic() throws Exception {
   JPanel panel = (JPanel) getInstrumentedRootComponent("TestMnemonics.form", "BindingTest");
   JLabel label = (JLabel) panel.getComponent(0);
   assertEquals("Mnemonic", label.getText());
   assertEquals('M', label.getDisplayedMnemonic());
   assertEquals(3, label.getDisplayedMnemonicIndex());
 }
示例#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
示例#12
0
 /** Presune obraz figury z pozice inx0 na pozici inx1. */
 public void moveFig(int inx0, int inx1) {
   JPanel panel0, panel1;
   panel0 = (JPanel) figurePan.getComponent(inx0);
   panel1 = (JPanel) figurePan.getComponent(inx1);
   Component c = panel0.getComponent(0);
   panel0.removeAll();
   panel1.removeAll();
   panel1.add(c);
   panel0.revalidate();
   panel1.revalidate();
 }
示例#13
0
    private void updateSize() {
      int size = 0;

      for (int i = 0; i < filesets.size(); i++) {
        if (((JCheckBox) comp.getComponent(i)).getModel().isSelected()) {
          size += installer.getIntegerProperty("comp." + filesets.elementAt(i) + ".disk-size");
        }
      }

      sizeLabel.setText("Estimated disk usage of selected" + " components: " + size + "Mb");
    }
 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);
     }
   }
 }
 public void testGridBagLayout() throws Exception {
   JPanel panel = (JPanel) getInstrumentedRootComponent("TestGridBag.form", "BindingTest");
   assertTrue(panel.getLayout() instanceof GridBagLayout);
   GridBagLayout gridBag = (GridBagLayout) panel.getLayout();
   JButton btn = (JButton) panel.getComponent(0);
   GridBagConstraints gbc = gridBag.getConstraints(btn);
   assertNotNull(gbc);
   assertEquals(2, gbc.gridheight);
   assertEquals(2, gbc.gridwidth);
   assertEquals(1.0, gbc.weightx, 0.01);
   assertEquals(new Insets(1, 2, 3, 4), gbc.insets);
   assertEquals(GridBagConstraints.HORIZONTAL, gbc.fill);
   assertEquals(GridBagConstraints.NORTHWEST, gbc.anchor);
 }
示例#16
0
 public void stateChanged(ChangeEvent e) {
   int value = slider.getValue();
   TitledBorder tb = (TitledBorder) slider.getBorder();
   tb.setTitle("Anim delay = " + String.valueOf(value) + " ms");
   int index = Java2Demo.tabbedPane.getSelectedIndex() - 1;
   DemoGroup dg = Java2Demo.group[index];
   JPanel p = dg.getPanel();
   for (int i = 0; i < p.getComponentCount(); i++) {
     DemoPanel dp = (DemoPanel) p.getComponent(i);
     if (dp.tools != null && dp.tools.slider != null) {
       dp.tools.slider.setValue(value);
     }
   }
   slider.repaint();
 }
示例#17
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);
  }
示例#18
0
  @Nullable
  public Condition getCondition() {
    Condition condition = null;
    ConditionTemplate template = (ConditionTemplate) conditionType.getSelectedItem();
    if (template != null) {
      int count = parameterPanels.getComponentCount();
      Object[] parameters = new Object[count];
      for (int i = 0; i < count; ++i) {
        ParameterPanel p = (ParameterPanel) parameterPanels.getComponent(i);
        parameters[i] = p.getParameter();
      }

      condition = new Condition(template.getName(), parameters);
    }
    return condition;
  }
示例#19
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;
  }
示例#20
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;
  }
示例#21
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;
  }
  @SuppressWarnings("HardCodedStringLiteral")
  private Element writePanel(final JPanel panel) {
    final Component comp = panel.getComponent(0);
    if (comp instanceof Splitter) {
      final Splitter splitter = (Splitter) comp;
      final Element res = new Element("splitter");
      res.setAttribute("split-orientation", splitter.getOrientation() ? "vertical" : "horizontal");
      res.setAttribute("split-proportion", Float.toString(splitter.getProportion()));
      final Element first = new Element("split-first");
      first.addContent(writePanel((JPanel) splitter.getFirstComponent()));
      final Element second = new Element("split-second");
      second.addContent(writePanel((JPanel) splitter.getSecondComponent()));
      res.addContent(first);
      res.addContent(second);
      return res;
    } else if (comp instanceof JBTabs) {
      final Element res = new Element("leaf");
      Integer limit =
          UIUtil.getClientProperty(
              ((JBTabs) comp).getComponent(), JBTabsImpl.SIDE_TABS_SIZE_LIMIT_KEY);
      if (limit != null) {
        res.setAttribute(JBTabsImpl.SIDE_TABS_SIZE_LIMIT_KEY.toString(), String.valueOf(limit));
      }

      writeWindow(res, findWindowWith(comp));
      return res;
    } else if (comp instanceof EditorWindow.TCompForTablessMode) {
      EditorWithProviderComposite composite = ((EditorWindow.TCompForTablessMode) comp).myEditor;
      Element res = new Element("leaf");
      res.addContent(writeComposite(composite.getFile(), composite, false, composite));
      return res;
    } else {
      LOG.error(comp != null ? comp.getClass().getName() : null);
      return null;
    }
  }
  /** Process Button Pressed - Process Matching */
  private void cmd_newProduct() {
    // Selecciono el departamento
    int depart = 0;
    String SQL =
        "Select XX_VMR_DEPARTMENT_ID "
            + "from XX_VMR_VENDORPRODREF "
            + "where XX_VMR_VENDORPRODREF_ID="
            + LineRefProv.getXX_VMR_VendorProdRef_ID();

    try {
      PreparedStatement pstmt = DB.prepareStatement(SQL, null);
      ResultSet rs = pstmt.executeQuery();

      while (rs.next()) {
        depart = rs.getInt("XX_VMR_DEPARTMENT_ID");
      }

      rs.close();
      pstmt.close();

    } catch (Exception a) {
      log.log(Level.SEVERE, SQL, a);
    }

    MVMRVendorProdRef vendorProdRef =
        new MVMRVendorProdRef(Env.getCtx(), LineRefProv.getXX_VMR_VendorProdRef_ID(), null);

    if (vendorProdRef.getXX_VMR_ProductClass_ID() > 0
        && vendorProdRef.getXX_VMR_TypeLabel_ID() > 0) {
      MOrder order = new MOrder(Env.getCtx(), LineRefProv.getC_Order_ID(), null);

      // Selecciono el departamento
      X_XX_VMR_Department dept =
          new X_XX_VMR_Department(Env.getCtx(), vendorProdRef.getXX_VMR_Department_ID(), null);
      int category = dept.getXX_VMR_Category_ID();

      // Selecciono la línea
      X_XX_VMR_Line line = new X_XX_VMR_Line(Env.getCtx(), vendorProdRef.getXX_VMR_Line_ID(), null);
      int typeInventory = line.getXX_VMR_TypeInventory_ID();

      MProduct newProduct =
          new MProduct(
              Env.getCtx(),
              vendorProdRef.getXX_VMR_Department_ID(),
              vendorProdRef.getXX_VMR_Line_ID(),
              vendorProdRef.getXX_VMR_Section_ID(),
              vendorProdRef.get_ID(),
              vendorProdRef.getC_TaxCategory_ID(),
              vendorProdRef.getXX_VME_ConceptValue_ID(),
              typeInventory,
              null);

      // Se buscará si por la referencia para producto ya existe para asignarle el Tipo de
      // Exhibición
      String sql =
          "select * from M_Product where XX_VMR_DEPARTMENT_ID = "
              + vendorProdRef.getXX_VMR_Department_ID()
              + " and "
              + "XX_VMR_LINE_ID = "
              + vendorProdRef.getXX_VMR_Line_ID()
              + " and XX_VMR_SECTION_ID = "
              + vendorProdRef.getXX_VMR_Section_ID()
              + " and "
              + "XX_VMR_VendorProdRef_id = "
              + vendorProdRef.getXX_VMR_VendorProdRef_ID()
              + " order by M_Product_ID desc";
      PreparedStatement pstmt = DB.prepareStatement(sql, null);
      ResultSet rs = null;
      try {
        rs = pstmt.executeQuery();
        if (rs.next())
          newProduct.setXX_VMR_TypeExhibition_ID(rs.getInt("XX_VMR_TypeExhibition_ID"));
      } catch (SQLException e) {

        e.printStackTrace();
      } finally {
        DB.closeResultSet(rs);
        DB.closeStatement(pstmt);
      }

      if (vendorProdRef.getXX_VMR_Section_ID() > 0) {
        X_XX_VMR_Section section =
            new X_XX_VMR_Section(Env.getCtx(), vendorProdRef.getXX_VMR_Section_ID(), null);
        newProduct.setName(section.getName());
      } else {
        newProduct.setName(vendorProdRef.getName());
      }
      newProduct.setXX_VMR_Category_ID(category);
      newProduct.setXX_VMR_LongCharacteristic_ID(vendorProdRef.getXX_VMR_LongCharacteristic_ID());
      newProduct.setXX_VMR_Brand_ID(vendorProdRef.getXX_VMR_Brand_ID());
      newProduct.setXX_VMR_UnitConversion_ID(vendorProdRef.getXX_VMR_UnitConversion_ID());
      newProduct.setXX_PiecesBySale_ID(vendorProdRef.getXX_PiecesBySale_ID());
      newProduct.setXX_VMR_UnitPurchase_ID(vendorProdRef.getXX_VMR_UnitPurchase_ID());
      newProduct.setXX_SaleUnit_ID(vendorProdRef.getXX_SaleUnit_ID());
      newProduct.setC_Country_ID(order.getC_Country_ID());
      newProduct.setIsActive(true);
      newProduct.setC_BPartner_ID(vendorProdRef.getC_BPartner_ID());
      newProduct.setXX_VMR_TypeLabel_ID(vendorProdRef.getXX_VMR_TypeLabel_ID());
      newProduct.setXX_VMR_ProductClass_ID(vendorProdRef.getXX_VMR_ProductClass_ID());
      newProduct.setM_AttributeSet_ID(Env.getCtx().getContextAsInt("#XX_L_P_ATTRIBUTESETST_ID"));
      newProduct.setProductType(X_Ref_M_Product_ProductType.ITEM.getValue());
      newProduct.save();

    } else {
      // Creo variables de sesion para atraparlas en la ventana producto
      Env.getCtx().setContext("#Depart_Aux", depart);
      Env.getCtx().setContext("#Section_Aux", LineRefProv.getXX_VMR_Section_ID());
      Env.getCtx().setContext("#Line_Aux", LineRefProv.getXX_VMR_Line_ID());
      Env.getCtx().setContext("#VendorRef_Aux", LineRefProv.getXX_VMR_VendorProdRef_ID());
      Env.getCtx().setContext("#FromProcess_Aux", "Y");

      AWindow window_product = new AWindow();
      Query query = Query.getNoRecordQuery("M_Product", true);
      window_product.initWindow(140, query);
      AEnv.showCenterScreen(window_product);

      // Obtenemos el GridController para setear la variable m_changed=true
      JRootPane jRootPane = ((JRootPane) window_product.getComponent(0));
      JLayeredPane jLayeredPane = (JLayeredPane) jRootPane.getComponent(1);
      JPanel jPanel = (JPanel) jLayeredPane.getComponent(0);
      APanel aPanel = (APanel) jPanel.getComponent(0);
      VTabbedPane vTabbedPane = (VTabbedPane) aPanel.getComponent(0);
      GridController gridController = (GridController) vTabbedPane.getComponent(0);
      GridTable mTable = gridController.getMTab().getTableModel();
      mTable.setChanged(true);

      MProduct.loadLineRefProv(LineRefProv, Env.getCtx());

      // Borro las variables de sesion creadas
      Env.getCtx().remove("#Depart_Aux");
      Env.getCtx().remove("#FromProcess_Aux");
      Env.getCtx().remove("#Line_Aux");
      Env.getCtx().remove("#Section_Aux");
      Env.getCtx().remove("#VendorRef_Aux");
    }
  } //  cmd_newProduct
示例#24
0
  public void initializeMainView(
      final SuperAdapter superAdapter,
      Container contentPane,
      Dimension bigPanelDim,
      Dimension panelDim) {
    contentPane.setLayout(new BorderLayout());

    final JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());
    contentPane.add(mainPanel, BorderLayout.CENTER);
    mainPanel.setBackground(Color.white);

    final JPanel toolbarPanel = new JPanel();
    toolbarPanel.setBorder(null);

    toolbarPanel.setLayout(new GridBagLayout());
    mainPanel.add(toolbarPanel, BorderLayout.NORTH);

    JPanel bigPanel = new JPanel();
    bigPanel.setLayout(new BorderLayout());
    bigPanel.setBackground(Color.white);

    bigPanel.setPreferredSize(new Dimension(bigPanelDim));
    bigPanel.setMaximumSize(new Dimension(bigPanelDim));
    bigPanel.setMinimumSize(new Dimension(bigPanelDim));

    JPanel bottomPanel = new JPanel();
    bottomPanel.setBackground(Color.white);

    JMenuBar menuBar = null;
    try {
      menuBar = superAdapter.createMenuBar();
    } catch (Exception e) {
      e.printStackTrace();
    }
    assert menuBar != null;
    contentPane.add(menuBar, BorderLayout.NORTH);

    GridBagConstraints toolbarConstraints = new GridBagConstraints();
    toolbarConstraints.anchor = GridBagConstraints.LINE_START;
    toolbarConstraints.fill = GridBagConstraints.HORIZONTAL;
    toolbarConstraints.gridx = 0;
    toolbarConstraints.gridy = 0;
    toolbarConstraints.weightx = 0.1;

    // --- Chromosome panel ---
    JPanel chrSelectionPanel = new JPanel();
    toolbarPanel.add(chrSelectionPanel, toolbarConstraints);

    chrSelectionPanel.setBorder(LineBorder.createGrayLineBorder());

    chrSelectionPanel.setLayout(new BorderLayout());

    JPanel chrLabelPanel = new JPanel();
    JLabel chrLabel = new JLabel("Chromosomes");
    chrLabel.setHorizontalAlignment(SwingConstants.CENTER);
    chrLabelPanel.setBackground(HiCGlobals.backgroundColor);
    chrLabelPanel.setLayout(new BorderLayout());
    chrLabelPanel.add(chrLabel, BorderLayout.CENTER);
    chrSelectionPanel.add(chrLabelPanel, BorderLayout.PAGE_START);

    JPanel chrButtonPanel = new JPanel();
    chrButtonPanel.setBackground(new Color(238, 238, 238));
    chrButtonPanel.setLayout(new BoxLayout(chrButtonPanel, BoxLayout.X_AXIS));

    // ---- chrBox1 ----
    chrBox1 = new JComboBox<Chromosome>();
    chrBox1.setModel(
        new DefaultComboBoxModel<Chromosome>(new Chromosome[] {new Chromosome(0, "All", 0)}));
    chrBox1.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            chrBox1ActionPerformed(e);
          }
        });
    chrBox1.setPreferredSize(new Dimension(95, 70));
    chrButtonPanel.add(chrBox1);

    // ---- chrBox2 ----
    chrBox2 = new JComboBox<Chromosome>();
    chrBox2.setModel(
        new DefaultComboBoxModel<Chromosome>(new Chromosome[] {new Chromosome(0, "All", 0)}));
    chrBox2.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            chrBox2ActionPerformed(e);
          }
        });
    chrBox2.setPreferredSize(new Dimension(95, 70));
    chrButtonPanel.add(chrBox2);

    // ---- refreshButton ----
    refreshButton = new JideButton();
    refreshButton.setIcon(
        new ImageIcon(getClass().getResource("/toolbarButtonGraphics/general/Refresh24.gif")));
    refreshButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            superAdapter.safeRefreshButtonActionPerformed();
          }
        });
    refreshButton.setPreferredSize(new Dimension(24, 24));
    chrButtonPanel.add(refreshButton);

    chrBox1.setEnabled(false);
    chrBox2.setEnabled(false);
    refreshButton.setEnabled(false);
    chrSelectionPanel.add(chrButtonPanel, BorderLayout.CENTER);

    chrSelectionPanel.setMinimumSize(new Dimension(200, 70));
    chrSelectionPanel.setPreferredSize(new Dimension(210, 70));

    // ======== Display Option Panel ========
    JPanel displayOptionPanel = new JPanel();
    displayOptionPanel.setBackground(new Color(238, 238, 238));
    displayOptionPanel.setBorder(LineBorder.createGrayLineBorder());
    displayOptionPanel.setLayout(new BorderLayout());
    JPanel displayOptionLabelPanel = new JPanel();
    displayOptionLabelPanel.setBackground(HiCGlobals.backgroundColor);
    displayOptionLabelPanel.setLayout(new BorderLayout());

    JLabel displayOptionLabel = new JLabel("Show");
    displayOptionLabel.setHorizontalAlignment(SwingConstants.CENTER);
    displayOptionLabelPanel.add(displayOptionLabel, BorderLayout.CENTER);
    displayOptionPanel.add(displayOptionLabelPanel, BorderLayout.PAGE_START);
    JPanel displayOptionButtonPanel = new JPanel();
    displayOptionButtonPanel.setBorder(new EmptyBorder(0, 10, 0, 10));
    displayOptionButtonPanel.setLayout(new GridLayout(1, 0, 20, 0));
    displayOptionComboBox = new JComboBox<MatrixType>();
    displayOptionComboBox.setModel(
        new DefaultComboBoxModel<MatrixType>(new MatrixType[] {MatrixType.OBSERVED}));
    displayOptionComboBox.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            superAdapter.safeDisplayOptionComboBoxActionPerformed();
            normalizationComboBox.setEnabled(!isWholeGenome());
          }
        });
    displayOptionButtonPanel.add(displayOptionComboBox);
    displayOptionPanel.add(displayOptionButtonPanel, BorderLayout.CENTER);
    displayOptionPanel.setMinimumSize(new Dimension(140, 70));
    displayOptionPanel.setPreferredSize(new Dimension(140, 70));
    displayOptionPanel.setMaximumSize(new Dimension(140, 70));

    toolbarConstraints.gridx = 1;
    toolbarConstraints.weightx = 0.1;
    toolbarPanel.add(displayOptionPanel, toolbarConstraints);
    displayOptionComboBox.setEnabled(false);

    // ======== Normalization Panel ========
    JPanel normalizationPanel = new JPanel();
    normalizationPanel.setBackground(new Color(238, 238, 238));
    normalizationPanel.setBorder(LineBorder.createGrayLineBorder());
    normalizationPanel.setLayout(new BorderLayout());

    JPanel normalizationLabelPanel = new JPanel();
    normalizationLabelPanel.setBackground(HiCGlobals.backgroundColor);
    normalizationLabelPanel.setLayout(new BorderLayout());

    JLabel normalizationLabel = new JLabel("Normalization");
    normalizationLabel.setHorizontalAlignment(SwingConstants.CENTER);
    normalizationLabelPanel.add(normalizationLabel, BorderLayout.CENTER);
    normalizationPanel.add(normalizationLabelPanel, BorderLayout.PAGE_START);

    JPanel normalizationButtonPanel = new JPanel();
    normalizationButtonPanel.setBorder(new EmptyBorder(0, 10, 0, 10));
    normalizationButtonPanel.setLayout(new GridLayout(1, 0, 20, 0));
    normalizationComboBox = new JComboBox<String>();
    normalizationComboBox.setModel(
        new DefaultComboBoxModel<String>(new String[] {NormalizationType.NONE.getLabel()}));
    normalizationComboBox.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            superAdapter.safeNormalizationComboBoxActionPerformed(e);
          }
        });
    normalizationButtonPanel.add(normalizationComboBox);
    normalizationPanel.add(normalizationButtonPanel, BorderLayout.CENTER);
    normalizationPanel.setPreferredSize(new Dimension(180, 70));
    normalizationPanel.setMinimumSize(new Dimension(140, 70));

    toolbarConstraints.gridx = 2;
    toolbarConstraints.weightx = 0.1;
    toolbarPanel.add(normalizationPanel, toolbarConstraints);
    normalizationComboBox.setEnabled(false);

    // ======== Resolution Panel ========
    hiCPanel = new JPanel();
    hiCPanel.setBackground(Color.white);
    hiCPanel.setLayout(new HiCLayout());
    bigPanel.add(hiCPanel, BorderLayout.CENTER);

    JPanel wrapGapPanel = new JPanel();
    wrapGapPanel.setBackground(Color.white);
    wrapGapPanel.setMaximumSize(new Dimension(5, 5));
    wrapGapPanel.setMinimumSize(new Dimension(5, 5));
    wrapGapPanel.setPreferredSize(new Dimension(5, 5));
    wrapGapPanel.setBorder(LineBorder.createBlackLineBorder());
    bigPanel.add(wrapGapPanel, BorderLayout.EAST);

    // splitPanel.insertPane(hiCPanel, 0);
    // splitPanel.setBackground(Color.white);

    // ---- rulerPanel2 ----
    JPanel topPanel = new JPanel();
    topPanel.setBackground(Color.green);
    topPanel.setLayout(new BorderLayout());
    hiCPanel.add(topPanel, BorderLayout.NORTH);
    trackLabelPanel = new TrackLabelPanel(superAdapter.getHiC());
    trackLabelPanel.setBackground(Color.white);
    hiCPanel.add(trackLabelPanel, HiCLayout.NORTH_WEST);

    trackPanelX = new TrackPanel(superAdapter, superAdapter.getHiC(), TrackPanel.Orientation.X);
    trackPanelX.setMaximumSize(new Dimension(4000, 50));
    trackPanelX.setPreferredSize(new Dimension(1, 50));
    trackPanelX.setMinimumSize(new Dimension(1, 50));
    trackPanelX.setVisible(false);
    topPanel.add(trackPanelX, BorderLayout.NORTH);

    rulerPanelX = new HiCRulerPanel(superAdapter.getHiC());
    rulerPanelX.setMaximumSize(new Dimension(4000, 50));
    rulerPanelX.setMinimumSize(new Dimension(1, 50));
    rulerPanelX.setPreferredSize(new Dimension(1, 50));
    rulerPanelX.setBorder(null);
    topPanel.add(rulerPanelX, BorderLayout.SOUTH);

    // ---- rulerPanel1 ----
    JPanel leftPanel = new JPanel();
    leftPanel.setBackground(Color.white);
    leftPanel.setLayout(new BorderLayout());
    hiCPanel.add(leftPanel, BorderLayout.WEST);

    trackPanelY = new TrackPanel(superAdapter, superAdapter.getHiC(), TrackPanel.Orientation.Y);
    trackPanelY.setMaximumSize(new Dimension(50, 4000));
    trackPanelY.setPreferredSize(new Dimension(50, 1));
    trackPanelY.setMinimumSize(new Dimension(50, 1));
    trackPanelY.setVisible(false);
    leftPanel.add(trackPanelY, BorderLayout.WEST);

    rulerPanelY = new HiCRulerPanel(superAdapter.getHiC());
    rulerPanelY.setMaximumSize(new Dimension(50, 4000));
    rulerPanelY.setPreferredSize(new Dimension(50, 800));
    rulerPanelY.setBorder(null);
    rulerPanelY.setMinimumSize(new Dimension(50, 1));
    leftPanel.add(rulerPanelY, BorderLayout.EAST);

    // ---- heatmapPanel ----
    // Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize();
    // int panelSize = screenDimension.height - 210;

    int panelWidth = (int) panelDim.getWidth();
    int panelHeight = (int) panelDim.getHeight();
    System.err.println("Window W: " + panelWidth + " H" + panelHeight);

    JPanel wrapHeatmapPanel = new JPanel(new BorderLayout());
    wrapHeatmapPanel.setMaximumSize(new Dimension(panelDim));
    wrapHeatmapPanel.setMinimumSize(new Dimension(panelDim));
    wrapHeatmapPanel.setPreferredSize(new Dimension(panelDim));
    wrapHeatmapPanel.setBackground(Color.BLUE);
    wrapHeatmapPanel.setVisible(true);

    heatmapPanel = new HeatmapPanel(superAdapter);
    heatmapPanel.setMaximumSize(new Dimension(panelWidth - 5, panelHeight - 5));
    heatmapPanel.setMinimumSize(new Dimension(panelWidth - 5, panelHeight - 5));
    heatmapPanel.setPreferredSize(new Dimension(panelWidth - 5, panelHeight - 5));
    heatmapPanel.setBackground(Color.white);

    wrapHeatmapPanel.add(heatmapPanel, BorderLayout.CENTER);

    // hiCPanel.setMaximumSize(new Dimension(panelWidth, panelHeight));
    // hiCPanel.setMinimumSize(new Dimension(panelWidth, panelHeight));
    // hiCPanel.setPreferredSize(new Dimension(panelWidth, panelHeight));

    hiCPanel.add(wrapHeatmapPanel, BorderLayout.CENTER);

    // ======== Resolution Slider Panel ========

    // Resolution  panel
    resolutionSlider = new ResolutionControl(superAdapter);
    resolutionSlider.setPreferredSize(new Dimension(200, 70));
    resolutionSlider.setMinimumSize(new Dimension(150, 70));

    toolbarConstraints.gridx = 3;
    toolbarConstraints.weightx = 0.1;
    toolbarPanel.add(resolutionSlider, toolbarConstraints);

    // ======== Color Range Panel ========
    colorRangePanel = new JColorRangePanel(superAdapter, heatmapPanel, preDefMapColor);

    toolbarConstraints.gridx = 4;
    toolbarConstraints.weightx = 0.5;
    toolbarPanel.add(colorRangePanel, toolbarConstraints);

    goPanel = new GoToPanel(superAdapter);
    toolbarConstraints.gridx = 5;
    toolbarConstraints.weightx = 0.25;
    toolbarPanel.add(goPanel, toolbarConstraints);
    // not sure this is working
    // toolbarPanel.setPreferredSize(new Dimension(panelHeight,100));
    toolbarPanel.setEnabled(false);

    // ======== Right side panel ========

    JPanel rightSidePanel = new JPanel(new BorderLayout()); // (new BorderLayout());
    rightSidePanel.setBackground(Color.white);
    rightSidePanel.setPreferredSize(new Dimension(210, 1000));
    rightSidePanel.setMaximumSize(new Dimension(10000, 10000));

    // ======== Bird's view mini map ========

    JPanel thumbPanel = new JPanel();
    thumbPanel.setLayout(new BorderLayout());

    // ---- thumbnailPanel ----
    thumbnailPanel = new ThumbnailPanel(superAdapter);
    thumbnailPanel.setBackground(Color.white);
    thumbnailPanel.setMaximumSize(new Dimension(210, 210));
    thumbnailPanel.setMinimumSize(new Dimension(210, 210));
    thumbnailPanel.setPreferredSize(new Dimension(210, 210));

    //        JPanel gapPanel = new JPanel();
    //        gapPanel.setMaximumSize(new Dimension(1, 1));
    //        rightSidePanel.add(gapPanel,BorderLayout.WEST);
    thumbPanel.add(thumbnailPanel, BorderLayout.CENTER);
    thumbPanel.setBackground(Color.white);
    rightSidePanel.add(thumbPanel, BorderLayout.NORTH);

    // ========= mouse hover text ======
    JPanel tooltipPanel = new JPanel(new BorderLayout());
    tooltipPanel.setBackground(Color.white);
    tooltipPanel.setPreferredSize(new Dimension(210, 490));
    mouseHoverTextPanel = new JEditorPane();
    mouseHoverTextPanel.setEditable(false);
    mouseHoverTextPanel.setContentType("text/html");
    mouseHoverTextPanel.setFont(new Font("sans-serif", 0, 20));
    mouseHoverTextPanel.setBackground(Color.white);
    mouseHoverTextPanel.setBorder(null);
    int mouseTextY = rightSidePanel.getBounds().y + rightSidePanel.getBounds().height;

    // *Dimension prefSize = new Dimension(210, 490);
    Dimension prefSize = new Dimension(210, 390);
    mouseHoverTextPanel.setPreferredSize(prefSize);

    JScrollPane tooltipScroller = new JScrollPane(mouseHoverTextPanel);
    tooltipScroller.setBackground(Color.white);
    tooltipScroller.setBorder(null);

    tooltipPanel.setPreferredSize(new Dimension(210, 500));
    tooltipPanel.add(tooltipScroller);
    tooltipPanel.setBounds(new Rectangle(new Point(0, mouseTextY), prefSize));
    tooltipPanel.setBackground(Color.white);
    tooltipPanel.setBorder(null);

    rightSidePanel.add(tooltipPanel, BorderLayout.CENTER);

    // compute preferred size
    Dimension preferredSize = new Dimension();
    for (int i = 0; i < rightSidePanel.getComponentCount(); i++) {
      Rectangle bounds = rightSidePanel.getComponent(i).getBounds();
      preferredSize.width = Math.max(bounds.x + bounds.width, preferredSize.width);
      preferredSize.height = Math.max(bounds.y + bounds.height, preferredSize.height);
    }
    Insets insets = rightSidePanel.getInsets();
    preferredSize.width += insets.right + 20;
    preferredSize.height += insets.bottom;
    rightSidePanel.setMinimumSize(preferredSize);
    rightSidePanel.setPreferredSize(preferredSize);
    mainPanel.add(bigPanel, BorderLayout.CENTER);
    mainPanel.add(rightSidePanel, BorderLayout.EAST);
  }
示例#25
0
  public ConditionPanel(TriggerDialog owner, @Nullable Condition condition) {
    super();

    BoxLayout layout = new BoxLayout(this, BoxLayout.Y_AXIS);
    setLayout(layout);
    setBorder(BorderFactory.createEmptyBorder(10, 5, 10, 5));

    this.owner = owner;
    ConditionTemplate[] templates = ConditionTemplates.getInstance().getTemplates();
    Arrays.sort(templates);
    conditionType = new JComboBox(templates);
    parameterPanels = new JPanel(new GridLayout(0, 1, 0, 5));
    addCondition = new JButton("+");
    removeCondition = new JButton("-");

    final JPanel header = new JPanel();
    header.add(conditionType);
    header.add(removeCondition);
    header.add(addCondition);

    add(header);
    add(parameterPanels);

    final TriggerDialog dialog = this.owner;
    conditionType.addItemListener(
        new ItemListener() {
          public void itemStateChanged(@Nonnull ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
              parameterPanels.removeAll();
              ConditionTemplate template = (ConditionTemplate) e.getItem();
              for (int i = 0; i < template.size(); ++i) {
                ParameterPanel parameter = new ParameterPanel(template.getParameter(i));

                parameterPanels.add(parameter);
              }
              dialog.pack();
              dialog.validate();
            } else if (e.getStateChange() == ItemEvent.DESELECTED) {
              parameterPanels.removeAll();
              dialog.pack();
              dialog.validate();
            }
          }
        });

    conditionType.setSelectedIndex(-1);
    if (condition != null) {
      conditionType.setSelectedItem(
          ConditionTemplates.getInstance().getTemplate(condition.getType()));
      Object[] parameters = condition.getParameters();
      for (int i = 0; i < parameters.length; ++i) {
        ParameterPanel panel = (ParameterPanel) parameterPanels.getComponent(i);
        panel.setParameter(parameters[i]);
      }
    }

    addCondition.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            dialog.addCondition();
          }
        });

    final ConditionPanel conditionPanel = this;
    removeCondition.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            dialog.removeCondition(conditionPanel);
          }
        });
  }
示例#26
0
 /**
  * Returns the currently displaying JComponent.
  *
  * @return The currently displaying JComponent.
  */
 JComponent getJComponent() {
   return (JComponent) mainPanel.getComponent(0);
 }
 public void testLabelFor() throws Exception {
   JPanel panel = (JPanel) getInstrumentedRootComponent("TestLabelFor.form", "BindingTest");
   JTextField textField = (JTextField) panel.getComponent(0);
   JLabel label = (JLabel) panel.getComponent(1);
   assertEquals(textField, label.getLabelFor());
 }
示例#28
0
 /**
  * Returns the name of the currently displaying JComponent.
  *
  * @return The name of the currently displaying JComponent.
  */
 String getComponentName() {
   return mainPanel.getComponent(0).getName();
 }
  public LibraryBundlingEditorComponent(@NotNull Project project) {
    myProject = project;
    GuiUtils.replaceJSplitPaneWithIDEASplitter(myMainPanel);
    ((JBSplitter) myMainPanel.getComponent(0)).setProportion(0.4f);

    myRulesPanel.add(
        ToolbarDecorator.createDecorator(myRulesList)
            .setAddAction(
                new AnActionButtonRunnable() {
                  @Override
                  public void run(AnActionButton button) {
                    updateCurrentRule();
                    myRulesModel.add(new LibraryBundlificationRule());
                    myRulesList.setSelectedIndex(myRulesModel.getSize() - 1);
                    updateFields();
                  }
                })
            .setRemoveAction(
                new AnActionButtonRunnable() {
                  @Override
                  public void run(AnActionButton button) {
                    myLastSelected = -1;
                    if (myRulesModel.getSize() == 1) {
                      myRulesModel.setElementAt(new LibraryBundlificationRule(), 0);
                      myRulesList.setSelectedIndex(0);
                    } else {
                      int index = myRulesList.getSelectedIndex();
                      myRulesModel.remove(index);
                      myRulesList.setSelectedIndex(index > 0 ? index - 1 : 0);
                    }
                    updateFields();
                  }
                })
            .setMoveUpAction(
                new AnActionButtonRunnable() {
                  @Override
                  public void run(AnActionButton button) {
                    updateCurrentRule();
                    myLastSelected = -1;
                    ListUtil.moveSelectedItemsUp(myRulesList);
                    updateFields();
                  }
                })
            .setMoveDownAction(
                new AnActionButtonRunnable() {
                  @Override
                  public void run(AnActionButton button) {
                    updateCurrentRule();
                    myLastSelected = -1;
                    ListUtil.moveSelectedItemsDown(myRulesList);
                    updateFields();
                  }
                })
            .addExtraAction(
                new AnActionButton("Copy", PlatformIcons.COPY_ICON) {
                  @Override
                  public void actionPerformed(AnActionEvent e) {
                    updateCurrentRule();
                    int index = myRulesList.getSelectedIndex();
                    if (index >= 0) {
                      myRulesModel.add(myRulesModel.getElementAt(index).copy());
                      myRulesList.setSelectedIndex(myRulesModel.getSize() - 1);
                      updateFields();
                    }
                  }

                  @Override
                  public boolean isEnabled() {
                    return myRulesList.getSelectedIndex() >= 0;
                  }
                })
            .createPanel(),
        BorderLayout.CENTER);

    myRulesModel = new CollectionListModel<>();
    //noinspection unchecked
    myRulesList.setModel(myRulesModel);
    myRulesList.addListSelectionListener(
        new ListSelectionListener() {
          @Override
          public void valueChanged(ListSelectionEvent e) {
            updateCurrentRule();
            updateFields();
          }
        });
  }