ref #8041 revert all changes except for the first and for the new method CdmUtils...
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / ui / dialog / selection / AbstractFilteredCdmResourceSelectionDialog.java
index 5eef31e2f7de3408eef49d14f18db4cc396b17a4..564face0024e9249eea54a6e2f5bccfb576dee0f 100644 (file)
 package eu.etaxonomy.taxeditor.ui.dialog.selection;
 
 import java.text.Collator;
+import java.util.ArrayList;
+import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 import java.util.UUID;
+import java.util.regex.Pattern;
 
-import org.eclipse.core.runtime.CoreException;
+import org.apache.commons.lang.StringUtils;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.dialogs.IDialogConstants;
 import org.eclipse.jface.dialogs.IDialogSettings;
 import org.eclipse.jface.viewers.ILabelProvider;
 import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
 import org.eclipse.jface.window.Window;
 import org.eclipse.jface.wizard.WizardDialog;
 import org.eclipse.swt.SWT;
@@ -32,20 +36,22 @@ import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
 import org.eclipse.swt.events.SelectionListener;
 import org.eclipse.swt.graphics.Cursor;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Link;
 import org.eclipse.swt.widgets.Shell;
 import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.IMemento;
 
-import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
-import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
+import eu.etaxonomy.cdm.api.service.dto.EntityDTOBase;
+import eu.etaxonomy.cdm.api.service.dto.IdentifiedEntityDTO;
+import eu.etaxonomy.cdm.common.CdmUtils;
 import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.cdm.model.common.ICdmBase;
 import eu.etaxonomy.cdm.model.common.IIdentifiableEntity;
 import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
-import eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap;
+import eu.etaxonomy.taxeditor.l10n.Messages;
 import eu.etaxonomy.taxeditor.model.MessagingUtils;
 import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
 import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
@@ -57,19 +63,22 @@ import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
  *
  * @author n.hoffmann
  * @created 04.06.2009
- * @version 1.0
  */
 public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmBase> extends
-               CdmFilteredItemsSelectionDialog implements IConversationEnabled {
+               SearchDialog {//implements IConversationEnabled {
 
-       private final ConversationHolder conversation;
+//     private final ConversationHolder conversation = null;
 
        protected List<UuidAndTitleCache<T>> model;
        private final Set<T> transientCdmObjects = new HashSet<T>();
        private final String settings;
-       protected final int limitOfInitialElements = 100;
+       protected final Integer limitOfInitialElements = null;
 
-       protected T cdmBaseToBeFiltered;
+       private T selectedObject;
+
+       protected Set<UUID> cdmBaseToBeFiltered;
+
+       protected Job searchJob;
 
 
        /**
@@ -83,28 +92,22 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
         * @param cdmObject a T object.
         * @param <T> a T object.
         */
-       protected AbstractFilteredCdmResourceSelectionDialog(Shell shell, ConversationHolder conversation, String title, boolean multi, String settings, T cdmObject) {
-               super(shell, multi);
-               setTitle(title);
-               setMessage("Use * for wildcard, or ? to see all entries");
+       protected AbstractFilteredCdmResourceSelectionDialog(Shell shell, //ConversationHolder conversation,
+               String title, boolean multi, String settings, T cdmObject) {
+               super(shell, title);
+               setShellStyle(SWT.DIALOG_TRIM);
+               setMessage(Messages.SearchDialog_patternLabel);
                this.settings = settings;
-
-               this.conversation = conversation;
-               this.cdmBaseToBeFiltered = cdmObject;
+        if (cdmObject != null){
+            this.cdmBaseToBeFiltered = new HashSet<>();
+            this.cdmBaseToBeFiltered.add(cdmObject.getUuid());
+        }
                Cursor cursor = shell.getCursor();
                shell.setCursor(shell.getDisplay().getSystemCursor(SWT.CURSOR_WAIT));
                init();
-               initModel();
                shell.setCursor(cursor);
-               String objectTitle = getTitle(cdmObject);
-//             if (objectTitle != null) {
-//                     setInitialPattern(objectTitle);
-//             }
-
                setListLabelProvider(createListLabelProvider());
-               setDetailsLabelProvider(createDetailsLabelProvider());
 
-               setSelectionHistory(new ResourceSelectionHistory());
        }
 
        /**
@@ -142,20 +145,36 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
         * @return a TYPE object.
         */
        protected static <TYPE extends CdmBase> TYPE getSelectionFromDialog(AbstractFilteredCdmResourceSelectionDialog<TYPE> dialog) {
-               //dialog.setInitialPattern("");
-               int result = dialog.open();
-
-               if (result == Window.CANCEL) {
-                       return null;
-               }
-
-               UUID uuid = dialog.getSelectedUuidAndTitleCache().getUuid();
-               if(uuid == null){
-                       return null;
-               }
-               return dialog.getCdmObjectByUuid(uuid);
+           UuidAndTitleCache result = getUuidAndTitleCacheSelectionFromDialog(dialog);
+           if (result != null){
+               return dialog.getCdmObjectByUuid(result.getUuid());
+           } else {
+            return null;
+        }
        }
 
+       /**
+     * <p>getSelectionFromDialog</p>
+     *
+     * @param dialog a {@link eu.etaxonomy.taxeditor.ui.dialog.selection.AbstractFilteredCdmResourceSelectionDialog} object.
+     * @param <TYPE> a TYPE object.
+     * @return a TYPE object.
+     */
+    protected static UuidAndTitleCache getUuidAndTitleCacheSelectionFromDialog(AbstractFilteredCdmResourceSelectionDialog dialog) {
+        if (dialog == null){
+            return null;
+        }
+        int result = dialog.open();
+
+        if (result == Window.CANCEL) {
+            return null;
+        }
+
+        UuidAndTitleCache uuid = dialog.getSelectedUuidAndTitleCache();
+
+        return uuid;
+    }
+
        /**
         * Check if object was created during the life of this dialog. If not,
         * retrieve it from the CdmStore.
@@ -180,13 +199,6 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
         */
        abstract protected T getPersistentObject(UUID uuid);
 
-       /**
-        * @param cdmObject
-        */
-//     protected void addObjectToModel(T cdmObject) {
-//             model.add(new UuidAndTitleCache(cdmObject.getClass(), cdmObject.getUuid(), getTitle(cdmObject)));
-//             transientCdmObjects.add(cdmObject);
-//     }
 
        /**
         * <p>isObjectTransient</p>
@@ -219,49 +231,6 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
        }
 
 
-       /** {@inheritDoc} */
-       @Override
-       public void refresh() {
-               super.refresh();
-       }
-
-
-
-       /* (non-Javadoc)
-        * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#createFilter()
-        */
-       /** {@inheritDoc} */
-       @Override
-       protected ItemsFilter createFilter() {
-               return new ItemsFilter() {
-
-                       /**
-                        * Always returns false to enforce refiltering even if the pattern is equal
-                        */
-                       @Override
-                       public boolean equalsFilter(ItemsFilter filter) {
-                               return false;
-                       }
-
-                       @Override
-                       public boolean isConsistentItem(Object item) {
-                               return false;
-                       }
-
-                       @Override
-                       public boolean matchItem(Object item) {
-                               String text = null;
-                               if(item instanceof UuidAndTitleCache){
-                                       text = ((UuidAndTitleCache) item).getTitleCache();
-                               }else if(item instanceof String){
-                                       text = (String) item;
-                               }
-                               return text != null ? matches(text) : false;
-                       }
-
-               };
-       }
-
 
        /**
         * Set the filter input to the Agent's title cache
@@ -269,31 +238,8 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
         * @param cdmObject a T object.
         */
        protected void setPattern(T cdmObject) {
-               // FilteredSelection does some very tricky caching to make sure it
-               // runs with high performance.
-               // This works for most use cases, but we want to change the model while the dialog is open
-               // and all the clever caching prevents the content provider from knowing that the model has changed
-               // I am aware, that this is a hack, but the FilteredSelectionDialog API does not offer a convenient
-               // way to solve the problem.
-//             try {
-//                     Field lastCompletedFilter = this.getClass().getSuperclass().getSuperclass().getDeclaredField("lastCompletedFilter");
-//                     lastCompletedFilter.setAccessible(true);
-//                     lastCompletedFilter.set(this, null);
-//             } catch (SecurityException e) {
-//                     MessagingUtils.error(getClass(), e);
-//             } catch (NoSuchFieldException e) {
-//                     MessagingUtils.error(getClass(), e);
-//             } catch (IllegalArgumentException e) {
-//                     MessagingUtils.error(getClass(), e);
-//             } catch (IllegalAccessException e) {
-//                     MessagingUtils.error(getClass(), e);
-//             }
-
-               // this also is not the nicest way to do it.
-               // I am still amazed, that FilteredSelectionDialog does not offer any methods to change its data
-               // once it was opened. Am I doing it wrong?
                String pattern = getTitle(cdmObject);
-               ((Text) getPatternControl()).setText(pattern);
+               getSearchField().setText(pattern);
        }
 
 
@@ -302,38 +248,59 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
        * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#fillContentProvider(org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.AbstractContentProvider, org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.ItemsFilter, org.eclipse.core.runtime.IProgressMonitor)
        */
        /** {@inheritDoc} */
+
        @Override
-       protected void fillContentProvider(AbstractContentProvider contentProvider,
-               ItemsFilter itemsFilter, IProgressMonitor progressMonitor)
-               throws CoreException {
+    protected void fillContentProvider(IProgressMonitor progressMonitor)
+                {
                try {
+                   if (model == null){
+                       model = new ArrayList<UuidAndTitleCache<T>>();
+                   }
                        if(model != null){
-                               progressMonitor.beginTask("Looking for entities", model.size());
-                               filterExcludedObjects();
+                           if (progressMonitor != null){
+                               progressMonitor.beginTask("Looking for entities", model.size());
+                           }
+                           sort();
+
+                           contentProvider.reset();
                                Iterator<UuidAndTitleCache<T>> iterator = model.iterator();
                                UuidAndTitleCache<T> element;
                                while(iterator.hasNext()){
                                    element = iterator.next();
-                                       contentProvider.add(element, itemsFilter);
-                                       if (progressMonitor.isCanceled()) {
-                                               throw new OperationCanceledException();
-                                       }
-                                       progressMonitor.worked(1);
+
+                                   if (cdmBaseToBeFiltered == null || !cdmBaseToBeFiltered.contains(element.getUuid())){
+                                       contentProvider.add(element);
+                                   }
+                                   if (progressMonitor != null){
+                                       if (progressMonitor.isCanceled()) {
+                                               return;
+                                       }
+                                       progressMonitor.worked(1);
+                                   }
                                }
+                               this.refresh();
                        }else{
+
                                MessagingUtils.warn(getClass(), "Model for Filtered Selection is null:" + this.getClass().getSimpleName());
                        }
                }
                finally {
-                       progressMonitor.done();
+                   if (progressMonitor != null) {
+                progressMonitor.done();
+            }
                }
        }
 
-       /* (non-Javadoc)
+
+    protected void sort() {
+        Collections.sort(model, getItemsComparator());
+    }
+
+    /* (non-Javadoc)
         * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#getDialogSettings()
         */
        /** {@inheritDoc} */
-       @Override
+
        protected IDialogSettings getDialogSettings() {
                IDialogSettings settings = TaxeditorStorePlugin.getDefault().getDialogSettings().getSection(getSettings());
 
@@ -347,7 +314,7 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
         * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#getElementName(java.lang.Object)
         */
        /** {@inheritDoc} */
-       @Override
+
        public String getElementName(Object item) {
                return ((UuidAndTitleCache) item).getTitleCache();
        }
@@ -356,26 +323,42 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
         * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#getItemsComparator()
         */
        /** {@inheritDoc} */
+
        @Override
-       protected Comparator getItemsComparator() {
+    protected Comparator getItemsComparator() {
                return new Comparator<UuidAndTitleCache>() {
                        @Override
                        public int compare(UuidAndTitleCache entity1,
                                        UuidAndTitleCache entity2) {
                                Collator collator = Collator.getInstance();
-                               return collator.compare(entity1.getTitleCache(), entity2.getTitleCache());
+                               if (entity1 == entity2){
+                                   return 0;
+                               }
+
+                               if (entity1 == null && entity2 != null){
+                                   return -1;
+                               }
+                               if (entity2 == null && entity1 != null){
+                                   return 1;
+                               }
+                               if (entity1.getUuid().equals(entity2.getUuid())){
+                    return 0;
+                }
+                               if (entity1.getTitleCache() == null && entity2.getTitleCache() != null){
+                                   return -1;
+                               }
+                               if (entity2.getTitleCache() == null){
+                                   return 1;
+                               }
+                               int result = collator.compare(entity1.getTitleCache(), entity2.getTitleCache());
+                               if (result == 0){
+                                   result = entity1.getUuid().compareTo(entity2.getUuid());
+                               }
+                               return result;
                        }
                };
        }
 
-       /* (non-Javadoc)
-        * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#validateItem(java.lang.Object)
-        */
-       /** {@inheritDoc} */
-       @Override
-       protected IStatus validateItem(Object item) {
-               return Status.OK_STATUS;
-       }
 
        /**
         * <p>getSelectedUuidAndTitleCache</p>
@@ -383,11 +366,25 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
         * @return a {@link eu.etaxonomy.cdm.model.common.UuidAndTitleCache} object.
         */
        protected UuidAndTitleCache getSelectedUuidAndTitleCache() {
-               Object[] result = getResult();
-               return result[0] == null ? null : (UuidAndTitleCache) result[0];
+               Object result = getResult();
+               if (result instanceof UuidAndTitleCache){
+                   return (UuidAndTitleCache) result;
+               }
+               return null;
        }
 
        /**
+     * @return
+     */
+    private Object getResult() {
+        StructuredSelection selection = getCurrentSelection();
+        if (selection == null){
+            return null;
+        }
+        return selection.getFirstElement();
+    }
+
+    /**
         * <p>Getter for the field <code>settings</code>.</p>
         *
         * @return a {@link java.lang.String} object.
@@ -399,36 +396,14 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
                return settings;
        }
 
-       /**
-        *
-        * @author n.hoffmann
-        * @created Oct 19, 2009
-        * @version 1.0
-        */
-       private class ResourceSelectionHistory extends SelectionHistory {
-           /*
-           * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.SelectionHistory#restoreItemFromMemento(org.eclipse.ui.IMemento)
-               */
-               @Override
-               protected Object restoreItemFromMemento(IMemento element) {
-                       return element.getString("resource"); //$NON-NLS-1$
-               }
-               /*
-                * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog.SelectionHistory#storeItemToMemento(java.lang.Object,
-                *      org.eclipse.ui.IMemento)
-                */
-               @Override
-               protected void storeItemToMemento(Object item, IMemento element) {
-                       element.putString("resource", item.toString()); //$NON-NLS-1$
-               }
-       }
+
 
        /**
         * <p>getNewWizardLinkText</p>
         *
         * @return a {@link java.lang.String} object.
         */
-       protected abstract String getNewWizardLinkText();
+       protected abstract String[] getNewWizardText();
 
        /**
         * <p>getNewEntityWizard</p>
@@ -445,9 +420,13 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
                        }
                        UuidAndTitleCache uuidAndTitleCache = (UuidAndTitleCache) element;
                        String titleCache = uuidAndTitleCache.getTitleCache();
-                       if(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_ID_IN_ENTITY_SELECTION_DIAOLOG)){
+                       if(PreferencesUtil.getBooleanValue(IPreferenceKeys.SHOW_ID_IN_ENTITY_SELECTION_DIAOLOG)){
                            titleCache += " ["+uuidAndTitleCache.getId()+"]";
                        }
+                       if (element instanceof EntityDTOBase){
+                           titleCache += "(" + ((IdentifiedEntityDTO)element).getIdentifier().getTypeLabel() +": " + ((IdentifiedEntityDTO)element).getIdentifier().getIdentifier() + ")";
+                       }
+
             return titleCache;
                }
        };
@@ -456,30 +435,71 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
        * @see org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#createExtendedContentArea(org.eclipse.swt.widgets.Composite)
        */
        /** {@inheritDoc} */
-       @Override
-       protected Control createExtendedContentArea(Composite parent) {
-               String newWizardLinkText = getNewWizardLinkText();
-        if(newWizardLinkText != null){
-                       Link link = new Link(parent, SWT.NONE);
-                       link.setText(newWizardLinkText);
-                       link.addSelectionListener(getNewWizardLinkSelectionListener());
-                       return link;
-               }
-               return null;
-       }
 
-       protected SelectionListener getNewWizardLinkSelectionListener(){
+//     @Override
+//    protected Control createExtendedContentArea(Composite parent) {
+//             String newWizardLinkText = getNewWizardLinkText();
+////        if(newWizardLinkText != null){
+////            newButton1 = this.createButton(this.getShell(), new_id, newWizardLinkText, false);
+////
+////            newButton1.addSelectionListener(getNewWizardLinkSelectionListener());
+////                   return newButton1;
+////           }
+//             return null;
+//     }
+
+       @Override
+    protected void createButtonsForButtonBar(Composite parent) {
+           String[] newButtonText = getNewWizardText();
+
+           if (newButtonText!= null){
+               this.newButton1 = createButton(parent, this.new_id, newButtonText[0], false);
+               newButton1.addSelectionListener(getNewWizardButtonSelectionListener());
+
+
+               if (newButtonText.length > 1){
+                   newButton2 = createButton(parent, this.new_id2, newButtonText[1], false);
+                   newButton2.addSelectionListener(getNewWizardButtonSelectionListener());
+
+               }
+
+           }
+           Button space = createButton(parent, this.space_id, " ", false);
+           space.setEnabled(false);
+           space.setVisible(false);
+           GridData gridData = new GridData();
+        gridData.grabExcessHorizontalSpace = false;
+        gridData.widthHint = 3;
+           space.setLayoutData(gridData);
+           GridLayout gridLayout = new GridLayout();
+           gridLayout.makeColumnsEqualWidth= false;
+           if (newButtonText != null){
+               gridLayout.numColumns=newButtonText.length+2;
+           }else{
+               gridLayout.numColumns=2;
+           }
+           parent.setLayout(gridLayout);
+
+        super.createButtonsForButtonBar(parent);
+        super.getButton(IDialogConstants.OK_ID).setEnabled(false);
+    }
+
+       protected SelectionListener getNewWizardButtonSelectionListener(){
                return new SelectionAdapter() {
 
-                       /* (non-Javadoc)
-                        * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
-                        */
                        @Override
                        public void widgetSelected(SelectionEvent e) {
-
-                           AbstractNewEntityWizard wizard = getNewEntityWizard(e.text);
+                           Object source = e.getSource();
+                           String text = null;
+                           if (source instanceof Button){
+                               Button sourceButton = (Button) source;
+                               text = sourceButton.getText();
+                           }
+                           AbstractNewEntityWizard wizard = getNewEntityWizard(text);
                            if(wizard!=null){
-                               wizard.init(null, null);
+                               if (wizard.getEntity() == null){
+                                   wizard.init(null, null);
+                               }
                                if(wizard.getEntity() != null) {
                                    WizardDialog dialog = new WizardDialog(getShell(), wizard);
                                    int status = dialog.open();
@@ -487,13 +507,17 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
                                    if (status == IStatus.OK) {
 
                                        T entity = (T) wizard.getEntity();
-                                      // model.add(new UuidAndTitleCache<T>(entity.getUuid(), entity.getId(), getTitle(entity)));
                                        refresh();
                                        setPattern(entity);
-                                       getConversationHolder().bind();
+
+//                                     if (getConversationHolder() != null){
+//                                         getConversationHolder().bind();
+//                                     }
                                    }
                                    //FIXME : Need to make sure this is a stable fix (ticket 3822)
-                                   getConversationHolder().commit();
+//                                 if (getConversationHolder() != null){
+//                                     getConversationHolder().commit();
+//                                 }
                                }
                            }
                        }
@@ -504,15 +528,15 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
         * <p>getConversationHolder</p>
         *
         * @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
-        */
-       @Override
-       public ConversationHolder getConversationHolder() {
-               return conversation;
-       }
+//      */
+//     @Override
+//     public ConversationHolder getConversationHolder() {
+//             return conversation;
+//     }
 
        /** {@inheritDoc} */
-       @Override
-       public void update(CdmDataChangeMap changeEvents) {}
+//     @Override
+//     public void update(CdmDataChangeMap changeEvents) {}
 
        /**
         * Don't want to add for example a taxon or synonym to itself
@@ -526,11 +550,41 @@ public abstract class AbstractFilteredCdmResourceSelectionDialog<T extends ICdmB
                        UuidAndTitleCache uuidAndTitleCacheToRemove = null;
 
                        for (UuidAndTitleCache uuidAndTitleCache : model){
-                               if ((cdmBaseToBeFiltered.getUuid()).equals(uuidAndTitleCache.getUuid())) {
+                               if (cdmBaseToBeFiltered != null && cdmBaseToBeFiltered.contains(uuidAndTitleCache.getUuid())) {
                                        uuidAndTitleCacheToRemove = uuidAndTitleCache;
                                }
                        }
                        model.remove(uuidAndTitleCacheToRemove);
                }
        }
+       @Override
+       void createFilterButton(Composite searchAndFilter){
+           //as default no filter button available
+       }
+
+       /** {@inheritDoc} */
+    @Override
+    protected void search() {
+        Control control =getSearchField();
+        String pattern = null;
+        if (control != null){
+            pattern = ((Text)control).getText();
+            if (pattern.equals("*") || pattern.equals("?")){
+                callService(null);
+            }else if (StringUtils.isNotBlank(pattern)){
+//                callService(CdmUtils.replaceNonWordCharacters(pattern, "."));
+                callService(pattern);
+            }
+            fillContentProvider(null);
+        }
+
+//        if (pattern.equals("?")){
+//            model = CdmStore.getService(INameService.class).getUuidAndTitleCache(null, null);
+//        }else if (pattern != null){
+//            model = CdmStore.getService(INameService.class).getUuidAndTitleCache(limitOfInitialElements, pattern);
+//        }
+    }
+
+    abstract void callService(String pattern);
+
 }