private void addSelectionListeneronToFontButton(Button fontButton, TableEditor fontEditor) { fontButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { String fontdata = ""; dialog = new FontDialog(Display.getCurrent().getActiveShell(), SWT.NONE); dialog.setText("Select Font"); String string = formatMap.get(excelFormats[4]); fontdata = checkDefaultValue(fontEditor, fontdata, string); RGB checkDefaultColor = checkDefaultColor(fontdata, string); dialog.setRGB(checkDefaultColor); FontData defaultFont = new FontData(fontdata); dialog.setFontData(defaultFont); FontData newFont = dialog.open(); RGB rgb = dialog.getRGB(); String convertRGBToHEX = convertRGBToHEX(rgb); if (newFont != null) { fontEditor.getItem().setText(1, newFont.toString() + "|" + convertRGBToHEX); } } }); }
private void addSelectionListeneronButton(Button button, TableEditor editor) { button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { ColorDialog dlg = new ColorDialog(Display.getCurrent().getActiveShell()); dlg.setRGB(new RGB(0, 0, 0)); RGB rgb = dlg.open(); if (rgb != null) { Color color = new Color(shell.getDisplay(), rgb); String colorValue = convertRGBToHEX(rgb); editor.getItem().setText(1, colorValue); color.dispose(); } } }); }
private Text addTextBoxInTable(TableViewer tableViewer, TableItem tableItem, String textBoxName, String valueTextPane, String editorName, int columnIndex, Listener listener) { final Composite buttonPane = new Composite(tableViewer.getTable(), SWT.NONE); buttonPane.setLayout(new FillLayout()); final Text text = new Text(buttonPane, SWT.NONE); text.addListener(SWT.Modify, listener); text.setData(FilterConstants.ROW_INDEX, tableViewer.getTable().indexOf(tableItem)); tableItem.setData(textBoxName, text); tableItem.setData(valueTextPane, buttonPane); //text.addModifyListener(FilterHelper.INSTANCE.getTextModifyListener()); final TableEditor editor = new TableEditor(tableViewer.getTable()); editor.grabHorizontal = true; editor.grabVertical = true; editor.setEditor(buttonPane, tableItem, columnIndex); editor.layout(); text.setData(editorName, editor); return text; }
private CCombo addComboInTable(TableViewer tableViewer, TableItem tableItem, String comboName, String comboPaneName, String editorName, int columnIndex, String[] relationalOperators, SelectionListener dropDownSelectionListener, ModifyListener modifyListener,FocusListener focusListener) { final Composite buttonPane = new Composite(tableViewer.getTable(), SWT.NONE); buttonPane.setLayout(new FillLayout()); final CCombo combo = new CCombo(buttonPane, SWT.NONE); combo.setItems(relationalOperators); combo.setData(FilterConstants.ROW_INDEX, tableViewer.getTable().indexOf(tableItem)); tableItem.setData(comboName, combo); tableItem.setData(comboPaneName, buttonPane); combo.addSelectionListener(dropDownSelectionListener); combo.addModifyListener(modifyListener); combo.addFocusListener(focusListener); new AutoCompleteField(combo, new CComboContentAdapter(), combo.getItems()); final TableEditor editor = new TableEditor(tableViewer.getTable()); editor.grabHorizontal = true; editor.grabVertical = true; editor.setEditor(buttonPane, tableItem, columnIndex); editor.layout(); combo.setData(editorName, editor); return combo; }
private void addButtonInTable(TableViewer tableViewer, TableItem tableItem, String columnName, String buttonPaneName, String editorName, int columnIndex, SelectionListener buttonSelectionListener, ImagePathConstant imagePath) { final Composite buttonPane = new Composite(tableViewer.getTable(), SWT.NONE); buttonPane.setLayout(new FillLayout()); final Button button = new Button(buttonPane, SWT.NONE); //button.setText(columnName); button.setData(FilterConstants.ROW_INDEX, tableViewer.getTable().indexOf(tableItem)); tableItem.setData(columnName, button); tableItem.setData(buttonPaneName, buttonPane); button.addSelectionListener(buttonSelectionListener); button.setImage(imagePath.getImageFromRegistry()); final TableEditor editor = new TableEditor(tableViewer.getTable()); editor.grabHorizontal = true; editor.grabVertical = true; editor.setEditor(buttonPane, tableItem, columnIndex); editor.layout(); button.setData(editorName, editor); }
private void addCheckButtonInTable(TableViewer tableViewer, TableItem tableItem, String columnName, String groupPaneName, String editorName, int columnIndex, SelectionListener buttonSelectionListener) { final Composite buttonPane = new Composite(tableViewer.getTable(), SWT.NONE); buttonPane.setLayout(new FillLayout()); final Button button = new Button(buttonPane, SWT.CHECK); button.setData(FilterConstants.ROW_INDEX, tableViewer.getTable().indexOf(tableItem)); if(null != buttonSelectionListener){ button.addSelectionListener(buttonSelectionListener); } tableItem.setData(columnName, button); tableItem.setData(groupPaneName, buttonPane); final TableEditor editor = new TableEditor(tableViewer.getTable()); editor.grabHorizontal = true; editor.grabVertical = true; editor.setEditor(buttonPane, tableItem, columnIndex); editor.layout(); button.setData(editorName, editor); }
/** * {@inheritDoc} */ @Override protected void perfomeOK() { final int index = columnCombo.getSelectionIndex(); if (index < columnComboInfo.complexUniqueKeyStartIndex) { referenceForPK = true; } else if (index < columnComboInfo.columnStartIndex) { final ComplexUniqueKey complexUniqueKey = source.getComplexUniqueKeyList().get(index - columnComboInfo.complexUniqueKeyStartIndex); referencedComplexUniqueKey = complexUniqueKey; } else { referencedColumn = columnComboInfo.candidateColumns.get(index - columnComboInfo.columnStartIndex); } for (final TableEditor tableEditor : tableEditorList) { final NormalColumn foreignKeyColumn = getSelectedColumn(tableEditor); foreignKeyColumnList.add(foreignKeyColumn); } }
private NormalColumn getSelectedColumn(final TableEditor tableEditor) { final Combo foreignKeyCombo = (Combo) tableEditor.getEditor(); final int foreignKeyComboIndex = foreignKeyCombo.getSelectionIndex(); int startIndex = 1; NormalColumn foreignKeyColumn = null; final List<NormalColumn> foreignKeyList = editorReferencedMap.get(tableEditor); if (foreignKeyList != null) { if (foreignKeyComboIndex <= foreignKeyList.size()) { foreignKeyColumn = foreignKeyList.get(foreignKeyComboIndex - startIndex); } else { startIndex += foreignKeyList.size(); } } if (foreignKeyColumn == null) { foreignKeyColumn = candidateForeignKeyColumns.get(foreignKeyComboIndex - startIndex); } return foreignKeyColumn; }
@Override protected String getErrorMessage() { final Set<NormalColumn> selectedColumns = new HashSet<NormalColumn>(); for (final TableEditor tableEditor : tableEditorList) { final Combo foreignKeyCombo = (Combo) tableEditor.getEditor(); final int index = foreignKeyCombo.getSelectionIndex(); if (index == 0) { return "error.foreign.key.not.selected"; } final NormalColumn selectedColumn = getSelectedColumn(tableEditor); if (selectedColumns.contains(selectedColumn)) { return "error.foreign.key.must.be.different"; } selectedColumns.add(selectedColumn); } if (existForeignKeySet(selectedColumns)) { return "error.foreign.key.already.exist"; } return null; }
private void edit(final TableItem item, final TableEditor tableEditor) { final Text text = new Text(table, SWT.NONE); text.setText(item.getText(targetColumn)); text.addFocusListener(new FocusAdapter() { @Override public void focusLost(final FocusEvent e) { item.setText(targetColumn, text.getText()); text.dispose(); } }); tableEditor.setEditor(text, item, targetColumn); text.setFocus(); text.selectAll(); }
@Override public void restruct() { columnTable.removeAll(); disposeTableEditor(); for (final NormalColumn normalColumn : copyData.getNormalColumns()) { final TableItem tableItem = new TableItem(columnTable, SWT.NONE); final TableEditor tableEditor = CompositeFactory.createCheckBoxTableEditor(tableItem, false, 0); tableEditorList.add(tableEditor); editorColumnMap.put(tableEditor, normalColumn); tableItem.setText(1, Format.null2blank(normalColumn.getName())); } setComboData(); setButtonStatus(false); nameText.setText(""); columnTable.getColumns()[1].pack(); }
private void setTableEditor(final NormalColumn normalColumn, final TableItem tableItem, final Boolean desc) { final Button descCheckButton = new Button(indexColumnList, SWT.CHECK); descCheckButton.pack(); if (DBManagerFactory.getDBManager(table.getDiagram()).isSupported(DBManager.SUPPORT_DESC_INDEX)) { final TableEditor editor = new TableEditor(indexColumnList); editor.minimumWidth = descCheckButton.getSize().x; editor.horizontalAlignment = SWT.CENTER; editor.setEditor(descCheckButton, tableItem, 1); columnCheckMap.put(normalColumn, editor); } descCheckBoxMap.put(normalColumn, descCheckButton); descCheckButton.setSelection(desc.booleanValue()); }
private void initNodeTable() { nodeTable.removeAll(); nodeCheckMap = new HashMap<NodeElement, TableEditor>(); for (final NodeElement nodeElement : diagram.getDiagramContents().getContents()) { final TableItem tableItem = new TableItem(nodeTable, SWT.NONE); final Button selectCheckButton = new Button(nodeTable, SWT.CHECK); selectCheckButton.pack(); final TableEditor editor = new TableEditor(nodeTable); editor.minimumWidth = selectCheckButton.getSize().x; editor.horizontalAlignment = SWT.CENTER; editor.setEditor(selectCheckButton, tableItem, 0); tableItem.setText(1, ResourceString.getResourceString("label.object.type." + nodeElement.getObjectType())); tableItem.setText(2, Format.null2blank(nodeElement.getName())); nodeCheckMap.put(nodeElement, editor); } }
public static TableEditor createCheckBoxTableEditor(TableItem tableItem, boolean selection, int column) { Table table = tableItem.getParent(); final Button checkBox = new Button(table, SWT.CHECK); checkBox.pack(); TableEditor editor = new TableEditor(table); editor.minimumWidth = checkBox.getSize().x; editor.horizontalAlignment = SWT.CENTER; editor.setEditor(checkBox, tableItem, column); checkBox.setSelection(selection); return editor; }
public RelationByExistingColumnsDialog(Shell parentShell, ERTable source, List<NormalColumn> candidateForeignKeyColumns, Map<NormalColumn, List<NormalColumn>> referencedMap, Map<Relation, Set<NormalColumn>> foreignKeySetMap) { super(parentShell); this.source = source; this.referencedColumnList = new ArrayList<NormalColumn>(); this.foreignKeyColumnList = new ArrayList<NormalColumn>(); this.candidateForeignKeyColumns = candidateForeignKeyColumns; this.referencedMap = referencedMap; this.foreignKeySetMap = foreignKeySetMap; this.tableEditorList = new ArrayList<TableEditor>(); this.editorReferencedMap = new HashMap<TableEditor, List<NormalColumn>>(); }
/** * {@inheritDoc} */ @Override protected void perfomeOK() { int index = this.columnCombo.getSelectionIndex(); if (index < this.columnComboInfo.complexUniqueKeyStartIndex) { this.referenceForPK = true; } else if (index < this.columnComboInfo.columnStartIndex) { ComplexUniqueKey complexUniqueKey = this.source .getComplexUniqueKeyList() .get(index - this.columnComboInfo.complexUniqueKeyStartIndex); this.referencedComplexUniqueKey = complexUniqueKey; } else { this.referencedColumn = this.columnComboInfo.candidateColumns .get(index - this.columnComboInfo.columnStartIndex); } for (TableEditor tableEditor : this.tableEditorList) { NormalColumn foreignKeyColumn = this.getSelectedColumn(tableEditor); this.foreignKeyColumnList.add(foreignKeyColumn); } }
private NormalColumn getSelectedColumn(TableEditor tableEditor) { Combo foreignKeyCombo = (Combo) tableEditor.getEditor(); int foreignKeyComboIndex = foreignKeyCombo.getSelectionIndex(); int startIndex = 1; NormalColumn foreignKeyColumn = null; List<NormalColumn> foreignKeyList = this.editorReferencedMap .get(tableEditor); if (foreignKeyList != null) { if (foreignKeyComboIndex <= foreignKeyList.size()) { foreignKeyColumn = foreignKeyList.get(foreignKeyComboIndex - startIndex); } else { startIndex += foreignKeyList.size(); } } if (foreignKeyColumn == null) { foreignKeyColumn = this.candidateForeignKeyColumns .get(foreignKeyComboIndex - startIndex); } return foreignKeyColumn; }
@Override protected String getErrorMessage() { Set<NormalColumn> selectedColumns = new HashSet<NormalColumn>(); for (TableEditor tableEditor : this.tableEditorList) { Combo foreignKeyCombo = (Combo) tableEditor.getEditor(); int index = foreignKeyCombo.getSelectionIndex(); if (index == 0) { return "error.foreign.key.not.selected"; } NormalColumn selectedColumn = this.getSelectedColumn(tableEditor); if (selectedColumns.contains(selectedColumn)) { return "error.foreign.key.must.be.different"; } selectedColumns.add(selectedColumn); } if (this.existForeignKeySet(selectedColumns)) { return "error.foreign.key.already.exist"; } return null; }
private void column2TableItem(NormalColumn referencedColumn) { TableItem tableItem = new TableItem(this.comparisonTable, SWT.NONE); tableItem.setText(0, Format.null2blank(referencedColumn.getLogicalName())); List<NormalColumn> foreignKeyList = this.referencedMap .get(referencedColumn.getRootReferencedColumn()); TableEditor tableEditor = new TableEditor(this.comparisonTable); tableEditor.grabHorizontal = true; tableEditor.setEditor(this.createForeignKeyCombo(foreignKeyList), tableItem, 1); this.tableEditorList.add(tableEditor); this.editorReferencedMap.put(tableEditor, foreignKeyList); }
private void edit(final TableItem item, final TableEditor tableEditor) { final Text text = new Text(table, SWT.NONE); text.setText(item.getText(targetColumn)); text.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { item.setText(targetColumn, text.getText()); text.dispose(); } }); tableEditor.setEditor(text, item, targetColumn); text.setFocus(); text.selectAll(); }
@Override public void restruct() { this.columnTable.removeAll(); this.disposeTableEditor(); for (NormalColumn normalColumn : this.copyData.getNormalColumns()) { TableItem tableItem = new TableItem(this.columnTable, SWT.NONE); TableEditor tableEditor = CompositeFactory .createCheckBoxTableEditor(tableItem, false, 0); this.tableEditorList.add(tableEditor); this.editorColumnMap.put(tableEditor, normalColumn); tableItem.setText(1, Format.null2blank(normalColumn.getName())); } this.setComboData(); this.setButtonStatus(false); this.nameText.setText(""); this.columnTable.getColumns()[1].pack(); }
private void setTableEditor(final NormalColumn normalColumn, TableItem tableItem, Boolean desc) { Button descCheckButton = new Button(this.indexColumnList, SWT.CHECK); descCheckButton.pack(); if (DBManagerFactory.getDBManager(this.table.getDiagram()).isSupported( DBManager.SUPPORT_DESC_INDEX)) { TableEditor editor = new TableEditor(this.indexColumnList); editor.minimumWidth = descCheckButton.getSize().x; editor.horizontalAlignment = SWT.CENTER; editor.setEditor(descCheckButton, tableItem, 1); this.columnCheckMap.put(normalColumn, editor); } this.descCheckBoxMap.put(normalColumn, descCheckButton); descCheckButton.setSelection(desc.booleanValue()); }
private void setupRelationship() { newCreatedRelationship = createRelationship(); newCreatedRelationship.setForeignKeyName(foreignKeyNameText.getText().trim()); if (isCreateNewColumn()) { // TODO ymd コマンド外の操作でカラムを追加しているため、undoしてもカラムが削除されない。コマンド化する。 for (final NormalColumn referredColumn : selectedReferredColumnList) { final NormalColumn newColumn = new NormalColumn(referredColumn, newCreatedRelationship, resultReferenceForPK); adjustNewForeignKeyColumn(newColumn); selectedForeignKeyColumnList.add(newColumn); target.addColumn(newColumn); } } else { for (final TableEditor mapperEditor : mapperEditorList) { selectedForeignKeyColumnList.add(findSelectedColumn(mapperEditor)); } } }
private NormalColumn findSelectedColumn(TableEditor tableEditor) { // not null final Combo foreignKeySelector = (Combo) tableEditor.getEditor(); final int selectionIndex = foreignKeySelector.getSelectionIndex(); int startIndex = 1; NormalColumn foreignKeyColumn = null; final List<NormalColumn> foreignKeyList = mapperEditorToReferredColumnsMap.get(tableEditor); if (foreignKeyList != null) { if (selectionIndex <= foreignKeyList.size()) { foreignKeyColumn = foreignKeyList.get(selectionIndex - startIndex); } else { startIndex += foreignKeyList.size(); } } if (foreignKeyColumn == null) { foreignKeyColumn = candidateForeignKeyColumns.get(selectionIndex - startIndex); } return foreignKeyColumn; }
private void initNodeTable() { nodeTable.removeAll(); nodeCheckMap = new HashMap<>(); for (final DiagramWalker walker : getTableWalkers()) { final TableItem tableItem = new TableItem(nodeTable, SWT.NONE); final Button selectCheckButton = new Button(nodeTable, SWT.CHECK); selectCheckButton.pack(); final TableEditor editor = new TableEditor(nodeTable); editor.minimumWidth = selectCheckButton.getSize().x; editor.horizontalAlignment = SWT.CENTER; editor.setEditor(selectCheckButton, tableItem, 0); tableItem.setText(1, DisplayMessages.getMessage("label.object.type." + walker.getObjectType())); tableItem.setText(2, walker.getName()); nodeCheckMap.put(walker, editor); } }
private void checkSelectedKey() { final int index = compoundUniqueKeyCombo.getSelectionIndex(); CompoundUniqueKey complexUniqueKey = null; String name = null; if (index != -1) { complexUniqueKey = table.getCompoundUniqueKeyList().get(index); name = complexUniqueKey.getUniqueKeyName(); setUpdateDeleteButtonStatus(true); } else { setUpdateDeleteButtonStatus(false); } uniqueKeyNameText.setText(Format.null2blank(name)); for (final TableEditor tableEditor : tableEditorList) { final Button checkbox = (Button) tableEditor.getEditor(); final NormalColumn column = editorColumnMap.get(tableEditor); if (complexUniqueKey != null && complexUniqueKey.getColumnList().contains(column)) { checkbox.setSelection(true); } else { checkbox.setSelection(false); } } }
private void initNodeTable() { nodeTable.removeAll(); nodeCheckMap = new HashMap<>(); for (final DiagramWalker nodeElement : diagram.getDiagramContents().getDiagramWalkers()) { final TableItem tableItem = new TableItem(nodeTable, SWT.NONE); final Button selectCheckButton = new Button(nodeTable, SWT.CHECK); selectCheckButton.pack(); final TableEditor editor = new TableEditor(nodeTable); editor.minimumWidth = selectCheckButton.getSize().x; editor.horizontalAlignment = SWT.CENTER; editor.setEditor(selectCheckButton, tableItem, 0); tableItem.setText(1, DisplayMessages.getMessage("label.object.type." + nodeElement.getObjectType())); tableItem.setText(2, nodeElement.getName()); nodeCheckMap.put(nodeElement, editor); } }
private void updateCellControls() { final TableItem[] items = table.getItems(); for (int i = 0; i < items.length; i++) { TableEditor editor = new TableEditor(table); final Text text = new Text(table, SWT.NONE); text.setText(items[i].getText(2)); final int index = i; text.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { items[index].setText(2, text.getText()); } }); editor.grabHorizontal = true; editor.setEditor(text, items[i], 2); } }
public void CreateTableText(Table table, TableItem item, final int i) { final TableEditor editor = new TableEditor(table); editors.add(editor); final Text text = new Text(table, SWT.NONE); text.setText(item.getText(i)); editor.grabHorizontal = true; editor.setEditor(text, item, i); text.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent evt) { editor.getItem().setText(i, text.getText()); updateygroup(); } }); }