Beispiel #1
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 JPanel createCompPanel() {
      filesets = new Vector();

      int count = installer.getIntegerProperty("comp.count");
      JPanel panel = new JPanel(new GridLayout(count, 1));

      String osClass = OperatingSystem.getOperatingSystem().getClass().getName();
      osClass = osClass.substring(osClass.indexOf('$') + 1);

      for (int i = 0; i < count; i++) {
        String os = installer.getProperty("comp." + i + ".os");

        if (os != null && !osClass.equals(os)) continue;

        JCheckBox checkBox =
            new JCheckBox(
                installer.getProperty("comp." + i + ".name")
                    + " ("
                    + installer.getProperty("comp." + i + ".disk-size")
                    + "Mb)");
        checkBox.getModel().setSelected(true);
        checkBox.addActionListener(this);
        checkBox.setRequestFocusEnabled(false);

        filesets.addElement(new Integer(i));

        panel.add(checkBox);
      }

      Dimension dim = panel.getPreferredSize();
      dim.width = Integer.MAX_VALUE;
      panel.setMaximumSize(dim);

      return panel;
    }
  private void helpButtonActionPerformed(java.awt.event.ActionEvent evt) {
    JPopupMenu jp = new JPopupMenu();

    JMenuItem mi = new JMenuItem("Help"); // No i18n
    JPanel panel = new JPanel();

    String msgTxt =
        "<html>Drops redundant events/alerts. <br>The suppressed/dropped Events/alerts will not <br>be added to the database. <br>You can choose to suppress all events/alerts <br>or only those that occur after a <br>certain period of time. <br>Refer Admin Guide for details.</html>"; // No i18n

    /*JTextArea ep = new JTextArea();
    ep.setColumns(20);
    ep.setLineWrap(true);
    ep.setRows(10);
    ep.setBackground(new java.awt.Color(200, 200, 200));
    ep.setWrapStyleWord(true);*/
    JLabel ep = new JLabel();
    ep.setSize(300, 200);
    ep.setText(msgTxt);
    panel.add(ep);

    mi.setLayout(new BorderLayout());
    mi.setPreferredSize(panel.getPreferredSize());
    mi.setFocusPainted(false);
    mi.add(panel, BorderLayout.CENTER);
    jp.setLayout(new BorderLayout());
    jp.add(mi, BorderLayout.CENTER);
    jp.show(helpButton, -60, -60);
  }
Beispiel #4
0
  /** Construct a FileTree */
  public FilePanel(JPanel panel, final IDEWindow ideWindow) {

    pane = panel;
    setLayout(new BorderLayout());
    // Make a tree list with all the nodes, and make it a JTree
    JTree tree = new JTree(addNodes(null, new File(System.getProperty("user.dir"))));

    // Add a listener
    tree.addTreeSelectionListener(
        new TreeSelectionListener() {
          public void valueChanged(TreeSelectionEvent e) {

            DefaultMutableTreeNode node =
                (DefaultMutableTreeNode) e.getPath().getLastPathComponent();

            File file = null;

            if (node.isLeaf()) {
              file = new File(node.getParent() + "/" + node);
              ToolbarFunctions.open(file, ideWindow);
            }
          }
        });

    setSize(panel.getPreferredSize());
    // Lastly, put the JTree into a JScrollPane.
    JScrollPane scrollpane = new JScrollPane();
    scrollpane.getViewport().add(tree);

    add(BorderLayout.CENTER, scrollpane);
  }
 ToolAdaptersManagementDialog(AppContext appContext, String title, String helpID) {
   super(appContext.getApplicationWindow(), title, 0, helpID);
   this.appContext = appContext;
   JPanel contentPanel = createContentPanel();
   setContent(contentPanel);
   super.getJDialog().setMinimumSize(contentPanel.getPreferredSize());
 }
  private void initGui() {
    JComponent filler =
        new JComponent() {
          @Override
          public Dimension getPreferredSize() {
            return myTextLabel.getPreferredSize();
          }
        };
    setLayout(new BorderLayout());
    setBorder(BorderFactory.createEmptyBorder(3, 20, 3, 20));

    add(myTextLabel, BorderLayout.WEST);
    Box box = Box.createHorizontalBox();
    box.add(Box.createHorizontalGlue());
    JPanel panel = new JPanel(new GridLayout(1, myLabels.size(), 0, 0));
    for (final JComponent myLabel : myLabels) {
      panel.add(myLabel);
    }
    panel.setMaximumSize(panel.getPreferredSize());
    box.add(panel);
    box.add(Box.createHorizontalGlue());
    add(box, BorderLayout.CENTER);

    add(filler, BorderLayout.EAST);
  }
 public void setLocation(@NotNull final Point screenPoint) {
   if (myPopup == null) {
     myForcedLocation = screenPoint;
   } else {
     moveTo(myContent, screenPoint, myLocateByContent ? myHeaderPanel.getPreferredSize() : null);
   }
 }
Beispiel #8
0
  public void addPanel(String name, JPanel panel) {

    if (tabbedPane.getTabCount() == 0) {
      preffered = panel.getPreferredSize();
    }

    panel.setPreferredSize(preffered);
    tabbedPane.add(name, panel);
  }
  @Override
  public Point getLocationOnScreen() {
    Dimension headerCorrectionSize = myLocateByContent ? myHeaderPanel.getPreferredSize() : null;
    Point screenPoint = myContent.getLocationOnScreen();
    if (headerCorrectionSize != null) {
      screenPoint.y -= headerCorrectionSize.height;
    }

    return screenPoint;
  }
Beispiel #10
0
  /**
   * The constructor for the class It's going to set the dimension of the program to 600x600, the
   * background is going to be white (in order to blend in with the vor image), and it is going to
   * add in the VOR radar and a radial indicator that will let the user know which radial he/she is
   * on
   */
  public finalVORGUI(int r) {
    deg = r;
    this.vor = new VorReceiver(deg, ".- -... -.-.");
    this.vor.setOBS(90); // set the OBS to 30
    JLayeredPane lp = new JLayeredPane();
    lp.setPreferredSize(new Dimension(WIDTH, HEIGHT));
    setBackground(Color.white);
    lp.setLayout(null);
    lp.setFocusable(true);
    degrees = deg; // r is intended radial
    CurrentRadial =
        new JLabel(
            "Intended Radial: "
                + deg); // A string that is always going to be above the radar. it's going to let
    // the user know the current radial
    CurrentRadial.setBounds(220, 18, 200, 200);
    MorseCode = new JLabel("Station: TO ENTER HERE");
    MorseCode.setBounds(200, 500, 200, 50);
    MorseCode.setText("Station: " + this.vor.getMorse());

    // vor.printVorStatus_v1();
    rotationPanel = new JPanel();
    rotationPanel = new TurningCanvas();
    rotationPanel.setBounds(
        157, 125, rotationPanel.getPreferredSize().width, rotationPanel.getPreferredSize().height);
    needle = new JPanel();
    needle = new DrawAttributes();
    needle.setBounds(100, 0, needle.getPreferredSize().width, needle.getPreferredSize().height);
    OBS = new JPanel();
    OBS = new AddButtons();
    OBS.setBounds(110, 350, 200, 100);
    lp.add(rotationPanel, Integer.valueOf(1));
    lp.add(needle, Integer.valueOf(2));
    lp.add(OBS, Integer.valueOf(3));
    lp.add(CurrentRadial, Integer.valueOf(4));
    lp.add(MorseCode, Integer.valueOf(5));
    add(lp);

    x = 172; // x is the location of the needle
    y1 = 155;
    y2 = 330;
  }
  /**
   * If the <code>preferredSize</code> has been set to a non-<code>null</code> value just returns
   * it. If the UI delegate's <code>getPreferredSize</code> method returns a non <code>null</code>
   * value then return that; otherwise defer to the component's layout manager.
   *
   * @return the value of the <code>preferredSize</code> property
   * @see #setPreferredSize
   * @see javax.swing.plaf.ComponentUI
   */
  @Override
  public Dimension getPreferredSize() {
    if (listPanel == null) {
      return super.getPreferredSize();
    } else {

      Dimension d = listPanel.getPreferredSize();
      Component p = getRootPane();
      int h = listPanel.isVisible() ? d.height : 0;
      int w = p == null ? d.width : getParent().getWidth();
      return new Dimension(w, 3 + 3 + 30 + h);
    }
  }
  public BorderedComponent(String text, JComponent comp, boolean collapsible) {
    super(null);

    this.comp = comp;

    // Only add border if text is not null
    if (text != null) {
      TitledBorder border;
      if (collapsible) {
        final JLabel textLabel = new JLabel(text);
        JPanel borderLabel =
            new JPanel(new FlowLayout(FlowLayout.LEFT, 2, 0)) {
              public int getBaseline(int w, int h) {
                Dimension dim = textLabel.getPreferredSize();
                return textLabel.getBaseline(dim.width, dim.height) + textLabel.getY();
              }
            };
        borderLabel.add(textLabel);
        border = new LabeledBorder(borderLabel);
        textLabel.setForeground(border.getTitleColor());

        if (IS_WIN) {
          collapseIcon = new ImageIcon(getImage("collapse-winlf"));
          expandIcon = new ImageIcon(getImage("expand-winlf"));
        } else {
          collapseIcon = new ArrowIcon(SOUTH, textLabel);
          expandIcon = new ArrowIcon(EAST, textLabel);
        }

        moreOrLessButton = new JButton(collapseIcon);
        moreOrLessButton.setContentAreaFilled(false);
        moreOrLessButton.setBorderPainted(false);
        moreOrLessButton.setMargin(new Insets(0, 0, 0, 0));
        moreOrLessButton.addActionListener(this);
        String toolTip = Messages.BORDERED_COMPONENT_MORE_OR_LESS_BUTTON_TOOLTIP;
        moreOrLessButton.setToolTipText(toolTip);
        borderLabel.add(moreOrLessButton);
        borderLabel.setSize(borderLabel.getPreferredSize());
        add(borderLabel);
      } else {
        border = new TitledBorder(text);
      }
      setBorder(new CompoundBorder(new FocusBorder(this), border));
    } else {
      setBorder(new FocusBorder(this));
    }
    if (comp != null) {
      add(comp);
    }
  }
 @Override
 public void actionPerformed(AnActionEvent e) {
   JPanel result = new JPanel(new BorderLayout());
   JLabel label = new JLabel("Lines around:");
   label.setBorder(BorderFactory.createEmptyBorder(4, 4, 0, 0));
   JPanel wrapper = new JPanel(new BorderLayout());
   wrapper.add(label, BorderLayout.NORTH);
   result.add(wrapper, BorderLayout.WEST);
   final JSlider slider = new JSlider(JSlider.HORIZONTAL, 1, 5, 1);
   slider.setMinorTickSpacing(1);
   slider.setPaintTicks(true);
   slider.setPaintTrack(true);
   slider.setSnapToTicks(true);
   UIUtil.setSliderIsFilled(slider, true);
   slider.setPaintLabels(true);
   slider.setLabelTable(LABELS);
   result.add(slider, BorderLayout.CENTER);
   final VcsConfiguration configuration = VcsConfiguration.getInstance(myProject);
   for (int i = 0; i < ourMarks.length; i++) {
     int mark = ourMarks[i];
     if (mark == configuration.SHORT_DIFF_EXTRA_LINES) {
       slider.setValue(i + 1);
     }
   }
   JBPopup popup =
       JBPopupFactory.getInstance().createComponentPopupBuilder(result, slider).createPopup();
   popup.setFinalRunnable(
       new Runnable() {
         @Override
         public void run() {
           int value = slider.getModel().getValue();
           if (configuration.SHORT_DIFF_EXTRA_LINES != ourMarks[value - 1]) {
             configuration.SHORT_DIFF_EXTRA_LINES = ourMarks[value - 1];
             myFragmentedContent.recalculate();
             refreshData(myFragmentedContent);
           }
         }
       });
   InputEvent inputEvent = e.getInputEvent();
   if (inputEvent instanceof MouseEvent) {
     int width = result.getPreferredSize().width;
     MouseEvent inputEvent1 = (MouseEvent) inputEvent;
     Point point1 = new Point(inputEvent1.getX() - width / 2, inputEvent1.getY());
     RelativePoint point = new RelativePoint(inputEvent1.getComponent(), point1);
     popup.show(point);
   } else {
     popup.showInBestPositionFor(e.getDataContext());
   }
 }
  @Override
  public void doLayout() {
    if (labelBar == null || listPanel == null) return;

    Dimension d = listPanel.getPreferredSize();
    Component p = getParent();
    int w = p == null ? d.width : getParent().getWidth();

    int y = 0;
    labelBar.setBounds(0, y, w, 30);
    y += 30;

    //noinspection SuspiciousNameCombination
    listPanel.setBounds(y, 33, w, d.height);
  }
  private void init() {
    setLayout(new BorderLayout(0, 5));
    setBorder(makeBorder());

    Box box = Box.createVerticalBox();
    box.add(makeTitlePanel());
    box.add(createResetPanel());
    box.add(createParameterPanel());
    box.add(createFilenamePanel());
    add(box, BorderLayout.NORTH);

    JPanel panel = createScriptPanel();
    add(panel, BorderLayout.CENTER);
    // Don't let the input field shrink too much
    add(Box.createVerticalStrut(panel.getPreferredSize().height), BorderLayout.WEST);
  }
  private JPanel createContentPanel() {
    // compute content and other buttons
    SpringLayout springLayout = new SpringLayout();
    JPanel panel = new JPanel(springLayout);
    int panelHeight = 0;
    JTable propertiesPanel = createPropertiesPanel();
    panelHeight += propertiesPanel.getPreferredSize().getHeight();
    panel.add(propertiesPanel);
    panelHeight += 10;
    panel.add(Box.createVerticalStrut(10));
    JScrollPane scrollPane = new JScrollPane(createAdaptersPanel());
    panelHeight += scrollPane.getPreferredSize().getHeight();
    panel.add(scrollPane);
    panelHeight += 10;
    panel.add(Box.createVerticalStrut(10));
    JPanel buttonsPanel = createButtonsPanel();
    panelHeight += buttonsPanel.getPreferredSize().getHeight();
    panel.add(buttonsPanel);

    springLayout.putConstraint(
        SpringLayout.NORTH, panel, DEFAULT_PADDING, SpringLayout.NORTH, propertiesPanel);
    springLayout.putConstraint(
        SpringLayout.WEST, panel, DEFAULT_PADDING, SpringLayout.WEST, propertiesPanel);
    springLayout.putConstraint(
        SpringLayout.EAST, panel, DEFAULT_PADDING, SpringLayout.EAST, propertiesPanel);
    springLayout.putConstraint(
        SpringLayout.NORTH, scrollPane, DEFAULT_PADDING, SpringLayout.SOUTH, propertiesPanel);
    springLayout.putConstraint(
        SpringLayout.WEST, panel, DEFAULT_PADDING, SpringLayout.WEST, scrollPane);
    springLayout.putConstraint(
        SpringLayout.EAST, panel, DEFAULT_PADDING, SpringLayout.EAST, scrollPane);
    springLayout.putConstraint(
        SpringLayout.NORTH, scrollPane, DEFAULT_PADDING, SpringLayout.SOUTH, buttonsPanel);
    springLayout.putConstraint(
        SpringLayout.WEST, panel, DEFAULT_PADDING, SpringLayout.WEST, buttonsPanel);
    springLayout.putConstraint(
        SpringLayout.EAST, panel, DEFAULT_PADDING, SpringLayout.EAST, buttonsPanel);

    panel.setPreferredSize(
        new Dimension(
            CHECK_COLUMN_WIDTH + LABEL_COLUMN_WIDTH + COLUMN_WIDTH - 32,
            panelHeight + DEFAULT_PADDING));
    makeCompactGrid(panel, 5, 1, 0, 0, 0, 0);
    return panel;
  }
  public ScalaApplicationSettingsForm(ScalaApplicationSettings settings) {
    mySettings = settings;

    myEnableCompileServer.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent e) {
            updateCompilationServerSettingsPanel();
          }
        });

    initCompilerTypeCmb();
    initCompileOrderCmb();

    ProjectSdksModel model = new ProjectSdksModel();
    model.reset(null);

    myCompilationServerSdk = new JdkComboBox(model);
    myCompilationServerSdk.insertItemAt(new JdkComboBox.NoneJdkComboBoxItem(), 0);

    mySdkPanel.add(myCompilationServerSdk, BorderLayout.CENTER);
    mySdkPanel.setSize(mySdkPanel.getPreferredSize());

    myNote.setForeground(JBColor.GRAY);

    delaySpinner.setEnabled(showTypeInfoOnCheckBox.isSelected());
    showTypeInfoOnCheckBox.addItemListener(
        new ItemListener() {
          @Override
          public void itemStateChanged(ItemEvent e) {
            delaySpinner.setEnabled(showTypeInfoOnCheckBox.isSelected());
          }
        });
    delaySpinner.setValue(mySettings.SHOW_TYPE_TOOLTIP_DELAY);

    updateCompilationServerSettingsPanel();
  }
  /* Build up the GUI using Swing magic. Nothing very exciting here - the
  BagPanel class makes the code a bit cleaner/easier to read. */
  private void guiInit() throws Exception {
    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.setMinimumSize(new Dimension(500, 250));
    mainPanel.setPreferredSize(new Dimension(500, 300));

    /* The message area */
    JScrollPane mssgPanel = new JScrollPane();
    mssgPanel.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    mssgPanel.setAutoscrolls(true);
    mssgArea = new JTextArea();
    mssgArea.setFont(new java.awt.Font("Monospaced", Font.PLAIN, 20));
    mainPanel.add(mssgPanel, BorderLayout.CENTER);
    mssgPanel.getViewport().add(mssgArea, null);

    /* The button area */
    BagPanel buttonPanel = new BagPanel();
    GridBagConstraints c = buttonPanel.c;

    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridwidth = GridBagConstraints.REMAINDER;

    buttonPanel.makeLabel("Detection", JLabel.CENTER);
    c.gridwidth = GridBagConstraints.RELATIVE;
    detDarkCb = buttonPanel.makeCheckBox("Dark", true);
    c.gridwidth = GridBagConstraints.REMAINDER;
    detAccelCb = buttonPanel.makeCheckBox("Movement", false);
    buttonPanel.makeSeparator(SwingConstants.HORIZONTAL);

    buttonPanel.makeLabel("Theft Reports", JLabel.CENTER);
    c.gridwidth = GridBagConstraints.RELATIVE;
    repLedCb = buttonPanel.makeCheckBox("LED", true);
    c.gridwidth = GridBagConstraints.REMAINDER;
    repSirenCb = buttonPanel.makeCheckBox("Siren", false);
    c.gridwidth = GridBagConstraints.RELATIVE;
    repServerCb = buttonPanel.makeCheckBox("Server", false);
    c.gridwidth = GridBagConstraints.REMAINDER;
    repNeighboursCb = buttonPanel.makeCheckBox("Neighbours", false);
    buttonPanel.makeSeparator(SwingConstants.HORIZONTAL);

    buttonPanel.makeLabel("Interval", JLabel.CENTER);
    fieldInterval = buttonPanel.makeTextField(10, null);
    fieldInterval.setText(Integer.toString(Constants.DEFAULT_CHECK_INTERVAL));

    ActionListener settingsAction =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            updateSettings();
          }
        };
    buttonPanel.makeButton("Update", settingsAction);

    mainPanel.add(buttonPanel, BorderLayout.EAST);

    /* The frame part */
    frame = new JFrame("AntiTheft");
    frame.setSize(mainPanel.getPreferredSize());
    frame.getContentPane().add(mainPanel);
    frame.setVisible(true);
    frame.addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent e) {
            System.exit(0);
          }
        });
  }
  /** Class constructor - make the JFrame ready */
  public TestProgram() {
    // Set screen size
    Toolkit tk = Toolkit.getDefaultToolkit();
    int x = (int) tk.getScreenSize().getWidth() - 150;
    int y = (int) tk.getScreenSize().getHeight() - 100;
    this.setSize(x, y);

    // Some settings
    this.setTitle("Friends With Benefits - Test program");
    field = new Field();
    random = new Random(System.currentTimeMillis());

    // Set the panel
    c = this.getContentPane();
    c.setLayout(new BorderLayout());

    contentpanel = new ContentPanel();
    contentpanel.setField(field);
    c.add(contentpanel, BorderLayout.CENTER);

    // Menupanel
    menupanel = new JPanel();
    layout = new GroupLayout(menupanel);
    menupanel.setLayout(layout);
    c.add(menupanel, BorderLayout.EAST);

    progress = new JProgressBar(0, 99);
    progress.setValue(99);

    open = new JButton("Open");
    open.setFocusPainted(false);
    save = new JButton("Save");
    save.setFocusPainted(false);
    open.addActionListener(this);
    save.addActionListener(this);

    everywhere = new JRadioButton("Everywhere");
    everywhere.setFocusPainted(false);
    inRectangle = new JRadioButton("In bounding rectangle");
    inRectangle.setFocusPainted(false);
    inRectangle.setSelected(true);

    placeOfCluster = new ButtonGroup();
    placeOfCluster.add(everywhere);
    placeOfCluster.add(inRectangle);

    addnoise = new JButton("Add noise");
    addnoise.setFocusPainted(false);
    addnoise.addActionListener(this);

    circle = new JRadioButton("Circle");
    circle.setFocusPainted(false);
    square = new JRadioButton("Square");
    square.setFocusPainted(false);
    circle.setSelected(true);

    squarecircle = new ButtonGroup();
    squarecircle.add(circle);
    squarecircle.add(square);

    fillFactor = new JSlider();
    fillFactor.setMajorTickSpacing(20);
    fillFactor.setMinorTickSpacing(5);
    fillFactor.setPaintTicks(true);

    addacluster = new JButton("Add simple cluster");
    addacluster.setFocusPainted(false);
    addacluster.addActionListener(this);

    clear = new JButton("Clear field");
    clear.addActionListener(this);
    clear.setFocusPainted(false);

    center = new JButton("Center field");
    center.addActionListener(this);
    center.setFocusPainted(false);

    minAlgo = new JTextField();
    minAlgo.setText("0");
    maxAlgo = new JTextField();
    maxAlgo.setText("10");
    run = new JButton("Run algo");
    run.addActionListener(this);
    run.setFocusPainted(false);

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

    JSeparator sep1 = new JSeparator();
    JSeparator sep2 = new JSeparator();
    JSeparator sep3 = new JSeparator();
    JSeparator sep4 = new JSeparator();
    JLabel runalgo = new JLabel("Run algorithm"), addcluster = new JLabel("Add simple cluster");
    JLabel addNoise = new JLabel("Add noise"), fillf = new JLabel("Fill factor:");
    JLabel minalgo = new JLabel("Min:"), maxalgo = new JLabel("Max:");
    addcluster.setFont(f);
    addNoise.setFont(f);
    runalgo.setFont(f);

    fillFactor.setPreferredSize(
        new Dimension(
            menupanel.getPreferredSize().width / 2, fillFactor.getPreferredSize().height));

    layout.setHorizontalGroup(
        layout
            .createParallelGroup(GroupLayout.Alignment.CENTER)
            .addGroup(
                layout.createSequentialGroup().addComponent(open).addGap(2).addComponent(save))
            .addComponent(sep1)
            .addComponent(addNoise)
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addComponent(everywhere)
                    .addComponent(inRectangle))
            .addComponent(addnoise)
            .addComponent(sep2)
            .addComponent(addcluster)
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.LEADING)
                    .addComponent(circle)
                    .addComponent(square))
            .addComponent(fillf)
            .addComponent(fillFactor)
            .addComponent(addacluster)
            .addComponent(sep3)
            .addComponent(center)
            .addComponent(clear)
            .addComponent(sep4)
            .addComponent(runalgo)
            .addGroup(
                layout
                    .createSequentialGroup()
                    .addComponent(minalgo)
                    .addGap(2)
                    .addComponent(minAlgo)
                    .addGap(10)
                    .addComponent(maxalgo)
                    .addGap(2)
                    .addComponent(maxAlgo))
            .addComponent(run)
            .addComponent(empty)
            .addComponent(progress));
    layout.setVerticalGroup(
        layout
            .createSequentialGroup()
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(open)
                    .addComponent(save))
            .addGap(5)
            .addComponent(sep1)
            .addGap(5)
            .addComponent(addNoise)
            .addComponent(everywhere)
            .addComponent(inRectangle)
            .addGap(3)
            .addComponent(addnoise)
            .addGap(5)
            .addComponent(sep2)
            .addGap(5)
            .addComponent(addcluster)
            .addComponent(circle)
            .addComponent(square)
            .addGap(3)
            .addComponent(fillf)
            .addGap(3)
            .addComponent(fillFactor)
            .addGap(3)
            .addComponent(addacluster)
            .addGap(5)
            .addComponent(sep3)
            .addGap(5)
            .addComponent(center)
            .addGap(3)
            .addComponent(clear)
            .addGap(5)
            .addComponent(sep4)
            .addGap(5)
            .addComponent(runalgo)
            .addGap(3)
            .addGroup(
                layout
                    .createParallelGroup(GroupLayout.Alignment.BASELINE)
                    .addComponent(minalgo)
                    .addComponent(minAlgo)
                    .addComponent(maxalgo)
                    .addComponent(maxAlgo))
            .addComponent(run)
            .addComponent(empty)
            .addComponent(progress));

    int width = menupanel.getPreferredSize().width;

    setSize(addNoise, width - 10);
    setSize(everywhere, width - 20);
    setSize(inRectangle, width - 20);
    setSize(addnoise, width);

    setSize(addcluster, width - 10);
    setSize(circle, width - 20);
    setSize(square, width - 20);
    setSize(addacluster, width);

    setSize(center, width);
    setSize(clear, width);

    setSize(runalgo, width - 10);
    setSize(minalgo, (int) Math.floor(width / 4) - 20);
    setMaxSize(minAlgo, (int) Math.ceil(width / 4));
    setSize(maxalgo, (int) Math.floor(width / 4) - 20);
    setMaxSize(maxAlgo, (int) Math.ceil(width / 4));
    setSize(run, width);

    empty.setPreferredSize(new Dimension(width, 1000));

    menupanel.setBorder(
        BorderFactory.createTitledBorder(
            BorderFactory.createLineBorder(Color.BLACK),
            "Menu",
            TitledBorder.CENTER,
            TitledBorder.DEFAULT_POSITION,
            f));
  }
  public DiameterCutOptionsTargetPanel() {
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    panel.add(GUIFactory.createLabel("Lungime:", 100));
    JFormattedTextField length = GUIFactory.createNumberInput(4100L, 0L, 1000000L, 80);
    panel.add(length);
    JComboBox<String> mCombo = new JComboBox<String>(GUIUtil.metric);
    mCombo.addItemListener(this);
    mCombo = new JComboBox<String>(GUIUtil.metric);
    mCombo.setPreferredSize(new Dimension(50, mCombo.getPreferredSize().height));
    panel.add(mCombo);
    add(panel);

    panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    panel.add(GUIFactory.createLabel("Diametru 1:", 100));
    JFormattedTextField smallRadius = GUIFactory.createNumberInput(200L, 0L, 1000000L, 80);
    panel.add(smallRadius);
    mCombo = new JComboBox<String>(GUIUtil.metric);
    mCombo.addItemListener(this);
    mCombo = new JComboBox<String>(GUIUtil.metric);
    mCombo.setPreferredSize(new Dimension(50, mCombo.getPreferredSize().height));
    panel.add(mCombo);
    add(panel);

    panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    panel.add(GUIFactory.createLabel("Diametru 2:", 100));
    JFormattedTextField bigRadius = GUIFactory.createNumberInput(600L, 0L, 1000000L, 80);
    panel.add(bigRadius);
    mCombo = new JComboBox<String>(GUIUtil.metric);
    mCombo.addItemListener(this);
    mCombo = new JComboBox<String>(GUIUtil.metric);
    mCombo.setPreferredSize(new Dimension(50, mCombo.getPreferredSize().height));
    panel.add(mCombo);
    add(panel);

    panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    label2 = GUIFactory.createLabel("Produse:", 100);
    panel.add(label2);
    products = ProductDAO.getProducts();
    JPanel productsPanel = new JPanel();
    productsPanel.setLayout(new BoxLayout(productsPanel, BoxLayout.Y_AXIS));
    for (Product product : products) {
      JPanel row = new JPanel(new FlowLayout(FlowLayout.LEFT));
      JCheckBox chk = new JCheckBox();
      row.add(chk);
      selection.add(chk);
      chk.setName("length" + (long) product.getLength());
      row.add(new JLabel(product.getName()));
      productsPanel.add(row);
    }
    JScrollPane scrollPane = new JScrollPane(productsPanel);
    scrollPane.setPreferredSize(new Dimension(productsPanel.getPreferredSize().width + 20, 215));
    panel.add(scrollPane);
    add(panel);

    JPanel filtru = new JPanel(new FlowLayout(FlowLayout.LEADING));
    filtru.add(filtru2m);
    filtru.add(filtru3m);
    filtru.add(filtru4m);
    filtru2m.setActionCommand("FILTRU2");
    filtru3m.setActionCommand("FILTRU3");
    filtru4m.setActionCommand("FILTRU4");
    filtru2m.addActionListener(this);
    filtru3m.addActionListener(this);
    filtru4m.addActionListener(this);
    panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    JLabel label1 = GUIFactory.createLabel("Filtru", 100);
    panel.add(label1);
    panel.add(filtru);
    add(panel);

    cancel.setActionCommand("CANCEL_DIALOG");
    cancel.addActionListener(GUIUtil.main);
    see.addActionListener(this);
  }
  private void initializeComponents() {
    this.setTitle("Configuration");
    this.setResizable(false);

    setLayout(new BorderLayout(20, 20));

    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.X_AXIS));
    mainPanel.setBorder(new LineBorder(mainPanel.getBackground(), 10));
    add(mainPanel, BorderLayout.CENTER);

    GridBagConstraints labelConstraints = new GridBagConstraints();
    labelConstraints.gridx = 0;
    labelConstraints.anchor = GridBagConstraints.WEST;
    labelConstraints.insets = new Insets(5, 5, 5, 5);

    GridBagConstraints inputConstraints = new GridBagConstraints();
    inputConstraints.gridx = 1;
    inputConstraints.anchor = GridBagConstraints.EAST;
    inputConstraints.weightx = 1;
    inputConstraints.insets = new Insets(5, 5, 5, 5);

    JPanel evolutionOptionsPanel = new JPanel();
    evolutionOptionsPanel.setBorder(new TitledBorder("Evolution"));
    evolutionOptionsPanel.setLayout(new BoxLayout(evolutionOptionsPanel, BoxLayout.Y_AXIS));
    mainPanel.add(evolutionOptionsPanel);

    // world size
    JPanel worldSizePanel = new JPanel(new GridBagLayout());
    evolutionOptionsPanel.add(worldSizePanel);
    JLabel worldSizeLabel = new JLabel("World Size");
    worldSizeLabel.setToolTipText("Size of the world in pixels. Width x Height.");
    worldSizePanel.add(worldSizeLabel, labelConstraints);
    JPanel worldSizeInputPanel = new JPanel();
    worldSizeInputPanel.setLayout(new GridBagLayout());
    final AutoSelectOnFocusSpinner worldSizeWidthSpinner =
        new AutoSelectOnFocusSpinner(
            new SpinnerNumberModel(config.getDimension().width, 1, Integer.MAX_VALUE, 1));
    final AutoSelectOnFocusSpinner worldSizeHeightSpinner =
        new AutoSelectOnFocusSpinner(
            new SpinnerNumberModel(config.getDimension().height, 1, Integer.MAX_VALUE, 1));
    worldSizeInputPanel.add(worldSizeWidthSpinner);
    JLabel separatorLabel = new JLabel("x");
    GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(0, 5, 0, 5);
    worldSizeInputPanel.add(separatorLabel, c);
    worldSizeInputPanel.add(worldSizeHeightSpinner);
    worldSizePanel.add(worldSizeInputPanel, inputConstraints);

    // starting energy
    JPanel startingEnergyPanel = new JPanel(new GridBagLayout());
    evolutionOptionsPanel.add(startingEnergyPanel);
    JLabel startingEnergyLabel = new JLabel("Starting Energy");
    startingEnergyLabel.setToolTipText(
        "<html>The amount of energy all newly painted pixels start out with.<br />Note that changing this will not affect already painted pixels.</html>");
    startingEnergyPanel.add(startingEnergyLabel, labelConstraints);
    final AutoSelectOnFocusSpinner startingEnergySpinner =
        new AutoSelectOnFocusSpinner(
            new SpinnerNumberModel(config.startingEnergy, 1, Integer.MAX_VALUE, 1));
    startingEnergyPanel.add(startingEnergySpinner, inputConstraints);

    // mutation rate
    JPanel mutationRatePanel = new JPanel(new GridBagLayout());
    evolutionOptionsPanel.add(mutationRatePanel);
    JLabel mutationRateLabel = new JLabel("Mutation Rate");
    mutationRateLabel.setToolTipText(
        "<html>Chance for a mutation to occur during copy or mixing operations.<br />A value of 0.01 means a 1% chance, a value of 0 disables mutation.</html>");
    mutationRatePanel.add(mutationRateLabel, labelConstraints);
    final JSpinner mutationRateSpinner =
        new JSpinner(new SpinnerNumberModel(config.mutationRate, 0.0, 1.0, 0.01));
    mutationRateSpinner.setEditor(
        new JSpinner.NumberEditor(mutationRateSpinner, "#.##############"));
    mutationRateSpinner.setPreferredSize(
        new Dimension(180, mutationRateSpinner.getPreferredSize().height));
    final JFormattedTextField mutationRateSpinnerText =
        ((JSpinner.NumberEditor) mutationRateSpinner.getEditor()).getTextField();
    mutationRateSpinnerText.addFocusListener(
        new FocusListener() {
          public void focusGained(FocusEvent e) {
            SwingUtilities.invokeLater(
                new Runnable() {
                  public void run() {
                    mutationRateSpinnerText.selectAll();
                  }
                });
          }

          public void focusLost(FocusEvent e) {}
        });
    mutationRatePanel.add(mutationRateSpinner, inputConstraints);

    JPanel guiOptionsPanel = new JPanel();
    guiOptionsPanel.setBorder(new TitledBorder("GUI"));
    guiOptionsPanel.setLayout(new BoxLayout(guiOptionsPanel, BoxLayout.Y_AXIS));
    mainPanel.add(guiOptionsPanel);

    // background color
    JPanel backgroundColorPanel = new JPanel(new GridBagLayout());
    guiOptionsPanel.add(backgroundColorPanel, labelConstraints);
    JLabel backgroundColorLabel = new JLabel("Background Color");
    backgroundColorLabel.setToolTipText(
        "<html>Pick the background color.<br />If you have a lot of dark pixels, you might want to set this to a light color.</html>");
    backgroundColorPanel.add(backgroundColorLabel, labelConstraints);
    backgroundColor = new PixelColor(config.backgroundColor);
    JPanel backgroundColorAlignmentPanel = new JPanel();
    backgroundColorAlignmentPanel.setLayout(new GridBagLayout());
    backgroundColorAlignmentPanel.setPreferredSize(mutationRateSpinner.getPreferredSize());
    final ColorChooserLabel backgroundColorChooserLabel = new ColorChooserLabel(backgroundColor);
    backgroundColorAlignmentPanel.add(backgroundColorChooserLabel);
    backgroundColorPanel.add(backgroundColorAlignmentPanel, inputConstraints);

    // FPS
    JPanel fpsPanel = new JPanel(new GridBagLayout());
    guiOptionsPanel.add(fpsPanel);
    JLabel fpsLabel = new JLabel("FPS");
    fpsLabel.setToolTipText(
        "<html>The repaint interval in frames per second (FPS).<br />Set this to a lower value to save a few CPU cycles.</html>");
    fpsPanel.add(fpsLabel, labelConstraints);
    final AutoSelectOnFocusSpinner fpsSpinner =
        new AutoSelectOnFocusSpinner(new SpinnerNumberModel(config.fps, 1, Integer.MAX_VALUE, 1));
    fpsPanel.add(fpsSpinner, inputConstraints);

    // paint history size
    JPanel paintHistorySizePanel = new JPanel(new GridBagLayout());
    guiOptionsPanel.add(paintHistorySizePanel);
    JLabel paintHistorySizeLabel = new JLabel("Paint-History Size");
    paintHistorySizeLabel.setToolTipText(
        "<html>Sets the number of entries in the paint history.<br />In case you have not found it yet: the paint history is the little menu that appears when you right-click on the image.</html>");
    paintHistorySizePanel.add(paintHistorySizeLabel, labelConstraints);
    final AutoSelectOnFocusSpinner paintHistorySizeSpinner =
        new AutoSelectOnFocusSpinner(
            new SpinnerNumberModel(config.paintHistorySize, 1, Integer.MAX_VALUE, 1));
    paintHistorySizePanel.add(paintHistorySizeSpinner, inputConstraints);

    JPanel videoOptionsPanel = new JPanel();
    videoOptionsPanel.setBorder(new TitledBorder("Video Recording"));
    videoOptionsPanel.setLayout(new BoxLayout(videoOptionsPanel, BoxLayout.Y_AXIS));
    mainPanel.add(videoOptionsPanel);

    // FPS video
    JPanel fpsVideoPanel = new JPanel(new GridBagLayout());
    videoOptionsPanel.add(fpsVideoPanel);
    JLabel fpsVideoLabel = new JLabel("FPS of videos");
    fpsVideoLabel.setToolTipText("The number of frames per second (FPS) in recorded videos.");
    fpsVideoPanel.add(fpsVideoLabel, labelConstraints);
    final AutoSelectOnFocusSpinner fpsVideoSpinner =
        new AutoSelectOnFocusSpinner(
            new SpinnerNumberModel(config.fpsVideo, 1, Integer.MAX_VALUE, 1));
    fpsVideoPanel.add(fpsVideoSpinner, inputConstraints);

    // video encoder command
    JPanel videoEncoderPanel = new JPanel(new GridBagLayout());
    videoOptionsPanel.add(videoEncoderPanel);
    JLabel videoEncoderLabel = new JLabel("Video Encoder");
    videoEncoderLabel.setToolTipText(
        "<html>The command to invoke your video encoder.<br />Use the tokens INPUT_FILE and OUTPUT_FILE to denote input and output files of your encoder.</html>");
    videoEncoderPanel.add(videoEncoderLabel, labelConstraints);
    final JTextArea videoEncoderTextArea = new JTextArea(Configuration.ENCODER_COMMAND);
    videoEncoderTextArea.setLineWrap(true);
    videoEncoderTextArea.setWrapStyleWord(true);
    JScrollPane videoEncoderScrollPane =
        new JScrollPane(
            videoEncoderTextArea,
            JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    videoEncoderScrollPane.setViewportBorder(null);
    videoEncoderScrollPane.setPreferredSize(
        new Dimension(worldSizeInputPanel.getPreferredSize().width, 100));
    videoEncoderPanel.add(videoEncoderScrollPane, inputConstraints);

    JPanel controlPanel = new JPanel();
    add(controlPanel, BorderLayout.SOUTH);

    JButton okButton = new JButton("OK");
    okButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {

            new Thread() {

              @Override
              public void run() {
                config.world.addChangeListener(
                    new IChangeListener() {

                      public void changed() {
                        int i, j;
                        double d;
                        String s;

                        // evolution

                        i = (Integer) worldSizeWidthSpinner.getValue();
                        j = (Integer) worldSizeHeightSpinner.getValue();
                        if (config.getDimension().width != i || config.getDimension().height != i) {
                          config.setDimension(new Dimension(i, j));
                        }

                        i = (Integer) startingEnergySpinner.getValue();
                        if (config.startingEnergy != i) {
                          config.startingEnergy = i;
                        }

                        d = (Double) mutationRateSpinner.getValue();
                        if (config.mutationRate != d) {
                          config.mutationRate = d;
                        }

                        // gui

                        i = backgroundColor.getInteger();
                        if (config.backgroundColor != i) {
                          config.backgroundColor = i;
                        }

                        i = (Integer) fpsSpinner.getValue();
                        if (config.fps != i) {
                          config.fps = i;
                        }

                        i = (Integer) paintHistorySizeSpinner.getValue();
                        if (config.paintHistorySize != i) {
                          config.paintHistorySize = i;
                        }

                        // video recording

                        i = (Integer) fpsVideoSpinner.getValue();
                        if (config.fpsVideo != i) {
                          config.fpsVideo = i;
                        }

                        s = videoEncoderTextArea.getText();
                        if (false == Configuration.ENCODER_COMMAND.equals(s)) {
                          Configuration.ENCODER_COMMAND = s;
                        }

                        dispose();
                      }
                    });
              }
            }.start();
          }
        });
    controlPanel.add(okButton);
    JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            dispose();
          }
        });
    controlPanel.add(cancelButton);

    pack();
  }
  public InfoPanelForDrawable(
      final Map map_line2treenodes, final String[] y_colnames, final Drawable dobj) {
    super();
    super.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    /* Define DecialFormat for the displayed time */
    if (fmt == null) {
      fmt = (DecimalFormat) NumberFormat.getInstance();
      fmt.applyPattern(FORMAT);
    }
    if (tfmt == null) tfmt = new TimeFormat();
    if (Normal_Border == null) {
      /*
      Normal_Border = BorderFactory.createCompoundBorder(
                      BorderFactory.createRaisedBevelBorder(),
                      BorderFactory.createLoweredBevelBorder() );
      */
      Normal_Border = BorderFactory.createEtchedBorder();
    }
    if (Shadow_Border == null) {
      Shadow_Border =
          BorderFactory.createTitledBorder(
              Normal_Border,
              " Preview State ",
              TitledBorder.LEFT,
              TitledBorder.TOP,
              Const.FONT,
              Color.magenta);
    }

    drawable = dobj;

    // Set the CategoryLabel Icon
    Dimension panel_max_size;
    Category type = null;
    CategoryLabel label_type = null;
    JPanel top_panel = new JPanel();
    top_panel.setLayout(new BoxLayout(top_panel, BoxLayout.X_AXIS));
    if (drawable instanceof Shadow && ((Shadow) drawable).getSelectedSubCategory() != null) {
      type = ((Shadow) drawable).getSelectedSubCategory();
      label_type = new CategoryLabel(type);
      ((Shadow) drawable).clearSelectedSubCategory();
      top_panel.setBorder(Shadow_Border);
    } else {
      type = drawable.getCategory();
      label_type = new CategoryLabel(type);
      top_panel.setBorder(Normal_Border);
    }
    top_panel.add(STRUT);
    top_panel.add(label_type);
    top_panel.add(GLUE);
    top_panel.setAlignmentX(Component.LEFT_ALIGNMENT);
    panel_max_size = top_panel.getPreferredSize();
    panel_max_size.width = Short.MAX_VALUE;
    top_panel.setMaximumSize(panel_max_size);
    super.add(top_panel);

    // Determine the text of the drawable
    TextAreaBuffer textbuf;
    int num_cols, num_rows;
    textbuf = new TextAreaBuffer(map_line2treenodes, y_colnames);
    if (drawable instanceof Shadow) textbuf.setShadowText((Shadow) drawable, type);
    else if (drawable instanceof Composite) textbuf.setCompositeText((Composite) drawable);
    else textbuf.setPrimitiveText((Primitive) drawable);
    textbuf.finalized();
    num_cols = textbuf.getColumnCount();
    num_rows = textbuf.getRowCount();

    // Set the TextArea
    JTextArea text_area;
    int adj_num_cols;
    text_area = new JTextArea(textbuf.toString());
    adj_num_cols = Routines.getAdjNumOfTextColumns(text_area, num_cols);
    num_cols = (int) Math.ceil(adj_num_cols * 85.0d / 100.0d);
    text_area.setColumns(num_cols);
    text_area.setRows(num_rows);
    text_area.setEditable(false);
    text_area.setLineWrap(true);
    JScrollPane scroller = new JScrollPane(text_area);
    scroller.setAlignmentX(Component.LEFT_ALIGNMENT);
    super.add(scroller);
  }
  /**
   * setupPanel.
   *
   * @param p a {@link javax.swing.JPanel} object.
   * @param list a {@link java.util.ArrayList} object.
   * @param stack a boolean.
   */
  private static void setupPanel(JPanel p, ArrayList<Card> list, boolean stack) {

    int maxY = 0;
    int maxX = 0;
    // remove all local enchantments

    Card c;
    /*
    for(int i = 0; i < list.size(); i++)
    {
      c = (Card)list.get(i);
      if(c.isLocalEnchantment())
        list.remove(i);
    }

    //add local enchantments to the permanents
    //put local enchantments "next to" the permanent they are enchanting
    //the inner for loop is backward so permanents with more than one local enchantments are in the right order
    Card ca[];
    for(int i = 0; i < list.size(); i++)
    {
      c = (Card)list.get(i);
      if(c.hasAttachedCards())
      {
        ca = c.getAttachedCards();
        for(int inner = ca.length - 1; 0 <= inner; inner--)
          list.add(i + 1, ca[inner]);
      }
    }
    */

    if (stack) {
      // add all Cards in list to the GUI, add arrows to Local Enchantments

      ArrayList<Card> manaPools = getManaPools(list);
      ArrayList<Card> enchantedLands = getEnchantedLands(list);
      ArrayList<Card> basicBlues = getBasics(list, Constant.Color.Blue);
      ArrayList<Card> basicReds = getBasics(list, Constant.Color.Red);
      ArrayList<Card> basicBlacks = getBasics(list, Constant.Color.Black);
      ArrayList<Card> basicGreens = getBasics(list, Constant.Color.Green);
      ArrayList<Card> basicWhites = getBasics(list, Constant.Color.White);
      ArrayList<Card> badlands = getNonBasicLand(list, "Badlands");
      ArrayList<Card> bayou = getNonBasicLand(list, "Bayou");
      ArrayList<Card> plateau = getNonBasicLand(list, "Plateau");
      ArrayList<Card> scrubland = getNonBasicLand(list, "Scrubland");
      ArrayList<Card> savannah = getNonBasicLand(list, "Savannah");
      ArrayList<Card> taiga = getNonBasicLand(list, "Taiga");
      ArrayList<Card> tropicalIsland = getNonBasicLand(list, "Tropical Island");
      ArrayList<Card> tundra = getNonBasicLand(list, "Tundra");
      ArrayList<Card> undergroundSea = getNonBasicLand(list, "Underground Sea");
      ArrayList<Card> volcanicIsland = getNonBasicLand(list, "Volcanic Island");

      ArrayList<Card> nonBasics = getNonBasics(list);

      ArrayList<Card> moxEmerald = getMoxen(list, "Mox Emerald");
      ArrayList<Card> moxJet = getMoxen(list, "Mox Jet");
      ArrayList<Card> moxPearl = getMoxen(list, "Mox Pearl");
      ArrayList<Card> moxRuby = getMoxen(list, "Mox Ruby");
      ArrayList<Card> moxSapphire = getMoxen(list, "Mox Sapphire");
      // ArrayList<Card> moxDiamond = getMoxen(list, "Mox Diamond");

      list = new ArrayList<Card>();
      list.addAll(manaPools);
      list.addAll(enchantedLands);
      list.addAll(basicBlues);
      list.addAll(basicReds);
      list.addAll(basicBlacks);
      list.addAll(basicGreens);
      list.addAll(basicWhites);
      list.addAll(badlands);
      list.addAll(bayou);
      list.addAll(plateau);
      list.addAll(scrubland);
      list.addAll(savannah);
      list.addAll(taiga);
      list.addAll(tropicalIsland);
      list.addAll(tundra);
      list.addAll(undergroundSea);
      list.addAll(volcanicIsland);

      list.addAll(nonBasics);

      list.addAll(moxEmerald);
      list.addAll(moxJet);
      list.addAll(moxPearl);
      list.addAll(moxRuby);
      list.addAll(moxSapphire);
      // list.addAll(moxDiamond);

      int atInStack = 0;

      int marginX = 5;
      int marginY = 5;

      int x = marginX;

      int cardOffset = Constant.Runtime.stackOffset[0];

      String color = "";
      ArrayList<JPanel> cards = new ArrayList<JPanel>();

      ArrayList<CardPanel> connectedCards = new ArrayList<CardPanel>();

      boolean nextEnchanted = false;
      Card prevCard = null;
      int nextXIfNotStacked = 0;
      for (int i = 0; i < list.size(); i++) {
        JPanel addPanel;
        c = list.get(i);

        addPanel = new CardPanel(c);

        boolean startANewStack = false;

        if (!isStackable(c)) {
          startANewStack = true;
        } else {
          String newColor = c.getName(); // CardUtil.getColor(c);

          if (!newColor.equals(color)) {
            startANewStack = true;
            color = newColor;
          }
        }

        if (i == 0) {
          startANewStack = false;
        }

        if (!startANewStack && atInStack == Constant.Runtime.stackSize[0]) {
          startANewStack = true;
        }

        if (c.isAura() && c.isEnchanting() && !nextEnchanted) startANewStack = false;
        else if (c.isAura() && c.isEnchanting()) {
          startANewStack = true;
          nextEnchanted = false;
        }

        if (c.isLand() && c.isEnchanted()) {
          startANewStack = false;
          nextEnchanted = true;
        }

        // very hacky, but this is to ensure enchantment stacking occurs correctly when a land is
        // enchanted, and there are more lands of that same name

        else if ((prevCard != null
            && c.isLand()
            && prevCard.isLand()
            && prevCard.isEnchanted()
            && prevCard.getName().equals(c.getName()))) startANewStack = true;
        else if (prevCard != null
            && c.isLand()
            && prevCard.isLand()
            && !prevCard.getName().equals(c.getName())) startANewStack = true;

        /*
        if (c.getName().equals("Squirrel Nest")) {
            startANewStack = true;
            System.out.println("startANewStack: " + startANewStack);
        }
        */
        if (c.isAura() && c.isEnchanting() && prevCard != null && prevCard instanceof ManaPool)
          startANewStack = true;
        if (c instanceof ManaPool && prevCard instanceof ManaPool && prevCard.isSnow())
          startANewStack = false;

        if (startANewStack) {
          setupConnectedCards(connectedCards);
          connectedCards.clear();

          // Fixed distance if last was a stack, looks a bit nicer
          if (atInStack > 1) {
            x +=
                Math.max(addPanel.getPreferredSize().width, addPanel.getPreferredSize().height)
                    + marginX;
          } else {
            x = nextXIfNotStacked;
          }

          atInStack = 0;
        } else {
          if (i != 0) {
            x += cardOffset;
          }
        }

        nextXIfNotStacked = x + marginX + addPanel.getPreferredSize().width;

        int xLoc = x;

        int yLoc = marginY;
        yLoc += atInStack * cardOffset;

        addPanel.setLocation(new Point(xLoc, yLoc));
        addPanel.setSize(addPanel.getPreferredSize());

        cards.add(addPanel);

        connectedCards.add((CardPanel) addPanel);

        atInStack++;
        prevCard = c;
      }

      setupConnectedCards(connectedCards);
      connectedCards.clear();

      for (int i = cards.size() - 1; i >= 0; i--) {
        JPanel card = cards.get(i);
        // maxX = Math.max(maxX, card.getLocation().x + card.getSize().width + marginX);
        maxY = Math.max(maxY, card.getLocation().y + card.getSize().height + marginY);
        p.add(card);
      }

      maxX = nextXIfNotStacked;

      // System.out.println("x:" + maxX + ", y:" + maxY);
      if (maxX > 0 && maxY > 0) { // p.getSize().width || maxY > p.getSize().height) {
        //        p.setSize(new Dimension(maxX, maxY));
        p.setPreferredSize(new Dimension(maxX, maxY));
      }

    } else {
      // add all Cards in list to the GUI, add arrows to Local Enchantments
      JPanel addPanel;
      for (int i = 0; i < list.size(); i++) {
        c = list.get(i);
        /*if(c.isLocalEnchantment())
          addPanel = getCardPanel(c, "<< " +c.getName());
        else
          addPanel = getCardPanel(c);
          */
        addPanel = new CardPanel(c);

        p.add(addPanel);
      }
    }
  } // setupPanel()
  /**
   * setupNoLandPermPanel.
   *
   * @param p a {@link javax.swing.JPanel} object.
   * @param list a {@link java.util.ArrayList} object.
   * @param stack a boolean.
   */
  private static void setupNoLandPermPanel(JPanel p, ArrayList<Card> list, boolean stack) {

    int maxY = 0;
    int maxX = 0;

    Card c;

    if (stack) {
      // add all Cards in list to the GUI, add arrows to Local Enchantments

      ArrayList<Card> planeswalkers = getPlaneswalkers(list);
      ArrayList<Card> equippedEnchantedCreatures =
          getEquippedEnchantedCreatures(
              list); // this will also fetch the equipment and/or enchantment
      ArrayList<Card> nonTokenCreatures = getNonTokenCreatures(list);
      ArrayList<Card> tokenCreatures = getTokenCreatures(list);

      // sort tokenCreatures by name (TODO: fix the warning message somehow)
      Collections.sort(
          tokenCreatures,
          new Comparator<Card>() {
            public int compare(Card c1, Card c2) {
              return c1.getName().compareTo(c2.getName());
            }
          });

      ArrayList<Card> artifacts = getNonCreatureArtifacts(list);
      ArrayList<Card> enchantments = getGlobalEnchantments(list);
      // ArrayList<Card> nonBasics = getNonBasics(list);

      list = new ArrayList<Card>();
      list.addAll(planeswalkers);
      list.addAll(equippedEnchantedCreatures);
      list.addAll(nonTokenCreatures);
      list.addAll(tokenCreatures);
      list.addAll(artifacts);
      list.addAll(enchantments);

      int atInStack = 0;

      int marginX = 5;
      int marginY = 5;

      int x = marginX;

      int cardOffset = Constant.Runtime.stackOffset[0];

      String color = "";
      ArrayList<JPanel> cards = new ArrayList<JPanel>();

      ArrayList<CardPanel> connectedCards = new ArrayList<CardPanel>();

      boolean nextEquippedEnchanted = false;
      int nextXIfNotStacked = 0;
      Card prevCard = null;
      for (int i = 0; i < list.size(); i++) {
        JPanel addPanel;
        c = list.get(i);
        addPanel = new CardPanel(c);

        boolean startANewStack = false;

        if (!isStackable(c)) {
          startANewStack = true;
        } else {
          String newColor = c.getName(); // CardUtil.getColor(c);

          if (!newColor.equals(color)) {
            startANewStack = true;
            color = newColor;
          }
        }

        if (i == 0) {
          startANewStack = false;
        }

        if (!startANewStack && atInStack == Constant.Runtime.stackSize[0]) {
          startANewStack = true;
        }

        if ((c.isEquipment() || c.isAura())
            && (c.isEquipping() || c.isEnchanting())
            && !nextEquippedEnchanted) startANewStack = false;
        else if ((c.isEquipment() || c.isAura()) && (c.isEquipping() || c.isEnchanting())) {
          startANewStack = true;
          nextEquippedEnchanted = false;
        }

        if (c.isCreature() && (c.isEquipped() || c.isEnchanted())) {
          startANewStack = false;
          nextEquippedEnchanted = true;
        }
        // very hacky, but this is to ensure equipment stacking occurs correctly when a token is
        // equipped/enchanted, and there are more tokens of that same name
        else if ((prevCard != null
            && c.isCreature()
            && prevCard.isCreature()
            && (prevCard.isEquipped() || prevCard.isEnchanted())
            && prevCard.getName().equals(c.getName()))) startANewStack = true;
        else if (prevCard != null
            && c.isCreature()
            && prevCard.isCreature()
            && !prevCard.getName().equals(c.getName())) startANewStack = true;

        if (((c.isAura() && c.isEnchanting()) || (c.isEquipment() && c.isEquipping()))
            && prevCard != null
            && prevCard.isPlaneswalker()) startANewStack = true;

        if (startANewStack) {
          setupConnectedCards(connectedCards);
          connectedCards.clear();

          // Fixed distance if last was a stack, looks a bit nicer
          if (atInStack > 1) {
            x +=
                Math.max(addPanel.getPreferredSize().width, addPanel.getPreferredSize().height)
                    + marginX;
          } else {
            x = nextXIfNotStacked;
          }

          atInStack = 0;
        } else {
          if (i != 0) {
            x += cardOffset;
          }
        }

        nextXIfNotStacked = x + marginX + addPanel.getPreferredSize().width;

        int xLoc = x;

        int yLoc = marginY;
        yLoc += atInStack * cardOffset;

        addPanel.setLocation(new Point(xLoc, yLoc));
        addPanel.setSize(addPanel.getPreferredSize());

        cards.add(addPanel);

        connectedCards.add((CardPanel) addPanel);

        atInStack++;
        prevCard = c;
      }

      setupConnectedCards(connectedCards);
      connectedCards.clear();

      for (int i = cards.size() - 1; i >= 0; i--) {
        JPanel card = cards.get(i);
        // maxX = Math.max(maxX, card.getLocation().x + card.getSize().width + marginX);
        maxY = Math.max(maxY, card.getLocation().y + card.getSize().height + marginY);
        p.add(card);
      }

      maxX = nextXIfNotStacked;

      if (maxX > 0 && maxY > 0) { // p.getSize().width || maxY > p.getSize().height) {
        p.setPreferredSize(new Dimension(maxX, maxY));
      }

    } else {
      JPanel addPanel;
      for (int i = 0; i < list.size(); i++) {
        c = list.get(i);
        addPanel = new CardPanel(c);

        p.add(addPanel);
      }
    }
  } // setupPanel()
  public void show(Component owner, int aScreenX, int aScreenY, final boolean considerForcedXY) {
    if (ApplicationManagerEx.getApplicationEx() != null
        && ApplicationManager.getApplication().isHeadlessEnvironment()) return;
    if (isDisposed()) {
      throw new IllegalStateException(
          "Popup was already disposed. Recreate a new instance to show again");
    }

    assert ApplicationManager.getApplication().isDispatchThread();

    addActivity();

    final boolean shouldShow = beforeShow();
    if (!shouldShow) {
      removeActivity();
      return;
    }

    prepareToShow();

    if (myInStack) {
      myFocusTrackback = new FocusTrackback(this, owner, true);
      myFocusTrackback.setMustBeShown(true);
    }

    Dimension sizeToSet = null;

    if (myDimensionServiceKey != null) {
      sizeToSet = DimensionService.getInstance().getSize(myDimensionServiceKey, myProject);
    }

    if (myForcedSize != null) {
      sizeToSet = myForcedSize;
    }

    if (myMinSize == null) {
      myMinSize = myContent.getMinimumSize();
    }

    if (sizeToSet == null) {
      sizeToSet = myContent.getPreferredSize();
    }

    if (sizeToSet != null) {
      sizeToSet.width = Math.max(sizeToSet.width, myMinSize.width);
      sizeToSet.height = Math.max(sizeToSet.height, myMinSize.height);

      myContent.setSize(sizeToSet);
      myContent.setPreferredSize(sizeToSet);
    }

    Point xy = new Point(aScreenX, aScreenY);
    boolean adjustXY = true;
    if (myDimensionServiceKey != null) {
      final Point storedLocation =
          DimensionService.getInstance().getLocation(myDimensionServiceKey, myProject);
      if (storedLocation != null) {
        xy = storedLocation;
        adjustXY = false;
      }
    }

    if (adjustXY) {
      final Insets insets = myContent.getInsets();
      if (insets != null) {
        xy.x -= insets.left;
        xy.y -= insets.top;
      }
    }

    if (considerForcedXY && myForcedLocation != null) {
      xy = myForcedLocation;
    }

    if (myLocateByContent) {
      final Dimension captionSize = myHeaderPanel.getPreferredSize();
      xy.y -= captionSize.height;
    }

    Rectangle targetBounds = new Rectangle(xy, myContent.getPreferredSize());
    Insets insets = myPopupBorder.getBorderInsets(myContent);
    if (insets != null) {
      targetBounds.x += insets.left;
      targetBounds.y += insets.top;
    }

    Rectangle original = new Rectangle(targetBounds);
    if (myLocateWithinScreen) {
      ScreenUtil.moveRectangleToFitTheScreen(targetBounds);
    }

    if (myMouseOutCanceller != null) {
      myMouseOutCanceller.myEverEntered = targetBounds.equals(original);
    }

    myOwner = IdeFrameImpl.findNearestModalComponent(owner);
    if (myOwner == null) {
      myOwner = owner;
    }

    myRequestorComponent = owner;

    boolean forcedDialog = (SystemInfo.isMac && !(myOwner instanceof IdeFrame)) || myMayBeParent;

    PopupComponent.Factory factory = getFactory(myForcedHeavyweight || myResizable, forcedDialog);
    myNativePopup = factory.isNativePopup();
    myPopup = factory.getPopup(myOwner, myContent, targetBounds.x, targetBounds.y);

    if (myResizable) {
      final JRootPane root = myContent.getRootPane();
      final IdeGlassPaneImpl glass = new IdeGlassPaneImpl(root);
      root.setGlassPane(glass);

      final ResizeComponentListener resizeListener = new ResizeComponentListener(this, glass);
      glass.addMousePreprocessor(resizeListener, this);
      glass.addMouseMotionPreprocessor(resizeListener, this);
    }

    if (myCaption != null && myMovable) {
      final MoveComponentListener moveListener =
          new MoveComponentListener(myCaption) {
            public void mousePressed(final MouseEvent e) {
              super.mousePressed(e);
              if (e.isConsumed()) return;

              if (UIUtil.isCloseClick(e)) {
                if (myCaption.isWithinPanel(e)) {
                  cancel();
                }
              }
            }
          };
      ListenerUtil.addMouseListener(myCaption, moveListener);
      ListenerUtil.addMouseMotionListener(myCaption, moveListener);
      final MyContentPanel saved = myContent;
      Disposer.register(
          this,
          new Disposable() {
            public void dispose() {
              ListenerUtil.removeMouseListener(saved, moveListener);
              ListenerUtil.removeMouseMotionListener(saved, moveListener);
            }
          });
    }

    for (JBPopupListener listener : myListeners) {
      listener.beforeShown(new LightweightWindowEvent(this));
    }

    myPopup.setRequestFocus(myRequestFocus);
    myPopup.show();

    final Window window = SwingUtilities.getWindowAncestor(myContent);

    myWindowListener = new MyWindowListener();
    window.addWindowListener(myWindowListener);

    if (myFocusable) {
      window.setFocusableWindowState(true);
      window.setFocusable(true);
    }

    myWindow = updateMaskAndAlpha(window);

    if (myWindow instanceof JWindow) {
      ((JWindow) myWindow).getRootPane().putClientProperty(KEY, this);
    }

    if (myWindow != null) {
      // dialogwrapper-based popups do this internally through peer,
      // for other popups like jdialog-based we should exclude them manually, but
      // we still have to be able to use IdeFrame as parent
      if (!myMayBeParent && !(myWindow instanceof Frame)) {
        WindowManager.getInstance().doNotSuggestAsParent(myWindow);
      }
    }

    final Runnable afterShow =
        new Runnable() {
          public void run() {
            if (myPreferredFocusedComponent != null && myInStack && myFocusable) {
              myFocusTrackback.registerFocusComponent(myPreferredFocusedComponent);
            }

            removeActivity();

            afterShow();
          }
        };

    if (myRequestFocus) {
      getFocusManager()
          .requestFocus(
              new FocusCommand() {
                @Override
                public ActionCallback run() {
                  if (isDisposed()) {
                    removeActivity();
                    return new ActionCallback.Done();
                  }

                  _requestFocus();

                  final ActionCallback result = new ActionCallback();

                  final Runnable afterShowRunnable =
                      new Runnable() {
                        @Override
                        public void run() {
                          afterShow.run();
                          result.setDone();
                        }
                      };
                  if (myNativePopup) {
                    final FocusRequestor furtherRequestor = getFocusManager().getFurtherRequestor();
                    SwingUtilities.invokeLater(
                        new Runnable() {
                          @Override
                          public void run() {
                            if (isDisposed()) {
                              result.setRejected();
                              return;
                            }

                            furtherRequestor
                                .requestFocus(
                                    new FocusCommand() {
                                      @Override
                                      public ActionCallback run() {
                                        if (isDisposed()) {
                                          return new ActionCallback.Rejected();
                                        }

                                        _requestFocus();

                                        afterShowRunnable.run();

                                        return new ActionCallback.Done();
                                      }
                                    },
                                    true)
                                .notify(result)
                                .doWhenProcessed(
                                    new Runnable() {
                                      @Override
                                      public void run() {
                                        removeActivity();
                                      }
                                    });
                          }
                        });
                  } else {
                    afterShowRunnable.run();
                  }

                  return result;
                }
              },
              true)
          .doWhenRejected(
              new Runnable() {
                @Override
                public void run() {
                  afterShow.run();
                }
              });
    } else {
      SwingUtilities.invokeLater(
          new Runnable() {
            @Override
            public void run() {
              if (isDisposed()) {
                removeActivity();
                return;
              }

              afterShow.run();
            }
          });
    }
  }
  protected boolean exportApplicationPrompt() throws IOException, SketchException {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.add(Box.createVerticalStrut(6));

    // Box panel = Box.createVerticalBox();

    // Box labelBox = Box.createHorizontalBox();
    //    String msg = "<html>Click Export to Application to create a standalone, " +
    //      "double-clickable application for the selected plaforms.";

    //    String msg = "Export to Application creates a standalone, \n" +
    //      "double-clickable application for the selected plaforms.";
    String line1 = "Export to Application creates double-clickable,";
    String line2 = "standalone applications for the selected plaforms.";
    JLabel label1 = new JLabel(line1, SwingConstants.CENTER);
    JLabel label2 = new JLabel(line2, SwingConstants.CENTER);
    label1.setAlignmentX(Component.LEFT_ALIGNMENT);
    label2.setAlignmentX(Component.LEFT_ALIGNMENT);
    //    label1.setAlignmentX();
    //    label2.setAlignmentX(0);
    panel.add(label1);
    panel.add(label2);
    int wide = label2.getPreferredSize().width;
    panel.add(Box.createVerticalStrut(12));

    final JCheckBox windowsButton = new JCheckBox("Windows");
    // windowsButton.setMnemonic(KeyEvent.VK_W);
    windowsButton.setSelected(Preferences.getBoolean("export.application.platform.windows"));
    windowsButton.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            Preferences.setBoolean(
                "export.application.platform.windows", windowsButton.isSelected());
          }
        });

    final JCheckBox macosxButton = new JCheckBox("Mac OS X");
    // macosxButton.setMnemonic(KeyEvent.VK_M);
    macosxButton.setSelected(Preferences.getBoolean("export.application.platform.macosx"));
    macosxButton.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            Preferences.setBoolean("export.application.platform.macosx", macosxButton.isSelected());
          }
        });

    final JCheckBox linuxButton = new JCheckBox("Linux");
    // linuxButton.setMnemonic(KeyEvent.VK_L);
    linuxButton.setSelected(Preferences.getBoolean("export.application.platform.linux"));
    linuxButton.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            Preferences.setBoolean("export.application.platform.linux", linuxButton.isSelected());
          }
        });

    JPanel platformPanel = new JPanel();
    // platformPanel.setLayout(new BoxLayout(platformPanel, BoxLayout.X_AXIS));
    platformPanel.add(windowsButton);
    platformPanel.add(Box.createHorizontalStrut(6));
    platformPanel.add(macosxButton);
    platformPanel.add(Box.createHorizontalStrut(6));
    platformPanel.add(linuxButton);
    platformPanel.setBorder(new TitledBorder("Platforms"));
    // Dimension goodIdea = new Dimension(wide, platformPanel.getPreferredSize().height);
    // platformPanel.setMaximumSize(goodIdea);
    wide = Math.max(wide, platformPanel.getPreferredSize().width);
    platformPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    panel.add(platformPanel);

    //  Box indentPanel = Box.createHorizontalBox();
    //  indentPanel.add(Box.createHorizontalStrut(new JCheckBox().getPreferredSize().width));
    final JCheckBox showStopButton = new JCheckBox("Show a Stop button");
    // showStopButton.setMnemonic(KeyEvent.VK_S);
    showStopButton.setSelected(Preferences.getBoolean("export.application.stop"));
    showStopButton.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            Preferences.setBoolean("export.application.stop", showStopButton.isSelected());
          }
        });
    showStopButton.setEnabled(Preferences.getBoolean("export.application.fullscreen"));
    showStopButton.setBorder(new EmptyBorder(3, 13, 6, 13));
    //  indentPanel.add(showStopButton);
    //  indentPanel.setAlignmentX(Component.LEFT_ALIGNMENT);

    final JCheckBox fullScreenButton = new JCheckBox("Full Screen (Present mode)");
    // fullscreenButton.setMnemonic(KeyEvent.VK_F);
    fullScreenButton.setSelected(Preferences.getBoolean("export.application.fullscreen"));
    fullScreenButton.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            boolean sal = fullScreenButton.isSelected();
            Preferences.setBoolean("export.application.fullscreen", sal);
            showStopButton.setEnabled(sal);
          }
        });
    fullScreenButton.setBorder(new EmptyBorder(3, 13, 3, 13));

    JPanel optionPanel = new JPanel();
    optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.Y_AXIS));
    optionPanel.add(fullScreenButton);
    optionPanel.add(showStopButton);
    //    optionPanel.add(indentPanel);
    optionPanel.setBorder(new TitledBorder("Options"));
    wide = Math.max(wide, platformPanel.getPreferredSize().width);
    // goodIdea = new Dimension(wide, optionPanel.getPreferredSize().height);
    optionPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    // optionPanel.setMaximumSize(goodIdea);
    panel.add(optionPanel);

    Dimension good;
    // label1, label2, platformPanel, optionPanel
    good = new Dimension(wide, label1.getPreferredSize().height);
    label1.setMaximumSize(good);
    good = new Dimension(wide, label2.getPreferredSize().height);
    label2.setMaximumSize(good);
    good = new Dimension(wide, platformPanel.getPreferredSize().height);
    platformPanel.setMaximumSize(good);
    good = new Dimension(wide, optionPanel.getPreferredSize().height);
    optionPanel.setMaximumSize(good);

    //    JPanel actionPanel = new JPanel();
    //    optionPanel.setLayout(new BoxLayout(optionPanel, BoxLayout.X_AXIS));
    //    optionPanel.add(Box.createHorizontalGlue());

    //    final JDialog frame = new JDialog(editor, "Export to Application");

    //    JButton cancelButton = new JButton("Cancel");
    //    cancelButton.addActionListener(new ActionListener() {
    //      public void actionPerformed(ActionEvent e) {
    //        frame.dispose();
    //        return false;
    //      }
    //    });

    // Add the buttons in platform-specific order
    //    if (PApplet.platform == PConstants.MACOSX) {
    //      optionPanel.add(cancelButton);
    //      optionPanel.add(exportButton);
    //    } else {
    //      optionPanel.add(exportButton);
    //      optionPanel.add(cancelButton);
    //    }
    String[] options = {"Export", "Cancel"};
    final JOptionPane optionPane =
        new JOptionPane(
            panel,
            JOptionPane.PLAIN_MESSAGE,
            // JOptionPane.QUESTION_MESSAGE,
            JOptionPane.YES_NO_OPTION,
            null,
            options,
            options[0]);

    final JDialog dialog = new JDialog(this, "Export Options", true);
    dialog.setContentPane(optionPane);

    optionPane.addPropertyChangeListener(
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent e) {
            String prop = e.getPropertyName();

            if (dialog.isVisible()
                && (e.getSource() == optionPane)
                && (prop.equals(JOptionPane.VALUE_PROPERTY))) {
              // If you were going to check something
              // before closing the window, you'd do
              // it here.
              dialog.setVisible(false);
            }
          }
        });
    dialog.pack();
    dialog.setResizable(false);

    Rectangle bounds = getBounds();
    dialog.setLocation(
        bounds.x + (bounds.width - dialog.getSize().width) / 2,
        bounds.y + (bounds.height - dialog.getSize().height) / 2);
    dialog.setVisible(true);

    Object value = optionPane.getValue();
    if (value.equals(options[0])) {
      return jmode.handleExportApplication(sketch);
    } else if (value.equals(options[1]) || value.equals(new Integer(-1))) {
      // closed window by hitting Cancel or ESC
      statusNotice("Export to Application canceled.");
    }
    return false;
  }
  public JComponent createCenterPanel() {
    List<FileStructureFilter> fileStructureFilters = new ArrayList<FileStructureFilter>();
    List<FileStructureNodeProvider> fileStructureNodeProviders =
        new ArrayList<FileStructureNodeProvider>();
    if (myTreeActionsOwner != null) {
      for (Filter filter : myBaseTreeModel.getFilters()) {
        if (filter instanceof FileStructureFilter) {
          final FileStructureFilter fsFilter = (FileStructureFilter) filter;
          myTreeActionsOwner.setActionIncluded(fsFilter, true);
          fileStructureFilters.add(fsFilter);
        }
      }

      if (myBaseTreeModel instanceof ProvidingTreeModel) {
        for (NodeProvider provider : ((ProvidingTreeModel) myBaseTreeModel).getNodeProviders()) {
          if (provider instanceof FileStructureNodeProvider) {
            fileStructureNodeProviders.add((FileStructureNodeProvider) provider);
          }
        }
      }
    }
    final JPanel panel = new JPanel(new BorderLayout());
    JPanel comboPanel = new JPanel(new GridLayout(0, 2, 0, 0));

    final Shortcut[] F4 =
        ActionManager.getInstance()
            .getAction(IdeActions.ACTION_EDIT_SOURCE)
            .getShortcutSet()
            .getShortcuts();
    final Shortcut[] ENTER = CustomShortcutSet.fromString("ENTER").getShortcuts();
    final CustomShortcutSet shortcutSet = new CustomShortcutSet(ArrayUtil.mergeArrays(F4, ENTER));
    new AnAction() {
      public void actionPerformed(AnActionEvent e) {
        final boolean succeeded = navigateSelectedElement();
        if (succeeded) {
          unregisterCustomShortcutSet(panel);
        }
      }
    }.registerCustomShortcutSet(shortcutSet, panel);

    new AnAction() {
      public void actionPerformed(AnActionEvent e) {
        if (mySpeedSearch != null && mySpeedSearch.isPopupActive()) {
          mySpeedSearch.hidePopup();
        } else {
          myPopup.cancel();
        }
      }
    }.registerCustomShortcutSet(CustomShortcutSet.fromString("ESCAPE"), myTree);

    new ClickListener() {
      @Override
      public boolean onClick(MouseEvent e, int clickCount) {
        navigateSelectedElement();
        return true;
      }
    }.installOn(myTree);

    for (FileStructureFilter filter : fileStructureFilters) {
      addCheckbox(comboPanel, filter);
    }

    for (FileStructureNodeProvider provider : fileStructureNodeProviders) {
      addCheckbox(comboPanel, provider);
    }
    myPreferredWidth = Math.max(comboPanel.getPreferredSize().width, 350);
    panel.add(comboPanel, BorderLayout.NORTH);
    JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(myAbstractTreeBuilder.getTree());
    scrollPane.setBorder(IdeBorderFactory.createBorder(SideBorder.TOP | SideBorder.BOTTOM));
    panel.add(scrollPane, BorderLayout.CENTER);
    panel.add(createSouthPanel(), BorderLayout.SOUTH);
    DataManager.registerDataProvider(
        panel,
        new DataProvider() {
          @Override
          public Object getData(@NonNls String dataId) {
            if (PlatformDataKeys.PROJECT.is(dataId)) {
              return myProject;
            }
            if (LangDataKeys.PSI_ELEMENT.is(dataId)) {
              final Object node =
                  ContainerUtil.getFirstItem(myAbstractTreeBuilder.getSelectedElements());
              if (!(node instanceof FilteringTreeStructure.FilteringNode)) return null;
              return getPsi((FilteringTreeStructure.FilteringNode) node);
            }
            if (LangDataKeys.POSITION_ADJUSTER_POPUP.is(dataId)) {
              return myPopup;
            }
            if (PlatformDataKeys.TREE_EXPANDER.is(dataId)) {
              return myTreeExpander;
            }
            return null;
          }
        });

    return panel;
  }
Beispiel #28
0
    public CustomDialog(Frame name) {
      super(name, "Customize Text Properties", true);
      this.setResizable(false);
      this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);

      GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
      String[] fontList = ge.getAvailableFontFamilyNames();
      fontCombo = new JComboBox(fontList);

      italic = new JCheckBox("Italic");
      bold = new JCheckBox("Bold");

      sizeCombo = new JComboBox(stringSize);
      ((JLabel) sizeCombo.getRenderer()).setHorizontalAlignment(SwingConstants.CENTER);
      sizeCombo.setSelectedIndex(4);
      sizeCombo.setPreferredSize(new Dimension(45, 21)); // tweek size

      example = new JTextField(" Preview ");
      example.setHorizontalAlignment(SwingConstants.CENTER);
      example.setFont(new Font("sanserif", Font.PLAIN, 28));
      example.setEditable(false);

      ok = new JButton("Apply");
      cancel = new JButton("Cancel");
      ok.setPreferredSize(cancel.getPreferredSize());

      foreground = new JButton("Edit Color");

      foreground.setPreferredSize(new Dimension(100, 50));

      // add the listeners
      fontCombo.addActionListener(this);
      italic.addItemListener(this);
      bold.addItemListener(this);
      sizeCombo.addActionListener(this);
      ok.addActionListener(this);
      cancel.addActionListener(this);
      foreground.addActionListener(this);

      JPanel p0 = new JPanel();
      p0.add(fontCombo);
      p0.setBorder(new TitledBorder(new EtchedBorder(), "Font family"));

      JPanel p1a = new JPanel();
      p1a.add(italic);
      p1a.add(bold);
      p1a.setBorder(new TitledBorder(new EtchedBorder(), "Font style"));

      JPanel p1b = new JPanel();
      p1b.add(sizeCombo);
      p1b.add(new JLabel("pt."));
      p1b.setBorder(new TitledBorder(new EtchedBorder(), "Font size"));

      JPanel p1 = new JPanel();
      p1.setLayout(new BoxLayout(p1, BoxLayout.X_AXIS));
      p1.add(p1a);
      p1.add(p1b);
      p1.setAlignmentX(Component.CENTER_ALIGNMENT);

      JPanel p2 = new JPanel(); // use FlowLayout
      p2.add(foreground);

      p2.setBorder(new TitledBorder(new EtchedBorder(), "Message color"));
      p2.setAlignmentX(Component.CENTER_ALIGNMENT);

      JPanel p3 = new JPanel();
      p3.setLayout(new BoxLayout(p3, BoxLayout.Y_AXIS));
      p3.add(example);
      p3.setPreferredSize(new Dimension(250, 60));
      p3.setMaximumSize(new Dimension(250, 60));
      p3.setAlignmentX(Component.CENTER_ALIGNMENT);

      JPanel p4 = new JPanel();
      p4.add(ok);
      p4.add(cancel);
      p4.setAlignmentX(Component.CENTER_ALIGNMENT);

      JPanel p = new JPanel();
      p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
      p.add(p0);
      p.add(Box.createRigidArea(new Dimension(0, 10)));
      p.add(p1);
      p.add(Box.createRigidArea(new Dimension(0, 10)));
      p.add(p2);
      p.add(Box.createRigidArea(new Dimension(0, 10)));
      p.add(p3);
      p.add(Box.createRigidArea(new Dimension(0, 10)));
      p.add(p4);
      p.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

      Dimension d1 = p3.getPreferredSize();
      Dimension d2 = p1.getPreferredSize();
      p1.setPreferredSize(new Dimension(d1.width, d2.height));
      p1.setMaximumSize(new Dimension(d1.width, d2.height));
      d2 = p2.getPreferredSize();
      p2.setPreferredSize(new Dimension(d1.width, d2.height));
      p2.setMaximumSize(new Dimension(d1.width, d2.height));

      this.setContentPane(p);
      this.pack();
    }