@Test(enabled=false) public void testLoadSettings() { final TableSettingsController controller = new MockController(); controller.setShowGrid(false); controller.setTableOrientation(TableOrientation.ROW_MAJOR); controller.setRowHeaderAlignment(RIGHT); controller.setColumnHeaderAlignment(CENTER); controller.setCellAlignment(DECIMAL); DefaultComboBoxModel cellFontModel = new DefaultComboBoxModel(); cellFontModel.addElement(JVMFontFamily.Serif); cellFontModel.addElement(JVMFontFamily.Monospaced); cellFontModel.setSelectedItem(JVMFontFamily.Serif); DefaultComboBoxModel rowHeaderFontModel = new DefaultComboBoxModel(); rowHeaderFontModel.addElement(JVMFontFamily.Serif); rowHeaderFontModel.addElement(JVMFontFamily.Monospaced); rowHeaderFontModel.setSelectedItem(JVMFontFamily.Serif); DefaultComboBoxModel columnHeaderFontModel = new DefaultComboBoxModel(); columnHeaderFontModel.addElement(JVMFontFamily.Serif); columnHeaderFontModel.addElement(JVMFontFamily.Monospaced); columnHeaderFontModel.setSelectedItem(JVMFontFamily.Serif); controller.setCellFont(cellFontModel); controller.setCellFontSize(12); controller.setCellFontStyle(Font.PLAIN); controller.setCellFontTextAttribute(TableFormattingConstants.UNDERLINE_OFF); controller.setCellFontColor(TableFormattingConstants.defaultFontColor); controller.setCellBackgroundColor(TableFormattingConstants.defaultBackgroundColor); controller.setRowHeaderFontName(rowHeaderFontModel); controller.setRowHeaderFontSize(12); controller.setRowHeaderFontStyle(Font.PLAIN); controller.setRowHeaderTextAttribute(TableFormattingConstants.UNDERLINE_OFF); controller.setColumnHeaderFontName(rowHeaderFontModel); controller.setColumnHeaderFontSize(12); controller.setColumnHeaderFontStyle(Font.PLAIN); controller.setColumnHeaderTextAttribute(TableFormattingConstants.UNDERLINE_OFF); controller.setRowHeaderBorderState(new BorderState(BorderEdge.NONE.value())); controller.setColumnHeaderBorderState(new BorderState(BorderEdge.NONE.value())); controller.setRowHeaderBorderColor(TableFormattingConstants.defaultFontColor); controller.setColumnHeaderBorderColor(TableFormattingConstants.defaultFontColor); DefaultComboBoxModel dateModel = new DefaultComboBoxModel(); dateModel.addElement("None"); dateModel.addElement("HHSS"); dateModel.setSelectedItem(0); controller.setDateFormat(dateModel); final TableSettingsControlPanel panel = GuiActionRunner.execute(new GuiQuery<TableSettingsControlPanel>() { @Override public TableSettingsControlPanel executeInEDT() { return new TableSettingsControlPanel(controller); } }); window = showInFrame(panel, PANEL_NAME); ROW_MAJOR.radioButtonIn(window).requireSelected(); COLUMN_MAJOR.radioButtonIn(window).requireNotSelected(); DECIMAL_PLACES.comboBoxIn(window).requireSelection("2"); CELL_FONT_NAME.comboBoxIn(window).requireSelection("Serif"); CELL_FONT_SIZE_NAME.spinnerIn(window).requireValue(12); CELL_FONT_BOLD_NAME.toggleButtonIn(window).requireNotSelected(); CELL_FONT_ITALIC_NAME.toggleButtonIn(window).requireNotSelected(); CELL_FONT_UNDERLINE_NAME.toggleButtonIn(window).requireNotSelected(); window.comboBox(new ComboBoxMatcher("Cell Font Color")).requireSelection(0); window.comboBox(new ComboBoxMatcher("Cell Background Color")).requireSelection(0); ROW_FONT_NAME.comboBoxIn(window).requireSelection("Serif"); ROW_FONT_SIZE_NAME.spinnerIn(window).requireValue(12); ROW_FONT_BOLD_NAME.toggleButtonIn(window).requireNotSelected(); ROW_FONT_ITALIC_NAME.toggleButtonIn(window).requireNotSelected(); ROW_FONT_UNDERLINE_NAME.toggleButtonIn(window).requireNotSelected(); ROW_BORDER_LEFT_NAME.toggleButtonIn(window).requireNotSelected(); ROW_BORDER_RIGHT_NAME.toggleButtonIn(window).requireNotSelected(); ROW_BORDER_TOP_NAME.toggleButtonIn(window).requireNotSelected(); ROW_BORDER_BOTTOM_NAME.toggleButtonIn(window).requireNotSelected(); COL_FONT_NAME.comboBoxIn(window).requireSelection("Serif"); COL_FONT_SIZE_NAME.spinnerIn(window).requireValue(12); COL_FONT_BOLD_NAME.toggleButtonIn(window).requireNotSelected(); COL_FONT_ITALIC_NAME.toggleButtonIn(window).requireNotSelected(); COL_FONT_UNDERLINE_NAME.toggleButtonIn(window).requireNotSelected(); COL_BORDER_LEFT_NAME.toggleButtonIn(window).requireNotSelected(); COL_BORDER_RIGHT_NAME.toggleButtonIn(window).requireNotSelected(); COL_BORDER_TOP_NAME.toggleButtonIn(window).requireNotSelected(); COL_BORDER_BOTTOM_NAME.toggleButtonIn(window).requireNotSelected(); window.comboBox(new ComboBoxMatcher("Cell Font Color")).requireSelection(0); window.comboBox(new ComboBoxMatcher("Cell Background Color")).requireSelection(0); window.comboBox(new ComboBoxMatcher("Row Header Font Color Control")).requireSelection(0); window.comboBox(new ComboBoxMatcher("Row Header Background Color Control")).requireSelection(0); window.comboBox(new ComboBoxMatcher("Col Header Font Color Control")).requireSelection(0); window.comboBox(new ComboBoxMatcher("Col Header Background Color Control")).requireSelection(0); window.comboBox(new ComboBoxMatcher("Row Header Border Color")).requireSelection(0); window.comboBox(new ComboBoxMatcher("Column Header Border Color")).requireSelection(0); FORMAT_AS_DATE_NAME.comboBoxIn(window).requireSelection(0); controller.setTableOrientation(TableOrientation.COLUMN_MAJOR); getQuery("ROW_HEADER_ALIGN_RIGHT_NAME").radioButtonIn(window).requireSelected(); getQuery("COLUMN_HEADER_ALIGN_CENTER_NAME").radioButtonIn(window).requireSelected(); getQuery("CELL_ALIGN_DECIMAL_NAME").radioButtonIn(window).requireSelected(); CELL_FONT_NAME.comboBoxIn(window).requireSelection("Serif"); CELL_FONT_SIZE_NAME.spinnerIn(window).requireValue(12); CELL_FONT_BOLD_NAME.toggleButtonIn(window).requireNotSelected(); CELL_FONT_ITALIC_NAME.toggleButtonIn(window).requireNotSelected(); CELL_FONT_UNDERLINE_NAME.toggleButtonIn(window).requireNotSelected(); window.comboBox(new ComboBoxMatcher("Cell Font Color")).requireSelection(0); window.comboBox(new ComboBoxMatcher("Cell Background Color")).requireSelection(0); ROW_FONT_NAME.comboBoxIn(window).requireSelection("Serif"); ROW_FONT_SIZE_NAME.spinnerIn(window).requireValue(12); ROW_FONT_BOLD_NAME.toggleButtonIn(window).requireNotSelected(); ROW_FONT_ITALIC_NAME.toggleButtonIn(window).requireNotSelected(); ROW_FONT_UNDERLINE_NAME.toggleButtonIn(window).requireNotSelected(); COL_FONT_NAME.comboBoxIn(window).requireSelection("Serif"); COL_FONT_SIZE_NAME.spinnerIn(window).requireValue(12); COL_FONT_BOLD_NAME.toggleButtonIn(window).requireNotSelected(); COL_FONT_ITALIC_NAME.toggleButtonIn(window).requireNotSelected(); COL_FONT_UNDERLINE_NAME.toggleButtonIn(window).requireNotSelected(); window.comboBox(new ComboBoxMatcher("Cell Font Color")).requireSelection(0); window.comboBox(new ComboBoxMatcher("Cell Background Color")).requireSelection(0); window.comboBox(new ComboBoxMatcher("Row Header Font Color Control")).requireSelection(0); window.comboBox(new ComboBoxMatcher("Row Header Background Color Control")).requireSelection(0); window.comboBox(new ComboBoxMatcher("Col Header Font Color Control")).requireSelection(0); window.comboBox(new ComboBoxMatcher("Col Header Background Color Control")).requireSelection(0); DefaultComboBoxModel model = new DefaultComboBoxModel(); for (int i=0; i <= 10; i++) { model.addElement(Integer.toString(i)); } model.setSelectedItem(4); controller.setDecimalPlaces(model); GuiActionRunner.execute(new GuiTask() { @Override public void executeInEDT() { panel.loadSettings(); } }); getRobot().waitForIdle(); ROW_MAJOR.radioButtonIn(window).requireNotSelected(); COLUMN_MAJOR.radioButtonIn(window).requireSelected(); DECIMAL_PLACES.comboBoxIn(window).requireSelection(4); CELL_FONT_NAME.comboBoxIn(window).requireSelection("Serif"); CELL_FONT_SIZE_NAME.spinnerIn(window).requireValue(12); CELL_FONT_BOLD_NAME.toggleButtonIn(window).requireNotSelected(); CELL_FONT_ITALIC_NAME.toggleButtonIn(window).requireNotSelected(); CELL_FONT_UNDERLINE_NAME.toggleButtonIn(window).requireNotSelected(); ENUMERATION.comboBoxIn(window).selectItem(0); DECIMAL_PLACES.comboBoxIn(window).selectItem(3); DECIMAL_PLACES.comboBoxIn(window).requireSelection(3); assertEquals(controller.getDecimalPlaces().intValue(), 3); CELL_FONT_NAME.comboBoxIn(window).selectItem("Dialog"); CELL_FONT_NAME.comboBoxIn(window).requireSelection("Dialog"); assertEquals(controller.getCellFontName().name(), "Dialog"); CELL_FONT_SIZE_NAME.spinnerIn(window).select(20); CELL_FONT_SIZE_NAME.spinnerIn(window).requireValue(20); assertEquals(controller.getCellFontSize().intValue(),20); CELL_FONT_BOLD_NAME.toggleButtonIn(window).click(); CELL_FONT_BOLD_NAME.toggleButtonIn(window).requireSelected(); assertEquals(controller.getCellFontStyle().intValue(),Font.BOLD); CELL_FONT_BOLD_NAME.toggleButtonIn(window).click(); CELL_FONT_BOLD_NAME.toggleButtonIn(window).requireNotSelected(); assertEquals(controller.getCellFontStyle().intValue(),Font.PLAIN); CELL_FONT_ITALIC_NAME.toggleButtonIn(window).click(); CELL_FONT_ITALIC_NAME.toggleButtonIn(window).requireSelected(); assertEquals(controller.getCellFontStyle().intValue(),Font.ITALIC); CELL_FONT_ITALIC_NAME.toggleButtonIn(window).click(); CELL_FONT_ITALIC_NAME.toggleButtonIn(window).requireNotSelected(); assertEquals(controller.getCellFontStyle().intValue(),Font.PLAIN); CELL_FONT_ITALIC_NAME.toggleButtonIn(window).click(); CELL_FONT_BOLD_NAME.toggleButtonIn(window).click(); assertEquals(controller.getCellFontStyle().intValue(),Font.BOLD+Font.ITALIC); window.comboBox(new ComboBoxMatcher("Cell Font Color")).selectItem(1); assertEquals(controller.getCellFontColor(),new Color(0,0,255)); window.comboBox(new ComboBoxMatcher("Cell Background Color")).selectItem(1); assertEquals(controller.getCellBackgroundColor(),new Color(0,0,255)); window.comboBox(new ComboBoxMatcher("Row Header Font Color Control")).selectItem(1); assertEquals(controller.getRowHeaderFontColor(),new Color(0,0,255)); window.comboBox(new ComboBoxMatcher("Row Header Background Color Control")).selectItem(1); assertEquals(controller.getRowHeaderBackgroundColor(),new Color(0,0,255)); window.comboBox(new ComboBoxMatcher("Col Header Font Color Control")).selectItem(1); assertEquals(controller.getColumnHeaderFontColor(),new Color(0,0,255)); window.comboBox(new ComboBoxMatcher("Col Header Background Color Control")).selectItem(1); assertEquals(controller.getColumnHeaderBackgroundColor(),new Color(0,0,255)); window.comboBox(new ComboBoxMatcher("Row Header Border Color")).selectItem(1); assertEquals(controller.getRowHeaderBorderColor(),new Color(0,0,255)); window.comboBox(new ComboBoxMatcher("Column Header Border Color")).selectItem(1); assertEquals(controller.getColumnHeaderBorderColor(),new Color(0,0,255)); ROW_FONT_NAME.comboBoxIn(window).selectItem("Dialog"); ROW_FONT_NAME.comboBoxIn(window).requireSelection("Dialog"); assertEquals(controller.getRowHeaderFontName().name(), "Dialog"); ROW_FONT_SIZE_NAME.spinnerIn(window).select(20); ROW_FONT_SIZE_NAME.spinnerIn(window).requireValue(20); assertEquals(controller.getRowHeaderFontSize().intValue(),20); ROW_FONT_BOLD_NAME.toggleButtonIn(window).click(); ROW_FONT_BOLD_NAME.toggleButtonIn(window).requireSelected(); assertEquals(controller.getRowFontStyle().intValue(),Font.BOLD); ROW_FONT_BOLD_NAME.toggleButtonIn(window).click(); ROW_FONT_BOLD_NAME.toggleButtonIn(window).requireNotSelected(); assertEquals(controller.getRowFontStyle().intValue(),Font.PLAIN); ROW_FONT_ITALIC_NAME.toggleButtonIn(window).click(); ROW_FONT_ITALIC_NAME.toggleButtonIn(window).requireSelected(); assertEquals(controller.getRowFontStyle().intValue(),Font.ITALIC); ROW_FONT_ITALIC_NAME.toggleButtonIn(window).click(); ROW_FONT_ITALIC_NAME.toggleButtonIn(window).requireNotSelected(); assertEquals(controller.getRowFontStyle().intValue(),Font.PLAIN); ROW_FONT_ITALIC_NAME.toggleButtonIn(window).click(); ROW_FONT_BOLD_NAME.toggleButtonIn(window).click(); assertEquals(controller.getRowFontStyle().intValue(),Font.BOLD+Font.ITALIC); COL_FONT_NAME.comboBoxIn(window).selectItem("Dialog"); COL_FONT_NAME.comboBoxIn(window).requireSelection("Dialog"); assertEquals(controller.getColumnHeaderFontName().name(), "Dialog"); COL_FONT_SIZE_NAME.spinnerIn(window).select(20); COL_FONT_SIZE_NAME.spinnerIn(window).requireValue(20); assertEquals(controller.getCellFontSize().intValue(),20); COL_FONT_BOLD_NAME.toggleButtonIn(window).click(); COL_FONT_BOLD_NAME.toggleButtonIn(window).requireSelected(); assertEquals(controller.getColumnHeaderFontStyle().intValue(),Font.BOLD); COL_FONT_BOLD_NAME.toggleButtonIn(window).click(); COL_FONT_BOLD_NAME.toggleButtonIn(window).requireNotSelected(); assertEquals(controller.getColumnHeaderFontStyle().intValue(),Font.PLAIN); COL_FONT_ITALIC_NAME.toggleButtonIn(window).click(); COL_FONT_ITALIC_NAME.toggleButtonIn(window).requireSelected(); assertEquals(controller.getColumnHeaderFontStyle().intValue(),Font.ITALIC); COL_FONT_ITALIC_NAME.toggleButtonIn(window).click(); COL_FONT_ITALIC_NAME.toggleButtonIn(window).requireNotSelected(); assertEquals(controller.getColumnHeaderFontStyle().intValue(),Font.PLAIN); COL_FONT_ITALIC_NAME.toggleButtonIn(window).click(); COL_FONT_BOLD_NAME.toggleButtonIn(window).click(); assertEquals(controller.getColumnHeaderFontStyle().intValue(),Font.BOLD+Font.ITALIC); window.comboBox(new ComboBoxMatcher("Row Header Border Color")).selectItem(0); assertEquals(controller.getRowHeaderBorderColor(),new Color(0,0,0)); window.comboBox(new ComboBoxMatcher("Column Header Border Color")).selectItem(0); assertEquals(controller.getColumnHeaderBorderColor(),new Color(0,0,0)); }
public void loadSettings() { if (controller.getTableOrientation() == TableOrientation.ROW_MAJOR) { setSelectedWithoutDispatchingEvents(tableRowOrientation, true); } else { setSelectedWithoutDispatchingEvents(tableColOrientation, true); } if ( controller.getRowHeight() > 0) { setValueWithoutDispatchingEvents(rowHeightSpinner, controller.getRowHeight(), rowHeightListener); } setValueWithoutDispatchingEvents(columnWidthSpinner, controller.getColumnWidth(), columnWidthListener); mgr.showAll(); configureAbbreviationSettings( LabelType.ROW, ROW_HEADER_LABEL, rowHeaderFullLabel, rowHeaderAbbreviatedLabel, rowHeaderAbbreviations, controller.getRowLabelAbbreviationSettings() ); configureAbbreviationSettings( LabelType.COLUMN, COLUMN_HEADER_LABEL, columnHeaderFullLabel, columnHeaderAbbreviatedLabel, columnHeaderAbbreviations, controller.getColumnLabelAbbreviationSettings() ); configureAbbreviationSettings( LabelType.CELL, CELL_LABEL, cellFullLabel, cellAbbreviatedLabel, cellAbbreviations, controller.getCellLabelAbbreviationSettings() ); ComboBoxModel enumerationModel = controller.getEnumerationModel(); enumeration.setModel(enumerationModel); if (enumerationModel.getSize() <= 1) { enumeration.setEnabled(false); } else { enumeration.setEnabled(true); } if (controller.selectedCellsHaveMixedEnumerations()) { ActionListener[] listeners = enumeration.getActionListeners(); for (ActionListener al : listeners) { enumeration.removeActionListener(al); } enumeration.setSelectedIndex(-1); for (ActionListener al : listeners) { enumeration.addActionListener(al); } } ActionListener[] listeners = numberOfDecimals.getActionListeners(); for (ActionListener al : listeners) { numberOfDecimals.removeActionListener(al); } int decimals = controller.getDecimalPlaces() == null ? -1 : controller.getDecimalPlaces(); numberOfDecimals.setSelectedIndex(decimals); for (ActionListener al : listeners) { numberOfDecimals.addActionListener(al); } listeners = rowHeaderFontName.getActionListeners(); for (ActionListener al : listeners) { rowHeaderFontName.removeActionListener(al); } if (controller.getRowHeaderFontName() != null) { rowHeaderFontName.setSelectedItem(controller.getRowHeaderFontName()); } else { rowHeaderFontName.setSelectedIndex(-1); } for (ActionListener al : listeners) { rowHeaderFontName.addActionListener(al); } listeners = columnHeaderFontName.getActionListeners(); for (ActionListener al : listeners) { columnHeaderFontName.removeActionListener(al); } if (controller.getRowHeaderFontName() != null) { columnHeaderFontName.setSelectedItem(controller.getColumnHeaderFontName()); } else { columnHeaderFontName.setSelectedIndex(-1); } for (ActionListener al : listeners) { columnHeaderFontName.addActionListener(al); } if (controller.getRowHeaderFontSize() != null) { setValueWithoutDispatchingEvents(rowHeaderFontSize, controller.getRowHeaderFontSize().intValue(), rowHeaderFontSizeListener); } if (controller.getColumnHeaderFontSize() != null) { setValueWithoutDispatchingEvents(columnHeaderFontSize, controller.getColumnHeaderFontSize().intValue(), columnHeaderFontSizeListener); } if (controller.getCellFontSize() != null) { setValueWithoutDispatchingEvents(cellFontSize, controller.getCellFontSize().intValue(), cellFontSizeListener); } if (controller.getRowFontStyle() != null) { if (controller.getRowFontStyle().equals(Font.BOLD)) { rowHeaderFontStyleBold.setSelected(true); rowHeaderFontStyleItalic.setSelected(false); } else if (controller.getRowFontStyle().equals(Font.ITALIC)) { rowHeaderFontStyleItalic.setSelected(true); rowHeaderFontStyleBold.setSelected(false); } else if (controller.getRowFontStyle().equals(Font.BOLD+Font.ITALIC)) { rowHeaderFontStyleBold.setSelected(true); rowHeaderFontStyleItalic.setSelected(true); } else { rowHeaderFontStyleBold.setSelected(false); rowHeaderFontStyleItalic.setSelected(false); } } else { rowHeaderFontStyleBold.setSelected(false); rowHeaderFontStyleItalic.setSelected(false); } if (controller.getCellFontTextAttribute() != null) { if (controller.getCellFontTextAttribute().equals(TextAttribute.UNDERLINE_ON)) { cellFontUnderline.setSelected(true); } else { cellFontUnderline.setSelected(false); } } if (controller.getRowHeaderTextAttribute() != null) { if (controller.getRowHeaderTextAttribute().equals(TextAttribute.UNDERLINE_ON)) { rowHeaderFontUnderline.setSelected(true); } else { rowHeaderFontUnderline.setSelected(false); } } if (controller.getColumnHeaderFontStyle() != null) { if (controller.getColumnHeaderFontStyle().equals(Font.BOLD)) { columnHeaderFontStyleBold.setSelected(true); columnHeaderFontStyleItalic.setSelected(false); } else if (controller.getColumnHeaderFontStyle().equals(Font.ITALIC)) { columnHeaderFontStyleItalic.setSelected(true); columnHeaderFontStyleBold.setSelected(false); } else if (controller.getColumnHeaderFontStyle().equals(Font.BOLD+Font.ITALIC)) { columnHeaderFontStyleBold.setSelected(true); columnHeaderFontStyleItalic.setSelected(true); } else { columnHeaderFontStyleBold.setSelected(false); columnHeaderFontStyleItalic.setSelected(false); } } else { columnHeaderFontStyleBold.setSelected(false); columnHeaderFontStyleItalic.setSelected(false); } if (controller.getColumnHeaderTextAttribute() != null) { if (controller.getColumnHeaderTextAttribute().equals(TextAttribute.UNDERLINE_ON)) { columnHeaderFontStyleUnderline.setSelected(true); } else { columnHeaderFontStyleUnderline.setSelected(false); } } if (controller.getCellFontStyle() != null) { if (controller.getCellFontStyle().equals(Font.BOLD)) { cellFontStyleBold.setSelected(true); cellFontStyleItalic.setSelected(false); } else if (controller.getCellFontStyle().equals(Font.ITALIC)) { cellFontStyleItalic.setSelected(true); cellFontStyleBold.setSelected(false); } else if (controller.getCellFontStyle().equals(Font.BOLD+Font.ITALIC)) { cellFontStyleBold.setSelected(true); cellFontStyleItalic.setSelected(true); } else { cellFontStyleBold.setSelected(false); cellFontStyleItalic.setSelected(false); } } else { cellFontStyleBold.setSelected(false); cellFontStyleItalic.setSelected(false); } if (controller.getRowHeaderFontColor() != null) { listeners = rowForegroundColorComboBox.getActionListeners(); for (ActionListener al : listeners) { rowForegroundColorComboBox.removeActionListener(al); } rowForegroundColorComboBox.setSelectedItem(controller.getRowHeaderFontColor()); for (ActionListener al : listeners) { rowForegroundColorComboBox.addActionListener(al); } } else { setSelectedWithoutDispatchingEvents(rowForegroundColorComboBox, 0); } if (controller.getColumnHeaderFontColor() != null) { listeners = columnForegroundColorComboBox.getActionListeners(); for (ActionListener al : listeners) { columnForegroundColorComboBox.removeActionListener(al); } columnForegroundColorComboBox.setSelectedItem(controller.getColumnHeaderFontColor()); for (ActionListener al : listeners) { columnForegroundColorComboBox.addActionListener(al); } } else { setSelectedWithoutDispatchingEvents(columnForegroundColorComboBox, 0); } if (controller.getRowHeaderBorderColor() != null) { listeners = rowHeaderBorderColorComboBox.getActionListeners(); for (ActionListener al : listeners) { rowHeaderBorderColorComboBox.removeActionListener(al); } rowHeaderBorderColorComboBox.setSelectedItem(controller.getRowHeaderBorderColor()); for (ActionListener al : listeners) { rowHeaderBorderColorComboBox.addActionListener(al); } } else { setSelectedWithoutDispatchingEvents(rowHeaderBorderColorComboBox, 0); } if (controller.getColumnHeaderBorderColor() != null) { columnHeaderBorderColorComboBox.setSelectedItem(controller.getColumnHeaderBorderColor()); } else { setSelectedWithoutDispatchingEvents(columnHeaderBorderColorComboBox, 0); } if (controller.getRowHeaderBackgroundColor() != null) { listeners = rowBackgroundColorComboBox.getActionListeners(); for (ActionListener al : listeners) { rowBackgroundColorComboBox.removeActionListener(al); } rowBackgroundColorComboBox.setSelectedItem(controller.getRowHeaderBackgroundColor()); for (ActionListener al : listeners) { rowBackgroundColorComboBox.addActionListener(al); } } else { setSelectedWithoutDispatchingEvents(rowBackgroundColorComboBox, 0); } if (controller.getColumnHeaderBackgroundColor() != null) { columnBackgroundColorComboBox.setSelectedItem(controller.getColumnHeaderBackgroundColor()); } else { setSelectedWithoutDispatchingEvents(columnBackgroundColorComboBox, 0); } if (controller.getCellFontColor() != null) { listeners = cellFontColorComboBox.getActionListeners(); for (ActionListener al : listeners) { cellFontColorComboBox.removeActionListener(al); } cellFontColorComboBox.setSelectedItem(controller.getCellFontColor()); for (ActionListener al : listeners) { cellFontColorComboBox.addActionListener(al); } } else { setSelectedWithoutDispatchingEvents(cellFontColorComboBox, 0); } if (controller.getCellBackgroundColor() != null) { listeners = cellBackgroundColorComboBox.getActionListeners(); for (ActionListener al : listeners) { cellBackgroundColorComboBox.removeActionListener(al); } cellBackgroundColorComboBox.setSelectedItem(controller.getCellBackgroundColor()); for (ActionListener al : listeners) { cellBackgroundColorComboBox.addActionListener(al); } } else { setSelectedWithoutDispatchingEvents(cellBackgroundColorComboBox, 0); } listeners = cellFontName.getActionListeners(); for (ActionListener al : listeners) { cellFontName.removeActionListener(al); } if (controller.getCellFontName() != null) { cellFontName.setSelectedItem(controller.getCellFontName()); } else { cellFontName.setSelectedIndex(-1); } for (ActionListener al : listeners) { cellFontName.addActionListener(al); } listeners = dateFormatChooser.getActionListeners(); for (ActionListener al : listeners) { dateFormatChooser.removeActionListener(al); } DateFormatItem dateFormatState = controller.getDateFormat() == null ? DateFormatItem.None : controller.getDateFormat(); dateFormatChooser.setSelectedItem(dateFormatState); for (ActionListener al : listeners) { dateFormatChooser.addActionListener(al); } BorderState borderState = controller.getBorderState(); toggleWithoutAction(cellBorderOnLeft, borderState.hasWestBorder()); toggleWithoutAction(cellBorderOnTop, borderState.hasNorthBorder()); toggleWithoutAction(cellBorderOnRight, borderState.hasEastBorder()); toggleWithoutAction(cellBorderOnBottom, borderState.hasSouthBorder()); BorderState rowHeaderborderState = controller.getRowHeaderBorderState(); if (rowHeaderborderState == null) { rowHeaderborderState = new BorderState(BorderEdge.NONE.value()); } toggleWithoutAction(rowHeaderBorderOnLeft, rowHeaderborderState.hasWestBorder()); toggleWithoutAction(rowHeaderBorderOnTop, rowHeaderborderState.hasNorthBorder()); toggleWithoutAction(rowHeaderBorderOnRight, rowHeaderborderState.hasEastBorder()); toggleWithoutAction(rowHeaderBorderOnBottom, rowHeaderborderState.hasSouthBorder()); BorderState columnHeaderborderState = controller.getColumnHeaderBorderState(); if (columnHeaderborderState == null) { columnHeaderborderState = new BorderState(BorderEdge.NONE.value()); } toggleWithoutAction(columnHeaderBorderOnLeft, columnHeaderborderState.hasWestBorder()); toggleWithoutAction(columnHeaderBorderOnTop, columnHeaderborderState.hasNorthBorder()); toggleWithoutAction(columnHeaderBorderOnRight, columnHeaderborderState.hasEastBorder()); toggleWithoutAction(columnHeaderBorderOnBottom, columnHeaderborderState.hasSouthBorder()); ContentAlignment alignment = controller.getCellAlignment(); selectButtonWithoutAction(cellAlignGroup, alignment); alignment = controller.getRowHeaderAlignment(); selectButtonWithoutAction(rowHeaderAlignGroup, alignment); alignment = controller.getColumnHeaderAlignment(); selectButtonWithoutAction(columnHeaderAlignGroup, alignment); if (controller.getSelectedCellCount() == (controller.getTableColumnCount() * controller.getTableRowCount()) || ((controller.getSelectedCellCount() == 0) && controller.canSetOrientation())) { mgr.enable(TABLE_ORIENTATION, true); } else if (controller.getSelectedCellCount() > 0) { mgr.disable(TABLE_ORIENTATION, true); } mgr.hide(SELECTION_NOT_EMPTY, controller.getSelectedCellCount() == 0); mgr.hide(HEADERS_HIDABLE, !controller.isCanHideHeaders()); mgr.hide(SINGLE_CELL_SELECTION, controller.getSelectedCellCount()!=1); mgr.hide(TABLE_ORIENTATION, !controller.canSetOrientation()); mgr.hide(TRANSPOSE, !controller.canTranspose()); mgr.hide(NOT_FULLY_IMPLEMENTED, true); mgr.enable(DATE_CONTROLS, true); if ((!controller.enumerationIsNone(enumerationModel) )) { mgr.disable(DECIMAL_CONTROLS, true); mgr.disable(DECIMAL_ALIGNMENT_BUTTON, true); mgr.disable(DATE_CONTROLS, true); } else if (!controller.dateIsNone(dateFormatChooser.getModel())) { mgr.disable(DECIMAL_CONTROLS, true); mgr.disable(DECIMAL_ALIGNMENT_BUTTON, true); } else { mgr.enable(DECIMAL_CONTROLS, true); mgr.enable(DECIMAL_ALIGNMENT_BUTTON, true); mgr.enable(DATE_CONTROLS, true); } mgr.hide(DECIMAL_CONTROLS, !controller.showDecimalPlaces()); mgr.hide(DATE_CONTROLS, !controller.showDecimalPlaces()); mgr.hideIfOthersHidden(rowColumnFormattingPanel, rowHeightSpinner, columnWidthSpinner, tableRowOrientation, transposeTableButton, rowHeaderAlignLeft, columnHeaderAlignLeft, showRowHeaders); mgr.tagComponents(COLUMN_IS_NOT_SELECTED, columnHeaderFontName, columnHeaderFontSize, columnHeaderFontStyleBold, columnHeaderFontStyleItalic, columnForegroundColorComboBox); mgr.hide(COLUMN_IS_NOT_SELECTED, controller.getSelectedColumnCount() == 0); mgr.tagComponents(ROW_IS_NOT_SELECTED, rowColumnFontFormattingPanel, rowHeaderFontName, rowHeaderFontSize, rowHeaderFontStyleBold, rowHeaderFontStyleItalic,rowForegroundColorComboBox); mgr.hide(ROW_IS_NOT_SELECTED, controller.getSelectedRowCount() == 0); mgr.hideIfOthersHidden(cellFormattingPanel, propertyToShow, enumeration, numberOfDecimals, dateFormatChooser, cellBorderOnLeft, cellBorderOnTop, cellBorderOnRight, cellBorderOnBottom); }
TableSettingsControlPanel extends JPanel { public void loadSettings() { if (controller.getTableOrientation() == TableOrientation.ROW_MAJOR) { setSelectedWithoutDispatchingEvents(tableRowOrientation, true); } else { setSelectedWithoutDispatchingEvents(tableColOrientation, true); } if ( controller.getRowHeight() > 0) { setValueWithoutDispatchingEvents(rowHeightSpinner, controller.getRowHeight(), rowHeightListener); } setValueWithoutDispatchingEvents(columnWidthSpinner, controller.getColumnWidth(), columnWidthListener); mgr.showAll(); configureAbbreviationSettings( LabelType.ROW, ROW_HEADER_LABEL, rowHeaderFullLabel, rowHeaderAbbreviatedLabel, rowHeaderAbbreviations, controller.getRowLabelAbbreviationSettings() ); configureAbbreviationSettings( LabelType.COLUMN, COLUMN_HEADER_LABEL, columnHeaderFullLabel, columnHeaderAbbreviatedLabel, columnHeaderAbbreviations, controller.getColumnLabelAbbreviationSettings() ); configureAbbreviationSettings( LabelType.CELL, CELL_LABEL, cellFullLabel, cellAbbreviatedLabel, cellAbbreviations, controller.getCellLabelAbbreviationSettings() ); ComboBoxModel enumerationModel = controller.getEnumerationModel(); enumeration.setModel(enumerationModel); if (enumerationModel.getSize() <= 1) { enumeration.setEnabled(false); } else { enumeration.setEnabled(true); } if (controller.selectedCellsHaveMixedEnumerations()) { ActionListener[] listeners = enumeration.getActionListeners(); for (ActionListener al : listeners) { enumeration.removeActionListener(al); } enumeration.setSelectedIndex(-1); for (ActionListener al : listeners) { enumeration.addActionListener(al); } } ActionListener[] listeners = numberOfDecimals.getActionListeners(); for (ActionListener al : listeners) { numberOfDecimals.removeActionListener(al); } int decimals = controller.getDecimalPlaces() == null ? -1 : controller.getDecimalPlaces(); numberOfDecimals.setSelectedIndex(decimals); for (ActionListener al : listeners) { numberOfDecimals.addActionListener(al); } listeners = rowHeaderFontName.getActionListeners(); for (ActionListener al : listeners) { rowHeaderFontName.removeActionListener(al); } if (controller.getRowHeaderFontName() != null) { rowHeaderFontName.setSelectedItem(controller.getRowHeaderFontName()); } else { rowHeaderFontName.setSelectedIndex(-1); } for (ActionListener al : listeners) { rowHeaderFontName.addActionListener(al); } listeners = columnHeaderFontName.getActionListeners(); for (ActionListener al : listeners) { columnHeaderFontName.removeActionListener(al); } if (controller.getRowHeaderFontName() != null) { columnHeaderFontName.setSelectedItem(controller.getColumnHeaderFontName()); } else { columnHeaderFontName.setSelectedIndex(-1); } for (ActionListener al : listeners) { columnHeaderFontName.addActionListener(al); } if (controller.getRowHeaderFontSize() != null) { setValueWithoutDispatchingEvents(rowHeaderFontSize, controller.getRowHeaderFontSize().intValue(), rowHeaderFontSizeListener); } if (controller.getColumnHeaderFontSize() != null) { setValueWithoutDispatchingEvents(columnHeaderFontSize, controller.getColumnHeaderFontSize().intValue(), columnHeaderFontSizeListener); } if (controller.getCellFontSize() != null) { setValueWithoutDispatchingEvents(cellFontSize, controller.getCellFontSize().intValue(), cellFontSizeListener); } if (controller.getRowFontStyle() != null) { if (controller.getRowFontStyle().equals(Font.BOLD)) { rowHeaderFontStyleBold.setSelected(true); rowHeaderFontStyleItalic.setSelected(false); } else if (controller.getRowFontStyle().equals(Font.ITALIC)) { rowHeaderFontStyleItalic.setSelected(true); rowHeaderFontStyleBold.setSelected(false); } else if (controller.getRowFontStyle().equals(Font.BOLD+Font.ITALIC)) { rowHeaderFontStyleBold.setSelected(true); rowHeaderFontStyleItalic.setSelected(true); } else { rowHeaderFontStyleBold.setSelected(false); rowHeaderFontStyleItalic.setSelected(false); } } else { rowHeaderFontStyleBold.setSelected(false); rowHeaderFontStyleItalic.setSelected(false); } if (controller.getCellFontTextAttribute() != null) { if (controller.getCellFontTextAttribute().equals(TextAttribute.UNDERLINE_ON)) { cellFontUnderline.setSelected(true); } else { cellFontUnderline.setSelected(false); } } if (controller.getRowHeaderTextAttribute() != null) { if (controller.getRowHeaderTextAttribute().equals(TextAttribute.UNDERLINE_ON)) { rowHeaderFontUnderline.setSelected(true); } else { rowHeaderFontUnderline.setSelected(false); } } if (controller.getColumnHeaderFontStyle() != null) { if (controller.getColumnHeaderFontStyle().equals(Font.BOLD)) { columnHeaderFontStyleBold.setSelected(true); columnHeaderFontStyleItalic.setSelected(false); } else if (controller.getColumnHeaderFontStyle().equals(Font.ITALIC)) { columnHeaderFontStyleItalic.setSelected(true); columnHeaderFontStyleBold.setSelected(false); } else if (controller.getColumnHeaderFontStyle().equals(Font.BOLD+Font.ITALIC)) { columnHeaderFontStyleBold.setSelected(true); columnHeaderFontStyleItalic.setSelected(true); } else { columnHeaderFontStyleBold.setSelected(false); columnHeaderFontStyleItalic.setSelected(false); } } else { columnHeaderFontStyleBold.setSelected(false); columnHeaderFontStyleItalic.setSelected(false); } if (controller.getColumnHeaderTextAttribute() != null) { if (controller.getColumnHeaderTextAttribute().equals(TextAttribute.UNDERLINE_ON)) { columnHeaderFontStyleUnderline.setSelected(true); } else { columnHeaderFontStyleUnderline.setSelected(false); } } if (controller.getCellFontStyle() != null) { if (controller.getCellFontStyle().equals(Font.BOLD)) { cellFontStyleBold.setSelected(true); cellFontStyleItalic.setSelected(false); } else if (controller.getCellFontStyle().equals(Font.ITALIC)) { cellFontStyleItalic.setSelected(true); cellFontStyleBold.setSelected(false); } else if (controller.getCellFontStyle().equals(Font.BOLD+Font.ITALIC)) { cellFontStyleBold.setSelected(true); cellFontStyleItalic.setSelected(true); } else { cellFontStyleBold.setSelected(false); cellFontStyleItalic.setSelected(false); } } else { cellFontStyleBold.setSelected(false); cellFontStyleItalic.setSelected(false); } if (controller.getRowHeaderFontColor() != null) { listeners = rowForegroundColorComboBox.getActionListeners(); for (ActionListener al : listeners) { rowForegroundColorComboBox.removeActionListener(al); } rowForegroundColorComboBox.setSelectedItem(controller.getRowHeaderFontColor()); for (ActionListener al : listeners) { rowForegroundColorComboBox.addActionListener(al); } } else { setSelectedWithoutDispatchingEvents(rowForegroundColorComboBox, 0); } if (controller.getColumnHeaderFontColor() != null) { listeners = columnForegroundColorComboBox.getActionListeners(); for (ActionListener al : listeners) { columnForegroundColorComboBox.removeActionListener(al); } columnForegroundColorComboBox.setSelectedItem(controller.getColumnHeaderFontColor()); for (ActionListener al : listeners) { columnForegroundColorComboBox.addActionListener(al); } } else { setSelectedWithoutDispatchingEvents(columnForegroundColorComboBox, 0); } if (controller.getRowHeaderBorderColor() != null) { listeners = rowHeaderBorderColorComboBox.getActionListeners(); for (ActionListener al : listeners) { rowHeaderBorderColorComboBox.removeActionListener(al); } rowHeaderBorderColorComboBox.setSelectedItem(controller.getRowHeaderBorderColor()); for (ActionListener al : listeners) { rowHeaderBorderColorComboBox.addActionListener(al); } } else { setSelectedWithoutDispatchingEvents(rowHeaderBorderColorComboBox, 0); } if (controller.getColumnHeaderBorderColor() != null) { columnHeaderBorderColorComboBox.setSelectedItem(controller.getColumnHeaderBorderColor()); } else { setSelectedWithoutDispatchingEvents(columnHeaderBorderColorComboBox, 0); } if (controller.getRowHeaderBackgroundColor() != null) { listeners = rowBackgroundColorComboBox.getActionListeners(); for (ActionListener al : listeners) { rowBackgroundColorComboBox.removeActionListener(al); } rowBackgroundColorComboBox.setSelectedItem(controller.getRowHeaderBackgroundColor()); for (ActionListener al : listeners) { rowBackgroundColorComboBox.addActionListener(al); } } else { setSelectedWithoutDispatchingEvents(rowBackgroundColorComboBox, 0); } if (controller.getColumnHeaderBackgroundColor() != null) { columnBackgroundColorComboBox.setSelectedItem(controller.getColumnHeaderBackgroundColor()); } else { setSelectedWithoutDispatchingEvents(columnBackgroundColorComboBox, 0); } if (controller.getCellFontColor() != null) { listeners = cellFontColorComboBox.getActionListeners(); for (ActionListener al : listeners) { cellFontColorComboBox.removeActionListener(al); } cellFontColorComboBox.setSelectedItem(controller.getCellFontColor()); for (ActionListener al : listeners) { cellFontColorComboBox.addActionListener(al); } } else { setSelectedWithoutDispatchingEvents(cellFontColorComboBox, 0); } if (controller.getCellBackgroundColor() != null) { listeners = cellBackgroundColorComboBox.getActionListeners(); for (ActionListener al : listeners) { cellBackgroundColorComboBox.removeActionListener(al); } cellBackgroundColorComboBox.setSelectedItem(controller.getCellBackgroundColor()); for (ActionListener al : listeners) { cellBackgroundColorComboBox.addActionListener(al); } } else { setSelectedWithoutDispatchingEvents(cellBackgroundColorComboBox, 0); } listeners = cellFontName.getActionListeners(); for (ActionListener al : listeners) { cellFontName.removeActionListener(al); } if (controller.getCellFontName() != null) { cellFontName.setSelectedItem(controller.getCellFontName()); } else { cellFontName.setSelectedIndex(-1); } for (ActionListener al : listeners) { cellFontName.addActionListener(al); } listeners = dateFormatChooser.getActionListeners(); for (ActionListener al : listeners) { dateFormatChooser.removeActionListener(al); } DateFormatItem dateFormatState = controller.getDateFormat() == null ? DateFormatItem.None : controller.getDateFormat(); dateFormatChooser.setSelectedItem(dateFormatState); for (ActionListener al : listeners) { dateFormatChooser.addActionListener(al); } BorderState borderState = controller.getBorderState(); toggleWithoutAction(cellBorderOnLeft, borderState.hasWestBorder()); toggleWithoutAction(cellBorderOnTop, borderState.hasNorthBorder()); toggleWithoutAction(cellBorderOnRight, borderState.hasEastBorder()); toggleWithoutAction(cellBorderOnBottom, borderState.hasSouthBorder()); BorderState rowHeaderborderState = controller.getRowHeaderBorderState(); if (rowHeaderborderState == null) { rowHeaderborderState = new BorderState(BorderEdge.NONE.value()); } toggleWithoutAction(rowHeaderBorderOnLeft, rowHeaderborderState.hasWestBorder()); toggleWithoutAction(rowHeaderBorderOnTop, rowHeaderborderState.hasNorthBorder()); toggleWithoutAction(rowHeaderBorderOnRight, rowHeaderborderState.hasEastBorder()); toggleWithoutAction(rowHeaderBorderOnBottom, rowHeaderborderState.hasSouthBorder()); BorderState columnHeaderborderState = controller.getColumnHeaderBorderState(); if (columnHeaderborderState == null) { columnHeaderborderState = new BorderState(BorderEdge.NONE.value()); } toggleWithoutAction(columnHeaderBorderOnLeft, columnHeaderborderState.hasWestBorder()); toggleWithoutAction(columnHeaderBorderOnTop, columnHeaderborderState.hasNorthBorder()); toggleWithoutAction(columnHeaderBorderOnRight, columnHeaderborderState.hasEastBorder()); toggleWithoutAction(columnHeaderBorderOnBottom, columnHeaderborderState.hasSouthBorder()); ContentAlignment alignment = controller.getCellAlignment(); selectButtonWithoutAction(cellAlignGroup, alignment); alignment = controller.getRowHeaderAlignment(); selectButtonWithoutAction(rowHeaderAlignGroup, alignment); alignment = controller.getColumnHeaderAlignment(); selectButtonWithoutAction(columnHeaderAlignGroup, alignment); if (controller.getSelectedCellCount() == (controller.getTableColumnCount() * controller.getTableRowCount()) || ((controller.getSelectedCellCount() == 0) && controller.canSetOrientation())) { mgr.enable(TABLE_ORIENTATION, true); } else if (controller.getSelectedCellCount() > 0) { mgr.disable(TABLE_ORIENTATION, true); } mgr.hide(SELECTION_NOT_EMPTY, controller.getSelectedCellCount() == 0); mgr.hide(HEADERS_HIDABLE, !controller.isCanHideHeaders()); mgr.hide(SINGLE_CELL_SELECTION, controller.getSelectedCellCount()!=1); mgr.hide(TABLE_ORIENTATION, !controller.canSetOrientation()); mgr.hide(TRANSPOSE, !controller.canTranspose()); mgr.hide(NOT_FULLY_IMPLEMENTED, true); mgr.enable(DATE_CONTROLS, true); if ((!controller.enumerationIsNone(enumerationModel) )) { mgr.disable(DECIMAL_CONTROLS, true); mgr.disable(DECIMAL_ALIGNMENT_BUTTON, true); mgr.disable(DATE_CONTROLS, true); } else if (!controller.dateIsNone(dateFormatChooser.getModel())) { mgr.disable(DECIMAL_CONTROLS, true); mgr.disable(DECIMAL_ALIGNMENT_BUTTON, true); } else { mgr.enable(DECIMAL_CONTROLS, true); mgr.enable(DECIMAL_ALIGNMENT_BUTTON, true); mgr.enable(DATE_CONTROLS, true); } mgr.hide(DECIMAL_CONTROLS, !controller.showDecimalPlaces()); mgr.hide(DATE_CONTROLS, !controller.showDecimalPlaces()); mgr.hideIfOthersHidden(rowColumnFormattingPanel, rowHeightSpinner, columnWidthSpinner, tableRowOrientation, transposeTableButton, rowHeaderAlignLeft, columnHeaderAlignLeft, showRowHeaders); mgr.tagComponents(COLUMN_IS_NOT_SELECTED, columnHeaderFontName, columnHeaderFontSize, columnHeaderFontStyleBold, columnHeaderFontStyleItalic, columnForegroundColorComboBox); mgr.hide(COLUMN_IS_NOT_SELECTED, controller.getSelectedColumnCount() == 0); mgr.tagComponents(ROW_IS_NOT_SELECTED, rowColumnFontFormattingPanel, rowHeaderFontName, rowHeaderFontSize, rowHeaderFontStyleBold, rowHeaderFontStyleItalic,rowForegroundColorComboBox); mgr.hide(ROW_IS_NOT_SELECTED, controller.getSelectedRowCount() == 0); mgr.hideIfOthersHidden(cellFormattingPanel, propertyToShow, enumeration, numberOfDecimals, dateFormatChooser, cellBorderOnLeft, cellBorderOnTop, cellBorderOnRight, cellBorderOnBottom); } }
TableSettingsControlPanel extends JPanel { public void loadSettings() { if (controller.getTableOrientation() == TableOrientation.ROW_MAJOR) { setSelectedWithoutDispatchingEvents(tableRowOrientation, true); } else { setSelectedWithoutDispatchingEvents(tableColOrientation, true); } if ( controller.getRowHeight() > 0) { setValueWithoutDispatchingEvents(rowHeightSpinner, controller.getRowHeight(), rowHeightListener); } setValueWithoutDispatchingEvents(columnWidthSpinner, controller.getColumnWidth(), columnWidthListener); mgr.showAll(); configureAbbreviationSettings( LabelType.ROW, ROW_HEADER_LABEL, rowHeaderFullLabel, rowHeaderAbbreviatedLabel, rowHeaderAbbreviations, controller.getRowLabelAbbreviationSettings() ); configureAbbreviationSettings( LabelType.COLUMN, COLUMN_HEADER_LABEL, columnHeaderFullLabel, columnHeaderAbbreviatedLabel, columnHeaderAbbreviations, controller.getColumnLabelAbbreviationSettings() ); configureAbbreviationSettings( LabelType.CELL, CELL_LABEL, cellFullLabel, cellAbbreviatedLabel, cellAbbreviations, controller.getCellLabelAbbreviationSettings() ); ComboBoxModel enumerationModel = controller.getEnumerationModel(); enumeration.setModel(enumerationModel); if (enumerationModel.getSize() <= 1) { enumeration.setEnabled(false); } else { enumeration.setEnabled(true); } if (controller.selectedCellsHaveMixedEnumerations()) { ActionListener[] listeners = enumeration.getActionListeners(); for (ActionListener al : listeners) { enumeration.removeActionListener(al); } enumeration.setSelectedIndex(-1); for (ActionListener al : listeners) { enumeration.addActionListener(al); } } ActionListener[] listeners = numberOfDecimals.getActionListeners(); for (ActionListener al : listeners) { numberOfDecimals.removeActionListener(al); } int decimals = controller.getDecimalPlaces() == null ? -1 : controller.getDecimalPlaces(); numberOfDecimals.setSelectedIndex(decimals); for (ActionListener al : listeners) { numberOfDecimals.addActionListener(al); } listeners = rowHeaderFontName.getActionListeners(); for (ActionListener al : listeners) { rowHeaderFontName.removeActionListener(al); } if (controller.getRowHeaderFontName() != null) { rowHeaderFontName.setSelectedItem(controller.getRowHeaderFontName()); } else { rowHeaderFontName.setSelectedIndex(-1); } for (ActionListener al : listeners) { rowHeaderFontName.addActionListener(al); } listeners = columnHeaderFontName.getActionListeners(); for (ActionListener al : listeners) { columnHeaderFontName.removeActionListener(al); } if (controller.getRowHeaderFontName() != null) { columnHeaderFontName.setSelectedItem(controller.getColumnHeaderFontName()); } else { columnHeaderFontName.setSelectedIndex(-1); } for (ActionListener al : listeners) { columnHeaderFontName.addActionListener(al); } if (controller.getRowHeaderFontSize() != null) { setValueWithoutDispatchingEvents(rowHeaderFontSize, controller.getRowHeaderFontSize().intValue(), rowHeaderFontSizeListener); } if (controller.getColumnHeaderFontSize() != null) { setValueWithoutDispatchingEvents(columnHeaderFontSize, controller.getColumnHeaderFontSize().intValue(), columnHeaderFontSizeListener); } if (controller.getCellFontSize() != null) { setValueWithoutDispatchingEvents(cellFontSize, controller.getCellFontSize().intValue(), cellFontSizeListener); } if (controller.getRowFontStyle() != null) { if (controller.getRowFontStyle().equals(Font.BOLD)) { rowHeaderFontStyleBold.setSelected(true); rowHeaderFontStyleItalic.setSelected(false); } else if (controller.getRowFontStyle().equals(Font.ITALIC)) { rowHeaderFontStyleItalic.setSelected(true); rowHeaderFontStyleBold.setSelected(false); } else if (controller.getRowFontStyle().equals(Font.BOLD+Font.ITALIC)) { rowHeaderFontStyleBold.setSelected(true); rowHeaderFontStyleItalic.setSelected(true); } else { rowHeaderFontStyleBold.setSelected(false); rowHeaderFontStyleItalic.setSelected(false); } } else { rowHeaderFontStyleBold.setSelected(false); rowHeaderFontStyleItalic.setSelected(false); } if (controller.getCellFontTextAttribute() != null) { if (controller.getCellFontTextAttribute().equals(TextAttribute.UNDERLINE_ON)) { cellFontUnderline.setSelected(true); } else { cellFontUnderline.setSelected(false); } } if (controller.getRowHeaderTextAttribute() != null) { if (controller.getRowHeaderTextAttribute().equals(TextAttribute.UNDERLINE_ON)) { rowHeaderFontUnderline.setSelected(true); } else { rowHeaderFontUnderline.setSelected(false); } } if (controller.getColumnHeaderFontStyle() != null) { if (controller.getColumnHeaderFontStyle().equals(Font.BOLD)) { columnHeaderFontStyleBold.setSelected(true); columnHeaderFontStyleItalic.setSelected(false); } else if (controller.getColumnHeaderFontStyle().equals(Font.ITALIC)) { columnHeaderFontStyleItalic.setSelected(true); columnHeaderFontStyleBold.setSelected(false); } else if (controller.getColumnHeaderFontStyle().equals(Font.BOLD+Font.ITALIC)) { columnHeaderFontStyleBold.setSelected(true); columnHeaderFontStyleItalic.setSelected(true); } else { columnHeaderFontStyleBold.setSelected(false); columnHeaderFontStyleItalic.setSelected(false); } } else { columnHeaderFontStyleBold.setSelected(false); columnHeaderFontStyleItalic.setSelected(false); } if (controller.getColumnHeaderTextAttribute() != null) { if (controller.getColumnHeaderTextAttribute().equals(TextAttribute.UNDERLINE_ON)) { columnHeaderFontStyleUnderline.setSelected(true); } else { columnHeaderFontStyleUnderline.setSelected(false); } } if (controller.getCellFontStyle() != null) { if (controller.getCellFontStyle().equals(Font.BOLD)) { cellFontStyleBold.setSelected(true); cellFontStyleItalic.setSelected(false); } else if (controller.getCellFontStyle().equals(Font.ITALIC)) { cellFontStyleItalic.setSelected(true); cellFontStyleBold.setSelected(false); } else if (controller.getCellFontStyle().equals(Font.BOLD+Font.ITALIC)) { cellFontStyleBold.setSelected(true); cellFontStyleItalic.setSelected(true); } else { cellFontStyleBold.setSelected(false); cellFontStyleItalic.setSelected(false); } } else { cellFontStyleBold.setSelected(false); cellFontStyleItalic.setSelected(false); } if (controller.getRowHeaderFontColor() != null) { listeners = rowForegroundColorComboBox.getActionListeners(); for (ActionListener al : listeners) { rowForegroundColorComboBox.removeActionListener(al); } rowForegroundColorComboBox.setSelectedItem(controller.getRowHeaderFontColor()); for (ActionListener al : listeners) { rowForegroundColorComboBox.addActionListener(al); } } else { setSelectedWithoutDispatchingEvents(rowForegroundColorComboBox, 0); } if (controller.getColumnHeaderFontColor() != null) { listeners = columnForegroundColorComboBox.getActionListeners(); for (ActionListener al : listeners) { columnForegroundColorComboBox.removeActionListener(al); } columnForegroundColorComboBox.setSelectedItem(controller.getColumnHeaderFontColor()); for (ActionListener al : listeners) { columnForegroundColorComboBox.addActionListener(al); } } else { setSelectedWithoutDispatchingEvents(columnForegroundColorComboBox, 0); } if (controller.getRowHeaderBorderColor() != null) { listeners = rowHeaderBorderColorComboBox.getActionListeners(); for (ActionListener al : listeners) { rowHeaderBorderColorComboBox.removeActionListener(al); } rowHeaderBorderColorComboBox.setSelectedItem(controller.getRowHeaderBorderColor()); for (ActionListener al : listeners) { rowHeaderBorderColorComboBox.addActionListener(al); } } else { setSelectedWithoutDispatchingEvents(rowHeaderBorderColorComboBox, 0); } if (controller.getColumnHeaderBorderColor() != null) { columnHeaderBorderColorComboBox.setSelectedItem(controller.getColumnHeaderBorderColor()); } else { setSelectedWithoutDispatchingEvents(columnHeaderBorderColorComboBox, 0); } if (controller.getRowHeaderBackgroundColor() != null) { listeners = rowBackgroundColorComboBox.getActionListeners(); for (ActionListener al : listeners) { rowBackgroundColorComboBox.removeActionListener(al); } rowBackgroundColorComboBox.setSelectedItem(controller.getRowHeaderBackgroundColor()); for (ActionListener al : listeners) { rowBackgroundColorComboBox.addActionListener(al); } } else { setSelectedWithoutDispatchingEvents(rowBackgroundColorComboBox, 0); } if (controller.getColumnHeaderBackgroundColor() != null) { columnBackgroundColorComboBox.setSelectedItem(controller.getColumnHeaderBackgroundColor()); } else { setSelectedWithoutDispatchingEvents(columnBackgroundColorComboBox, 0); } if (controller.getCellFontColor() != null) { listeners = cellFontColorComboBox.getActionListeners(); for (ActionListener al : listeners) { cellFontColorComboBox.removeActionListener(al); } cellFontColorComboBox.setSelectedItem(controller.getCellFontColor()); for (ActionListener al : listeners) { cellFontColorComboBox.addActionListener(al); } } else { setSelectedWithoutDispatchingEvents(cellFontColorComboBox, 0); } if (controller.getCellBackgroundColor() != null) { listeners = cellBackgroundColorComboBox.getActionListeners(); for (ActionListener al : listeners) { cellBackgroundColorComboBox.removeActionListener(al); } cellBackgroundColorComboBox.setSelectedItem(controller.getCellBackgroundColor()); for (ActionListener al : listeners) { cellBackgroundColorComboBox.addActionListener(al); } } else { setSelectedWithoutDispatchingEvents(cellBackgroundColorComboBox, 0); } listeners = cellFontName.getActionListeners(); for (ActionListener al : listeners) { cellFontName.removeActionListener(al); } if (controller.getCellFontName() != null) { cellFontName.setSelectedItem(controller.getCellFontName()); } else { cellFontName.setSelectedIndex(-1); } for (ActionListener al : listeners) { cellFontName.addActionListener(al); } listeners = dateFormatChooser.getActionListeners(); for (ActionListener al : listeners) { dateFormatChooser.removeActionListener(al); } DateFormatItem dateFormatState = controller.getDateFormat() == null ? DateFormatItem.None : controller.getDateFormat(); dateFormatChooser.setSelectedItem(dateFormatState); for (ActionListener al : listeners) { dateFormatChooser.addActionListener(al); } BorderState borderState = controller.getBorderState(); toggleWithoutAction(cellBorderOnLeft, borderState.hasWestBorder()); toggleWithoutAction(cellBorderOnTop, borderState.hasNorthBorder()); toggleWithoutAction(cellBorderOnRight, borderState.hasEastBorder()); toggleWithoutAction(cellBorderOnBottom, borderState.hasSouthBorder()); BorderState rowHeaderborderState = controller.getRowHeaderBorderState(); if (rowHeaderborderState == null) { rowHeaderborderState = new BorderState(BorderEdge.NONE.value()); } toggleWithoutAction(rowHeaderBorderOnLeft, rowHeaderborderState.hasWestBorder()); toggleWithoutAction(rowHeaderBorderOnTop, rowHeaderborderState.hasNorthBorder()); toggleWithoutAction(rowHeaderBorderOnRight, rowHeaderborderState.hasEastBorder()); toggleWithoutAction(rowHeaderBorderOnBottom, rowHeaderborderState.hasSouthBorder()); BorderState columnHeaderborderState = controller.getColumnHeaderBorderState(); if (columnHeaderborderState == null) { columnHeaderborderState = new BorderState(BorderEdge.NONE.value()); } toggleWithoutAction(columnHeaderBorderOnLeft, columnHeaderborderState.hasWestBorder()); toggleWithoutAction(columnHeaderBorderOnTop, columnHeaderborderState.hasNorthBorder()); toggleWithoutAction(columnHeaderBorderOnRight, columnHeaderborderState.hasEastBorder()); toggleWithoutAction(columnHeaderBorderOnBottom, columnHeaderborderState.hasSouthBorder()); ContentAlignment alignment = controller.getCellAlignment(); selectButtonWithoutAction(cellAlignGroup, alignment); alignment = controller.getRowHeaderAlignment(); selectButtonWithoutAction(rowHeaderAlignGroup, alignment); alignment = controller.getColumnHeaderAlignment(); selectButtonWithoutAction(columnHeaderAlignGroup, alignment); if (controller.getSelectedCellCount() == (controller.getTableColumnCount() * controller.getTableRowCount()) || ((controller.getSelectedCellCount() == 0) && controller.canSetOrientation())) { mgr.enable(TABLE_ORIENTATION, true); } else if (controller.getSelectedCellCount() > 0) { mgr.disable(TABLE_ORIENTATION, true); } mgr.hide(SELECTION_NOT_EMPTY, controller.getSelectedCellCount() == 0); mgr.hide(HEADERS_HIDABLE, !controller.isCanHideHeaders()); mgr.hide(SINGLE_CELL_SELECTION, controller.getSelectedCellCount()!=1); mgr.hide(TABLE_ORIENTATION, !controller.canSetOrientation()); mgr.hide(TRANSPOSE, !controller.canTranspose()); mgr.hide(NOT_FULLY_IMPLEMENTED, true); mgr.enable(DATE_CONTROLS, true); if ((!controller.enumerationIsNone(enumerationModel) )) { mgr.disable(DECIMAL_CONTROLS, true); mgr.disable(DECIMAL_ALIGNMENT_BUTTON, true); mgr.disable(DATE_CONTROLS, true); } else if (!controller.dateIsNone(dateFormatChooser.getModel())) { mgr.disable(DECIMAL_CONTROLS, true); mgr.disable(DECIMAL_ALIGNMENT_BUTTON, true); } else { mgr.enable(DECIMAL_CONTROLS, true); mgr.enable(DECIMAL_ALIGNMENT_BUTTON, true); mgr.enable(DATE_CONTROLS, true); } mgr.hide(DECIMAL_CONTROLS, !controller.showDecimalPlaces()); mgr.hide(DATE_CONTROLS, !controller.showDecimalPlaces()); mgr.hideIfOthersHidden(rowColumnFormattingPanel, rowHeightSpinner, columnWidthSpinner, tableRowOrientation, transposeTableButton, rowHeaderAlignLeft, columnHeaderAlignLeft, showRowHeaders); mgr.tagComponents(COLUMN_IS_NOT_SELECTED, columnHeaderFontName, columnHeaderFontSize, columnHeaderFontStyleBold, columnHeaderFontStyleItalic, columnForegroundColorComboBox); mgr.hide(COLUMN_IS_NOT_SELECTED, controller.getSelectedColumnCount() == 0); mgr.tagComponents(ROW_IS_NOT_SELECTED, rowColumnFontFormattingPanel, rowHeaderFontName, rowHeaderFontSize, rowHeaderFontStyleBold, rowHeaderFontStyleItalic,rowForegroundColorComboBox); mgr.hide(ROW_IS_NOT_SELECTED, controller.getSelectedRowCount() == 0); mgr.hideIfOthersHidden(cellFormattingPanel, propertyToShow, enumeration, numberOfDecimals, dateFormatChooser, cellBorderOnLeft, cellBorderOnTop, cellBorderOnRight, cellBorderOnBottom); } TableSettingsControlPanel(TableSettingsController panelController); }
TableSettingsControlPanel extends JPanel { public void loadSettings() { if (controller.getTableOrientation() == TableOrientation.ROW_MAJOR) { setSelectedWithoutDispatchingEvents(tableRowOrientation, true); } else { setSelectedWithoutDispatchingEvents(tableColOrientation, true); } if ( controller.getRowHeight() > 0) { setValueWithoutDispatchingEvents(rowHeightSpinner, controller.getRowHeight(), rowHeightListener); } setValueWithoutDispatchingEvents(columnWidthSpinner, controller.getColumnWidth(), columnWidthListener); mgr.showAll(); configureAbbreviationSettings( LabelType.ROW, ROW_HEADER_LABEL, rowHeaderFullLabel, rowHeaderAbbreviatedLabel, rowHeaderAbbreviations, controller.getRowLabelAbbreviationSettings() ); configureAbbreviationSettings( LabelType.COLUMN, COLUMN_HEADER_LABEL, columnHeaderFullLabel, columnHeaderAbbreviatedLabel, columnHeaderAbbreviations, controller.getColumnLabelAbbreviationSettings() ); configureAbbreviationSettings( LabelType.CELL, CELL_LABEL, cellFullLabel, cellAbbreviatedLabel, cellAbbreviations, controller.getCellLabelAbbreviationSettings() ); ComboBoxModel enumerationModel = controller.getEnumerationModel(); enumeration.setModel(enumerationModel); if (enumerationModel.getSize() <= 1) { enumeration.setEnabled(false); } else { enumeration.setEnabled(true); } if (controller.selectedCellsHaveMixedEnumerations()) { ActionListener[] listeners = enumeration.getActionListeners(); for (ActionListener al : listeners) { enumeration.removeActionListener(al); } enumeration.setSelectedIndex(-1); for (ActionListener al : listeners) { enumeration.addActionListener(al); } } ActionListener[] listeners = numberOfDecimals.getActionListeners(); for (ActionListener al : listeners) { numberOfDecimals.removeActionListener(al); } int decimals = controller.getDecimalPlaces() == null ? -1 : controller.getDecimalPlaces(); numberOfDecimals.setSelectedIndex(decimals); for (ActionListener al : listeners) { numberOfDecimals.addActionListener(al); } listeners = rowHeaderFontName.getActionListeners(); for (ActionListener al : listeners) { rowHeaderFontName.removeActionListener(al); } if (controller.getRowHeaderFontName() != null) { rowHeaderFontName.setSelectedItem(controller.getRowHeaderFontName()); } else { rowHeaderFontName.setSelectedIndex(-1); } for (ActionListener al : listeners) { rowHeaderFontName.addActionListener(al); } listeners = columnHeaderFontName.getActionListeners(); for (ActionListener al : listeners) { columnHeaderFontName.removeActionListener(al); } if (controller.getRowHeaderFontName() != null) { columnHeaderFontName.setSelectedItem(controller.getColumnHeaderFontName()); } else { columnHeaderFontName.setSelectedIndex(-1); } for (ActionListener al : listeners) { columnHeaderFontName.addActionListener(al); } if (controller.getRowHeaderFontSize() != null) { setValueWithoutDispatchingEvents(rowHeaderFontSize, controller.getRowHeaderFontSize().intValue(), rowHeaderFontSizeListener); } if (controller.getColumnHeaderFontSize() != null) { setValueWithoutDispatchingEvents(columnHeaderFontSize, controller.getColumnHeaderFontSize().intValue(), columnHeaderFontSizeListener); } if (controller.getCellFontSize() != null) { setValueWithoutDispatchingEvents(cellFontSize, controller.getCellFontSize().intValue(), cellFontSizeListener); } if (controller.getRowFontStyle() != null) { if (controller.getRowFontStyle().equals(Font.BOLD)) { rowHeaderFontStyleBold.setSelected(true); rowHeaderFontStyleItalic.setSelected(false); } else if (controller.getRowFontStyle().equals(Font.ITALIC)) { rowHeaderFontStyleItalic.setSelected(true); rowHeaderFontStyleBold.setSelected(false); } else if (controller.getRowFontStyle().equals(Font.BOLD+Font.ITALIC)) { rowHeaderFontStyleBold.setSelected(true); rowHeaderFontStyleItalic.setSelected(true); } else { rowHeaderFontStyleBold.setSelected(false); rowHeaderFontStyleItalic.setSelected(false); } } else { rowHeaderFontStyleBold.setSelected(false); rowHeaderFontStyleItalic.setSelected(false); } if (controller.getCellFontTextAttribute() != null) { if (controller.getCellFontTextAttribute().equals(TextAttribute.UNDERLINE_ON)) { cellFontUnderline.setSelected(true); } else { cellFontUnderline.setSelected(false); } } if (controller.getRowHeaderTextAttribute() != null) { if (controller.getRowHeaderTextAttribute().equals(TextAttribute.UNDERLINE_ON)) { rowHeaderFontUnderline.setSelected(true); } else { rowHeaderFontUnderline.setSelected(false); } } if (controller.getColumnHeaderFontStyle() != null) { if (controller.getColumnHeaderFontStyle().equals(Font.BOLD)) { columnHeaderFontStyleBold.setSelected(true); columnHeaderFontStyleItalic.setSelected(false); } else if (controller.getColumnHeaderFontStyle().equals(Font.ITALIC)) { columnHeaderFontStyleItalic.setSelected(true); columnHeaderFontStyleBold.setSelected(false); } else if (controller.getColumnHeaderFontStyle().equals(Font.BOLD+Font.ITALIC)) { columnHeaderFontStyleBold.setSelected(true); columnHeaderFontStyleItalic.setSelected(true); } else { columnHeaderFontStyleBold.setSelected(false); columnHeaderFontStyleItalic.setSelected(false); } } else { columnHeaderFontStyleBold.setSelected(false); columnHeaderFontStyleItalic.setSelected(false); } if (controller.getColumnHeaderTextAttribute() != null) { if (controller.getColumnHeaderTextAttribute().equals(TextAttribute.UNDERLINE_ON)) { columnHeaderFontStyleUnderline.setSelected(true); } else { columnHeaderFontStyleUnderline.setSelected(false); } } if (controller.getCellFontStyle() != null) { if (controller.getCellFontStyle().equals(Font.BOLD)) { cellFontStyleBold.setSelected(true); cellFontStyleItalic.setSelected(false); } else if (controller.getCellFontStyle().equals(Font.ITALIC)) { cellFontStyleItalic.setSelected(true); cellFontStyleBold.setSelected(false); } else if (controller.getCellFontStyle().equals(Font.BOLD+Font.ITALIC)) { cellFontStyleBold.setSelected(true); cellFontStyleItalic.setSelected(true); } else { cellFontStyleBold.setSelected(false); cellFontStyleItalic.setSelected(false); } } else { cellFontStyleBold.setSelected(false); cellFontStyleItalic.setSelected(false); } if (controller.getRowHeaderFontColor() != null) { listeners = rowForegroundColorComboBox.getActionListeners(); for (ActionListener al : listeners) { rowForegroundColorComboBox.removeActionListener(al); } rowForegroundColorComboBox.setSelectedItem(controller.getRowHeaderFontColor()); for (ActionListener al : listeners) { rowForegroundColorComboBox.addActionListener(al); } } else { setSelectedWithoutDispatchingEvents(rowForegroundColorComboBox, 0); } if (controller.getColumnHeaderFontColor() != null) { listeners = columnForegroundColorComboBox.getActionListeners(); for (ActionListener al : listeners) { columnForegroundColorComboBox.removeActionListener(al); } columnForegroundColorComboBox.setSelectedItem(controller.getColumnHeaderFontColor()); for (ActionListener al : listeners) { columnForegroundColorComboBox.addActionListener(al); } } else { setSelectedWithoutDispatchingEvents(columnForegroundColorComboBox, 0); } if (controller.getRowHeaderBorderColor() != null) { listeners = rowHeaderBorderColorComboBox.getActionListeners(); for (ActionListener al : listeners) { rowHeaderBorderColorComboBox.removeActionListener(al); } rowHeaderBorderColorComboBox.setSelectedItem(controller.getRowHeaderBorderColor()); for (ActionListener al : listeners) { rowHeaderBorderColorComboBox.addActionListener(al); } } else { setSelectedWithoutDispatchingEvents(rowHeaderBorderColorComboBox, 0); } if (controller.getColumnHeaderBorderColor() != null) { columnHeaderBorderColorComboBox.setSelectedItem(controller.getColumnHeaderBorderColor()); } else { setSelectedWithoutDispatchingEvents(columnHeaderBorderColorComboBox, 0); } if (controller.getRowHeaderBackgroundColor() != null) { listeners = rowBackgroundColorComboBox.getActionListeners(); for (ActionListener al : listeners) { rowBackgroundColorComboBox.removeActionListener(al); } rowBackgroundColorComboBox.setSelectedItem(controller.getRowHeaderBackgroundColor()); for (ActionListener al : listeners) { rowBackgroundColorComboBox.addActionListener(al); } } else { setSelectedWithoutDispatchingEvents(rowBackgroundColorComboBox, 0); } if (controller.getColumnHeaderBackgroundColor() != null) { columnBackgroundColorComboBox.setSelectedItem(controller.getColumnHeaderBackgroundColor()); } else { setSelectedWithoutDispatchingEvents(columnBackgroundColorComboBox, 0); } if (controller.getCellFontColor() != null) { listeners = cellFontColorComboBox.getActionListeners(); for (ActionListener al : listeners) { cellFontColorComboBox.removeActionListener(al); } cellFontColorComboBox.setSelectedItem(controller.getCellFontColor()); for (ActionListener al : listeners) { cellFontColorComboBox.addActionListener(al); } } else { setSelectedWithoutDispatchingEvents(cellFontColorComboBox, 0); } if (controller.getCellBackgroundColor() != null) { listeners = cellBackgroundColorComboBox.getActionListeners(); for (ActionListener al : listeners) { cellBackgroundColorComboBox.removeActionListener(al); } cellBackgroundColorComboBox.setSelectedItem(controller.getCellBackgroundColor()); for (ActionListener al : listeners) { cellBackgroundColorComboBox.addActionListener(al); } } else { setSelectedWithoutDispatchingEvents(cellBackgroundColorComboBox, 0); } listeners = cellFontName.getActionListeners(); for (ActionListener al : listeners) { cellFontName.removeActionListener(al); } if (controller.getCellFontName() != null) { cellFontName.setSelectedItem(controller.getCellFontName()); } else { cellFontName.setSelectedIndex(-1); } for (ActionListener al : listeners) { cellFontName.addActionListener(al); } listeners = dateFormatChooser.getActionListeners(); for (ActionListener al : listeners) { dateFormatChooser.removeActionListener(al); } DateFormatItem dateFormatState = controller.getDateFormat() == null ? DateFormatItem.None : controller.getDateFormat(); dateFormatChooser.setSelectedItem(dateFormatState); for (ActionListener al : listeners) { dateFormatChooser.addActionListener(al); } BorderState borderState = controller.getBorderState(); toggleWithoutAction(cellBorderOnLeft, borderState.hasWestBorder()); toggleWithoutAction(cellBorderOnTop, borderState.hasNorthBorder()); toggleWithoutAction(cellBorderOnRight, borderState.hasEastBorder()); toggleWithoutAction(cellBorderOnBottom, borderState.hasSouthBorder()); BorderState rowHeaderborderState = controller.getRowHeaderBorderState(); if (rowHeaderborderState == null) { rowHeaderborderState = new BorderState(BorderEdge.NONE.value()); } toggleWithoutAction(rowHeaderBorderOnLeft, rowHeaderborderState.hasWestBorder()); toggleWithoutAction(rowHeaderBorderOnTop, rowHeaderborderState.hasNorthBorder()); toggleWithoutAction(rowHeaderBorderOnRight, rowHeaderborderState.hasEastBorder()); toggleWithoutAction(rowHeaderBorderOnBottom, rowHeaderborderState.hasSouthBorder()); BorderState columnHeaderborderState = controller.getColumnHeaderBorderState(); if (columnHeaderborderState == null) { columnHeaderborderState = new BorderState(BorderEdge.NONE.value()); } toggleWithoutAction(columnHeaderBorderOnLeft, columnHeaderborderState.hasWestBorder()); toggleWithoutAction(columnHeaderBorderOnTop, columnHeaderborderState.hasNorthBorder()); toggleWithoutAction(columnHeaderBorderOnRight, columnHeaderborderState.hasEastBorder()); toggleWithoutAction(columnHeaderBorderOnBottom, columnHeaderborderState.hasSouthBorder()); ContentAlignment alignment = controller.getCellAlignment(); selectButtonWithoutAction(cellAlignGroup, alignment); alignment = controller.getRowHeaderAlignment(); selectButtonWithoutAction(rowHeaderAlignGroup, alignment); alignment = controller.getColumnHeaderAlignment(); selectButtonWithoutAction(columnHeaderAlignGroup, alignment); if (controller.getSelectedCellCount() == (controller.getTableColumnCount() * controller.getTableRowCount()) || ((controller.getSelectedCellCount() == 0) && controller.canSetOrientation())) { mgr.enable(TABLE_ORIENTATION, true); } else if (controller.getSelectedCellCount() > 0) { mgr.disable(TABLE_ORIENTATION, true); } mgr.hide(SELECTION_NOT_EMPTY, controller.getSelectedCellCount() == 0); mgr.hide(HEADERS_HIDABLE, !controller.isCanHideHeaders()); mgr.hide(SINGLE_CELL_SELECTION, controller.getSelectedCellCount()!=1); mgr.hide(TABLE_ORIENTATION, !controller.canSetOrientation()); mgr.hide(TRANSPOSE, !controller.canTranspose()); mgr.hide(NOT_FULLY_IMPLEMENTED, true); mgr.enable(DATE_CONTROLS, true); if ((!controller.enumerationIsNone(enumerationModel) )) { mgr.disable(DECIMAL_CONTROLS, true); mgr.disable(DECIMAL_ALIGNMENT_BUTTON, true); mgr.disable(DATE_CONTROLS, true); } else if (!controller.dateIsNone(dateFormatChooser.getModel())) { mgr.disable(DECIMAL_CONTROLS, true); mgr.disable(DECIMAL_ALIGNMENT_BUTTON, true); } else { mgr.enable(DECIMAL_CONTROLS, true); mgr.enable(DECIMAL_ALIGNMENT_BUTTON, true); mgr.enable(DATE_CONTROLS, true); } mgr.hide(DECIMAL_CONTROLS, !controller.showDecimalPlaces()); mgr.hide(DATE_CONTROLS, !controller.showDecimalPlaces()); mgr.hideIfOthersHidden(rowColumnFormattingPanel, rowHeightSpinner, columnWidthSpinner, tableRowOrientation, transposeTableButton, rowHeaderAlignLeft, columnHeaderAlignLeft, showRowHeaders); mgr.tagComponents(COLUMN_IS_NOT_SELECTED, columnHeaderFontName, columnHeaderFontSize, columnHeaderFontStyleBold, columnHeaderFontStyleItalic, columnForegroundColorComboBox); mgr.hide(COLUMN_IS_NOT_SELECTED, controller.getSelectedColumnCount() == 0); mgr.tagComponents(ROW_IS_NOT_SELECTED, rowColumnFontFormattingPanel, rowHeaderFontName, rowHeaderFontSize, rowHeaderFontStyleBold, rowHeaderFontStyleItalic,rowForegroundColorComboBox); mgr.hide(ROW_IS_NOT_SELECTED, controller.getSelectedRowCount() == 0); mgr.hideIfOthersHidden(cellFormattingPanel, propertyToShow, enumeration, numberOfDecimals, dateFormatChooser, cellBorderOnLeft, cellBorderOnTop, cellBorderOnRight, cellBorderOnBottom); } TableSettingsControlPanel(TableSettingsController panelController); void loadSettings(); }
TableSettingsControlPanel extends JPanel { public void loadSettings() { if (controller.getTableOrientation() == TableOrientation.ROW_MAJOR) { setSelectedWithoutDispatchingEvents(tableRowOrientation, true); } else { setSelectedWithoutDispatchingEvents(tableColOrientation, true); } if ( controller.getRowHeight() > 0) { setValueWithoutDispatchingEvents(rowHeightSpinner, controller.getRowHeight(), rowHeightListener); } setValueWithoutDispatchingEvents(columnWidthSpinner, controller.getColumnWidth(), columnWidthListener); mgr.showAll(); configureAbbreviationSettings( LabelType.ROW, ROW_HEADER_LABEL, rowHeaderFullLabel, rowHeaderAbbreviatedLabel, rowHeaderAbbreviations, controller.getRowLabelAbbreviationSettings() ); configureAbbreviationSettings( LabelType.COLUMN, COLUMN_HEADER_LABEL, columnHeaderFullLabel, columnHeaderAbbreviatedLabel, columnHeaderAbbreviations, controller.getColumnLabelAbbreviationSettings() ); configureAbbreviationSettings( LabelType.CELL, CELL_LABEL, cellFullLabel, cellAbbreviatedLabel, cellAbbreviations, controller.getCellLabelAbbreviationSettings() ); ComboBoxModel enumerationModel = controller.getEnumerationModel(); enumeration.setModel(enumerationModel); if (enumerationModel.getSize() <= 1) { enumeration.setEnabled(false); } else { enumeration.setEnabled(true); } if (controller.selectedCellsHaveMixedEnumerations()) { ActionListener[] listeners = enumeration.getActionListeners(); for (ActionListener al : listeners) { enumeration.removeActionListener(al); } enumeration.setSelectedIndex(-1); for (ActionListener al : listeners) { enumeration.addActionListener(al); } } ActionListener[] listeners = numberOfDecimals.getActionListeners(); for (ActionListener al : listeners) { numberOfDecimals.removeActionListener(al); } int decimals = controller.getDecimalPlaces() == null ? -1 : controller.getDecimalPlaces(); numberOfDecimals.setSelectedIndex(decimals); for (ActionListener al : listeners) { numberOfDecimals.addActionListener(al); } listeners = rowHeaderFontName.getActionListeners(); for (ActionListener al : listeners) { rowHeaderFontName.removeActionListener(al); } if (controller.getRowHeaderFontName() != null) { rowHeaderFontName.setSelectedItem(controller.getRowHeaderFontName()); } else { rowHeaderFontName.setSelectedIndex(-1); } for (ActionListener al : listeners) { rowHeaderFontName.addActionListener(al); } listeners = columnHeaderFontName.getActionListeners(); for (ActionListener al : listeners) { columnHeaderFontName.removeActionListener(al); } if (controller.getRowHeaderFontName() != null) { columnHeaderFontName.setSelectedItem(controller.getColumnHeaderFontName()); } else { columnHeaderFontName.setSelectedIndex(-1); } for (ActionListener al : listeners) { columnHeaderFontName.addActionListener(al); } if (controller.getRowHeaderFontSize() != null) { setValueWithoutDispatchingEvents(rowHeaderFontSize, controller.getRowHeaderFontSize().intValue(), rowHeaderFontSizeListener); } if (controller.getColumnHeaderFontSize() != null) { setValueWithoutDispatchingEvents(columnHeaderFontSize, controller.getColumnHeaderFontSize().intValue(), columnHeaderFontSizeListener); } if (controller.getCellFontSize() != null) { setValueWithoutDispatchingEvents(cellFontSize, controller.getCellFontSize().intValue(), cellFontSizeListener); } if (controller.getRowFontStyle() != null) { if (controller.getRowFontStyle().equals(Font.BOLD)) { rowHeaderFontStyleBold.setSelected(true); rowHeaderFontStyleItalic.setSelected(false); } else if (controller.getRowFontStyle().equals(Font.ITALIC)) { rowHeaderFontStyleItalic.setSelected(true); rowHeaderFontStyleBold.setSelected(false); } else if (controller.getRowFontStyle().equals(Font.BOLD+Font.ITALIC)) { rowHeaderFontStyleBold.setSelected(true); rowHeaderFontStyleItalic.setSelected(true); } else { rowHeaderFontStyleBold.setSelected(false); rowHeaderFontStyleItalic.setSelected(false); } } else { rowHeaderFontStyleBold.setSelected(false); rowHeaderFontStyleItalic.setSelected(false); } if (controller.getCellFontTextAttribute() != null) { if (controller.getCellFontTextAttribute().equals(TextAttribute.UNDERLINE_ON)) { cellFontUnderline.setSelected(true); } else { cellFontUnderline.setSelected(false); } } if (controller.getRowHeaderTextAttribute() != null) { if (controller.getRowHeaderTextAttribute().equals(TextAttribute.UNDERLINE_ON)) { rowHeaderFontUnderline.setSelected(true); } else { rowHeaderFontUnderline.setSelected(false); } } if (controller.getColumnHeaderFontStyle() != null) { if (controller.getColumnHeaderFontStyle().equals(Font.BOLD)) { columnHeaderFontStyleBold.setSelected(true); columnHeaderFontStyleItalic.setSelected(false); } else if (controller.getColumnHeaderFontStyle().equals(Font.ITALIC)) { columnHeaderFontStyleItalic.setSelected(true); columnHeaderFontStyleBold.setSelected(false); } else if (controller.getColumnHeaderFontStyle().equals(Font.BOLD+Font.ITALIC)) { columnHeaderFontStyleBold.setSelected(true); columnHeaderFontStyleItalic.setSelected(true); } else { columnHeaderFontStyleBold.setSelected(false); columnHeaderFontStyleItalic.setSelected(false); } } else { columnHeaderFontStyleBold.setSelected(false); columnHeaderFontStyleItalic.setSelected(false); } if (controller.getColumnHeaderTextAttribute() != null) { if (controller.getColumnHeaderTextAttribute().equals(TextAttribute.UNDERLINE_ON)) { columnHeaderFontStyleUnderline.setSelected(true); } else { columnHeaderFontStyleUnderline.setSelected(false); } } if (controller.getCellFontStyle() != null) { if (controller.getCellFontStyle().equals(Font.BOLD)) { cellFontStyleBold.setSelected(true); cellFontStyleItalic.setSelected(false); } else if (controller.getCellFontStyle().equals(Font.ITALIC)) { cellFontStyleItalic.setSelected(true); cellFontStyleBold.setSelected(false); } else if (controller.getCellFontStyle().equals(Font.BOLD+Font.ITALIC)) { cellFontStyleBold.setSelected(true); cellFontStyleItalic.setSelected(true); } else { cellFontStyleBold.setSelected(false); cellFontStyleItalic.setSelected(false); } } else { cellFontStyleBold.setSelected(false); cellFontStyleItalic.setSelected(false); } if (controller.getRowHeaderFontColor() != null) { listeners = rowForegroundColorComboBox.getActionListeners(); for (ActionListener al : listeners) { rowForegroundColorComboBox.removeActionListener(al); } rowForegroundColorComboBox.setSelectedItem(controller.getRowHeaderFontColor()); for (ActionListener al : listeners) { rowForegroundColorComboBox.addActionListener(al); } } else { setSelectedWithoutDispatchingEvents(rowForegroundColorComboBox, 0); } if (controller.getColumnHeaderFontColor() != null) { listeners = columnForegroundColorComboBox.getActionListeners(); for (ActionListener al : listeners) { columnForegroundColorComboBox.removeActionListener(al); } columnForegroundColorComboBox.setSelectedItem(controller.getColumnHeaderFontColor()); for (ActionListener al : listeners) { columnForegroundColorComboBox.addActionListener(al); } } else { setSelectedWithoutDispatchingEvents(columnForegroundColorComboBox, 0); } if (controller.getRowHeaderBorderColor() != null) { listeners = rowHeaderBorderColorComboBox.getActionListeners(); for (ActionListener al : listeners) { rowHeaderBorderColorComboBox.removeActionListener(al); } rowHeaderBorderColorComboBox.setSelectedItem(controller.getRowHeaderBorderColor()); for (ActionListener al : listeners) { rowHeaderBorderColorComboBox.addActionListener(al); } } else { setSelectedWithoutDispatchingEvents(rowHeaderBorderColorComboBox, 0); } if (controller.getColumnHeaderBorderColor() != null) { columnHeaderBorderColorComboBox.setSelectedItem(controller.getColumnHeaderBorderColor()); } else { setSelectedWithoutDispatchingEvents(columnHeaderBorderColorComboBox, 0); } if (controller.getRowHeaderBackgroundColor() != null) { listeners = rowBackgroundColorComboBox.getActionListeners(); for (ActionListener al : listeners) { rowBackgroundColorComboBox.removeActionListener(al); } rowBackgroundColorComboBox.setSelectedItem(controller.getRowHeaderBackgroundColor()); for (ActionListener al : listeners) { rowBackgroundColorComboBox.addActionListener(al); } } else { setSelectedWithoutDispatchingEvents(rowBackgroundColorComboBox, 0); } if (controller.getColumnHeaderBackgroundColor() != null) { columnBackgroundColorComboBox.setSelectedItem(controller.getColumnHeaderBackgroundColor()); } else { setSelectedWithoutDispatchingEvents(columnBackgroundColorComboBox, 0); } if (controller.getCellFontColor() != null) { listeners = cellFontColorComboBox.getActionListeners(); for (ActionListener al : listeners) { cellFontColorComboBox.removeActionListener(al); } cellFontColorComboBox.setSelectedItem(controller.getCellFontColor()); for (ActionListener al : listeners) { cellFontColorComboBox.addActionListener(al); } } else { setSelectedWithoutDispatchingEvents(cellFontColorComboBox, 0); } if (controller.getCellBackgroundColor() != null) { listeners = cellBackgroundColorComboBox.getActionListeners(); for (ActionListener al : listeners) { cellBackgroundColorComboBox.removeActionListener(al); } cellBackgroundColorComboBox.setSelectedItem(controller.getCellBackgroundColor()); for (ActionListener al : listeners) { cellBackgroundColorComboBox.addActionListener(al); } } else { setSelectedWithoutDispatchingEvents(cellBackgroundColorComboBox, 0); } listeners = cellFontName.getActionListeners(); for (ActionListener al : listeners) { cellFontName.removeActionListener(al); } if (controller.getCellFontName() != null) { cellFontName.setSelectedItem(controller.getCellFontName()); } else { cellFontName.setSelectedIndex(-1); } for (ActionListener al : listeners) { cellFontName.addActionListener(al); } listeners = dateFormatChooser.getActionListeners(); for (ActionListener al : listeners) { dateFormatChooser.removeActionListener(al); } DateFormatItem dateFormatState = controller.getDateFormat() == null ? DateFormatItem.None : controller.getDateFormat(); dateFormatChooser.setSelectedItem(dateFormatState); for (ActionListener al : listeners) { dateFormatChooser.addActionListener(al); } BorderState borderState = controller.getBorderState(); toggleWithoutAction(cellBorderOnLeft, borderState.hasWestBorder()); toggleWithoutAction(cellBorderOnTop, borderState.hasNorthBorder()); toggleWithoutAction(cellBorderOnRight, borderState.hasEastBorder()); toggleWithoutAction(cellBorderOnBottom, borderState.hasSouthBorder()); BorderState rowHeaderborderState = controller.getRowHeaderBorderState(); if (rowHeaderborderState == null) { rowHeaderborderState = new BorderState(BorderEdge.NONE.value()); } toggleWithoutAction(rowHeaderBorderOnLeft, rowHeaderborderState.hasWestBorder()); toggleWithoutAction(rowHeaderBorderOnTop, rowHeaderborderState.hasNorthBorder()); toggleWithoutAction(rowHeaderBorderOnRight, rowHeaderborderState.hasEastBorder()); toggleWithoutAction(rowHeaderBorderOnBottom, rowHeaderborderState.hasSouthBorder()); BorderState columnHeaderborderState = controller.getColumnHeaderBorderState(); if (columnHeaderborderState == null) { columnHeaderborderState = new BorderState(BorderEdge.NONE.value()); } toggleWithoutAction(columnHeaderBorderOnLeft, columnHeaderborderState.hasWestBorder()); toggleWithoutAction(columnHeaderBorderOnTop, columnHeaderborderState.hasNorthBorder()); toggleWithoutAction(columnHeaderBorderOnRight, columnHeaderborderState.hasEastBorder()); toggleWithoutAction(columnHeaderBorderOnBottom, columnHeaderborderState.hasSouthBorder()); ContentAlignment alignment = controller.getCellAlignment(); selectButtonWithoutAction(cellAlignGroup, alignment); alignment = controller.getRowHeaderAlignment(); selectButtonWithoutAction(rowHeaderAlignGroup, alignment); alignment = controller.getColumnHeaderAlignment(); selectButtonWithoutAction(columnHeaderAlignGroup, alignment); if (controller.getSelectedCellCount() == (controller.getTableColumnCount() * controller.getTableRowCount()) || ((controller.getSelectedCellCount() == 0) && controller.canSetOrientation())) { mgr.enable(TABLE_ORIENTATION, true); } else if (controller.getSelectedCellCount() > 0) { mgr.disable(TABLE_ORIENTATION, true); } mgr.hide(SELECTION_NOT_EMPTY, controller.getSelectedCellCount() == 0); mgr.hide(HEADERS_HIDABLE, !controller.isCanHideHeaders()); mgr.hide(SINGLE_CELL_SELECTION, controller.getSelectedCellCount()!=1); mgr.hide(TABLE_ORIENTATION, !controller.canSetOrientation()); mgr.hide(TRANSPOSE, !controller.canTranspose()); mgr.hide(NOT_FULLY_IMPLEMENTED, true); mgr.enable(DATE_CONTROLS, true); if ((!controller.enumerationIsNone(enumerationModel) )) { mgr.disable(DECIMAL_CONTROLS, true); mgr.disable(DECIMAL_ALIGNMENT_BUTTON, true); mgr.disable(DATE_CONTROLS, true); } else if (!controller.dateIsNone(dateFormatChooser.getModel())) { mgr.disable(DECIMAL_CONTROLS, true); mgr.disable(DECIMAL_ALIGNMENT_BUTTON, true); } else { mgr.enable(DECIMAL_CONTROLS, true); mgr.enable(DECIMAL_ALIGNMENT_BUTTON, true); mgr.enable(DATE_CONTROLS, true); } mgr.hide(DECIMAL_CONTROLS, !controller.showDecimalPlaces()); mgr.hide(DATE_CONTROLS, !controller.showDecimalPlaces()); mgr.hideIfOthersHidden(rowColumnFormattingPanel, rowHeightSpinner, columnWidthSpinner, tableRowOrientation, transposeTableButton, rowHeaderAlignLeft, columnHeaderAlignLeft, showRowHeaders); mgr.tagComponents(COLUMN_IS_NOT_SELECTED, columnHeaderFontName, columnHeaderFontSize, columnHeaderFontStyleBold, columnHeaderFontStyleItalic, columnForegroundColorComboBox); mgr.hide(COLUMN_IS_NOT_SELECTED, controller.getSelectedColumnCount() == 0); mgr.tagComponents(ROW_IS_NOT_SELECTED, rowColumnFontFormattingPanel, rowHeaderFontName, rowHeaderFontSize, rowHeaderFontStyleBold, rowHeaderFontStyleItalic,rowForegroundColorComboBox); mgr.hide(ROW_IS_NOT_SELECTED, controller.getSelectedRowCount() == 0); mgr.hideIfOthersHidden(cellFormattingPanel, propertyToShow, enumeration, numberOfDecimals, dateFormatChooser, cellBorderOnLeft, cellBorderOnTop, cellBorderOnRight, cellBorderOnBottom); } TableSettingsControlPanel(TableSettingsController panelController); void loadSettings();  }