List of usage examples for org.eclipse.jface.viewers ComboViewer getElementAt
public Object getElementAt(int index)
From source file:gov.redhawk.ide.snapshot.ui.SnapshotWizardPage.java
License:Open Source License
protected void createOutputControls(final Composite parent) { Label label;//from www .j av a2s . co m // Add Label and combo box to select file type label = new Label(parent, SWT.None); label.setText("File Type:"); ComboViewer fileTypeCombo = new ComboViewer(parent, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.SIMPLE); fileTypeCombo.getControl() .setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create()); fileTypeCombo.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { return ((IDataWriterDesc) element).getName(); } }); fileTypeCombo.setContentProvider(ArrayContentProvider.getInstance()); // ArrayContentProvider does not store any state, therefore can re-use instances IDataWriterDesc[] input = SnapshotActivator.getDataReceiverRegistry().getRecieverDescs(); fileTypeCombo.setInput(input); fileTypeCombo.setSorter(new ViewerSorter()); // sort combo items alphabetically (this selects last item?) context.bindValue(ViewerProperties.singleSelection().observe(fileTypeCombo), BeansObservables.observeValue(settings, "dataWriter")); if (input.length > 0) { fileTypeCombo.setSelection(new StructuredSelection(fileTypeCombo.getElementAt(0))); // select first sorted element } // add check box to see if the user wants to save to their workspace workspaceCheck = new Button(parent, SWT.CHECK); workspaceCheck.setText("Save to Workspace"); // add check box to see if user wants to confirm overwrite of existing file(s) final Button confirmOverwrite = new Button(parent, SWT.CHECK); confirmOverwrite.setText("Confirm overwrite"); context.bindValue(WidgetProperties.selection().observe(confirmOverwrite), BeansObservables.observeValue(settings, "confirmOverwrite")); // region to hold the different pages for saving to the workspace or the file system fileFinder = new Group(parent, SWT.SHADOW_ETCHED_IN); fileFinder.setText("Save to"); fileFinder.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).span(3, 2).create()); fileFinderLayout = new StackLayout(); fileFinderLayout.marginHeight = 5; fileFinderLayout.marginWidth = 5; fileFinder.setLayout(fileFinderLayout); // the different pages: search file system, search workspace searchFileSystem = makeFileSystemSave(fileFinder); searchFileSystem.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).span(3, 2).create()); searchWorkbench = makeWorkbenchTree(fileFinder); searchWorkbench.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).span(3, 2).create()); // This binding must be defined after all controls have been configured, because its update strategy // implementation calls setSaveLocation(), which depends on the controls being already configured context.bindValue(WidgetProperties.selection().observe(workspaceCheck), BeansObservables.observeValue(settings, "saveToWorkspace"), createWsCheckUpdateStrategy(), createWsCheckUpdateStrategy()); restoreWidgetValues(settings); // determining which page starts on top setSaveLocationComposite(workspaceCheck.getSelection(), true); // switching pages workspaceCheck.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { setSaveLocationComposite(workspaceCheck.getSelection(), true); } }); }
From source file:net.enilink.komma.edit.ui.wizards.RefactorMoveWizard.java
License:Open Source License
protected void createPages() { selectModelPage = new WizardPage("Select Target Model") { @Override// w w w . j a v a 2 s . co m public void createControl(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout()); Label label = new Label(composite, SWT.NONE); label.setText("Select target model:"); final Combo combo = new Combo(composite, SWT.DROP_DOWN); final ComboViewer cViewer = new ComboViewer(combo); cViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { targetModel = (IModel) cViewer.getElementAt(combo.getSelectionIndex()); setPageComplete(true); } }); // get potential target models from list of active editors IEditorReference[] openEditors = workbench.getActiveWorkbenchWindow().getActivePage() .getEditorReferences(); for (IEditorReference ref : openEditors) { IEditorPart editor = ref.getEditor(true); if (editor != null && editor != workbench.getActiveWorkbenchWindow().getActivePage().getActiveEditor()) { IModel model = (IModel) editor.getAdapter(IModel.class); if (model != null) { cViewer.add(model); } } } final Button keepNamespaceButton = new Button(composite, SWT.CHECK); keepNamespaceButton.setSelection(keepNamespace); keepNamespaceButton.setText("Keep namespaces"); keepNamespaceButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { keepNamespace = keepNamespaceButton.getSelection(); } }); setDescription("Select the target model from the list of open editors."); setControl(composite); setPageComplete(false); } }; showPreviewPage = new RefactorPreviewPage("Preview") { @Override public Collection<Change> collectChanges() { changes = new RefactoringProcessor(domain).createMoveChanges(currentSelection.toList(), targetModel, keepNamespace); return changes; } }; }
From source file:org.bbaw.pdr.ae.view.control.dialogs.SelectObjectDialog.java
License:Open Source License
/** * Builds the aspect search.//from ww w. ja v a 2 s . c om */ private void buildAspectSearch() { DataType dtAll = new DataType(); dtAll.setValue("ALL"); dtAll.setLabel("ALL"); _aspectQuery = new PdrQuery(); _aspectQuery.setType(0); _criteria = new Criteria(); _criteria.setType("tagging"); //$NON-NLS-1$ _aspectQuery.getCriterias().add(_criteria); final Criteria c = _aspectQuery.getCriterias().firstElement(); _searchATagComp = new Composite(_aspectSearchGroup, SWT.NONE); _searchATagComp.setLayout(new GridLayout()); ((GridLayout) _searchATagComp.getLayout()).makeColumnsEqualWidth = true; ((GridLayout) _searchATagComp.getLayout()).numColumns = 15; _searchATagComp.setLayoutData(new GridData()); ((GridData) _searchATagComp.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) _searchATagComp.getLayoutData()).grabExcessHorizontalSpace = true; // ((GridData) searchPTagComp.getLayoutData()).heightHint = 200; ((GridData) _searchATagComp.getLayoutData()).grabExcessVerticalSpace = false; ((GridData) _searchATagComp.getLayoutData()).horizontalSpan = 1; Label sem = new Label(_searchATagComp, SWT.NONE); sem.setText(NLMessages.getString("Dialog_semantic")); sem.setLayoutData(new GridData()); ((GridData) sem.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) sem.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) sem.getLayoutData()).horizontalSpan = 2; Label tagName = new Label(_searchATagComp, SWT.NONE); tagName.setText(NLMessages.getString("Dialog_Markup")); tagName.setLayoutData(new GridData()); ((GridData) tagName.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) tagName.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) tagName.getLayoutData()).horizontalSpan = 2; Label tagType = new Label(_searchATagComp, SWT.NONE); tagType.setText(NLMessages.getString("Dialog_type")); tagType.setLayoutData(new GridData()); ((GridData) tagType.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) tagType.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) tagType.getLayoutData()).horizontalSpan = 2; Label tagSubtype = new Label(_searchATagComp, SWT.NONE); tagSubtype.setText(NLMessages.getString("Dialog_subtype")); tagSubtype.setLayoutData(new GridData()); ((GridData) tagSubtype.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) tagSubtype.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) tagSubtype.getLayoutData()).horizontalSpan = 2; Label searchTextLabel = new Label(_searchATagComp, SWT.NONE); searchTextLabel.setText(NLMessages.getString("Dialog_searchText")); searchTextLabel.setLayoutData(new GridData()); ((GridData) searchTextLabel.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) searchTextLabel.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) searchTextLabel.getLayoutData()).horizontalSpan = 5; Label fuzzy = new Label(_searchATagComp, SWT.NONE); fuzzy.setText(NLMessages.getString("Dialog_fuzzy")); fuzzy.setLayoutData(new GridData()); ((GridData) fuzzy.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) fuzzy.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) fuzzy.getLayoutData()).horizontalSpan = 1; final Combo semCombo = new Combo(_searchATagComp, SWT.READ_ONLY); semCombo.setLayoutData(new GridData()); ComboViewer comboSemanticViewer = new ComboViewer(semCombo); comboSemanticViewer.setContentProvider(new AEConfigPresentableContentProvider()); comboSemanticViewer.setLabelProvider(new AEConfigPresentableLabelProvider()); ((AEConfigPresentableContentProvider) comboSemanticViewer.getContentProvider()).setAddALL(true); if (_facade.getAllSemantics() != null && !_facade.getAllSemantics().isEmpty()) { comboSemanticViewer.setInput(_facade.getAllSemantics()); if (c.getCrit0() != null) { setComboViewerByString(comboSemanticViewer, c.getCrit0()); } else { semCombo.select(0); c.setCrit0(semCombo.getItem(0)); } } semCombo.setLayoutData(new GridData()); ((GridData) semCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) semCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) semCombo.getLayoutData()).horizontalSpan = 2; comboSemanticViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); IAEPresentable cp = (IAEPresentable) obj; if (cp != null) { c.setCrit0(cp.getValue()); } } }); semCombo.pack(); final Combo tagCombo = new Combo(_searchATagComp, SWT.READ_ONLY); tagCombo.setLayoutData(new GridData()); tagCombo.setLayoutData(new GridData()); ((GridData) tagCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) tagCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) tagCombo.getLayoutData()).horizontalSpan = 2; final ComboViewer tagComboViewer = new ComboViewer(tagCombo); tagComboViewer.setContentProvider(new MarkupContentProvider(true)); tagComboViewer.setLabelProvider(new MarkupLabelProvider()); tagComboViewer.setComparator(new ConfigDataComparator()); if (_facade.getConfigs().containsKey(_markupProvider)) { HashMap<String, ConfigData> input = _facade.getConfigs().get(_markupProvider).getChildren(); tagComboViewer.setInput(input); } if (c.getCrit1() != null) { setComboViewerByString(tagComboViewer, c.getCrit1()); } else { Object obj = tagComboViewer.getElementAt(0); if (obj != null) { tagComboViewer.setSelection(new StructuredSelection(obj)); ConfigData cd = (ConfigData) tagComboViewer.getElementAt(0); if (cd.getValue().startsWith("aodl:")) //$NON-NLS-1$ { c.setCrit1(cd.getValue().substring(5)); } else { c.setCrit1(cd.getValue()); } } } final Combo typeCombo = new Combo(_searchATagComp, SWT.READ_ONLY); typeCombo.setLayoutData(new GridData()); typeCombo.setLayoutData(new GridData()); ((GridData) typeCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) typeCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) typeCombo.getLayoutData()).horizontalSpan = 2; final ComboViewer typeComboViewer = new ComboViewer(typeCombo); typeComboViewer.setContentProvider(new MarkupContentProvider(false)); typeComboViewer.setLabelProvider(new MarkupLabelProvider()); typeComboViewer.setComparator(new ConfigDataComparator()); tagComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); ConfigData cd = (ConfigData) obj; String selection; if (cd.getValue().startsWith("aodl:")) { selection = cd.getValue().substring(5); } else { selection = cd.getValue(); } c.setCrit1(selection); setComboViewerInput(typeComboViewer, "tagging_values", c.getCrit1(), null, null); } }); if (c.getCrit2() != null) { setComboViewerByString(typeComboViewer, c.getCrit2()); } final Combo subtypeCombo = new Combo(_searchATagComp, SWT.READ_ONLY); final ComboViewer subtypeComboViewer = new ComboViewer(subtypeCombo); subtypeComboViewer.setContentProvider(new MarkupContentProvider(false)); subtypeComboViewer.setLabelProvider(new MarkupLabelProvider()); subtypeComboViewer.setComparator(new ConfigDataComparator()); typeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); ConfigData cd = (ConfigData) obj; subtypeComboViewer.setInput(null); if (cd != null) { c.setCrit2(cd.getValue()); } setComboViewerInput(subtypeComboViewer, "tagging_values", c.getCrit1(), c.getCrit2(), null); } }); subtypeCombo.setLayoutData(new GridData()); subtypeCombo.setLayoutData(new GridData()); ((GridData) subtypeCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) subtypeCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) subtypeCombo.getLayoutData()).horizontalSpan = 2; if (c.getCrit3() != null) { setComboViewerByString(subtypeComboViewer, c.getCrit3()); } subtypeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); ConfigData cd = (ConfigData) obj; if (cd != null) { c.setCrit3(cd.getValue()); } } }); final Text searchText = new Text(_searchATagComp, SWT.BORDER); searchText.setLayoutData(new GridData()); searchText.setLayoutData(new GridData()); ((GridData) searchText.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) searchText.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) searchText.getLayoutData()).horizontalSpan = 5; if (c.getSearchText() != null) { searchText.setText(c.getSearchText()); } searchText.addFocusListener(new FocusListener() { @Override public void focusGained(final FocusEvent e) { String[] vals = new String[] {}; try { vals = _mainSearcher.getFacets("tagging", c.getCrit1(), c.getCrit2(), null, null); } catch (Exception e1) { e1.printStackTrace(); } new AutoCompleteField(searchText, new TextContentAdapter(), vals); } @Override public void focusLost(final FocusEvent e) { c.setSearchText(searchText.getText()); } }); searchText.addKeyListener(new KeyListener() { @Override public void keyPressed(final KeyEvent e) { if (e.keyCode == SWT.CR) { c.setSearchText(searchText.getText()); searchAspects(); } } @Override public void keyReleased(final KeyEvent e) { } }); final Button fuzzyB = new Button(_searchATagComp, SWT.CHECK); fuzzyB.setLayoutData(new GridData()); fuzzyB.setSelection(c.isFuzzy()); fuzzyB.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { c.setFuzzy(!c.isFuzzy()); } }); _searchADateComp = new Composite(_aspectSearchGroup, SWT.NONE); _searchADateComp.setLayout(new GridLayout()); ((GridLayout) _searchADateComp.getLayout()).makeColumnsEqualWidth = true; ((GridLayout) _searchADateComp.getLayout()).numColumns = 13; _searchADateComp.setLayoutData(new GridData()); ((GridData) _searchADateComp.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) _searchADateComp.getLayoutData()).grabExcessHorizontalSpace = true; // ((GridData) searchADateComp.getLayoutData()).heightHint = 200; ((GridData) _searchADateComp.getLayoutData()).grabExcessVerticalSpace = false; ((GridData) _searchADateComp.getLayoutData()).horizontalSpan = 1; Label typeDate = new Label(_searchADateComp, SWT.NONE); typeDate.setText(NLMessages.getString("Dialog_type")); typeDate.setLayoutData(new GridData()); ((GridData) typeDate.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) typeDate.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) typeDate.getLayoutData()).horizontalSpan = 2; Label bl = new Label(_searchADateComp, SWT.NONE); bl.setText(""); //$NON-NLS-1$ Label notBefore = new Label(_searchADateComp, SWT.NONE); notBefore.setText(NLMessages.getString("Dialog_day")); notBefore.setLayoutData(new GridData()); ((GridData) notBefore.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) notBefore.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) notBefore.getLayoutData()).horizontalSpan = 1; Label month = new Label(_searchADateComp, SWT.NONE); month.setText(NLMessages.getString("Dialog_month")); month.setLayoutData(new GridData()); ((GridData) month.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) month.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) month.getLayoutData()).horizontalSpan = 1; Label year = new Label(_searchADateComp, SWT.NONE); year.setText(NLMessages.getString("Dialog_year")); year.setLayoutData(new GridData()); ((GridData) year.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) year.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) year.getLayoutData()).horizontalSpan = 2; Label bl2 = new Label(_searchADateComp, SWT.NONE); bl2.setText(""); //$NON-NLS-1$ Label notAfter = new Label(_searchADateComp, SWT.NONE); notAfter.setText(NLMessages.getString("Dialog_day")); notAfter.setLayoutData(new GridData()); ((GridData) notAfter.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) notAfter.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) notAfter.getLayoutData()).horizontalSpan = 1; Label month2 = new Label(_searchADateComp, SWT.NONE); month2.setText(NLMessages.getString("Dialog_month")); month2.setLayoutData(new GridData()); ((GridData) month2.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) month2.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) month2.getLayoutData()).horizontalSpan = 1; Label year2 = new Label(_searchADateComp, SWT.NONE); year2.setText(NLMessages.getString("Dialog_year")); year2.setLayoutData(new GridData()); ((GridData) year2.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) year2.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) year2.getLayoutData()).horizontalSpan = 2; final Combo typeDCombo = new Combo(_searchADateComp, SWT.READ_ONLY); typeDCombo.setLayoutData(new GridData()); ComboViewer timeTypeComboViewer = new ComboViewer(typeDCombo); timeTypeComboViewer.setContentProvider(ArrayContentProvider.getInstance()); timeTypeComboViewer.setLabelProvider(new LabelProvider() { @Override public String getText(final Object element) { String str = (String) element; if (NLMessages.getString("Editor_time_" + str) != null) { return NLMessages.getString("Editor_time_" + str); } return str; } }); timeTypeComboViewer.setInput(AEConstants.TIME_TYPES); timeTypeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection selection = event.getSelection(); Object obj = ((IStructuredSelection) selection).getFirstElement(); String s = (String) obj; c.setDateType(s); } }); if (c.getDateType() != null) { StructuredSelection selection = new StructuredSelection(c.getDateType()); timeTypeComboViewer.setSelection(selection); } else { StructuredSelection selection = new StructuredSelection(AEConstants.TIME_TYPES[0]); timeTypeComboViewer.setSelection(selection); c.setDateType(AEConstants.TIME_TYPES[0]); } typeDCombo.pack(); typeDCombo.setLayoutData(new GridData()); ((GridData) typeDCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) typeDCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) typeDCombo.getLayoutData()).horizontalSpan = 2; Label from = new Label(_searchADateComp, SWT.NONE); from.setText(NLMessages.getString("Dialog_from")); from.setLayoutData(new GridData()); ((GridData) from.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) from.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) from.getLayoutData()).horizontalSpan = 1; final Combo day1Combo = new Combo(_searchADateComp, SWT.READ_ONLY); day1Combo.setLayoutData(new GridData()); day1Combo.setItems(AEConstants.DAYS); day1Combo.setLayoutData(new GridData()); ((GridData) day1Combo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) day1Combo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) day1Combo.getLayoutData()).horizontalSpan = 1; if (c.getDateFrom() == null) { PdrDate dateFrom = new PdrDate("0000-00-00"); //$NON-NLS-1$ // dateFrom.setDay(0); // dateFrom.setMonth(0); // dateFrom.setYear(0); c.setDateFrom(dateFrom); day1Combo.select(c.getDateFrom().getDay()); } // System.out.println("test: dateFrom " + c.getDateFrom().toString()); //$NON-NLS-1$ // else // { // // day1Combo.select(0); // c.getDateFrom().setDay(0); // // } day1Combo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { c.getDateFrom().setDay(day1Combo.getSelectionIndex()); } }); final Combo month1Combo = new Combo(_searchADateComp, SWT.READ_ONLY); month1Combo.setLayoutData(new GridData()); month1Combo.setItems(AEConstants.MONTHS); month1Combo.setLayoutData(new GridData()); ((GridData) month1Combo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) month1Combo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) month1Combo.getLayoutData()).horizontalSpan = 1; if (c.getDateFrom() != null) { month1Combo.select(c.getDateFrom().getMonth()); } else { month1Combo.select(0); c.getDateFrom().setMonth(0); } month1Combo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { c.getDateFrom().setMonth(month1Combo.getSelectionIndex()); } }); final YearSpinner year1Spinner = new YearSpinner(_searchADateComp, SWT.NULL); // year1Spinner.setLayoutData(new GridData()); // year1Spinner.setLayoutData(new GridData()); // ((GridData) year1Spinner.getLayoutData()).horizontalAlignment = // SWT.FILL; // ((GridData) year1Spinner.getLayoutData()).grabExcessHorizontalSpace = // true; // ((GridData) year1Spinner.getLayoutData()).horizontalSpan = 2; // year1Spinner.setMinimum(0); // year1Spinner.setMaximum(9999); if (c.getDateFrom() != null) { year1Spinner.setSelection(c.getDateFrom().getYear()); } else { year1Spinner.setSelection(_preselection); c.getDateFrom().setYear(_preselection); } year1Spinner.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(final SelectionEvent e) { c.getDateFrom().setYear(year1Spinner.getSelection()); } @Override public void widgetSelected(final SelectionEvent e) { c.getDateFrom().setYear(year1Spinner.getSelection()); } }); Label to = new Label(_searchADateComp, SWT.NONE); to.setText(NLMessages.getString("Dialog_to")); to.setLayoutData(new GridData()); ((GridData) to.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) to.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) to.getLayoutData()).horizontalSpan = 1; final Combo day2Combo = new Combo(_searchADateComp, SWT.READ_ONLY); day2Combo.setLayoutData(new GridData()); day2Combo.setItems(AEConstants.DAYS); day2Combo.setLayoutData(new GridData()); ((GridData) day2Combo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) day2Combo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) day2Combo.getLayoutData()).horizontalSpan = 1; if (c.getDateTo() == null) { PdrDate dateTo = new PdrDate("0000-00-00"); //$NON-NLS-1$ c.setDateTo(dateTo); day2Combo.select(c.getDateTo().getDay()); } day2Combo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { c.getDateTo().setDay(day2Combo.getSelectionIndex()); } }); final Combo month2Combo = new Combo(_searchADateComp, SWT.READ_ONLY); month2Combo.setLayoutData(new GridData()); month2Combo.setItems(AEConstants.MONTHS); month2Combo.setLayoutData(new GridData()); ((GridData) month2Combo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) month2Combo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) month2Combo.getLayoutData()).horizontalSpan = 1; if (c.getDateTo() != null) { month2Combo.select(c.getDateTo().getMonth()); } else { month2Combo.select(0); c.getDateTo().setMonth(0); } month2Combo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { c.getDateTo().setMonth(month2Combo.getSelectionIndex()); } }); final YearSpinner year2Spinner = new YearSpinner(_searchADateComp, SWT.NULL); // year2Spinner.setLayoutData(new GridData()); // year2Spinner.setLayoutData(new GridData()); // ((GridData) year2Spinner.getLayoutData()).horizontalAlignment = // SWT.FILL; // ((GridData) year2Spinner.getLayoutData()).grabExcessHorizontalSpace = // true; // ((GridData) year2Spinner.getLayoutData()).horizontalSpan = 2; // year2Spinner.setMinimum(0); // year2Spinner.setMaximum(9999); if (c.getDateTo() != null) { year2Spinner.setSelection(c.getDateTo().getYear()); } else { year2Spinner.setSelection(_preselection); c.getDateTo().setYear(_preselection); } year2Spinner.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(final SelectionEvent e) { c.getDateTo().setYear(year2Spinner.getSelection()); } @Override public void widgetSelected(final SelectionEvent e) { c.getDateTo().setYear(year2Spinner.getSelection()); } }); final Button includeB = new Button(_searchADateComp, SWT.CHECK); includeB.setLayoutData(new GridData()); includeB.setSelection(c.isIncludeConcurrences()); includeB.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { c.setIncludeConcurrences(!c.isIncludeConcurrences()); } }); }
From source file:org.bbaw.pdr.ae.view.control.dialogs.SelectObjectDialog.java
License:Open Source License
/** * Builds the person search./*w w w . j a va 2s . co m*/ */ private void buildPersonSearch() { DataType dtAll = new DataType(); dtAll.setValue("ALL"); dtAll.setLabel("ALL"); _personQuery = new PdrQuery(); _personQuery.setType(1); _criteria = new Criteria(); _criteria.setType("tagging"); //$NON-NLS-1$ _personQuery.getCriterias().add(_criteria); _criteria = new Criteria(); _criteria.setType("tagging"); //$NON-NLS-1$ _personQuery.getCriterias().add(_criteria); _criteria = new Criteria(); _personQuery.getCriterias().add(_criteria); _criteria.setType("relation"); //$NON-NLS-1$ _criteria = new Criteria(); _personQuery.getCriterias().add(_criteria); _criteria.setType("date"); //$NON-NLS-1$ boolean tag1 = true; boolean rel1 = true; boolean date1 = true; for (int i = 0; i < _personQuery.getCriterias().size(); i++) { // System.out.println("for i = " + i); //$NON-NLS-1$ final Criteria c = _personQuery.getCriterias().get(i); if (c.getType().equals("tagging")) //$NON-NLS-1$ { if (tag1) { tag1 = false; _searchPTagComp = new Composite(_personSearchGroup, SWT.NONE); _searchPTagComp.setLayout(new GridLayout()); ((GridLayout) _searchPTagComp.getLayout()).makeColumnsEqualWidth = true; ((GridLayout) _searchPTagComp.getLayout()).numColumns = 15; _searchPTagComp.setLayoutData(new GridData()); ((GridData) _searchPTagComp.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) _searchPTagComp.getLayoutData()).grabExcessHorizontalSpace = true; // ((GridData) searchPTagComp.getLayoutData()).heightHint = // 200; ((GridData) _searchPTagComp.getLayoutData()).grabExcessVerticalSpace = false; ((GridData) _searchPTagComp.getLayoutData()).horizontalSpan = 1; Label op = new Label(_searchPTagComp, SWT.NONE); op.setText(NLMessages.getString("Dialog_operand")); op.setLayoutData(new GridData()); ((GridData) op.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) op.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) op.getLayoutData()).horizontalSpan = 2; Label sem = new Label(_searchPTagComp, SWT.NONE); sem.setText(NLMessages.getString("Dialog_semantic")); sem.setLayoutData(new GridData()); ((GridData) sem.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) sem.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) sem.getLayoutData()).horizontalSpan = 2; Label tagName = new Label(_searchPTagComp, SWT.NONE); tagName.setText(NLMessages.getString("Dialog_markup")); tagName.setLayoutData(new GridData()); ((GridData) tagName.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) tagName.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) tagName.getLayoutData()).horizontalSpan = 2; Label tagType = new Label(_searchPTagComp, SWT.NONE); tagType.setText(NLMessages.getString("Dialog_type")); tagType.setLayoutData(new GridData()); ((GridData) tagType.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) tagType.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) tagType.getLayoutData()).horizontalSpan = 2; Label tagSubtype = new Label(_searchPTagComp, SWT.NONE); tagSubtype.setText(NLMessages.getString("Dialog_subtype")); tagSubtype.setLayoutData(new GridData()); ((GridData) tagSubtype.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) tagSubtype.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) tagSubtype.getLayoutData()).horizontalSpan = 2; Label searchTextLabel = new Label(_searchPTagComp, SWT.NONE); searchTextLabel.setText(NLMessages.getString("Dialog_searchText")); searchTextLabel.setLayoutData(new GridData()); ((GridData) searchTextLabel.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) searchTextLabel.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) searchTextLabel.getLayoutData()).horizontalSpan = 3; Label fuzzy = new Label(_searchPTagComp, SWT.NONE); fuzzy.setText(NLMessages.getString("Dialog_fuzzy")); fuzzy.setLayoutData(new GridData()); ((GridData) fuzzy.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) fuzzy.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) fuzzy.getLayoutData()).horizontalSpan = 1; Label include = new Label(_searchPTagComp, SWT.NONE); include.setText(NLMessages.getString("Dialog_include")); include.setToolTipText(NLMessages.getString("Dialog_includeConcurrences")); include.setLayoutData(new GridData()); ((GridData) include.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) include.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) include.getLayoutData()).horizontalSpan = 1; } if (i == 0) { Label l = new Label(_searchPTagComp, SWT.NONE); l.setText(NLMessages.getString("Dialog_Markup")); l.setLayoutData(new GridData()); ((GridData) l.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) l.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) l.getLayoutData()).horizontalSpan = 2; } else { final Combo opCombo = new Combo(_searchPTagComp, SWT.READ_ONLY); opCombo.setLayoutData(new GridData()); opCombo.add(Operator.AND.toString()); opCombo.add(Operator.OR.toString()); opCombo.add(Operator.NOT.toString()); opCombo.setLayoutData(new GridData()); ((GridData) opCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) opCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) opCombo.getLayoutData()).horizontalSpan = 2; if (c.getOperator() != null) { opCombo.setText(c.getOperator()); } else { opCombo.select(0); c.setOperator(opCombo.getItem(0)); } opCombo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { c.setOperator(opCombo.getItem(opCombo.getSelectionIndex())); } }); } final Combo semCombo = new Combo(_searchPTagComp, SWT.READ_ONLY); semCombo.setLayoutData(new GridData()); ComboViewer comboSemanticViewer = new ComboViewer(semCombo); comboSemanticViewer.setContentProvider(new AEConfigPresentableContentProvider()); comboSemanticViewer.setLabelProvider(new AEConfigPresentableLabelProvider()); ((AEConfigPresentableContentProvider) comboSemanticViewer.getContentProvider()).setAddALL(true); if (_facade.getAllSemantics() != null && !_facade.getAllSemantics().isEmpty()) { comboSemanticViewer.setInput(_facade.getAllSemantics()); if (c.getCrit0() != null) { setComboViewerByString(comboSemanticViewer, c.getCrit0()); } else { semCombo.select(0); c.setCrit0(semCombo.getItem(0)); } } semCombo.setLayoutData(new GridData()); ((GridData) semCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) semCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) semCombo.getLayoutData()).horizontalSpan = 2; comboSemanticViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); IAEPresentable cp = (IAEPresentable) obj; if (cp != null) { c.setCrit0(cp.getValue()); } } }); semCombo.pack(); final Combo tagCombo = new Combo(_searchPTagComp, SWT.READ_ONLY); tagCombo.setLayoutData(new GridData()); tagCombo.setLayoutData(new GridData()); ((GridData) tagCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) tagCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) tagCombo.getLayoutData()).horizontalSpan = 2; final ComboViewer tagComboViewer = new ComboViewer(tagCombo); tagComboViewer.setContentProvider(new MarkupContentProvider(true)); tagComboViewer.setLabelProvider(new MarkupLabelProvider()); tagComboViewer.setComparator(new ConfigDataComparator()); if (_facade.getConfigs().containsKey(_markupProvider)) { HashMap<String, ConfigData> input = _facade.getConfigs().get(_markupProvider).getChildren(); tagComboViewer.setInput(input); } if (c.getCrit1() != null) { setComboViewerByString(tagComboViewer, c.getCrit1()); } else { Object obj = tagComboViewer.getElementAt(0); if (obj != null) { tagComboViewer.setSelection(new StructuredSelection(obj)); ConfigData cd = (ConfigData) tagComboViewer.getElementAt(0); if (cd.getValue().startsWith("aodl:")) //$NON-NLS-1$ { c.setCrit1(cd.getValue().substring(5)); } else { c.setCrit1(cd.getValue()); } } } final Combo typeCombo = new Combo(_searchPTagComp, SWT.READ_ONLY); typeCombo.setLayoutData(new GridData()); typeCombo.setLayoutData(new GridData()); ((GridData) typeCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) typeCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) typeCombo.getLayoutData()).horizontalSpan = 2; final ComboViewer typeComboViewer = new ComboViewer(typeCombo); typeComboViewer.setContentProvider(new MarkupContentProvider(false)); typeComboViewer.setLabelProvider(new MarkupLabelProvider()); typeComboViewer.setComparator(new ConfigDataComparator()); tagComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); ConfigData cd = (ConfigData) obj; String selection; if (cd.getValue().startsWith("aodl:")) { selection = cd.getValue().substring(5); } else { selection = cd.getValue(); } c.setCrit1(selection); setComboViewerInput(typeComboViewer, "tagging_values", c.getCrit1(), null, null); } }); if (c.getCrit2() != null) { setComboViewerByString(typeComboViewer, c.getCrit2()); } final Combo subtypeCombo = new Combo(_searchPTagComp, SWT.READ_ONLY); final ComboViewer subtypeComboViewer = new ComboViewer(subtypeCombo); subtypeComboViewer.setContentProvider(new MarkupContentProvider(false)); subtypeComboViewer.setLabelProvider(new MarkupLabelProvider()); subtypeComboViewer.setComparator(new ConfigDataComparator()); typeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); ConfigData cd = (ConfigData) obj; subtypeComboViewer.setInput(null); if (cd != null) { c.setCrit2(cd.getValue()); } setComboViewerInput(subtypeComboViewer, "tagging_values", c.getCrit1(), c.getCrit2(), null); } }); subtypeCombo.setLayoutData(new GridData()); subtypeCombo.setLayoutData(new GridData()); ((GridData) subtypeCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) subtypeCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) subtypeCombo.getLayoutData()).horizontalSpan = 2; if (c.getCrit3() != null) { setComboViewerByString(subtypeComboViewer, c.getCrit3()); } subtypeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); ConfigData cd = (ConfigData) obj; if (cd != null) { c.setCrit3(cd.getValue()); } } }); final Text searchText = new Text(_searchPTagComp, SWT.BORDER); searchText.setLayoutData(new GridData()); searchText.setLayoutData(new GridData()); ((GridData) searchText.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) searchText.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) searchText.getLayoutData()).horizontalSpan = 3; if (c.getSearchText() != null) { searchText.setText(c.getSearchText()); } searchText.addFocusListener(new FocusListener() { @Override public void focusGained(final FocusEvent e) { String[] vals = new String[] {}; try { vals = _mainSearcher.getFacets("tagging", c.getCrit1(), c.getCrit2(), null, null); } catch (Exception e1) { e1.printStackTrace(); } new AutoCompleteField(searchText, new TextContentAdapter(), vals); } @Override public void focusLost(final FocusEvent e) { c.setSearchText(searchText.getText()); } }); searchText.addKeyListener(new KeyListener() { @Override public void keyPressed(final KeyEvent e) { if (e.keyCode == SWT.CR) { c.setSearchText(searchText.getText()); searchPersons(); } } @Override public void keyReleased(final KeyEvent e) { } }); final Button fuzzyB = new Button(_searchPTagComp, SWT.CHECK); fuzzyB.setLayoutData(new GridData()); fuzzyB.setSelection(c.isFuzzy()); fuzzyB.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { c.setFuzzy(!c.isFuzzy()); } }); final Button includeB = new Button(_searchPTagComp, SWT.CHECK); includeB.setLayoutData(new GridData()); includeB.setSelection(c.isIncludeConcurrences()); includeB.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { c.setIncludeConcurrences(!c.isIncludeConcurrences()); } }); } // if tagging if (c.getType().equals("relation")) //$NON-NLS-1$ { if (rel1) { rel1 = false; _searchPRelComp = new Composite(_personSearchGroup, SWT.NONE); _searchPRelComp.setLayout(new GridLayout()); ((GridLayout) _searchPRelComp.getLayout()).makeColumnsEqualWidth = true; ((GridLayout) _searchPRelComp.getLayout()).numColumns = 15; _searchPRelComp.setLayoutData(new GridData()); ((GridData) _searchPRelComp.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) _searchPRelComp.getLayoutData()).grabExcessHorizontalSpace = true; // ((GridData) searchPRelComp.getLayoutData()).heightHint = // 200; ((GridData) _searchPRelComp.getLayoutData()).grabExcessVerticalSpace = false; ((GridData) _searchPRelComp.getLayoutData()).horizontalSpan = 1; Label l = new Label(_searchPRelComp, SWT.NONE); l.setText(NLMessages.getString("Dialog_relation")); l.setLayoutData(new GridData()); ((GridData) l.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) l.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) l.getLayoutData()).horizontalSpan = 2; Label context = new Label(_searchPRelComp, SWT.NONE); context.setText(NLMessages.getString("Dialog_context")); context.setLayoutData(new GridData()); ((GridData) context.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) context.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) context.getLayoutData()).horizontalSpan = 2; Label classL = new Label(_searchPRelComp, SWT.NONE); classL.setText(NLMessages.getString("Dialog_class")); classL.setLayoutData(new GridData()); ((GridData) classL.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) classL.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) classL.getLayoutData()).horizontalSpan = 2; Label relObj = new Label(_searchPRelComp, SWT.NONE); relObj.setText(NLMessages.getString("Dialog_relObject")); relObj.setLayoutData(new GridData()); ((GridData) relObj.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) relObj.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) relObj.getLayoutData()).horizontalSpan = 4; Label searchTextLabel = new Label(_searchPRelComp, SWT.NONE); searchTextLabel.setText(NLMessages.getString("Dialog_searchText")); searchTextLabel.setLayoutData(new GridData()); ((GridData) searchTextLabel.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) searchTextLabel.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) searchTextLabel.getLayoutData()).horizontalSpan = 3; Label fuzzy = new Label(_searchPRelComp, SWT.NONE); fuzzy.setText(""); //$NON-NLS-1$ fuzzy.setLayoutData(new GridData()); ((GridData) fuzzy.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) fuzzy.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) fuzzy.getLayoutData()).horizontalSpan = 1; Label include = new Label(_searchPRelComp, SWT.NONE); include.setText(""); //$NON-NLS-1$ include.setToolTipText(NLMessages.getString("Dialog_includeConcurrences")); include.setLayoutData(new GridData()); ((GridData) include.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) include.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) include.getLayoutData()).horizontalSpan = 1; } if (i == 0) { Label l = new Label(_searchPRelComp, SWT.NONE); l.setLayoutData(new GridData()); l.setLayoutData(new GridData()); ((GridData) l.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) l.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) l.getLayoutData()).horizontalSpan = 2; } else { final Combo opCombo = new Combo(_searchPRelComp, SWT.READ_ONLY); opCombo.setLayoutData(new GridData()); opCombo.add(Operator.AND.toString()); opCombo.add(Operator.OR.toString()); opCombo.add(Operator.NOT.toString()); opCombo.setLayoutData(new GridData()); ((GridData) opCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) opCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) opCombo.getLayoutData()).horizontalSpan = 2; if (c.getOperator() != null) { opCombo.setText(c.getOperator()); } else { opCombo.select(0); c.setOperator(opCombo.getItem(0)); } opCombo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { c.setOperator(opCombo.getItem(opCombo.getSelectionIndex())); } }); } // final Combo contextCombo = new Combo(searchPRelComp, // SWT.READ_ONLY); // contextCombo.setLayoutData(new GridData()); // contextCombo.setLayoutData(new GridData()); // ((GridData) contextCombo.getLayoutData()).horizontalAlignment // = SWT.FILL; // ((GridData) // contextCombo.getLayoutData()).grabExcessHorizontalSpace = // true ; // ((GridData) contextCombo.getLayoutData()).horizontalSpan = 2; // // // final Combo classCombo = new Combo(searchPRelComp, // SWT.READ_ONLY); // classCombo.setLayoutData(new GridData()); // classCombo.setLayoutData(new GridData()); // ((GridData) classCombo.getLayoutData()).horizontalAlignment = // SWT.FILL; // ((GridData) // classCombo.getLayoutData()).grabExcessHorizontalSpace = true; // ((GridData) classCombo.getLayoutData()).horizontalSpan = 2; // // // if (c.getRelationContext() != null) // { // contextCombo.select(contextCombo.indexOf(c.getRelationContext())); // } // else // { // try { // contextCombo.setItems(_mainSearcher.getFacets // ("relation", null, null, null, null)); //$NON-NLS-1$ //$NON-NLS-2$ // } catch (Exception e1) { // e1.printStackTrace(); // } // contextCombo.add("ALL", 0); //$NON-NLS-1$ // contextCombo.select(0); // c.setRelationContext(contextCombo.getItem(0)); // // } // contextCombo.addSelectionListener(new SelectionAdapter(){ // public void widgetSelected(SelectionEvent se){ // String selection = // contextCombo.getItem(contextCombo.getSelectionIndex()); // c.setRelationContext(selection); // try { // classCombo.setItems(_mainSearcher // .getFacets("relation", null, selection, null, null)); //$NON-NLS-1$ //$NON-NLS-2$ // } catch (Exception e1) { // e1.printStackTrace(); // } // classCombo.add("ALL", 0); //$NON-NLS-1$ // classCombo.select(0); // c.setRelationContext(classCombo.getItem(0)); // // } // }); // // if (c.getRelationClass() != null) // { // classCombo.setText(c.getRelationClass()); // } // else // { // // classCombo.add("ALL", 0); //$NON-NLS-1$ // classCombo.select(0); // c.setRelationClass(classCombo.getItem(0)); // } // // // classCombo.addSelectionListener(new SelectionAdapter(){ // public void widgetSelected(SelectionEvent se){ // String selection = // classCombo.getItem(classCombo.getSelectionIndex()); // c.setRelationContext(selection); // // } // }); final Combo contextCombo = new Combo(_searchPRelComp, SWT.READ_ONLY); contextCombo.setLayoutData(new GridData()); contextCombo.setLayoutData(new GridData()); ((GridData) contextCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) contextCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) contextCombo.getLayoutData()).horizontalSpan = 2; final ComboViewer contextComboViewer = new ComboViewer(contextCombo); contextComboViewer.setContentProvider(new MarkupContentProvider(false)); contextComboViewer.setLabelProvider(new MarkupLabelProvider()); contextComboViewer.setComparator(new ConfigDataComparator()); final Combo classCombo = new Combo(_searchPRelComp, SWT.READ_ONLY); classCombo.setLayoutData(new GridData()); classCombo.setLayoutData(new GridData()); ((GridData) classCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) classCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) classCombo.getLayoutData()).horizontalSpan = 2; final ComboViewer classComboViewer = new ComboViewer(classCombo); classComboViewer.setContentProvider(new MarkupContentProvider(false)); classComboViewer.setLabelProvider(new MarkupLabelProvider()); classComboViewer.setComparator(new ConfigDataComparator()); setComboViewerInput(contextComboViewer, "relation", null, null, null); if (c.getRelationContext() != null) { setComboViewerByString(contextComboViewer, c.getRelationContext()); setComboViewerInput(classComboViewer, "relation", c.getRelationContext(), null, null); } else { contextComboViewer.setSelection(new StructuredSelection(contextComboViewer.getElementAt(0))); ConfigData cd = (ConfigData) contextComboViewer.getElementAt(0); c.setRelationContext(cd.getValue()); } contextComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); ConfigData cd = (ConfigData) obj; c.setRelationContext(cd.getValue()); setComboViewerInput(classComboViewer, "relation", c.getRelationContext(), null, null); } }); if (c.getRelationClass() != null) { setComboViewerByString(classComboViewer, c.getRelationClass()); } classComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); ConfigData cd = (ConfigData) obj; c.setRelationClass(cd.getValue()); } }); final Text relObjText = new Text(_searchPRelComp, SWT.BORDER); relObjText.setLayoutData(new GridData()); relObjText.setLayoutData(new GridData()); ((GridData) relObjText.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) relObjText.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) relObjText.getLayoutData()).horizontalSpan = 3; if (c.getRelatedId() != null) { relObjText.setText(c.getRelatedId().toString()); } relObjText.setEnabled(false); relObjText.addFocusListener(new FocusListener() { @Override public void focusGained(final FocusEvent e) { } @Override public void focusLost(final FocusEvent e) { } }); final Button setObj = new Button(_searchPRelComp, SWT.PUSH); setObj.setText(NLMessages.getString("Dialog_set_key")); setObj.setEnabled(false); setObj.setFont(JFaceResources.getDialogFont()); setObj.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { // System.out.println("setObj"); //$NON-NLS-1$ } }); final Text searchText = new Text(_searchPRelComp, SWT.BORDER); searchText.setLayoutData(new GridData()); searchText.setLayoutData(new GridData()); ((GridData) searchText.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) searchText.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) searchText.getLayoutData()).horizontalSpan = 3; if (c.getSearchText() != null) { searchText.setText(c.getSearchText()); } searchText.addFocusListener(new FocusAdapter() { @Override public void focusLost(final FocusEvent e) { c.setSearchText(searchText.getText()); } }); searchText.addKeyListener(new KeyListener() { @Override public void keyPressed(final KeyEvent e) { if (e.keyCode == SWT.CR) { c.setSearchText(searchText.getText()); searchPersons(); } } @Override public void keyReleased(final KeyEvent e) { } }); final Button fuzzyB = new Button(_searchPRelComp, SWT.CHECK); fuzzyB.setLayoutData(new GridData()); fuzzyB.setSelection(c.isFuzzy()); fuzzyB.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { c.setFuzzy(!c.isFuzzy()); } }); final Button includeB = new Button(_searchPRelComp, SWT.CHECK); includeB.setLayoutData(new GridData()); includeB.setSelection(c.isIncludeConcurrences()); includeB.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { c.setIncludeConcurrences(!c.isIncludeConcurrences()); } }); } // if relation if (c.getType().equals("date")) //$NON-NLS-1$ { if (date1) { date1 = false; _searchPDateComp = new Composite(_personSearchGroup, SWT.NONE); _searchPDateComp.setLayout(new GridLayout()); ((GridLayout) _searchPDateComp.getLayout()).makeColumnsEqualWidth = true; ((GridLayout) _searchPDateComp.getLayout()).numColumns = 15; _searchPDateComp.setLayoutData(new GridData()); ((GridData) _searchPDateComp.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) _searchPDateComp.getLayoutData()).grabExcessHorizontalSpace = true; // ((GridData) searchPDateComp.getLayoutData()).heightHint = // 200; ((GridData) _searchPDateComp.getLayoutData()).grabExcessVerticalSpace = false; ((GridData) _searchPDateComp.getLayoutData()).horizontalSpan = 1; Label l2 = new Label(_searchPDateComp, SWT.NONE); l2.setText(NLMessages.getString("Dialog_date")); l2.setLayoutData(new GridData()); ((GridData) l2.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) l2.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) l2.getLayoutData()).horizontalSpan = 2; Label typeDate = new Label(_searchPDateComp, SWT.NONE); typeDate.setText(NLMessages.getString("Dialog_type")); typeDate.setLayoutData(new GridData()); ((GridData) typeDate.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) typeDate.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) typeDate.getLayoutData()).horizontalSpan = 2; Label bl = new Label(_searchPDateComp, SWT.NONE); bl.setText(""); //$NON-NLS-1$ Label notBefore = new Label(_searchPDateComp, SWT.NONE); notBefore.setText(NLMessages.getString("Dialog_day")); notBefore.setLayoutData(new GridData()); ((GridData) notBefore.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) notBefore.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) notBefore.getLayoutData()).horizontalSpan = 1; Label month = new Label(_searchPDateComp, SWT.NONE); month.setText(NLMessages.getString("Dialog_month")); month.setLayoutData(new GridData()); ((GridData) month.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) month.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) month.getLayoutData()).horizontalSpan = 1; Label year = new Label(_searchPDateComp, SWT.NONE); year.setText(NLMessages.getString("Dialog_year")); year.setLayoutData(new GridData()); ((GridData) year.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) year.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) year.getLayoutData()).horizontalSpan = 2; Label bl2 = new Label(_searchPDateComp, SWT.NONE); bl2.setText(""); //$NON-NLS-1$ Label notAfter = new Label(_searchPDateComp, SWT.NONE); notAfter.setText(NLMessages.getString("Dialog_day")); notAfter.setLayoutData(new GridData()); ((GridData) notAfter.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) notAfter.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) notAfter.getLayoutData()).horizontalSpan = 1; Label month2 = new Label(_searchPDateComp, SWT.NONE); month2.setText(NLMessages.getString("Dialog_month")); month2.setLayoutData(new GridData()); ((GridData) month2.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) month2.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) month2.getLayoutData()).horizontalSpan = 1; Label year2 = new Label(_searchPDateComp, SWT.NONE); year2.setText(NLMessages.getString("Dialog_year")); year2.setLayoutData(new GridData()); ((GridData) year2.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) year2.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) year2.getLayoutData()).horizontalSpan = 2; Label include = new Label(_searchPDateComp, SWT.NONE); include.setText(""); //$NON-NLS-1$ include.setToolTipText(NLMessages.getString("Dialog_includeConcurrences")); include.setLayoutData(new GridData()); ((GridData) include.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) include.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) include.getLayoutData()).horizontalSpan = 1; } if (i == 0) { Label l = new Label(_searchPDateComp, SWT.NONE); l.setLayoutData(new GridData()); ((GridData) l.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) l.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) l.getLayoutData()).horizontalSpan = 2; } else { final Combo opCombo = new Combo(_searchPDateComp, SWT.READ_ONLY); opCombo.setLayoutData(new GridData()); opCombo.add(Operator.AND.toString()); opCombo.add(Operator.OR.toString()); opCombo.add(Operator.NOT.toString()); opCombo.setLayoutData(new GridData()); ((GridData) opCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) opCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) opCombo.getLayoutData()).horizontalSpan = 2; if (c.getOperator() != null) { opCombo.setText(c.getOperator()); } else { opCombo.select(0); c.setOperator(opCombo.getItem(0)); } opCombo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { c.setOperator(opCombo.getItem(opCombo.getSelectionIndex())); } }); } final Combo typeDCombo = new Combo(_searchPDateComp, SWT.READ_ONLY); typeDCombo.setLayoutData(new GridData()); ComboViewer timeTypeComboViewer = new ComboViewer(typeDCombo); timeTypeComboViewer.setContentProvider(ArrayContentProvider.getInstance()); timeTypeComboViewer.setLabelProvider(new LabelProvider() { @Override public String getText(final Object element) { String str = (String) element; if (NLMessages.getString("Editor_time_" + str) != null) { return NLMessages.getString("Editor_time_" + str); } return str; } }); timeTypeComboViewer.setInput(AEConstants.TIME_TYPES); timeTypeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection selection = event.getSelection(); Object obj = ((IStructuredSelection) selection).getFirstElement(); String s = (String) obj; c.setDateType(s); } }); if (c.getDateType() != null) { StructuredSelection selection = new StructuredSelection(c.getDateType()); timeTypeComboViewer.setSelection(selection); } else { StructuredSelection selection = new StructuredSelection(AEConstants.TIME_TYPES[0]); timeTypeComboViewer.setSelection(selection); c.setDateType(AEConstants.TIME_TYPES[0]); } typeDCombo.pack(); typeDCombo.setLayoutData(new GridData()); ((GridData) typeDCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) typeDCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) typeDCombo.getLayoutData()).horizontalSpan = 2; Label from = new Label(_searchPDateComp, SWT.NONE); from.setText(NLMessages.getString("Dialog_from")); from.setLayoutData(new GridData()); ((GridData) from.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) from.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) from.getLayoutData()).horizontalSpan = 1; final Combo day1Combo = new Combo(_searchPDateComp, SWT.READ_ONLY); day1Combo.setLayoutData(new GridData()); day1Combo.setItems(AEConstants.DAYS); day1Combo.setLayoutData(new GridData()); ((GridData) day1Combo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) day1Combo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) day1Combo.getLayoutData()).horizontalSpan = 1; if (c.getDateFrom() == null) { PdrDate dateFrom = new PdrDate("0000-00-00"); //$NON-NLS-1$ // dateFrom.setDay(0); // dateFrom.setMonth(0); // dateFrom.setYear(0); c.setDateFrom(dateFrom); day1Combo.select(c.getDateFrom().getDay()); } // System.out.println("test: dateFrom " + c.getDateFrom().toString()); //$NON-NLS-1$ // else // { // // day1Combo.select(0); // c.getDateFrom().setDay(0); // // } day1Combo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { c.getDateFrom().setDay(day1Combo.getSelectionIndex()); } }); final Combo month1Combo = new Combo(_searchPDateComp, SWT.READ_ONLY); month1Combo.setLayoutData(new GridData()); month1Combo.setItems(AEConstants.MONTHS); month1Combo.setLayoutData(new GridData()); ((GridData) month1Combo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) month1Combo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) month1Combo.getLayoutData()).horizontalSpan = 1; if (c.getDateFrom() != null) { month1Combo.select(c.getDateFrom().getMonth()); } else { month1Combo.select(0); c.getDateFrom().setMonth(0); } month1Combo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { c.getDateFrom().setMonth(month1Combo.getSelectionIndex()); } }); final YearSpinner year1Spinner = new YearSpinner(_searchPDateComp, SWT.NULL); // year1Spinner.setLayoutData(new GridData()); // year1Spinner.setLayoutData(new GridData()); // ((GridData) year1Spinner.getLayoutData()).horizontalAlignment // = SWT.FILL; // ((GridData) // year1Spinner.getLayoutData()).grabExcessHorizontalSpace = // true; // ((GridData) year1Spinner.getLayoutData()).horizontalSpan = 2; // year1Spinner.setMinimum(0); // year1Spinner.setMaximum(9999); if (c.getDateFrom() != null) { year1Spinner.setSelection(c.getDateFrom().getYear()); } else { year1Spinner.setSelection(_preselection); c.getDateFrom().setYear(_preselection); } year1Spinner.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(final SelectionEvent e) { c.getDateFrom().setYear(year1Spinner.getSelection()); } @Override public void widgetSelected(final SelectionEvent e) { c.getDateFrom().setYear(year1Spinner.getSelection()); } }); Label to = new Label(_searchPDateComp, SWT.NONE); to.setText(NLMessages.getString("Dialog_to")); to.setLayoutData(new GridData()); ((GridData) to.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) to.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) to.getLayoutData()).horizontalSpan = 1; final Combo day2Combo = new Combo(_searchPDateComp, SWT.READ_ONLY); day2Combo.setLayoutData(new GridData()); day2Combo.setItems(AEConstants.DAYS); day2Combo.setLayoutData(new GridData()); ((GridData) day2Combo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) day2Combo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) day2Combo.getLayoutData()).horizontalSpan = 1; if (c.getDateTo() == null) { PdrDate dateTo = new PdrDate("0000-00-00"); //$NON-NLS-1$ c.setDateTo(dateTo); day2Combo.select(c.getDateTo().getDay()); } day2Combo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { c.getDateTo().setDay(day2Combo.getSelectionIndex()); } }); final Combo month2Combo = new Combo(_searchPDateComp, SWT.READ_ONLY); month2Combo.setLayoutData(new GridData()); month2Combo.setItems(AEConstants.MONTHS); month2Combo.setLayoutData(new GridData()); ((GridData) month2Combo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) month2Combo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) month2Combo.getLayoutData()).horizontalSpan = 1; if (c.getDateTo() != null) { month2Combo.select(c.getDateTo().getMonth()); } else { month2Combo.select(0); c.getDateTo().setMonth(0); } month2Combo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { c.getDateTo().setMonth(month2Combo.getSelectionIndex()); } }); final YearSpinner year2Spinner = new YearSpinner(_searchPDateComp, SWT.NONE); year2Spinner.setLayoutData(new GridData()); year2Spinner.setLayoutData(new GridData()); ((GridData) year2Spinner.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) year2Spinner.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) year2Spinner.getLayoutData()).horizontalSpan = 1; year2Spinner.setMinimum(0); year2Spinner.setMaximum(9999); if (c.getDateTo() != null) { year2Spinner.setSelection(c.getDateTo().getYear()); } else { year2Spinner.setSelection(_preselection); c.getDateTo().setYear(_preselection); } year2Spinner.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(final SelectionEvent e) { c.getDateTo().setYear(year2Spinner.getSelection()); } @Override public void widgetSelected(final SelectionEvent e) { c.getDateTo().setYear(year2Spinner.getSelection()); } }); final Button includeB = new Button(_searchPDateComp, SWT.CHECK); includeB.setLayoutData(new GridData()); includeB.setSelection(c.isIncludeConcurrences()); includeB.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { c.setIncludeConcurrences(!c.isIncludeConcurrences()); } }); } // if date } }
From source file:org.bbaw.pdr.ae.view.control.templates.aspectsemantic.controller.config.MarkupTemplateConfigEditor.java
License:Open Source License
private void loadIndividualSettings(final AspectConfigTemplate aspectConfigTemplate, Composite composite) { _prevWidget = null;// w ww . j a v a 2 s .co m for (Control c : composite.getChildren()) { c.dispose(); } boolean pathB = false; boolean combo = false; boolean date = false; boolean levelSpanB = false; boolean relation = false; boolean preSuffix = false; boolean horizontalSpan = false; switch (aspectConfigTemplate.getWidgetType()) { case 0: //text pathB = true; combo = false; date = false; levelSpanB = false; relation = false; preSuffix = true; horizontalSpan = true; break; case 1: //combo pathB = false; combo = true; date = false; levelSpanB = true; relation = false; preSuffix = true; horizontalSpan = true; break; case 2: //date pathB = true; combo = false; date = true; levelSpanB = false; relation = false; preSuffix = true; horizontalSpan = false; break; case 3: // date_combo pathB = false; combo = true; date = true; levelSpanB = true; relation = false; preSuffix = true; horizontalSpan = false; break; case 4: // relation pathB = false; combo = false; date = false; levelSpanB = false; relation = false; preSuffix = false; horizontalSpan = false; break; case 5: // relation_defined pathB = false; combo = false; date = false; levelSpanB = false; relation = true; preSuffix = false; horizontalSpan = true; break; case 6: // timeStm pathB = false; combo = false; date = true; levelSpanB = false; relation = false; preSuffix = false; horizontalSpan = false; break; case 7: // reference pathB = false; combo = false; date = false; levelSpanB = false; relation = false; preSuffix = false; horizontalSpan = false; break; default: break; } final boolean pathCombo = combo; // path SelectionListener aspectFacetListener = new SelectionAdapter() { @Override public void widgetDefaultSelected(final SelectionEvent e) { } @Override public void widgetSelected(final SelectionEvent e) { final String type = (String) ((Button) e.getSource()).getData(); aspectConfigTemplate.setPos(type); // System.out.println("aspectFacetQuery key set to " + type); //$NON-NLS-1$ if (type.equals("type")) //$NON-NLS-1$ { aspectConfigTemplate.setType(null); } else if (type.equals("subtype")) //$NON-NLS-1$ { aspectConfigTemplate.setSubtype(null); aspectConfigTemplate.setRole(null); } else if (type.equals("role")) //$NON-NLS-1$ { aspectConfigTemplate.setRole(null); } } }; if (pathB || pathCombo) { Label path = new Label(composite, SWT.RIGHT); path.setText(NLMessages.getString("Config_Path")); path.setLayoutData(new GridData()); ((GridData) path.getLayoutData()).horizontalSpan = 4; Label taggingElement = new Label(composite, SWT.NONE); taggingElement.setText(NLMessages.getString("Editor_markup_element") + "*"); taggingElement.setLayoutData(new GridData()); Combo comboTaggingElement = new Combo(composite, SWT.READ_ONLY | SWT.RIGHT); comboTaggingElement.setBackground(WHITE_COLOR); comboTaggingElement.setLayoutData(new GridData()); ((GridData) comboTaggingElement.getLayoutData()).horizontalSpan = 3; ((GridData) comboTaggingElement.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) comboTaggingElement.getLayoutData()).grabExcessHorizontalSpace = true; ComboViewer comboTaggingElementViewer = new ComboViewer(comboTaggingElement); comboTaggingElementViewer.setContentProvider(new MarkupContentProvider()); comboTaggingElementViewer.setLabelProvider(new MarkupLabelProvider()); if (_facade.getConfigs().containsKey(_provider)) { // TODO comboTaggingElementViewer // comboTaggingElementViewer.setInput( // _facade.getConfigs().get(_provider).getChildren()); comboTaggingElementViewer.setInput(getMarkupsOnLevel(aspectConfigTemplate, 0)); } final ControlDecoration elementDeco = new ControlDecoration(comboTaggingElement, SWT.RIGHT | SWT.TOP); elementDeco.setDescriptionText(PDRConfigProvider.readDocu(_provider, "markup", "element", aspectConfigTemplate.getElement(), null, null, null)); if (elementDeco.getDescriptionText() != null) { elementDeco.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage()); } else { elementDeco.setImage(null); } Label taggingType = new Label(composite, SWT.NONE); taggingType.setText(NLMessages.getString("Editor_type") + "*"); taggingType.setLayoutData(new GridData()); final Combo comboTaggingType = new Combo(composite, SWT.READ_ONLY | SWT.RIGHT); comboTaggingType.setBackground(WHITE_COLOR); comboTaggingType.setLayoutData(new GridData()); ((GridData) comboTaggingType.getLayoutData()).horizontalAlignment = GridData.FILL; ((GridData) comboTaggingType.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) comboTaggingType.getLayoutData()).horizontalSpan = 3; final ComboViewer comboTaggingTypeViewer = new ComboViewer(comboTaggingType); comboTaggingTypeViewer.setContentProvider(new MarkupContentProvider()); comboTaggingTypeViewer.setLabelProvider(new MarkupLabelProvider()); // comboTaggingType.setItems(readConfigs(_markupProvider, "markup", // "type", eListName, null, null)); final ControlDecoration typeDeco = new ControlDecoration(comboTaggingType, SWT.RIGHT | SWT.TOP); if (aspectConfigTemplate.getElement() != null) { if (aspectConfigTemplate.getElement().startsWith("aodl:")) { aspectConfigTemplate.setElement(aspectConfigTemplate.getElement().substring(5)); } if (_facade.getConfigs().get(_provider).getChildren() .containsKey(aspectConfigTemplate.getElement())) { if (pathCombo) { // comboTaggingTypeViewer.setInput( // // _facade.getConfigs().get(_provider).getChildren() // .get("aodl:" + aspectConfigTemplate.getElement()).getChildren()); // TODO comboTaggingTypeViewer comboTaggingTypeViewer.setInput(getMarkupsOnLevel(aspectConfigTemplate, 1)); ConfigItem ci = new ConfigItem(); ci.setLabel("COMBO Selection"); ci.setValue("COMBO Selection"); ViewHelper.comboViewerInsertElement(comboTaggingTypeViewer, ci, 0); } else { // comboTaggingTypeViewer.setInput(_facade.getConfigs().get(_provider).getChildren() // .get("aodl:" + aspectConfigTemplate.getElement()).getChildren()); // TODO: comboTaggingTypeViewer comboTaggingTypeViewer.setInput(getMarkupsOnLevel(aspectConfigTemplate, 1)); } } } Label taggingSubtype = new Label(composite, SWT.NONE); taggingSubtype.setText(NLMessages.getString("Editor_subtype")); taggingSubtype.setLayoutData(new GridData()); final Combo comboTaggingSubtype = new Combo(composite, SWT.READ_ONLY | SWT.RIGHT); comboTaggingSubtype.setBackground(WHITE_COLOR); comboTaggingSubtype.setLayoutData(new GridData()); ((GridData) comboTaggingSubtype.getLayoutData()).horizontalAlignment = GridData.FILL; ((GridData) comboTaggingSubtype.getLayoutData()).grabExcessHorizontalSpace = true; comboTaggingSubtype.setEnabled(false); final ComboViewer comboTaggingSubtypeViewer = new ComboViewer(comboTaggingSubtype); comboTaggingSubtypeViewer.setContentProvider(new MarkupContentProvider()); comboTaggingSubtypeViewer.setLabelProvider(new MarkupLabelProvider()); final ControlDecoration subtypeDeco = new ControlDecoration(comboTaggingSubtype, SWT.RIGHT | SWT.TOP); ((GridData) comboTaggingSubtype.getLayoutData()).horizontalSpan = 3; Label taggingRole = new Label(composite, SWT.NONE); taggingRole.setText(NLMessages.getString("Editor_role")); taggingRole.setLayoutData(new GridData()); final Combo comboTaggingRole = new Combo(composite, SWT.READ_ONLY | SWT.RIGHT); comboTaggingRole.setBackground(WHITE_COLOR); comboTaggingRole.setLayoutData(new GridData()); ((GridData) comboTaggingRole.getLayoutData()).horizontalAlignment = GridData.FILL; ((GridData) comboTaggingRole.getLayoutData()).grabExcessHorizontalSpace = true; final ComboViewer comboTaggingRoleViewer = new ComboViewer(comboTaggingRole); comboTaggingRoleViewer.setContentProvider(new MarkupContentProvider()); comboTaggingRoleViewer.setLabelProvider(new MarkupLabelProvider()); comboTaggingRole.setEnabled(false); final ControlDecoration roleDeco = new ControlDecoration(comboTaggingRole, SWT.RIGHT | SWT.TOP); ((GridData) comboTaggingRole.getLayoutData()).horizontalSpan = 3; _loading = true; comboTaggingElementViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); ConfigData cd = (ConfigData) obj; if (cd.getValue().startsWith("aodl:")) { aspectConfigTemplate.setElement(cd.getValue().substring(5)); } else { aspectConfigTemplate.setElement(cd.getValue()); } comboTaggingSubtype.removeAll(); comboTaggingSubtype.setEnabled(false); if (!_loading) { comboTaggingType.removeAll(); aspectConfigTemplate.setType(""); //$NON-NLS-1$ aspectConfigTemplate.setSubtype(""); //$NON-NLS-1$ aspectConfigTemplate.setRole(""); //$NON-NLS-1$ } comboTaggingRole.removeAll(); comboTaggingRole.setEnabled(false); elementDeco.setDescriptionText(PDRConfigProvider.readDocu(_provider, "markup", "element", aspectConfigTemplate.getElement(), null, null, null)); if (elementDeco.getDescriptionText() != null && elementDeco.getDescriptionText().trim().length() > 0) { elementDeco.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage()); } else { elementDeco.setImage(null); } typeDeco.setImage(null); typeDeco.setDescriptionText(null); subtypeDeco.setImage(null); subtypeDeco.setDescriptionText(null); roleDeco.setImage(null); roleDeco.setDescriptionText(null); if (_facade.getConfigs().containsKey(_provider)) { // HashMap<String,ConfigData> children = // _facade.getConfigs().get(_provider).getChildren() // .get("aodl:" + aspectConfigTemplate.getElement()).getChildren(); // TODO: comboTaggingTypeViewer comboTaggingTypeViewer.setInput(getMarkupsOnLevel(aspectConfigTemplate, 1)); if (pathCombo) { ConfigItem ci = new ConfigItem(); ci.setLabel("COMBO Selection"); ci.setValue("COMBO Selection"); ViewHelper.comboViewerInsertElement(comboTaggingTypeViewer, ci, 0); if (!_loading) { comboTaggingTypeViewer.setSelection(new StructuredSelection(ci)); aspectConfigTemplate.setPos("type"); } } else if (!_loading) { comboTaggingTypeViewer .setSelection(new StructuredSelection(comboTaggingTypeViewer.getElementAt(0))); } } comboTaggingTypeViewer.refresh(); // comboTaggingType.setItems(readConfigs(_markupProvider, // "markup", "type", eListName, null, null)); } }); comboTaggingTypeViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); ConfigData cd = (ConfigData) obj; comboTaggingSubtype.removeAll(); comboTaggingRole.removeAll(); comboTaggingRole.setEnabled(false); if (!_loading) { aspectConfigTemplate.setSubtype(""); //$NON-NLS-1$ aspectConfigTemplate.setRole(""); //$NON-NLS-1$ } if (cd != null) { if (cd.getValue().equals("COMBO Selection")) { comboTaggingRole.setEnabled(false); comboTaggingSubtype.setEnabled(false); aspectConfigTemplate.setType(null); aspectConfigTemplate.setSubtype(null); aspectConfigTemplate.setRole(null); aspectConfigTemplate.setPos("type"); } else { aspectConfigTemplate.setType(cd.getValue()); // ConfigData input = null; // if (_facade.getConfigs().containsKey(_provider)) // { // input = _facade.getConfigs().get(_provider).getChildren() // .get("aodl:" + aspectConfigTemplate.getElement()).getChildren() // .get(aspectConfigTemplate.getType()); // } // if (input != null) if (ifMarkupsOnLevel(aspectConfigTemplate, 1)) { //HashMap<String, ConfigData> children = input.getChildren(); // TODO comboTaggingSubtypeViewer HashMap<String, ConfigData> children = getMarkupsOnLevel(aspectConfigTemplate, 2); comboTaggingSubtypeViewer.setInput(children); if (pathCombo && !_loading) { ConfigItem ci = new ConfigItem(); ci.setLabel("COMBO Selection"); ci.setValue("COMBO Selection"); ViewHelper.comboViewerInsertElement(comboTaggingSubtypeViewer, ci, 0); if (!_loading) { comboTaggingSubtypeViewer.setSelection(new StructuredSelection(ci)); aspectConfigTemplate.setPos("subtype"); } } comboTaggingSubtype.setEnabled(true); } typeDeco.setDescriptionText(PDRConfigProvider.readDocu(_provider, "markup", "type", aspectConfigTemplate.getElement(), aspectConfigTemplate.getType(), null, null)); if (typeDeco.getDescriptionText() != null && typeDeco.getDescriptionText().trim().length() > 0) { typeDeco.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage()); } else { typeDeco.setImage(null); } } } subtypeDeco.setImage(null); subtypeDeco.setDescriptionText(null); roleDeco.setImage(null); roleDeco.setDescriptionText(null); processMarkupComboSettings(aspectConfigTemplate); updatePreviewWidget(aspectConfigTemplate); } }); // Label blancType = new Label(tagging1Coposite, SWT.NONE); // blancType.setText(""); // blancType.setLayoutData(new GridData()); comboTaggingSubtypeViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); ConfigData cd = (ConfigData) obj; if (cd != null) { aspectConfigTemplate.setSubtype(cd.getValue()); comboTaggingRole.removeAll(); if (!_loading) { aspectConfigTemplate.setRole(""); //$NON-NLS-1$ } comboTaggingSubtype.layout(); if (cd.getValue().equals("COMBO Selection") && !_loading) { comboTaggingRole.setEnabled(false); aspectConfigTemplate.setSubtype(null); aspectConfigTemplate.setRole(null); aspectConfigTemplate.setPos("subtype"); } else { // ConfigData input = _facade.getConfigs().get(_provider); // if (input != null) // { // input = input.getChildren().get("aodl:" + aspectConfigTemplate.getElement()); // } // if (input != null) // { // input = input.getChildren().get(aspectConfigTemplate.getType()); // } // if (input != null) // { // input = input.getChildren().get(aspectConfigTemplate.getSubtype()); // } // if (input != null) if (ifMarkupsOnLevel(aspectConfigTemplate, 2)) { // TODO comboTaggingRoleViewer HashMap<String, ConfigData> children = getMarkupsOnLevel(aspectConfigTemplate, 3); comboTaggingRoleViewer.setInput(children); if (pathCombo) { ConfigItem ci = new ConfigItem(); ci.setLabel("COMBO Selection"); ci.setValue("COMBO Selection"); ViewHelper.comboViewerInsertElement(comboTaggingRoleViewer, ci, 0); comboTaggingRoleViewer.setSelection(new StructuredSelection(ci)); aspectConfigTemplate.setPos("role"); } comboTaggingRole.setEnabled(true); } subtypeDeco.setDescriptionText(PDRConfigProvider.readDocu(_provider, "markup", "subtype", aspectConfigTemplate.getElement(), aspectConfigTemplate.getType(), aspectConfigTemplate.getSubtype(), null)); if (subtypeDeco.getDescriptionText() != null && subtypeDeco.getDescriptionText().trim().length() > 0) { subtypeDeco.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage()); } else { subtypeDeco.setImage(null); } } roleDeco.setImage(null); roleDeco.setDescriptionText(null); processMarkupComboSettings(aspectConfigTemplate); updatePreviewWidget(aspectConfigTemplate); } } }); // Label blancSubtype = new Label(tagging1Coposite, SWT.NONE); // blancSubtype.setText(""); // blancSubtype.setLayoutData(new GridData()); // end subtype comboTaggingRoleViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); ConfigData cd = (ConfigData) obj; if (cd != null) { if (cd.getValue().equals("COMBO Selection")) { aspectConfigTemplate.setRole(null); aspectConfigTemplate.setPos("role"); } else { aspectConfigTemplate.setRole(cd.getValue()); roleDeco.setDescriptionText(PDRConfigProvider.readDocu(_provider, "markup", "role", aspectConfigTemplate.getElement(), aspectConfigTemplate.getType(), aspectConfigTemplate.getSubtype(), aspectConfigTemplate.getRole())); if (roleDeco.getDescriptionText() != null && roleDeco.getDescriptionText().trim().length() > 0) { roleDeco.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage()); } else { roleDeco.setImage(null); } } processMarkupComboSettings(aspectConfigTemplate); updatePreviewWidget(aspectConfigTemplate); } else { roleDeco.setImage(null); } } }); // set combos if (date && comboTaggingElementViewer != null) { aspectConfigTemplate.setElement("date"); if (_facade.getConfigs().get(_provider) != null && _facade.getConfigs().get(_provider).getChildren().containsKey("aodl:date")) { comboTaggingElementViewer.setSelection(new StructuredSelection( _facade.getConfigs().get(_provider).getChildren().get("aodl:date"))); comboTaggingElement.setEnabled(false); comboTaggingType.setEnabled(true); comboTaggingTypeViewer.refresh(); } } if (aspectConfigTemplate.getElement() != null) { if (!aspectConfigTemplate.getElement().startsWith("aodl:")) { setComboViewerByString(comboTaggingElementViewer, "aodl:" + aspectConfigTemplate.getElement()); } else { setComboViewerByString(comboTaggingElementViewer, aspectConfigTemplate.getElement()); } if (aspectConfigTemplate.getType() != null) { // if (_facade.getConfigs().get(_provider) != null // && _facade.getConfigs().get(_provider).getChildren() // .get("aodl:" + aspectConfigTemplate.getElement()) != null) if (ifMarkupsOnLevel(aspectConfigTemplate, 0)) { // comboTaggingTypeViewer.setInput(_facade.getConfigs().get(_provider).getChildren() // .get("aodl:" + aspectConfigTemplate.getElement()).getChildren()); //TODO comboTaggingTypeViewer comboTaggingTypeViewer.setInput(getMarkupsOnLevel(aspectConfigTemplate, 1)); if (pathCombo && aspectConfigTemplate.getPos() != null && aspectConfigTemplate.getPos().equals("type")) { ConfigItem ci = new ConfigItem(); ci.setLabel("COMBO Selection"); ci.setValue("COMBO Selection"); ViewHelper.comboViewerInsertElement(comboTaggingTypeViewer, ci, 0); setComboViewerByString(comboTaggingTypeViewer, "COMBO Selection"); } else { setComboViewerByString(comboTaggingTypeViewer, aspectConfigTemplate.getType()); } // if (aspectConfigTemplate.getType() != null // && _facade.getConfigs().get(_provider).getChildren() // .get("aodl:" + aspectConfigTemplate.getElement()).getChildren() // .get(aspectConfigTemplate.getType()) != null) if (ifMarkupsOnLevel(aspectConfigTemplate, 1)) { // comboTaggingSubtypeViewer.setInput(_facade.getConfigs().get(_provider).getChildren() // .get("aodl:" + aspectConfigTemplate.getElement()).getChildren() // .get(aspectConfigTemplate.getType()).getChildren()); // TODO: comboTaggingSubtypeViewer comboTaggingSubtypeViewer.setInput(getMarkupsOnLevel(aspectConfigTemplate, 2)); if (pathCombo && aspectConfigTemplate.getPos() != null && aspectConfigTemplate.getPos().equals("subtype")) { ConfigData ci = new ConfigData(); ci.setLabel("COMBO Selection"); ci.setValue("COMBO Selection"); ViewHelper.comboViewerInsertElement(comboTaggingSubtypeViewer, ci, 0); setComboViewerByString(comboTaggingSubtypeViewer, "COMBO Selection"); } else { setComboViewerByString(comboTaggingSubtypeViewer, aspectConfigTemplate.getSubtype()); } // if (aspectConfigTemplate.getSubtype() != null // && _facade.getConfigs().get(_provider).getChildren() // .get("aodl:" + aspectConfigTemplate.getElement()).getChildren() // .get(aspectConfigTemplate.getType()).getChildren() // .get(aspectConfigTemplate.getSubtype()) != null) if (ifMarkupsOnLevel(aspectConfigTemplate, 2)) { // TODO comboTaggingRoleViewer comboTaggingRoleViewer.setInput(getMarkupsOnLevel(aspectConfigTemplate, 3)); if (pathCombo && aspectConfigTemplate.getPos() != null && aspectConfigTemplate.getPos().equals("role")) { ConfigItem ci = new ConfigItem(); ci.setLabel("COMBO Selection"); ci.setValue("COMBO Selection"); ViewHelper.comboViewerInsertElement(comboTaggingRoleViewer, ci, 0); setComboViewerByString(comboTaggingRoleViewer, "COMBO Selection"); } else { setComboViewerByString(comboTaggingRoleViewer, aspectConfigTemplate.getRole()); } } } } } _loading = false; } else { comboTaggingElementViewer.setSelection(new StructuredSelection( _facade.getConfigs().get(_provider).getChildren().get("aodl:persName"))); comboTaggingElement.setEnabled(true); if (_facade.getConfigs().containsKey(_provider)) { comboTaggingTypeViewer.setInput( _facade.getConfigs().get(_provider).getChildren().get("aodl:persName").getChildren()); } comboTaggingTypeViewer.refresh(); } } if (levelSpanB) { // levelSpan Label levelSpan = new Label(composite, SWT.NONE); levelSpan.setText(NLMessages.getString("Config_level_span")); levelSpan.setLayoutData(new GridData()); ((GridData) levelSpan.getLayoutData()).horizontalSpan = 1; ((GridData) levelSpan.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) levelSpan.getLayoutData()).horizontalAlignment = SWT.FILL; levelSpan.pack(); final Spinner levelSpanSpinner = new Spinner(composite, SWT.NONE | SWT.READ_ONLY); levelSpanSpinner.setLayoutData(new GridData()); ((GridData) levelSpanSpinner.getLayoutData()).horizontalSpan = 1; ((GridData) levelSpanSpinner.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) levelSpanSpinner.getLayoutData()).horizontalAlignment = SWT.FILL; levelSpanSpinner.setSelection(aspectConfigTemplate.getLevelSpan()); levelSpanSpinner.setMaximum(3); levelSpanSpinner.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { aspectConfigTemplate.setLevelSpan(levelSpanSpinner.getSelection()); updatePreviewWidget(aspectConfigTemplate); } }); // SelectionListener } if (combo) { Label levelSpan = new Label(composite, SWT.NONE); levelSpan.setText(NLMessages.getString("Config_Preview")); levelSpan.setLayoutData(new GridData()); ((GridData) levelSpan.getLayoutData()).horizontalSpan = 1; ((GridData) levelSpan.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) levelSpan.getLayoutData()).horizontalAlignment = SWT.FILL; levelSpan.pack(); Composite c = new Composite(composite, SWT.BORDER); c.setLayoutData(new GridData()); c.setLayout(new GridLayout(1, false)); ((GridLayout) c.getLayout()).marginHeight = 0; ((GridLayout) c.getLayout()).verticalSpacing = 0; ((GridLayout) c.getLayout()).marginWidth = 0; ((GridData) c.getLayoutData()).heightHint = 20; ((GridData) c.getLayoutData()).horizontalSpan = 1; ((GridData) c.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) c.getLayoutData()).horizontalAlignment = SWT.FILL; _prevWidget = new AEAspectWidgetCustomizable(c, aspectConfigTemplate, SWT.NONE); updatePreviewWidget(aspectConfigTemplate); c.layout(); c.pack(); } if (date) { Label date1 = new Label(composite, SWT.RIGHT); date1.setText(NLMessages.getString("Editor_add_dates") + "1"); date1.setLayoutData(new GridData()); final Combo date1Combo = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY); date1Combo.setBackground(WHITE_COLOR); date1Combo.setLayoutData(new GridData()); ((GridData) date1Combo.getLayoutData()).horizontalSpan = 1; ((GridData) date1Combo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) date1Combo.getLayoutData()).grabExcessHorizontalSpace = true; ComboViewer date1ComboViewer = new ComboViewer(date1Combo); date1ComboViewer.setContentProvider(ArrayContentProvider.getInstance()); date1ComboViewer.setLabelProvider(new LabelProvider() { @Override public String getText(final Object element) { String str = (String) element; if (NLMessages.getString("Editor_time_" + str) != null) { return NLMessages.getString("Editor_time_" + str); } return str; } }); date1ComboViewer.setInput(AEConstants.TIME_TYPES); date1ComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection selection = event.getSelection(); Object obj = ((IStructuredSelection) selection).getFirstElement(); String s = (String) obj; aspectConfigTemplate.setDate1(s); } }); if (aspectConfigTemplate.getDate1() != null) { StructuredSelection selection = new StructuredSelection(aspectConfigTemplate.getDate1()); date1ComboViewer.setSelection(selection); } else { date1Combo.select(0); ISelection selection = date1ComboViewer.getSelection(); Object obj = ((IStructuredSelection) selection).getFirstElement(); String s = (String) obj; aspectConfigTemplate.setDate1(s); } Label date2 = new Label(composite, SWT.RIGHT); date2.setText(NLMessages.getString("Editor_add_dates") + "2"); date2.setLayoutData(new GridData()); final Combo date2Combo = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY); date2Combo.setBackground(WHITE_COLOR); date2Combo.setLayoutData(new GridData()); ((GridData) date2Combo.getLayoutData()).horizontalSpan = 1; ((GridData) date2Combo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) date2Combo.getLayoutData()).grabExcessHorizontalSpace = true; ComboViewer date2ComboViewer = new ComboViewer(date2Combo); date2ComboViewer.setContentProvider(ArrayContentProvider.getInstance()); date2ComboViewer.setLabelProvider(new LabelProvider() { @Override public String getText(final Object element) { String str = (String) element; if (str.trim().length() > 0) { String label = NLMessages.getString("Editor_time_" + str); if (label != null && !label.startsWith("!")) { return label; } } return str; } }); String[] _afters = new String[] { "", "to", "notAfter" }; //$NON-NLS-1$ date2ComboViewer.setInput(_afters); date2ComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection selection = event.getSelection(); Object obj = ((IStructuredSelection) selection).getFirstElement(); String s = (String) obj; aspectConfigTemplate.setDate2(s); } }); if (aspectConfigTemplate.getDate2() != null) { StructuredSelection selection = new StructuredSelection(aspectConfigTemplate.getDate2()); date2ComboViewer.setSelection(selection); } else { date2Combo.select(0); ISelection selection = date2ComboViewer.getSelection(); Object obj = ((IStructuredSelection) selection).getFirstElement(); String s = (String) obj; aspectConfigTemplate.setDate2(s); } } if (relation) { Label relationContextLabel = new Label(composite, SWT.NONE); relationContextLabel.setText(NLMessages.getString("Editor_context")); relationContextLabel.setLayoutData(new GridData()); ((GridData) relationContextLabel.getLayoutData()).horizontalSpan = 1; Combo relationContextCombo = new Combo(composite, SWT.READ_ONLY); relationContextCombo.setBackground(WHITE_COLOR); relationContextCombo.setLayoutData(new GridData()); ((GridData) relationContextCombo.getLayoutData()).horizontalSpan = 3; ((GridData) relationContextCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) relationContextCombo.getLayoutData()).grabExcessHorizontalSpace = true; final ComboViewer relationContextComboViewer = new ComboViewer(relationContextCombo); relationContextComboViewer.setContentProvider(new MarkupContentProvider()); relationContextComboViewer.setLabelProvider(new MarkupLabelProvider()); final ControlDecoration relContextDeco = new ControlDecoration(relationContextCombo, SWT.RIGHT | SWT.TOP); Label relationTypeLabel = new Label(composite, SWT.NONE); relationTypeLabel.setText(NLMessages.getString("Editor_class")); relationTypeLabel.setLayoutData(new GridData()); ((GridData) relationTypeLabel.getLayoutData()).horizontalSpan = 1; final Combo relationClassCombo = new Combo(composite, SWT.READ_ONLY); relationClassCombo.setBackground(WHITE_COLOR); relationClassCombo.setLayoutData(new GridData()); ((GridData) relationClassCombo.getLayoutData()).horizontalSpan = 3; ((GridData) relationClassCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) relationClassCombo.getLayoutData()).grabExcessHorizontalSpace = true; final ComboViewer relationClassComboViewer = new ComboViewer(relationClassCombo); relationClassComboViewer.setContentProvider(new MarkupContentProvider()); relationClassComboViewer.setLabelProvider(new MarkupLabelProvider()); final ControlDecoration relClassDeco = new ControlDecoration(relationClassCombo, SWT.RIGHT | SWT.TOP); Label relCitationLabel = new Label(composite, SWT.NONE); relCitationLabel.setText(NLMessages.getString("Config_value")); relCitationLabel.setLayoutData(new GridData()); final Combo relValueCombo = new Combo(composite, SWT.BORDER | SWT.READ_ONLY); relValueCombo.setBackground(WHITE_COLOR); relValueCombo.setLayoutData(new GridData()); ((GridData) relValueCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) relValueCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) relValueCombo.getLayoutData()).horizontalSpan = 3; final ComboViewer relValueComboViewer = new ComboViewer(relValueCombo); relValueComboViewer.setContentProvider(new MarkupContentProvider()); relValueComboViewer.setLabelProvider(new MarkupLabelProvider()); final ControlDecoration relValueDeco = new ControlDecoration(relValueCombo, SWT.RIGHT | SWT.TOP); if (_facade.getConfigs().get(_provider) != null) { relationContextComboViewer.setInput( _facade.getConfigs().get(_provider).getChildren().get("aodl:relation").getChildren()); } // control for relationClassCombo // ArrayList<String> list = cListPro // .getList("types", "type", "relation"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ // for (int n = 0; n < list.size(); n++) // { // relationClassCombo.add(list.get(n)); // } if (aspectConfigTemplate.getElement() != null) { setComboViewerByString(relationContextComboViewer, aspectConfigTemplate.getElement()); } relationContextComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); ConfigData cd = (ConfigData) obj; aspectConfigTemplate.setElement(cd.getValue()); relationClassCombo.removeAll(); relValueCombo.removeAll(); relContextDeco.setDescriptionText(PDRConfigProvider.readDocu(_provider, "relation", "context", aspectConfigTemplate.getElement(), null, null, null)); if (relContextDeco.getDescriptionText() != null) { relContextDeco.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage()); } else { relContextDeco.setImage(null); } relationClassComboViewer .setInput(_facade.getConfigs().get(_provider).getChildren().get("aodl:relation") .getChildren().get(aspectConfigTemplate.getElement()).getChildren()); } }); relationContextCombo.layout(); // control for relationContextCombo if (aspectConfigTemplate.getType() != null) { if (aspectConfigTemplate.getElement() != null && _facade.getConfigs().get(_provider) != null && _facade.getConfigs().get(_provider).getChildren().get("aodl:relation") != null && _facade.getConfigs().get(_provider).getChildren().get("aodl:relation").getChildren() .get(aspectConfigTemplate.getElement()) != null) { relationClassComboViewer .setInput(_facade.getConfigs().get(_provider).getChildren().get("aodl:relation") .getChildren().get(aspectConfigTemplate.getElement()).getChildren()); } setComboViewerByString(relationClassComboViewer, aspectConfigTemplate.getType()); } else { relationClassComboViewer.setInput(null); relationClassComboViewer.refresh(); } relationClassComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); ConfigData cd = (ConfigData) obj; aspectConfigTemplate.setType(cd.getValue()); relValueComboViewer.setInput(_facade.getConfigs().get(_provider).getChildren() .get("aodl:relation").getChildren().get(aspectConfigTemplate.getElement()).getChildren() .get(aspectConfigTemplate.getType()).getChildren()); relValueComboViewer.refresh(); relClassDeco.setDescriptionText(PDRConfigProvider.readDocu(_provider, "relation", "class", aspectConfigTemplate.getElement(), aspectConfigTemplate.getType(), null, null)); if (relClassDeco.getDescriptionText() != null) { relClassDeco.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage()); } else { relClassDeco.setImage(null); } } }); relationClassCombo.layout(); if (aspectConfigTemplate.getSubtype() != null) { if (aspectConfigTemplate.getType() != null && _facade.getConfigs().get(_provider) != null && _facade.getConfigs().get(_provider).getChildren().get("aodl:relation") != null && _facade.getConfigs().get(_provider).getChildren().get("aodl:relation").getChildren() .get(aspectConfigTemplate.getElement()) != null && _facade.getConfigs().get(_provider).getChildren().get("aodl:relation").getChildren() .get(aspectConfigTemplate.getElement()).getChildren() .get(aspectConfigTemplate.getType()) != null) { relValueComboViewer.setInput(_facade.getConfigs().get(_provider).getChildren() .get("aodl:relation").getChildren().get(aspectConfigTemplate.getElement()).getChildren() .get(aspectConfigTemplate.getType()).getChildren()); } setComboViewerByString(relValueComboViewer, aspectConfigTemplate.getSubtype()); } else { relValueComboViewer.setInput(null); relValueComboViewer.refresh(); } relValueComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); ConfigData cd = (ConfigData) obj; aspectConfigTemplate.setSubtype(cd.getValue()); relValueDeco.setDescriptionText(PDRConfigProvider.readDocu(_provider, "relation", "value", aspectConfigTemplate.getElement(), aspectConfigTemplate.getType(), aspectConfigTemplate.getSubtype(), null)); if (relValueDeco.getDescriptionText() != null) { relValueDeco.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage()); } else { relValueDeco.setImage(null); } } }); } if (preSuffix) { Label prefix = new Label(composite, SWT.NONE); prefix.setText(NLMessages.getString("Config_Prefix")); prefix.setLayoutData(new GridData()); final Text prefixText = new Text(composite, SWT.BORDER); prefixText.setLayoutData(new GridData()); ((GridData) prefixText.getLayoutData()).horizontalSpan = 1; ((GridData) prefixText.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) prefixText.getLayoutData()).horizontalAlignment = SWT.FILL; if (aspectConfigTemplate.getPrefix() != null) { prefixText.setText(aspectConfigTemplate.getPrefix()); } else { prefixText.setText(""); } prefixText.addFocusListener(new FocusAdapter() { @Override public void focusLost(final FocusEvent e) { aspectConfigTemplate.setPrefix(prefixText.getText().trim()); // if (c instanceof ConfigItem) // { // ((ConfigItem) c).setLabel(labelText.getText().trim()); // } } }); Label suffix = new Label(composite, SWT.NONE); suffix.setText(NLMessages.getString("Config_suffix")); suffix.setLayoutData(new GridData()); final Text suffixText = new Text(composite, SWT.BORDER); suffixText.setLayoutData(new GridData()); ((GridData) suffixText.getLayoutData()).horizontalSpan = 1; ((GridData) suffixText.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) suffixText.getLayoutData()).horizontalAlignment = SWT.FILL; if (aspectConfigTemplate.getSuffix() != null) { suffixText.setText(aspectConfigTemplate.getSuffix()); } else { suffixText.setText(""); } suffixText.addFocusListener(new FocusAdapter() { @Override public void focusLost(final FocusEvent e) { aspectConfigTemplate.setSuffix(suffixText.getText().trim()); // if (c instanceof ConfigItem) // { // ((ConfigItem) c).setLabel(labelText.getText().trim()); // } } }); } // levelSpan if (horizontalSpan) { Label horizontalSpanL = new Label(composite, SWT.NONE); horizontalSpanL.setText(NLMessages.getString("Config_horizontal_span")); horizontalSpanL.setLayoutData(new GridData()); ((GridData) horizontalSpanL.getLayoutData()).horizontalSpan = 1; ((GridData) horizontalSpanL.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) horizontalSpanL.getLayoutData()).horizontalAlignment = SWT.FILL; horizontalSpanL.pack(); final Combo horizontalSpanCombo = new Combo(composite, SWT.NONE | SWT.READ_ONLY); horizontalSpanCombo.setLayoutData(new GridData()); ((GridData) horizontalSpanCombo.getLayoutData()).horizontalSpan = 1; ((GridData) horizontalSpanCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) horizontalSpanCombo.getLayoutData()).horizontalAlignment = SWT.FILL; if (relation) { horizontalSpanCombo.setItems(new String[] { "50%", "75%", "100%" }); } else { horizontalSpanCombo.setItems(new String[] { "25%", "50%", "75%", "100%" }); } horizontalSpanCombo.select(aspectConfigTemplate.getHorizontalSpan() - 1); horizontalSpanCombo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { String selection = horizontalSpanCombo.getItem(horizontalSpanCombo.getSelectionIndex()); if (selection.startsWith("25")) { aspectConfigTemplate.setHorizontalSpan(1); } else if (selection.startsWith("50")) { aspectConfigTemplate.setHorizontalSpan(2); } else if (selection.startsWith("75")) { aspectConfigTemplate.setHorizontalSpan(3); } else if (selection.startsWith("100")) { aspectConfigTemplate.setHorizontalSpan(4); } } }); // SelectionListener } else { aspectConfigTemplate.setHorizontalSpan(4); } composite.layout(); }
From source file:org.bbaw.pdr.ae.view.editorlite.view.PersonAspectEditor.java
License:Open Source License
/** * Load identifiers./* www. ja v a2s .com*/ * @param add the add * @param del the del */ private void loadIdentifiers(final boolean add, final Integer del) { if (_scrollCompIdentifier != null) { _scrollCompIdentifier.dispose(); } _scrollCompIdentifier = new ScrolledComposite((Composite) _identifierTabItem.getControl(), SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); _identifierTabItem.setData("sc", _scrollCompIdentifier); _scrollCompIdentifier.setExpandHorizontal(true); _scrollCompIdentifier.setExpandVertical(true); _scrollCompIdentifier.setMinSize(SWT.DEFAULT, SWT.DEFAULT); _scrollCompIdentifier.setLayoutData(new GridData()); ((GridData) _scrollCompIdentifier.getLayoutData()).heightHint = 380; ((GridData) _scrollCompIdentifier.getLayoutData()).widthHint = 630; ((GridData) _scrollCompIdentifier.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) _scrollCompIdentifier.getLayoutData()).grabExcessHorizontalSpace = true; _scrollCompIdentifier.setMinHeight(1); _scrollCompIdentifier.setMinWidth(1); _scrollCompIdentifier.setLayout(new GridLayout()); Composite contentCompIdentifier = new Composite(_scrollCompIdentifier, SWT.NONE); contentCompIdentifier.setLayout(new GridLayout()); _scrollCompIdentifier.setContent(contentCompIdentifier); if (add && _currentPerson.getIdentifiers() == null) { _currentPerson.setIdentifiers(new Identifiers()); _currentPerson.getIdentifiers().setIdentifiers(new Vector<Identifier>()); _currentPerson.getIdentifiers().getIdentifiers().add(new Identifier()); } else if (add) { _currentPerson.getIdentifiers().getIdentifiers().add(new Identifier()); } if (del != null) { // System.out.println("old size " + _currentPerson.getIdentifiers().getIdentifiers().size()); //$NON-NLS-1$ _currentPerson.getIdentifiers().remove(del); } for (int i = 0; i < _currentPerson.getIdentifiers().getIdentifiers().size(); i++) { int m = i + 1; final Identifier identifier = _currentPerson.getIdentifiers().getIdentifiers().get(i); final Group idGroup = new Group(contentCompIdentifier, SWT.SHADOW_IN); idGroup.setText(NLMessages.getString("Editor_externalIdentifiers") + m); //$NON-NLS-1$ idGroup.setLayoutData(new GridData()); idGroup.setLayout(new GridLayout()); idGroup.setData("num", i); //$NON-NLS-1$ ((GridData) idGroup.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) idGroup.getLayoutData()).grabExcessHorizontalSpace = true; ((GridLayout) idGroup.getLayout()).numColumns = 5; ((GridLayout) idGroup.getLayout()).makeColumnsEqualWidth = false; final Combo idProviderCombo = new Combo(idGroup, SWT.DROP_DOWN | SWT.READ_ONLY); idProviderCombo.setEnabled(_mayWritePerson); idProviderCombo.setBackground(WHITE_COLOR); final ComboViewer idProviderComboViewer = new ComboViewer(idProviderCombo); idProviderComboViewer.setContentProvider(new MarkupContentProvider()); idProviderComboViewer.setLabelProvider(new MarkupLabelProvider()); idProviderCombo.setLayoutData(new GridData()); ((GridData) idProviderCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) idProviderCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) idProviderCombo.getLayoutData()).horizontalIndent = 6; if (_facade.getConfigs().get(_configProvider) != null && _facade.getConfigs().get(_configProvider).getUsage() != null && !_facade.getConfigs() .get(_configProvider).getUsage().getIdentifiers().getChildren().isEmpty()) { ConfigData cd = _facade.getConfigs().get(_configProvider).getUsage().getIdentifiers(); idProviderComboViewer.setInput(cd.getChildren()); } idProviderComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); IAEPresentable cp = (IAEPresentable) obj; if (cp != null) { identifier.setProvider(cp.getValue()); validate(); } } }); if (identifier.getProvider() != null) { ViewHelper.setComboViewerByString(idProviderComboViewer, identifier.getProvider(), true); } else if (idProviderCombo.getItemCount() > 0) { idProviderComboViewer.setSelection(new StructuredSelection(idProviderComboViewer.getElementAt(0))); } final Text idText = new Text(idGroup, SWT.BORDER); idText.setLayoutData(new GridData()); idText.setEditable(_mayWritePerson); idText.setBackground(WHITE_COLOR); ((GridData) idText.getLayoutData()).horizontalSpan = 3; ((GridData) idText.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) idText.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) idText.getLayoutData()).horizontalIndent = 8; final ControlDecoration decoIdent = new ControlDecoration(idText, SWT.LEFT | SWT.TOP); if (identifier.getIdentifier() != null) { idText.setText(identifier.getIdentifier()); //$NON-NLS-1$ } else { idText.setText(""); //$NON-NLS-1$ decoIdent.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED).getImage()); } idText.addFocusListener(new FocusAdapter() { @Override public void focusLost(final FocusEvent e) { identifier.setIdentifier(idText.getText()); //$NON-NLS-1$ if (identifier.isValidId()) { decoIdent.setImage(null); } else { decoIdent.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED).getImage()); } validate(); } }); idText.addKeyListener(new KeyListener() { @Override public void keyPressed(final KeyEvent e) { } @Override public void keyReleased(final KeyEvent e) { // System.out.println("key released"); //$NON-NLS-1$ identifier.setIdentifier(idText.getText()); //$NON-NLS-1$ if (identifier.isValidId()) { decoIdent.setImage(null); } else { decoIdent.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED).getImage()); } validate(); } }); final Button showData = new Button(idGroup, SWT.PUSH); showData.setText(NLMessages.getString("Editor_showData")); //$NON-NLS-1$ showData.setToolTipText(NLMessages.getString("Editor_showData_tooltip")); showData.setImage(_imageReg.get(IconsInternal.BROWSER)); showData.setLayoutData(new GridData()); showData.setData("num", i); //$NON-NLS-1$ showData.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench() .getService(IHandlerService.class); _facade.setRequestedIdentifierType(identifier.getProvider()); //$NON-NLS-1$ _facade.setRequestedIdentifier(identifier.getIdentifier()); //$NON-NLS-1$ try { handlerService.executeCommand("org.bbaw.pdr.ae.view.identifiers.commands" + //$NON-NLS-1$ ".OpenBrowserDialog", null); //$NON-NLS-1$ } catch (ExecutionException e) { e.printStackTrace(); } catch (NotDefinedException e) { e.printStackTrace(); } catch (NotEnabledException e) { e.printStackTrace(); } catch (NotHandledException e) { e.printStackTrace(); } } }); Label qualityLabel = new Label(idGroup, SWT.NONE); qualityLabel.setText(""); //$NON-NLS-1$ qualityLabel.setLayoutData(new GridData()); final ControlDecoration decoIdentQual = new ControlDecoration(qualityLabel, SWT.LEFT | SWT.TOP); // final String qual = ""; SelectionListener idListener = new SelectionAdapter() { @Override public void widgetDefaultSelected(final SelectionEvent e) { validate(); } @Override public void widgetSelected(final SelectionEvent e) { final String qual = (String) ((Button) e.getSource()).getData("text"); // System.out.println("pnd qual: " + pndQual); //$NON-NLS-1$ identifier.setQuality(qual); //$NON-NLS-1$ if (identifier.isValidQuality()) { decoIdentQual.setImage(null); } else { decoIdentQual.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED).getImage()); } validate(); } }; final Button[] radios = new Button[_ratings.length]; for (int j = 0; j < _ratings.length; j++) { radios[j] = new Button(idGroup, SWT.RADIO); radios[j].setText(NLMessages.getString("Editor_" + _ratings[j])); radios[j].setData("text", _ratings[j]); radios[j].setEnabled(_mayWritePerson); radios[j].setLayoutData(new GridData()); radios[j].addSelectionListener(idListener); } if (identifier.getQuality() != null) { ViewHelper.setRadioByString(radios, identifier.getQuality()); } else { decoIdentQual.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED).getImage()); } Label b = new Label(idGroup, SWT.NONE); b.setText(""); //$NON-NLS-1$ b.setLayoutData(new GridData()); Label idAuthorityLabel = new Label(idGroup, SWT.NONE); idAuthorityLabel.setText(NLMessages.getString("Editor_createdBy")); //$NON-NLS-1$ idAuthorityLabel.setLayoutData(new GridData()); final Text idAuthorityText = new Text(idGroup, SWT.BORDER | SWT.READ_ONLY); idAuthorityText.setData("num", i); //$NON-NLS-1$ if (identifier.getAuthority() != null) { User u = null; try { u = _facade.getUserManager().getUserById(identifier.getAuthority().toString()); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } if (u != null) { idAuthorityText.setText(u.getDisplayName()); } else { idAuthorityText.setText(identifier.getAuthority().toString()); } } else { idAuthorityText.setText(_facade.getCurrentUser().getPdrId().toString()); identifier.setAuthority(_facade.getCurrentUser().getPdrId()); } idAuthorityText.setLayoutData(new GridData()); ((GridData) idAuthorityText.getLayoutData()).horizontalSpan = 3; ((GridData) idAuthorityText.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) idAuthorityText.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) idAuthorityText.getLayoutData()).horizontalIndent = 8; final Button delIdentifier = new Button(idGroup, SWT.PUSH); delIdentifier.setText(NLMessages.getString("Editor_delete")); //$NON-NLS-1$ delIdentifier.setToolTipText(NLMessages.getString("Editor_remove_identifier_tooltip")); delIdentifier.setImage(_imageReg.get(IconsInternal.IDENTIFIER_REMOVE)); delIdentifier.setLayoutData(new GridData()); delIdentifier.setData("num", i); //$NON-NLS-1$ delIdentifier.setEnabled(_mayWritePerson); delIdentifier.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { // System.out.println("del identifier " + (Integer) delIdentifier.getData("num")); //$NON-NLS-1$ //$NON-NLS-2$ loadIdentifiers(false, (Integer) delIdentifier.getData("num")); //$NON-NLS-1$ validate(); } }); idGroup.layout(); idGroup.pack(); } // idGroup contentCompIdentifier.redraw(); contentCompIdentifier.layout(); _scrollCompIdentifier.setContent(contentCompIdentifier); Point point = contentCompIdentifier.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); Point mp = _tabFolder.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); if (point.x > mp.x - 20) { point.x = mp.x - 20; } if (point.y > mp.y - 20) { point.y = mp.y - 20; } _scrollCompIdentifier.setMinSize(point); _scrollCompIdentifier.layout(); _identifierTabItem.getControl().redraw(); ((Composite) _identifierTabItem.getControl()).layout(); _identifierTabItem.getControl().update(); }
From source file:org.bbaw.pdr.ae.view.identifiers.view.IdentifierSearchView.java
License:Open Source License
/** * Create contents of the view part.//from w w w . ja v a 2 s . c om */ @Override public void createPartControl(Composite parent) { createSelectionListener(); IWorkbenchWindow ww = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); ISelectionService selService = ww.getSelectionService(); selService.addSelectionListener(AEPluginIDs.VIEW_TREEVIEW, _mainSelectionListener); _facade.addObserver(this); Composite container = new Composite(parent, SWT.NONE); container.setLayout(new GridLayout(1, false)); _resultMap = new HashMap<PdrId, ConcurrenceDataHead>(); Composite compositeHead = new Composite(container, SWT.NONE); compositeHead.setLayout(new GridLayout(5, false)); compositeHead.setLayoutData(new GridData()); ((GridData) compositeHead.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) compositeHead.getLayoutData()).grabExcessHorizontalSpace = true; SelectionAdapter radioSelAdapter = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { _searchTarget = (Integer) ((Button) e.getSource()).getData(); } }; Label lblPersonsToProcess = new Label(compositeHead, SWT.NONE); lblPersonsToProcess.setText("Persons:"); Button btnRadioButton = new Button(compositeHead, SWT.RADIO); btnRadioButton.setData(0); btnRadioButton.addSelectionListener(radioSelAdapter); btnRadioButton.setText("All Persons"); Button btnRadioButton_1 = new Button(compositeHead, SWT.RADIO); btnRadioButton_1.setText("Selected Tree"); btnRadioButton_1.setData(1); btnRadioButton_1.addSelectionListener(radioSelAdapter); Button btnRadioButton_2 = new Button(compositeHead, SWT.RADIO); btnRadioButton_2.setText("Selected Persons"); btnRadioButton_2.setData(2); btnRadioButton_2.addSelectionListener(radioSelAdapter); btnRadioButton_2.setSelection(_searchTarget == 2); Button chaine2Selection = new Button(compositeHead, SWT.CHECK); chaine2Selection.setText("Chain2Selection"); chaine2Selection.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { _chain2Selection = !_chain2Selection; } }); chaine2Selection.setSelection(_chain2Selection); Composite composite_2 = new Composite(compositeHead, SWT.NONE); composite_2.setLayout(new GridLayout(4, false)); composite_2.setLayoutData(new GridData()); ((GridData) composite_2.getLayoutData()).horizontalSpan = 5; ((GridData) composite_2.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) composite_2.getLayoutData()).grabExcessHorizontalSpace = true; Label lblWebservice = new Label(composite_2, SWT.NONE); lblWebservice.setText("Webservice"); ComboViewer comboViewer = new ComboViewer(composite_2, SWT.READ_ONLY); Combo combo_1 = comboViewer.getCombo(); combo_1.setLayoutData(new GridData()); ((GridData) combo_1.getLayoutData()).horizontalSpan = 2; ((GridData) combo_1.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) combo_1.getLayoutData()).grabExcessHorizontalSpace = true; comboViewer.setContentProvider(new AEConfigPresentableContentProvider()); comboViewer.setLabelProvider(new AEConfigPresentableLabelProvider()); if (IdentifiersExtension.getConcurrenceSearchServices() != null) { comboViewer.setInput(IdentifiersExtension.getConcurrenceSearchServices()); } comboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); _concurrenceSearchService = (IConcurrenceSearchService) obj; } }); Object in = comboViewer.getInput(); if (in instanceof Map<?, ?>) { Map<String, IConcurrenceSearchService> map = (Map<String, IConcurrenceSearchService>) in; String pdrKey = null; for (String s : map.keySet()) { if (s.toLowerCase().contains("pdr")) { pdrKey = s; break; } } if (pdrKey != null) { IConcurrenceSearchService service = map.get(pdrKey); comboViewer.setSelection(new StructuredSelection(service)); } else if (comboViewer.getElementAt(0) != null) { comboViewer.setSelection(new StructuredSelection(comboViewer.getElementAt(0))); } } Button btnGo = new Button(composite_2, SWT.NONE); btnGo.setText("GO"); btnGo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (_selectedPerson != null) { if (_resultMap == null) { _resultMap = new HashMap<PdrId, ConcurrenceDataHead>(); } if (!_resultMap.containsKey(_selectedPerson.getPdrId())) { searchConcurringPersons(_searchTarget, _concurrenceSearchService); } else if (_resultMap.containsKey(_selectedPerson.getPdrId()) && !_resultMap.get(_selectedPerson.getPdrId()).getServices() .contains(_concurrenceSearchService.getLabel())) { searchConcurringPersons(_searchTarget, _concurrenceSearchService); } else { loadConcurrenceData(_selectedPerson, _resultMap.get(_selectedPerson.getPdrId())); } } else if (_searchTarget < 2) { searchConcurringPersons(_searchTarget, _concurrenceSearchService); } } }); _scrolledComposite = new ScrolledComposite(container, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); _scrolledComposite.setLayoutData(new GridData()); ((GridData) _scrolledComposite.getLayoutData()).horizontalSpan = 1; ((GridData) _scrolledComposite.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) _scrolledComposite.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) _scrolledComposite.getLayoutData()).verticalAlignment = SWT.FILL; ((GridData) _scrolledComposite.getLayoutData()).grabExcessVerticalSpace = true; _scrolledComposite.setExpandHorizontal(true); _scrolledComposite.setExpandVertical(true); _scrolledComposite.setBackground(AEVIEWConstants.VIEW_BACKGROUND_SELECTED_COLOR); _contentComposite = new Composite(_scrolledComposite, SWT.NONE); _contentComposite.setLayout(new GridLayout(1, false)); _scrolledComposite.setContent(_contentComposite); _contentComposite.setLayoutData(new GridData()); ((GridData) _contentComposite.getLayoutData()).horizontalSpan = 1; ((GridData) _contentComposite.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) _contentComposite.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) _contentComposite.getLayoutData()).verticalAlignment = SWT.FILL; ((GridData) _contentComposite.getLayoutData()).grabExcessVerticalSpace = true; _contentComposite.setBackground(AEVIEWConstants.VIEW_BACKGROUND_DESELECTED_COLOR); }
From source file:org.bbaw.pdr.ae.view.main.dialogs.AdvancedSearchDialog.java
License:Open Source License
/** * Builds the facet aspect search.//from w w w . j ava 2s.co m * @param type the type * @param crit the crit */ private void buildFacetAspectSearch(final int type, final Integer crit) { DataType dtAll = new DataType(); dtAll.setValue("ALL"); //$NON-NLS-1$ dtAll.setLabel("ALL"); //$NON-NLS-1$ boolean tag1 = true; boolean date1 = true; Composite searchPFacetComp = new Composite(_facetAspectSearchGroup, SWT.NONE); searchPFacetComp.setLayout(new GridLayout()); ((GridLayout) searchPFacetComp.getLayout()).makeColumnsEqualWidth = true; ((GridLayout) searchPFacetComp.getLayout()).numColumns = 12; searchPFacetComp.setLayoutData(new GridData()); ((GridData) searchPFacetComp.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) searchPFacetComp.getLayoutData()).grabExcessHorizontalSpace = true; // ((GridData) searchPTagComp.getLayoutData()).heightHint = 200; ((GridData) searchPFacetComp.getLayoutData()).grabExcessVerticalSpace = false; ((GridData) searchPFacetComp.getLayoutData()).horizontalSpan = 1; Label aspectFacet = new Label(searchPFacetComp, SWT.NONE); aspectFacet.setText("Choose aspectFacets"); //$NON-NLS-1$ aspectFacet.setLayoutData(new GridData()); ((GridData) aspectFacet.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) aspectFacet.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) aspectFacet.getLayoutData()).horizontalSpan = 4; SelectionListener aspectFacetListener = new SelectionAdapter() { @Override public void widgetDefaultSelected(final SelectionEvent e) { } @SuppressWarnings("unchecked") @Override public void widgetSelected(final SelectionEvent e) { final String type = (String) ((Button) e.getSource()).getData(); _aspectFacetQuery.setKey(type); // System.out.println("aspectFacetQuery key set to " + type); //$NON-NLS-1$ if (type.equals("content")) //$NON-NLS-1$ { try { _aspectFacetStrings = _mainSearcher.getFacets("tagging", _aspectFacetElement, //$NON-NLS-1$ _aspectFacetType, _aspectFacetSubtype, _aspectFacetRole); setQueryFacets(_aspectFacetQuery, _aspectFacetStrings); _aspectFacetCombo.setItems(_aspectFacetStrings); } catch (Exception e1) { e1.printStackTrace(); } } else if (type.equals("type")) //$NON-NLS-1$ { try { _aspectFacetStrings = (_mainSearcher.getFacets("tagging_values", _aspectFacetElement, null, //$NON-NLS-1$ null, null)); } catch (Exception e1) { e1.printStackTrace(); } _aspectFacetQuery .setFacets((HashMap<String, IAEPresentable>) _aspectFacetTypeComboViewer.getInput()); } else if (type.equals("subtype")) //$NON-NLS-1$ { try { _aspectFacetStrings = (_mainSearcher.getFacets("tagging_values", _aspectFacetElement, //$NON-NLS-1$ _aspectFacetType, null, null)); } catch (Exception e1) { e1.printStackTrace(); } _aspectFacetQuery .setFacets((HashMap<String, IAEPresentable>) _aspectFacetSubtypeComboViewer.getInput()); } else if (type.equals("role")) //$NON-NLS-1$ { try { _aspectFacetStrings = (_mainSearcher.getFacets("tagging_values", _aspectFacetElement, //$NON-NLS-1$ _aspectFacetType, _aspectFacetSubtype, null)); } catch (Exception e1) { e1.printStackTrace(); } _aspectFacetQuery .setFacets((HashMap<String, IAEPresentable>) _aspectFacetRoleComboViewer.getInput()); } } }; Button facetTypeButton = new Button(searchPFacetComp, SWT.RADIO); facetTypeButton.setText(NLMessages.getString("Dialog_type")); facetTypeButton.setData("type"); //$NON-NLS-1$ facetTypeButton.addSelectionListener(aspectFacetListener); facetTypeButton.setLayoutData(new GridData()); ((GridData) facetTypeButton.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) facetTypeButton.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) facetTypeButton.getLayoutData()).horizontalSpan = 2; Button facetSubtypeButton = new Button(searchPFacetComp, SWT.RADIO); facetSubtypeButton.setText(NLMessages.getString("Dialog_subtype")); facetSubtypeButton.setData("subtype"); //$NON-NLS-1$ facetSubtypeButton.addSelectionListener(aspectFacetListener); facetSubtypeButton.setLayoutData(new GridData()); ((GridData) facetSubtypeButton.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) facetSubtypeButton.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) facetSubtypeButton.getLayoutData()).horizontalSpan = 2; Button facetRoleButton = new Button(searchPFacetComp, SWT.RADIO); facetRoleButton.setText(NLMessages.getString("Dialog_role")); facetRoleButton.setData("role"); //$NON-NLS-1$ facetRoleButton.addSelectionListener(aspectFacetListener); facetRoleButton.setLayoutData(new GridData()); ((GridData) facetRoleButton.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) facetRoleButton.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) facetRoleButton.getLayoutData()).horizontalSpan = 2; Button facetContentButton = new Button(searchPFacetComp, SWT.RADIO); facetContentButton.setText(NLMessages.getString("Dialog_markup_content")); facetContentButton.setData("content"); //$NON-NLS-1$ facetContentButton.addSelectionListener(aspectFacetListener); facetContentButton.setLayoutData(new GridData()); ((GridData) facetContentButton.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) facetContentButton.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) facetContentButton.getLayoutData()).horizontalSpan = 2; facetContentButton.setSelection(true); Button chooseFacetsButton = new Button(searchPFacetComp, SWT.CHECK); chooseFacetsButton.setText(NLMessages.getString("Dialog_faceted_search")); chooseFacetsButton.setLayoutData(new GridData()); ((GridData) chooseFacetsButton.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) chooseFacetsButton.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) chooseFacetsButton.getLayoutData()).horizontalSpan = 2; chooseFacetsButton.setSelection(_aspectFacetQuery.getType() == 4); chooseFacetsButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { if (_aspectFacetQuery.getType() == 4) { _aspectFacetQuery.setType(0); } else { _aspectFacetQuery.setType(4); } } }); final Combo facetElementCombo = new Combo(searchPFacetComp, SWT.READ_ONLY); final ComboViewer facetElementComboViewer = new ComboViewer(facetElementCombo); final Combo facetTypeCombo = new Combo(searchPFacetComp, SWT.READ_ONLY); _aspectFacetTypeComboViewer = new ComboViewer(facetTypeCombo); final Combo facetSubtypeCombo = new Combo(searchPFacetComp, SWT.READ_ONLY); _aspectFacetSubtypeComboViewer = new ComboViewer(facetSubtypeCombo); final Combo facetRoleCombo = new Combo(searchPFacetComp, SWT.READ_ONLY); _aspectFacetRoleComboViewer = new ComboViewer(facetRoleCombo); _aspectFacetCombo = new Combo(searchPFacetComp, SWT.READ_ONLY); facetElementCombo.setLayoutData(new GridData()); facetElementCombo.setLayoutData(new GridData()); ((GridData) facetElementCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) facetElementCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) facetElementCombo.getLayoutData()).horizontalSpan = 2; facetElementComboViewer.setContentProvider(new MarkupContentProvider(true)); facetElementComboViewer.setLabelProvider(new MarkupLabelProvider()); facetElementComboViewer.setComparator(new ConfigDataComparator()); if (_facade.getConfigs().containsKey(_markupProvider)) { HashMap<String, ConfigData> input = _facade.getConfigs().get(_markupProvider).getChildren(); facetElementComboViewer.setInput(input); } Object obj = facetElementComboViewer.getElementAt(0); if (obj != null) { facetElementComboViewer.setSelection(new StructuredSelection(obj)); ConfigData cd = (ConfigData) facetElementComboViewer.getElementAt(0); if (cd.getValue().startsWith("aodl:")) { _aspectFacetElement = cd.getValue().substring(5); //$NON-NLS-1$ } else { _aspectFacetElement = cd.getValue(); } } facetElementComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override @SuppressWarnings("unchecked") public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); ConfigData cd = (ConfigData) obj; if (cd.getValue().startsWith("aodl:")) { _aspectFacetElement = cd.getValue().substring(5); //$NON-NLS-1$ } else { _aspectFacetElement = cd.getValue(); } _aspectFacetQuery.getCriterias().get(0).setCrit1(_aspectFacetElement); facetTypeCombo.removeAll(); _aspectFacetQuery.getCriterias().get(0).setCrit2(null); facetSubtypeCombo.removeAll(); _aspectFacetQuery.getCriterias().get(0).setCrit3(null); facetRoleCombo.removeAll(); _aspectFacetQuery.getCriterias().get(0).setCrit4(null); _aspectFacetCombo.removeAll(); setComboViewerInput(_aspectFacetTypeComboViewer, "tagging_values", _aspectFacetElement, null, null); //$NON-NLS-1$ if (_aspectFacetQuery.getKey().equals("content")) //$NON-NLS-1$ { try { _aspectFacetStrings = _mainSearcher.getFacets("tagging", _aspectFacetElement, //$NON-NLS-1$ _aspectFacetType, _aspectFacetSubtype, _aspectFacetRole); _aspectFacetCombo.setItems(_aspectFacetStrings); setQueryFacets(_aspectFacetQuery, _aspectFacetStrings); } catch (Exception e1) { e1.printStackTrace(); } } else if (_aspectFacetQuery.getKey().equals("type")) //$NON-NLS-1$ { try { _aspectFacetStrings = (_mainSearcher.getFacets("tagging_values", _aspectFacetElement, null, //$NON-NLS-1$ null, null)); } catch (Exception e1) { e1.printStackTrace(); } _aspectFacetQuery .setFacets((HashMap<String, IAEPresentable>) _aspectFacetTypeComboViewer.getInput()); } } }); facetTypeCombo.setLayoutData(new GridData()); facetTypeCombo.setLayoutData(new GridData()); ((GridData) facetTypeCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) facetTypeCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) facetTypeCombo.getLayoutData()).horizontalSpan = 2; _aspectFacetTypeComboViewer.setContentProvider(new MarkupContentProvider()); _aspectFacetTypeComboViewer.setLabelProvider(new MarkupLabelProvider()); _aspectFacetTypeComboViewer.setComparator(new ConfigDataComparator()); _aspectFacetTypeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override @SuppressWarnings("unchecked") public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); ConfigData cd = (ConfigData) obj; facetSubtypeCombo.removeAll(); _aspectFacetQuery.getCriterias().get(0).setCrit3(null); facetRoleCombo.removeAll(); _aspectFacetQuery.getCriterias().get(0).setCrit4(null); _aspectFacetCombo.removeAll(); _aspectFacetType = cd.getValue(); _aspectFacetQuery.getCriterias().get(0).setCrit2(_aspectFacetType); setComboViewerInput(_aspectFacetSubtypeComboViewer, "tagging_values", _aspectFacetElement, //$NON-NLS-1$ _aspectFacetType, null); if (_aspectFacetQuery.getKey().equals("content")) //$NON-NLS-1$ { try { _aspectFacetStrings = (_mainSearcher.getFacets("tagging", _aspectFacetElement, //$NON-NLS-1$ _aspectFacetType, _aspectFacetSubtype, _aspectFacetRole)); setQueryFacets(_aspectFacetQuery, _aspectFacetStrings); _aspectFacetCombo.setItems(_aspectFacetStrings); } catch (Exception e1) { e1.printStackTrace(); } } else if (_aspectFacetQuery.getKey().equals("subtype")) //$NON-NLS-1$ { try { _aspectFacetStrings = (_mainSearcher.getFacets("tagging_values", _aspectFacetElement, //$NON-NLS-1$ _aspectFacetType, null, null)); } catch (Exception e1) { e1.printStackTrace(); } _aspectFacetQuery .setFacets((HashMap<String, IAEPresentable>) _aspectFacetSubtypeComboViewer.getInput()); } } }); facetSubtypeCombo.setLayoutData(new GridData()); facetSubtypeCombo.setLayoutData(new GridData()); ((GridData) facetSubtypeCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) facetSubtypeCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) facetSubtypeCombo.getLayoutData()).horizontalSpan = 2; _aspectFacetSubtypeComboViewer.setContentProvider(new MarkupContentProvider()); _aspectFacetSubtypeComboViewer.setLabelProvider(new MarkupLabelProvider()); _aspectFacetSubtypeComboViewer.setComparator(new ConfigDataComparator()); _aspectFacetSubtypeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override @SuppressWarnings("unchecked") public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); ConfigData cd = (ConfigData) obj; _aspectFacetSubtype = cd.getValue(); facetRoleCombo.removeAll(); _aspectFacetQuery.getCriterias().get(0).setCrit4(null); _aspectFacetCombo.removeAll(); _aspectFacetQuery.getCriterias().get(0).setCrit3(_aspectFacetSubtype); setComboViewerInput(_aspectFacetRoleComboViewer, "tagging_values", _aspectFacetElement, _aspectFacetType, _aspectFacetSubtype); if (_aspectFacetQuery.getKey().equals("content")) //$NON-NLS-1$ { try { _aspectFacetStrings = (_mainSearcher.getFacets("tagging", _aspectFacetElement, //$NON-NLS-1$ _aspectFacetType, _aspectFacetSubtype, _aspectFacetRole)); setQueryFacets(_aspectFacetQuery, _aspectFacetStrings); _aspectFacetCombo.setItems(_aspectFacetStrings); } catch (Exception e1) { e1.printStackTrace(); } } else if (_aspectFacetQuery.getKey().equals("role")) //$NON-NLS-1$ { try { _aspectFacetStrings = (_mainSearcher.getFacets("tagging_values", _aspectFacetElement, //$NON-NLS-1$ _aspectFacetType, _aspectFacetSubtype, null)); } catch (Exception e1) { e1.printStackTrace(); } _aspectFacetQuery .setFacets((HashMap<String, IAEPresentable>) _aspectFacetRoleComboViewer.getInput()); } } }); facetRoleCombo.setLayoutData(new GridData()); facetRoleCombo.setLayoutData(new GridData()); ((GridData) facetRoleCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) facetRoleCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) facetRoleCombo.getLayoutData()).horizontalSpan = 2; _aspectFacetRoleComboViewer.setContentProvider(new MarkupContentProvider()); _aspectFacetRoleComboViewer.setLabelProvider(new MarkupLabelProvider()); _aspectFacetRoleComboViewer.setComparator(new ConfigDataComparator()); _aspectFacetRoleComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); ConfigData cd = (ConfigData) obj; _aspectFacetRole = cd.getValue(); _aspectFacetCombo.removeAll(); _aspectFacetQuery.getCriterias().get(0).setCrit4(_aspectFacetRole); if (_aspectFacetQuery.getKey().equals("content")) //$NON-NLS-1$ { try { _aspectFacetStrings = (_mainSearcher.getFacets("tagging", _aspectFacetElement, //$NON-NLS-1$ _aspectFacetType, _aspectFacetSubtype, _aspectFacetRole)); setQueryFacets(_aspectFacetQuery, _aspectFacetStrings); _aspectFacetCombo.setItems(_aspectFacetStrings); } catch (Exception e1) { e1.printStackTrace(); } } } }); _aspectFacetCombo.setLayoutData(new GridData()); _aspectFacetCombo.setLayoutData(new GridData()); ((GridData) _aspectFacetCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) _aspectFacetCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) _aspectFacetCombo.getLayoutData()).horizontalSpan = 2; // facetCombo.addFocusListener(new FocusAdapter(){ // public void focusGained(FocusEvent e) // { // try { // facetQuery.setFacets(mainSearcher.getFacets( "tagging", facetElement, facetType, facetSubtype, //$NON-NLS-1$ // facetRole)); // facetCombo.setItems(facetQuery.getFacets()); // // } catch (Exception e1) { // e1.printStackTrace(); // } // } // } // ); for (int i = 1; i < _aspectFacetQuery.getCriterias().size(); i++) { // System.out.println("for i = " + i); //$NON-NLS-1$ final Criteria c = _aspectFacetQuery.getCriterias().get(i); if (c.getType().equals("tagging")) //$NON-NLS-1$ { if (tag1) { tag1 = false; _searchATagComp = new Composite(_facetAspectSearchGroup, SWT.NONE); _searchATagComp.setLayout(new GridLayout()); ((GridLayout) _searchATagComp.getLayout()).makeColumnsEqualWidth = true; ((GridLayout) _searchATagComp.getLayout()).numColumns = 14; _searchATagComp.setLayoutData(new GridData()); ((GridData) _searchATagComp.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) _searchATagComp.getLayoutData()).grabExcessHorizontalSpace = true; // ((GridData) searchATagComp.getLayoutData()).heightHint = // 200; ((GridData) _searchATagComp.getLayoutData()).grabExcessVerticalSpace = false; ((GridData) _searchATagComp.getLayoutData()).horizontalSpan = 1; Label op = new Label(_searchATagComp, SWT.NONE); op.setText(NLMessages.getString("Dialog_operand")); //$NON-NLS-1$ op.setLayoutData(new GridData()); ((GridData) op.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) op.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) op.getLayoutData()).horizontalSpan = 1; Label sem = new Label(_searchATagComp, SWT.NONE); sem.setText(NLMessages.getString("Dialog_semantic")); //$NON-NLS-1$ sem.setLayoutData(new GridData()); ((GridData) sem.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) sem.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) sem.getLayoutData()).horizontalSpan = 2; Label tagName = new Label(_searchATagComp, SWT.NONE); tagName.setText(NLMessages.getString("Dialog_markup")); //$NON-NLS-1$ tagName.setLayoutData(new GridData()); ((GridData) tagName.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) tagName.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) tagName.getLayoutData()).horizontalSpan = 2; Label tagType = new Label(_searchATagComp, SWT.NONE); tagType.setText(NLMessages.getString("Dialog_type")); //$NON-NLS-1$ tagType.setLayoutData(new GridData()); ((GridData) tagType.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) tagType.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) tagType.getLayoutData()).horizontalSpan = 2; Label tagSubtype = new Label(_searchATagComp, SWT.NONE); tagSubtype.setText(NLMessages.getString("Dialog_subtype")); //$NON-NLS-1$ tagSubtype.setLayoutData(new GridData()); ((GridData) tagSubtype.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) tagSubtype.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) tagSubtype.getLayoutData()).horizontalSpan = 2; Label searchTextLabel = new Label(_searchATagComp, SWT.NONE); searchTextLabel.setText(NLMessages.getString("Dialog_searchText")); //$NON-NLS-1$ searchTextLabel.setLayoutData(new GridData()); ((GridData) searchTextLabel.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) searchTextLabel.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) searchTextLabel.getLayoutData()).horizontalSpan = 3; Label fuzzy = new Label(_searchATagComp, SWT.NONE); fuzzy.setText(NLMessages.getString("Dialog_fuzzy")); //$NON-NLS-1$ fuzzy.setLayoutData(new GridData()); ((GridData) fuzzy.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) fuzzy.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) fuzzy.getLayoutData()).horizontalSpan = 1; Label include = new Label(_searchATagComp, SWT.NONE); include.setText(NLMessages.getString("Dialog_include")); //$NON-NLS-1$ include.setToolTipText(NLMessages.getString("Dialog_includeConcurrences")); //$NON-NLS-1$ include.setLayoutData(new GridData()); ((GridData) include.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) include.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) include.getLayoutData()).horizontalSpan = 1; } if (i == 0) { Label l = new Label(_searchATagComp, SWT.NONE); l.setText(NLMessages.getString("Dialog_markup")); //$NON-NLS-1$ l.setLayoutData(new GridData()); ((GridData) l.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) l.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) l.getLayoutData()).horizontalSpan = 1; } else { Label l = new Label(_searchATagComp, SWT.NONE); l.setText("AND"); //$NON-NLS-1$ l.setLayoutData(new GridData()); ((GridData) l.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) l.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) l.getLayoutData()).horizontalSpan = 1; // final Combo opCombo = new Combo(searchATagComp, // SWT.READ_ONLY); // opCombo.setLayoutData(new GridData()); // opCombo.add(Operator.AND.toString()); // opCombo.add(Operator.OR.toString()); // opCombo.add(Operator.NOT.toString()); // opCombo.setLayoutData(new GridData()); // ((GridData) opCombo.getLayoutData()).horizontalAlignment // = SWT.FILL; // ((GridData) // opCombo.getLayoutData()).grabExcessHorizontalSpace = true // ; // ((GridData) opCombo.getLayoutData()).horizontalSpan = 1; // if (c.getOperator() != null) // { // opCombo.setText(c.getOperator()); // } // else // { // opCombo.select(0); // c.setOperator(opCombo.getItem(0)); // // } // opCombo.addSelectionListener(new SelectionAdapter(){ // public void widgetSelected(SelectionEvent se){ // c.setOperator(opCombo.getItem(opCombo.getSelectionIndex())); // } // }); } final Combo semCombo = new Combo(_searchATagComp, SWT.READ_ONLY); semCombo.setLayoutData(new GridData()); ComboViewer comboSemanticViewer = new ComboViewer(semCombo); comboSemanticViewer.setContentProvider(new AEConfigPresentableContentProvider()); comboSemanticViewer.setLabelProvider(new AEConfigPresentableLabelProvider()); ((AEConfigPresentableContentProvider) comboSemanticViewer.getContentProvider()).setAddALL(true); if (_facade.getAllSemantics() != null && !_facade.getAllSemantics().isEmpty()) { comboSemanticViewer.setInput(_facade.getAllSemantics()); if (c.getCrit0() != null) { setComboViewerByString(comboSemanticViewer, c.getCrit0()); } else { semCombo.select(0); c.setCrit0(semCombo.getItem(0)); } } semCombo.setLayoutData(new GridData()); ((GridData) semCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) semCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) semCombo.getLayoutData()).horizontalSpan = 2; comboSemanticViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); IAEPresentable cp = (IAEPresentable) obj; if (cp != null) { c.setCrit0(cp.getValue()); } } }); final Combo tagCombo = new Combo(_searchATagComp, SWT.READ_ONLY); tagCombo.setLayoutData(new GridData()); tagCombo.setLayoutData(new GridData()); ((GridData) tagCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) tagCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) tagCombo.getLayoutData()).horizontalSpan = 2; final ComboViewer tagComboViewer = new ComboViewer(tagCombo); tagComboViewer.setContentProvider(new MarkupContentProvider(true)); tagComboViewer.setLabelProvider(new MarkupLabelProvider()); tagComboViewer.setComparator(new ConfigDataComparator()); if (_facade.getConfigs().containsKey(_markupProvider)) { HashMap<String, ConfigData> input = _facade.getConfigs().get(_markupProvider).getChildren(); tagComboViewer.setInput(input); } if (c.getCrit1() != null) { setComboViewerByString(tagComboViewer, c.getCrit1()); } else { obj = tagComboViewer.getElementAt(0); if (obj != null) { tagComboViewer.setSelection(new StructuredSelection(obj)); ConfigData cd = (ConfigData) tagComboViewer.getElementAt(0); if (cd.getValue().startsWith("aodl:")) { c.setCrit1(cd.getValue().substring(5)); //$NON-NLS-1$ } else { c.setCrit1(cd.getValue()); } } } final Combo typeCombo = new Combo(_searchATagComp, SWT.READ_ONLY); typeCombo.setLayoutData(new GridData()); typeCombo.setLayoutData(new GridData()); ((GridData) typeCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) typeCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) typeCombo.getLayoutData()).horizontalSpan = 2; final ComboViewer typeComboViewer = new ComboViewer(typeCombo); typeComboViewer.setContentProvider(new MarkupContentProvider()); typeComboViewer.setLabelProvider(new MarkupLabelProvider()); typeComboViewer.setComparator(new ConfigDataComparator()); tagComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); ConfigData cd = (ConfigData) obj; String selection; if (cd.getValue().startsWith("aodl:")) { selection = cd.getValue().substring(5); //$NON-NLS-1$ } else { selection = cd.getValue(); } c.setCrit1(selection); setComboViewerInput(typeComboViewer, "tagging_values", c.getCrit1(), null, null); //$NON-NLS-1$ } }); if (c.getCrit2() != null) { setComboViewerByString(typeComboViewer, c.getCrit2()); } final Combo subtypeCombo = new Combo(_searchATagComp, SWT.READ_ONLY); final ComboViewer subtypeComboViewer = new ComboViewer(subtypeCombo); subtypeComboViewer.setContentProvider(new MarkupContentProvider()); subtypeComboViewer.setLabelProvider(new MarkupLabelProvider()); subtypeComboViewer.setComparator(new ConfigDataComparator()); // typeCombo.addFocusListener(new FocusAdapter(){ // public void focusGained(FocusEvent e) // { // } // } // ); typeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); ConfigData cd = (ConfigData) obj; subtypeComboViewer.setInput(null); if (cd != null) { c.setCrit2(cd.getValue()); } setComboViewerInput(subtypeComboViewer, "tagging_values", c.getCrit1(), c.getCrit2(), null); //$NON-NLS-1$ } }); subtypeCombo.setLayoutData(new GridData()); subtypeCombo.setLayoutData(new GridData()); ((GridData) subtypeCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) subtypeCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) subtypeCombo.getLayoutData()).horizontalSpan = 2; if (c.getCrit3() != null) { setComboViewerByString(subtypeComboViewer, c.getCrit3()); } // subtypeCombo.addFocusListener(new FocusAdapter(){ // public void focusGained(FocusEvent e) // { // // } // } // ); subtypeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); ConfigData cd = (ConfigData) obj; if (cd != null) { c.setCrit3(cd.getValue()); } } }); final Text searchText = new Text(_searchATagComp, SWT.BORDER); searchText.setLayoutData(new GridData()); searchText.setLayoutData(new GridData()); ((GridData) searchText.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) searchText.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) searchText.getLayoutData()).horizontalSpan = 3; if (c.getSearchText() != null) { searchText.setText(c.getSearchText()); } searchText.addFocusListener(new FocusAdapter() { @Override public void focusLost(final FocusEvent e) { c.setSearchText(searchText.getText()); } }); searchText.addKeyListener(new KeyListener() { @Override public void keyPressed(final KeyEvent e) { if (e.keyCode == SWT.CR) { c.setSearchText(searchText.getText()); okPressed(); } } @Override public void keyReleased(final KeyEvent e) { } }); final Button fuzzyB = new Button(_searchATagComp, SWT.CHECK); fuzzyB.setLayoutData(new GridData()); fuzzyB.setSelection(c.isFuzzy()); fuzzyB.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { c.setFuzzy(!c.isFuzzy()); } }); final Button includeB = new Button(_searchATagComp, SWT.CHECK); includeB.setLayoutData(new GridData()); includeB.setSelection(c.isIncludeConcurrences()); includeB.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { c.setIncludeConcurrences(!c.isIncludeConcurrences()); } }); } // if tagging if (c.getType().equals("date")) //$NON-NLS-1$ { if (date1) { date1 = false; _searchADateComp = new Composite(_facetAspectSearchGroup, SWT.NONE); _searchADateComp.setLayout(new GridLayout()); ((GridLayout) _searchADateComp.getLayout()).makeColumnsEqualWidth = true; ((GridLayout) _searchADateComp.getLayout()).numColumns = 14; _searchADateComp.setLayoutData(new GridData()); ((GridData) _searchADateComp.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) _searchADateComp.getLayoutData()).grabExcessHorizontalSpace = true; // ((GridData) searchADateComp.getLayoutData()).heightHint = // 200; ((GridData) _searchADateComp.getLayoutData()).grabExcessVerticalSpace = false; ((GridData) _searchADateComp.getLayoutData()).horizontalSpan = 1; Label l2 = new Label(_searchADateComp, SWT.NONE); l2.setText(NLMessages.getString("Dialog_date")); //$NON-NLS-1$ l2.setLayoutData(new GridData()); ((GridData) l2.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) l2.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) l2.getLayoutData()).horizontalSpan = 1; Label typeDate = new Label(_searchADateComp, SWT.NONE); typeDate.setText(NLMessages.getString("Dialog_type")); //$NON-NLS-1$ typeDate.setLayoutData(new GridData()); ((GridData) typeDate.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) typeDate.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) typeDate.getLayoutData()).horizontalSpan = 2; Label bl = new Label(_searchADateComp, SWT.NONE); bl.setText(""); //$NON-NLS-1$ Label notBefore = new Label(_searchADateComp, SWT.NONE); notBefore.setText(NLMessages.getString("Dialog_day")); //$NON-NLS-1$ notBefore.setLayoutData(new GridData()); ((GridData) notBefore.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) notBefore.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) notBefore.getLayoutData()).horizontalSpan = 1; Label month = new Label(_searchADateComp, SWT.NONE); month.setText(NLMessages.getString("Dialog_month")); //$NON-NLS-1$ month.setLayoutData(new GridData()); ((GridData) month.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) month.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) month.getLayoutData()).horizontalSpan = 1; Label year = new Label(_searchADateComp, SWT.NONE); year.setText(NLMessages.getString("Dialog_year")); //$NON-NLS-1$ year.setLayoutData(new GridData()); ((GridData) year.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) year.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) year.getLayoutData()).horizontalSpan = 2; Label bl2 = new Label(_searchADateComp, SWT.NONE); bl2.setText(""); //$NON-NLS-1$ Label notAfter = new Label(_searchADateComp, SWT.NONE); notAfter.setText(NLMessages.getString("Dialog_day")); //$NON-NLS-1$ notAfter.setLayoutData(new GridData()); ((GridData) notAfter.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) notAfter.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) notAfter.getLayoutData()).horizontalSpan = 1; Label month2 = new Label(_searchADateComp, SWT.NONE); month2.setText(NLMessages.getString("Dialog_month")); //$NON-NLS-1$ month2.setLayoutData(new GridData()); ((GridData) month2.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) month2.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) month2.getLayoutData()).horizontalSpan = 1; Label year2 = new Label(_searchADateComp, SWT.NONE); year2.setText(NLMessages.getString("Dialog_year")); //$NON-NLS-1$ year2.setLayoutData(new GridData()); ((GridData) year2.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) year2.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) year2.getLayoutData()).horizontalSpan = 2; Label include = new Label(_searchADateComp, SWT.NONE); include.setText(""); //$NON-NLS-1$ include.setToolTipText(NLMessages.getString("Dialog_includeConcurrences")); //$NON-NLS-1$ include.setLayoutData(new GridData()); ((GridData) include.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) include.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) include.getLayoutData()).horizontalSpan = 1; } if (i == 0) { Label l = new Label(_searchADateComp, SWT.NONE); l.setLayoutData(new GridData()); ((GridData) l.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) l.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) l.getLayoutData()).horizontalSpan = 1; } else { Label l = new Label(_searchADateComp, SWT.NONE); l.setText("AND"); //$NON-NLS-1$ l.setLayoutData(new GridData()); ((GridData) l.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) l.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) l.getLayoutData()).horizontalSpan = 1; // final Combo opCombo = new Combo(searchADateComp, // SWT.READ_ONLY); // opCombo.setLayoutData(new GridData()); // opCombo.add(Operator.AND.toString()); // opCombo.add(Operator.OR.toString()); // opCombo.add(Operator.NOT.toString()); // opCombo.setLayoutData(new GridData()); // ((GridData) opCombo.getLayoutData()).horizontalAlignment // = SWT.FILL; // ((GridData) // opCombo.getLayoutData()).grabExcessHorizontalSpace = true // ; // ((GridData) opCombo.getLayoutData()).horizontalSpan = 1; // if (c.getOperator() != null) // { // opCombo.setText(c.getOperator()); // } // else // { // opCombo.select(0); // c.setOperator(opCombo.getItem(0)); // // } // opCombo.addSelectionListener(new SelectionAdapter(){ // public void widgetSelected(SelectionEvent se){ // c.setOperator(opCombo.getItem(opCombo.getSelectionIndex())); // } // }); } final Combo typeDCombo = new Combo(_searchADateComp, SWT.READ_ONLY); typeDCombo.setLayoutData(new GridData()); ComboViewer timeTypeComboViewer = new ComboViewer(typeDCombo); timeTypeComboViewer.setContentProvider(ArrayContentProvider.getInstance()); timeTypeComboViewer.setLabelProvider(new LabelProvider() { @Override public String getText(final Object element) { String str = (String) element; if (NLMessages.getString("Editor_time_" + str) != null) //$NON-NLS-1$ { return NLMessages.getString("Editor_time_" + str); //$NON-NLS-1$ } return str; } }); timeTypeComboViewer.setInput(AEConstants.TIME_TYPES); timeTypeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection selection = event.getSelection(); Object obj = ((IStructuredSelection) selection).getFirstElement(); String s = (String) obj; c.setDateType(s); } }); if (c.getDateType() != null) { StructuredSelection selection = new StructuredSelection(c.getDateType()); timeTypeComboViewer.setSelection(selection); } else { StructuredSelection selection = new StructuredSelection(AEConstants.TIME_TYPES[0]); timeTypeComboViewer.setSelection(selection); c.setDateType(AEConstants.TIME_TYPES[0]); } typeDCombo.pack(); typeDCombo.setLayoutData(new GridData()); ((GridData) typeDCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) typeDCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) typeDCombo.getLayoutData()).horizontalSpan = 2; Label from = new Label(_searchADateComp, SWT.NONE); from.setText(NLMessages.getString("Dialog_from")); //$NON-NLS-1$ from.setLayoutData(new GridData()); ((GridData) from.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) from.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) from.getLayoutData()).horizontalSpan = 1; final Combo day1Combo = new Combo(_searchADateComp, SWT.READ_ONLY); day1Combo.setLayoutData(new GridData()); day1Combo.setItems(AEConstants.DAYS); day1Combo.setLayoutData(new GridData()); ((GridData) day1Combo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) day1Combo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) day1Combo.getLayoutData()).horizontalSpan = 1; if (c.getDateFrom() == null) { PdrDate dateFrom = new PdrDate("0000-00-00"); //$NON-NLS-1$ // dateFrom.setDay(0); // dateFrom.setMonth(0); // dateFrom.setYear(0); c.setDateFrom(dateFrom); day1Combo.select(c.getDateFrom().getDay()); } // System.out.println("test: dateFrom " + c.getDateFrom().toString()); //$NON-NLS-1$ // else // { // // day1Combo.select(0); // c.getDateFrom().setDay(0); // // } day1Combo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { c.getDateFrom().setDay(day1Combo.getSelectionIndex()); } }); final Combo month1Combo = new Combo(_searchADateComp, SWT.READ_ONLY); month1Combo.setLayoutData(new GridData()); month1Combo.setItems(AEConstants.MONTHS); month1Combo.setLayoutData(new GridData()); ((GridData) month1Combo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) month1Combo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) month1Combo.getLayoutData()).horizontalSpan = 1; if (c.getDateFrom() != null) { month1Combo.select(c.getDateFrom().getMonth()); } else { month1Combo.select(0); c.getDateFrom().setMonth(0); } month1Combo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { c.getDateFrom().setMonth(month1Combo.getSelectionIndex()); } }); final YearSpinner year1Spinner = new YearSpinner(_searchADateComp, SWT.NULL); // year1Spinner.setLayoutData(new GridData()); // year1Spinner.setLayoutData(new GridData()); // ((GridData) year1Spinner.getLayoutData()).horizontalAlignment // = SWT.FILL; // ((GridData) // year1Spinner.getLayoutData()).grabExcessHorizontalSpace = // true; // ((GridData) year1Spinner.getLayoutData()).horizontalSpan = 2; // year1Spinner.setMinimum(0); // year1Spinner.setMaximum(9999); if (c.getDateFrom() != null) { year1Spinner.setSelection(c.getDateFrom().getYear()); } else { year1Spinner.setSelection(_preselection); c.getDateFrom().setYear(_preselection); } year1Spinner.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(final SelectionEvent e) { c.getDateFrom().setYear(year1Spinner.getSelection()); // System.out.println("year1Spinner.getSelection() " + // year1Spinner.getSelection()); } @Override public void widgetSelected(final SelectionEvent e) { c.getDateFrom().setYear(year1Spinner.getSelection()); // System.out.println("year1Spinner.getSelection() " + // year1Spinner.getSelection()); } }); Label to = new Label(_searchADateComp, SWT.NONE); to.setText(NLMessages.getString("Dialog_to")); //$NON-NLS-1$ to.setLayoutData(new GridData()); ((GridData) to.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) to.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) to.getLayoutData()).horizontalSpan = 1; final Combo day2Combo = new Combo(_searchADateComp, SWT.READ_ONLY); day2Combo.setLayoutData(new GridData()); day2Combo.setItems(AEConstants.DAYS); day2Combo.setLayoutData(new GridData()); ((GridData) day2Combo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) day2Combo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) day2Combo.getLayoutData()).horizontalSpan = 1; if (c.getDateTo() == null) { PdrDate dateTo = new PdrDate("0000-00-00"); //$NON-NLS-1$ c.setDateTo(dateTo); day2Combo.select(c.getDateTo().getDay()); } day2Combo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { c.getDateTo().setDay(day2Combo.getSelectionIndex()); } }); final Combo month2Combo = new Combo(_searchADateComp, SWT.READ_ONLY); month2Combo.setLayoutData(new GridData()); month2Combo.setItems(AEConstants.MONTHS); month2Combo.setLayoutData(new GridData()); ((GridData) month2Combo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) month2Combo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) month2Combo.getLayoutData()).horizontalSpan = 1; if (c.getDateTo() != null) { month2Combo.select(c.getDateTo().getMonth()); } else { month2Combo.select(0); c.getDateTo().setMonth(0); } month2Combo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { c.getDateTo().setMonth(month2Combo.getSelectionIndex()); } }); final YearSpinner year2Spinner = new YearSpinner(_searchADateComp, SWT.NULL); // year2Spinner.setLayoutData(new GridData()); // year2Spinner.setLayoutData(new GridData()); // ((GridData) year2Spinner.getLayoutData()).horizontalAlignment // = SWT.FILL; // ((GridData) // year2Spinner.getLayoutData()).grabExcessHorizontalSpace = // true; // ((GridData) year2Spinner.getLayoutData()).horizontalSpan = 2; // year2Spinner.setMinimum(0); // year2Spinner.setMaximum(9999); if (c.getDateTo() != null) { year2Spinner.setSelection(c.getDateTo().getYear()); } else { year2Spinner.setSelection(_preselection); c.getDateTo().setYear(_preselection); } year2Spinner.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(final SelectionEvent e) { c.getDateTo().setYear(year2Spinner.getSelection()); } @Override public void widgetSelected(final SelectionEvent e) { c.getDateTo().setYear(year2Spinner.getSelection()); } }); final Button includeB = new Button(_searchADateComp, SWT.CHECK); includeB.setLayoutData(new GridData()); includeB.setSelection(c.isIncludeConcurrences()); includeB.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { c.setIncludeConcurrences(!c.isIncludeConcurrences()); } }); } // if date if (c.getType().equals("reference")) //$NON-NLS-1$ { _searchARefComp = new Composite(_facetAspectSearchGroup, SWT.NONE); _searchARefComp.setLayout(new GridLayout()); ((GridLayout) _searchARefComp.getLayout()).makeColumnsEqualWidth = true; ((GridLayout) _searchARefComp.getLayout()).numColumns = 14; _searchARefComp.setLayoutData(new GridData()); ((GridData) _searchARefComp.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) _searchARefComp.getLayoutData()).grabExcessHorizontalSpace = true; // ((GridData) searchPTagComp.getLayoutData()).heightHint = 200; ((GridData) _searchARefComp.getLayoutData()).grabExcessVerticalSpace = false; ((GridData) _searchARefComp.getLayoutData()).horizontalSpan = 1; Label l = new Label(_searchARefComp, SWT.NONE); l.setText("AND"); //$NON-NLS-1$ l.setLayoutData(new GridData()); ((GridData) l.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) l.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) l.getLayoutData()).horizontalSpan = 1; // final Combo opCombo = new Combo(searchARefComp, // SWT.READ_ONLY); // opCombo.setLayoutData(new GridData()); // opCombo.add(Operator.AND.toString()); // opCombo.add(Operator.OR.toString()); // opCombo.add(Operator.NOT.toString()); // opCombo.setLayoutData(new GridData()); // ((GridData) opCombo.getLayoutData()).horizontalAlignment = // SWT.FILL; // ((GridData) // opCombo.getLayoutData()).grabExcessHorizontalSpace = true ; // ((GridData) opCombo.getLayoutData()).horizontalSpan = 1; // if (c.getOperator() != null) // { // opCombo.setText(c.getOperator()); // } // else // { // opCombo.select(0); // c.setOperator(opCombo.getItem(0)); // // } // opCombo.addSelectionListener(new SelectionAdapter(){ // public void widgetSelected(SelectionEvent se){ // c.setOperator(opCombo.getItem(opCombo.getSelectionIndex())); // } // }); Label sem = new Label(_searchARefComp, SWT.NONE); sem.setText(NLMessages.getString("Dialog_reference")); //$NON-NLS-1$ sem.setLayoutData(new GridData()); ((GridData) sem.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) sem.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) sem.getLayoutData()).horizontalSpan = 2; Label tagName = new Label(_searchARefComp, SWT.NONE); tagName.setText(NLMessages.getString("Dialog_genre")); //$NON-NLS-1$ tagName.setLayoutData(new GridData()); ((GridData) tagName.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) tagName.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) tagName.getLayoutData()).horizontalSpan = 2; final Combo genreCombo = new Combo(_searchARefComp, SWT.READ_ONLY); genreCombo.setLayoutData(new GridData()); ComboViewer genreComboViewer = new ComboViewer(genreCombo); genreComboViewer.setContentProvider(new RefTemplateContentProvider(false)); genreComboViewer.setLabelProvider(new LabelProvider() { @Override public String getText(final Object element) { ReferenceModsTemplate template = (ReferenceModsTemplate) element; return template.getLabel(); } }); genreComboViewer.setInput(_facade.getAllGenres()); genreComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection selection = event.getSelection(); Object obj = ((IStructuredSelection) selection).getFirstElement(); ReferenceModsTemplate template = (ReferenceModsTemplate) obj; if (template != null) { c.setCrit0(template.getValue()); } } }); genreCombo.add("ALL", 0); //$NON-NLS-1$ genreCombo.setLayoutData(new GridData()); ((GridData) genreCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) genreCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) genreCombo.getLayoutData()).horizontalSpan = 2; if (c.getCrit0() != null) { StructuredSelection selection = new StructuredSelection(c.getCrit0()); genreComboViewer.setSelection(selection); } else { genreCombo.select(0); c.setCrit0(genreCombo.getItem(0)); } Label tagType = new Label(_searchARefComp, SWT.NONE); tagType.setText(NLMessages.getString("Dialog_searchText")); //$NON-NLS-1$ tagType.setLayoutData(new GridData()); ((GridData) tagType.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) tagType.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) tagType.getLayoutData()).horizontalSpan = 2; final Text searchText = new Text(_searchARefComp, SWT.BORDER); searchText.setLayoutData(new GridData()); searchText.setLayoutData(new GridData()); ((GridData) searchText.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) searchText.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) searchText.getLayoutData()).horizontalSpan = 3; if (c.getSearchText() != null) { searchText.setText(c.getSearchText()); } searchText.addFocusListener(new FocusAdapter() { @Override public void focusLost(final FocusEvent e) { c.setSearchText(searchText.getText()); } }); searchText.addKeyListener(new KeyListener() { @Override public void keyPressed(final KeyEvent e) { if (e.keyCode == SWT.CR) { c.setSearchText(searchText.getText()); okPressed(); } } @Override public void keyReleased(final KeyEvent e) { } }); final Button fuzzyB = new Button(_searchARefComp, SWT.CHECK); fuzzyB.setLayoutData(new GridData()); fuzzyB.setSelection(c.isFuzzy()); fuzzyB.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { c.setFuzzy(!c.isFuzzy()); } }); final Button includeB = new Button(_searchARefComp, SWT.CHECK); includeB.setLayoutData(new GridData()); includeB.setSelection(c.isIncludeConcurrences()); includeB.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { c.setIncludeConcurrences(!c.isIncludeConcurrences()); } }); } // if reference } // contentCompSearch.layout(); // scrollCompSearch.setContent(contentCompSearch); // scrollCompSearch.setMinSize(contentCompSearch.computeSize(SWT.DEFAULT, // SWT.DEFAULT, true)); // scrollCompSearch.layout(); _facetAspectSearchGroup.redraw(); _facetAspectSearchGroup.layout(); _facetAspectSearchGroup.pack(); _facetAspectSearchGroup.layout(); // facetPersonSearchGroup.pack(); }
From source file:org.bbaw.pdr.ae.view.main.dialogs.AdvancedSearchDialog.java
License:Open Source License
/** * Builds the facet person search./*from ww w . ja va2s . co m*/ * @param type the type * @param crit the crit */ private void buildFacetPersonSearch(final int type, final Integer crit) { // DataType dtAll = new DataType(); dtAll.setValue("ALL"); //$NON-NLS-1$ dtAll.setLabel("ALL"); //$NON-NLS-1$ boolean tag1 = true; boolean date1 = true; Composite searchPFacetComp = new Composite(_facetPersonSearchGroup, SWT.NONE); searchPFacetComp.setLayout(new GridLayout()); ((GridLayout) searchPFacetComp.getLayout()).makeColumnsEqualWidth = true; ((GridLayout) searchPFacetComp.getLayout()).numColumns = 12; searchPFacetComp.setLayoutData(new GridData()); ((GridData) searchPFacetComp.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) searchPFacetComp.getLayoutData()).grabExcessHorizontalSpace = true; // ((GridData) searchPTagComp.getLayoutData()).heightHint = 200; ((GridData) searchPFacetComp.getLayoutData()).grabExcessVerticalSpace = false; ((GridData) searchPFacetComp.getLayoutData()).horizontalSpan = 1; Label facet = new Label(searchPFacetComp, SWT.NONE); facet.setText(NLMessages.getString("Dialog_choose_facets")); facet.setLayoutData(new GridData()); ((GridData) facet.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) facet.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) facet.getLayoutData()).horizontalSpan = 4; SelectionListener facetListener = new SelectionAdapter() { @Override public void widgetDefaultSelected(final SelectionEvent e) { } @SuppressWarnings("unchecked") @Override public void widgetSelected(final SelectionEvent e) { final String type = (String) ((Button) e.getSource()).getData(); _facetQuery.setKey(type); // System.out.println("facetQuery key set to " + type); //$NON-NLS-1$ if (type.equals("content")) //$NON-NLS-1$ { try { _facetStrings = _mainSearcher.getFacets("tagging", _facetElement, _facetType, _facetSubtype, //$NON-NLS-1$ _facetRole); setQueryFacets(_facetQuery, _facetStrings); _facetCombo.setItems(_facetStrings); } catch (Exception e1) { e1.printStackTrace(); } } else if (type.equals("type")) //$NON-NLS-1$ { try { _facetStrings = (_mainSearcher.getFacets("tagging_values", _facetElement, null, null, //$NON-NLS-1$ null)); } catch (Exception e1) { e1.printStackTrace(); } _facetQuery.setFacets((HashMap<String, IAEPresentable>) _facetTypeComboViewer.getInput()); } else if (type.equals("subtype")) //$NON-NLS-1$ { try { _facetStrings = (_mainSearcher.getFacets("tagging_values", _facetElement, _facetType, null, //$NON-NLS-1$ null)); } catch (Exception e1) { e1.printStackTrace(); } _facetQuery.setFacets((HashMap<String, IAEPresentable>) _facetSubtypeComboViewer.getInput()); } else if (type.equals("role")) //$NON-NLS-1$ { try { _facetStrings = (_mainSearcher.getFacets("tagging_values", _facetElement, _facetType, //$NON-NLS-1$ _facetSubtype, null)); } catch (Exception e1) { e1.printStackTrace(); } _facetQuery.setFacets((HashMap<String, IAEPresentable>) _facetRoleComboViewer.getInput()); } } }; Button facetTypeButton = new Button(searchPFacetComp, SWT.RADIO); facetTypeButton.setText(NLMessages.getString("Dialog_type")); facetTypeButton.setData("type"); //$NON-NLS-1$ facetTypeButton.addSelectionListener(facetListener); facetTypeButton.setLayoutData(new GridData()); ((GridData) facetTypeButton.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) facetTypeButton.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) facetTypeButton.getLayoutData()).horizontalSpan = 2; Button facetSubtypeButton = new Button(searchPFacetComp, SWT.RADIO); facetSubtypeButton.setText(NLMessages.getString("Dialog_subtype")); facetSubtypeButton.setData("subtype"); //$NON-NLS-1$ facetSubtypeButton.addSelectionListener(facetListener); facetSubtypeButton.setLayoutData(new GridData()); ((GridData) facetSubtypeButton.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) facetSubtypeButton.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) facetSubtypeButton.getLayoutData()).horizontalSpan = 2; Button facetRoleButton = new Button(searchPFacetComp, SWT.RADIO); facetRoleButton.setText(NLMessages.getString("Dialog_role")); facetRoleButton.setData("role"); //$NON-NLS-1$ facetRoleButton.addSelectionListener(facetListener); facetRoleButton.setLayoutData(new GridData()); ((GridData) facetRoleButton.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) facetRoleButton.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) facetRoleButton.getLayoutData()).horizontalSpan = 2; Button facetContentButton = new Button(searchPFacetComp, SWT.RADIO); facetContentButton.setText(NLMessages.getString("Dialog_markup_content")); facetContentButton.setData("content"); //$NON-NLS-1$ facetContentButton.addSelectionListener(facetListener); facetContentButton.setLayoutData(new GridData()); ((GridData) facetContentButton.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) facetContentButton.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) facetContentButton.getLayoutData()).horizontalSpan = 2; facetContentButton.setSelection(true); Label blanc = new Label(searchPFacetComp, SWT.NONE); blanc.setText(""); //$NON-NLS-1$ blanc.setLayoutData(new GridData()); ((GridData) blanc.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) blanc.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) blanc.getLayoutData()).horizontalSpan = 2; final Combo facetElementCombo = new Combo(searchPFacetComp, SWT.READ_ONLY); final ComboViewer facetElementComboViewer = new ComboViewer(facetElementCombo); final Combo facetTypeCombo = new Combo(searchPFacetComp, SWT.READ_ONLY); _facetTypeComboViewer = new ComboViewer(facetTypeCombo); final Combo facetSubtypeCombo = new Combo(searchPFacetComp, SWT.READ_ONLY); _facetSubtypeComboViewer = new ComboViewer(facetSubtypeCombo); final Combo facetRoleCombo = new Combo(searchPFacetComp, SWT.READ_ONLY); _facetRoleComboViewer = new ComboViewer(facetRoleCombo); _facetCombo = new Combo(searchPFacetComp, SWT.READ_ONLY); facetElementCombo.setLayoutData(new GridData()); facetElementCombo.setLayoutData(new GridData()); ((GridData) facetElementCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) facetElementCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) facetElementCombo.getLayoutData()).horizontalSpan = 2; facetElementComboViewer.setContentProvider(new MarkupContentProvider(true)); facetElementComboViewer.setLabelProvider(new MarkupLabelProvider()); facetElementComboViewer.setComparator(new ConfigDataComparator()); if (_facade.getConfigs().containsKey(_markupProvider)) { HashMap<String, ConfigData> input = _facade.getConfigs().get(_markupProvider).getChildren(); facetElementComboViewer.setInput(input); } Object obj = facetElementComboViewer.getElementAt(0); if (obj != null) { facetElementComboViewer.setSelection(new StructuredSelection(obj)); ConfigData cd = (ConfigData) facetElementComboViewer.getElementAt(0); if (cd.getValue().startsWith("aodl:")) { _facetElement = cd.getValue().substring(5); //$NON-NLS-1$ } else { _facetElement = cd.getValue(); } } facetElementComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override @SuppressWarnings("unchecked") public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); ConfigData cd = (ConfigData) obj; if (cd.getValue().startsWith("aodl:")) { _facetElement = cd.getValue().substring(5); //$NON-NLS-1$ } else { _facetElement = cd.getValue(); } _facetQuery.getCriterias().get(0).setCrit1(_facetElement); facetTypeCombo.removeAll(); _facetQuery.getCriterias().get(0).setCrit2(null); facetSubtypeCombo.removeAll(); _facetQuery.getCriterias().get(0).setCrit3(null); facetRoleCombo.removeAll(); _facetQuery.getCriterias().get(0).setCrit4(null); _facetCombo.removeAll(); setComboViewerInput(_facetTypeComboViewer, "tagging_values", _facetElement, null, null); //$NON-NLS-1$ if (_facetQuery.getKey().equals("content")) //$NON-NLS-1$ { try { _facetStrings = _mainSearcher.getFacets("tagging", _facetElement, _facetType, _facetSubtype, //$NON-NLS-1$ _facetRole); _facetCombo.setItems(_facetStrings); setQueryFacets(_facetQuery, _facetStrings); } catch (Exception e1) { e1.printStackTrace(); } } else if (_facetQuery.getKey().equals("type")) //$NON-NLS-1$ { try { _facetStrings = (_mainSearcher.getFacets("tagging_values", _facetElement, null, null, //$NON-NLS-1$ null)); } catch (Exception e1) { e1.printStackTrace(); } _facetQuery.setFacets((HashMap<String, IAEPresentable>) _facetTypeComboViewer.getInput()); } } }); facetTypeCombo.setLayoutData(new GridData()); facetTypeCombo.setLayoutData(new GridData()); ((GridData) facetTypeCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) facetTypeCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) facetTypeCombo.getLayoutData()).horizontalSpan = 2; _facetTypeComboViewer.setContentProvider(new MarkupContentProvider()); _facetTypeComboViewer.setLabelProvider(new MarkupLabelProvider()); _facetTypeComboViewer.setComparator(new ConfigDataComparator()); _facetTypeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override @SuppressWarnings("unchecked") public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); ConfigData cd = (ConfigData) obj; facetSubtypeCombo.removeAll(); _facetQuery.getCriterias().get(0).setCrit3(null); facetRoleCombo.removeAll(); _facetQuery.getCriterias().get(0).setCrit4(null); _facetCombo.removeAll(); _facetType = cd.getValue(); _facetQuery.getCriterias().get(0).setCrit2(_facetType); setComboViewerInput(_facetSubtypeComboViewer, "tagging_values", _facetElement, _facetType, null); //$NON-NLS-1$ if (_facetQuery.getKey().equals("content")) //$NON-NLS-1$ { try { _facetStrings = (_mainSearcher.getFacets("tagging", _facetElement, _facetType, //$NON-NLS-1$ _facetSubtype, _facetRole)); setQueryFacets(_facetQuery, _facetStrings); _facetCombo.setItems(_facetStrings); } catch (Exception e1) { e1.printStackTrace(); } } else if (_facetQuery.getKey().equals("subtype")) //$NON-NLS-1$ { try { _facetStrings = (_mainSearcher.getFacets("tagging_values", _facetElement, _facetType, null, //$NON-NLS-1$ null)); } catch (Exception e1) { e1.printStackTrace(); } _facetQuery.setFacets((HashMap<String, IAEPresentable>) _facetSubtypeComboViewer.getInput()); } } }); facetSubtypeCombo.setLayoutData(new GridData()); facetSubtypeCombo.setLayoutData(new GridData()); ((GridData) facetSubtypeCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) facetSubtypeCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) facetSubtypeCombo.getLayoutData()).horizontalSpan = 2; _facetSubtypeComboViewer.setContentProvider(new MarkupContentProvider()); _facetSubtypeComboViewer.setLabelProvider(new MarkupLabelProvider()); _facetSubtypeComboViewer.setComparator(new ConfigDataComparator()); _facetSubtypeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override @SuppressWarnings("unchecked") public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); ConfigData cd = (ConfigData) obj; _aspectFacetSubtype = cd.getValue(); facetRoleCombo.removeAll(); _facetQuery.getCriterias().get(0).setCrit4(null); _facetCombo.removeAll(); _facetQuery.getCriterias().get(0).setCrit3(_facetSubtype); setComboViewerInput(_facetRoleComboViewer, "tagging_values", _facetElement, _facetType, //$NON-NLS-1$ _facetSubtype); if (_facetQuery.getKey().equals("content")) //$NON-NLS-1$ { try { _facetStrings = (_mainSearcher.getFacets("tagging", _facetElement, _facetType, //$NON-NLS-1$ _facetSubtype, _facetRole)); setQueryFacets(_facetQuery, _facetStrings); _facetCombo.setItems(_facetStrings); } catch (Exception e1) { e1.printStackTrace(); } } else if (_facetQuery.getKey().equals("role")) //$NON-NLS-1$ { try { _facetStrings = (_mainSearcher.getFacets("tagging_values", _facetElement, _facetType, //$NON-NLS-1$ _facetSubtype, null)); } catch (Exception e1) { e1.printStackTrace(); } _facetQuery.setFacets((HashMap<String, IAEPresentable>) _facetRoleComboViewer.getInput()); } } }); facetRoleCombo.setLayoutData(new GridData()); facetRoleCombo.setLayoutData(new GridData()); ((GridData) facetRoleCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) facetRoleCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) facetRoleCombo.getLayoutData()).horizontalSpan = 2; _facetRoleComboViewer.setContentProvider(new MarkupContentProvider()); _facetRoleComboViewer.setLabelProvider(new MarkupLabelProvider()); _facetRoleComboViewer.setComparator(new ConfigDataComparator()); _facetRoleComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); ConfigData cd = (ConfigData) obj; _facetRole = cd.getValue(); _facetCombo.removeAll(); _facetQuery.getCriterias().get(0).setCrit4(_facetRole); if (_facetQuery.getKey().equals("content")) //$NON-NLS-1$ { try { _facetStrings = (_mainSearcher.getFacets("tagging", _facetElement, _facetType, //$NON-NLS-1$ _facetSubtype, _facetRole)); setQueryFacets(_facetQuery, _facetStrings); _facetCombo.setItems(_facetStrings); } catch (Exception e1) { e1.printStackTrace(); } } } }); _facetCombo.setLayoutData(new GridData()); _facetCombo.setLayoutData(new GridData()); ((GridData) _facetCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) _facetCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) _facetCombo.getLayoutData()).horizontalSpan = 2; // facetCombo.addFocusListener(new FocusAdapter(){ // public void focusGained(FocusEvent e) // { // try { // facetQuery.setFacets(mainSearcher.getFacets( "tagging", facetElement, facetType, facetSubtype, //$NON-NLS-1$ // facetRole)); // facetCombo.setItems(facetQuery.getFacets()); // // } catch (Exception e1) { // e1.printStackTrace(); // } // } // } // ); for (int i = 1; i < _facetQuery.getCriterias().size(); i++) { // System.out.println("for i = " + i); //$NON-NLS-1$ final Criteria c = _facetQuery.getCriterias().get(i); if (c.getType().equals("tagging")) //$NON-NLS-1$ { if (tag1) { tag1 = false; _searchPTagComp = new Composite(_facetPersonSearchGroup, SWT.NONE); _searchPTagComp.setLayout(new GridLayout()); ((GridLayout) _searchPTagComp.getLayout()).makeColumnsEqualWidth = true; ((GridLayout) _searchPTagComp.getLayout()).numColumns = 14; _searchPTagComp.setLayoutData(new GridData()); ((GridData) _searchPTagComp.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) _searchPTagComp.getLayoutData()).grabExcessHorizontalSpace = true; // ((GridData) searchPTagComp.getLayoutData()).heightHint = // 200; ((GridData) _searchPTagComp.getLayoutData()).grabExcessVerticalSpace = false; ((GridData) _searchPTagComp.getLayoutData()).horizontalSpan = 1; Label op = new Label(_searchPTagComp, SWT.NONE); op.setText(NLMessages.getString("Dialog_operand")); //$NON-NLS-1$ op.setLayoutData(new GridData()); ((GridData) op.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) op.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) op.getLayoutData()).horizontalSpan = 1; Label sem = new Label(_searchPTagComp, SWT.NONE); sem.setText(NLMessages.getString("Dialog_semantic")); //$NON-NLS-1$ sem.setLayoutData(new GridData()); ((GridData) sem.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) sem.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) sem.getLayoutData()).horizontalSpan = 2; Label tagName = new Label(_searchPTagComp, SWT.NONE); tagName.setText(NLMessages.getString("Dialog_markup")); //$NON-NLS-1$ tagName.setLayoutData(new GridData()); ((GridData) tagName.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) tagName.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) tagName.getLayoutData()).horizontalSpan = 2; Label tagType = new Label(_searchPTagComp, SWT.NONE); tagType.setText(NLMessages.getString("Dialog_type")); //$NON-NLS-1$ tagType.setLayoutData(new GridData()); ((GridData) tagType.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) tagType.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) tagType.getLayoutData()).horizontalSpan = 2; Label tagSubtype = new Label(_searchPTagComp, SWT.NONE); tagSubtype.setText(NLMessages.getString("Dialog_subtype")); //$NON-NLS-1$ tagSubtype.setLayoutData(new GridData()); ((GridData) tagSubtype.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) tagSubtype.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) tagSubtype.getLayoutData()).horizontalSpan = 2; Label searchTextLabel = new Label(_searchPTagComp, SWT.NONE); searchTextLabel.setText(NLMessages.getString("Dialog_searchText")); //$NON-NLS-1$ searchTextLabel.setLayoutData(new GridData()); ((GridData) searchTextLabel.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) searchTextLabel.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) searchTextLabel.getLayoutData()).horizontalSpan = 3; Label fuzzy = new Label(_searchPTagComp, SWT.NONE); fuzzy.setText(NLMessages.getString("Dialog_fuzzy")); //$NON-NLS-1$ fuzzy.setLayoutData(new GridData()); ((GridData) fuzzy.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) fuzzy.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) fuzzy.getLayoutData()).horizontalSpan = 1; Label include = new Label(_searchPTagComp, SWT.NONE); include.setText(NLMessages.getString("Dialog_include")); //$NON-NLS-1$ include.setToolTipText(NLMessages.getString("Dialog_includeConcurrences")); //$NON-NLS-1$ include.setLayoutData(new GridData()); ((GridData) include.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) include.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) include.getLayoutData()).horizontalSpan = 1; } if (i == 0) { Label l = new Label(_searchPTagComp, SWT.NONE); l.setText(NLMessages.getString("Dialog_markup")); //$NON-NLS-1$ l.setLayoutData(new GridData()); ((GridData) l.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) l.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) l.getLayoutData()).horizontalSpan = 1; } else { final Combo opCombo = new Combo(_searchPTagComp, SWT.READ_ONLY); opCombo.setLayoutData(new GridData()); opCombo.add(Operator.AND.toString()); opCombo.add(Operator.OR.toString()); opCombo.add(Operator.NOT.toString()); opCombo.setLayoutData(new GridData()); ((GridData) opCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) opCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) opCombo.getLayoutData()).horizontalSpan = 1; if (c.getOperator() != null) { opCombo.setText(c.getOperator()); } else { opCombo.select(0); c.setOperator(opCombo.getItem(0)); } opCombo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { c.setOperator(opCombo.getItem(opCombo.getSelectionIndex())); } }); } final Combo semCombo = new Combo(_searchPTagComp, SWT.READ_ONLY); semCombo.setLayoutData(new GridData()); ComboViewer comboSemanticViewer = new ComboViewer(semCombo); comboSemanticViewer.setContentProvider(new AEConfigPresentableContentProvider()); comboSemanticViewer.setLabelProvider(new AEConfigPresentableLabelProvider()); ((AEConfigPresentableContentProvider) comboSemanticViewer.getContentProvider()).setAddALL(true); if (_facade.getAllSemantics() != null && !_facade.getAllSemantics().isEmpty()) { comboSemanticViewer.setInput(_facade.getAllSemantics()); if (c.getCrit0() != null) { setComboViewerByString(comboSemanticViewer, c.getCrit0()); } else { semCombo.select(0); c.setCrit0(semCombo.getItem(0)); } } semCombo.setLayoutData(new GridData()); ((GridData) semCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) semCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) semCombo.getLayoutData()).horizontalSpan = 2; comboSemanticViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); IAEPresentable cp = (IAEPresentable) obj; if (cp != null) { c.setCrit0(cp.getValue()); } } }); final Combo tagCombo = new Combo(_searchPTagComp, SWT.READ_ONLY); tagCombo.setLayoutData(new GridData()); tagCombo.setLayoutData(new GridData()); ((GridData) tagCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) tagCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) tagCombo.getLayoutData()).horizontalSpan = 2; final ComboViewer tagComboViewer = new ComboViewer(tagCombo); tagComboViewer.setContentProvider(new MarkupContentProvider(true)); tagComboViewer.setLabelProvider(new MarkupLabelProvider()); tagComboViewer.setComparator(new ConfigDataComparator()); if (_facade.getConfigs().containsKey(_markupProvider)) { HashMap<String, ConfigData> input = _facade.getConfigs().get(_markupProvider).getChildren(); facetElementComboViewer.setInput(input); } if (c.getCrit1() != null) { setComboViewerByString(tagComboViewer, c.getCrit1()); } else { obj = facetElementComboViewer.getElementAt(0); if (obj != null) { facetElementComboViewer.setSelection(new StructuredSelection(obj)); ConfigData cd = (ConfigData) facetElementComboViewer.getElementAt(0); if (cd != null && cd.getValue().startsWith("aodl:")) { c.setCrit1(cd.getValue().substring(5)); //$NON-NLS-1$ } else if (cd != null) { c.setCrit1(cd.getValue()); } } } final Combo typeCombo = new Combo(_searchPTagComp, SWT.READ_ONLY); typeCombo.setLayoutData(new GridData()); typeCombo.setLayoutData(new GridData()); ((GridData) typeCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) typeCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) typeCombo.getLayoutData()).horizontalSpan = 2; final ComboViewer typeComboViewer = new ComboViewer(typeCombo); typeComboViewer.setContentProvider(new MarkupContentProvider()); typeComboViewer.setLabelProvider(new MarkupLabelProvider()); typeComboViewer.setComparator(new ConfigDataComparator()); tagComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); ConfigData cd = (ConfigData) obj; String selection; if (cd.getValue().startsWith("aodl:")) { selection = cd.getValue().substring(5); //$NON-NLS-1$ } else { selection = cd.getValue(); } c.setCrit1(selection); setComboViewerInput(typeComboViewer, "tagging_values", c.getCrit1(), null, null); //$NON-NLS-1$ } }); if (c.getCrit2() != null) { setComboViewerByString(typeComboViewer, c.getCrit2()); } final Combo subtypeCombo = new Combo(_searchPTagComp, SWT.READ_ONLY); final ComboViewer subtypeComboViewer = new ComboViewer(subtypeCombo); subtypeComboViewer.setContentProvider(new MarkupContentProvider()); subtypeComboViewer.setLabelProvider(new MarkupLabelProvider()); subtypeComboViewer.setComparator(new ConfigDataComparator()); // typeCombo.addFocusListener(new FocusAdapter(){ // public void focusGained(FocusEvent e) // { // } // } // ); typeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); ConfigData cd = (ConfigData) obj; subtypeComboViewer.setInput(null); if (cd != null) { c.setCrit2(cd.getValue()); } setComboViewerInput(subtypeComboViewer, "tagging_values", c.getCrit1(), c.getCrit2(), null); //$NON-NLS-1$ } }); subtypeCombo.setLayoutData(new GridData()); subtypeCombo.setLayoutData(new GridData()); ((GridData) subtypeCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) subtypeCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) subtypeCombo.getLayoutData()).horizontalSpan = 2; if (c.getCrit3() != null) { setComboViewerByString(subtypeComboViewer, c.getCrit3()); } // subtypeCombo.addFocusListener(new FocusAdapter(){ // public void focusGained(FocusEvent e) // { // // } // } // ); subtypeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); ConfigData cd = (ConfigData) obj; if (cd != null) { c.setCrit3(cd.getValue()); } } }); final Text searchText = new Text(_searchPTagComp, SWT.BORDER); searchText.setLayoutData(new GridData()); searchText.setLayoutData(new GridData()); ((GridData) searchText.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) searchText.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) searchText.getLayoutData()).horizontalSpan = 3; if (c.getSearchText() != null) { searchText.setText(c.getSearchText()); } searchText.addFocusListener(new FocusAdapter() { @Override public void focusLost(final FocusEvent e) { c.setSearchText(searchText.getText()); } }); searchText.addKeyListener(new KeyListener() { @Override public void keyPressed(final KeyEvent e) { if (e.keyCode == SWT.CR) { c.setSearchText(searchText.getText()); okPressed(); } } @Override public void keyReleased(final KeyEvent e) { } }); final Button fuzzyB = new Button(_searchPTagComp, SWT.CHECK); fuzzyB.setLayoutData(new GridData()); fuzzyB.setSelection(c.isFuzzy()); fuzzyB.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { c.setFuzzy(!c.isFuzzy()); } }); final Button includeB = new Button(_searchPTagComp, SWT.CHECK); includeB.setLayoutData(new GridData()); includeB.setSelection(c.isIncludeConcurrences()); includeB.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { c.setIncludeConcurrences(!c.isIncludeConcurrences()); } }); } // if tagging if (c.getType().equals("date")) //$NON-NLS-1$ { if (date1) { date1 = false; _searchPDateComp = new Composite(_facetPersonSearchGroup, SWT.NONE); _searchPDateComp.setLayout(new GridLayout()); ((GridLayout) _searchPDateComp.getLayout()).makeColumnsEqualWidth = true; ((GridLayout) _searchPDateComp.getLayout()).numColumns = 14; _searchPDateComp.setLayoutData(new GridData()); ((GridData) _searchPDateComp.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) _searchPDateComp.getLayoutData()).grabExcessHorizontalSpace = true; // ((GridData) searchPDateComp.getLayoutData()).heightHint = // 200; ((GridData) _searchPDateComp.getLayoutData()).grabExcessVerticalSpace = false; ((GridData) _searchPDateComp.getLayoutData()).horizontalSpan = 1; Label l2 = new Label(_searchPDateComp, SWT.NONE); l2.setText(NLMessages.getString("Dialog_date")); //$NON-NLS-1$ l2.setLayoutData(new GridData()); ((GridData) l2.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) l2.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) l2.getLayoutData()).horizontalSpan = 1; Label typeDate = new Label(_searchPDateComp, SWT.NONE); typeDate.setText(NLMessages.getString("Dialog_type")); //$NON-NLS-1$ typeDate.setLayoutData(new GridData()); ((GridData) typeDate.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) typeDate.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) typeDate.getLayoutData()).horizontalSpan = 2; Label bl = new Label(_searchPDateComp, SWT.NONE); bl.setText(""); //$NON-NLS-1$ Label notBefore = new Label(_searchPDateComp, SWT.NONE); notBefore.setText(NLMessages.getString("Dialog_day")); //$NON-NLS-1$ notBefore.setLayoutData(new GridData()); ((GridData) notBefore.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) notBefore.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) notBefore.getLayoutData()).horizontalSpan = 1; Label month = new Label(_searchPDateComp, SWT.NONE); month.setText(NLMessages.getString("Dialog_month")); //$NON-NLS-1$ month.setLayoutData(new GridData()); ((GridData) month.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) month.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) month.getLayoutData()).horizontalSpan = 1; Label year = new Label(_searchPDateComp, SWT.NONE); year.setText(NLMessages.getString("Dialog_year")); //$NON-NLS-1$ year.setLayoutData(new GridData()); ((GridData) year.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) year.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) year.getLayoutData()).horizontalSpan = 2; Label bl2 = new Label(_searchPDateComp, SWT.NONE); bl2.setText(""); //$NON-NLS-1$ Label notAfter = new Label(_searchPDateComp, SWT.NONE); notAfter.setText(NLMessages.getString("Dialog_day")); //$NON-NLS-1$ notAfter.setLayoutData(new GridData()); ((GridData) notAfter.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) notAfter.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) notAfter.getLayoutData()).horizontalSpan = 1; Label month2 = new Label(_searchPDateComp, SWT.NONE); month2.setText(NLMessages.getString("Dialog_month")); //$NON-NLS-1$ month2.setLayoutData(new GridData()); ((GridData) month2.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) month2.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) month2.getLayoutData()).horizontalSpan = 1; Label year2 = new Label(_searchPDateComp, SWT.NONE); year2.setText(NLMessages.getString("Dialog_year")); //$NON-NLS-1$ year2.setLayoutData(new GridData()); ((GridData) year2.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) year2.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) year2.getLayoutData()).horizontalSpan = 2; Label include = new Label(_searchPDateComp, SWT.NONE); include.setText(""); //$NON-NLS-1$ include.setToolTipText(NLMessages.getString("Dialog_includeConcurrences")); //$NON-NLS-1$ include.setLayoutData(new GridData()); ((GridData) include.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) include.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) include.getLayoutData()).horizontalSpan = 1; } if (i == 0) { Label l = new Label(_searchPDateComp, SWT.NONE); l.setLayoutData(new GridData()); ((GridData) l.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) l.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) l.getLayoutData()).horizontalSpan = 1; } else { final Combo opCombo = new Combo(_searchPDateComp, SWT.READ_ONLY); opCombo.setLayoutData(new GridData()); opCombo.add(Operator.AND.toString()); opCombo.add(Operator.OR.toString()); opCombo.add(Operator.NOT.toString()); opCombo.setLayoutData(new GridData()); ((GridData) opCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) opCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) opCombo.getLayoutData()).horizontalSpan = 1; if (c.getOperator() != null) { opCombo.setText(c.getOperator()); } else { opCombo.select(0); c.setOperator(opCombo.getItem(0)); } opCombo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { c.setOperator(opCombo.getItem(opCombo.getSelectionIndex())); } }); } final Combo typeDCombo = new Combo(_searchPDateComp, SWT.READ_ONLY); typeDCombo.setLayoutData(new GridData()); ComboViewer timeTypeComboViewer = new ComboViewer(typeDCombo); timeTypeComboViewer.setContentProvider(ArrayContentProvider.getInstance()); timeTypeComboViewer.setLabelProvider(new LabelProvider() { @Override public String getText(final Object element) { String str = (String) element; if (NLMessages.getString("Editor_time_" + str) != null) //$NON-NLS-1$ { return NLMessages.getString("Editor_time_" + str); //$NON-NLS-1$ } return str; } }); timeTypeComboViewer.setInput(AEConstants.TIME_TYPES); timeTypeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection selection = event.getSelection(); Object obj = ((IStructuredSelection) selection).getFirstElement(); String s = (String) obj; c.setDateType(s); } }); if (c.getDateType() != null) { StructuredSelection selection = new StructuredSelection(c.getDateType()); timeTypeComboViewer.setSelection(selection); } else { StructuredSelection selection = new StructuredSelection(AEConstants.TIME_TYPES[0]); timeTypeComboViewer.setSelection(selection); c.setDateType(AEConstants.TIME_TYPES[0]); } typeDCombo.pack(); typeDCombo.setLayoutData(new GridData()); ((GridData) typeDCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) typeDCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) typeDCombo.getLayoutData()).horizontalSpan = 2; Label from = new Label(_searchPDateComp, SWT.NONE); from.setText(NLMessages.getString("Dialog_from")); //$NON-NLS-1$ from.setLayoutData(new GridData()); ((GridData) from.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) from.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) from.getLayoutData()).horizontalSpan = 1; final Combo day1Combo = new Combo(_searchPDateComp, SWT.READ_ONLY); day1Combo.setLayoutData(new GridData()); day1Combo.setItems(AEConstants.DAYS); day1Combo.setLayoutData(new GridData()); ((GridData) day1Combo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) day1Combo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) day1Combo.getLayoutData()).horizontalSpan = 1; if (c.getDateFrom() == null) { PdrDate dateFrom = new PdrDate("0000-00-00"); //$NON-NLS-1$ // dateFrom.setDay(0); // dateFrom.setMonth(0); // dateFrom.setYear(0); c.setDateFrom(dateFrom); day1Combo.select(c.getDateFrom().getDay()); } // System.out.println("test: dateFrom " + c.getDateFrom().toString()); //$NON-NLS-1$ // else // { // // day1Combo.select(0); // c.getDateFrom().setDay(0); // // } day1Combo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { c.getDateFrom().setDay(day1Combo.getSelectionIndex()); } }); final Combo month1Combo = new Combo(_searchPDateComp, SWT.READ_ONLY); month1Combo.setLayoutData(new GridData()); month1Combo.setItems(AEConstants.MONTHS); month1Combo.setLayoutData(new GridData()); ((GridData) month1Combo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) month1Combo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) month1Combo.getLayoutData()).horizontalSpan = 1; if (c.getDateFrom() != null) { month1Combo.select(c.getDateFrom().getMonth()); } else { month1Combo.select(0); c.getDateFrom().setMonth(0); } month1Combo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { c.getDateFrom().setMonth(month1Combo.getSelectionIndex()); } }); final YearSpinner year1Spinner = new YearSpinner(_searchPDateComp, SWT.NULL); // year1Spinner.setLayoutData(new GridData()); // year1Spinner.setLayoutData(new GridData()); // ((GridData) year1Spinner.getLayoutData()).horizontalAlignment // = SWT.FILL; // ((GridData) // year1Spinner.getLayoutData()).grabExcessHorizontalSpace = // true; // ((GridData) year1Spinner.getLayoutData()).horizontalSpan = 2; // year1Spinner.setMinimum(0); // year1Spinner.setMaximum(9999); if (c.getDateFrom() != null) { year1Spinner.setSelection(c.getDateFrom().getYear()); } else { year1Spinner.setSelection(_preselection); c.getDateFrom().setYear(_preselection); } year1Spinner.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(final SelectionEvent e) { c.getDateFrom().setYear(year1Spinner.getSelection()); // System.out.println("year1Spinner.getSelection() " + // year1Spinner.getSelection()); } @Override public void widgetSelected(final SelectionEvent e) { c.getDateFrom().setYear(year1Spinner.getSelection()); // System.out.println("year1Spinner.getSelection() " + // year1Spinner.getSelection()); } }); Label to = new Label(_searchPDateComp, SWT.NONE); to.setText(NLMessages.getString("Dialog_to")); //$NON-NLS-1$ to.setLayoutData(new GridData()); ((GridData) to.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) to.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) to.getLayoutData()).horizontalSpan = 1; final Combo day2Combo = new Combo(_searchPDateComp, SWT.READ_ONLY); day2Combo.setLayoutData(new GridData()); day2Combo.setItems(AEConstants.DAYS); day2Combo.setLayoutData(new GridData()); ((GridData) day2Combo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) day2Combo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) day2Combo.getLayoutData()).horizontalSpan = 1; if (c.getDateTo() == null) { PdrDate dateTo = new PdrDate("0000-00-00"); //$NON-NLS-1$ c.setDateTo(dateTo); day2Combo.select(c.getDateTo().getDay()); } day2Combo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { c.getDateTo().setDay(day2Combo.getSelectionIndex()); } }); final Combo month2Combo = new Combo(_searchPDateComp, SWT.READ_ONLY); month2Combo.setLayoutData(new GridData()); month2Combo.setItems(AEConstants.MONTHS); month2Combo.setLayoutData(new GridData()); ((GridData) month2Combo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) month2Combo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) month2Combo.getLayoutData()).horizontalSpan = 1; if (c.getDateTo() != null) { month2Combo.select(c.getDateTo().getMonth()); } else { month2Combo.select(0); c.getDateTo().setMonth(0); } month2Combo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { c.getDateTo().setMonth(month2Combo.getSelectionIndex()); } }); final YearSpinner year2Spinner = new YearSpinner(_searchPDateComp, SWT.NULL); // year2Spinner.setLayoutData(new GridData()); // year2Spinner.setLayoutData(new GridData()); // ((GridData) year2Spinner.getLayoutData()).horizontalAlignment // = SWT.FILL; // ((GridData) // year2Spinner.getLayoutData()).grabExcessHorizontalSpace = // true; // ((GridData) year2Spinner.getLayoutData()).horizontalSpan = 2; // year2Spinner.setMinimum(0); // year2Spinner.setMaximum(9999); if (c.getDateTo() != null) { year2Spinner.setSelection(c.getDateTo().getYear()); } else { year2Spinner.setSelection(_preselection); c.getDateTo().setYear(_preselection); } year2Spinner.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(final SelectionEvent e) { c.getDateTo().setYear(year2Spinner.getSelection()); } @Override public void widgetSelected(final SelectionEvent e) { c.getDateTo().setYear(year2Spinner.getSelection()); } }); final Button includeB = new Button(_searchPDateComp, SWT.CHECK); includeB.setLayoutData(new GridData()); includeB.setSelection(c.isIncludeConcurrences()); includeB.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { c.setIncludeConcurrences(!c.isIncludeConcurrences()); } }); } // if date if (c.getType().equals("reference")) //$NON-NLS-1$ { _searchPRefComp = new Composite(_facetPersonSearchGroup, SWT.NONE); _searchPRefComp.setLayout(new GridLayout()); ((GridLayout) _searchPRefComp.getLayout()).makeColumnsEqualWidth = true; ((GridLayout) _searchPRefComp.getLayout()).numColumns = 14; _searchPRefComp.setLayoutData(new GridData()); ((GridData) _searchPRefComp.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) _searchPRefComp.getLayoutData()).grabExcessHorizontalSpace = true; // ((GridData) searchPTagComp.getLayoutData()).heightHint = 200; ((GridData) _searchPRefComp.getLayoutData()).grabExcessVerticalSpace = false; ((GridData) _searchPRefComp.getLayoutData()).horizontalSpan = 1; final Combo opCombo = new Combo(_searchPRefComp, SWT.READ_ONLY); opCombo.setLayoutData(new GridData()); opCombo.add(Operator.AND.toString()); opCombo.add(Operator.OR.toString()); opCombo.add(Operator.NOT.toString()); opCombo.setLayoutData(new GridData()); ((GridData) opCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) opCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) opCombo.getLayoutData()).horizontalSpan = 1; if (c.getOperator() != null) { opCombo.setText(c.getOperator()); } else { opCombo.select(0); c.setOperator(opCombo.getItem(0)); } opCombo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { c.setOperator(opCombo.getItem(opCombo.getSelectionIndex())); } }); Label sem = new Label(_searchPRefComp, SWT.NONE); sem.setText(NLMessages.getString("Dialog_reference")); //$NON-NLS-1$ sem.setLayoutData(new GridData()); ((GridData) sem.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) sem.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) sem.getLayoutData()).horizontalSpan = 2; Label tagName = new Label(_searchPRefComp, SWT.NONE); tagName.setText(NLMessages.getString("Dialog_genre")); //$NON-NLS-1$ tagName.setLayoutData(new GridData()); ((GridData) tagName.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) tagName.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) tagName.getLayoutData()).horizontalSpan = 2; final Combo genreCombo = new Combo(_searchPRefComp, SWT.READ_ONLY); genreCombo.setLayoutData(new GridData()); ComboViewer genreComboViewer = new ComboViewer(genreCombo); genreComboViewer.setContentProvider(new RefTemplateContentProvider(false)); genreComboViewer.setLabelProvider(new LabelProvider() { @Override public String getText(final Object element) { ReferenceModsTemplate template = (ReferenceModsTemplate) element; return template.getLabel(); } }); genreComboViewer.setInput(_facade.getAllGenres()); genreComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection selection = event.getSelection(); Object obj = ((IStructuredSelection) selection).getFirstElement(); ReferenceModsTemplate template = (ReferenceModsTemplate) obj; if (template != null) { c.setCrit0(template.getValue()); } } }); genreCombo.add("ALL", 0); //$NON-NLS-1$ genreCombo.setLayoutData(new GridData()); ((GridData) genreCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) genreCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) genreCombo.getLayoutData()).horizontalSpan = 2; if (c.getCrit0() != null) { StructuredSelection selection = new StructuredSelection(c.getCrit0()); genreComboViewer.setSelection(selection); } else { genreCombo.select(0); c.setCrit0(genreCombo.getItem(0)); } Label tagType = new Label(_searchPRefComp, SWT.NONE); tagType.setText(NLMessages.getString("Dialog_searchText")); //$NON-NLS-1$ tagType.setLayoutData(new GridData()); ((GridData) tagType.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) tagType.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) tagType.getLayoutData()).horizontalSpan = 2; final Text searchText = new Text(_searchPRefComp, SWT.BORDER); searchText.setLayoutData(new GridData()); searchText.setLayoutData(new GridData()); ((GridData) searchText.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) searchText.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) searchText.getLayoutData()).horizontalSpan = 3; if (c.getSearchText() != null) { searchText.setText(c.getSearchText()); } searchText.addFocusListener(new FocusAdapter() { @Override public void focusLost(final FocusEvent e) { c.setSearchText(searchText.getText()); } }); searchText.addKeyListener(new KeyListener() { @Override public void keyPressed(final KeyEvent e) { if (e.keyCode == SWT.CR) { c.setSearchText(searchText.getText()); okPressed(); } } @Override public void keyReleased(final KeyEvent e) { } }); final Button fuzzyB = new Button(_searchPRefComp, SWT.CHECK); fuzzyB.setLayoutData(new GridData()); fuzzyB.setSelection(c.isFuzzy()); fuzzyB.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { c.setFuzzy(!c.isFuzzy()); } }); final Button includeB = new Button(_searchPRefComp, SWT.CHECK); includeB.setLayoutData(new GridData()); includeB.setSelection(c.isIncludeConcurrences()); includeB.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { c.setIncludeConcurrences(!c.isIncludeConcurrences()); } }); } // if reference } // contentCompSearch.layout(); // scrollCompSearch.setContent(contentCompSearch); // scrollCompSearch.setMinSize(contentCompSearch.computeSize(SWT.DEFAULT, // SWT.DEFAULT, true)); // scrollCompSearch.layout(); _facetPersonSearchGroup.redraw(); _facetPersonSearchGroup.layout(); _facetPersonSearchGroup.pack(); _facetPersonSearchGroup.layout(); // facetPersonSearchGroup.pack(); }
From source file:org.bbaw.pdr.ae.view.main.dialogs.AdvancedSearchDialog.java
License:Open Source License
/** * Builds the person search./* www . j av a2 s . c o m*/ * @param type the type * @param crit the crit */ private void buildPersonSearch(final int type, final Integer crit) { _markupProvider = Platform.getPreferencesService().getString(CommonActivator.PLUGIN_ID, "PRIMARY_TAGGING_PROVIDER", AEConstants.CLASSIFICATION_AUTHORITY, null).toUpperCase(); //$NON-NLS-1$ _relationProvider = Platform.getPreferencesService().getString(CommonActivator.PLUGIN_ID, "PRIMARY_RELATION_PROVIDER", AEConstants.RELATION_CLASSIFICATION_PROVIDER, null).toUpperCase(); DataType dtAll = new DataType(); dtAll.setValue("ALL"); //$NON-NLS-1$ dtAll.setLabel("ALL"); //$NON-NLS-1$ boolean tag1 = true; boolean rel1 = true; boolean date1 = true; for (int i = 0; i < _personQuery.getCriterias().size(); i++) { // System.out.println("for i = " + i); //$NON-NLS-1$ final Criteria c = _personQuery.getCriterias().get(i); if (c.getType().equals("tagging")) //$NON-NLS-1$ { if (tag1) { tag1 = false; _searchPTagComp = new Composite(_personSearchGroup, SWT.NONE); _searchPTagComp.setLayout(new GridLayout()); ((GridLayout) _searchPTagComp.getLayout()).makeColumnsEqualWidth = true; ((GridLayout) _searchPTagComp.getLayout()).numColumns = 14; _searchPTagComp.setLayoutData(new GridData()); ((GridData) _searchPTagComp.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) _searchPTagComp.getLayoutData()).grabExcessHorizontalSpace = true; // ((GridData) searchPTagComp.getLayoutData()).heightHint = // 200; ((GridData) _searchPTagComp.getLayoutData()).grabExcessVerticalSpace = false; ((GridData) _searchPTagComp.getLayoutData()).horizontalSpan = 1; Label op = new Label(_searchPTagComp, SWT.NONE); op.setText(NLMessages.getString("Dialog_operand")); //$NON-NLS-1$ op.setLayoutData(new GridData()); ((GridData) op.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) op.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) op.getLayoutData()).horizontalSpan = 1; Label sem = new Label(_searchPTagComp, SWT.NONE); sem.setText(NLMessages.getString("Dialog_semantic")); //$NON-NLS-1$ sem.setLayoutData(new GridData()); ((GridData) sem.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) sem.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) sem.getLayoutData()).horizontalSpan = 2; Label tagName = new Label(_searchPTagComp, SWT.NONE); tagName.setText(NLMessages.getString("Dialog_markup")); //$NON-NLS-1$ tagName.setLayoutData(new GridData()); ((GridData) tagName.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) tagName.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) tagName.getLayoutData()).horizontalSpan = 2; Label tagType = new Label(_searchPTagComp, SWT.NONE); tagType.setText(NLMessages.getString("Dialog_type")); //$NON-NLS-1$ tagType.setLayoutData(new GridData()); ((GridData) tagType.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) tagType.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) tagType.getLayoutData()).horizontalSpan = 2; Label tagSubtype = new Label(_searchPTagComp, SWT.NONE); tagSubtype.setText(NLMessages.getString("Dialog_subtype")); //$NON-NLS-1$ tagSubtype.setLayoutData(new GridData()); ((GridData) tagSubtype.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) tagSubtype.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) tagSubtype.getLayoutData()).horizontalSpan = 2; Label searchTextLabel = new Label(_searchPTagComp, SWT.NONE); searchTextLabel.setText(NLMessages.getString("Dialog_searchText")); //$NON-NLS-1$ searchTextLabel.setLayoutData(new GridData()); ((GridData) searchTextLabel.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) searchTextLabel.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) searchTextLabel.getLayoutData()).horizontalSpan = 3; Label fuzzy = new Label(_searchPTagComp, SWT.NONE); fuzzy.setText(NLMessages.getString("Dialog_fuzzy")); //$NON-NLS-1$ fuzzy.setLayoutData(new GridData()); ((GridData) fuzzy.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) fuzzy.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) fuzzy.getLayoutData()).horizontalSpan = 1; Label include = new Label(_searchPTagComp, SWT.NONE); include.setText(NLMessages.getString("Dialog_include")); //$NON-NLS-1$ include.setToolTipText(NLMessages.getString("Dialog_includeConcurrences")); //$NON-NLS-1$ include.setLayoutData(new GridData()); ((GridData) include.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) include.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) include.getLayoutData()).horizontalSpan = 1; } if (i == 0) { Label l = new Label(_searchPTagComp, SWT.NONE); l.setText(NLMessages.getString("Dialog_markup")); //$NON-NLS-1$ l.setLayoutData(new GridData()); ((GridData) l.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) l.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) l.getLayoutData()).horizontalSpan = 1; } else { final Combo opCombo = new Combo(_searchPTagComp, SWT.READ_ONLY); opCombo.setLayoutData(new GridData()); opCombo.add(Operator.AND.toString()); opCombo.add(Operator.OR.toString()); opCombo.add(Operator.NOT.toString()); opCombo.setLayoutData(new GridData()); ((GridData) opCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) opCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) opCombo.getLayoutData()).horizontalSpan = 1; if (c.getOperator() != null) { opCombo.select(opCombo.indexOf(c.getOperator())); } else { opCombo.select(0); c.setOperator(opCombo.getItem(0)); } opCombo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { c.setOperator(opCombo.getItem(opCombo.getSelectionIndex())); } }); opCombo.pack(); } final Combo semCombo = new Combo(_searchPTagComp, SWT.READ_ONLY); semCombo.setLayoutData(new GridData()); ComboViewer comboSemanticViewer = new ComboViewer(semCombo); comboSemanticViewer.setContentProvider(new AEConfigPresentableContentProvider()); comboSemanticViewer.setLabelProvider(new AEConfigPresentableLabelProvider()); ((AEConfigPresentableContentProvider) comboSemanticViewer.getContentProvider()).setAddALL(true); if (_facade.getAllSemantics() != null && !_facade.getAllSemantics().isEmpty()) { comboSemanticViewer.setInput(_facade.getAllSemantics()); if (c.getCrit0() != null) { setComboViewerByString(comboSemanticViewer, c.getCrit0()); } else { semCombo.select(0); c.setCrit0(semCombo.getItem(0)); } } semCombo.setLayoutData(new GridData()); ((GridData) semCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) semCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) semCombo.getLayoutData()).horizontalSpan = 2; comboSemanticViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); IAEPresentable cp = (IAEPresentable) obj; if (cp != null) { c.setCrit0(cp.getValue()); } } }); semCombo.pack(); final Combo tagCombo = new Combo(_searchPTagComp, SWT.READ_ONLY); tagCombo.setLayoutData(new GridData()); tagCombo.setLayoutData(new GridData()); ((GridData) tagCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) tagCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) tagCombo.getLayoutData()).horizontalSpan = 2; final ComboViewer tagComboViewer = new ComboViewer(tagCombo); tagComboViewer.setContentProvider(new MarkupContentProvider(true)); tagComboViewer.setLabelProvider(new MarkupLabelProvider()); tagComboViewer.setComparator(new ConfigDataComparator()); if (_facade.getConfigs().containsKey(_markupProvider)) { HashMap<String, ConfigData> input = _facade.getConfigs().get(_markupProvider).getChildren(); tagComboViewer.setInput(input); } if (c.getCrit1() != null) { setComboViewerByString(tagComboViewer, c.getCrit1()); } else { Object obj = tagComboViewer.getElementAt(0); if (obj != null) { tagComboViewer.setSelection(new StructuredSelection(obj)); ConfigData cd = (ConfigData) tagComboViewer.getElementAt(0); if (cd.getValue().startsWith("aodl:")) //$NON-NLS-1$ { c.setCrit1(cd.getValue().substring(5)); } else { c.setCrit1(cd.getValue()); } } } final Combo typeCombo = new Combo(_searchPTagComp, SWT.READ_ONLY); typeCombo.setLayoutData(new GridData()); typeCombo.setLayoutData(new GridData()); ((GridData) typeCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) typeCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) typeCombo.getLayoutData()).horizontalSpan = 2; final ComboViewer typeComboViewer = new ComboViewer(typeCombo); typeComboViewer.setContentProvider(new MarkupContentProvider(false)); typeComboViewer.setLabelProvider(new MarkupLabelProvider()); typeComboViewer.setComparator(new ConfigDataComparator()); tagComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); ConfigData cd = (ConfigData) obj; String selection; if (cd.getValue().startsWith("aodl:")) //$NON-NLS-1$ { selection = cd.getValue().substring(5); } else { selection = cd.getValue(); } c.setCrit1(selection); setComboViewerInput(typeComboViewer, "tagging_values", c.getCrit1(), null, null); //$NON-NLS-1$ } }); if (c.getCrit2() != null) { setComboViewerByString(typeComboViewer, c.getCrit2()); } final Combo subtypeCombo = new Combo(_searchPTagComp, SWT.READ_ONLY); final ComboViewer subtypeComboViewer = new ComboViewer(subtypeCombo); subtypeComboViewer.setContentProvider(new MarkupContentProvider()); subtypeComboViewer.setLabelProvider(new MarkupLabelProvider()); subtypeComboViewer.setComparator(new ConfigDataComparator()); typeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); ConfigData cd = (ConfigData) obj; subtypeComboViewer.setInput(null); if (cd != null) { c.setCrit2(cd.getValue()); } setComboViewerInput(subtypeComboViewer, "tagging_values", c.getCrit1(), c.getCrit2(), null); //$NON-NLS-1$ } }); subtypeCombo.setLayoutData(new GridData()); subtypeCombo.setLayoutData(new GridData()); ((GridData) subtypeCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) subtypeCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) subtypeCombo.getLayoutData()).horizontalSpan = 2; if (c.getCrit3() != null) { setComboViewerByString(subtypeComboViewer, c.getCrit3()); } subtypeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); ConfigData cd = (ConfigData) obj; if (cd != null) { c.setCrit3(cd.getValue()); } } }); final Text searchText = new Text(_searchPTagComp, SWT.BORDER); searchText.setLayoutData(new GridData()); searchText.setLayoutData(new GridData()); ((GridData) searchText.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) searchText.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) searchText.getLayoutData()).horizontalSpan = 3; if (c.getSearchText() != null) { searchText.setText(c.getSearchText()); } searchText.addFocusListener(new FocusAdapter() { @Override public void focusLost(final FocusEvent e) { c.setSearchText(searchText.getText()); } }); searchText.addKeyListener(new KeyListener() { @Override public void keyPressed(final KeyEvent e) { if (e.keyCode == SWT.CR) { c.setSearchText(searchText.getText()); okPressed(); } } @Override public void keyReleased(final KeyEvent e) { } }); final Button fuzzyB = new Button(_searchPTagComp, SWT.CHECK); fuzzyB.setLayoutData(new GridData()); fuzzyB.setSelection(c.isFuzzy()); fuzzyB.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { c.setFuzzy(!c.isFuzzy()); } }); final Button includeB = new Button(_searchPTagComp, SWT.CHECK); includeB.setLayoutData(new GridData()); includeB.setSelection(c.isIncludeConcurrences()); includeB.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { c.setIncludeConcurrences(!c.isIncludeConcurrences()); } }); } // if tagging if (c.getType().equals("relation")) //$NON-NLS-1$ { if (rel1) { rel1 = false; _searchPRelComp = new Composite(_personSearchGroup, SWT.NONE); _searchPRelComp.setLayout(new GridLayout()); ((GridLayout) _searchPRelComp.getLayout()).makeColumnsEqualWidth = true; ((GridLayout) _searchPRelComp.getLayout()).numColumns = 14; _searchPRelComp.setLayoutData(new GridData()); ((GridData) _searchPRelComp.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) _searchPRelComp.getLayoutData()).grabExcessHorizontalSpace = true; // ((GridData) searchPRelComp.getLayoutData()).heightHint = // 200; ((GridData) _searchPRelComp.getLayoutData()).grabExcessVerticalSpace = false; ((GridData) _searchPRelComp.getLayoutData()).horizontalSpan = 1; Label l = new Label(_searchPRelComp, SWT.NONE); l.setText(NLMessages.getString("Dialog_relation")); //$NON-NLS-1$ l.setLayoutData(new GridData()); ((GridData) l.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) l.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) l.getLayoutData()).horizontalSpan = 1; Label context = new Label(_searchPRelComp, SWT.NONE); context.setText(NLMessages.getString("Dialog_context")); //$NON-NLS-1$ context.setLayoutData(new GridData()); ((GridData) context.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) context.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) context.getLayoutData()).horizontalSpan = 2; Label classL = new Label(_searchPRelComp, SWT.NONE); classL.setText(NLMessages.getString("Dialog_class")); //$NON-NLS-1$ classL.setLayoutData(new GridData()); ((GridData) classL.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) classL.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) classL.getLayoutData()).horizontalSpan = 2; Label relObj = new Label(_searchPRelComp, SWT.NONE); relObj.setText(NLMessages.getString("Dialog_relObject")); //$NON-NLS-1$ relObj.setLayoutData(new GridData()); ((GridData) relObj.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) relObj.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) relObj.getLayoutData()).horizontalSpan = 4; Label searchTextLabel = new Label(_searchPRelComp, SWT.NONE); searchTextLabel.setText(NLMessages.getString("Dialog_searchText")); //$NON-NLS-1$ searchTextLabel.setLayoutData(new GridData()); ((GridData) searchTextLabel.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) searchTextLabel.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) searchTextLabel.getLayoutData()).horizontalSpan = 3; Label fuzzy = new Label(_searchPRelComp, SWT.NONE); fuzzy.setText(""); //$NON-NLS-1$ fuzzy.setLayoutData(new GridData()); ((GridData) fuzzy.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) fuzzy.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) fuzzy.getLayoutData()).horizontalSpan = 1; Label include = new Label(_searchPRelComp, SWT.NONE); include.setText(""); //$NON-NLS-1$ include.setToolTipText(NLMessages.getString("Dialog_includeConcurrences")); //$NON-NLS-1$ include.setLayoutData(new GridData()); ((GridData) include.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) include.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) include.getLayoutData()).horizontalSpan = 1; } if (i == 0) { Label l = new Label(_searchPRelComp, SWT.NONE); l.setLayoutData(new GridData()); l.setLayoutData(new GridData()); ((GridData) l.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) l.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) l.getLayoutData()).horizontalSpan = 1; } else { final Combo opCombo = new Combo(_searchPRelComp, SWT.READ_ONLY); opCombo.setLayoutData(new GridData()); opCombo.add(Operator.AND.toString()); opCombo.add(Operator.OR.toString()); opCombo.add(Operator.NOT.toString()); opCombo.setLayoutData(new GridData()); ((GridData) opCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) opCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) opCombo.getLayoutData()).horizontalSpan = 1; if (c.getOperator() != null) { opCombo.select(opCombo.indexOf(c.getOperator())); } else { opCombo.select(0); c.setOperator(opCombo.getItem(0)); } opCombo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { c.setOperator(opCombo.getItem(opCombo.getSelectionIndex())); } }); } final Combo contextCombo = new Combo(_searchPRelComp, SWT.READ_ONLY); contextCombo.setLayoutData(new GridData()); contextCombo.setLayoutData(new GridData()); ((GridData) contextCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) contextCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) contextCombo.getLayoutData()).horizontalSpan = 2; final ComboViewer contextComboViewer = new ComboViewer(contextCombo); contextComboViewer.setContentProvider(new MarkupContentProvider()); contextComboViewer.setLabelProvider(new MarkupLabelProvider()); contextComboViewer.setComparator(new ConfigDataComparator()); final Combo classCombo = new Combo(_searchPRelComp, SWT.READ_ONLY); classCombo.setLayoutData(new GridData()); classCombo.setLayoutData(new GridData()); ((GridData) classCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) classCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) classCombo.getLayoutData()).horizontalSpan = 2; final ComboViewer classComboViewer = new ComboViewer(classCombo); classComboViewer.setContentProvider(new MarkupContentProvider()); classComboViewer.setLabelProvider(new MarkupLabelProvider()); classComboViewer.setComparator(new ConfigDataComparator()); setComboViewerInput(contextComboViewer, "relation", null, null, null); //$NON-NLS-1$ if (c.getRelationContext() != null) { setComboViewerByString(contextComboViewer, c.getRelationContext()); setComboViewerInput(classComboViewer, "relation", c.getRelationContext(), null, null); //$NON-NLS-1$ } else { contextComboViewer.setSelection(new StructuredSelection(contextComboViewer.getElementAt(0))); ConfigData cd = (ConfigData) contextComboViewer.getElementAt(0); c.setRelationContext(cd.getValue()); } contextComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); ConfigData cd = (ConfigData) obj; c.setRelationContext(cd.getValue()); setComboViewerInput(classComboViewer, "relation", c.getRelationContext(), null, null); //$NON-NLS-1$ } }); if (c.getRelationClass() != null) { setComboViewerByString(classComboViewer, c.getRelationClass()); } classComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); ConfigData cd = (ConfigData) obj; c.setRelationClass(cd.getValue()); } }); final Text relObjText = new Text(_searchPRelComp, SWT.BORDER); relObjText.setLayoutData(new GridData()); relObjText.setLayoutData(new GridData()); ((GridData) relObjText.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) relObjText.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) relObjText.getLayoutData()).horizontalSpan = 3; if (c.getRelatedId() != null) { relObjText.setText(c.getRelatedId().toString()); } relObjText.setEnabled(false); final Button setObj = new Button(_searchPRelComp, SWT.PUSH); setObj.setEnabled(false); setObj.setText(NLMessages.getString("Dialog_set_key")); //$NON-NLS-1$ setObj.setFont(JFaceResources.getDialogFont()); setObj.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { } }); final Text searchText = new Text(_searchPRelComp, SWT.BORDER); searchText.setLayoutData(new GridData()); searchText.setLayoutData(new GridData()); ((GridData) searchText.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) searchText.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) searchText.getLayoutData()).horizontalSpan = 3; if (c.getSearchText() != null) { searchText.setText(c.getSearchText()); } searchText.addFocusListener(new FocusAdapter() { @Override public void focusLost(final FocusEvent e) { c.setSearchText(searchText.getText()); } }); searchText.addKeyListener(new KeyListener() { @Override public void keyPressed(final KeyEvent e) { if (e.keyCode == SWT.CR) { c.setSearchText(searchText.getText()); okPressed(); } } @Override public void keyReleased(final KeyEvent e) { } }); final Button fuzzyB = new Button(_searchPRelComp, SWT.CHECK); fuzzyB.setLayoutData(new GridData()); fuzzyB.setSelection(c.isFuzzy()); fuzzyB.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { c.setFuzzy(!c.isFuzzy()); } }); final Button includeB = new Button(_searchPRelComp, SWT.CHECK); includeB.setLayoutData(new GridData()); includeB.setSelection(c.isIncludeConcurrences()); includeB.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { c.setIncludeConcurrences(!c.isIncludeConcurrences()); } }); } // if relation if (c.getType().equals("date")) //$NON-NLS-1$ { if (date1) { date1 = false; _searchPDateComp = new Composite(_personSearchGroup, SWT.NONE); _searchPDateComp.setLayout(new GridLayout()); ((GridLayout) _searchPDateComp.getLayout()).makeColumnsEqualWidth = true; ((GridLayout) _searchPDateComp.getLayout()).numColumns = 14; _searchPDateComp.setLayoutData(new GridData()); ((GridData) _searchPDateComp.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) _searchPDateComp.getLayoutData()).grabExcessHorizontalSpace = true; // ((GridData) searchPDateComp.getLayoutData()).heightHint = // 200; ((GridData) _searchPDateComp.getLayoutData()).grabExcessVerticalSpace = false; ((GridData) _searchPDateComp.getLayoutData()).horizontalSpan = 1; Label l2 = new Label(_searchPDateComp, SWT.NONE); l2.setText(NLMessages.getString("Dialog_date")); //$NON-NLS-1$ l2.setLayoutData(new GridData()); ((GridData) l2.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) l2.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) l2.getLayoutData()).horizontalSpan = 1; Label typeDate = new Label(_searchPDateComp, SWT.NONE); typeDate.setText(NLMessages.getString("Dialog_type")); //$NON-NLS-1$ typeDate.setLayoutData(new GridData()); ((GridData) typeDate.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) typeDate.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) typeDate.getLayoutData()).horizontalSpan = 2; // Label notBefore = new Label(_searchPDateComp, SWT.NONE); notBefore.setText(NLMessages.getString("Dialog_day")); //$NON-NLS-1$ notBefore.setLayoutData(new GridData()); ((GridData) notBefore.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) notBefore.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) notBefore.getLayoutData()).horizontalSpan = 1; Label month = new Label(_searchPDateComp, SWT.NONE); month.setText(NLMessages.getString("Dialog_month")); //$NON-NLS-1$ month.setLayoutData(new GridData()); ((GridData) month.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) month.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) month.getLayoutData()).horizontalSpan = 1; Label bl = new Label(_searchPDateComp, SWT.NONE); bl.setText(""); //$NON-NLS-1$ Label year = new Label(_searchPDateComp, SWT.NONE); year.setText(NLMessages.getString("Dialog_year")); //$NON-NLS-1$ year.setLayoutData(new GridData()); ((GridData) year.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) year.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) year.getLayoutData()).horizontalSpan = 2; // Label bl2 = new Label (searchPDateComp, SWT.NONE); // bl2.setText(""); //$NON-NLS-1$ Label notAfter = new Label(_searchPDateComp, SWT.NONE); notAfter.setText(NLMessages.getString("Dialog_day")); //$NON-NLS-1$ notAfter.setLayoutData(new GridData()); ((GridData) notAfter.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) notAfter.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) notAfter.getLayoutData()).horizontalSpan = 1; Label month2 = new Label(_searchPDateComp, SWT.NONE); month2.setText(NLMessages.getString("Dialog_month")); //$NON-NLS-1$ month2.setLayoutData(new GridData()); ((GridData) month2.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) month2.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) month2.getLayoutData()).horizontalSpan = 1; Label bl2 = new Label(_searchPDateComp, SWT.NONE); bl2.setText(""); //$NON-NLS-1$ Label year2 = new Label(_searchPDateComp, SWT.NONE); year2.setText(NLMessages.getString("Dialog_year")); //$NON-NLS-1$ year2.setLayoutData(new GridData()); ((GridData) year2.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) year2.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) year2.getLayoutData()).horizontalSpan = 2; Label include = new Label(_searchPDateComp, SWT.NONE); include.setText(""); //$NON-NLS-1$ include.setToolTipText(NLMessages.getString("Dialog_includeConcurrences")); //$NON-NLS-1$ include.setLayoutData(new GridData()); ((GridData) include.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) include.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) include.getLayoutData()).horizontalSpan = 1; } if (i == 0) { Label l = new Label(_searchPDateComp, SWT.NONE); l.setLayoutData(new GridData()); ((GridData) l.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) l.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) l.getLayoutData()).horizontalSpan = 1; } else { final Combo opCombo = new Combo(_searchPDateComp, SWT.READ_ONLY); opCombo.setLayoutData(new GridData()); opCombo.add(Operator.AND.toString()); opCombo.add(Operator.OR.toString()); opCombo.add(Operator.NOT.toString()); opCombo.setLayoutData(new GridData()); ((GridData) opCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) opCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) opCombo.getLayoutData()).horizontalSpan = 1; if (c.getOperator() != null) { opCombo.setText(c.getOperator()); } else { opCombo.select(0); c.setOperator(opCombo.getItem(0)); } opCombo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { c.setOperator(opCombo.getItem(opCombo.getSelectionIndex())); } }); } final Combo typeDCombo = new Combo(_searchPDateComp, SWT.READ_ONLY); typeDCombo.setLayoutData(new GridData()); ComboViewer timeTypeComboViewer = new ComboViewer(typeDCombo); timeTypeComboViewer.setContentProvider(ArrayContentProvider.getInstance()); timeTypeComboViewer.setLabelProvider(new LabelProvider() { @Override public String getText(final Object element) { String str = (String) element; if (NLMessages.getString("Editor_time_" + str) != null) //$NON-NLS-1$ { return NLMessages.getString("Editor_time_" + str); //$NON-NLS-1$ } return str; } }); timeTypeComboViewer.setInput(AEConstants.TIME_TYPES); timeTypeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection selection = event.getSelection(); Object obj = ((IStructuredSelection) selection).getFirstElement(); String s = (String) obj; // System.out.println("datetype selected " + s); //$NON-NLS-1$ c.setDateType(s); } }); if (c.getDateType() != null) { StructuredSelection selection = new StructuredSelection(c.getDateType()); timeTypeComboViewer.setSelection(selection); } else { StructuredSelection selection = new StructuredSelection(AEConstants.TIME_TYPES[0]); timeTypeComboViewer.setSelection(selection); c.setDateType(AEConstants.TIME_TYPES[0]); } Label from = new Label(_searchPDateComp, SWT.NONE); from.setText(NLMessages.getString("Dialog_from")); //$NON-NLS-1$ from.setLayoutData(new GridData()); ((GridData) from.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) from.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) from.getLayoutData()).horizontalSpan = 1; final Combo day1Combo = new Combo(_searchPDateComp, SWT.READ_ONLY); day1Combo.setLayoutData(new GridData()); day1Combo.setItems(AEConstants.DAYS); day1Combo.setLayoutData(new GridData()); ((GridData) day1Combo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) day1Combo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) day1Combo.getLayoutData()).horizontalSpan = 1; if (c.getDateFrom() == null) { PdrDate dateFrom = new PdrDate("0000-00-00"); //$NON-NLS-1$ // dateFrom.setDay(0); // dateFrom.setMonth(0); // dateFrom.setYear(0); c.setDateFrom(dateFrom); day1Combo.select(c.getDateFrom().getDay()); } // System.out.println("test: dateFrom " + c.getDateFrom().toString()); //$NON-NLS-1$ // else // { // // day1Combo.select(0); // c.getDateFrom().setDay(0); // // } day1Combo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { c.getDateFrom().setDay(day1Combo.getSelectionIndex()); } }); final Combo month1Combo = new Combo(_searchPDateComp, SWT.READ_ONLY); month1Combo.setLayoutData(new GridData()); month1Combo.setItems(AEConstants.MONTHS); month1Combo.setLayoutData(new GridData()); ((GridData) month1Combo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) month1Combo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) month1Combo.getLayoutData()).horizontalSpan = 1; if (c.getDateFrom() != null) { month1Combo.select(c.getDateFrom().getMonth()); } else { month1Combo.select(0); c.getDateFrom().setMonth(0); } month1Combo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { c.getDateFrom().setMonth(month1Combo.getSelectionIndex()); } }); final YearSpinner year1Spinner = new YearSpinner(_searchPDateComp, SWT.NULL); if (c.getDateFrom() != null) { year1Spinner.setSelection(c.getDateFrom().getYear()); } else { year1Spinner.setSelection(_preselection); c.getDateFrom().setYear(_preselection); } year1Spinner.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(final SelectionEvent e) { c.getDateFrom().setYear(year1Spinner.getSelection()); } @Override public void widgetSelected(final SelectionEvent e) { c.getDateFrom().setYear(year1Spinner.getSelection()); } }); Label to = new Label(_searchPDateComp, SWT.NONE); to.setText(NLMessages.getString("Dialog_to")); //$NON-NLS-1$ to.setLayoutData(new GridData()); ((GridData) to.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) to.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) to.getLayoutData()).horizontalSpan = 1; final Combo day2Combo = new Combo(_searchPDateComp, SWT.READ_ONLY); day2Combo.setLayoutData(new GridData()); day2Combo.setItems(AEConstants.DAYS); day2Combo.setLayoutData(new GridData()); ((GridData) day2Combo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) day2Combo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) day2Combo.getLayoutData()).horizontalSpan = 1; if (c.getDateTo() == null) { PdrDate dateTo = new PdrDate("0000-00-00"); //$NON-NLS-1$ c.setDateTo(dateTo); day2Combo.select(c.getDateTo().getDay()); } day2Combo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { c.getDateTo().setDay(day2Combo.getSelectionIndex()); } }); final Combo month2Combo = new Combo(_searchPDateComp, SWT.READ_ONLY); month2Combo.setLayoutData(new GridData()); month2Combo.setItems(AEConstants.MONTHS); month2Combo.setLayoutData(new GridData()); ((GridData) month2Combo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) month2Combo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) month2Combo.getLayoutData()).horizontalSpan = 1; if (c.getDateTo() != null) { month2Combo.select(c.getDateTo().getMonth()); } else { month2Combo.select(0); c.getDateTo().setMonth(0); } month2Combo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { c.getDateTo().setMonth(month2Combo.getSelectionIndex()); } }); final YearSpinner year2Spinner = new YearSpinner(_searchPDateComp, SWT.NULL); if (c.getDateTo() != null) { year2Spinner.setSelection(c.getDateTo().getYear()); } else { year2Spinner.setSelection(_preselection); c.getDateTo().setYear(_preselection); } year2Spinner.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(final SelectionEvent e) { c.getDateTo().setYear(year2Spinner.getSelection()); } @Override public void widgetSelected(final SelectionEvent e) { c.getDateTo().setYear(year2Spinner.getSelection()); } }); final Button includeB = new Button(_searchPDateComp, SWT.CHECK); includeB.setLayoutData(new GridData()); includeB.setSelection(c.isIncludeConcurrences()); includeB.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { c.setIncludeConcurrences(!c.isIncludeConcurrences()); } }); } // if date if (c.getType().equals("reference")) //$NON-NLS-1$ { _searchPRefComp = new Composite(_personSearchGroup, SWT.NONE); _searchPRefComp.setLayout(new GridLayout()); ((GridLayout) _searchPRefComp.getLayout()).makeColumnsEqualWidth = true; ((GridLayout) _searchPRefComp.getLayout()).numColumns = 14; _searchPRefComp.setLayoutData(new GridData()); ((GridData) _searchPRefComp.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) _searchPRefComp.getLayoutData()).grabExcessHorizontalSpace = true; // ((GridData) searchPTagComp.getLayoutData()).heightHint = 200; ((GridData) _searchPRefComp.getLayoutData()).grabExcessVerticalSpace = false; ((GridData) _searchPRefComp.getLayoutData()).horizontalSpan = 1; final Combo opCombo = new Combo(_searchPRefComp, SWT.READ_ONLY); opCombo.setLayoutData(new GridData()); opCombo.add(Operator.AND.toString()); opCombo.add(Operator.OR.toString()); opCombo.add(Operator.NOT.toString()); opCombo.setLayoutData(new GridData()); ((GridData) opCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) opCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) opCombo.getLayoutData()).horizontalSpan = 1; if (c.getOperator() != null) { opCombo.setText(c.getOperator()); } else { opCombo.select(0); c.setOperator(opCombo.getItem(0)); } opCombo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { c.setOperator(opCombo.getItem(opCombo.getSelectionIndex())); } }); Label sem = new Label(_searchPRefComp, SWT.NONE); sem.setText(NLMessages.getString("Dialog_reference")); //$NON-NLS-1$ sem.setLayoutData(new GridData()); ((GridData) sem.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) sem.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) sem.getLayoutData()).horizontalSpan = 2; Label tagName = new Label(_searchPRefComp, SWT.NONE); tagName.setText(NLMessages.getString("Dialog_genre")); //$NON-NLS-1$ tagName.setLayoutData(new GridData()); ((GridData) tagName.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) tagName.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) tagName.getLayoutData()).horizontalSpan = 2; final Combo genreCombo = new Combo(_searchPRefComp, SWT.READ_ONLY); genreCombo.setLayoutData(new GridData()); ComboViewer genreComboViewer = new ComboViewer(genreCombo); genreComboViewer.setContentProvider(new RefTemplateContentProvider(false)); genreComboViewer.setLabelProvider(new LabelProvider() { @Override public String getText(final Object element) { ReferenceModsTemplate template = (ReferenceModsTemplate) element; return template.getLabel(); } }); genreComboViewer.setInput(_facade.getAllGenres()); genreComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection selection = event.getSelection(); Object obj = ((IStructuredSelection) selection).getFirstElement(); ReferenceModsTemplate template = (ReferenceModsTemplate) obj; if (template != null) { c.setCrit0(template.getValue()); } } }); genreCombo.add("ALL", 0); //$NON-NLS-1$ genreCombo.setLayoutData(new GridData()); ((GridData) genreCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) genreCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) genreCombo.getLayoutData()).horizontalSpan = 2; if (c.getCrit0() != null) { StructuredSelection selection = new StructuredSelection(c.getCrit0()); genreComboViewer.setSelection(selection); } else { genreCombo.select(0); c.setCrit0(genreCombo.getItem(0)); } Label tagType = new Label(_searchPRefComp, SWT.NONE); tagType.setText(NLMessages.getString("Dialog_searchText")); //$NON-NLS-1$ tagType.setLayoutData(new GridData()); ((GridData) tagType.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) tagType.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) tagType.getLayoutData()).horizontalSpan = 2; final Text searchText = new Text(_searchPRefComp, SWT.BORDER); searchText.setLayoutData(new GridData()); searchText.setLayoutData(new GridData()); ((GridData) searchText.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) searchText.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) searchText.getLayoutData()).horizontalSpan = 3; if (c.getSearchText() != null) { searchText.setText(c.getSearchText()); } searchText.addFocusListener(new FocusAdapter() { @Override public void focusLost(final FocusEvent e) { c.setSearchText(searchText.getText()); } }); searchText.addKeyListener(new KeyListener() { @Override public void keyPressed(final KeyEvent e) { if (e.keyCode == SWT.CR) { c.setSearchText(searchText.getText()); okPressed(); } } @Override public void keyReleased(final KeyEvent e) { } }); final Button fuzzyB = new Button(_searchPRefComp, SWT.CHECK); fuzzyB.setLayoutData(new GridData()); fuzzyB.setSelection(c.isFuzzy()); fuzzyB.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { c.setFuzzy(!c.isFuzzy()); } }); final Button includeB = new Button(_searchPRefComp, SWT.CHECK); includeB.setLayoutData(new GridData()); includeB.setSelection(c.isIncludeConcurrences()); includeB.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { c.setIncludeConcurrences(!c.isIncludeConcurrences()); } }); } // if reference } // contentCompSearch.layout(); // scrollCompSearch.setContent(contentCompSearch); // scrollCompSearch.setMinSize(contentCompSearch.computeSize(SWT.DEFAULT, // SWT.DEFAULT, true)); // scrollCompSearch.layout(); _personSearchGroup.redraw(); _personSearchGroup.layout(); _personSearchGroup.pack(); _personSearchGroup.layout(); // personSearchGroup.pack(); }