| | |
| | | import java.awt.GridBagLayout; |
| | | import java.awt.Point; |
| | | import java.awt.Rectangle; |
| | | import java.awt.Toolkit; |
| | | import java.awt.event.ActionEvent; |
| | | import java.awt.event.ActionListener; |
| | | import java.awt.event.MouseAdapter; |
| | |
| | | |
| | | private HashSet<JLabel> subsectionLabels = new HashSet<JLabel>(); |
| | | |
| | | private DatabasesTableModel dbTableModel; |
| | | private JTable dbTable; |
| | | private DatabasesTableModel dbTableModelWithReplication; |
| | | private DatabasesTableModel dbTableModelWithoutReplication; |
| | | private JTable dbTableWithReplication; |
| | | private JTable dbTableWithoutReplication; |
| | | |
| | | private ListenersTableModel listenersTableModel; |
| | | private JTable listenersTable; |
| | |
| | | |
| | | private final String NOT_AVAILABLE = getMsg("not-available-label"); |
| | | |
| | | private final int MAXIMAL_WIDTH = 1000; |
| | | private final int MAXIMAL_HEIGHT = 1000; |
| | | |
| | | /** |
| | | * ProgressDialog constructor. |
| | | */ |
| | |
| | | int packedMinWidth = (int) getPreferredSize().getWidth(); |
| | | int packedMinHeight = (int) getPreferredSize().getHeight(); |
| | | |
| | | int minWidth = Math.min(packedMinWidth, MAXIMAL_WIDTH); |
| | | int minHeight = Math.min(packedMinHeight, MAXIMAL_HEIGHT); |
| | | int minWidth = Math.min(packedMinWidth, getMaximalWidth()); |
| | | int minHeight = Math.min(packedMinHeight, getMaximalHeight()); |
| | | |
| | | addComponentListener(new MinimumSizeComponentListener(this, |
| | | minWidth, minHeight)); |
| | |
| | | if (mustRepack) |
| | | { |
| | | pack(); |
| | | int packedMinWidth = (int) getPreferredSize().getWidth(); |
| | | int packedMinHeight = (int) getPreferredSize().getHeight(); |
| | | |
| | | int minWidth = Math.min(packedMinWidth, getMaximalWidth()); |
| | | int minHeight = Math.min(packedMinHeight, getMaximalHeight()); |
| | | |
| | | if ((minWidth != packedMinWidth) || (minHeight != packedMinHeight)) |
| | | { |
| | | setPreferredSize(new Dimension(minWidth, minHeight)); |
| | | pack(); |
| | | } |
| | | |
| | | lastPackDescriptor = lastDescriptor; |
| | | } |
| | | } |
| | |
| | | |
| | | p.add(createSubsectionTitle(getMsg("databases-title")), gbc); |
| | | |
| | | dbTableModel = new DatabasesTableModel(); |
| | | dbTable = UIFactory.makeSortableTable(dbTableModel, |
| | | dbTableModelWithReplication = new DatabasesTableModel(true); |
| | | dbTableModelWithoutReplication = new DatabasesTableModel(false); |
| | | dbTableWithReplication = |
| | | UIFactory.makeSortableTable(dbTableModelWithReplication, |
| | | new DatabasesCellRenderer(), |
| | | UIFactory.makeHeaderRenderer()); |
| | | toolTipManager.registerComponent(dbTable); |
| | | toolTipManager.registerComponent(dbTableWithReplication); |
| | | dbTableWithoutReplication = |
| | | UIFactory.makeSortableTable(dbTableModelWithoutReplication, |
| | | new DatabasesCellRenderer(), |
| | | UIFactory.makeHeaderRenderer()); |
| | | toolTipManager.registerComponent(dbTableWithoutReplication); |
| | | |
| | | gbc.insets.top = UIFactory.TOP_INSET_PRIMARY_FIELD; |
| | | p.add(dbTable.getTableHeader(), gbc); |
| | | int height = (int)dbTable.getTableHeader().getPreferredSize().getHeight(); |
| | | dbTable.setRowHeight(height); |
| | | p.add(dbTableWithReplication.getTableHeader(), gbc); |
| | | int height = (int)dbTableWithReplication.getTableHeader(). |
| | | getPreferredSize().getHeight(); |
| | | dbTableWithReplication.setRowHeight(height); |
| | | gbc.insets.top = 0; |
| | | p.add(dbTable, gbc); |
| | | p.add(dbTableWithReplication, gbc); |
| | | |
| | | gbc.insets.top = UIFactory.TOP_INSET_PRIMARY_FIELD; |
| | | p.add(dbTableWithoutReplication.getTableHeader(), gbc); |
| | | height = (int)dbTableWithoutReplication.getTableHeader(). |
| | | getPreferredSize().getHeight(); |
| | | dbTableWithoutReplication.setRowHeight(height); |
| | | gbc.insets.top = 0; |
| | | p.add(dbTableWithoutReplication, gbc); |
| | | dbTableWithoutReplication.setVisible(false); |
| | | |
| | | gbc.insets.top = UIFactory.TOP_INSET_PRIMARY_FIELD; |
| | | lDbTableEmpty = UIFactory.makeJLabel(UIFactory.IconType.NO_ICON, "", |
| | |
| | | { |
| | | replicas.addAll(db.getBaseDns()); |
| | | } |
| | | dbTableModel.setData(replicas); |
| | | dbTableModelWithReplication.setData(replicas); |
| | | dbTableModelWithoutReplication.setData(replicas); |
| | | |
| | | if (dbTableModel.getRowCount() == 0) |
| | | if (dbTableModelWithReplication.getRowCount() == 0) |
| | | { |
| | | dbTable.setVisible(false); |
| | | dbTable.getTableHeader().setVisible(false); |
| | | |
| | | dbTableWithoutReplication.setVisible(false); |
| | | dbTableWithoutReplication.getTableHeader().setVisible(false); |
| | | dbTableWithReplication.setVisible(false); |
| | | dbTableWithReplication.getTableHeader().setVisible(false); |
| | | lDbTableEmpty.setVisible(true); |
| | | if (desc.getStatus() == ServerStatusDescriptor.ServerStatus.STARTED) |
| | | { |
| | |
| | | } |
| | | else |
| | | { |
| | | dbTable.setVisible(true); |
| | | dbTable.getTableHeader().setVisible(true); |
| | | boolean replicated = false; |
| | | for (BaseDNDescriptor suffix: replicas) |
| | | { |
| | | if (suffix.getType() == BaseDNDescriptor.Type.REPLICATED) |
| | | { |
| | | replicated = true; |
| | | } |
| | | } |
| | | |
| | | updateTableSizes(dbTableWithoutReplication); |
| | | updateTableSizes(dbTableWithReplication); |
| | | dbTableWithoutReplication.setVisible(!replicated); |
| | | dbTableWithoutReplication.getTableHeader().setVisible(!replicated); |
| | | dbTableWithReplication.setVisible(replicated); |
| | | dbTableWithReplication.getTableHeader().setVisible(replicated); |
| | | lDbTableEmpty.setVisible(false); |
| | | updateTableSizes(dbTable); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | private int getMaximalWidth() |
| | | { |
| | | Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
| | | |
| | | boolean multipleScreen = screenSize.width / screenSize.height >= 2; |
| | | |
| | | if (multipleScreen) |
| | | { |
| | | return Math.min((screenSize.width/2) - 100, 1000); |
| | | } |
| | | else |
| | | { |
| | | return Math.min(screenSize.width - 100, 1000); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Returns the maximum height we allow this dialog to have after pack. |
| | | * @return the maximum height we allow this dialog to have after pack. |
| | | */ |
| | | private int getMaximalHeight() |
| | | { |
| | | Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); |
| | | |
| | | return Math.min(screenSize.height - 100, 800); |
| | | } |
| | | /** |
| | | * Method written for testing purposes. |
| | | * @param args the arguments to be passed to the test program. |