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.jface.dialogs.IDialogConstants;
import org.eclipse.jface.viewers.DelegatingStyledCellLabelProvider.IStyledLabelProvider;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IColorProvider;
import org.eclipse.swt.SWT;
import org.eclipse.swt.accessibility.AccessibleAdapter;
import org.eclipse.swt.accessibility.AccessibleEvent;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
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;
import org.eclipse.ui.internal.WorkbenchPlugin;
-import eu.etaxonomy.cdm.api.conversation.IConversationEnabled;
import eu.etaxonomy.cdm.model.common.ICdmBase;
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
import eu.etaxonomy.taxeditor.l10n.Messages;
* @date 15.11.2017
*
*/
-public abstract class SearchDialog<T extends ICdmBase> extends Dialog implements IConversationEnabled{
+public abstract class SearchDialog<T extends ICdmBase> extends Dialog{// implements IConversationEnabled{
private TableViewer list;
private Text searchField;
private String title;
+ protected Button newButton1;
+
+
+ protected Button newButton2;
+ protected Button filterButton;
+ protected Button btnCheckButton;
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;
+ protected final int space_id = 6;
// Need to keep our own list of listeners
private final ListenerList listeners = new ListenerList();
private static final String EMPTY_STRING = ""; //$NON-NLS-1$
private GridData gd_1;
+ protected boolean useIdentifier;
- public SearchDialog(Shell parent, boolean multi) {
+ public SearchDialog(Shell parent, String title) {
super(parent);
+ this.title = title;
contentProvider = new ContentProvider();
refreshCacheJob = new RefreshCacheJob();
}
+ @Override
+ public void create() {
+ // TODO Auto-generated method stub
+ super.create();
+ refresh();
+ }
+
+ @Override
+ protected void configureShell(Shell shell) {
+ super.configureShell(shell);
+ shell.setText(title);
+ }
@Override
protected Control createDialogArea(Composite parent) {
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());
+
+ searchAndFilter.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
+ 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) {
@Override
public void modifyText(ModifyEvent e) {
search();
- try {
- fillContentProvider(null);
- } catch (CoreException coreException) {
- // TODO Auto-generated catch block
- coreException.printStackTrace();
- }
+// fillContentProvider(null);
+
}
});
- 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 = 7;
+
searchField.setLayoutData(gd_1);
+ createFilterButton(searchAndFilter);
+
+ addIdentifierCheckButton(searchAndFilter);
+// new Label(searchAndFilter, SWT.NONE);
setList(new TableViewer(container, SWT.SINGLE
| SWT.BORDER | SWT.V_SCROLL | SWT.VIRTUAL));
okPressed();
}
});
- createExtendedContentArea(container);
+ searchField.addKeyListener(new KeyAdapter() {
+ @Override
+ public void keyPressed(KeyEvent e) {
+ if (e.keyCode == SWT.ARROW_DOWN) {
+ if (getList().getTable().getItemCount() > 0) {
+ getList().getTable().setFocus();
+ }
+ }
+ }
+ });
+
+// createExtendedContentArea(container);
+ new Label(container, SWT.NONE);
+ search();
return container;
}
- protected abstract void search();
-
- /**
- * Creates an extra content area, which will be located above the details.
- *
- * @param parent
- * parent to create the dialog widgets in
- * @return an extra content area
- */
- protected abstract Control createExtendedContentArea(Composite parent);
- /**
- * Sets the title for this dialog.
- *
- * @param title
- * the title
- */
- public void setTitle(String title) {
- this.title = title;
+ protected void addIdentifierCheckButton(Composite searchAndFilter) {
+ //as default do nothing
}
+
+ abstract void createFilterButton(Composite searchAndFilter) ;
+
+ protected abstract void search();
+
+
/**
* Create a new header which is labelled by headerLabel.
*
*/
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.horizontalIndent = 5;
gd_header.widthHint = 575;
header.setLayoutData(gd_header);
GridLayout layout = new GridLayout();
+ layout.marginLeft = 5;
+ layout.horizontalSpacing = 0;
layout.verticalSpacing = 1;
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() {
-// @Override
-// public void mouseDown(MouseEvent e) {
-// showViewMenu();
-// }
-// });
-
- 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();
- }
- });
-
- menuManager = new MenuManager();
-
- fillViewMenu(menuManager);
-
- IHandlerService service = PlatformUI.getWorkbench()
- .getService(IHandlerService.class);
- IHandler handler = new AbstractHandler() {
- @Override
- 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);
- }
public TableViewer getList() {
return list;
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);
+ 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);
}
+ public Button getNewButton1() {
+ return newButton1;
+ }
+
+
+ public void setNewButton1(Button newButton1) {
+ this.newButton1 = newButton1;
+ }
+
+
+ public Button getNewButton2() {
+ return newButton2;
+ }
+
+
+ public void setNewButton2(Button newButton2) {
+ this.newButton2 = newButton2;
+ }
+
+
+ public Button getFilterButton() {
+ return filterButton;
+ }
+
+
+ public void setFilterButton(Button filterButton) {
+ this.filterButton = filterButton;
+ }
+
/**
* Sets a new label provider for items in the list. If the label provider
* also implements {@link
}
+ public boolean isUseIdentifier() {
+ return useIdentifier;
+ }
+
public StructuredSelection getCurrentSelection() {
return currentSelection;
* progress monitor reflects the state of the filtering process.
* @throws CoreException
*/
- protected abstract void fillContentProvider(IProgressMonitor progressMonitor) throws CoreException;
+ protected abstract void fillContentProvider(IProgressMonitor progressMonitor) ;
/**
getList().getTable().setSelection(0);
getList().getTable().notifyListeners(SWT.Selection, new Event());
}
+ if ( super.getButton(IDialogConstants.OK_ID) != null){
+ super.getButton(IDialogConstants.OK_ID).setEnabled(true);
+ }
} else {
getList().setSelection(StructuredSelection.EMPTY);
}
}
if (SearchDialog.this != null) {
-
- try {
- SearchDialog.this.fillContentProvider(monitor);
- } catch (CoreException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ SearchDialog.this.fillContentProvider(monitor);
}
return new Status(IStatus.OK, PlatformUI.PLUGIN_ID, IStatus.OK,
return new Point(593, 399);
}
+
+
}