import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
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.TraverseEvent;
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.ui.IWorkbenchPreferenceConstants;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.FilteredItemsSelectionDialog;
protected Button newButton2;
protected Button filterButton;
+ protected Button btnCheckButton;
private StructuredSelection currentSelection;
// message to show user
private final RefreshCacheJob refreshCacheJob;
- private ToolBar toolBar;
- 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);
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);
+
+ searchAndFilter.setLayoutData(new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL));
GridLayout searchAndFilterLayout = new GridLayout();
searchAndFilterLayout.numColumns = 2;
searchAndFilter.setLayout(searchAndFilterLayout);
@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.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
+ gd_1.horizontalIndent = 7;
-// gd_1.horizontalIndent = 2;
-// gd_1.horizontalAlignment = SWT.CENTER;
-// gd_1.grabExcessHorizontalSpace = true;
-// gd_1.widthHint = 500;
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();
}
});
+ 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 void addIdentifierCheckButton(Composite searchAndFilter) {
+ //as default do nothing
+ }
+
+
abstract void createFilterButton(Composite searchAndFilter) ;
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;
- }
/**
* 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, 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;
}
return itemsListLabelProvider;
}
-// 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 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 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,