Ejemplo n.º 1
0
    /**
     * Returns the maximum amount of space the layout can use.
     *
     * @param the Container for which this layout manager is being used
     * @return a Dimension object containing the layout's maximum size
     */
    public Dimension maximumLayoutSize(Container target) {
      Dimension cpd;
      int cpWidth = Integer.MAX_VALUE;
      int cpHeight = Integer.MAX_VALUE;
      int mbWidth = Integer.MAX_VALUE;
      int mbHeight = Integer.MAX_VALUE;
      int tpWidth = Integer.MAX_VALUE;
      int tpHeight = Integer.MAX_VALUE;
      Insets i = target.getInsets();
      JRootPane root = (JRootPane) target;

      if (root.getContentPane() != null) {
        cpd = root.getContentPane().getMaximumSize();
        if (cpd != null) {
          cpWidth = cpd.width;
          cpHeight = cpd.height;
        }
      }

      int maxHeight = Math.max(Math.max(cpHeight, mbHeight), tpHeight);
      // Only overflows if 3 real non-MAX_VALUE heights, sum to > MAX_VALUE
      // Only will happen if sums to more than 2 billion units.  Not likely.
      if (maxHeight != Integer.MAX_VALUE) {
        maxHeight = cpHeight + mbHeight + tpHeight + i.top + i.bottom;
      }

      int maxWidth = Math.max(Math.max(cpWidth, mbWidth), tpWidth);
      // Similar overflow comment as above
      if (maxWidth != Integer.MAX_VALUE) {
        maxWidth += i.left + i.right;
      }

      return new Dimension(maxWidth, maxHeight);
    }
Ejemplo n.º 2
0
    /**
     * Instructs the layout manager to perform the layout for the specified container.
     *
     * @param the Container for which this layout manager is being used
     */
    public void layoutContainer(Container parent) {
      JRootPane root = (JRootPane) parent;
      Rectangle b = root.getBounds();
      Insets i = root.getInsets();
      int nextY = 0;
      int w = b.width - i.right - i.left;
      int h = b.height - i.top - i.bottom;

      if (root.getLayeredPane() != null) {
        root.getLayeredPane().setBounds(i.left, i.top, w, h);
      }
      if (root.getGlassPane() != null) {
        root.getGlassPane().setBounds(i.left, i.top, w, h);
      }
      // Note: This is laying out the children in the layeredPane,
      // technically, these are not our children.
      if (root.getWindowDecorationStyle() != JRootPane.NONE
          && (root.getUI() instanceof RootPaneUI)) {
        JComponent titlePane = ((RootPaneUI) root.getUI()).getTitlePane();
        if (titlePane != null) {
          Dimension tpd = titlePane.getPreferredSize();
          if (tpd != null) {
            int tpHeight = tpd.height;
            titlePane.setBounds(0, 0, w, tpHeight);
            nextY += tpHeight;
          }
        }
      }

      if (root.getContentPane() != null) {

        root.getContentPane().setBounds(0, nextY, w, h < nextY ? 0 : h - nextY);
      }
    }
Ejemplo n.º 3
0
    /**
     * Returns the minimum amount of space the layout needs.
     *
     * @param the Container for which this layout manager is being used
     * @return a Dimension object containing the layout's minimum size
     */
    public Dimension minimumLayoutSize(Container parent) {
      Dimension cpd;
      int cpWidth = 0;
      int cpHeight = 0;
      int mbWidth = 0;
      int mbHeight = 0;
      int tpWidth = 0;

      Insets i = parent.getInsets();
      JRootPane root = (JRootPane) parent;

      if (root.getContentPane() != null) {
        cpd = root.getContentPane().getMinimumSize();
      } else {
        cpd = root.getSize();
      }
      if (cpd != null) {
        cpWidth = cpd.width;
        cpHeight = cpd.height;
      }

      return new Dimension(
          Math.max(Math.max(cpWidth, mbWidth), tpWidth) + i.left + i.right,
          cpHeight + mbHeight + tpWidth + i.top + i.bottom);
    }
Ejemplo n.º 4
0
    /**
     * Returns the amount of space the layout would like to have.
     *
     * @param the Container for which this layout manager is being used
     * @return a Dimension object containing the layout's preferred size
     */
    public Dimension preferredLayoutSize(Container parent) {
      Dimension cpd, tpd;
      int cpWidth = 0;
      int cpHeight = 0;
      int mbWidth = 0;
      int mbHeight = 0;
      int tpWidth = 0;
      Insets i = parent.getInsets();
      JRootPane root = (JRootPane) parent;

      if (root.getContentPane() != null) {
        cpd = root.getContentPane().getPreferredSize();
      } else {
        cpd = root.getSize();
      }
      if (cpd != null) {
        cpWidth = cpd.width;
        cpHeight = cpd.height;
      }

      if (root.getWindowDecorationStyle() != JRootPane.NONE
          && (root.getUI() instanceof RootPaneUI)) {
        JComponent titlePane = ((RootPaneUI) root.getUI()).getTitlePane();
        if (titlePane != null) {
          tpd = titlePane.getPreferredSize();
          if (tpd != null) {
            tpWidth = tpd.width;
          }
        }
      }

      return new Dimension(
          Math.max(Math.max(cpWidth, mbWidth), tpWidth) + i.left + i.right,
          cpHeight + mbHeight + tpWidth + i.top + i.bottom);
    }
Ejemplo n.º 5
0
    /**
     * Returns the maximum amount of space the layout can use.
     *
     * @param the Container for which this layout manager is being used
     * @return a Dimension object containing the layout's maximum size
     */
    public Dimension maximumLayoutSize(Container target) {
      Dimension cpd, mbd, tpd;
      int cpWidth = Integer.MAX_VALUE;
      int cpHeight = Integer.MAX_VALUE;
      int mbWidth = Integer.MAX_VALUE;
      int mbHeight = Integer.MAX_VALUE;
      int tpWidth = Integer.MAX_VALUE;
      int tpHeight = Integer.MAX_VALUE;
      Insets i = target.getInsets();
      JRootPane root = (JRootPane) target;

      if (root.getContentPane() != null) {
        cpd = root.getContentPane().getMaximumSize();
        if (cpd != null) {
          cpWidth = cpd.width;
          cpHeight = cpd.height;
        }
      }

      if (root.getMenuBar() != null) {
        mbd = root.getMenuBar().getMaximumSize();
        if (mbd != null) {
          mbWidth = mbd.width;
          mbHeight = mbd.height;
        }
      }

      if (root.getWindowDecorationStyle() != JRootPane.NONE
          && (root.getUI() instanceof HokageRootPaneUI)) {
        JComponent titlePane = ((HokageRootPaneUI) root.getUI()).getTitlePane();
        if (titlePane != null) {
          tpd = titlePane.getMaximumSize();
          if (tpd != null) {
            tpWidth = tpd.width;
            tpHeight = tpd.height;
          }
        }
      }

      int maxHeight = Math.max(Math.max(cpHeight, mbHeight), tpHeight);
      // Only overflows if 3 real non-MAX_VALUE heights, sum to > MAX_VALUE
      // Only will happen if sums to more than 2 billion units.  Not likely.
      if (maxHeight != Integer.MAX_VALUE) {
        maxHeight = cpHeight + mbHeight + tpHeight + i.top + i.bottom;
      }

      int maxWidth = Math.max(Math.max(cpWidth, mbWidth), tpWidth);
      // Similar overflow comment as above
      if (maxWidth != Integer.MAX_VALUE) {
        maxWidth += i.left + i.right;
      }

      return new Dimension(maxWidth, maxHeight);
    }
Ejemplo n.º 6
0
    /** Resets the <code>Popup</code> to an initial state. */
    void reset(Component owner, Component contents, int ownerX, int ownerY) {
      super.reset(owner, contents, ownerX, ownerY);

      Component component = getComponent();

      component.setLocation(ownerX, ownerY);
      rootPane.getContentPane().add(contents, BorderLayout.CENTER);
      contents.invalidate();
      component.validate();
      pack();
    }
Ejemplo n.º 7
0
 public void hide() {
   super.hide();
   rootPane.getContentPane().removeAll();
   recycleMediumWeightPopup(this);
 }
  /**
   * Create contents of the wizard.
   *
   * @param parent
   */
  public void createControl(Composite parent) {
    Composite container = new Composite(parent, SWT.NULL);

    setControl(container);
    container.setLayout(new GridLayout(3, false));

    Label label = new Label(container, SWT.NONE);
    label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    label.setText("代码保存路径");

    txtSavePath = new Text(container, SWT.BORDER);
    txtSavePath.setEditable(false);
    txtSavePath.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    // 选择源码保存路径
    Button button = new Button(container, SWT.NONE);
    button.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseDown(MouseEvent e) {
            // 选择路径
            ContainerSelectionDialog dialog =
                new ContainerSelectionDialog(
                    getShell(), ResourcesPlugin.getWorkspace().getRoot(), false, "请选择生成的源文件的存放目录");
            if (dialog.open() == ContainerSelectionDialog.OK) {
              Object[] result = dialog.getResult();
              if (result.length == 1) {
                txtSavePath.setText(((Path) result[0]).makeAbsolute().toString());
                validInput();
              }
            }
          }
        });
    button.setText("浏览...");

    Label label_1 = new Label(container, SWT.NONE);
    label_1.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    label_1.setText("模板文件路径");

    txtTempPath = new Text(container, SWT.BORDER);
    txtTempPath.setEditable(false);
    txtTempPath.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));

    // 选择模板文件
    Button button_1 = new Button(container, SWT.NONE);
    button_1.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseDown(MouseEvent e) {
            // 选择模板文件
            FileDialog fileDialog = new FileDialog(getShell());
            fileDialog.setFilterExtensions(new String[] {"*.xml", "*.*"});
            String filenameString = fileDialog.open();
            if (filenameString != null && filenameString.length() > 0) {
              txtTempPath.setText(filenameString);
            }
            // 加载模板配置文件内容
            loadTemplate(filenameString);
            validInput();
          }
        });
    button_1.setText("浏览...");

    Label label_2 = new Label(container, SWT.NONE);
    label_2.setText("模板明细列表");

    Composite composite = new Composite(container, SWT.EMBEDDED);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    Frame frame = SWT_AWT.new_Frame(composite);

    Panel panel = new Panel();
    frame.add(panel);
    panel.setLayout(new BorderLayout(0, 0));

    JRootPane rootPane = new JRootPane();
    panel.add(rootPane);

    JScrollPane scrollPane = new JScrollPane();
    rootPane.getContentPane().add(scrollPane, BorderLayout.CENTER);

    table = new JTable();
    table.setFillsViewportHeight(true);
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    table.setModel(tableModel);
    table.setRowHeight(25);
    scrollPane.setViewportView(table);
    new Label(container, SWT.NONE);

    // 是否生成 列表头设置
    final int isattributeIndex = 0; // 是否生成
    final JTableCheckBoxHeader isgenallcheck = new JTableCheckBoxHeader("是否生成");
    table.getColumnModel().getColumn(isattributeIndex).setHeaderRenderer(isgenallcheck);
    table.getColumnModel().getColumn(isattributeIndex).setPreferredWidth(50);
    table
        .getTableHeader()
        .addMouseListener(
            new java.awt.event.MouseAdapter() {
              public void mouseClicked(java.awt.event.MouseEvent e) {
                if (table.getColumnModel().getColumnIndexAtX(e.getX())
                    == isattributeIndex) { // 如果点击的是第0列,即checkbox这一列
                  @SuppressWarnings("unused")
                  JCheckBox Checkbox = (JCheckBox) isgenallcheck;
                  boolean b = !isgenallcheck.isSelected();
                  isgenallcheck.setSelected(b);
                  table.getTableHeader().repaint();
                  for (int i = 0; i < table.getRowCount(); i++) {
                    table.getModel().setValueAt(b, i, isattributeIndex); // 把这一列都设成和表头一样
                  }
                }
              }
            });

    // 加原来的配置
    ConfigUtil configUtil = new ConfigUtil();
    this.setTxtSavePath(configUtil.getSavePath());
    this.setTxtTempPath(configUtil.getTempPath());
    // 加载模板配置文件内容
    loadTemplate(this.getTxtTempPath());
    setPageComplete(false);
    validInput();
  }