Example usage for org.eclipse.jface.viewers StructuredSelection getFirstElement

List of usage examples for org.eclipse.jface.viewers StructuredSelection getFirstElement

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers StructuredSelection getFirstElement.

Prototype

@Override
    public Object getFirstElement() 

Source Link

Usage

From source file:org.apache.directory.studio.openldap.config.editor.dialogs.ReplicationConsumerDialog.java

License:Apache License

/**
 * Action launched when the edit attribute button is clicked.
 *//* w  ww . j  a  v a 2 s. co m*/
private void editAttributeButtonAction() {
    StructuredSelection selection = (StructuredSelection) attributesTableViewer.getSelection();

    if (!selection.isEmpty()) {
        String selectedAttribute = (String) selection.getFirstElement();
        AttributeDialog dialog = new AttributeDialog(editAttributeButton.getShell(), browserConnection,
                selectedAttribute);
        if (dialog.open() == AttributeDialog.OK) {
            String attribute = dialog.getAttribute();
            int selectedAttributeIndex = attributes.indexOf(selectedAttribute);

            attributes.remove(selectedAttributeIndex);
            attributes.add(selectedAttributeIndex, attribute);
            syncRepl.setAttributes(attributes.toArray(new String[0]));
            attributesTableViewer.refresh();
            attributesTableViewer.setSelection(new StructuredSelection(attribute));
        }
    }
}

From source file:org.apache.directory.studio.openldap.config.editor.dialogs.ReplicationConsumerDialog.java

License:Apache License

/**
 * Action launched when the delete attribute button is clicked.
 *//*  w w w  . j  a  va  2 s.  co m*/
private void deleteAttributeButtonAction() {
    StructuredSelection selection = (StructuredSelection) attributesTableViewer.getSelection();

    if (!selection.isEmpty()) {
        String selectedAttribute = (String) selection.getFirstElement();
        attributes.remove(selectedAttribute);
        syncRepl.setAttributes(attributes.toArray(new String[0]));
        attributesTableViewer.refresh();

        //            updateAttributesTableButtonsState();
    }
}

From source file:org.apache.directory.studio.openldap.config.editor.dialogs.ReplicationConsumerDialog.java

License:Apache License

/**
 * Gets the replication type.//  w w w.j  a va  2 s  .  c o  m
 *
 * @return the replication type
 */
private Type getReplicationType() {
    StructuredSelection selection = (StructuredSelection) replicationTypeComboViewer.getSelection();

    if ((selection != null) && (!selection.isEmpty())) {
        return (Type) selection.getFirstElement();
    }

    return null;
}

From source file:org.apache.directory.studio.openldap.config.editor.dialogs.ReplicationConsumerDialog.java

License:Apache License

/**
 * Gets the encryption method./*ww  w.  j  av a  2 s .  co m*/
 *
 * @return the encryption method
 */
private EncryptionMethod getEncryptionMethod() {
    StructuredSelection selection = (StructuredSelection) encryptionMethodComboViewer.getSelection();

    if ((selection != null) && (!selection.isEmpty())) {
        return (EncryptionMethod) selection.getFirstElement();
    }

    return null;
}

From source file:org.apache.directory.studio.openldap.config.editor.dialogs.ReplicationConsumerDialog.java

License:Apache License

/**
 * Gets the scope.//w  w  w  . ja  va  2 s. c o m
 *
 * @return the scope
 */
private Scope getScope() {
    StructuredSelection selection = (StructuredSelection) scopeComboViewer.getSelection();

    if ((selection != null) && (!selection.isEmpty())) {
        return (Scope) selection.getFirstElement();
    }

    return null;
}

From source file:org.apache.directory.studio.openldap.config.editor.dialogs.ReplicationOptionsDialog.java

License:Apache License

/**
 * Gets the sync data./*from ww w. j a v  a 2s  .c om*/
 *
 * @return the sync data
 */
private SyncData getSyncData() {
    if (enableDeltaSyncReplCheckbox.getSelection()) {
        StructuredSelection selection = (StructuredSelection) syncDataComboViewer.getSelection();

        if ((selection != null) && (!selection.isEmpty())) {
            return (SyncData) selection.getFirstElement();
        }
    }

    return null;
}

From source file:org.apache.directory.studio.openldap.config.editor.dialogs.ReplicationSaslDialog.java

License:Apache License

/**
 * Gets the selected SASL mechanism.//from  w w w. ja v a2  s  . c o m
 *
 * @return the selected SASL mechanism
 */
private String getSaslMechanism() {
    StructuredSelection selection = (StructuredSelection) saslMechanismComboViewer.getSelection();

    if ((selection != null) && (!selection.isEmpty())) {
        return ((SaslMechanism) selection.getFirstElement()).getValue();
    }

    return null;
}

From source file:org.apache.directory.studio.openldap.config.editor.dialogs.RwmMappingDialog.java

License:Apache License

/**
 * Gets the selected sort method.//www.  java  2 s  .  co  m
 *
 * @return the selected sort method
 */
private OlcRwmMapValueTypeEnum getSelectedType() {
    StructuredSelection selection = (StructuredSelection) typeComboViewer.getSelection();

    if (!selection.isEmpty()) {
        return (OlcRwmMapValueTypeEnum) selection.getFirstElement();
    }

    return null;
}

From source file:org.apache.directory.studio.openldap.config.editor.dialogs.ValueSortingValueDialog.java

License:Apache License

/**
 * Gets the selected sort method./*from   ww w .  ja va  2s  .  co m*/
 *
 * @return the selected sort method
 */
private Object getSelectedSortMethod() {
    StructuredSelection selection = (StructuredSelection) sortMethodComboViewer.getSelection();

    if (!selection.isEmpty()) {
        return selection.getFirstElement();
    }

    return null;
}

From source file:org.apache.directory.studio.openldap.config.editor.dialogs.ValueSortingValueDialog.java

License:Apache License

/**
 * Gets the selected secondary sort method.
 *
 * @return the selected secondary sort method
 *///from w w  w  .  jav  a 2 s  .co  m
private Object getSelectedSecondarySortMethod() {
    StructuredSelection selection = (StructuredSelection) secondarySortMethodComboViewer.getSelection();

    if (!selection.isEmpty()) {
        return selection.getFirstElement();
    }

    return null;
}