|
Lines 17-23
Link Here
|
| 17 |
import java.util.HashSet; |
17 |
import java.util.HashSet; |
| 18 |
import java.util.List; |
18 |
import java.util.List; |
| 19 |
import java.util.Set; |
19 |
import java.util.Set; |
| 20 |
|
20 |
import java.util.regex.PatternSyntaxException; |
| 21 |
import org.eclipse.core.resources.WorkspaceJob; |
21 |
import org.eclipse.core.resources.WorkspaceJob; |
| 22 |
import org.eclipse.core.runtime.IProgressMonitor; |
22 |
import org.eclipse.core.runtime.IProgressMonitor; |
| 23 |
import org.eclipse.core.runtime.IStatus; |
23 |
import org.eclipse.core.runtime.IStatus; |
|
Lines 39-50
Link Here
|
| 39 |
import org.eclipse.jface.viewers.LabelProvider; |
39 |
import org.eclipse.jface.viewers.LabelProvider; |
| 40 |
import org.eclipse.jface.viewers.SelectionChangedEvent; |
40 |
import org.eclipse.jface.viewers.SelectionChangedEvent; |
| 41 |
import org.eclipse.jface.viewers.Viewer; |
41 |
import org.eclipse.jface.viewers.Viewer; |
|
|
42 |
import org.eclipse.jface.viewers.ViewerFilter; |
| 42 |
import org.eclipse.jface.viewers.ViewerSorter; |
43 |
import org.eclipse.jface.viewers.ViewerSorter; |
| 43 |
import org.eclipse.jface.wizard.IWizardPage; |
44 |
import org.eclipse.jface.wizard.IWizardPage; |
| 44 |
import org.eclipse.jface.wizard.WizardPage; |
45 |
import org.eclipse.jface.wizard.WizardPage; |
| 45 |
import org.eclipse.jpt.common.ui.internal.util.SWTUtil; |
46 |
import org.eclipse.jpt.common.ui.internal.util.SWTUtil; |
| 46 |
import org.eclipse.jpt.common.ui.internal.util.TableLayoutComposite; |
47 |
import org.eclipse.jpt.common.ui.internal.util.TableLayoutComposite; |
| 47 |
import org.eclipse.jpt.common.utility.internal.CollectionTools; |
48 |
import org.eclipse.jpt.common.utility.internal.CollectionTools; |
|
|
49 |
import org.eclipse.jpt.common.utility.internal.Tools; |
| 48 |
import org.eclipse.jpt.jpa.core.JpaProject; |
50 |
import org.eclipse.jpt.jpa.core.JpaProject; |
| 49 |
import org.eclipse.jpt.jpa.db.ConnectionProfile; |
51 |
import org.eclipse.jpt.jpa.db.ConnectionProfile; |
| 50 |
import org.eclipse.jpt.jpa.db.Schema; |
52 |
import org.eclipse.jpt.jpa.db.Schema; |
|
Lines 58-63
Link Here
|
| 58 |
import org.eclipse.swt.SWT; |
60 |
import org.eclipse.swt.SWT; |
| 59 |
import org.eclipse.swt.events.KeyAdapter; |
61 |
import org.eclipse.swt.events.KeyAdapter; |
| 60 |
import org.eclipse.swt.events.KeyEvent; |
62 |
import org.eclipse.swt.events.KeyEvent; |
|
|
63 |
import org.eclipse.swt.events.KeyListener; |
| 64 |
import org.eclipse.swt.events.SelectionAdapter; |
| 61 |
import org.eclipse.swt.events.SelectionEvent; |
65 |
import org.eclipse.swt.events.SelectionEvent; |
| 62 |
import org.eclipse.swt.events.SelectionListener; |
66 |
import org.eclipse.swt.events.SelectionListener; |
| 63 |
import org.eclipse.swt.graphics.Color; |
67 |
import org.eclipse.swt.graphics.Color; |
|
Lines 67-76
Link Here
|
| 67 |
import org.eclipse.swt.widgets.Button; |
71 |
import org.eclipse.swt.widgets.Button; |
| 68 |
import org.eclipse.swt.widgets.Composite; |
72 |
import org.eclipse.swt.widgets.Composite; |
| 69 |
import org.eclipse.swt.widgets.Control; |
73 |
import org.eclipse.swt.widgets.Control; |
| 70 |
import org.eclipse.swt.widgets.Display; |
|
|
| 71 |
import org.eclipse.swt.widgets.Label; |
74 |
import org.eclipse.swt.widgets.Label; |
| 72 |
import org.eclipse.swt.widgets.TableColumn; |
75 |
import org.eclipse.swt.widgets.TableColumn; |
| 73 |
import org.eclipse.swt.widgets.TableItem; |
76 |
import org.eclipse.swt.widgets.TableItem; |
|
|
77 |
import org.eclipse.swt.widgets.Text; |
| 74 |
import org.eclipse.ui.PlatformUI; |
78 |
import org.eclipse.ui.PlatformUI; |
| 75 |
import org.eclipse.ui.help.IWorkbenchHelpSystem; |
79 |
import org.eclipse.ui.help.IWorkbenchHelpSystem; |
| 76 |
|
80 |
|
|
Lines 90-95
Link Here
|
| 90 |
private Button refreshTablesButton; |
94 |
private Button refreshTablesButton; |
| 91 |
private Button selectAllButton; |
95 |
private Button selectAllButton; |
| 92 |
private Button deselectAllButton; |
96 |
private Button deselectAllButton; |
|
|
97 |
private Text searchText; |
| 98 |
private SearchFilter filter; |
| 93 |
|
99 |
|
| 94 |
private WorkspaceJob fetchTablesJob; |
100 |
private WorkspaceJob fetchTablesJob; |
| 95 |
protected final ResourceManager resourceManager; |
101 |
protected final ResourceManager resourceManager; |
|
Lines 192-201
Link Here
|
| 192 |
tableLabel.setLayoutData(gridData); |
198 |
tableLabel.setLayoutData(gridData); |
| 193 |
tableLabel.setText(JptUiEntityGenMessages.GenerateEntitiesWizard_tableSelectPage_tables ); |
199 |
tableLabel.setText(JptUiEntityGenMessages.GenerateEntitiesWizard_tableSelectPage_tables ); |
| 194 |
|
200 |
|
|
|
201 |
this.searchText = this.buildSearchText(parent); |
| 202 |
|
| 203 |
// build two empty labels to align the components |
| 204 |
new Label(parent, SWT.NONE); |
| 205 |
new Label(parent, SWT.NONE); |
| 206 |
|
| 195 |
TableLayoutComposite layout = new TableLayoutComposite(parent, SWT.NONE); |
207 |
TableLayoutComposite layout = new TableLayoutComposite(parent, SWT.NONE); |
| 196 |
this.addColumnLayoutData(layout); |
208 |
this.addColumnLayoutData(layout); |
| 197 |
|
209 |
|
|
|
210 |
filter = new SearchFilter(); |
| 198 |
this.tableTable = this.buildCheckboxTableViewer(this.buildTable(layout)); |
211 |
this.tableTable = this.buildCheckboxTableViewer(this.buildTable(layout)); |
|
|
212 |
this.tableTable.addFilter(filter); |
| 199 |
|
213 |
|
| 200 |
this.createButtonComposite(parent); |
214 |
this.createButtonComposite(parent); |
| 201 |
this.initTablesSelectionControl(this.possibleTables()); |
215 |
this.initTablesSelectionControl(this.possibleTables()); |
|
Lines 453-458
Link Here
|
| 453 |
private IContentProvider buildTableTableContentProvider() { |
467 |
private IContentProvider buildTableTableContentProvider() { |
| 454 |
return new TableTableContentProvider(); |
468 |
return new TableTableContentProvider(); |
| 455 |
} |
469 |
} |
|
|
470 |
|
| 471 |
private Text buildSearchText(Composite parent) { |
| 472 |
GridData gridData = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL); |
| 473 |
Text text = new Text(parent, SWT.BORDER | SWT.SEARCH | SWT.ICON_SEARCH | SWT.ICON_CANCEL); |
| 474 |
text.setMessage(JptUiEntityGenMessages.GenerateEntitiesWizard_tableSelectPage_tableSearch); |
| 475 |
text.setLayoutData(gridData); |
| 476 |
text.addSelectionListener(this.buildClearSearchTextSelectionListener()); |
| 477 |
text.addKeyListener(this.buildSearchTextKeyListener()); |
| 478 |
return text; |
| 479 |
} |
| 456 |
|
480 |
|
| 457 |
// ********** listeners callbacks ********** |
481 |
// ********** listeners callbacks ********** |
| 458 |
|
482 |
|
|
Lines 534-539
Link Here
|
| 534 |
|
558 |
|
| 535 |
public void widgetSelected(SelectionEvent e) { |
559 |
public void widgetSelected(SelectionEvent e) { |
| 536 |
refreshTables(); |
560 |
refreshTables(); |
|
|
561 |
} |
| 562 |
}; |
| 563 |
} |
| 564 |
|
| 565 |
private SelectionListener buildClearSearchTextSelectionListener() { |
| 566 |
return new SelectionAdapter() { |
| 567 |
public void widgetDefaultSelected(SelectionEvent e) { |
| 568 |
filter.setSearchText(""); |
| 569 |
tableTable.refresh(); |
| 570 |
} |
| 571 |
}; |
| 572 |
} |
| 573 |
|
| 574 |
private KeyListener buildSearchTextKeyListener() { |
| 575 |
return new KeyAdapter() { |
| 576 |
public void keyReleased(KeyEvent event) { |
| 577 |
filter.setSearchText(searchText.getText()); |
| 578 |
tableTable.refresh(); |
| 537 |
} |
579 |
} |
| 538 |
}; |
580 |
}; |
| 539 |
} |
581 |
} |
|
Lines 764-767
Link Here
|
| 764 |
return ((Collection<?>) inputElement).toArray(); |
806 |
return ((Collection<?>) inputElement).toArray(); |
| 765 |
} |
807 |
} |
| 766 |
} |
808 |
} |
| 767 |
} |
809 |
|
|
|
810 |
private class SearchFilter extends ViewerFilter { |
| 811 |
|
| 812 |
private String inputString; |
| 813 |
private boolean exLogged; |
| 814 |
private String oldInput; |
| 815 |
private String newInput; |
| 816 |
|
| 817 |
public void setSearchText(String givenStr) { |
| 818 |
// Input string must be a substring of the existing value and is case-sensitive |
| 819 |
inputString = ".*" + givenStr + ".*"; |
| 820 |
newInput = givenStr; |
| 821 |
|
| 822 |
} |
| 823 |
|
| 824 |
@Override |
| 825 |
public boolean select(Viewer viewer, Object parentElement, Object element) { |
| 826 |
if (inputString == null || inputString.length() == 0) { |
| 827 |
return true; |
| 828 |
} |
| 829 |
|
| 830 |
Table table = (Table) element; |
| 831 |
try { |
| 832 |
if (table.getName().matches(inputString)) { |
| 833 |
exLogged = false; |
| 834 |
return true; |
| 835 |
} |
| 836 |
}catch (PatternSyntaxException ex) { |
| 837 |
if (!exLogged || !Tools.valuesAreEqual(oldInput, newInput) ) { |
| 838 |
// Log the exception when invalid search string is given |
| 839 |
// and log the exception only once instead of logging it for each table entry |
| 840 |
JptJpaUiPlugin.instance().logError(ex, "Invaid table search string: {0}", newInput); |
| 841 |
exLogged = true; |
| 842 |
oldInput = newInput; |
| 843 |
} |
| 844 |
return false; |
| 845 |
} |
| 846 |
|
| 847 |
return false; |
| 848 |
} |
| 849 |
} |
| 850 |
} |