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 org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Cursor;
+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 eu.etaxonomy.cdm.api.conversation.ConversationHolder;
protected void fillContentProvider(IProgressMonitor progressMonitor)
throws CoreException {
try {
+ if (model == null){
+ model = new ArrayList<UuidAndTitleCache<T>>();
+ }
if(model != null){
if (progressMonitor != null){
progressMonitor.beginTask("Looking for entities", model.size());
}
this.refresh();
}else{
+
MessagingUtils.warn(getClass(), "Model for Filtered Selection is null:" + this.getClass().getSimpleName());
}
}
*
* @return a {@link java.lang.String} object.
*/
- protected abstract String getNewWizardLinkText();
+ protected abstract String[] getNewWizardText();
/**
* <p>getNewEntityWizard</p>
*/
/** {@inheritDoc} */
+// @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 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 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());
+ }
+ }
+
+ super.createButtonsForButtonBar(parent);
+ }
- protected SelectionListener getNewWizardLinkSelectionListener(){
+ protected SelectionListener getNewWizardButtonSelectionListener(){
return new SelectionAdapter() {
/* (non-Javadoc)
*/
@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) {
model.remove(uuidAndTitleCacheToRemove);
}
}
+ @Override
+ void createFilterButton(Composite searchAndFilter){
+ //as default no filter button available
+ }
}
/**
*
*/
- protected static final String PERSON = "Person";
+ protected static final String PERSON = "new Person";
/**
*
*/
- protected static final String TEAM = "Team";
+ protected static final String TEAM = "new Team";
protected static boolean selectTeamMember;
/** {@inheritDoc} */
@Override
- protected String getNewWizardLinkText() {
+ protected String[] getNewWizardText() {
+ String[] result;
if (this.selectTeamMember){
- return String.format("Create a new <a>%1s</a>", PERSON);
+ result = new String[1];
+ result[0] = PERSON;
+
+ }else{
+ result = new String[2];
+ result[0] = PERSON;
+ result[1] = TEAM;
}
- return String.format("Create a new <a>%1s</a> or <a>%2s</a>", TEAM, PERSON);
+ return result;
}
/* (non-Javadoc)
* @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewWizardLinkSelectionListener()
*/
@Override
- protected SelectionListener getNewWizardLinkSelectionListener() {
- return super.getNewWizardLinkSelectionListener();
+ protected SelectionListener getNewWizardButtonSelectionListener() {
+ return super.getNewWizardButtonSelectionListener();
}
/** {@inheritDoc} */
/** {@inheritDoc} */
@Override
- protected String getNewWizardLinkText() {
- return String.format("Create a new <a>%1s</a>", "Amplification ");
+ protected String[] getNewWizardText() {
+ String[] result = new String[1];
+ result[0] = "Amplification";
+ return result;
}
}
import java.util.UUID;
-import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
super(shell, conversation, title, multi, settings, classification);
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#createExtendedContentArea
- * (org.eclipse.swt.widgets.Composite)
- */
- /** {@inheritDoc} */
- @Override
- protected Control createExtendedContentArea(Composite parent) {
- return null;
- }
+// /*
+// * (non-Javadoc)
+// *
+// * @see
+// * org.eclipse.ui.dialogs.FilteredItemsSelectionDialog#createExtendedContentArea
+// * (org.eclipse.swt.widgets.Composite)
+// */
+// /** {@inheritDoc} */
+// @Override
+// protected Control createExtendedContentArea(Composite parent) {
+// return null;
+// }
/*
* (non-Javadoc)
/** {@inheritDoc} */
@Override
- protected String getNewWizardLinkText() {
+ protected String[] getNewWizardText() {
return null;
}
}
*/
/** {@inheritDoc} */
@Override
- protected String getNewWizardLinkText() {
- return String.format("Create a new <a>%1s</a>", "Collection ");
+ protected String[] getNewWizardText() {
+ return new String[]{ "Collection "};
}
/* (non-Javadoc)
/** {@inheritDoc} */
@Override
- protected String getNewWizardLinkText() {
- return String.format("Create a new <a>%1s</a>", "Unit ");
+ protected String[] getNewWizardText() {
+ return new String[]{ "Unit "};
}
}
/** {@inheritDoc} */
@Override
- protected String getNewWizardLinkText() {
- return String.format("Create a new <a>%1s</a>", "Reference ");
+ protected String[] getNewWizardText() {
+ return new String[]{"Reference "};
}
}
/**
* Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy
+* European Distributed Institute of Taxonomy
* http://www.e-taxonomy.eu
-*
+*
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
"Choose Feature", false, FeatureSelectionDialog.class.getCanonicalName(), feature);
return getSelectionFromDialog(dialog);
}
-
+
/**
* @param shell
* @param conversation
@Override
protected Feature getPersistentObject(UUID uuid) {
-
+
DefinedTermBase<?> term = CdmStore.getService(ITermService.class).load(uuid);
-
+
if(term instanceof Feature){
return (Feature) term;
}
-
+
return null;
}
@Override
protected void search() {
List<Feature> features = CdmStore.getService(ITermService.class).list(Feature.class, null, null, null, null);
-
+
List<UuidAndTitleCache<Feature>> featureUuidAndTitleCache = new ArrayList<UuidAndTitleCache<Feature>>();
-
+
for(Feature feature : features){
UuidAndTitleCache<Feature> uuidAndTitleCache = new UuidAndTitleCache<Feature>(Feature.class, feature.getUuid(), feature.getId(), feature.getTitleCache());
featureUuidAndTitleCache.add(uuidAndTitleCache);
}
-
+
model = featureUuidAndTitleCache;
}
* @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewWizardLinkText()
*/
@Override
- protected String getNewWizardLinkText() {
+ protected String[] getNewWizardText() {
return null;
}
import java.util.List;
import java.util.UUID;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Link;
-import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Shell;
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
}
}
- /** {@inheritDoc} */
- @Override
- protected Control createExtendedContentArea(Composite parent) {
- Link link = new Link(parent, SWT.NONE);
- link.setText(getNewWizardLinkText());
- link.addListener (SWT.Selection, new Listener () {
- @Override
- public void handleEvent(Event event) {
-
- InputDialog input = new InputDialog(getShell(), "New feature tree", "Enter label for new feature tree", null, null);
- int status = input.open();
- if (status == IStatus.OK) {
- String label = input.getValue();
- if(label!=null){
- FeatureTree featureTree = FeatureTree.NewInstance();
- featureTree.setTitleCache(label, false);
- CdmStore.getService(IFeatureTreeService.class).save(featureTree);
- UuidAndTitleCache<FeatureTree> uuidAndTitleCache = new UuidAndTitleCache<FeatureTree>(FeatureTree.class, featureTree.getUuid(),featureTree.getId(), featureTree.getTitleCache());
- model.add(uuidAndTitleCache);
- setPattern(featureTree);
- }
- }
- }
- });
- return link;
- }
+// /** {@inheritDoc} */
+// @Override
+// protected Control createExtendedContentArea(Composite parent) {
+// Link link = new Link(parent, SWT.NONE);
+// link.setText(getNewWizardLinkText());
+// link.addListener (SWT.Selection, new Listener () {
+// @Override
+// public void handleEvent(Event event) {
+//
+// InputDialog input = new InputDialog(getShell(), "New feature tree", "Enter label for new feature tree", null, null);
+// int status = input.open();
+// if (status == IStatus.OK) {
+// String label = input.getValue();
+// if(label!=null){
+// FeatureTree featureTree = FeatureTree.NewInstance();
+// featureTree.setTitleCache(label, false);
+// CdmStore.getService(IFeatureTreeService.class).save(featureTree);
+// UuidAndTitleCache<FeatureTree> uuidAndTitleCache = new UuidAndTitleCache<FeatureTree>(FeatureTree.class, featureTree.getUuid(),featureTree.getId(), featureTree.getTitleCache());
+// model.add(uuidAndTitleCache);
+// setPattern(featureTree);
+// }
+// }
+// }
+// });
+// return link;
+// }
/** {@inheritDoc} */
@Override
- protected String getNewWizardLinkText() {
- return String.format("Create a new <a>%1s</a>" , "Feature tree ");
+ protected String[] getNewWizardText() {
+ return new String[]{ "Feature tree "};
}
/** {@inheritDoc} */
@Override
- protected String getNewWizardLinkText() {
- return String.format("Create a new <a>%1s</a>", "Field Unit ");
+ protected String[] getNewWizardText() {
+ return new String[]{"Field Unit "};
}
}
--- /dev/null
+// $Id$
+/**
+* Copyright (C) 2017 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.taxeditor.ui.dialog.selection;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+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.Shell;
+
+import eu.etaxonomy.cdm.api.service.IVocabularyService;
+import eu.etaxonomy.cdm.model.common.TermType;
+import eu.etaxonomy.cdm.model.common.TermVocabulary;
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
+import eu.etaxonomy.taxeditor.store.CdmStore;
+
+/**
+ * @author k.luther
+ * @date 21.11.2017
+ *
+ */
+public class FilterDialog extends Dialog {
+
+ List<TermVocabulary> vocabularies = new ArrayList<TermVocabulary>();
+
+ List<TermVocabulary> selectedVocabularies = new ArrayList<TermVocabulary>();
+
+ Object preferenceId;
+
+ /**
+ * @param parentShell
+ */
+ protected FilterDialog(Shell parentShell, Object preferenceId, List<TermVocabulary> selectedVocabularies) {
+ super(parentShell);
+ vocabularies = CdmStore.getService(IVocabularyService.class).listByTermType(TermType.NamedArea, true, null, null, null, null);
+ this.preferenceId = preferenceId;
+ List<TermVocabulary> tempSelectedVocabularies = new ArrayList<>();
+ this.selectedVocabularies = selectedVocabularies;
+
+ }
+
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite dialogArea = new Composite(parent, SWT.NULL);
+ dialogArea.setLayout(new GridLayout(1, false));
+ for (TermVocabulary voc: vocabularies){
+ Button btnCheckButton = new Button(dialogArea, SWT.CHECK);
+ btnCheckButton.setText(voc.getLabel());
+ btnCheckButton.setData(voc);
+ if (selectedVocabularies.contains(voc)){
+ btnCheckButton.setSelection(true);
+ }else {
+ btnCheckButton.setSelection(false);
+ }
+
+ btnCheckButton.addSelectionListener(new SelectionListener(){
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (btnCheckButton.getSelection()){
+ Object obj = btnCheckButton.getData();
+ if (!selectedVocabularies.contains(btnCheckButton.getData())){
+ selectedVocabularies.add((TermVocabulary)btnCheckButton.getData());
+ }
+ }else{
+ if (selectedVocabularies.contains(btnCheckButton.getData())){
+ selectedVocabularies.remove(btnCheckButton.getData());
+ }
+ }
+
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ });
+ }
+
+ GridData gd_table = new GridData(SWT.CENTER, SWT.CENTER, true, true, 2, 1);
+ gd_table.heightHint = 231;
+ gd_table.widthHint = 543;
+
+ return dialogArea;
+
+ }
+
+ @Override
+ protected void okPressed(){
+ for (TermVocabulary voc: vocabularies){
+ if (selectedVocabularies.contains(voc)){
+ PreferencesUtil.getPreferenceStore().setValue(getPrefKey(voc), false);
+ } else{
+ PreferencesUtil.getPreferenceStore().setValue(getPrefKey(voc), true);
+ }
+ }
+ super.okPressed();
+ }
+
+ private String getPrefKey(TermVocabulary vocabulary){
+ return "hide_"+NamedAreaSelectionDialog.class.getCanonicalName()+vocabulary.getUuid()+preferenceId;
+ }
+
+}
model = new ArrayList<UuidAndTitleCache<GrantedAuthorityImpl>>();
for(GrantedAuthorityImpl authority : authorities){
-
+
model.add(new UuidAndTitleCache<GrantedAuthorityImpl>(GrantedAuthorityImpl.class, authority.getUuid(), authority.getId(), String.format("%s", GrantedAuthorityLabelTextProvider.getText(authority))));
}
}
* @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewWizardLinkText()
*/
@Override
- protected String getNewWizardLinkText() {
- return String.format("Create a new <a>%1s</a>", "GrantedAuthority ");
+ protected String[] getNewWizardText() {
+ return new String[]{"GrantedAuthority "};
}
@Override
* @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewWizardLinkText()
*/
@Override
- protected String getNewWizardLinkText() {
- return String.format("Create a new <a>%1s</a>", "Group ");
+ protected String[] getNewWizardText() {
+ return new String[]{"Group "};
}
/* (non-Javadoc)
* @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewWizardLinkText()
*/
@Override
- protected String getNewWizardLinkText() {
- return String.format("Create a new <a>%1s</a>", "Institution ");
+ protected String[] getNewWizardText() {
+ return new String[]{"Institution "};
}
/* (non-Javadoc)
/** {@inheritDoc} */
@Override
- protected String getNewWizardLinkText() {
- return "";
+ protected String[] getNewWizardText() {
+ return null;
}
}
/** {@inheritDoc} */
@Override
- protected String getNewWizardLinkText() {
- return String.format("Create a new <a>%1s</a>", "Name ");
+ protected String[] getNewWizardText() {
+ return new String[]{"Name "};
}
}
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
+import org.eclipse.wb.swt.ResourceManager;
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.service.ITermService;
}
PreferencesUtil.getPreferenceStore().setValue(getPrefKey(vocabulary), !isChecked());
search();
- try {
- fillContentProvider(null);
- } catch (CoreException coreException) {
- // TODO Auto-generated catch block
- coreException.printStackTrace();
- }
}
}
protected List<TermVocabulary> selectedVocabularies;
protected ArrayList<TermVocabulary> preselectedVocabularies;
- private Object preferenceID;
+
/**
TermVocabulary preselectedVocabulary = CdmStore.getService(IVocabularyService.class).find(preselectedVocabularyUuids[i]);
preselectedVocabularies.add(preselectedVocabulary);
}
- List<TermVocabulary> tempSelectedVocabularies = new ArrayList<>();
- for(TermVocabulary vocabulary:selectedVocabularies){
+
+
+ selectedVocabularies = createSelectedVocabularies();;
+// search;//re-init to consider pre-selected vocabularies
+ }
+
+ private List<TermVocabulary> createSelectedVocabularies() {
+ List<TermVocabulary> tempSelectedVocabularies = new ArrayList<TermVocabulary>();
+ for(TermVocabulary vocabulary:selectedVocabularies){
if(preselectedVocabularies.contains(vocabulary)
|| !PreferencesUtil.getPreferenceStore().getBoolean(getPrefKey(vocabulary))){
tempSelectedVocabularies.add(vocabulary);
}
}
- selectedVocabularies = tempSelectedVocabularies;
-// search;//re-init to consider pre-selected vocabularies
- }
+ return tempSelectedVocabularies;
+ }
/** {@inheritDoc} */
- @Override
- protected void fillViewMenu(IMenuManager menuManager) {
-
-// super.fillViewMenu(menuManager);
-
- for(TermVocabulary<NamedArea> vocabulary : getAvailableVocabularies()){
- IncludeNamedAreaVocabulary action = new IncludeNamedAreaVocabulary(vocabulary);
- menuManager.add(action);
- if(preselectedVocabularies.contains(vocabulary)) {
- action.setChecked(true);
- }
- else{
- action.setChecked(!PreferencesUtil.getPreferenceStore().getBoolean(getPrefKey(vocabulary)));
- }
- }
- }
+// @Override
+// protected void fillViewMenu(IMenuManager menuManager) {
+//
+//// super.fillViewMenu(menuManager);
+//
+// for(TermVocabulary<NamedArea> vocabulary : getAvailableVocabularies()){
+// IncludeNamedAreaVocabulary action = new IncludeNamedAreaVocabulary(vocabulary);
+// menuManager.add(action);
+// if(preselectedVocabularies.contains(vocabulary)) {
+// action.setChecked(true);
+// }
+// else{
+// action.setChecked(!PreferencesUtil.getPreferenceStore().getBoolean(getPrefKey(vocabulary)));
+// }
+// }
+// }
private String getPrefKey(TermVocabulary vocabulary){
return "hide_"+NamedAreaSelectionDialog.class.getCanonicalName()+vocabulary.getUuid()+preferenceID;
}else{
model = CdmStore.getService(ITermService.class).getUuidAndTitleCache(selectedVocabularies, limitOfInitialElements, pattern, PreferencesUtil.getGlobalLanguage());
}
-
+ try {
+ fillContentProvider(null);
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
// Set<NamedArea> terms = new HashSet<NamedArea>();
// for(TermVocabulary<NamedArea> vocabulary : selectedVocabularies){
// terms.addAll(vocabulary.getTermsOrderedByLabels(CdmStore.getDefaultLanguage()));
// }
}
- /** {@inheritDoc} */
- @Override
- protected Control createExtendedContentArea(Composite parent) {
- return null;
- }
+// /** {@inheritDoc} */
+// @Override
+// protected Control createExtendedContentArea(Composite parent) {
+// return null;
+// }
/** {@inheritDoc} */
@Override
/** {@inheritDoc} */
@Override
- protected String getNewWizardLinkText() {
+ protected String[] getNewWizardText() {
return null;
}
+
+ @Override
+ void createFilterButton(Composite searchAndFilter)
+ {
+ filterButton = new Button(searchAndFilter, SWT.NONE);
+// filterButton.setText("Filter");
+ filterButton.setImage(ResourceManager.getPluginImage("eu.etaxonomy.taxeditor.store", "icons/funnel-icon.png"));
+// SelectionListener filterSelectionListener = new FilterSelectionListener(preferenceID, this);
+ filterButton.addSelectionListener(new SelectionListener(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+
+ Object source = e.getSource();
+ String text = null;
+ if (source instanceof Button){
+ Shell shell = ((Button)source).getShell();
+ Dialog dialog = new FilterDialog(getShell(), preferenceID, selectedVocabularies);
+ if(dialog!=null){
+ dialog.open();
+ }
+ createSelectedVocabularies();
+ }
+
+
+
+
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+
+ });
+
+ }
+
+ /**
+ *
+ */
+ public void setSelectedVocabularies() {
+ // TODO Auto-generated method stub
+
+ }
+
}
/** {@inheritDoc} */
@Override
- protected String getNewWizardLinkText() {
- return String.format("Create a new <a>%1s</a>", "Team ");
+ protected String[] getNewWizardText() {
+ return new String[]{"Team "};
}
/** {@inheritDoc} */
/** {@inheritDoc} */
@Override
- protected String getNewWizardLinkText() {
- return String.format("Create a new <a>%1s</a>", "Person ");
+ protected String[] getNewWizardText() {
+ return new String[]{"Person"};
}
}
* @see eu.etaxonomy.taxeditor.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewWizardLinkText()
*/
@Override
- protected String getNewWizardLinkText() {
+ protected String[] getNewWizardText() {
return null;
}
/** {@inheritDoc} */
@Override
- protected String getNewWizardLinkText() {
- return String.format("Create a new <a>%1s</a>", "Primer ");
+ protected String[] getNewWizardText() {
+ return new String[]{"Primer "};
}
}
/** {@inheritDoc} */
@Override
- protected String getNewWizardLinkText() {
- return String.format("Create a new <a>%1s</a>", "Reference ");
+ protected String[] getNewWizardText() {
+ return new String[]{"Reference "};
}
}
* {@inheritDoc}
*/
@Override
- protected String getNewWizardLinkText() {
- // TODO Auto-generated method stub
+ protected String[] getNewWizardText() {
+
return null;
}
import java.util.Comparator;
import java.util.List;
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.IHandler;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.ListenerList;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.LegacyActionTools;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.swt.accessibility.AccessibleEvent;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.TraverseEvent;
import org.eclipse.swt.events.TraverseListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Rectangle;
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.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.ToolBar;
-import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.ui.IWorkbenchPreferenceConstants;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.FilteredItemsSelectionDialog;
-import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.internal.IWorkbenchGraphicConstants;
import org.eclipse.ui.internal.WorkbenchImages;
import org.eclipse.ui.internal.WorkbenchMessages;
private TableViewer list;
private Text searchField;
private String title;
+ protected Button newButton1;
+
+
+ protected Button newButton2;
+ protected Button filterButton;
private StructuredSelection currentSelection;
// message to show user
private final RefreshCacheJob refreshCacheJob;
private ToolBar toolBar;
- private ToolItem toolItem;
private MenuManager menuManager;
+
+ protected Object preferenceID;
+
+ protected final int new_id = 4;
+ protected final int new_id2 = 5;
// Need to keep our own list of listeners
private final ListenerList listeners = new ListenerList();
contentProvider = new ContentProvider();
refreshCacheJob = new RefreshCacheJob();
+
}
final Label headerLabel = createHeader(container);
- searchField = new Text(container, SWT.SINGLE | SWT.BORDER | SWT.SEARCH | SWT.ICON_CANCEL);
+ Composite searchAndFilter = new Composite(container, container.getStyle());
+// GridData gd_searchAndFilter = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
+ GridData gd_searchAndFilter =new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
+// gd_searchAndFilter.widthHint = 576;
+ searchAndFilter.setLayoutData(gd_searchAndFilter);
+ GridLayout searchAndFilterLayout = new GridLayout();
+ searchAndFilterLayout.numColumns = 2;
+ searchAndFilter.setLayout(searchAndFilterLayout);
+ searchField = new Text(searchAndFilter, SWT.SINGLE | SWT.BORDER | SWT.SEARCH | SWT.ICON_CANCEL);
searchField.getAccessible().addAccessibleListener(new AccessibleAdapter() {
@Override
public void getName(AccessibleEvent e) {
}
}
});
- gd_1 = new GridData(GridData.FILL_HORIZONTAL);
- gd_1.horizontalIndent = 2;
- gd_1.horizontalAlignment = SWT.CENTER;
- gd_1.widthHint = 575;
+ gd_1 = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
+
+// gd_1.horizontalIndent = 2;
+// gd_1.horizontalAlignment = SWT.CENTER;
+// gd_1.grabExcessHorizontalSpace = true;
+// gd_1.widthHint = 500;
searchField.setLayoutData(gd_1);
+ createFilterButton(searchAndFilter);
setList(new TableViewer(container, SWT.SINGLE
| SWT.BORDER | SWT.V_SCROLL | SWT.VIRTUAL));
okPressed();
}
});
- createExtendedContentArea(container);
+// createExtendedContentArea(container);
+ new Label(container, SWT.NONE);
return container;
}
+
+ abstract void createFilterButton(Composite searchAndFilter) ;
+
protected abstract void search();
/**
* parent to create the dialog widgets in
* @return an extra content area
*/
- protected abstract Control createExtendedContentArea(Composite parent);
+// protected abstract Control createExtendedContentArea(Composite parent);
/**
* Sets the title for this dialog.
*/
private Label createHeader(Composite parent) {
Composite header = new Composite(parent, SWT.NONE);
- GridData gd_header = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1);
+ GridData gd_header = new GridData(SWT.CENTER, SWT.CENTER, false, false, 2, 1);
gd_header.widthHint = 575;
header.setLayoutData(gd_header);
layout.marginWidth = 0;
layout.marginHeight = 0;
header.setLayout(layout);
-
- createViewMenu(header);
-
+ new Label(header, SWT.NONE);
Label headerLabel = new Label(header, SWT.NONE);
headerLabel.setText((getMessage() != null && getMessage().trim()
.length() > 0) ? getMessage()
gd_headerLabel.verticalAlignment = SWT.BOTTOM;
gd_headerLabel.minimumHeight = 10;
headerLabel.setLayoutData(gd_headerLabel);
- new Label(header, SWT.NONE);
-
return headerLabel;
}
}
return itemsListLabelProvider;
}
- private void createViewMenu(Composite parent) {
- toolBar = new ToolBar(parent, SWT.FLAT);
- toolItem = new ToolItem(toolBar, SWT.PUSH, 0);
-
- GridData data = new GridData();
- data.horizontalAlignment = GridData.END;
- data.grabExcessHorizontalSpace = true;
- toolBar.setLayoutData(data);
-
-// toolBar.addMouseListener(new MouseAdapter() {
+// private void createViewMenu(Composite parent) {
+// toolBar = new ToolBar(parent, SWT.FLAT);
+//
+// GridData data = new GridData();
+// data.horizontalAlignment = GridData.END;
+// data.grabExcessHorizontalSpace = true;
+// toolBar.setLayoutData(data);
+//
+// menuManager = new MenuManager();
+//
+// fillViewMenu(menuManager);
+//
+// IHandlerService service = PlatformUI.getWorkbench()
+// .getService(IHandlerService.class);
+// IHandler handler = new AbstractHandler() {
// @Override
-// public void mouseDown(MouseEvent e) {
+// public Object execute(ExecutionEvent event) {
// showViewMenu();
+// return null;
// }
-// });
+// };
+// }
+
+// /**
+// * Fills the menu of the dialog.
+// *
+// * @param menuManager
+// * the menu manager
+// */
+// protected void fillViewMenu(IMenuManager menuManager) {
+//
+// }
+
+// private void showViewMenu() {
+// Menu menu = menuManager.createContextMenu(getShell());
+// Rectangle bounds = toolItem.getBounds();
+// Point topLeft = new Point(bounds.x, bounds.y + bounds.height);
+// topLeft = toolBar.toDisplay(topLeft);
+// menu.setLocation(topLeft.x, topLeft.y);
+// menu.setVisible(true);
+// }
- toolItem.setImage(WorkbenchImages
- .getImage(IWorkbenchGraphicConstants.IMG_LCL_VIEW_MENU));
- toolItem
- .setToolTipText(WorkbenchMessages.FilteredItemsSelectionDialog_menu);
- toolItem.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- showViewMenu();
- }
- });
+ public TableViewer getList() {
+ return list;
+ }
- menuManager = new MenuManager();
+ public void setList(TableViewer list) {
+ this.list = list;
+ Table table = list.getTable();
+ GridData gd_table = new GridData(SWT.CENTER, SWT.CENTER, true, true, 2, 1);
+ gd_table.heightHint = 231;
+ gd_table.widthHint = 543;
+ table.setLayoutData(gd_table);
+ }
- fillViewMenu(menuManager);
+ public Button getNewButton1() {
+ return newButton1;
+ }
- IHandlerService service = PlatformUI.getWorkbench()
- .getService(IHandlerService.class);
- IHandler handler = new AbstractHandler() {
- @Override
- public Object execute(ExecutionEvent event) {
- showViewMenu();
- return null;
- }
- };
+
+ public void setNewButton1(Button newButton1) {
+ this.newButton1 = newButton1;
}
- /**
- * Fills the menu of the dialog.
- *
- * @param menuManager
- * the menu manager
- */
- protected void fillViewMenu(IMenuManager menuManager) {
+ public Button getNewButton2() {
+ return newButton2;
}
- private void showViewMenu() {
- Menu menu = menuManager.createContextMenu(getShell());
- Rectangle bounds = toolItem.getBounds();
- Point topLeft = new Point(bounds.x, bounds.y + bounds.height);
- topLeft = toolBar.toDisplay(topLeft);
- menu.setLocation(topLeft.x, topLeft.y);
- menu.setVisible(true);
+
+ public void setNewButton2(Button newButton2) {
+ this.newButton2 = newButton2;
}
- public TableViewer getList() {
- return list;
+
+ public Button getFilterButton() {
+ return filterButton;
}
- public void setList(TableViewer list) {
- this.list = list;
- Table table = list.getTable();
- GridData gd_table = new GridData(SWT.CENTER, SWT.CENTER, true, true, 1, 1);
- gd_table.heightHint = 231;
- gd_table.widthHint = 543;
- table.setLayoutData(gd_table);
+
+ public void setFilterButton(Button filterButton) {
+ this.filterButton = filterButton;
}
/**
return new Point(593, 399);
}
+
+
}
return null;
}
+ public static <T extends ICdmBase> T getSelectionFromExtDialog(Class<T> clazz, Shell shell, ConversationHolder conversation, ICdmFormElement parentElement){
+ return (T) ExtReferenceSelectionDialog.select(shell, conversation, null);
+ }
+
+
}
--- /dev/null
+// $Id$
+/**
+* Copyright (C) 2017 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.taxeditor.ui.dialog.selection;
+
+import java.util.List;
+
+import org.eclipse.e4.ui.di.AboutToShow;
+import org.eclipse.e4.ui.model.application.commands.MCommand;
+import org.eclipse.e4.ui.model.application.commands.MCommandsFactory;
+import org.eclipse.e4.ui.model.application.ui.menu.MHandledMenuItem;
+import org.eclipse.e4.ui.model.application.ui.menu.MMenu;
+import org.eclipse.e4.ui.model.application.ui.menu.MMenuElement;
+import org.eclipse.e4.ui.model.application.ui.menu.MMenuFactory;
+
+import eu.etaxonomy.cdm.model.common.TermVocabulary;
+import eu.etaxonomy.cdm.model.location.NamedArea;
+import eu.etaxonomy.taxeditor.l10n.Messages;
+
+/**
+ * @author k.luther
+ * @date 20.11.2017
+ *
+ */
+public class SelectionViewMenu {
+
+ public static final String COMMAND_ID = "taxeditor-selection.command.selectViewMenu"; //$NON-NLS-1$
+ public static final String COMMAND_PARAMETER_VOCABULARY = COMMAND_ID+".vocabulary"; //$NON-NLS-1$
+ public static final String COMMAND_PARAMETER_VOCABULARY_STATE = COMMAND_ID+".state"; //$NON-NLS-1$
+
+ @AboutToShow
+ public void aboutToShow(List<MMenuElement> items, List<TermVocabulary> vocabularies) {
+
+ MMenu menu = MMenuFactory.INSTANCE.createMenu();
+ menu.setLabel(Messages.SelectionViewMenu_selectVocabulary);
+ items.add(menu);
+ for(TermVocabulary<NamedArea> vocabulary: vocabularies){
+ createMenuItem(menu, vocabulary);
+ }
+ }
+
+
+ private void createMenuItem(MMenu menu, final TermVocabulary<NamedArea> vocabulary) {
+
+ MMenu subMenu = MMenuFactory.INSTANCE.createMenu();
+ subMenu.setLabel(String.format(Messages.SelectionViewMenu_SET_FLAG, vocabulary.getLabel()));
+ menu.getChildren().add(subMenu);
+
+ MHandledMenuItem subMenuItemYes = MMenuFactory.INSTANCE.createHandledMenuItem();
+ subMenuItemYes.setLabel(Messages.SelectionViewMenu_4_YES);
+ MCommand mCommandYes = MCommandsFactory.INSTANCE.createCommand();
+ mCommandYes.setElementId(COMMAND_ID);
+ //set params
+ subMenuItemYes.getTransientData().put(COMMAND_PARAMETER_VOCABULARY, vocabulary);
+ subMenuItemYes.getTransientData().put(COMMAND_PARAMETER_VOCABULARY_STATE, true);
+ subMenuItemYes.setCommand(mCommandYes);
+ subMenu.getChildren().add(subMenuItemYes);
+
+ MHandledMenuItem subMenuItemNo = MMenuFactory.INSTANCE.createHandledMenuItem();
+ subMenuItemNo.setLabel(Messages.SelectionViewMenu_NO);
+ MCommand mCommandNo = MCommandsFactory.INSTANCE.createCommand();
+ mCommandNo.setElementId(COMMAND_ID);
+// //set params
+// subMenuItemNo.getTransientData().put(COMMAND_PARAMETER_MARKER_TYPE, markerType);
+// subMenuItemNo.getTransientData().put(COMMAND_PARAMETER_MARKER_STATE, false);
+// subMenuItemNo.setCommand(mCommandNo);
+// subMenu.getChildren().add(subMenuItemNo);
+ }
+}
/** {@inheritDoc} */
@Override
- protected String getNewWizardLinkText() {
- return String.format("Create a new <a>%1s</a>", "field unit/derived unit");
+ protected String[] getNewWizardText() {
+ return new String[]{"field unit/derived unit"};
}
}
/** {@inheritDoc} */
@Override
- protected String getNewWizardLinkText() {
- return String.format("Create a new <a>%1s</a>", "Taxon ");
+ protected String[] getNewWizardText() {
+ return new String[]{"Taxon "};
}
}
import java.util.List;
import java.util.UUID;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
if(classification != null){
selectedClassification = classification;
}
- search();
+
+ fillClassifications();
+ createClassificationSelectionCombo(shell);
}
/** {@inheritDoc} */
@Override
- protected Control createExtendedContentArea(Composite parent) {
- return createClassificationSelectionCombo(parent);
+ protected Control createDialogArea(Composite parent) {
+ Composite container = (Composite) super.createDialogArea(parent);
+ return createClassificationSelectionCombo(container);
}
/*
}
- if(classifications == null){
+// fillClassifications();
+ if (pattern == null || pattern.equals("?")){
+ model = CdmStore.getService(IClassificationService.class).getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(selectedClassification.getUuid(), null, null);
+ }else{
+ model = CdmStore.getService(IClassificationService.class).getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(selectedClassification.getUuid(), limitOfInitialElements, pattern);
+ }
+ try {
+ fillContentProvider(null);
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ private void fillClassifications() {
+ if(classifications == null){
classifications = CdmStore.getService(IClassificationService.class).list(null, null, null, null, null);
Collections.sort(classifications, new Comparator<Classification>() {
selectedClassification = this.cdmBaseToBeFiltered.getClassification();
}
}
- if (pattern == null || pattern.equals("?")){
- model = CdmStore.getService(IClassificationService.class).getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(selectedClassification.getUuid(), limitOfInitialElements, pattern);
- }else{
- model = CdmStore.getService(IClassificationService.class).getTaxonNodeUuidAndTitleCacheOfAcceptedTaxaByClassification(selectedClassification.getUuid(), null, null);
- }
- }
+ }
/** {@inheritDoc} */
@Override
/** {@inheritDoc} */
@Override
- protected String getNewWizardLinkText() {
+ protected String[] getNewWizardText() {
return null;
}
selectedClassification = classifications.get(classificationSelectionCombo.getSelectionIndex());
// refresh();
- setPattern(null);
+ if (getSearchField().getText() != null){
+ search();
+ }
}
/** {@inheritDoc} */
/** {@inheritDoc} */
@Override
- protected String getNewWizardLinkText() {
- return String.format("Create a new <a>%1s</a>", "Team ");
+ protected String[] getNewWizardText() {
+ return new String[]{"Team "};
}
/** {@inheritDoc} */
* @see eu.etaxonomy.taxeditor.ui.dialogs.filteredSelection.AbstractFilteredCdmResourceSelectionDialog#getNewWizardLinkText()
*/
@Override
- protected String getNewWizardLinkText() {
- return String.format("Create a new <a>%1s</a>", "User ");
+ protected String[] getNewWizardText() {
+ return new String[]{"User"};
}
/* (non-Javadoc)