List of usage examples for org.eclipse.jface.viewers ComboViewer setLabelProvider
@Override public void setLabelProvider(IBaseLabelProvider labelProvider)
Viewer
framework method ensures that the given label provider is an instance of ILabelProvider
. 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 . j a va 2 s . c o m */ @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.//w w w. j a va2 s . c o 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 w ww. java 2 s. c o 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./*from www. j ava2 s .c om*/ * @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(); }
From source file:org.bbaw.pdr.ae.view.main.dialogs.AdvancedSearchDialog.java
License:Open Source License
/** * Builds the reference search.//from ww w. jav a 2s.c o m * @param i the i * @param object the object */ private void buildReferenceSearch(final int i, final Object object) { final Criteria c = _referenceQuery.getCriterias().firstElement(); Composite searchRefComp = new Composite(_referenceSearchGroup, SWT.NONE); searchRefComp.setLayout(new GridLayout()); ((GridLayout) searchRefComp.getLayout()).makeColumnsEqualWidth = true; ((GridLayout) searchRefComp.getLayout()).numColumns = 10; searchRefComp.setLayoutData(new GridData()); ((GridData) searchRefComp.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) searchRefComp.getLayoutData()).grabExcessHorizontalSpace = true; // ((GridData) searchRefComp.getLayoutData()).heightHint = 200; ((GridData) searchRefComp.getLayoutData()).grabExcessVerticalSpace = false; ((GridData) searchRefComp.getLayoutData()).horizontalSpan = 1; Button chooseFacetsButton = new Button(searchRefComp, 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(_referenceQuery.getType() == 5); chooseFacetsButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { if (_referenceQuery.getType() == 5) { _referenceQuery.setType(2); } else { _referenceQuery.setType(5); } } }); Label refFacet = new Label(searchRefComp, SWT.NONE); refFacet.setText(NLMessages.getString("Dialog_faceted_by")); refFacet.setLayoutData(new GridData()); ((GridData) refFacet.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) refFacet.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) refFacet.getLayoutData()).horizontalSpan = 2; final Combo facetTypeCombo = new Combo(searchRefComp, SWT.READ_ONLY); facetTypeCombo.setLayoutData(new GridData()); facetTypeCombo.setLayoutData(new GridData()); ((GridData) facetTypeCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) facetTypeCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) facetTypeCombo.getLayoutData()).horizontalSpan = 2; ComboViewer facetTypeComboViewer = new ComboViewer(facetTypeCombo); facetTypeComboViewer.setContentProvider(ArrayContentProvider.getInstance()); facetTypeComboViewer.setLabelProvider(new LabelProvider() { @Override public String getText(final Object element) { String str = (String) element; return NLMessages.getString("Editor_" + str); //$NON-NLS-1$ } }); String[] refFacets = new String[] { "title", "subtitle", "partName", "name", "genre", "dateCreated", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ "dateIssued", "dateCaptured", "copyrightDate", "publisher", "place", "edition", "physicalLocation", //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$//$NON-NLS-5$//$NON-NLS-6$//$NON-NLS-7$ "shelfLocator" }; //$NON-NLS-1$ facetTypeComboViewer.setInput(refFacets); final Combo refFacetsCombo = new Combo(searchRefComp, SWT.READ_ONLY); refFacetsCombo.setLayoutData(new GridData()); final ComboViewer refFacetsComboViewer = new ComboViewer(refFacetsCombo); refFacetsComboViewer.setContentProvider(ArrayContentProvider.getInstance()); refFacetsComboViewer.setLabelProvider(new LabelProvider() { @Override public String getText(final Object element) { String str = (String) element; return str; } }); facetTypeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection selection = event.getSelection(); Object obj = ((IStructuredSelection) selection).getFirstElement(); String s = (String) obj; String type = null; if (s.equals("name")) //$NON-NLS-1$ { s = "namePart"; //$NON-NLS-1$ type = "family"; //$NON-NLS-1$ } try { _referenceFacets = _mainSearcher.getFacets("reference", s, type, null, null); //$NON-NLS-1$ } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } if (s.equals("genre")) //$NON-NLS-1$ { _referenceQuery.setKey("genre"); //$NON-NLS-1$ String[] genreLabel = new String[_referenceFacets.length]; for (int i = 0; i < _referenceFacets.length; i++) { ReferenceModsTemplate temp = _facade.getReferenceModsTemplates().get(_referenceFacets[i]); if (temp != null) { genreLabel[i] = temp.getLabel(); } else { genreLabel[i] = _referenceFacets[i]; } } refFacetsComboViewer.setInput(genreLabel); } else { _referenceQuery.setKey(null); refFacetsComboViewer.setInput(_referenceFacets); } setQueryFacets(_referenceQuery, _referenceFacets); } }); // refFacetsComboViewer.setInput(facade.getReferenceModsTemplates()); // refFacetsComboViewer.addSelectionChangedListener(new // ISelectionChangedListener() { // // public void selectionChanged(SelectionChangedEvent event) { // ISelection selection = event.getSelection(); // Object obj = ((IStructuredSelection) selection).getFirstElement(); // ReferenceModsTemplate template = (ReferenceModsTemplate) obj; // // } // // }); refFacetsCombo.setLayoutData(new GridData()); ((GridData) refFacetsCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) refFacetsCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) refFacetsCombo.getLayoutData()).horizontalSpan = 4; Label op = new Label(searchRefComp, SWT.NONE); op.setText(NLMessages.getString("Dialog_genre")); //$NON-NLS-1$ op.setLayoutData(new GridData()); ((GridData) op.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) op.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) op.getLayoutData()).horizontalSpan = 2; Label tagName = new Label(searchRefComp, SWT.NONE); tagName.setText(NLMessages.getString("Dialog_role")); //$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(searchRefComp, SWT.NONE); tagType.setText(NLMessages.getString("Dialog_name")); //$NON-NLS-1$ tagType.setLayoutData(new GridData()); ((GridData) tagType.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) tagType.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) tagType.getLayoutData()).horizontalSpan = 5; Label fuzzy = new Label(searchRefComp, 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; final Combo genreCombo = new Combo(searchRefComp, 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)); } final Combo roleCombo = new Combo(searchRefComp, SWT.READ_ONLY); roleCombo.setLayoutData(new GridData()); roleCombo.setLayoutData(new GridData()); ((GridData) roleCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) roleCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) roleCombo.getLayoutData()).horizontalSpan = 2; ComboViewer comboViewer = new ComboViewer(roleCombo); comboViewer.setContentProvider(ArrayContentProvider.getInstance()); comboViewer.setLabelProvider(new LabelProvider() { @Override public String getText(final Object element) { String str = (String) element; if (str.equals("ALL")) { return str; //$NON-NLS-1$ } return NLMessages.getString("Editor_role_" + str); //$NON-NLS-1$ } }); String[] input = new String[AEConstants.REF_ROLETERM_CODE.length + 1]; System.arraycopy(new String[] { "ALL" }, 0, input, 0, 1); //$NON-NLS-1$ System.arraycopy(AEConstants.REF_ROLETERM_CODE, 0, input, 1, AEConstants.REF_ROLETERM_CODE.length); comboViewer.setInput(input); comboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection selection = event.getSelection(); Object obj = ((IStructuredSelection) selection).getFirstElement(); String s = (String) obj; c.setCrit1(s); } }); // roleCombo.add("ALL", 0); //$NON-NLS-1$ // if (c.getCrit1() != null) // { // roleCombo.setText(c.getCrit1()); // } // else // { // roleCombo.select(0); // c.setCrit1(roleCombo.getItem(0)); // // // } // roleCombo.addSelectionListener(new SelectionAdapter(){ // public void widgetSelected(SelectionEvent se) // { // // if (!(semCombo.getSelectionIndex() > semCombo.getItems().length)) // // { // c.setCrit1(roleCombo.getItem(roleCombo.getSelectionIndex())); // // } // } // }); final Text nameText = new Text(searchRefComp, SWT.BORDER); nameText.setLayoutData(new GridData()); nameText.setLayoutData(new GridData()); ((GridData) nameText.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) nameText.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) nameText.getLayoutData()).horizontalSpan = 5; if (c.getCrit3() != null) { nameText.setText(c.getCrit3()); } nameText.addFocusListener(new FocusListener() { @Override public void focusGained(final FocusEvent e) { String[] vals = new String[] {}; try { vals = _mainSearcher.getFacets("reference", "namePart", null, null, null); //$NON-NLS-1$ //$NON-NLS-2$ } catch (Exception e1) { e1.printStackTrace(); } new AutoCompleteField(nameText, new TextContentAdapter(), vals); } @Override public void focusLost(final FocusEvent e) { c.setCrit3(nameText.getText()); } }); nameText.addKeyListener(new KeyListener() { @Override public void keyPressed(final KeyEvent e) { if (e.keyCode == SWT.CR) { c.setCrit3(nameText.getText()); okPressed(); } } @Override public void keyReleased(final KeyEvent e) { } }); final Button fuzzyB = new Button(searchRefComp, 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()); } }); Label title = new Label(searchRefComp, SWT.NONE); title.setText(NLMessages.getString("Dialog_refTitle")); //$NON-NLS-1$ title.setLayoutData(new GridData()); ((GridData) title.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) title.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) title.getLayoutData()).horizontalSpan = 2; final Text searchText2 = new Text(searchRefComp, SWT.BORDER); searchText2.setLayoutData(new GridData()); searchText2.setLayoutData(new GridData()); ((GridData) searchText2.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) searchText2.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) searchText2.getLayoutData()).horizontalSpan = 8; if (c.getCrit4() != null) { searchText2.setText(c.getCrit4()); } searchText2.addFocusListener(new FocusListener() { @Override public void focusGained(final FocusEvent e) { String[] vals = new String[] {}; try { vals = _mainSearcher.getFacets("reference", "title", null, null, null); //$NON-NLS-1$ //$NON-NLS-2$ } catch (Exception e1) { e1.printStackTrace(); } new AutoCompleteField(searchText2, new TextContentAdapter(), vals); } @Override public void focusLost(final FocusEvent e) { c.setCrit4(searchText2.getText()); } }); searchText2.addKeyListener(new KeyListener() { @Override public void keyPressed(final KeyEvent e) { if (e.keyCode == SWT.CR) { c.setCrit4(searchText2.getText()); okPressed(); } } @Override public void keyReleased(final KeyEvent e) { } }); Label searchText = new Label(searchRefComp, SWT.NONE); searchText.setText(NLMessages.getString("Dialog_freeSearch")); //$NON-NLS-1$ searchText.setLayoutData(new GridData()); ((GridData) searchText.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) searchText.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) searchText.getLayoutData()).horizontalSpan = 2; final Text searchText3 = new Text(searchRefComp, SWT.BORDER); searchText3.setLayoutData(new GridData()); searchText3.setLayoutData(new GridData()); ((GridData) searchText3.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) searchText3.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) searchText3.getLayoutData()).horizontalSpan = 8; if (c.getSearchText() != null) { searchText3.setText(c.getSearchText()); } searchText3.addFocusListener(new FocusAdapter() { @Override public void focusLost(final FocusEvent e) { c.setSearchText(searchText3.getText()); } }); searchText3.addKeyListener(new KeyListener() { @Override public void keyPressed(final KeyEvent e) { if (e.keyCode == SWT.CR) { c.setSearchText(searchText3.getText()); okPressed(); } } @Override public void keyReleased(final KeyEvent e) { } }); }
From source file:org.bbaw.pdr.ae.view.main.dialogs.ExpertSearchDialog.java
License:Open Source License
/** * Builds the person search./* w w w .j av a 2s. c o m*/ * @param type the type * @param crit the crit */ private void buildPersonSearch(final int type, final Integer crit) { DataType dtAll = new DataType(); dtAll.setValue("ALL"); //$NON-NLS-1$ dtAll.setLabel("ALL"); //$NON-NLS-1$ if (_scrollCompSearch != null) { _scrollCompSearch.dispose(); } if (_searchPTagComp != null) { _searchPTagComp.dispose(); } // if (placeGroup != null) placeGroup.dispose(); _scrollCompSearch = new ScrolledComposite(_personSearchGroup, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); _scrollCompSearch.setExpandHorizontal(true); _scrollCompSearch.setExpandVertical(true); _scrollCompSearch.setMinHeight(1); _scrollCompSearch.setMinWidth(1); _scrollCompSearch.setLayout(new GridLayout()); _scrollCompSearch.setLayoutData(new GridData()); ((GridData) _scrollCompSearch.getLayoutData()).heightHint = 400; ((GridData) _scrollCompSearch.getLayoutData()).horizontalSpan = 4; ((GridData) _scrollCompSearch.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) _scrollCompSearch.getLayoutData()).grabExcessHorizontalSpace = true; _scrollCompSearch.pack(); Composite contentCompSearch = new Composite(_scrollCompSearch, SWT.NONE); contentCompSearch.setLayout(new GridLayout()); _scrollCompSearch.setContent(contentCompSearch); boolean tag1 = true; boolean rel1 = true; boolean date1 = true; switch (type) { case 0: // pdrQuery = new PdrQuery(); // criteria = new Criteria(); // pdrQuery.getCriterias().add(criteria); break; // normales laden case 1: // neues criteria einfgen _criteria = new Criteria(); _pdrQuery.getCriterias().add(_criteria); _criteria.setType("tagging"); //$NON-NLS-1$ // System.out.println("in case 1"); //$NON-NLS-1$ // System.out.println("anzahl crit " + pdrQuery.getCriterias().size()); //$NON-NLS-1$ break; case 2: // criteria lschen _pdrQuery.getCriterias().removeElementAt(crit); break; case 3: // neue relation einfgen _criteria = new Criteria(); _pdrQuery.getCriterias().add(_criteria); _criteria.setType("relation"); //$NON-NLS-1$ break; case 4: // relation lschen _pdrQuery.getCriterias().removeElementAt(crit); break; case 5: // date criteria einfgen _criteria = new Criteria(); _pdrQuery.getCriterias().add(_criteria); _criteria.setType("date"); //$NON-NLS-1$ break; case 6: _pdrQuery.getCriterias().removeElementAt(crit); break; case 7: // reference criteria einfgen _criteria = new Criteria(); _pdrQuery.getCriterias().add(_criteria); _criteria.setType("reference"); //$NON-NLS-1$ break; case 8: _pdrQuery.getCriterias().removeElementAt(crit); break; default: break; } Collections.sort(_pdrQuery.getCriterias()); // load last search. if (_facade.getLastExpertSearch() != null) { _pdrQuery = _facade.getLastExpertSearch(); } for (int i = 0; i < _pdrQuery.getCriterias().size(); i++) { // System.out.println("for i = " + i); //$NON-NLS-1$ final Criteria c = _pdrQuery.getCriterias().get(i); if (c.getType().equals("tagging")) //$NON-NLS-1$ { if (tag1) { tag1 = false; _searchPTagComp = new Composite(contentCompSearch, SWT.NONE); _searchPTagComp.setLayout(new GridLayout()); ((GridLayout) _searchPTagComp.getLayout()).makeColumnsEqualWidth = true; ((GridLayout) _searchPTagComp.getLayout()).numColumns = 21; _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 = 2; 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_tagging")); //$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 tagRole = new Label(_searchPTagComp, SWT.NONE); tagRole.setText(NLMessages.getString("Dialog_role")); //$NON-NLS-1$ tagRole.setLayoutData(new GridData()); ((GridData) tagRole.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) tagRole.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) tagRole.getLayoutData()).horizontalSpan = 2; Label tagKey = new Label(_searchPTagComp, SWT.NONE); tagKey.setText(NLMessages.getString("Dialog_key")); //$NON-NLS-1$ tagKey.setLayoutData(new GridData()); ((GridData) tagKey.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) tagKey.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) tagKey.getLayoutData()).horizontalSpan = 3; 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; Label del = new Label(_searchPTagComp, SWT.NONE); del.setText(NLMessages.getString("Dialog_del")); //$NON-NLS-1$ del.setLayoutData(new GridData()); ((GridData) del.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) del.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) del.getLayoutData()).horizontalSpan = 1; } if (i == 0) { Label l = new Label(_searchPTagComp, 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(_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()); 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()); 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()); } final Combo roleCombo = new Combo(_searchPTagComp, SWT.READ_ONLY); final ComboViewer roleComboViewer = new ComboViewer(roleCombo); roleComboViewer.setContentProvider(new MarkupContentProvider()); roleComboViewer.setLabelProvider(new MarkupLabelProvider()); roleComboViewer.setComparator(new ConfigDataComparator()); 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()); } setComboViewerInput(roleComboViewer, "tagging_values", c.getCrit1(), c.getCrit2(), //$NON-NLS-1$ c.getCrit3()); } }); roleCombo.setLayoutData(new GridData()); roleCombo.setLayoutData(new GridData()); ((GridData) roleCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) roleCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) roleCombo.getLayoutData()).horizontalSpan = 2; if (c.getCrit4() != null) { setComboViewerByString(roleComboViewer, c.getCrit4()); } roleComboViewer.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.setCrit4(cd.getValue()); } } }); final Text keyText = new Text(_searchPTagComp, SWT.BORDER); keyText.setLayoutData(new GridData()); keyText.setLayoutData(new GridData()); ((GridData) keyText.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) keyText.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) keyText.getLayoutData()).horizontalSpan = 2; if (c.getCrit5() != null) { keyText.setText(c.getCrit5()); } keyText.setEnabled(false); final Button keySet = new Button(_searchPTagComp, SWT.PUSH); keySet.setEnabled(false); keySet.setText(NLMessages.getString("Dialog_set_key")); //$NON-NLS-1$ keySet.setFont(JFaceResources.getDialogFont()); keySet.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { } }); 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()); } }); 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()); } }); final Button delTagCriteria = new Button(_searchPTagComp, SWT.PUSH); delTagCriteria.setLayoutData(new GridData()); delTagCriteria.setText("-"); //$NON-NLS-1$ delTagCriteria.setData("tag", i); //$NON-NLS-1$ delTagCriteria.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { buildPersonSearch(2, ((Integer) delTagCriteria.getData("tag"))); //$NON-NLS-1$ } }); } // if tagging if (c.getType().equals("relation")) //$NON-NLS-1$ { if (rel1) { rel1 = false; _searchPRelComp = new Composite(contentCompSearch, 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")); //$NON-NLS-1$ 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")); //$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 = 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 (XQException 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 (XQException 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()); 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()); } }); 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(contentCompSearch, SWT.NONE); _searchPDateComp.setLayout(new GridLayout()); ((GridLayout) _searchPDateComp.getLayout()).makeColumnsEqualWidth = true; ((GridLayout) _searchPDateComp.getLayout()).numColumns = 21; _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; if (i != 0) { Label l2 = new Label(_searchPDateComp, SWT.NONE); l2.setLayoutData(new GridData()); l2.setLayoutData(new GridData()); ((GridData) l2.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) l2.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) l2.getLayoutData()).horizontalSpan = 2; } else { Label op = new Label(_searchPDateComp, 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 = 2; } 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 = 3; Label bl = new Label(_searchPDateComp, SWT.NONE); bl.setText(""); //$NON-NLS-1$ bl.setLayoutData(new GridData()); ((GridData) bl.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) bl.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) bl.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 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 = 3; Label bl2 = new Label(_searchPDateComp, SWT.NONE); bl2.setText(""); //$NON-NLS-1$ bl2.setLayoutData(new GridData()); ((GridData) bl2.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) bl2.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) bl2.getLayoutData()).horizontalSpan = 2; 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 = 3; if (i != 0) { Label l2 = new Label(_searchPDateComp, SWT.NONE); l2.setLayoutData(new GridData()); l2.setLayoutData(new GridData()); ((GridData) l2.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) l2.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) l2.getLayoutData()).horizontalSpan = 2; } else { Label include = new Label(_searchPDateComp, 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; Label del = new Label(_searchPDateComp, SWT.NONE); del.setText(NLMessages.getString("Dialog_del")); //$NON-NLS-1$ del.setLayoutData(new GridData()); ((GridData) del.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) del.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) del.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) //$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 = 2; 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 = 2; 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()); } }); final Button delTagCriteria = new Button(_searchPDateComp, SWT.PUSH); delTagCriteria.setLayoutData(new GridData()); delTagCriteria.setText("-"); //$NON-NLS-1$ delTagCriteria.setData("tag", i); //$NON-NLS-1$ delTagCriteria.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { buildPersonSearch(2, ((Integer) delTagCriteria.getData("tag"))); //$NON-NLS-1$ } }); } // if date if (c.getType().equals("reference")) //$NON-NLS-1$ { _searchPRefComp = new Composite(contentCompSearch, SWT.NONE); _searchPRefComp.setLayout(new GridLayout()); ((GridLayout) _searchPRefComp.getLayout()).makeColumnsEqualWidth = true; ((GridLayout) _searchPRefComp.getLayout()).numColumns = 15; _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 = 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())); } }); 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()); } }); 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(); }
From source file:org.bbaw.pdr.ae.view.main.editors.AspectEditorDialog.java
License:Open Source License
/** * Load classification.//from w w w.j a v a2 s. c o m * @param type the type * @param cla the cla */ private void loadClassification(final int type, final Integer cla) { if (_scrollCompClass != null) { _scrollCompClass.dispose(); } _scrollCompClass = new ScrolledComposite(_classificationComposite, SWT.V_SCROLL); _scrollCompClass.setExpandHorizontal(true); _scrollCompClass.setExpandVertical(true); _scrollCompClass.setMinHeight(1); _scrollCompClass.setMinWidth(1); _scrollCompClass.setLayout(new GridLayout()); _scrollCompClass.setLayoutData(new GridData()); ((GridData) _scrollCompClass.getLayoutData()).heightHint = 100; ((GridData) _scrollCompClass.getLayoutData()).widthHint = 700; ((GridData) _scrollCompClass.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) _scrollCompClass.getLayoutData()).grabExcessHorizontalSpace = true; Composite contentCompClass = new Composite(_scrollCompClass, SWT.NONE); contentCompClass.setLayout(new GridLayout()); ((GridLayout) contentCompClass.getLayout()).numColumns = 4; ((GridLayout) contentCompClass.getLayout()).makeColumnsEqualWidth = false; ((GridLayout) contentCompClass.getLayout()).marginHeight = 0; ((GridLayout) contentCompClass.getLayout()).marginWidth = 0; _scrollCompClass.setContent(contentCompClass); switch (type) { case 0: break; // nix, normales laden case 1: // neue SemanticStm einfgen if (_currentAspect.getSemanticDim() == null) { _currentAspect.setSemanticDim(new SemanticDim()); _currentAspect.getSemanticDim().setSemanticStms(new Vector<SemanticStm>()); _currentAspect.getSemanticDim().getSemanticStms().add(new SemanticStm()); } else { _currentAspect.getSemanticDim().getSemanticStms().add(new SemanticStm()); } _currentAspect.getSemanticDim().getSemanticStms().lastElement() .setProvider(Platform .getPreferencesService().getString(CommonActivator.PLUGIN_ID, "PRIMARY_SEMANTIC_PROVIDER", AEConstants.CLASSIFICATION_AUTHORITY, null) .toUpperCase()); //$NON-NLS-1$ break; case 2: // SemanticStm lschen _currentAspect.getSemanticDim().remove(cla); break; default: break; } // contentCompClass = (Composite)scrollCompClass.getContent(); // Control[] children = contentCompClass.getChildren(); // for (Control c : children) // { // c.dispose(); // } if (_currentAspect.getSemanticDim() != null) { for (int i = 0; i < _currentAspect.getSemanticDim().getSemanticStms().size(); i++) { final SemanticStm semanticStm = _currentAspect.getSemanticDim().getSemanticStms().get(i); if (_facade.isPersonNameTag(semanticStm.getLabel())) { _addBelongsToButton.setEnabled(false); _addRelationsButton.setEnabled(false); while (_currentAspect.getRelationDim().getRelationStms().size() > 1) { _currentAspect.getRelationDim().getRelationStms() .remove(_currentAspect.getRelationDim().getRelationStms().lastElement()); } } else { setMessage(""); _addBelongsToButton.setEnabled(_mayWrite); _addRelationsButton.setEnabled(_mayWrite); } final Combo claProviderCombo = new Combo(contentCompClass, SWT.DROP_DOWN | SWT.READ_ONLY); claProviderCombo.setItems(PDRConfigProvider.readConfigs(_semanticProvider, "_semanticProvider", null, null, null, null)); claProviderCombo.setEnabled(_mayWrite); claProviderCombo.setLayoutData(new GridData()); ((GridData) claProviderCombo.getLayoutData()).minimumWidth = 100; // ((GridData) // claProviderCombo.getLayoutData()).horizontalAlignment = // SWT.LEFT; // claProviderCombo.pack(); claProviderCombo.setBackground(WHITE_COLOR); final Combo classifierCombo = new Combo(contentCompClass, SWT.DROP_DOWN | SWT.READ_ONLY); classifierCombo.setEnabled(_mayWrite); classifierCombo.setBackground(WHITE_COLOR); final ComboViewer comboSemanticViewer = new ComboViewer(classifierCombo); comboSemanticViewer.setContentProvider(new MarkupContentProvider()); comboSemanticViewer.setLabelProvider(new MarkupLabelProvider()); claProviderCombo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { semanticStm.setProvider(claProviderCombo.getItem(claProviderCombo.getSelectionIndex())); classifierCombo.removeAll(); if (semanticStm.getProvider() != null && semanticStm.getProvider().trim().length() > 0) { if (_facade.getConfigs().get(semanticStm.getProvider().toUpperCase()) != null && _facade.getConfigs().get(semanticStm.getProvider().toUpperCase()) .getChildren().get("aodl:semanticStm").getChildren() != null && !_facade.getConfigs().get(semanticStm.getProvider().toUpperCase()) .getChildren().get("aodl:semanticStm").getChildren().isEmpty()) { comboSemanticViewer.setInput(_facade.getConfigs().get(semanticStm.getProvider()) .getChildren().get("aodl:semanticStm").getChildren()); } } } }); // } if (semanticStm.getProvider() != null && semanticStm.getProvider().trim().length() > 0) { ViewHelper.setComboByString(claProviderCombo, semanticStm.getProvider().toUpperCase()); if (_facade.getConfigs().get(semanticStm.getProvider().toUpperCase()) != null && _facade.getConfigs().get(semanticStm.getProvider().toUpperCase()).getChildren() .get("aodl:semanticStm").getChildren() != null && !_facade.getConfigs().get(semanticStm.getProvider().toUpperCase()).getChildren() .get("aodl:semanticStm").getChildren().isEmpty()) { comboSemanticViewer .setInput(_facade.getConfigs().get(semanticStm.getProvider().toUpperCase()) .getChildren().get("aodl:semanticStm").getChildren()); } } classifierCombo.setLayoutData(new GridData()); ((GridData) classifierCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) classifierCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) classifierCombo.getLayoutData()).horizontalIndent = 6; final ControlDecoration decoClassC = new ControlDecoration(classifierCombo, SWT.LEFT | SWT.TOP); final ControlDecoration decoClassInfo = new ControlDecoration(classifierCombo, SWT.RIGHT | SWT.TOP); 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) { semanticStm.setLabel(cp.getValue()); decoClassInfo.setDescriptionText(PDRConfigProvider.readDocu(semanticStm.getProvider(), "semanticStm", semanticStm.getLabel(), null, null, null, null)); if (decoClassInfo.getDescriptionText() != null) { decoClassInfo.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage()); } else { decoClassInfo.setImage(null); } decoClassC.setImage(null); if (_facade.isPersonNameTag(semanticStm.getLabel())) { _addBelongsToButton.setEnabled(false); _addRelationsButton.setEnabled(false); setMessage(NLMessages.getString("Editor_semantic_norm_name_only_one_relation")); while (_currentAspect.getRelationDim().getRelationStms().size() > 1) { _currentAspect.getRelationDim().getRelationStms().remove( _currentAspect.getRelationDim().getRelationStms().lastElement()); } loadRelationDim(0, 0, 0); } else { setMessage(""); _addBelongsToButton.setEnabled(true); _addRelationsButton.setEnabled(true); } validate(); } } }); if (semanticStm.getLabel() != null) { ViewHelper.setComboViewerByString(comboSemanticViewer, semanticStm.getLabel(), true); decoClassInfo .setDescriptionText(PDRConfigProvider.readDocu(semanticStm.getProvider().toUpperCase(), "semanticStm", semanticStm.getLabel(), null, null, null, null)); if (decoClassInfo.getDescriptionText() != null) { decoClassInfo.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage()); } else { decoClassInfo.setImage(null); } // @SuppressWarnings("unchecked") // HashMap<String, ConfigData> inputs = (HashMap<String, // ConfigData>) comboSemanticViewer.getInput(); // if (inputs.containsKey(semanticStm.getLabel())) // { // // System.out.println("contains key s " + s); // for (String key : inputs.keySet()) // { // if (key.equals(semanticStm.getLabel())) // { // ConfigData cd = inputs.get(key); // // // StructuredSelection sel = new // // StructuredSelection(cd); // // comboSemanticViewer.setSelection(sel, true); // comboSemanticViewer.reveal(cd); // break; // } // } // } } else { decoClassC.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED).getImage()); } // classifierCombo.pack(); final Button delSemanticStm = new Button(contentCompClass, SWT.PUSH); delSemanticStm.setToolTipText(NLMessages.getString("Editor_remove_semStm_tip")); delSemanticStm.setImage(_imageReg.get(IconsInternal.CLASSIFICATION_REMOVE)); delSemanticStm.setLayoutData(new GridData()); ((GridData) delSemanticStm.getLayoutData()).horizontalAlignment = SWT.RIGHT; ((GridData) delSemanticStm.getLayoutData()).horizontalIndent = 6; delSemanticStm.setData("cla", i); //$NON-NLS-1$ delSemanticStm .setEnabled(_currentAspect.getSemanticDim().getSemanticStms().size() > 1 && _mayWrite); delSemanticStm.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { loadClassification(2, (Integer) delSemanticStm.getData("cla")); //$NON-NLS-1$ validate(); } }); // delSemanticStm.pack(); if (i == 0) { Button addFurtherClassifier = new Button(contentCompClass, SWT.PUSH); addFurtherClassifier.setToolTipText(NLMessages.getString("Editor_add_semStm_tip")); addFurtherClassifier.setImage(_imageReg.get(IconsInternal.CLASSIFICATION_ADD)); addFurtherClassifier.setEnabled(_mayWrite); addFurtherClassifier.setLayoutData(new GridData()); ((GridData) addFurtherClassifier.getLayoutData()).horizontalAlignment = SWT.LEFT; addFurtherClassifier.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { loadClassification(1, null); validate(); } }); // addFurtherClassifier.pack(); } else { Label blanc = new Label(contentCompClass, SWT.NONE); blanc.setText(""); } // ccCompo.redraw(); // ccCompo.layout(); // ccCompo.pack(); } } // classificationGroup.redraw(); // classificationGroup.layout(); // classificationGroup.pack(); contentCompClass.layout(); contentCompClass.layout(); _scrollCompClass.setContent(contentCompClass); Point point = contentCompClass.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); // System.out.println("contentComp Class height " + point.y); Point mp = _mainTabFolder.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); if (point.x > mp.x - 20) { point.x = mp.x - 20; } _scrollCompClass.setMinSize(point); _scrollCompClass.layout(); _classificationComposite.redraw(); _classificationComposite.layout(); // _classificationComposite.pack(); // _mainTabFolder.redraw(); _mainTabFolder.layout(); // _mainTabFolder.pack(); }
From source file:org.bbaw.pdr.ae.view.main.editors.AspectEditorDialog.java
License:Open Source License
/** * Load relation dim.//from w w w. j a v a2 s .co m * @param type the type * @param relStm the rel stm * @param rel the rel */ private void loadRelationDim(final int type, final Integer relStm, final Integer rel) { if (_scrollCompRel != null) { _scrollCompRel.dispose(); } if (_relGroup != null) { _relGroup.dispose(); } _scrollCompRel = new ScrolledComposite(_relationComposite, SWT.BORDER | SWT.V_SCROLL); _scrollCompRel.setExpandHorizontal(true); _scrollCompRel.setExpandVertical(true); _scrollCompRel.setMinHeight(1); _scrollCompRel.setMinWidth(1); if (_currentAspect.getPdrId().getId() % 2 == 0) { _e = true; } _scrollCompRel.setLayout(new GridLayout()); _scrollCompRel.setLayoutData(new GridData()); ((GridData) _scrollCompRel.getLayoutData()).heightHint = 490; ((GridData) _scrollCompRel.getLayoutData()).widthHint = 700; ((GridData) _scrollCompRel.getLayoutData()).horizontalSpan = 2; ((GridData) _scrollCompRel.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) _scrollCompRel.getLayoutData()).grabExcessHorizontalSpace = true; _scrollCompRel.layout(); Composite contentCompRel = new Composite(_scrollCompRel, SWT.NONE); contentCompRel.setLayout(new GridLayout()); _scrollCompRel.setContent(contentCompRel); switch (type) { case 0: break; // nix, normales laden case 1: // neues relationStm einfgen if (_currentAspect.getRelationDim() == null) { _currentAspect.setRelationDim(new RelationDim()); _currentAspect.getRelationDim().setRelationStms(new Vector<RelationStm>()); _currentAspect.getRelationDim().getRelationStms().add(new RelationStm()); } else { _currentAspect.getRelationDim().getRelationStms().add(new RelationStm()); } break; case 2: // relationStm lschen _currentAspect.getRelationDim().remove(relStm); break; case 3: // neue relation einfgen _currentAspect.getRelationDim().getRelationStms().get(relStm).getRelations().add(new Relation()); break; case 4: // relation lschen _currentAspect.getRelationDim().getRelationStms().get(relStm).getRelations().removeElementAt(rel); break; case 5: // belongsto statement einfgen if (_currentAspect.getRelationDim() == null) { _currentAspect.setRelationDim(new RelationDim()); _currentAspect.getRelationDim().setRelationStms(new Vector<RelationStm>()); } RelationStm rs = new RelationStm(); rs.setSubject(_currentAspect.getPdrId()); Relation r = new Relation(); r.setRelation("aspect_of"); //$NON-NLS-1$ r.setProvider("PDR"); //$NON-NLS-1$ rs.setRelations(new Vector<Relation>(1)); rs.getRelations().add(r); _currentAspect.getRelationDim().getRelationStms().add(rs); break; default: break; } for (int i = 0; i < _currentAspect.getRelationDim().getRelationStms().size(); i++) { int l = i + 1; final RelationStm relationStm = _currentAspect.getRelationDim().getRelationStms().get(i); _relGroup = new Group(contentCompRel, SWT.SHADOW_IN); _relGroup.setData("relStm", i); //$NON-NLS-1$ _relGroup.setLayout(new GridLayout()); ((GridLayout) _relGroup.getLayout()).numColumns = 8; ((GridLayout) _relGroup.getLayout()).makeColumnsEqualWidth = false; _relGroup.setLayoutData(new GridData()); ((GridData) _relGroup.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) _relGroup.getLayoutData()).grabExcessHorizontalSpace = true; _relGroup.setText(NLMessages.getString("Editor_relStm") + l); // check whether relationStm contains only a belongs-to statement. if (relationStm.getSubject() != null && relationStm.getSubject().equals(_currentAspect.getPdrId())) { final Relation relBel = relationStm.getRelations().firstElement(); Label belongsto = new Label(_relGroup, SWT.NONE); belongsto.setText(NLMessages.getString("Editor_aspect_of")); belongsto.setLayoutData(new GridData()); final Text belongstoObject = new Text(_relGroup, SWT.BORDER); belongstoObject.setData("relStm", i); //$NON-NLS-1$ belongstoObject.setEditable(_mayWrite); belongstoObject.setBackground(WHITE_COLOR); belongstoObject.setLayoutData(new GridData()); ((GridData) belongstoObject.getLayoutData()).horizontalSpan = 3; ((GridData) belongstoObject.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) belongstoObject.getLayoutData()).grabExcessHorizontalSpace = true; final ControlDecoration decoRelBelongsTo = new ControlDecoration(belongstoObject, SWT.LEFT | SWT.TOP); if (relBel.getObject() != null) { PdrObject o = _facade.getPdrObject(relBel.getObject()); decoRelBelongsTo.setImage(null); if (o != null) { belongstoObject.setText(o.getDisplayNameWithID()); } else { belongstoObject.setText(relBel.getObject().toString()); decoRelBelongsTo.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage()); decoRelBelongsTo .setDescriptionText(NLMessages.getString("Editor_missing_object_no_relation")); } } else { belongstoObject.setText(""); //$NON-NLS-1$ decoRelBelongsTo.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED).getImage()); } ControlDecoration decoBelObj = new ControlDecoration(belongstoObject, SWT.LEFT | SWT.BOTTOM); decoBelObj.setDescriptionText(NLMessages.getString("Editor_relation_proposal_deco")); decoBelObj.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage()); decoBelObj.setShowOnlyOnFocus(false); belongstoObject.addFocusListener(new FocusListener() { @Override public void focusGained(final FocusEvent e) { char[] autoActivationCharacters = new char[] { '.', '#' }; KeyStroke keyStrokeP; KeyStroke keyStrokeA; KeyStroke keyStrokeL; try { keyStrokeA = KeyStroke.getInstance("Ctrl+e"); keyStrokeP = KeyStroke.getInstance("Ctrl+p"); keyStrokeL = KeyStroke.getInstance("Ctrl+l"); ContentProposalAdapter adapter = new ContentProposalAdapter(belongstoObject, new TextContentAdapter(), new FacetContentProposalProvider(_facade.getAllPersonsFacets()), keyStrokeP, autoActivationCharacters); adapter.setLabelProvider(new AutoCompleteNameLabelProvider()); adapter.addContentProposalListener(new IContentProposalListener() { @Override public void proposalAccepted(final IContentProposal proposal) { belongstoObject.setText(proposal.getContent()); if (((Facet) proposal).getKey() != null) { relBel.setObject(new PdrId(((Facet) proposal).getKey())); decoRelBelongsTo.setImage(null); validate(); } } }); if (_facade.getLoadedAspectsFacets() != null) { ContentProposalAdapter adapter2 = new ContentProposalAdapter(belongstoObject, new TextContentAdapter(), new FacetContentProposalProvider(_facade.getLoadedAspectsFacets()), keyStrokeA, autoActivationCharacters); adapter2.setLabelProvider(new AutoCompleteNameLabelProvider()); adapter2.addContentProposalListener(new IContentProposalListener() { @Override public void proposalAccepted(final IContentProposal proposal) { belongstoObject.setText(proposal.getContent()); if (((Facet) proposal).getKey() != null) { relBel.setObject(new PdrId(((Facet) proposal).getKey())); decoRelBelongsTo.setImage(null); validate(); } } }); } if (_facade.getLastObjectsFacets() != null) { ContentProposalAdapter adapter3 = new ContentProposalAdapter(belongstoObject, new TextContentAdapter(), new FacetContentProposalProvider(_facade.getLastObjectsFacets()), keyStrokeL, autoActivationCharacters); adapter3.setLabelProvider(new AutoCompleteNameLabelProvider()); adapter3.addContentProposalListener(new IContentProposalListener() { @Override public void proposalAccepted(final IContentProposal proposal) { belongstoObject.setText(proposal.getContent()); if (((Facet) proposal).getKey() != null) { relBel.setObject(new PdrId(((Facet) proposal).getKey())); decoRelBelongsTo.setImage(null); validate(); } } }); } } catch (org.eclipse.jface.bindings.keys.ParseException e1) { e1.printStackTrace(); } } @Override public void focusLost(final FocusEvent e) { if (relBel.getObject() != null) { if (relBel.getObject().getType().equals("pdrAo") || _facade.getPdrObject(relBel.getObject()) != null) { decoRelBelongsTo.setDescriptionText(""); decoRelBelongsTo.setImage(null); } } else { relBel.setObject(null); decoRelBelongsTo.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage()); decoRelBelongsTo .setDescriptionText(NLMessages.getString("Editor_missing_object_no_relation")); } validate(); } }); belongstoObject.addKeyListener(new KeyListener() { @Override public void keyPressed(final KeyEvent e) { } @Override public void keyReleased(final KeyEvent e) { if (belongstoObject.getText().length() == 23) { PdrObject o = _facade.getPdrObject(new PdrId(belongstoObject.getText())); if (o != null) { decoRelBelongsTo.setImage(null); relBel.setObject(new PdrId(belongstoObject.getText())); belongstoObject.setText(o.getDisplayNameWithID()); } } else if (belongstoObject.getText().trim().length() == 0) { relBel.setObject(null); } validate(); } }); Button relateCPButton = new Button(_relGroup, SWT.PUSH); relateCPButton.setText(NLMessages.getString("Editor_currentPerson")); relateCPButton.setToolTipText(NLMessages.getString("Editor_relate_cp_aspect_of")); relateCPButton.setImage(_imageReg.get(IconsInternal.PERSON)); relateCPButton.setLayoutData(new GridData()); ((GridData) relateCPButton.getLayoutData()).horizontalAlignment = SWT.RIGHT; ((GridData) relateCPButton.getLayoutData()).grabExcessHorizontalSpace = false; relateCPButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { relBel.setObject(_currentPerson.getPdrId()); PdrObject o = _currentPerson; if (o != null) { belongstoObject.setText(o.getDisplayNameWithID()); } else { belongstoObject.setText(relBel.getObject().toString()); } if (relBel.isValid()) { decoRelBelongsTo.setImage(null); } else { decoRelBelongsTo.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage()); } validate(); } }); if (_currentPerson != null) { relateCPButton.setEnabled(_mayWrite); } else { relateCPButton.setEnabled(false); } Button belongstoObjectButton = new Button(_relGroup, SWT.PUSH); belongstoObjectButton.setText(NLMessages.getString("Editor_select_dots")); belongstoObjectButton.setToolTipText(NLMessages.getString("Editor_open_selObjDialog_aspectOf_tip")); belongstoObjectButton.setImage(_imageReg.get(IconsInternal.SEARCH)); belongstoObjectButton.setEnabled(_mayWrite); belongstoObjectButton.setLayoutData(new GridData()); ((GridData) belongstoObjectButton.getLayoutData()).horizontalAlignment = SWT.RIGHT; ((GridData) belongstoObjectButton.getLayoutData()).grabExcessHorizontalSpace = false; belongstoObjectButton.setToolTipText(NLMessages.getString("Editor_linkPersonOrAspectToolTip")); //$NON-NLS-1$ belongstoObjectButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { IWorkbench workbench = PlatformUI.getWorkbench(); Display display = workbench.getDisplay(); Shell shell = new Shell(display); SelectObjectDialog dialog = new SelectObjectDialog(shell, 1); dialog.open(); if (_facade.getRequestedId() != null) { relBel.setObject(_facade.getRequestedId()); PdrObject o = _facade.getPdrObject(relBel.getObject()); if (o != null) { belongstoObject.setText(o.getDisplayNameWithID()); } else { belongstoObject.setText(relBel.getObject().toString()); } if (relBel.isValid()) { decoRelBelongsTo.setImage(null); } } else { if (!relBel.isValid()) { decoRelBelongsTo.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage()); } } validate(); } }); // belongstoObjectButton.pack(); final Button delRelationStm = new Button(_relGroup, SWT.PUSH); delRelationStm.setImage(_imageReg.get(IconsInternal.BELONGING_REMOVE)); delRelationStm.setData("relStm", i); //$NON-NLS-1$ delRelationStm .setEnabled(_currentAspect.getRelationDim().getRelationStms().size() > 1 && _mayWrite); if (_e && (Integer) delRelationStm.getData("relStm") == 3) //$NON-NLS-1$ { delRelationStm.setToolTipText(_egg); } else { delRelationStm.setToolTipText("Delete"); //$NON-NLS-1$ } delRelationStm.setLayoutData(new GridData()); delRelationStm.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { loadRelationDim(2, (Integer) delRelationStm.getData("relStm"), null); //$NON-NLS-1$ validate(); } }); delRelationStm.setLayoutData(new GridData()); } else { Label relationSubjectLabel = new Label(_relGroup, SWT.NONE); relationSubjectLabel.setText(NLMessages.getString("Editor_subject")); relationSubjectLabel.setLayoutData(new GridData()); final Text relationSubject = new Text(_relGroup, SWT.BORDER); relationSubject.setEditable(_mayWrite); relationSubject.setBackground(WHITE_COLOR); relationSubject.setLayoutData(new GridData()); ((GridData) relationSubject.getLayoutData()).horizontalSpan = 5; ((GridData) relationSubject.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) relationSubject.getLayoutData()).grabExcessHorizontalSpace = true; final ControlDecoration decoRelSubject = new ControlDecoration(relationSubject, SWT.LEFT | SWT.TOP); if (relationStm.getSubject() != null) //$NON-NLS-1$ { PdrObject o = _facade.getPdrObject(relationStm.getSubject()); decoRelSubject.setImage(null); if (o != null) { relationSubject.setText(o.getDisplayNameWithID()); } else { relationSubject.setText(relationStm.getSubject().toString()); decoRelSubject.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage()); decoRelSubject .setDescriptionText(NLMessages.getString("Editor_missing_object_no_relation")); } } else { relationSubject.setText(""); //$NON-NLS-1$ decoRelSubject.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED).getImage()); } ControlDecoration decorelationSubject = new ControlDecoration(relationSubject, SWT.LEFT | SWT.BOTTOM); decorelationSubject.setDescriptionText(NLMessages.getString("Editor_relation_proposal_deco")); decorelationSubject.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage()); decorelationSubject.setShowOnlyOnFocus(false); relationSubject.addFocusListener(new FocusListener() { @Override public void focusGained(final FocusEvent e) { char[] autoActivationCharacters = new char[] { '.', '#' }; KeyStroke keyStrokeP; KeyStroke keyStrokeA; KeyStroke keyStrokeL; try { keyStrokeA = KeyStroke.getInstance("Ctrl+e"); keyStrokeP = KeyStroke.getInstance("Ctrl+p"); keyStrokeL = KeyStroke.getInstance("Ctrl+l"); ContentProposalAdapter adapter = new ContentProposalAdapter(relationSubject, new TextContentAdapter(), new FacetContentProposalProvider(_facade.getAllPersonsFacets()), keyStrokeP, autoActivationCharacters); adapter.setLabelProvider(new AutoCompleteNameLabelProvider()); adapter.addContentProposalListener(new IContentProposalListener() { @Override public void proposalAccepted(final IContentProposal proposal) { relationSubject.setText(proposal.getContent()); if (((Facet) proposal).getKey() != null) { relationStm.setSubject(new PdrId(((Facet) proposal).getKey())); decoRelSubject.setImage(null); validate(); } } }); ContentProposalAdapter adapter2 = new ContentProposalAdapter(relationSubject, new TextContentAdapter(), new FacetContentProposalProvider(_facade.getLoadedAspectsFacets()), keyStrokeA, autoActivationCharacters); adapter2.setLabelProvider(new AutoCompleteNameLabelProvider()); adapter2.addContentProposalListener(new IContentProposalListener() { @Override public void proposalAccepted(final IContentProposal proposal) { relationSubject.setText(proposal.getContent()); if (((Facet) proposal).getKey() != null) { relationStm.setSubject(new PdrId(((Facet) proposal).getKey())); decoRelSubject.setImage(null); validate(); } } }); if (_facade.getLastObjectsFacets() != null) { ContentProposalAdapter adapter3 = new ContentProposalAdapter(relationSubject, new TextContentAdapter(), new FacetContentProposalProvider(_facade.getLastObjectsFacets()), keyStrokeL, autoActivationCharacters); adapter3.setLabelProvider(new AutoCompleteNameLabelProvider()); adapter3.addContentProposalListener(new IContentProposalListener() { @Override public void proposalAccepted(final IContentProposal proposal) { relationSubject.setText(proposal.getContent()); if (((Facet) proposal).getKey() != null) { relationStm.setSubject(new PdrId(((Facet) proposal).getKey())); decoRelSubject.setImage(null); validate(); } } }); } } catch (org.eclipse.jface.bindings.keys.ParseException e1) { e1.printStackTrace(); } } @Override public void focusLost(final FocusEvent e) { if (relationStm.getSubject() == null) { if (relationSubject.getText() != null && _facade.getPdrObject(new PdrId(relationSubject.getText())) != null) { relationStm.setSubject(new PdrId(relationSubject.getText())); decoRelSubject.setDescriptionText(""); decoRelSubject.setImage(null); } else { relationStm.setSubject(null); decoRelSubject.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage()); decoRelSubject.setDescriptionText( NLMessages.getString("Editor_missing_object_no_relation")); } } else if (relationSubject.getText().trim().length() == 0) { relationStm.setSubject(null); decoRelSubject.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage()); } validate(); } }); relationSubject.addKeyListener(new KeyListener() { @Override public void keyPressed(final KeyEvent e) { } @Override public void keyReleased(final KeyEvent e) { if (relationSubject.getText().length() == 23) { PdrObject o = _facade.getPdrObject(relationStm.getSubject()); if (o != null) { decoRelSubject.setImage(null); relationStm.setSubject(new PdrId(relationSubject.getText())); relationSubject.setText(o.getDisplayNameWithID()); } } else if (relationSubject.getText().trim().length() == 0) { relationStm.setSubject(null); decoRelSubject.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage()); } // if (relationSubject.getText().length() == 23) // { // relationStm.setSubject(new // PdrId(relationSubject.getText())); // if (relationStm.getSubject().isValid()) // { // decoRelSubject.setImage(null); // PdrObject o = // _facade.getReference(relationStm.getSubject()); // if (o != null) // relationSubject.setText(o.getDisplayNameWithID()); // else // relationSubject.setText(relationStm.getSubject().toString()); // } // else // { // decoRelSubject.setImage(FieldDecorationRegistry // .getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED).getImage()); // } // } // else if (relationSubject.getText().length() == 0) // { // relationStm.setSubject(null); // decoRelSubject.setImage(FieldDecorationRegistry // .getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage()); // } validate(); } }); Button relateCPButton = new Button(_relGroup, SWT.PUSH); relateCPButton.setText(NLMessages.getString("Editor_currentPerson")); relateCPButton.setToolTipText(NLMessages.getString("Editor_relate_cp_subject_tip")); relateCPButton.setImage(_imageReg.get(IconsInternal.PERSON)); relateCPButton.setEnabled(_mayWrite); relateCPButton.setLayoutData(new GridData()); ((GridData) relateCPButton.getLayoutData()).horizontalAlignment = SWT.RIGHT; ((GridData) relateCPButton.getLayoutData()).grabExcessHorizontalSpace = false; relateCPButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { relationSubject.setText(_currentPerson.getPdrId().toString()); relationStm.setSubject(_currentPerson.getPdrId()); PdrObject o = _currentPerson; if (o != null) { relationSubject.setText(o.getDisplayNameWithID()); } else { relationSubject.setText(relationStm.getSubject().toString()); } if (relationStm.getSubject().isValid()) { decoRelSubject.setImage(null); } else { decoRelSubject.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage()); } validate(); } }); if (_currentPerson != null) { relateCPButton.setEnabled(_mayWrite); } else { relateCPButton.setEnabled(false); } Button relateSubjectButton = new Button(_relGroup, SWT.PUSH); relateSubjectButton.setText(NLMessages.getString("Editor_select_dots")); relateSubjectButton.setToolTipText(NLMessages.getString("Editor_open_selObjDialog_subject_tip")); relateSubjectButton.setImage(_imageReg.get(IconsInternal.SEARCH)); relateSubjectButton.setEnabled(_mayWrite); relateSubjectButton.setLayoutData(new GridData()); // ((GridData) // relateSubjectButton.getLayoutData()).horizontalAlignment = // SWT.RIGHT; ((GridData) relateSubjectButton.getLayoutData()).grabExcessHorizontalSpace = false; relateSubjectButton.setToolTipText(NLMessages.getString("Editor_linkPersonOrAspectToolTip")); //$NON-NLS-1$ relateSubjectButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { IWorkbench workbench = PlatformUI.getWorkbench(); Display display = workbench.getDisplay(); Shell shell = new Shell(display); SelectObjectDialog dialog = new SelectObjectDialog(shell, 1); dialog.open(); if (_facade.getRequestedId() != null) { relationStm.setSubject(_facade.getRequestedId()); PdrObject o = _facade.getPdrObject(relationStm.getSubject()); if (o != null) { relationSubject.setText(o.getDisplayNameWithID()); } else { relationSubject.setText(_facade.getRequestedId().toString()); } if (relationStm.getSubject().isValid()) { decoRelSubject.setImage(null); } } else { if (!relationStm.getSubject().isValid()) { decoRelSubject.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage()); } } validate(); } }); // relateSubjectButton.pack(); final Button delRelationStm = new Button(_relGroup, SWT.PUSH); delRelationStm.setText(NLMessages.getString("Editor_delete")); delRelationStm.setToolTipText(NLMessages.getString("Editor_remove_relStm_tip")); delRelationStm.setImage(_imageReg.get(IconsInternal.RELATION_REMOVE)); delRelationStm .setEnabled(_currentAspect.getRelationDim().getRelationStms().size() > 1 && _mayWrite); delRelationStm.setLayoutData(new GridData()); delRelationStm.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { loadRelationDim(2, (Integer) _relGroup.getData("relStm"), null); //$NON-NLS-1$ validate(); } }); delRelationStm.setLayoutData(new GridData()); final Button addRelation = new Button(_relGroup, SWT.PUSH); addRelation.setText(NLMessages.getString("Editor_addRelation")); addRelation.setToolTipText(NLMessages.getString("Editor_add_relObj_tip")); addRelation.setImage(_imageReg.get(IconsInternal.RELATION_ADD)); addRelation.setEnabled(_mayWrite); addRelation.setLayoutData(new GridData()); addRelation.setData("relStm", i); //$NON-NLS-1$ addRelation.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { loadRelationDim(3, (Integer) addRelation.getData("relStm"), null); //$NON-NLS-1$ validate(); } }); addRelation.setLayoutData(new GridData()); if (relationStm.getRelations() != null) //$NON-NLS-1$ { for (int j = 0; j < relationStm.getRelations().size(); j++) //$NON-NLS-1$ { final Composite relComposite = new Composite(_relGroup, SWT.NONE); relComposite.setLayoutData(new GridData()); ((GridData) relComposite.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) relComposite.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) relComposite.getLayoutData()).horizontalSpan = 8; relComposite.setLayout(new GridLayout()); ((GridLayout) relComposite.getLayout()).numColumns = 6; ((GridLayout) relComposite.getLayout()).makeColumnsEqualWidth = true; relComposite.setData("relStm", i); //$NON-NLS-1$ relComposite.setData("rel", j); //$NON-NLS-1$ final Relation relation = relationStm.getRelations().get(j); //$NON-NLS-1$ final Combo relationClassCombo; final Combo relationProviderCombo; final Combo relationContextCombo; Label relationObjectLabel = new Label(relComposite, SWT.NONE); relationObjectLabel.setText(NLMessages.getString("Editor_object")); relationObjectLabel.setLayoutData(new GridData()); final Text relationObject = new Text(relComposite, SWT.BORDER); relationObject.setEditable(_mayWrite); relationObject.setBackground(WHITE_COLOR); relationObject.setLayoutData(new GridData()); ((GridData) relationObject.getLayoutData()).horizontalSpan = 3; ((GridData) relationObject.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) relationObject.getLayoutData()).grabExcessHorizontalSpace = true; final ControlDecoration decoRelObj = new ControlDecoration(relationObject, SWT.LEFT | SWT.TOP); if (relation.getObject() != null) { PdrObject o = _facade.getPdrObject(relation.getObject()); decoRelObj.setImage(null); if (o != null) { relationObject.setText(o.getDisplayNameWithID()); } else { relationObject.setText(relation.getObject().toString()); decoRelObj.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage()); decoRelObj.setDescriptionText( NLMessages.getString("Editor_missing_object_no_relation")); } } else { relationObject.setText(""); //$NON-NLS-1$ decoRelObj.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED).getImage()); } ControlDecoration decorelationObj = new ControlDecoration(relationObject, SWT.LEFT | SWT.BOTTOM); decorelationObj.setDescriptionText(NLMessages.getString("Editor_relation_proposal_deco")); decorelationObj.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage()); decorelationObj.setShowOnlyOnFocus(false); relationObject.addFocusListener(new FocusListener() { @Override public void focusGained(final FocusEvent e) { char[] autoActivationCharacters = new char[] { '.', '#' }; KeyStroke keyStrokeP; KeyStroke keyStrokeA; KeyStroke keyStrokeL; try { keyStrokeA = KeyStroke.getInstance("Ctrl+e"); keyStrokeP = KeyStroke.getInstance("Ctrl+p"); keyStrokeL = KeyStroke.getInstance("Ctrl+l"); ContentProposalAdapter adapter = new ContentProposalAdapter(relationObject, new TextContentAdapter(), new FacetContentProposalProvider(_facade.getAllPersonsFacets()), keyStrokeP, autoActivationCharacters); adapter.setLabelProvider(new AutoCompleteNameLabelProvider()); adapter.addContentProposalListener(new IContentProposalListener() { @Override public void proposalAccepted(final IContentProposal proposal) { relationObject.setText(proposal.getContent()); if (((Facet) proposal).getKey() != null) { relation.setObject(new PdrId(((Facet) proposal).getKey())); decoRelObj.setImage(null); validate(); } } }); ContentProposalAdapter adapter2 = new ContentProposalAdapter(relationObject, new TextContentAdapter(), new FacetContentProposalProvider(_facade.getLoadedAspectsFacets()), keyStrokeA, autoActivationCharacters); adapter2.setLabelProvider(new AutoCompleteNameLabelProvider()); adapter2.addContentProposalListener(new IContentProposalListener() { @Override public void proposalAccepted(final IContentProposal proposal) { relationObject.setText(proposal.getContent()); if (((Facet) proposal).getKey() != null) { relation.setObject(new PdrId(((Facet) proposal).getKey())); decoRelObj.setImage(null); validate(); } } }); if (_facade.getLastObjectsFacets() != null) { ContentProposalAdapter adapter3 = new ContentProposalAdapter(relationObject, new TextContentAdapter(), new FacetContentProposalProvider(_facade.getLastObjectsFacets()), keyStrokeL, autoActivationCharacters); adapter3.setLabelProvider(new AutoCompleteNameLabelProvider()); adapter3.addContentProposalListener(new IContentProposalListener() { @Override public void proposalAccepted(final IContentProposal proposal) { relationObject.setText(proposal.getContent()); if (((Facet) proposal).getKey() != null) { relation.setObject(new PdrId(((Facet) proposal).getKey())); decoRelObj.setImage(null); validate(); } } }); } } catch (org.eclipse.jface.bindings.keys.ParseException e1) { e1.printStackTrace(); } } @Override public void focusLost(final FocusEvent e) { if (relation.getObject() == null) { if (relationObject.getText() != null && _facade.getPdrObject(new PdrId(relationObject.getText())) != null) { relation.setObject(new PdrId(relationObject.getText())); decoRelObj.setDescriptionText(""); decoRelObj.setImage(null); } else { relation.setObject(null); decoRelObj.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage()); decoRelObj.setDescriptionText( NLMessages.getString("Editor_missing_object_no_relation")); } } else if (relationObject.getText().trim().length() == 0) { relation.setObject(null); decoRelObj.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage()); } validate(); } }); relationObject.addKeyListener(new KeyListener() { @Override public void keyPressed(final KeyEvent e) { } @Override public void keyReleased(final KeyEvent e) { if (relationObject.getText().length() == 23) { PdrObject o = _facade.getPdrObject(new PdrId(relationObject.getText())); if (o != null) { decoRelObj.setImage(null); relation.setObject(new PdrId(relationObject.getText())); relationObject.setText(o.getDisplayNameWithID()); } } else if (relationObject.getText().trim().length() == 0) { relation.setObject(null); decoRelObj.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage()); } validate(); } }); Button relateCPObjButton = new Button(relComposite, SWT.PUSH); relateCPObjButton.setText(NLMessages.getString("Editor_currentPerson")); relateCPObjButton.setToolTipText(NLMessages.getString("Editor_relate_cp_object_tip")); relateCPObjButton.setImage(_imageReg.get(IconsInternal.PERSON)); relateCPObjButton.setEnabled(_mayWrite); relateCPObjButton.setLayoutData(new GridData()); relateCPObjButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { relationObject.setText(_currentPerson.getPdrId().toString()); relation.setObject(_currentPerson.getPdrId()); PdrObject o = _currentPerson; if (o != null) { relationObject.setText(o.getDisplayNameWithID()); } else { relationObject.setText(relation.getObject().toString()); } if (relation.isValid()) { decoRelObj.setImage(null); } else { decoRelObj.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage()); relationObject.setText(""); } validate(); } }); if (_currentPerson != null) { relateCPObjButton.setEnabled(_mayWrite); } else { relateCPObjButton.setEnabled(false); } Button relateObjectButton = new Button(relComposite, SWT.PUSH); relateObjectButton.setText(NLMessages.getString("Editor_select_dots")); relateObjectButton .setToolTipText(NLMessages.getString("Editor_open_selObjDialog_object_tip")); relateObjectButton.setImage(_imageReg.get(IconsInternal.SEARCH)); relateObjectButton.setEnabled(_mayWrite); relateObjectButton.setLayoutData(new GridData()); relateObjectButton.setToolTipText(NLMessages.getString("Editor_linkPersonOrAspectToolTip")); //$NON-NLS-1$ relateObjectButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { IWorkbench workbench = PlatformUI.getWorkbench(); Display display = workbench.getDisplay(); Shell shell = new Shell(display); SelectObjectDialog dialog = new SelectObjectDialog(shell, 1); dialog.open(); if (_facade.getRequestedId() != null) { relation.setObject(_facade.getRequestedId()); PdrObject o = _facade.getPdrObject(relation.getObject()); if (o != null) { relationObject.setText(o.getDisplayNameWithID()); } else { relationObject.setText(relation.getObject().toString()); } if (relation.isValid()) { decoRelObj.setImage(null); } } else { if (!relation.isValid()) { decoRelObj.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage()); relationObject.setText(""); } } validate(); } }); // relateObjectButton.pack(); Label relationClassificationLabel = new Label(relComposite, SWT.NONE); relationClassificationLabel.setText(NLMessages.getString("Editor_provider")); relationClassificationLabel.setLayoutData(new GridData()); ((GridData) relationClassificationLabel.getLayoutData()).horizontalSpan = 1; relationProviderCombo = new Combo(relComposite, SWT.READ_ONLY); relationProviderCombo.setEnabled(_mayWrite); relationProviderCombo.setBackground(WHITE_COLOR); relationProviderCombo.setLayoutData(new GridData()); ((GridData) relationProviderCombo.getLayoutData()).horizontalAlignment = GridData.FILL; ((GridData) relationProviderCombo.getLayoutData()).horizontalSpan = 1; ((GridData) relationProviderCombo.getLayoutData()).grabExcessHorizontalSpace = true; relationProviderCombo.setItems(PDRConfigProvider.readConfigs(_relationProvider, "relationProvider", null, null, null, null)); if (relation.getProvider() != null) { ViewHelper.setComboByString(relationProviderCombo, relation.getProvider()); } else { relationProviderCombo.select(relationProviderCombo.indexOf(_relationProvider)); relation.setProvider(_relationProvider); } Label relationContextLabel = new Label(relComposite, SWT.NONE); relationContextLabel.setText(NLMessages.getString("Editor_context")); relationContextLabel.setLayoutData(new GridData()); ((GridData) relationContextLabel.getLayoutData()).horizontalSpan = 1; relationContextCombo = new Combo(relComposite, SWT.READ_ONLY); relationContextCombo.setEnabled(_mayWrite); 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()); if (relation.getProvider() != null && _facade.getConfigs().get(relation.getProvider()) != null) { relationContextComboViewer.setInput(_facade.getConfigs().get(relation.getProvider()) .getChildren().get("aodl:relation").getChildren()); } final ControlDecoration relContextDeco = new ControlDecoration(relationContextCombo, SWT.RIGHT | SWT.TOP); Label relationTypeLabel = new Label(relComposite, SWT.NONE); relationTypeLabel.setText(NLMessages.getString("Editor_class")); relationTypeLabel.setLayoutData(new GridData()); ((GridData) relationTypeLabel.getLayoutData()).horizontalSpan = 1; relationClassCombo = new Combo(relComposite, SWT.READ_ONLY); relationClassCombo.setEnabled(_mayWrite); 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 b = new Label(relComposite, SWT.NONE); b.setText(""); b.setLayoutData(new GridData()); ((GridData) b.getLayoutData()).horizontalSpan = 2; Label relCitationLabel = new Label(relComposite, SWT.NONE); relCitationLabel.setText(NLMessages.getString("Config_value")); relCitationLabel.setLayoutData(new GridData()); final Combo relValue = new Combo(relComposite, SWT.BORDER | SWT.READ_ONLY); relValue.setEnabled(_mayWrite); relValue.setBackground(WHITE_COLOR); relValue.setLayoutData(new GridData()); ((GridData) relValue.getLayoutData()).horizontalAlignment = GridData.FILL; ((GridData) relValue.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) relValue.getLayoutData()).horizontalSpan = 4; final ComboViewer relValueComboViewer = new ComboViewer(relValue); relValueComboViewer.setContentProvider(new MarkupContentProvider()); relValueComboViewer.setLabelProvider(new MarkupLabelProvider()); final ControlDecoration relValueDeco = new ControlDecoration(relValue, SWT.RIGHT | SWT.TOP); relationProviderCombo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { relationClassCombo.removeAll(); relationContextCombo.removeAll(); relValue.removeAll(); relation.setProvider( relationProviderCombo.getItem(relationProviderCombo.getSelectionIndex())); relationContextComboViewer.setInput(_facade.getConfigs().get(relation.getProvider()) .getChildren().get("aodl:relation").getChildren()); } }); // relationProviderCombo.pack(); // relValue.pack(); // 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 (relation.getContext() != null) { ViewHelper.setComboViewerByString(relationContextComboViewer, relation.getContext(), true); } relationContextComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); ConfigData cd = (ConfigData) obj; relation.setContext(cd.getValue()); relationClassCombo.removeAll(); relValue.removeAll(); relContextDeco.setDescriptionText(PDRConfigProvider.readDocu(relation.getProvider(), "relation", "context", relation.getContext(), 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(relation.getProvider()) .getChildren().get("aodl:relation").getChildren().get(relation.getContext()) .getChildren()); } }); // relationContextCombo.pack(); // control for relationContextCombo if (relation.getRClass() != null) { if (relation.getContext() != null && _facade.getConfigs().get(relation.getProvider()) != null && _facade.getConfigs().get(relation.getProvider()).getChildren() .get("aodl:relation") != null && _facade.getConfigs().get(relation.getProvider()).getChildren() .get("aodl:relation").getChildren() .get(relation.getContext()) != null) { relationClassComboViewer.setInput(_facade.getConfigs().get(relation.getProvider()) .getChildren().get("aodl:relation").getChildren().get(relation.getContext()) .getChildren()); } ViewHelper.setComboViewerByString(relationClassComboViewer, relation.getRClass(), true); } 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; relation.setRClass(cd.getValue()); relValueComboViewer.setInput(_facade.getConfigs().get(relation.getProvider()) .getChildren().get("aodl:relation").getChildren().get(relation.getContext()) .getChildren().get(relation.getRClass()).getChildren()); relClassDeco.setDescriptionText( PDRConfigProvider.readDocu(relation.getProvider(), "relation", "class", relation.getContext(), relation.getRClass(), null, null)); if (relClassDeco.getDescriptionText() != null) { relClassDeco.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION) .getImage()); } else { relClassDeco.setImage(null); } } }); // relationClassCombo.pack(); if (relation.getRelation() != null) { if (relation.getRClass() != null && _facade.getConfigs().get(relation.getProvider()) != null && _facade.getConfigs().get(relation.getProvider()).getChildren() .get("aodl:relation") != null && _facade.getConfigs().get(relation.getProvider()).getChildren() .get("aodl:relation").getChildren().get(relation.getContext()) != null && _facade.getConfigs().get(relation.getProvider()).getChildren() .get("aodl:relation").getChildren().get(relation.getContext()) .getChildren().get(relation.getRClass()) != null) { relValueComboViewer.setInput(_facade.getConfigs().get(relation.getProvider()) .getChildren().get("aodl:relation").getChildren().get(relation.getContext()) .getChildren().get(relation.getRClass()).getChildren()); } ViewHelper.setComboViewerByString(relValueComboViewer, relation.getRelation(), true); } 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; relation.setRelation(cd.getValue()); relValueDeco.setDescriptionText(PDRConfigProvider.readDocu(relation.getProvider(), "relation", "value", relation.getContext(), relation.getRClass(), relation.getRelation(), null)); if (relValueDeco.getDescriptionText() != null) { relValueDeco.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION) .getImage()); } else { relValueDeco.setImage(null); } } }); final Button delRelation = new Button(relComposite, SWT.PUSH); delRelation.setText(NLMessages.getString("Editor_deleteRel")); delRelation.setToolTipText(NLMessages.getString("Editor_remove_relation_tip")); delRelation.setImage(_imageReg.get(IconsInternal.RELATION_REMOVE)); delRelation.setEnabled(_mayWrite); delRelation.setLayoutData(_gridData); ((GridData) delRelation.getLayoutData()).horizontalIndent = 8; delRelation.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { loadRelationDim(4, (Integer) relComposite.getData("relStm"), //$NON-NLS-1$ ((Integer) relComposite.getData("rel"))); //$NON-NLS-1$ validate(); } }); delRelation.setLayoutData(new GridData()); relComposite.layout(); } } } _relGroup.layout(); } contentCompRel.layout(); _scrollCompRel.setContent(contentCompRel); Point point = contentCompRel.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); Point mp = _mainTabFolder.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); if (point.x > mp.x - 20) { point.x = mp.x - 20; } _scrollCompRel.setMinSize(point); _scrollCompRel.layout(); _relationComposite.redraw(); _relationComposite.layout(); // _relationComposite.pack(); // _mainTabFolder.redraw(); _mainTabFolder.layout(); // _mainTabFolder.pack(); }
From source file:org.bbaw.pdr.ae.view.main.editors.AspectEditorDialog.java
License:Open Source License
/** * <h4>Load time spatial dim.</h4> * <p>/*from ww w . jav a 2 s.c o m*/ * generates GUI elements for representation and modification of * {@link TimeDim} and {@link SpatialDim} information of the current {@link Aspect}. * </p><p> * Can also add/remove {@link TimeStm}/{@link SpatialStm} or {@link Time}/{@link Place} * objects prior to GUI assemblage. Functional behaviour is determined by parameter <code>type</code>: * <ul><li>0. Do nothing, just make GUI stuff</li> * <li>1. Add new {@link TimeStm}</li> * <li>2. Delete {@link TimeStm} at index <code>timeStm</code></li> * <li>3. Add new {@link Time} object at index <code>timeStm</code></li> * <li>4. Delete {@link Time} element index <code>timeStm</code></li> * <li>5. add new {@link SpatialStm}</li> * <li>6. Delete {@link SpatialStm}</li> * <li>7. Add new {@link Place} at index <code>spatialStm</code></li> * <li>8. Delete {@link Place} at index <code>spatialStm</code></li> * <li>15. Add both new {@link TimeStm} and {@link SpatialStm}</li></ul> * </p> * @param type numerical value specifying functional behaviour * @param timeStm index of {@link TimeStm} to be deleted or to which an additional {@link Time} object is to be added * @param time index of {@link Time} element to be deleted. The {@link TimeStm} in which deletion is to be done must be specified using <code>timeStm</code> param. * @param spatialStm index of {@link SpatialStm} which should be deleted or extended by a new {@link Place} element * @param place index of {@link Place} element which shall be deleted. spatialStm must we specified as well, obviously. */ private void loadTimeSpatialDim(Integer type, final Integer timeStm, final Integer time, final Integer spatialStm, final Integer place) { System.out.println("LOAD loadTimeSpatialDim"); if (_scrollCompTimePlace != null) { _scrollCompTimePlace.dispose(); } if (_timeGroup != null) { _timeGroup.dispose(); } if (_placeGroup != null) { _placeGroup.dispose(); } _scrollCompTimePlace = new ScrolledComposite(_dimensionComposite, SWT.BORDER | SWT.V_SCROLL); _scrollCompTimePlace.setExpandHorizontal(true); _scrollCompTimePlace.setExpandVertical(true); _scrollCompTimePlace.setMinHeight(1); _scrollCompTimePlace.setMinWidth(1); _scrollCompTimePlace.setLayout(new GridLayout()); _scrollCompTimePlace.setLayoutData(new GridData()); ((GridData) _scrollCompTimePlace.getLayoutData()).heightHint = 490; ((GridData) _scrollCompTimePlace.getLayoutData()).widthHint = 700; ((GridData) _scrollCompTimePlace.getLayoutData()).horizontalSpan = 2; ((GridData) _scrollCompTimePlace.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) _scrollCompTimePlace.getLayoutData()).grabExcessHorizontalSpace = true; _scrollCompTimePlace.layout(); Composite contentCompTimePlace = new Composite(_scrollCompTimePlace, SWT.NONE); contentCompTimePlace.setLayout(new GridLayout()); _scrollCompTimePlace.setContent(contentCompTimePlace); if (_currentAspect.getTimeDim() == null) { _currentAspect.setTimeDim(new TimeDim()); _currentAspect.getTimeDim().setTimeStms(new Vector<TimeStm>()); } if (_currentAspect.getSpatialDim() == null) { _currentAspect.setSpatialDim(new SpatialDim()); _currentAspect.getSpatialDim().setSpatialStms(new Vector<SpatialStm>()); } if (_currentAspect.getTimeDim().getTimeStms().size() == 0 && _currentAspect.getSpatialDim().getSpatialStms().size() == 0) { type = 15; } else if (_currentAspect.getTimeDim().getTimeStms().size() == 0) { type = 1; } else if (_currentAspect.getSpatialDim().getSpatialStms().size() == 0) { type = 5; } switch (type) { case 0: break; // nix, normales laden case 1: // neues timeStm einfgen _currentAspect.getTimeDim().getTimeStms().add(new TimeStm()); break; case 2: // timeStm lschen _currentAspect.getTimeDim().remove(timeStm); break; case 3: // neue time einfgen _currentAspect.getTimeDim().getTimeStms().get(timeStm).getTimes().add(new Time()); _currentAspect.getTimeDim().getTimeStms().get(timeStm).getTimes().lastElement() .setTimeStamp(new PdrDate(PRESELECTED_YEAR, 0, 0)); break; case 4: // time lschen _currentAspect.getTimeDim().getTimeStms().get(timeStm).getTimes().removeElementAt(time); break; case 5: // neues spatialStm einfgen _currentAspect.getSpatialDim().getSpatialStms().add(new SpatialStm()); break; case 6: // spatialStm lschen _currentAspect.getSpatialDim().remove(spatialStm); break; case 7: // neuer place einfgen _currentAspect.getSpatialDim().getSpatialStms().get(spatialStm).getPlaces().add(new Place()); break; case 8: // place lschen _currentAspect.getSpatialDim().getSpatialStms().get(spatialStm).getPlaces().removeElementAt(place); break; case 15: // neues spatialStm und timeStm einfgen _currentAspect.getTimeDim().getTimeStms().add(new TimeStm()); _currentAspect.getSpatialDim().getSpatialStms().add(new SpatialStm()); break; default: break; } if (_currentAspect.getTimeDim() != null && _currentAspect.getTimeDim().getTimeStms() != null) { for (int i = 0; i < _currentAspect.getTimeDim().getTimeStms().size(); i++) { final TimeStm tStm = _currentAspect.getTimeDim().getTimeStms().get(i); _timeGroup = new Group(contentCompTimePlace, SWT.SHADOW_IN); _timeGroup.setData("timeStm", i); //$NON-NLS-1$ _timeGroup.setLayout(new GridLayout()); ((GridLayout) _timeGroup.getLayout()).numColumns = 5; _timeGroup.setLayoutData(new GridData()); ((GridLayout) _timeGroup.getLayout()).makeColumnsEqualWidth = false; ((GridData) _timeGroup.getLayoutData()).horizontalAlignment = GridData.FILL; ((GridData) _timeGroup.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) _timeGroup.getLayoutData()).minimumHeight = 20; int m = 1 + i; _timeGroup.setText(NLMessages.getString("Editor_timeStm") + m); Label spatialStmTypeLabel = new Label(_timeGroup, SWT.NONE); spatialStmTypeLabel.setText(NLMessages.getString("Editor_space_type")); spatialStmTypeLabel.setLayoutData(new GridData()); final Combo timeStmCombo = new Combo(_timeGroup, SWT.DROP_DOWN | SWT.READ_ONLY); timeStmCombo.setEnabled(_mayWrite); timeStmCombo.setBackground(WHITE_COLOR); timeStmCombo.setLayoutData(new GridData()); ((GridData) timeStmCombo.getLayoutData()).horizontalAlignment = GridData.FILL; ((GridData) timeStmCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) timeStmCombo.getLayoutData()).horizontalSpan = 2; ComboViewer timeStmComboViewer = new ComboViewer(timeStmCombo); timeStmComboViewer.setContentProvider(ArrayContentProvider.getInstance()); timeStmComboViewer.setLabelProvider(new LabelProvider() { @Override public String getText(final Object element) { String str = (String) element; return NLMessages.getString("Editor_timetypes_" + str); } }); timeStmComboViewer.setInput(AEConstants.TIMEDIMTYPES); timeStmComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection selection = event.getSelection(); Object obj = ((IStructuredSelection) selection).getFirstElement(); String s = (String) obj; tStm.setType(s); } }); if (tStm.getType() != null) { StructuredSelection selection = new StructuredSelection(tStm.getType()); timeStmComboViewer.setSelection(selection); } else { timeStmCombo.select(0); ISelection selection = timeStmComboViewer.getSelection(); Object obj = ((IStructuredSelection) selection).getFirstElement(); String s = (String) obj; tStm.setType(s); } final Button delTimeStm = new Button(_timeGroup, SWT.PUSH); delTimeStm.setText(NLMessages.getString("Editor_delete")); delTimeStm.setToolTipText(NLMessages.getString("Editor_remove_timeStm_tip")); delTimeStm.setImage(_imageReg.get(IconsInternal.TIME_REMOVE)); delTimeStm.setLayoutData(_gridData); delTimeStm.setData("timeStm", i); //$NON-NLS-1$ delTimeStm.setEnabled(_currentAspect.getTimeDim().getTimeStms().size() > 1 && _mayWrite); delTimeStm.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { // System.out.println("del timeStm " + (Integer) delTimeStm.getData("timeStm")); //$NON-NLS-1$ //$NON-NLS-2$ loadTimeSpatialDim(2, (Integer) delTimeStm.getData("timeStm"), null, null, null); //$NON-NLS-1$ validate(); } }); delTimeStm.setLayoutData(new GridData()); final Button addTime = new Button(_timeGroup, SWT.PUSH); addTime.setText(NLMessages.getString("Editor_addTime")); addTime.setToolTipText(NLMessages.getString("Editor_add_time_tip")); addTime.setImage(_imageReg.get(IconsInternal.ADD)); addTime.setEnabled(_mayWrite); addTime.setLayoutData(_gridData); addTime.setData("timeStm", i); //$NON-NLS-1$ addTime.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { // System.out.println("add time " + (Integer) addTime.getData("timeStm")); //$NON-NLS-1$ //$NON-NLS-2$ loadTimeSpatialDim(3, (Integer) addTime.getData("timeStm"), null, null, null); //$NON-NLS-1$ validate(); } }); addTime.setLayoutData(new GridData()); if (tStm.getTimes() != null) { for (int j = 0; j < tStm.getTimes().size(); j++) { final Time tTime = tStm.getTimes().get(j); final Composite compositeTime = new Composite(_timeGroup, SWT.NONE); compositeTime.setData("timeStm", i); //$NON-NLS-1$ compositeTime.setData("time", j); //$NON-NLS-1$ compositeTime.setLayout(new GridLayout()); compositeTime.setLayoutData(new GridData()); ((GridLayout) compositeTime.getLayout()).numColumns = 8; ((GridLayout) compositeTime.getLayout()).makeColumnsEqualWidth = false; ((GridData) compositeTime.getLayoutData()).horizontalSpan = 5; ((GridData) compositeTime.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) compositeTime.getLayoutData()).grabExcessHorizontalSpace = true; FocusListener focusListener = new FocusAdapter() { }; int l = j + 1; Label timeLabel = new Label(compositeTime, SWT.NONE); timeLabel.setText(NLMessages.getString("Editor_time_space") + l); timeLabel.setLayoutData(new GridData()); final Combo timeTypeCombo = new Combo(compositeTime, SWT.DROP_DOWN | SWT.READ_ONLY); timeTypeCombo.setBackground(WHITE_COLOR); timeTypeCombo.setEnabled(_mayWrite); timeTypeCombo.setLayoutData(new GridData()); ((GridData) timeTypeCombo.getLayoutData()).horizontalSpan = 1; ((GridData) timeTypeCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) timeTypeCombo.getLayoutData()).grabExcessHorizontalSpace = true; ComboViewer timeTypeComboViewer = new ComboViewer(timeTypeCombo); 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; tTime.setType(s); } }); if (tTime.getType() != null) { StructuredSelection selection = new StructuredSelection(tTime.getType()); timeTypeComboViewer.setSelection(selection); } else { timeTypeCombo.select(0); ISelection selection = timeTypeComboViewer.getSelection(); Object obj = ((IStructuredSelection) selection).getFirstElement(); String s = (String) obj; tTime.setType(s); } Combo comboTimeDay = new Combo(compositeTime, SWT.READ_ONLY); comboTimeDay.setEnabled(_mayWrite); comboTimeDay.setBackground(WHITE_COLOR); comboTimeDay.setLayoutData(new GridData()); ((GridData) comboTimeDay.getLayoutData()).horizontalAlignment = GridData.FILL; ((GridData) comboTimeDay.getLayoutData()).grabExcessHorizontalSpace = true; comboTimeDay.setItems(AEConstants.DAYS); comboTimeDay.addFocusListener(focusListener); if (tTime.getTimeStamp() != null) { comboTimeDay.select(tTime.getTimeStamp().getDay()); } comboTimeDay.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { tTime.getTimeStamp().setDay(timeTypeCombo.getSelectionIndex()); } }); final Combo comboTimeMonth = new Combo(compositeTime, SWT.READ_ONLY); comboTimeMonth.setEnabled(_mayWrite); comboTimeMonth.setBackground(WHITE_COLOR); comboTimeMonth.setLayoutData(new GridData()); ((GridData) comboTimeMonth.getLayoutData()).horizontalAlignment = GridData.FILL; ((GridData) comboTimeMonth.getLayoutData()).grabExcessHorizontalSpace = true; comboTimeMonth.setItems(AEConstants.MONTHS); comboTimeMonth.addFocusListener(focusListener); if (tTime.getTimeStamp() != null) { comboTimeMonth.select(tTime.getTimeStamp().getMonth()); } comboTimeMonth.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { tTime.getTimeStamp().setMonth(comboTimeMonth.getSelectionIndex()); } }); final YearSpinner spinnerTimeYear = new YearSpinner(compositeTime, SWT.BORDER); spinnerTimeYear.setEnabled(_mayWrite); final ControlDecoration decoTime = new ControlDecoration(spinnerTimeYear, SWT.LEFT | SWT.TOP); if (tTime.getTimeStamp() != null) { spinnerTimeYear.setSelection(tTime.getTimeStamp().getYear()); } else { decoTime.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED).getImage()); } spinnerTimeYear.pack(); spinnerTimeYear.addFocusListener(focusListener); spinnerTimeYear.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent se) { tTime.getTimeStamp().setYear(spinnerTimeYear.getSelection()); if (tTime.isValid()) { decoTime.setImage(null); } else { decoTime.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage()); } validate(); } }); Label timeAccuracy = new Label(compositeTime, SWT.NONE); timeAccuracy.setText(NLMessages.getString("Editor_quality2")); timeAccuracy.setLayoutData(new GridData()); final Combo timeAccuracyCombo = new Combo(compositeTime, SWT.DROP_DOWN | SWT.READ_ONLY); timeAccuracyCombo.setEnabled(_mayWrite); timeAccuracyCombo.setBackground(WHITE_COLOR); timeAccuracyCombo.setLayoutData(new GridData()); ((GridData) timeAccuracyCombo.getLayoutData()).horizontalSpan = 2; ((GridData) timeAccuracyCombo.getLayoutData()).horizontalSpan = 1; ((GridData) timeAccuracyCombo.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) timeAccuracyCombo.getLayoutData()).grabExcessHorizontalSpace = true; ComboViewer timeAccuracyComboViewer = new ComboViewer(timeAccuracyCombo); timeAccuracyComboViewer.setContentProvider(ArrayContentProvider.getInstance()); timeAccuracyComboViewer.setLabelProvider(new LabelProvider() { @Override public String getText(final Object element) { String str = (String) element; return NLMessages.getString("Editor_accuracy_" + str); } }); timeAccuracyComboViewer.setInput(AEConstants.TIME_ACCURACY); timeAccuracyComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection selection = event.getSelection(); Object obj = ((IStructuredSelection) selection).getFirstElement(); String s = (String) obj; tTime.setAccuracy(s); } }); if (tTime.getAccuracy() != null) //$NON-NLS-1$ //$NON-NLS-2$ { StructuredSelection selection = new StructuredSelection(tTime.getAccuracy()); timeAccuracyComboViewer.setSelection(selection); } else { timeAccuracyCombo.select(0); ISelection selection = timeAccuracyComboViewer.getSelection(); Object obj = ((IStructuredSelection) selection).getFirstElement(); String s = (String) obj; tTime.setAccuracy(s); } final Button delTime = new Button(compositeTime, SWT.PUSH); delTime.setText(NLMessages.getString("Editor_deleteTime")); delTime.setToolTipText(NLMessages.getString("Editor_remove_time_tip")); delTime.setImage(_imageReg.get(IconsInternal.REMOVE)); delTime.setEnabled(_mayWrite); // delTime.setImage(Activator.getDefault().getImageDescriptor("remove).createImage()); delTime.setLayoutData(_gridData); delTime.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { // System.out.println("del time " + (Integer) compositeTime //$NON-NLS-1$ // .getData("timeStm") // + " " + (Integer) compositeTime.getData("time")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ loadTimeSpatialDim(4, (Integer) compositeTime.getData("timeStm"), //$NON-NLS-1$ (Integer) compositeTime.getData("time"), null, null); //$NON-NLS-1$ validate(); } }); delTime.setLayoutData(new GridData()); delTime.pack(); compositeTime.layout(); } // compositeTime } // timeGroup } } // XXX this is were spatialStm controls are put together. What about this 'set key' button?? // XXX also, are newly created place elements correctly put into aspects contents? if (_currentAspect.getSpatialDim() != null && _currentAspect.getSpatialDim().getSpatialStms() != null) { for (int i = 0; i < _currentAspect.getSpatialDim().getSpatialStms().size(); i++) { final SpatialStm sStm = _currentAspect.getSpatialDim().getSpatialStms().get(i); int l = i + 1; _placeGroup = new Group(contentCompTimePlace, SWT.SHADOW_IN); _placeGroup.setData("spatialStm", i); //$NON-NLS-1$ _placeGroup.setLayout(new GridLayout()); ((GridLayout) _placeGroup.getLayout()).numColumns = 5; _placeGroup.setText(NLMessages.getString("Editor_spatialStm") + l); _placeGroup.setLayoutData(new GridData()); ((GridData) _placeGroup.getLayoutData()).horizontalAlignment = GridData.FILL; ((GridData) _placeGroup.getLayoutData()).minimumHeight = 60; ((GridData) _placeGroup.getLayoutData()).grabExcessHorizontalSpace = true; Label spatialStmTypeLabel = new Label(_placeGroup, SWT.NONE); spatialStmTypeLabel.setText( NLMessages.getString("Editor_stm_space") + l + NLMessages.getString("Editor_space_type")); spatialStmTypeLabel.setLayoutData(new GridData()); final Combo spatialTypCombo = new Combo(_placeGroup, SWT.DROP_DOWN | SWT.READ_ONLY); spatialTypCombo.setEnabled(_mayWrite); spatialTypCombo.setBackground(WHITE_COLOR); spatialTypCombo.setLayoutData(new GridData()); ((GridData) spatialTypCombo.getLayoutData()).horizontalAlignment = GridData.FILL; ((GridData) spatialTypCombo.getLayoutData()).horizontalSpan = 2; ((GridData) spatialTypCombo.getLayoutData()).grabExcessHorizontalSpace = true; ComboViewer spatialTypComboViewer = new ComboViewer(spatialTypCombo); spatialTypComboViewer.setContentProvider(ArrayContentProvider.getInstance()); spatialTypComboViewer.setLabelProvider(new LabelProvider() { @Override public String getText(final Object element) { String str = (String) element; return NLMessages.getString("Editor_spatialdim_types_" + str); } }); spatialTypComboViewer.setInput(AEConstants.SPATIALDIMTYPES); spatialTypComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection selection = event.getSelection(); Object obj = ((IStructuredSelection) selection).getFirstElement(); String s = (String) obj; sStm.setType(s); } }); if (sStm.getType() != null) //$NON-NLS-1$ { StructuredSelection selection = new StructuredSelection(sStm.getType()); spatialTypComboViewer.setSelection(selection); } else { spatialTypCombo.select(0); ISelection selection = spatialTypComboViewer.getSelection(); Object obj = ((IStructuredSelection) selection).getFirstElement(); String s = (String) obj; sStm.setType(s); } final Button delSpatialStm = new Button(_placeGroup, SWT.PUSH); delSpatialStm.setText(NLMessages.getString("Editor_delete")); delSpatialStm.setToolTipText(NLMessages.getString("Editor_remove_spatialStm_tip")); delSpatialStm.setImage(_imageReg.get(IconsInternal.PLACE_REMOVE)); delSpatialStm.setEnabled(_currentAspect.getSpatialDim().getSpatialStms().size() > 1 && _mayWrite); delSpatialStm.setLayoutData(_gridData); delSpatialStm.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { // System.out.println("del timeStm " + (Integer) placeGroup //$NON-NLS-1$ // .getData("spatialStm")); //$NON-NLS-1$ loadTimeSpatialDim(6, null, null, ((Integer) _placeGroup.getData("spatialStm")), null); //$NON-NLS-1$ } }); delSpatialStm.setLayoutData(new GridData()); final Button addPlace = new Button(_placeGroup, SWT.PUSH); addPlace.setText(NLMessages.getString("Editor_addPlace")); addPlace.setToolTipText(NLMessages.getString("Editor_add_place_tip")); addPlace.setImage(_imageReg.get(IconsInternal.ADD)); addPlace.setEnabled(_mayWrite); addPlace.setLayoutData(_gridData); addPlace.setData("spatialStm", i); //$NON-NLS-1$ addPlace.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { // System.out.println("add place " + (Integer) placeGroup //$NON-NLS-1$ // .getData("spatialStm")); //$NON-NLS-1$ loadTimeSpatialDim(7, null, null, ((Integer) addPlace.getData("spatialStm")), null); //$NON-NLS-1$ validate(); } }); addPlace.setLayoutData(new GridData()); if (sStm.getPlaces() != null) { for (int j = 0; j < sStm.getPlaces().size(); j++) { int m = j + 1; final Place p = sStm.getPlaces().get(j); final Composite compositePlace = new Composite(_placeGroup, SWT.NONE); compositePlace.setData("spatialStm", i); //$NON-NLS-1$ compositePlace.setData("place", j); //$NON-NLS-1$ compositePlace.setLayout(new GridLayout()); compositePlace.setLayoutData(new GridData()); ((GridLayout) compositePlace.getLayout()).numColumns = 6; ((GridLayout) compositePlace.getLayout()).makeColumnsEqualWidth = true; ((GridData) compositePlace.getLayoutData()).horizontalAlignment = GridData.FILL; ((GridData) compositePlace.getLayoutData()).horizontalSpan = 5; @SuppressWarnings("unused") FocusListener focusListener = new FocusAdapter() { }; Label spacialLabel = new Label(compositePlace, SWT.NONE); spacialLabel.setText(NLMessages.getString("Editor_palce_space") + m + NLMessages.getString("Editor_space_name")); spacialLabel.setLayoutData(new GridData()); final Text placeText = new Text(compositePlace, SWT.BORDER); placeText.setEditable(_mayWrite); placeText.setBackground(WHITE_COLOR); placeText.setLayoutData(new GridData()); ((GridData) placeText.getLayoutData()).horizontalAlignment = GridData.FILL; ((GridData) placeText.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) placeText.getLayoutData()).horizontalSpan = 5; final ControlDecoration decoPlace = new ControlDecoration(placeText, SWT.LEFT | SWT.TOP); if (p.getPlaceName() != null) { placeText.setText(p.getPlaceName()); //$NON-NLS-1$ } else { placeText.setText(""); //$NON-NLS-1$ decoPlace.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED).getImage()); } placeText.addFocusListener(new FocusListener() { @Override public void focusLost(final FocusEvent e) { p.setPlaceName(placeText.getText()); //$NON-NLS-1$ if (p.isValid()) { decoPlace.setImage(null); } else { decoPlace.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage()); } validate(); } @Override public void focusGained(FocusEvent e) { String[] vals = new String[] { "NO PLACE FOUNG" }; try { vals = _mainSearcher.getFacets("tagging", "placeName", p.getType(), p.getSubtype(), null); } catch (Exception e1) { e1.printStackTrace(); } new AutoCompleteField(placeText, new TextContentAdapter(), vals); } }); placeText.addKeyListener(new KeyListener() { @Override public void keyPressed(final KeyEvent e) { } @Override public void keyReleased(final KeyEvent e) { p.setPlaceName(placeText.getText()); //$NON-NLS-1$ if (p.isValid()) { decoPlace.setImage(null); } else { decoPlace.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR).getImage()); } validate(); } }); Label placeTypeL = new Label(compositePlace, SWT.NONE); placeTypeL.setText(NLMessages.getString("Editor_type")); placeTypeL.setLayoutData(new GridData()); final Combo placeTypeCombo = new Combo(compositePlace, SWT.DROP_DOWN | SWT.READ_ONLY); placeTypeCombo.setEnabled(_mayWrite); placeTypeCombo.setBackground(WHITE_COLOR); placeTypeCombo.setLayoutData(new GridData()); ((GridData) placeTypeCombo.getLayoutData()).horizontalAlignment = GridData.FILL; ((GridData) placeTypeCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) placeTypeCombo.getLayoutData()).horizontalSpan = 2; ComboViewer placeTypeComboViewer = new ComboViewer(placeTypeCombo); placeTypeComboViewer.setContentProvider(new MarkupContentProvider()); placeTypeComboViewer.setLabelProvider(new MarkupLabelProvider()); if (_facade.getConfigs().containsKey(_markupProvider)) { placeTypeComboViewer.setInput(_facade.getConfigs().get(_markupProvider).getChildren() .get("aodl:placeName").getChildren()); } // placeTypeCombo.setItems(readConfigs(_markupProvider, // "markup", "type", "placeName", null, null)); // // for (String sdt : AEConstants.PLACESCALE) // { // placeTypeCombo.add(sdt); // } if (p.getType() != null) { ViewHelper.setComboViewerByString(placeTypeComboViewer, p.getType(), true); } else { ConfigData cd = (ConfigData) placeTypeComboViewer.getElementAt(0); p.setType(cd.getValue()); } Label placeSubtypeL = new Label(compositePlace, SWT.NONE); placeSubtypeL.setText(NLMessages.getString("Editor_subtype")); placeSubtypeL.setLayoutData(new GridData()); final Combo placeSubtypeCombo = new Combo(compositePlace, SWT.DROP_DOWN | SWT.READ_ONLY); placeSubtypeCombo.setEnabled(_mayWrite); placeSubtypeCombo.setBackground(WHITE_COLOR); placeSubtypeCombo.setLayoutData(new GridData()); ((GridData) placeSubtypeCombo.getLayoutData()).horizontalAlignment = GridData.FILL; ((GridData) placeSubtypeCombo.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) placeSubtypeCombo.getLayoutData()).horizontalSpan = 2; final ComboViewer placeSubtypeComboViewer = new ComboViewer(placeSubtypeCombo); placeSubtypeComboViewer.setContentProvider(new MarkupContentProvider()); placeSubtypeComboViewer.setLabelProvider(new MarkupLabelProvider()); placeTypeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); ConfigData cd = (ConfigData) obj; p.setType(cd.getValue()); placeSubtypeComboViewer.setInput(_facade.getConfigs().get(_markupProvider) .getChildren().get("aodl:placeName").getChildren().get(p.getType()) .getChildren()); } }); // for (String sdt : AEConstants.PLACESCALE) // { // placeSubtypeCombo.add(sdt); // } if (p.getSubtype() != null) { ViewHelper.setComboViewerByString(placeSubtypeComboViewer, p.getSubtype(), true); } placeSubtypeComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { ISelection iSelection = event.getSelection(); Object obj = ((IStructuredSelection) iSelection).getFirstElement(); ConfigData cd = (ConfigData) obj; p.setSubtype(cd.getValue()); } }); Label placeKeyL = new Label(compositePlace, SWT.NONE); placeKeyL.setText(NLMessages.getString("Editor_key")); placeKeyL.setLayoutData(new GridData()); // XXX this is the spatialStm place's 'key' attr final Text placeKeyText = new Text(compositePlace, SWT.BORDER); placeKeyText.setEditable(_mayWrite); placeKeyText.setBackground(WHITE_COLOR); placeKeyText.setLayoutData(new GridData()); ((GridData) placeKeyText.getLayoutData()).horizontalAlignment = SWT.FILL; ((GridData) placeKeyText.getLayoutData()).grabExcessHorizontalSpace = true; ((GridData) placeKeyText.getLayoutData()).horizontalSpan = 3; if (p.getKey() != null) { placeKeyText.setText(p.getKey()); //$NON-NLS-1$ } else { placeKeyText.setText(""); //$NON-NLS-1$ } //XXX value from text field is only copied on lost focus event placeKeyText.addFocusListener(new FocusAdapter() { @Override public void focusLost(final FocusEvent e) { p.setKey(placeKeyText.getText()); } }); final Button delPlace = new Button(compositePlace, SWT.PUSH); delPlace.setText(NLMessages.getString("Editor_deletePlace")); delPlace.setToolTipText(NLMessages.getString("Editor_remove_place_tip")); delPlace.setImage(_imageReg.get(IconsInternal.REMOVE)); delPlace.setEnabled(_mayWrite); delPlace.setLayoutData(_gridData); delPlace.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { // System.out.println("del place " + (Integer) compositePlace //$NON-NLS-1$ //.getData("spatialStm") + " " + (Integer) compositePlace.getData("place")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ loadTimeSpatialDim(8, null, null, (Integer) compositePlace.getData("spatialStm"), //$NON-NLS-1$ (Integer) compositePlace.getData("place")); //$NON-NLS-1$ validate(); } }); delPlace.setLayoutData(new GridData()); delPlace.pack(); compositePlace.layout(); // compositePlace } } _timeGroup.layout(); _placeGroup.layout(); // placeGroup } } contentCompTimePlace.layout(); _scrollCompTimePlace.setContent(contentCompTimePlace); Point point = contentCompTimePlace.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); Point mp = _mainTabFolder.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); if (point.x > mp.x - 20) { point.x = mp.x - 20; } _scrollCompTimePlace.setMinSize(point); _scrollCompTimePlace.layout(); _dimensionComposite.redraw(); _dimensionComposite.layout(); // _dimensionComposite.pack(); // _mainTabFolder.redraw(); _mainTabFolder.layout(); // _mainTabFolder.pack(); }
From source file:org.bbaw.pdr.ae.view.main.editors.PersonEditorDialog.java
License:Open Source License
/** * Load identifiers.//w w w.java 2s .c o m * @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(_identifierComposite, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL); _scrollCompIdentifier.setExpandHorizontal(true); _scrollCompIdentifier.setExpandVertical(true); _scrollCompIdentifier.setMinSize(SWT.DEFAULT, SWT.DEFAULT); _scrollCompIdentifier.setLayoutData(new GridData()); ((GridData) _scrollCompIdentifier.getLayoutData()).heightHint = 300; ((GridData) _scrollCompIdentifier.getLayoutData()).widthHint = 580; ((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 externalIdentifierCombo = new Combo(idGroup, // SWT.DROP_DOWN | SWT.READ_ONLY); // externalIdentifierCombo.setLayoutData(new GridData()); // externalIdentifierCombo.setEnabled(_mayWrite); // externalIdentifierCombo.setBackground(WHITE_COLOR); // // ((GridData) // // externalIdentifierCombo.getLayoutData()).horizontalAlignment // // = SWT.FILL; // // ((GridData) // // // externalIdentifierCombo.getLayoutData()).grabExcessHorizontalSpace // // = true; // for (String sdt : AEConstants.EXTERNAL_IDENTIFIER_PROVIDER) // { // externalIdentifierCombo.add(sdt); // } final Combo idProviderCombo = new Combo(idGroup, SWT.DROP_DOWN | SWT.READ_ONLY); idProviderCombo.setEnabled(_mayWrite); 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(_mayWrite); 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(_mayWrite); 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(_mayWrite); 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 = _mainTabFolder.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); if (point.x > mp.x - 20) { point.x = mp.x - 20; } _scrollCompIdentifier.setMinSize(point); _scrollCompIdentifier.layout(); _identifierComposite.redraw(); _identifierComposite.layout(); // _scrollCompIdentifier.setSize(DIALOG_DEFAULT_BOUNDS, // DIALOG_DEFAULT_BOUNDS); _identifierComposite.update(); }