use of org.jboss.tools.hibernate.search.runtime.spi.IHSearchService in project jbosstools-hibernate by jbosstools.
the class IndexRebuildHandler method run.
private void run(final ConsoleConfiguration consoleConfig, final Set<Class> classes) {
try {
consoleConfig.execute(new Command() {
public Object execute() {
final IConfiguration cfg = consoleConfig.getConfiguration();
if (cfg == null) {
return null;
}
IHSearchService service = HSearchServiceLookup.findService(HSearchConsoleConfigurationPreferences.getHSearchVersion(consoleConfig.getName()));
service.newIndexRebuild(consoleConfig.getSessionFactory(), classes);
return null;
}
});
MessageDialog.openInformation(HibernateConsolePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(), "Initial index rebuild", "Initial index rebuild succesfully finished");
} catch (Exception e) {
MessageDialog.openError(HibernateConsolePlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(), "Initial index rebuild failed", e.getMessage());
}
}
use of org.jboss.tools.hibernate.search.runtime.spi.IHSearchService in project jbosstools-hibernate by jbosstools.
the class AnalyzersTabBuilder method buildTab.
protected Composite buildTab(CTabFolder folder, ConsoleConfiguration consoleConfig) {
final String consoleConfigName = consoleConfig.getName();
Composite container = new Composite(folder, SWT.TOP);
container.setLayout(new GridLayout(2, true));
GridData comboGridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING, GridData.VERTICAL_ALIGN_CENTER, false, false);
comboGridData.horizontalSpan = 2;
analyzersCombo = new AnalyzersCombo(container, comboGridData, consoleConfigName);
final Text input = new Text(container, SWT.MULTI | SWT.BORDER);
input.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
final Text output = new Text(container, SWT.MULTI | SWT.BORDER);
output.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
output.setEditable(false);
input.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
IHSearchService service = HSearchServiceLookup.findService(HSearchConsoleConfigurationPreferences.getHSearchVersion(consoleConfigName));
String result = service.doAnalyze(((Text) e.getSource()).getText(), analyzersCombo.getAnalyzer());
output.setText(result);
}
});
container.pack();
container.update();
return container;
}
use of org.jboss.tools.hibernate.search.runtime.spi.IHSearchService in project jbosstools-hibernate by jbosstools.
the class ExploreDocsTabBuilder method createOperatingConrols.
protected void createOperatingConrols(Composite parent, final ConsoleConfiguration consoleConfig) {
createEntityCheckBoxes(parent, consoleConfig);
Composite block = new Composite(parent, SWT.NONE);
block.setLayout(new RowLayout());
Button execButton = new Button(block, SWT.PUSH);
new Label(block, SWT.NONE).setText("Document #");
Button preButton = new Button(block, SWT.PUSH);
preButton.setText("<---");
this.docNumberLbl = new Label(block, SWT.NONE);
this.docNumberLbl.setText(" ");
Button nextButton = new Button(block, SWT.PUSH);
nextButton.setText("--->");
preButton.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
if (docs.isEmpty()) {
return;
}
int curNum = Integer.valueOf(docNumberLbl.getText());
if (curNum > 0) {
tableInsert(docs.get(curNum - 1));
docNumberLbl.setText(String.valueOf(curNum - 1));
}
}
});
nextButton.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
if (docs.isEmpty()) {
return;
}
int curNum = Integer.valueOf(docNumberLbl.getText());
if (curNum < docs.size() - 1) {
tableInsert(docs.get(curNum + 1));
docNumberLbl.setText(String.valueOf(curNum + 1));
}
}
});
execButton.setImage(EclipseImages.getImage(ImageConstants.EXECUTE));
execButton.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
ClassLoader classloader = ConsoleConfigurationUtils.getClassLoader(consoleConfig);
Set<Class> classes = new HashSet<Class>();
for (Button entityBtn : entityCheckBoxes) {
if (entityBtn.getSelection()) {
try {
classes.add(Class.forName(entityBtn.getText(), true, classloader));
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
}
if (classes.isEmpty()) {
return;
}
IHSearchService service = HSearchServiceLookup.findService(HSearchConsoleConfigurationPreferences.getHSearchVersion(consoleConfig.getName()));
docs = service.getEntityDocuments(consoleConfig.getSessionFactory(), classes.toArray(new Class[0]));
if (docs.isEmpty()) {
tableViewer.getTable().removeAll();
tableViewer.add(new TableObject("No Lucene index found", ""));
tableViewer.add(new TableObject("or your console configuration is out of sync", ""));
return;
}
tableInsert(docs.get(0));
docNumberLbl.setText("0");
}
});
}
use of org.jboss.tools.hibernate.search.runtime.spi.IHSearchService in project jbosstools-hibernate by jbosstools.
the class SearchTabBuilder method buildTab.
protected Composite buildTab(CTabFolder folder, ConsoleConfiguration consoleConfig) {
final String consoleConfigName = consoleConfig.getName();
Composite container = new Composite(folder, SWT.VERTICAL);
container.setLayout(new GridLayout());
Composite entitiesContainer = new Composite(container, SWT.TOP);
GridData entitiesGridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
entitiesContainer.setLayoutData(entitiesGridData);
createEntityCombo(entitiesContainer, consoleConfig);
entitiesContainer.pack();
Composite searchDataComposite = new Composite(container, SWT.TOP);
searchDataComposite.setLayout(new GridLayout(2, true));
final Text query = new Text(searchDataComposite, SWT.MULTI | SWT.BORDER);
GridData queryGridData = new GridData(GridData.FILL, GridData.BEGINNING, true, false);
queryGridData.heightHint = 5 * query.getLineHeight();
queryGridData.verticalSpan = 2;
query.setLayoutData(queryGridData);
analyzersCombo = new AnalyzersCombo(searchDataComposite, new GridData(), consoleConfigName);
Button searchButton = new Button(searchDataComposite, SWT.PUSH);
searchButton.setText("Search");
searchButton.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event event) {
ClassLoader classloader = ConsoleConfigurationUtils.getClassLoader(consoleConfig);
Class<?> entity = null;
try {
entity = Class.forName(entityCombo.getText(), true, classloader);
} catch (ClassNotFoundException e) {
entity = null;
}
IHSearchService service = HSearchServiceLookup.findService(HSearchConsoleConfigurationPreferences.getHSearchVersion(consoleConfigName));
resultTable.showResults(service.search(consoleConfig.getSessionFactory(), entity, fieldsCombo.getText(), analyzersCombo.getAnalyzer(), query.getText()), consoleConfig.getSessionFactory().getAllClassMetadata().get(entityCombo.getText()));
}
});
searchDataComposite.pack();
this.resultTable = new SearchResultTable(container, consoleConfig);
// container.pack();
container.update();
return container;
}
Aggregations