List of usage examples for org.eclipse.jface.viewers StructuredSelection isEmpty
@Override public boolean isEmpty()
From source file:org.apache.directory.studio.openldap.config.editor.databases.DatabasesMasterDetailsBlock.java
License:Apache License
/** * Update the button according to the content of the table. If we have * no Database, we just enable the Add button. If we only have one Database, * we don't enable the Add and Delete buttons. We also enable the Up and * Down button accordingly to the selected database : if it's the first one, * the Up butto is disabled, if it's the last one, the Down button is * disabled./* ww w . ja v a 2 s .co m*/ */ private void refreshButtonStates() { // Getting the selection of the table viewer StructuredSelection selection = (StructuredSelection) databaseTableViewer.getSelection(); if (!selection.isEmpty()) { OlcDatabaseConfig database = ((DatabaseWrapper) selection.getFirstElement()).getDatabase(); deleteButton.setEnabled(true); upButton.setEnabled(getMinOrderingValue() != OpenLdapConfigurationPluginUtils .getOrderingPrefix(database.getOlcDatabase())); downButton.setEnabled(getMaxOrderingValue() != OpenLdapConfigurationPluginUtils .getOrderingPrefix(database.getOlcDatabase())); } else { deleteButton.setEnabled(false); upButton.setEnabled(false); downButton.setEnabled(false); } }
From source file:org.apache.directory.studio.openldap.config.editor.dialogs.overlays.MemberOfOverlayConfigurationBlock.java
License:Apache License
/** * Gets the selected dangling reference behavior. * * @return the selected dangling reference behavior *///from w w w . j av a 2 s .c o m private OlcMemberOfDanglingReferenceBehaviorEnum getSelectedDanglingReferenceBehavior() { StructuredSelection selection = (StructuredSelection) danglingReferenceBehaviorComboViewer.getSelection(); if ((selection != null) && (!selection.isEmpty())) { Object firstElement = selection.getFirstElement(); if (firstElement instanceof OlcMemberOfDanglingReferenceBehaviorEnum) { return (OlcMemberOfDanglingReferenceBehaviorEnum) firstElement; } else { return null; } } return null; }
From source file:org.apache.directory.studio.openldap.config.editor.dialogs.overlays.MemberOfOverlayConfigurationBlock.java
License:Apache License
/** * Gets the selected dangling reference error code. * * @return the selected dangling reference error code *//*from w ww .ja v a2 s .co m*/ private ResultCodeEnum getSelectedDanglingReferenceErrorCode() { StructuredSelection selection = (StructuredSelection) danglingReferenceErrorCodeComboViewer.getSelection(); if ((selection != null) && (!selection.isEmpty())) { Object firstElement = selection.getFirstElement(); if (firstElement instanceof ResultCodeEnum) { return (ResultCodeEnum) firstElement; } else { return null; } } return null; }
From source file:org.apache.directory.studio.openldap.config.editor.dialogs.overlays.RewriteRemapOverlayConfigurationBlock.java
License:Apache License
/** * Action launched when the edit mapping button is clicked, or * when the value sorts table viewer is double-clicked. *//*from ww w .j a va2 s. c om*/ private void editMappingButtonAction() { StructuredSelection selection = (StructuredSelection) mappingsTableViewer.getSelection(); if (!selection.isEmpty()) { String selectedMapping = (String) selection.getFirstElement(); RwmMappingDialog dialog = new RwmMappingDialog(addMappingButton.getShell(), browserConnection, selectedMapping); if (dialog.open() == AttributeDialog.OK) { String value = dialog.getValue(); int index = mappings.indexOf(selectedMapping); mappings.remove(selectedMapping); mappings.add(index, value); mappingsTableViewer.refresh(); mappingsTableViewer.setSelection(new StructuredSelection(value)); } } }
From source file:org.apache.directory.studio.openldap.config.editor.dialogs.overlays.ValueSortingOverlayConfigurationBlock.java
License:Apache License
/** * Action launched when the edit value sort button is clicked, or * when the value sorts table viewer is double-clicked. *///from w w w .java 2 s .c om private void editValueSortButtonAction() { StructuredSelection selection = (StructuredSelection) valueSortsTableViewer.getSelection(); if (!selection.isEmpty()) { String selectedValueSort = (String) selection.getFirstElement(); ValueSortingValueDialog dialog = new ValueSortingValueDialog(addValueSortButton.getShell(), browserConnection, selectedValueSort); if (dialog.open() == AttributeDialog.OK) { String value = dialog.getValue(); int index = valueSorts.indexOf(selectedValueSort); valueSorts.remove(selectedValueSort); valueSorts.add(index, value); valueSortsTableViewer.refresh(); valueSortsTableViewer.setSelection(new StructuredSelection(value)); } } }
From source file:org.apache.directory.studio.openldap.config.editor.dialogs.ReplicationConsumerDialog.java
License:Apache License
/** * Updates the state of the attributes table buttons. *///from w ww . j av a 2 s.c o m private void updateAttributesTableButtonsState() { StructuredSelection selection = (StructuredSelection) attributesTableViewer.getSelection(); editAttributeButton.setEnabled(!selection.isEmpty()); deleteAttributeButton.setEnabled(!selection.isEmpty()); }
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. *///from w ww.j a v a 2 s. c o 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. *//*from w ww. j ava2 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./*from w w w .j a v a2 s . com*/ * * @return the encryption method */ private EncryptionMethod getEncryptionMethod() { StructuredSelection selection = (StructuredSelection) encryptionMethodComboViewer.getSelection(); if ((selection != null) && (!selection.isEmpty())) { return (EncryptionMethod) selection.getFirstElement(); } return null; }