use of org.springsource.ide.eclipse.commons.quicksearch.util.TableResizeHelper in project eclipse-integration-commons by spring-projects.
the class QuickSearchDialog method createDialogArea.
// /**
// * 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);
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createDialogArea(Composite parent) {
Composite dialogArea = (Composite) super.createDialogArea(parent);
dialogArea.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
QuickSearchDialog.this.dispose();
}
});
Composite content = new Composite(dialogArea, SWT.NONE);
GridData gd = new GridData(GridData.FILL_BOTH);
content.setLayoutData(gd);
GridLayout layout = new GridLayout();
layout.numColumns = 1;
layout.marginWidth = 0;
layout.marginHeight = 0;
content.setLayout(layout);
final Label headerLabel = createHeader(content);
pattern = new Text(content, SWT.SINGLE | SWT.BORDER | SWT.SEARCH | SWT.ICON_CANCEL);
pattern.getAccessible().addAccessibleListener(new AccessibleAdapter() {
public void getName(AccessibleEvent e) {
e.result = LegacyActionTools.removeMnemonics(headerLabel.getText());
}
});
gd = new GridData(GridData.FILL_HORIZONTAL);
pattern.setLayoutData(gd);
final Label listLabel = createLabels(content);
sashForm = new SashForm(content, SWT.VERTICAL);
GridDataFactory.fillDefaults().grab(true, true).applyTo(sashForm);
list = new TableViewer(sashForm, (multi ? SWT.MULTI : SWT.SINGLE) | SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL | SWT.VIRTUAL);
// ColumnViewerToolTipSupport.enableFor(list, ToolTip.NO_RECREATE);
list.getTable().setHeaderVisible(true);
list.getTable().setLinesVisible(true);
list.getTable().getAccessible().addAccessibleListener(new AccessibleAdapter() {
public void getName(AccessibleEvent e) {
if (e.childID == ACC.CHILDID_SELF) {
e.result = LegacyActionTools.removeMnemonics(listLabel.getText());
}
}
});
list.setContentProvider(contentProvider);
// new ScrollListener(list.getTable().getVerticalBar());
// new SelectionChangedListener(list);
TableViewerColumn col = new TableViewerColumn(list, SWT.RIGHT);
col.setLabelProvider(LINE_NUMBER_LABEL_PROVIDER);
col.getColumn().setText("Line");
col.getColumn().setWidth(40);
col = new TableViewerColumn(list, SWT.LEFT);
col.getColumn().setText("Text");
col.setLabelProvider(LINE_TEXT_LABEL_PROVIDER);
col.getColumn().setWidth(400);
col = new TableViewerColumn(list, SWT.LEFT);
col.getColumn().setText("Path");
col.setLabelProvider(LINE_FILE_LABEL_PROVIDER);
col.getColumn().setWidth(150);
new TableResizeHelper(list).enableResizing();
// list.setLabelProvider(getItemsListLabelProvider());
list.setInput(new Object[0]);
list.setItemCount(contentProvider.getNumberOfElements());
gd = new GridData(GridData.FILL_BOTH);
applyDialogFont(list.getTable());
gd.heightHint = list.getTable().getItemHeight() * 15;
list.getTable().setLayoutData(gd);
createPopupMenu();
pattern.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
applyFilter();
}
});
pattern.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if (e.keyCode == SWT.ARROW_DOWN) {
if (list.getTable().getItemCount() > 0) {
list.getTable().setFocus();
list.getTable().select(0);
// programatic selection may not fire selection events so...
refreshDetails();
}
}
}
});
list.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
StructuredSelection selection = (StructuredSelection) event.getSelection();
handleSelected(selection);
}
});
list.addDoubleClickListener(new IDoubleClickListener() {
public void doubleClick(DoubleClickEvent event) {
handleDoubleClick();
}
});
list.getTable().addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent e) {
if (e.keyCode == SWT.ARROW_UP && (e.stateMask & SWT.SHIFT) == 0 && (e.stateMask & SWT.CTRL) == 0) {
StructuredSelection selection = (StructuredSelection) list.getSelection();
if (selection.size() == 1) {
Object element = selection.getFirstElement();
if (element.equals(list.getElementAt(0))) {
pattern.setFocus();
}
list.getTable().notifyListeners(SWT.Selection, new Event());
}
}
if (e.keyCode == SWT.ARROW_DOWN && (e.stateMask & SWT.SHIFT) != 0 && (e.stateMask & SWT.CTRL) != 0) {
list.getTable().notifyListeners(SWT.Selection, new Event());
}
}
});
createDetailsArea(sashForm);
sashForm.setWeights(new int[] { 5, 1 });
applyDialogFont(content);
restoreDialog(getDialogSettings());
if (initialPatternText != null) {
pattern.setText(initialPatternText);
}
switch(selectionMode) {
case CARET_BEGINNING:
pattern.setSelection(0, 0);
break;
case FULL_SELECTION:
pattern.setSelection(0, initialPatternText.length());
break;
}
// apply filter even if pattern is empty (display history)
applyFilter();
return dialogArea;
}
Aggregations