List of usage examples for org.eclipse.jface.viewers StructuredSelection isEmpty
@Override public boolean isEmpty()
From source file:org.apache.directory.studio.schemaeditor.view.wizards.NewAttributeTypeGeneralWizardPage.java
License:Apache License
/** * Get the name of the schema.//from w ww . ja v a 2s. com * * @return * the name of the schema */ public String getSchemaValue() { StructuredSelection selection = (StructuredSelection) schemaComboViewer.getSelection(); if (!selection.isEmpty()) { Schema schema = (Schema) selection.getFirstElement(); return schema.getSchemaName(); } else { return null; } }
From source file:org.apache.directory.studio.schemaeditor.view.wizards.NewObjectClassContentWizardPage.java
License:Apache License
/** * This method is called when the "Remove" button of the superiors * table is selected.//from www . j av a2 s . c o m */ private void removeSuperiorObjectClass() { StructuredSelection selection = (StructuredSelection) superiorsTableViewer.getSelection(); if (!selection.isEmpty()) { superiorsList.remove(selection.getFirstElement()); updateSuperiorsTable(); } }
From source file:org.apache.directory.studio.schemaeditor.view.wizards.NewObjectClassMandatoryAttributesPage.java
License:Apache License
/** * This method is called when the "Remove" button of the mandatory * attribute types table is selected.// w ww . j av a2 s .c o m */ private void removeMandatoryAttributeType() { StructuredSelection selection = (StructuredSelection) mandatoryAttributeTypesTableViewer.getSelection(); if (!selection.isEmpty()) { mandatoryAttributeTypesList.remove(selection.getFirstElement()); updateMandatoryAttributeTypesTableTable(); } }
From source file:org.apache.directory.studio.schemaeditor.view.wizards.NewObjectClassOptionalAttributesPage.java
License:Apache License
/** * This method is called when the "Remove" button of the optional * attribute types table is selected./*from ww w .j a v a 2 s . com*/ */ private void removeOptionalAttributeType() { StructuredSelection selection = (StructuredSelection) optionalAttributeTypesTableViewer.getSelection(); if (!selection.isEmpty()) { optionalAttributeTypesList.remove(selection.getFirstElement()); updateOptionalAttributeTypesTableTable(); } }
From source file:org.apache.directory.studio.templateeditor.editor.widgets.EditorTable.java
License:Apache License
/** * This method is called when the 'Edit...' toolbar item is clicked. *///w w w.j a va2 s .c o m private void editToolItemAction() { StructuredSelection selection = (StructuredSelection) tableViewer.getSelection(); if (!selection.isEmpty()) { String selectedValue = (String) selection.getFirstElement(); IAttribute attribute = getAttribute(); if ((attribute != null) && (attribute.isString()) && (attribute.getValueSize() > 0)) { IValue value = null; for (IValue attributeValue : attribute.getValues()) { if (selectedValue.equals(attributeValue.getStringValue())) { value = attributeValue; break; } } if (value != null) { TextDialog textDialog = new TextDialog(tableViewer.getTable().getShell(), selectedValue); if (textDialog.open() == Dialog.OK) { String newValue = textDialog.getText(); if (!selectedValue.equals(newValue)) { deleteAttributeValue(selectedValue); addAttributeValue(newValue); tableViewer.setSelection(new StructuredSelection(newValue)); } } } } } }
From source file:org.apache.directory.studio.templateeditor.editor.widgets.EditorTable.java
License:Apache License
/** * This method is called when the 'Delete...' toolbar item is clicked. */// w w w . j a va 2 s . c o m private void deleteToolItemAction() { StructuredSelection selection = (StructuredSelection) tableViewer.getSelection(); if (!selection.isEmpty()) { // Launching a confirmation dialog if (MessageDialog.openConfirm(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.getString("EditorTable.Confirmation"), //$NON-NLS-1$ Messages.getString("EditorTable.ConfirmationDeleteValue"))) //$NON-NLS-1$ { deleteAttributeValue((String) selection.getFirstElement()); } } }
From source file:org.apache.directory.studio.templateeditor.editor.widgets.EditorTable.java
License:Apache License
/** * Updates the states of the buttons.//from w w w. j a v a 2s . c o m */ private void updateButtonsStates() { StructuredSelection selection = (StructuredSelection) tableViewer.getSelection(); if ((editToolItem != null) && (!editToolItem.isDisposed())) { editToolItem.setEnabled(!selection.isEmpty()); } if ((deleteToolItem != null) && (!deleteToolItem.isDisposed())) { deleteToolItem.setEnabled(!selection.isEmpty()); } }
From source file:org.apache.directory.studio.templateeditor.view.preferences.TemplateEntryEditorPreferencePage.java
License:Apache License
/** * Creates the templates viewer.//from w w w . j a v a2 s . c om */ private void createTemplatesViewer() { // Templates tree Tree templatesTree = new Tree(templatesViewerComposite, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION | SWT.CHECK); templatesTree.setLinesVisible(false); // Templates table viewer templatesViewer = new CheckboxTreeViewer(templatesTree); GridData gridData2 = new GridData(SWT.FILL, SWT.NONE, true, false); gridData2.heightHint = 160; templatesViewer.getTree().setLayoutData(gridData2); // Templates content and label providers, and comparator TemplatesContentProvider contentProvider = new TemplatesContentProvider(this, manager); templatesViewer.setContentProvider(contentProvider); TemplatesCheckStateListener checkStateProviderListener = new TemplatesCheckStateListener(contentProvider, manager); templatesViewer.addCheckStateListener(checkStateProviderListener); TemplatesLabelProvider labelProvider = new TemplatesLabelProvider(manager); templatesViewer.setLabelProvider(labelProvider); templatesViewer.setComparator(new ColumnsTableViewerComparator(labelProvider)); templatesViewer.addDoubleClickListener(new IDoubleClickListener() { @SuppressWarnings("unchecked") public void doubleClick(DoubleClickEvent event) { StructuredSelection selection = (StructuredSelection) templatesViewer.getSelection(); if (!selection.isEmpty()) { Iterator<Object> selectionIterator = selection.iterator(); while (selectionIterator.hasNext()) { Object selectedElement = (Object) selectionIterator.next(); if (templatesViewer.getExpandedState(selectedElement)) { templatesViewer.collapseToLevel(selectedElement, 1); } else { templatesViewer.expandToLevel(selectedElement, 1); } } } } }); }
From source file:org.apache.directory.studio.templateeditor.view.preferences.TemplateEntryEditorPreferencePage.java
License:Apache License
/** * Updates the states of the buttons.//from ww w . ja v a 2 s . com */ @SuppressWarnings("unchecked") private void updateButtonsStates() { StructuredSelection selection = (StructuredSelection) templatesViewer.getSelection(); if (!selection.isEmpty()) { if (selection.size() == 1) { // Only one row is selected Object selectedObject = selection.getFirstElement(); removeTemplateButton.setEnabled((selectedObject instanceof FileTemplate) || (selectedObject instanceof PreferencesFileTemplate)); // If we're in the object class presentation, we need to update the 'Set Default' button if (store.getInt( EntryTemplatePluginConstants.PREF_TEMPLATES_PRESENTATION) == EntryTemplatePluginConstants.PREF_TEMPLATES_PRESENTATION_OBJECT_CLASS) { if (selectedObject instanceof Template) { Template selectedTemplate = (Template) selectedObject; setDefaultTemplateButton.setEnabled((manager.isEnabled(selectedTemplate) && (!manager.isDefaultTemplate(selectedTemplate)))); } else { setDefaultTemplateButton.setEnabled(false); } } } else { // More than one row is selected removeTemplateButton.setEnabled(true); Iterator<Object> selectionIterator = ((StructuredSelection) templatesViewer.getSelection()) .iterator(); while (selectionIterator.hasNext()) { Object selectedObject = selectionIterator.next(); if (!((selectedObject instanceof FileTemplate) || (selectedObject instanceof PreferencesFileTemplate))) { removeTemplateButton.setEnabled(false); break; } } // If we're in the object class presentation, we need to update the 'Set Default' button if (store.getInt( EntryTemplatePluginConstants.PREF_TEMPLATES_PRESENTATION) == EntryTemplatePluginConstants.PREF_TEMPLATES_PRESENTATION_OBJECT_CLASS) { setDefaultTemplateButton.setEnabled(false); } } } else { removeTemplateButton.setEnabled(false); setDefaultTemplateButton.setEnabled(false); } }
From source file:org.apache.directory.studio.templateeditor.view.preferences.TemplateEntryEditorPreferencePage.java
License:Apache License
/** * Implements the remove template action. *//*from w ww . j av a 2 s . co m*/ @SuppressWarnings("unchecked") private void removeTemplateAction() { StructuredSelection selection = (StructuredSelection) templatesViewer.getSelection(); if (!selection.isEmpty()) { Iterator<Object> selectionIterator = ((StructuredSelection) templatesViewer.getSelection()).iterator(); while (selectionIterator.hasNext()) { Object selectedObject = selectionIterator.next(); if (selectedObject instanceof Template) { Template template = (Template) selectedObject; if (!manager.removeTemplate(template)) { // Creating and opening the dialog String dialogTitle = Messages .getString("TemplateEntryEditorPreferencePage.UnableToRemoveTheTemplate"); //$NON-NLS-1$ String dialogMessage = MessageFormat.format(Messages .getString("TemplateEntryEditorPreferencePage.TheTemplateCouldNotBeRemoved") //$NON-NLS-1$ + EntryTemplatePluginUtils.LINE_SEPARATOR + EntryTemplatePluginUtils.LINE_SEPARATOR + Messages.getString( "TemplateEntryEditorPreferencePage.SeeTheLogsFileForMoreInformation"), //$NON-NLS-1$ template.getTitle()); MessageDialog dialog = new MessageDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), dialogTitle, null, dialogMessage, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, MessageDialog.OK); dialog.open(); } } } } }