Java Code Examples for org.eclipse.swt.widgets.Combo#getSelectionIndex()

The following examples show how to use org.eclipse.swt.widgets.Combo#getSelectionIndex() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RelationByExistingColumnsDialog.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 2
Source File: RelationByExistingColumnsDialog.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example 3
Source File: RelationshipByExistingColumnsDialog.java    From erflute with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 4
Source File: RelationByExistingColumnsDialog.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 5
Source File: RelationByExistingColumnsDialog.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
@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;
}
 
Example 6
Source File: MechanicDialog.java    From workspacemechanic with Eclipse Public License 1.0 5 votes vote down vote up
@Override 
public void widgetSelected(SelectionEvent e) {
  Combo combo = (Combo) e.getSource();
  int index = combo.getSelectionIndex();
  Decision choice = Decision.valueOf(index);
  userTaskChoices.put(item, choice);
}
 
Example 7
Source File: AbstractExportDialog.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
protected Category getSelectedCategory(final Combo categoryCombo) {
    Category category = null;

    final int categoryIndex = categoryCombo.getSelectionIndex();

    if (categoryIndex != 0) {
        category = categoryList.get(categoryIndex - 1);
    }

    return category;
}
 
Example 8
Source File: SWTUtils.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Tests if the Combo value is empty. If so, it adds an error color to the background of the cell.
 * 
 * @param combo
 *            the combo to validate
 * @param validSelectionIndex
 *            the first item that is a "valid" selection
 * @return boolean
 */
public static boolean validateCombo(Combo combo, int validSelectionIndex)
{
	int selectionIndex = Math.max(validSelectionIndex, 0);
	String text = combo.getText();
	if (text == null || text.length() == 0 || combo.getSelectionIndex() < selectionIndex)
	{
		combo.setBackground(backgroundErrorColor);
		return false;
	}
	combo.setBackground(null);
	return true;
}
 
Example 9
Source File: WizardUtils.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
public static int getComboIndex(final Combo combo, final int defVal) {
    if ((combo == null) || (combo.isDisposed())) {
        return defVal;
    }

    return (combo.getSelectionIndex());
}
 
Example 10
Source File: LevelPropertyDialog.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private void updateFormatHelper( IDialogHelper helper, Combo combo )
{
	if ( helper != null )
	{
		if ( combo.getSelectionIndex( ) > -1 )
		{
			helper.setProperty( BuilderConstants.FORMAT_VALUE_TYPE,
					getDataTypeNames( )[combo.getSelectionIndex( )] );
		}
		helper.update( true );
	}
}
 
Example 11
Source File: RelationshipByExistingColumnsDialog.java    From erflute with Apache License 2.0 4 votes vote down vote up
@Override
protected String doValidate() {
    final String foreignKeyName = foreignKeyNameText.getText().trim();
    if (Srl.is_Null_or_TrimmedEmpty(foreignKeyName)) {
        return "Input foreign key name e.g. FK_XXX";
    }
    if (source.getDiagramSettings().isValidatePhysicalName() && !Check.isAlphabet(foreignKeyName)) {
        return "error.foreign.key.name.not.alphabet";
    }
    final ERDiagram diagram = target.getDiagram();
    final List<TableView> tableViewList = diagram.getDiagramContents().getDiagramWalkers().getTableViewList();
    for (final TableView tableView : tableViewList) {
        final List<Relationship> relationshipList = tableView.getIncomingRelationshipList();
        for (final Relationship currentRel : relationshipList) {
            final String currentForeignKeyName = currentRel.getForeignKeyName();
            if (currentForeignKeyName != null) {
                if (currentForeignKeyName.equalsIgnoreCase(foreignKeyName)) {
                    return "error.foreign.key.name.already.exists";
                }
            }
        }
    }
    if (isCreateNewColumn()) {
        for (final NormalColumn referredColumn : selectedReferredColumnList) {
            final NormalColumn existingColumn = target.findColumnByPhysicalName(referredColumn.getPhysicalName());
            if (existingColumn != null) {
                return "The same name column already exists, cannot create new column";
            }
        }
        return null;
    } else {
        // #hope check type difference by jflute
        final Set<NormalColumn> selectedColumns = new HashSet<>();
        for (final TableEditor tableEditor : mapperEditorList) {
            final Combo foreignKeySelector = (Combo) tableEditor.getEditor();
            final int selectionIndex = foreignKeySelector.getSelectionIndex();
            if (selectionIndex == 0) {
                return "error.foreign.key.not.selected";
            }
            final NormalColumn selectedColumn = findSelectedColumn(tableEditor);
            if (selectedColumns.contains(selectedColumn)) {
                return "error.foreign.key.must.be.different";
            }
            selectedColumns.add(selectedColumn);
        }
        if (existsForeignKeyColumnSet(selectedColumns)) {
            return "error.foreign.key.already.exist";
        }
        return null;
    }
}