Example usage for org.eclipse.jface.viewers CheckboxTableViewer newCheckList

List of usage examples for org.eclipse.jface.viewers CheckboxTableViewer newCheckList

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers CheckboxTableViewer newCheckList.

Prototype

public static CheckboxTableViewer newCheckList(Composite parent, int style) 

Source Link

Document

Creates a table viewer on a newly-created table control under the given parent.

Usage

From source file:com.arc.cdt.importer.internal.ui.ProjectSelectionWizardPage.java

License:Open Source License

public void createControl(Composite parent) {
    Composite composite = new Composite(parent, SWT.NULL);
    composite.setLayout(new GridLayout(2, false));
    mViewer = CheckboxTableViewer.newCheckList(composite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    GridData gridData = new GridData(GridData.FILL_BOTH);
    gridData.verticalSpan = 3;//from   www.j  a  v a  2 s. c  om
    mViewer.getControl().setLayoutData(gridData);

    mViewer.setContentProvider(new IStructuredContentProvider() {

        public Object[] getElements(Object inputElement) {
            if (inputElement instanceof ICodewrightProjectSpace) {
                try {
                    return ((ICodewrightProjectSpace) inputElement).getProjects();
                } catch (Exception e) {
                    return new Exception[] { e };
                }
            } else
                return EMPTY;
        }

        public void dispose() {
        }

        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }

    });

    mViewer.setLabelProvider(new LabelProvider() {
        @Override
        public String getText(Object element) {
            if (element instanceof ICodewrightProject) {
                return ((ICodewrightProject) element).getName();
            } else if (element instanceof Exception) {
                return ((Exception) element).getMessage();
            } else
                return "";
        }

        @Override
        public Image getImage(Object element) {
            if (element instanceof ICodewrightProject) {
                return ImporterPlugin.getDefault().getImageRegistry().get(PROJECT_IMAGE_KEY);
            }
            return null;
        }

    });

    mViewer.addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            validate();
        }
    });

    Button setAllButton = new Button(composite, SWT.PUSH);
    setAllButton.setText("Select All");
    setAllButton.setLayoutData(new GridData());
    setAllButton.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            mViewer.setAllChecked(true);
            validate();
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);

        }
    });

    Button clearAllButton = new Button(composite, SWT.PUSH);
    clearAllButton.setText("Clear All");
    clearAllButton.setLayoutData(new GridData());
    clearAllButton.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent e) {
            mViewer.setAllChecked(false);
            validate();
        }

        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);

        }
    });

    setControl(composite);

}

From source file:com.arc.embeddedcdt.gui.ARCCommonTab.java

License:Open Source License

/**
 * Creates the favorites control/* w  w  w. j av  a2s  .  co  m*/
 * @param parent the parent composite to add this one to
 * @since 3.2
 */
private void createFavoritesComponent(Composite parent) {
    Group favComp = SWTFactory.createGroup(parent,
            LaunchConfigurationsMessages.CommonTab_Display_in_favorites_menu__10, 1, 1, GridData.FILL_BOTH);
    fFavoritesTable = CheckboxTableViewer.newCheckList(favComp,
            SWT.CHECK | SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
    Control table = fFavoritesTable.getControl();
    GridData gd = new GridData(GridData.FILL_BOTH);
    table.setLayoutData(gd);
    table.setFont(parent.getFont());
    fFavoritesTable.setContentProvider(new FavoritesContentProvider());
    fFavoritesTable.setLabelProvider(new FavoritesLabelProvider());
    fFavoritesTable.addCheckStateListener(new ICheckStateListener() {
        public void checkStateChanged(CheckStateChangedEvent event) {
            updateLaunchConfigurationDialog();
        }
    });
}

From source file:com.archimatetool.editor.preferences.ConnectionsPreferencePage.java

License:Open Source License

private CheckboxTableViewer createRelationsTable(Composite parent) {
    final CheckboxTableViewer viewer = CheckboxTableViewer.newCheckList(parent, SWT.BORDER);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.heightHint = 80;//w w  w.  jav  a2s.c o  m
    viewer.getTable().setLayoutData(gd);

    viewer.setLabelProvider(new LabelProvider() {
        @Override
        public String getText(Object element) {
            return ArchimateLabelProvider.INSTANCE.getDefaultName((EClass) element);
        }

        @Override
        public Image getImage(Object element) {
            return ArchimateLabelProvider.INSTANCE.getImage(element);
        }
    });

    viewer.setContentProvider(new IStructuredContentProvider() {
        @Override
        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }

        @Override
        public void dispose() {
        }

        @Override
        public Object[] getElements(Object inputElement) {
            return ConnectionPreferences.RELATION_KEYMAP.keySet().toArray();
        }
    });

    viewer.setCheckStateProvider(new ICheckStateProvider() {
        @Override
        public boolean isGrayed(Object element) {
            return false;
        }

        @Override
        public boolean isChecked(Object element) {
            int value = (Integer) viewer.getInput();
            return (value & ConnectionPreferences.RELATION_KEYMAP.get(element)) != 0;
        }
    });

    return viewer;
}

From source file:com.asakusafw.shafu.internal.ui.wizards.SelectGradleProjectsPage.java

License:Apache License

@Override
public void createControl(Composite parent) {
    initializeDialogUnits(parent);//from w  w  w  .  ja va 2 s. com
    Composite pane = new Composite(parent, SWT.NONE);
    pane.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    setControl(pane);

    pane.setLayout(new GridLayout(1, false));

    Label descriptionLabel = new Label(pane, SWT.NONE);
    descriptionLabel.setText(Messages.SelectGradleProjectsPage_targetLabel);
    descriptionLabel.setLayoutData(GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.BEGINNING).create());

    this.viewer = CheckboxTableViewer.newCheckList(pane, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    viewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    viewer.setContentProvider(ArrayContentProvider.getInstance());
    viewer.setLabelProvider(new ProjectLabelProvider());
    viewer.getTable().setEnabled(false);
    viewer.getTable().addMouseListener(new MouseAdapter() {
        @Override
        public void mouseDown(MouseEvent e) {
            Table tree = (Table) e.getSource();
            Point point = new Point(e.x, e.y);
            TableItem item = tree.getItem(point);
            if (item == null) {
                return;
            }
            ProjectEntry entry = (ProjectEntry) item.getData();
            if (item.getBounds().contains(point) && entry.isEnabled()) {
                boolean checked = !item.getChecked();
                item.setChecked(checked);
                refreshSelection();
            }
        }
    });

    createGradleSettings(pane);
    createWorkingSetSettings(pane);
    createConsoleButton(pane);

    Dialog.applyDialogFont(pane);
    setPageComplete(false);
}

From source file:com.bdaum.zoom.net.communities.ui.EditCommunityAccountDialog.java

License:Open Source License

private void createAlbumGroup(Composite parent) {
    IDbManager db = Core.getCore().getDbManager();
    List<SmartCollectionImpl> albums = db.obtainObjects(SmartCollectionImpl.class, "album", true, //$NON-NLS-1$
            QueryField.EQUALS);/*ww w. j a  va  2 s . c o m*/
    List<PhotoSet> photosets = account.getPhotosets();
    Map<String, PhotoSet> remoteAlbums = new HashMap<String, PhotoSet>(photosets.size() * 5 / 4 + 1);
    for (PhotoSet photoset : photosets)
        remoteAlbums.put(photoset.getTitle(), photoset);
    final Map<String, SmartCollectionImpl> localAlbums = new HashMap<String, SmartCollectionImpl>(
            albums.size() * 5 / 4 + 1);
    externalAlbums = new HashMap<String, PhotoSet>(remoteAlbums);
    for (SmartCollectionImpl album : albums) {
        String name = Utilities.getExternalAlbumName(album);
        externalAlbums.remove(name);
        localAlbums.put(name, album);
    }
    parent.setLayout(new GridLayout());
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    composite.setLayout(new GridLayout());

    albumViewer = CheckboxTableViewer.newCheckList(composite, SWT.BORDER | SWT.V_SCROLL);
    GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
    layoutData.heightHint = 400;
    albumViewer.getControl().setLayoutData(layoutData);
    albumViewer.setContentProvider(ArrayContentProvider.getInstance());
    albumViewer.setLabelProvider(new ZColumnLabelProvider() {
        @Override
        public String getText(Object element) {
            if (element instanceof PhotoSet)
                return ((PhotoSet) element).getTitle();
            return element.toString();
        }

        @Override
        public Font getFont(Object element) {
            if (element instanceof PhotoSet && externalAlbums.containsKey(((PhotoSet) element).getTitle()))
                return JFaceResources.getBannerFont();
            return super.getFont(element);
        }

    });
    albumViewer.setComparator(ZViewerComparator.INSTANCE);
    albumViewer.addCheckStateListener(new ICheckStateListener() {
        public void checkStateChanged(CheckStateChangedEvent event) {
            updateAlbumsButton();
        }
    });
    albumViewer.setInput(photosets);
    importAlbumsButton = new Button(composite, SWT.PUSH);
    importAlbumsButton.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
    importAlbumsButton.setText(Messages.EditCommunityAccountDialog_import_into_catalog);
    importAlbumsButton.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            BusyIndicator.showWhile(e.display, () -> importAlbums());
        }

        private void importAlbums() {
            final IDbManager dbm = Core.getCore().getDbManager();
            GroupImpl importedAlbums = dbm.obtainById(GroupImpl.class, Constants.GROUP_ID_IMPORTED_ALBUMS);
            if (importedAlbums == null) {
                importedAlbums = new GroupImpl(Messages.EditCommunityAccountDialog_imported_albums, true,
                        Constants.INHERIT_LABEL, null, 0, null);
                importedAlbums.setStringId(Constants.GROUP_ID_IMPORTED_ALBUMS);
            }
            Object[] checkedElements = albumViewer.getCheckedElements();
            final List<Object> collections = new ArrayList<Object>(checkedElements.length + 1);
            for (Object obj : checkedElements) {
                PhotoSet photoSet = (PhotoSet) obj;
                String title = photoSet.getTitle();
                SmartCollectionImpl sm = localAlbums.get(title);
                if (sm == null) {
                    sm = new SmartCollectionImpl(title, false, true, false, false, photoSet.getDescription(), 0,
                            null, 0, null, Constants.INHERIT_LABEL, null, 0, null);
                    sm.setGroup_rootCollection_parent(Constants.GROUP_ID_IMPORTED_ALBUMS);
                    List<Criterion> criteria = new ArrayList<Criterion>(1);
                    criteria.add(
                            new CriterionImpl(Constants.OID, null, sm.getStringId(), QueryField.XREF, false));
                    sm.setCriterion(criteria);
                    importedAlbums.addRootCollection(sm.getStringId());
                } else
                    sm.setDescription(photoSet.getDescription());
                collections.add(sm);
                externalAlbums.remove(title);
                albumViewer.setChecked(obj, false);
            }
            collections.add(importedAlbums);
            dbm.safeTransaction(null, collections);
            Core.getCore().fireStructureModified();
            updateAlbumsButton();
        }
    });
    updateAlbumsButton();
}

From source file:com.bdaum.zoom.net.communities.ui.EditCommunityAccountDialog.java

License:Open Source License

private void createCategoryGroup(Composite parent) {
    List<? extends org.scohen.juploadr.app.Category> categories = account.getCategories();
    IDbManager db = Core.getCore().getDbManager();
    final Meta meta = db.getMeta(true);
    Map<String, Category> localCategories = meta.getCategory();
    externalCategories = new HashSet<String>(categories.size() * 5 / 4 + 1);
    for (org.scohen.juploadr.app.Category cat : categories)
        externalCategories.add(cat.getTitle());
    externalCategories.removeAll(localCategories.keySet());
    parent.setLayout(new GridLayout());
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    composite.setLayout(new GridLayout());
    Label allCatLabel = new Label(composite, SWT.NONE);
    allCatLabel.setText(Messages.EditCommunityAccountDialog_all_categories);
    allCatViewer = CheckboxTableViewer.newCheckList(composite, SWT.BORDER | SWT.V_SCROLL);
    GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
    layoutData.heightHint = 150;/*from w  w w.  j  ava2 s .  co m*/
    allCatViewer.getControl().setLayoutData(layoutData);
    allCatViewer.setContentProvider(ArrayContentProvider.getInstance());
    allCatViewer.setLabelProvider(new ZColumnLabelProvider() {
        @Override
        public String getText(Object element) {
            if (element instanceof org.scohen.juploadr.app.Category)
                return ((org.scohen.juploadr.app.Category) element).getTitle();
            return element.toString();
        }

        @Override
        public Font getFont(Object element) {
            if (element instanceof org.scohen.juploadr.app.Category
                    && externalCategories.contains(((org.scohen.juploadr.app.Category) element).getTitle()))
                return JFaceResources.getBannerFont();
            return super.getFont(element);
        }

    });
    allCatViewer.setComparator(ZViewerComparator.INSTANCE);
    allCatViewer.addCheckStateListener(new ICheckStateListener() {
        public void checkStateChanged(CheckStateChangedEvent event) {
            Object element = event.getElement();
            if (!externalCategories.contains(((org.scohen.juploadr.app.Category) element).getTitle()))
                allCatViewer.setChecked(element, false);
            updateCatButtons();
        }
    });
    allCatViewer.setInput(categories);
    updateAllCatButton = new Button(composite, SWT.PUSH);
    updateAllCatButton.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
    updateAllCatButton.setText(Messages.EditCommunityAccountDialog_import_into_catalog);
    updateAllCatButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            BusyIndicator.showWhile(e.display, () -> importAllCats());
        }

        private void importAllCats() {
            Object[] checkedElements = allCatViewer.getCheckedElements();
            Map<String, Category> newCats = new HashMap<String, Category>(meta.getCategory());
            for (Object element : checkedElements) {
                org.scohen.juploadr.app.Category cat = (org.scohen.juploadr.app.Category) element;
                String label = cat.getTitle();
                CategoryImpl newCat = new CategoryImpl(label);
                newCats.put(label, newCat);
                allCatViewer.setChecked(element, false);
                externalCategories.remove(label);
            }
            updateMeta(meta, newCats);
            updateCatButtons();
        }

    });
    // Part 2
    Map<String, Category> usedCategories = new HashMap<String, Category>();
    externalUsedCat = new HashSet<Category>();
    List<PhotoSet> photosets = account.getPhotosets();
    for (PhotoSet photoSet : photosets) {
        org.scohen.juploadr.app.Category category = photoSet.getCategory();
        if (category != null) {
            String title = category.getTitle();
            Category usedCat = usedCategories.get(title);
            if (usedCat == null) {
                usedCat = new CategoryImpl(title);
                usedCategories.put(title, usedCat);
            }
            Category localCat = localCategories.get(title);
            if (localCat == null)
                externalUsedCat.add(usedCat);
            org.scohen.juploadr.app.Category subcategory = photoSet.getSubcategory();
            if (subcategory != null) {
                String stitle = subcategory.getTitle();
                Category usedSub = usedCat.getSubCategory(stitle);
                if (usedSub == null) {
                    usedSub = new CategoryImpl(stitle);
                    usedCat.putSubCategory(usedSub);
                }
                if (localCat == null || localCat.getSubCategory() == null
                        || !localCat.getSubCategory().containsKey(stitle))
                    externalUsedCat.add(usedSub);
            }
        }
    }
    Label usedCatLabel = new Label(composite, SWT.NONE);
    usedCatLabel.setText(Messages.EditCommunityAccountDialog_used_categories);
    ExpandCollapseGroup expandCollapseGroup = new ExpandCollapseGroup(composite, SWT.NONE);
    usedCatViewer = new CheckboxTreeViewer(composite, SWT.BORDER | SWT.V_SCROLL);
    expandCollapseGroup.setViewer(usedCatViewer);
    layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
    layoutData.heightHint = 100;
    usedCatViewer.getControl().setLayoutData(layoutData);
    usedCatViewer.setContentProvider(new ITreeContentProvider() {
        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
            // do nothing
        }

        public void dispose() {
            // do nothing
        }

        public Object[] getElements(Object inputElement) {
            if (inputElement instanceof Map<?, ?>) {
                return ((Map<?, ?>) inputElement).values().toArray();
            }
            return EMPTY;
        }

        public boolean hasChildren(Object element) {
            return getChildren(element).length > 0;
        }

        public Object getParent(Object element) {
            if (element instanceof Category)
                return ((Category) element).getCategory_subCategory_parent();
            return null;
        }

        public Object[] getChildren(Object parentElement) {
            if (parentElement instanceof Category) {
                AomMap<String, Category> subCategories = ((Category) parentElement).getSubCategory();
                if (subCategories != null) {
                    List<Category> children = new ArrayList<>(subCategories.size());
                    for (Category cat : subCategories.values())
                        if (cat != null)
                            children.add(cat);
                    return children.toArray();
                }
            }
            return EMPTY;
        }
    });
    usedCatViewer.setLabelProvider(new ZColumnLabelProvider() {
        @Override
        public String getText(Object element) {
            if (element instanceof Category)
                return ((Category) element).getLabel();
            return element.toString();
        }

        @Override
        public Font getFont(Object element) {
            if (element instanceof Category && externalUsedCat.contains(element))
                return JFaceResources.getBannerFont();
            return super.getFont(element);
        }

    });
    usedCatViewer.setComparator(ZViewerComparator.INSTANCE);
    usedCatViewer.addCheckStateListener(new ICheckStateListener() {
        public void checkStateChanged(CheckStateChangedEvent event) {
            Object element = event.getElement();
            if (element instanceof Category && event.getChecked()) {
                if (!externalUsedCat.contains(element))
                    usedCatViewer.setChecked(element, false);
                else {
                    Category pcat = ((Category) element).getCategory_subCategory_parent();
                    if (pcat != null && externalUsedCat.contains(pcat))
                        usedCatViewer.setChecked(pcat, true);
                }
            }
            updateCatButtons();
        }
    });
    UiUtilities.installDoubleClickExpansion(usedCatViewer);
    usedCatViewer.setInput(usedCategories);
    usedCatViewer.expandAll();
    updateUsedCatButton = new Button(composite, SWT.PUSH);
    updateUsedCatButton.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
    updateUsedCatButton.setText(Messages.EditCommunityAccountDialog_import_into_catalog);
    updateUsedCatButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            BusyIndicator.showWhile(e.display, () -> importAllUsedCats());
        }

        private void importAllUsedCats() {
            Object[] checkedElements = usedCatViewer.getCheckedElements();
            Map<String, Category> newCats = new HashMap<String, Category>(meta.getCategory());
            for (Object element : checkedElements) {
                Category cat = (Category) element;
                Category pcat = cat.getCategory_subCategory_parent();
                if (pcat != null) {
                    Category p2 = newCats.get(pcat.getLabel());
                    if (p2 != null) {
                        pcat.removeSubCategory(cat.getLabel());
                        p2.putSubCategory(cat);
                    } else
                        newCats.put(pcat.getLabel(), pcat);
                } else if (newCats.get(cat.getLabel()) == null)
                    newCats.put(cat.getLabel(), cat);
                externalUsedCat.remove(cat);
                usedCatViewer.setChecked(cat, false);
                if (pcat != null) {
                    externalUsedCat.remove(pcat);
                    usedCatViewer.setChecked(pcat, false);
                }
            }
            updateMeta(meta, newCats);
            updateCatButtons();
        }
    });
    updateCatButtons();
}

From source file:com.bdaum.zoom.report.internal.wizards.ValuePage.java

License:Open Source License

@Override
public void createControl(Composite parent) {
    stack = new Composite(parent, SWT.NONE);
    stack.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    stackLayout = new StackLayout();
    stack.setLayout(stackLayout);/*from  www  . j a v a  2 s  .c  om*/
    setControl(stack);
    setHelp(HelpContextIds.REPORT_WIZARD);
    daytimeComposite = new Composite(stack, SWT.NONE);
    daytimeComposite.setLayout(new GridLayout());
    Label label = new Label(daytimeComposite, SWT.NONE);
    label.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
    label.setFont(JFaceResources.getBannerFont());
    label.setText(Messages.ValuePage_time_of_day);
    dayTimeButtonGroup = new RadioButtonGroup(daytimeComposite, Messages.ValuePage_intervals, SWT.NONE,
            Messages.ValuePage_hours, Messages.ValuePage_fifteen_min);
    GridData data = new GridData(SWT.BEGINNING, SWT.CENTER, false, false);
    data.verticalIndent = 20;
    dayTimeButtonGroup.setLayoutData(data);
    dayTimeButtonGroup.addListener(this);
    dayTimeButtonGroup.setSelection(0);
    timeComposite = new Composite(stack, SWT.NONE);
    timeComposite.setLayout(new GridLayout(4, false));
    label = new Label(timeComposite, SWT.NONE);
    label.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false, 4, 1));
    label.setFont(JFaceResources.getBannerFont());
    label.setText(Messages.ValuePage_calTime);
    label = new Label(timeComposite, SWT.NONE);
    label.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
    label.setText(Messages.ValuePage_from);
    timeFromField = new DateTime(timeComposite, SWT.CALENDAR | SWT.SHORT);
    timeFromField.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
    label = new Label(timeComposite, SWT.NONE);
    label.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
    label.setText(Messages.ValuePage_to);
    timeToField = new DateTime(timeComposite, SWT.CALENDAR | SWT.SHORT);
    timeToField.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
    timeFromField.setDate(timeToField.getYear() - 4, 0, 1);
    timeFromField.addListener(SWT.Selection, this);
    timeToField.addListener(SWT.Selection, this);
    GregorianCalendar cal = new GregorianCalendar();
    timeToField.setDate(cal.get(GregorianCalendar.YEAR), cal.get(GregorianCalendar.MONTH) + 1,
            cal.get(GregorianCalendar.DAY_OF_MONTH));
    timeButtonGroup = new RadioButtonGroup(timeComposite, Messages.ValuePage_interval, 2,
            Messages.ValuePage_by_year, Messages.ValuePage_by_quarter, Messages.ValuePage_by_month,
            Messages.ValuePage_by_week, Messages.ValuePage_by_day);
    timeButtonGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1));
    timeButtonGroup.addListener(this);
    timeButtonGroup.setSelection(0);
    numericComposite = new Composite(stack, SWT.NONE);
    numericComposite.setLayout(new GridLayout(1, false));
    label = new Label(numericComposite, SWT.NONE);
    label.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
    label.setFont(JFaceResources.getBannerFont());
    label.setText(Messages.ValuePage_numeric);
    numericViewer = createFieldViewer(numericComposite);
    Composite rangeComp = new Composite(numericComposite, SWT.NONE);
    rangeComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    rangeComp.setLayout(new GridLayout(3, false));
    rangeLabel = new Label(rangeComp, SWT.NONE);
    rangeLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));

    label = new Label(rangeComp, SWT.NONE);
    label.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
    label.setText(Messages.ValuePage_range);
    rangeSlider = new RangeControl(rangeComp, SWT.BORDER);
    rangeSlider.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true, 2, 1));
    rangeSlider.setSelection(new Point(25, 75));
    rangeSlider.addListener(this);
    label = new Label(rangeComp, SWT.NONE);
    label.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
    label.setText(Messages.ValuePage_intervals);
    intervalField = new NumericControl(rangeComp, SWT.NONE);
    intervalField.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, true, 2, 1));
    intervalField.setMinimum(2);
    intervalField.setMaximum(150);
    intervalField.setSelection(50);
    intervalField.addListener(this);
    discreteComposite = new Composite(stack, SWT.NONE);
    discreteComposite.setLayout(new GridLayout(1, false));
    label = new Label(discreteComposite, SWT.NONE);
    label.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
    label.setFont(JFaceResources.getBannerFont());
    label.setText(Messages.ValuePage_discrete);
    discreteViewer = createFieldViewer(discreteComposite);
    Composite spinnerComp = new Composite(discreteComposite, SWT.NONE);
    spinnerComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    spinnerComp.setLayout(new GridLayout(2, false));
    thresholdLabel = new Label(spinnerComp, SWT.NONE);
    thresholdLabel.setText(Messages.ValuePage_threshold);

    thresholdField = new NumericControl(spinnerComp, SWT.BORDER);
    thresholdField.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
    thresholdField.setMaximum(50);
    thresholdField.setIncrement(1);
    thresholdField.setDigits(1);
    thresholdField.setSelection(10);
    thresholdField.addListener(this);

    hiddenLabel = new Label(discreteComposite, SWT.NONE);
    hiddenLabel.setText(Messages.ValuePage_hidden);
    Composite filterComp = new Composite(discreteComposite, SWT.NONE);
    filterComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    filterComp.setLayout(new GridLayout(2, false));

    filterViewer = CheckboxTableViewer.newCheckList(filterComp, SWT.BORDER);
    GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
    layoutData.heightHint = 200;
    layoutData.widthHint = 200;
    filterViewer.getControl().setLayoutData(layoutData);
    filterViewer.setContentProvider(ArrayContentProvider.getInstance());
    filterViewer.setLabelProvider(ZColumnLabelProvider.getDefaultInstance());
    allNoneGroup = new AllNoneGroup(filterComp, new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            filterViewer.setAllChecked(e.widget.getData() == AllNoneGroup.ALL);
        }
    });
    setInput();
    super.createControl(parent);
}

From source file:com.bdaum.zoom.ui.internal.dialogs.AutoRuleComponent.java

License:Open Source License

@SuppressWarnings("unused")
public AutoRuleComponent(Composite parent, int style, IAdaptable info) {
    this.info = info;
    composite = new Composite(parent, SWT.NONE);
    Layout layout = parent.getLayout();/* w w  w . j  a  v a2 s  .  c  o m*/
    if (layout instanceof GridLayout) {
        GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
        layoutData.horizontalSpan = ((GridLayout) layout).numColumns;
        composite.setLayoutData(layoutData);
    }
    composite.setLayout(new GridLayout());
    new Label(composite, SWT.NONE).setText(Messages.AutoRuleComponent_collections_expl);
    CGroup autoGroup = UiUtilities.createGroup(composite, 2, Messages.AutoRuleComponent_title);
    ruleViewer = new TableViewer(autoGroup, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI | SWT.V_SCROLL);
    TableViewerColumn col0 = new TableViewerColumn(ruleViewer, SWT.NONE);
    col0.getColumn().setText(Messages.AutoRuleComponent_name);
    col0.getColumn().setWidth(100);
    col0.setLabelProvider(new ZColumnLabelProvider() {
        @Override
        public String getText(Object element) {
            if (element instanceof AutoRule)
                return ((AutoRule) element).getName();
            return element.toString();
        }
    });
    TableViewerColumn col1 = new TableViewerColumn(ruleViewer, SWT.NONE);
    col1.getColumn().setText(Messages.AutoRuleComponent_group);
    col1.getColumn().setWidth(180);
    col1.setLabelProvider(new ZColumnLabelProvider() {
        @Override
        public String getText(Object element) {
            if (element instanceof AutoRule)
                return ((AutoRule) element).getQfield().getCategory().toString();
            return element.toString();
        }
    });
    TableViewerColumn col2 = new TableViewerColumn(ruleViewer, SWT.NONE);
    col2.getColumn().setText(Messages.AutoRuleComponent_field);
    col2.getColumn().setWidth(220);
    col2.setLabelProvider(new ZColumnLabelProvider() {
        @Override
        public String getText(Object element) {
            if (element instanceof AutoRule)
                return ((AutoRule) element).getQfield().getLabel();
            return element.toString();
        }
    });
    TableViewerColumn col3 = new TableViewerColumn(ruleViewer, SWT.NONE);
    col3.getColumn().setText(Messages.AutoRuleComponent_type);
    col3.getColumn().setWidth(160);
    col3.setLabelProvider(new ZColumnLabelProvider() {
        @Override
        public String getText(Object element) {
            if (element instanceof AutoRule) {
                AutoRule rule = (AutoRule) element;
                if (rule.hasCustomIntervals())
                    return Messages.AutoRuleComponent_custom;
                QueryField qfield = rule.getQfield();
                switch (qfield.getAutoPolicy()) {
                case QueryField.AUTO_DISCRETE:
                    if (qfield.getEnumeration() != null)
                        return Messages.AutoRuleComponent_enum;
                    if (qfield.getType() == QueryField.T_BOOLEAN)
                        return Messages.AutoRuleComponent_bool;
                    return Messages.AutoRuleComponent_discrete;
                case QueryField.AUTO_LINEAR:
                    return Messages.AutoRuleComponent_linear;
                case QueryField.AUTO_LOG:
                    return Messages.AutoRuleComponent_exp;
                case QueryField.AUTO_CONTAINS:
                    return Messages.AutoRuleComponent_arbitrary;
                case QueryField.AUTO_SELECT:
                    return Messages.AutoRuleComponent_multiple;
                }
            }
            return element.toString();
        }
    });
    TableViewerColumn col4 = new TableViewerColumn(ruleViewer, SWT.NONE);
    col4.getColumn().setText(Messages.AutoRuleComponent_parms);
    col4.getColumn().setWidth(220);
    col4.setLabelProvider(new ZColumnLabelProvider() {
        @Override
        public String getText(Object element) {
            if (element instanceof AutoRule) {
                AutoRule rule = (AutoRule) element;
                QueryField qfield = rule.getQfield();
                switch (qfield.getAutoPolicy()) {
                case QueryField.AUTO_CONTAINS:
                case QueryField.AUTO_SELECT:
                    return rule.getValueSpec();
                case QueryField.AUTO_DISCRETE:
                    if (qfield.getEnumeration() != null)
                        return rule.getEnumerationSpec();
                    if (qfield.getType() == QueryField.T_BOOLEAN)
                        return Format.booleanFormatter.toString(Boolean.parseBoolean(rule.getBooleanSpec()));
                    //$FALL-THROUGH$
                default:
                    return rule.getIntervalSpec();
                }
            }
            return element.toString();
        }
    });

    ruleViewer.getTable().setHeaderVisible(true);
    ruleViewer.getTable().setLinesVisible(true);
    GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
    layoutData.heightHint = (style & SWT.SHORT) != 0 ? 150 : 300;
    ruleViewer.getTable().setLayoutData(layoutData);
    ruleViewer.setContentProvider(ArrayContentProvider.getInstance());
    new SortColumnManager(ruleViewer, new int[] { SWT.UP, SWT.UP, SWT.UP, SWT.NONE, SWT.NONE }, 0);
    ruleViewer.setComparator(ZViewerComparator.INSTANCE);
    ruleViewer.getControl().addKeyListener(new KeyAdapter() {
        @Override
        public void keyPressed(KeyEvent e) {
            if (e.keyCode == SWT.CTRL)
                cntrlDwn = true;
        }

        @Override
        public void keyReleased(KeyEvent e) {
            if (e.keyCode == SWT.CTRL)
                cntrlDwn = false;
        }
    });
    ruleViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            updateButtons();
            if (cntrlDwn) {
                if (editAutoButton.isEnabled())
                    editRule();
                cntrlDwn = false;
            }
        }
    });
    ruleViewer.addDoubleClickListener(new IDoubleClickListener() {
        @Override
        public void doubleClick(DoubleClickEvent event) {
            if (!cntrlDwn && editAutoButton.isEnabled())
                editRule();
        }
    });
    ruleViewer.setInput(autoRules);
    Composite autoButtonBar = new Composite(autoGroup, SWT.NONE);
    autoButtonBar.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false));
    autoButtonBar.setLayout(new GridLayout(1, false));
    addAutoButton = new Button(autoButtonBar, SWT.PUSH);
    addAutoButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    addAutoButton.setText(Messages.AutoRuleComponent_add);
    addAutoButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            AutoRuleDialog dialog = new AutoRuleDialog(parent.getShell(), null, autoRules);
            if (dialog.open() == AutoRuleDialog.OK) {
                AutoRule rule = dialog.getRule();
                autoRules.add(rule);
                ruleViewer.add(rule);
                ruleViewer.setSelection(new StructuredSelection(rule));
                fillAccelViewer();
                updateButtons();
            }
        }
    });
    editAutoButton = new Button(autoButtonBar, SWT.PUSH);
    editAutoButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    editAutoButton.setText(Messages.AutoRuleComponent_edit);
    editAutoButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            editRule();
        }
    });
    removeAutoButton = new Button(autoButtonBar, SWT.PUSH);
    removeAutoButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    removeAutoButton.setText(Messages.AutoRuleComponent_remove);
    removeAutoButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            @SuppressWarnings("unchecked")
            Iterator<AutoRule> it = ruleViewer.getStructuredSelection().iterator();
            while (it.hasNext()) {
                AutoRule rule = it.next();
                int index = autoRules.indexOf(rule);
                autoRules.remove(rule);
                if (index >= autoRules.size())
                    --index;
                ruleViewer.remove(rule);
                if (index >= 0)
                    ruleViewer.setSelection(new StructuredSelection(autoRules.get(index)));
            }
            fillAccelViewer();
            updateButtons();
        }
    });
    new Label(autoButtonBar, SWT.SEPARATOR | SWT.HORIZONTAL)
            .setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    applyButton = new Button(autoButtonBar, SWT.PUSH);
    applyButton.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
    applyButton.setText(Messages.AutoRuleComponent_apply);
    applyButton.setToolTipText(Messages.AutoRuleComponent_apply_tooltip);
    applyButton.addSelectionListener(new SelectionAdapter() {
        @SuppressWarnings("unchecked")
        @Override
        public void widgetSelected(SelectionEvent e) {
            IStructuredSelection sel = ruleViewer.getStructuredSelection();
            if (!sel.isEmpty())
                OperationJob.executeSlaveOperation(
                        new AutoRuleOperation(new ArrayList<AutoRule>(sel.toList()), null, null), info, false);
        }
    });
    CGroup accelGroup = UiUtilities.createGroup(composite, 1, Messages.AutoRuleComponent_accel_candidates);
    new Label(accelGroup, SWT.WRAP).setText(Messages.AutoRuleComponent_accel_msg);
    accelViewer = CheckboxTableViewer.newCheckList(accelGroup, SWT.V_SCROLL | SWT.BORDER);
    accelViewer.getTable().setLayoutData(new GridData(400, (style & SWT.SHORT) != 0 ? 50 : 80));
    accelViewer.setContentProvider(ArrayContentProvider.getInstance());
    accelViewer.setLabelProvider(new ZColumnLabelProvider() {
        @Override
        public String getText(Object element) {
            if (element instanceof QueryField)
                return ((QueryField) element).getLabel();
            return element.toString();
        }
    });
    accelViewer.setComparator(ZViewerComparator.INSTANCE);
    updateButtons();
}

From source file:com.bdaum.zoom.ui.internal.dialogs.CategorizeDialog.java

License:Open Source License

@SuppressWarnings("unused")
protected void createProposalArea() {
    Composite proposalArea = new Composite(comp, SWT.NONE);
    proposalArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    proposalArea.setLayout(new GridLayout(1, false));
    proposalTitle = new Label(proposalArea, SWT.NONE);
    proposalTitle.setFont(JFaceResources.getHeaderFont());
    proposalTitle.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
    setProposalTitel();/*from w  w w  . j  ava2s .c om*/
    stack = new Composite(proposalArea, SWT.BORDER);
    stack.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    stackLayout = new StackLayout();
    stack.setLayout(stackLayout);
    PairLabelProvider pairLabelProvider = new PairLabelProvider();
    CategoryLabelProvider catLabelProvider = new CategoryLabelProvider(getVocabManager());
    ISelectionChangedListener selectionChangedListener = new ISelectionChangedListener() {
        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            updateButtons();
        }
    };
    // Unsplit version
    propComp = new Composite(stack, SWT.NONE);
    propComp.setLayout(new GridLayout(2, false));
    Label label = new Label(propComp, SWT.NONE);
    label.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false, 2, 1));
    label.setText(Messages.CategorizeDialog_mark_keywords);

    proposalViewer = CheckboxTableViewer.newCheckList(propComp, SWT.V_SCROLL);
    GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
    layoutData.widthHint = 200;
    proposalViewer.getTable().setLayoutData(layoutData);
    TableViewerColumn col1 = new TableViewerColumn(proposalViewer, SWT.NONE);
    col1.getColumn().setWidth(150);
    col1.setLabelProvider(catLabelProvider);
    TableViewerColumn col2 = new TableViewerColumn(proposalViewer, SWT.NONE);
    col2.getColumn().setWidth(70);

    col2.setLabelProvider(pairLabelProvider);
    proposalViewer.setContentProvider(ArrayContentProvider.getInstance());
    proposalViewer.addDragSupport(DND.DROP_MOVE | DND.DROP_COPY, new Transfer[] { selectionTransfer },
            new ProposalDragSourceListener(proposalViewer));
    proposalViewer.addSelectionChangedListener(selectionChangedListener);
    ZColumnViewerToolTipSupport.enableFor(proposalViewer);

    Composite buttonArea = new Composite(propComp, SWT.NONE);
    buttonArea.setLayoutData(new GridData(SWT.END, SWT.BEGINNING, false, false));
    buttonArea.setLayout(new GridLayout(1, false));
    new AllNoneGroup(buttonArea, new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            proposalViewer.setAllChecked(e.widget.getData() == AllNoneGroup.ALL);
            updateButtons();
        }
    });
    Button button = new Button(buttonArea, SWT.PUSH);
    button.setText(Messages.CategorizeDialog_select_unpaired);
    button.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            Token[] tokens = (Token[]) proposalViewer.getInput();
            for (Token tok : tokens) {
                proposalViewer.setChecked(tok, tok.getMatch() == UNCHECKED);
            }
        }
    });
    // Split version
    splitComp = new Composite(stack, SWT.NONE);
    splitComp.setLayout(new GridLayout(2, false));
    Label catLabel = new Label(splitComp, SWT.NONE);
    catLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, true, false, 2, 1));
    catLabel.setFont(JFaceResources.getBannerFont());
    catLabel.setText(Messages.CategorizeDialog_proposed_as_categories);
    Label catLabel2 = new Label(splitComp, SWT.NONE);
    catLabel2.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, true, false, 2, 1));
    catLabel2.setText(Messages.CategorizeDialog_can_be_marked_as_keywords);
    proposalViewer1 = CheckboxTableViewer.newCheckList(splitComp, SWT.V_SCROLL);
    layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
    layoutData.widthHint = 200;
    layoutData.heightHint = 100;
    proposalViewer1.getTable().setLayoutData(layoutData);
    col1 = new TableViewerColumn(proposalViewer1, SWT.NONE);
    col1.getColumn().setWidth(150);
    col1.setLabelProvider(catLabelProvider);
    col2 = new TableViewerColumn(proposalViewer1, SWT.NONE);
    col2.getColumn().setWidth(70);

    col2.setLabelProvider(pairLabelProvider);
    proposalViewer1.setContentProvider(ArrayContentProvider.getInstance());
    proposalViewer1.addDragSupport(DND.DROP_MOVE | DND.DROP_COPY, new Transfer[] { selectionTransfer },
            new ProposalDragSourceListener(proposalViewer1));
    proposalViewer1.addSelectionChangedListener(selectionChangedListener);
    ColumnViewerToolTipSupport.enableFor(proposalViewer1);

    Composite buttonArea1 = new Composite(splitComp, SWT.NONE);
    buttonArea1.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, true, false));
    buttonArea1.setLayout(new GridLayout(1, false));
    new AllNoneGroup(buttonArea1, new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            proposalViewer1.setAllChecked(e.widget.getData() == AllNoneGroup.ALL);
            updateButtons();
        }
    });
    button = new Button(buttonArea1, SWT.PUSH);
    button.setText(Messages.CategorizeDialog_select_unpaired);
    button.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            Token[] tokens = (Token[]) proposalViewer1.getInput();
            for (Token tok : tokens)
                proposalViewer1.setChecked(tok, tok.getMatch() == UNCHECKED);
        }
    });
    Label keyLabel = new Label(splitComp, SWT.NONE);
    keyLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, true, true, 2, 1));
    keyLabel.setFont(JFaceResources.getBannerFont());
    keyLabel.setText(Messages.CategorizeDialog_proposed_as_keywords);
    proposalViewer2 = CheckboxTableViewer.newCheckList(splitComp, SWT.V_SCROLL);
    layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
    layoutData.widthHint = 200;
    layoutData.heightHint = 300;
    proposalViewer2.getTable().setLayoutData(layoutData);
    proposalViewer2.setLabelProvider(new ColumnLabelProvider());
    proposalViewer2.setContentProvider(ArrayContentProvider.getInstance());
    proposalViewer2.addSelectionChangedListener(selectionChangedListener);

    Composite buttonArea2 = new Composite(splitComp, SWT.NONE);
    buttonArea2.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, true, false));
    buttonArea2.setLayout(new GridLayout(1, false));
    new AllNoneGroup(buttonArea2, new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            proposalViewer2.setAllChecked(e.widget.getData() == AllNoneGroup.ALL);
            updateButtons();
        }
    });
    // Messages
    msgComp = new Composite(stack, SWT.NONE);
    msgComp.setLayout(new GridLayout(1, false));
    msgLabel = new Label(msgComp, SWT.CENTER | SWT.WRAP);
    GridData ldata = new GridData(SWT.FILL, SWT.CENTER, true, true);
    ldata.heightHint = 30;
    msgLabel.setLayoutData(ldata);

    CLink aiLink = new CLink(proposalArea, SWT.NONE);
    aiLink.setText(Messages.CategorizeDialog_configure);
    aiLink.setToolTipText(Messages.CategorizeDialog_user_preferences);
    aiLink.addListener(new Listener() {
        @Override
        public void handleEvent(Event event) {
            if (aiService != null) {
                boolean wasEnabled = aiService.isEnabled();
                if (wasEnabled)
                    Job.getJobManager().cancel(this);
                if (aiService.configure(getShell())) {
                    boolean enabled = aiService.isEnabled();
                    setProposalTitel();
                    List<Asset> reordered;
                    int p = assets.indexOf(currentAsset);
                    reordered = p > 0 ? assets.subList(p, assets.size()) : assets;
                    for (Asset asset : reordered)
                        predictions.remove(asset.getStringId());
                    fillValues(false);
                    // TODO could be improved when language can be
                    // controlled through API
                    if (enabled)
                        startPredictionJob(reordered);
                }
            }
        }
    });
}

From source file:com.bdaum.zoom.ui.internal.dialogs.EditMetaDialog.java

License:Open Source License

@SuppressWarnings("unused")
private void createIndexingGroup(CTabFolder folder) {
    final Composite ixComp = createTabPage(folder, Messages.EditMetaDialog_indexing,
            Messages.EditMetaDialog_configure_index, 1, 0);
    final Composite composite = new Composite(ixComp, SWT.NONE);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    composite.setLayout(new GridLayout());
    noIndexButton = WidgetFactory.createCheckButton(composite, Messages.EditMetaDialog_no_indexing, null);
    noIndexButton.addListener(new Listener() {

        @Override/* w w  w  . j a v a2s.com*/
        public void handleEvent(Event event) {
            updateIndexingControls();
        }
    });
    simComp = new Composite(composite, SWT.NONE);
    simComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    GridLayout layout = new GridLayout(1, false);
    layout.marginWidth = 0;
    simComp.setLayout(layout);
    Label label = new Label(simComp, SWT.WRAP);
    label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    label.setText(Messages.EditMetaDialog_influences_speed);
    label = new Label(simComp, SWT.WRAP);
    label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    label.setText(Messages.EditMetaDialog_configure_index_warning);
    Composite vGroup = new Composite(simComp, SWT.NONE);
    vGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    layout = new GridLayout(2, false);
    layout.marginWidth = 0;
    vGroup.setLayout(layout);
    CGroup simGroup = new CGroup(vGroup, SWT.NONE);
    simGroup.setText(Messages.EditMetaDialog_similarity_algos);
    simGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
    simGroup.setLayout(new GridLayout());
    simViewer = CheckboxTableViewer.newCheckList(simGroup, SWT.FULL_SELECTION | SWT.SINGLE | SWT.V_SCROLL);
    GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    layoutData.heightHint = 200;
    layoutData.widthHint = 400;
    simViewer.getControl().setLayoutData(layoutData);
    simViewer.setContentProvider(ArrayContentProvider.getInstance());
    ZColumnViewerToolTipSupport.enableFor(simViewer, ToolTip.NO_RECREATE);
    simViewer.setComparator(ZViewerComparator.INSTANCE);
    simViewer.setLabelProvider(new ZColumnLabelProvider() {
        @Override
        public String getToolTipText(Object element) {
            if (element instanceof Algorithm && UiActivator.getDefault().getShowHover())
                return ((Algorithm) element).getDescription();
            return super.getToolTipText(element);
        }

        @Override
        public String getText(Object element) {
            return element.toString();
        }

        @Override
        public Image getImage(Object element) {
            if (element instanceof Algorithm && ((Algorithm) element).isAi())
                return Icons.neural.getImage();
            return null;
        }
    });
    Button algoButton = new Button(simGroup, SWT.PUSH);
    algoButton.setLayoutData(new GridData(SWT.END, SWT.CENTER, true, false));
    algoButton.setText(Messages.EditMetaDialog_show_more);
    algoButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent e) {
            essentialAlgos = !essentialAlgos;
            algoButton.setText(
                    essentialAlgos ? Messages.EditMetaDialog_show_more : Messages.EditMetaDialog_show_less);
            updateSelectedAlgorithms();
            Object[] checkedElements = simViewer.getCheckedElements();
            simViewer.setInput(simViewer.getInput());
            simViewer.setCheckedElements(checkedElements);
            simGroup.layout(true, true);
        }
    });
    simViewer.addCheckStateListener(new ICheckStateListener() {
        @Override
        public void checkStateChanged(CheckStateChangedEvent event) {
            validateAlgorithms();
        }
    });
    simViewer.setFilters(new ViewerFilter() {
        @Override
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            if (essentialAlgos && element instanceof Algorithm)
                return ((Algorithm) element).isEssential()
                        || cbirAlgorithms.contains(((Algorithm) element).getName());
            return true;
        }
    });
    simViewer.setInput(Core.getCore().getDbFactory().getLireService(true).getSupportedSimilarityAlgorithms());
    textGroup = new CGroup(vGroup, SWT.NONE);
    textGroup.setText(Messages.EditMetaDialog_fields_in_text_search);
    textGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    textGroup.setLayout(new GridLayout());
    textIndexViewer = new ContainerCheckedTreeViewer(textGroup, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
    setViewerLayout(textIndexViewer, SWT.DEFAULT, 1);
    textIndexViewer.setLabelProvider(new MetadataLabelProvider());
    textIndexViewer.setContentProvider(new MetadataContentProvider());
    textIndexViewer.setFilters(new ViewerFilter[] { new ViewerFilter() {
        @Override
        public boolean select(Viewer aViewer, Object parentElement, Object element) {
            if (element instanceof QueryField && ((QueryField) element).getLabel() != null)
                return isFullTextSearch((QueryField) element);
            return false;
        }

        private boolean isFullTextSearch(QueryField qf) {
            if (qf.hasChildren()) {
                for (QueryField child : qf.getChildren())
                    if (isFullTextSearch(child))
                        return true;
                return false;
            }
            return qf.isFullTextSearch();
        }
    } });
    textIndexViewer.setComparator(ZViewerComparator.INSTANCE);
    UiUtilities.installDoubleClickExpansion(textIndexViewer);
    textIndexViewer.setInput(QueryField.ALL);
    textIndexViewer.expandToLevel(1);
    textIndexViewer.expandToLevel(QueryField.IMAGE_ALL, 1);
    Composite bGroup = new Composite(textGroup, SWT.NONE);
    bGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    bGroup.setLayout(new GridLayout(4, false));
    fileNameButton = WidgetFactory.createCheckButton(bGroup, Messages.EditMetaDialog_file_name, null);
    personsButton = WidgetFactory.createCheckButton(bGroup, Messages.EditMetaDialog_persons_shown,
            new GridData(SWT.BEGINNING, SWT.CENTER, false, false, 3, 1));
    Label sep = new Label(bGroup, SWT.SEPARATOR | SWT.HORIZONTAL);
    sep.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 4, 1));

    Label lab = new Label(bGroup, SWT.NONE);
    lab.setFont(JFaceResources.getBannerFont());
    lab.setText(Messages.EditMetaDialog_slide_shows);
    lab.setLayoutData(new GridData(140, SWT.DEFAULT));
    slideTitleButton = WidgetFactory.createCheckButton(bGroup, Messages.EditMetaDialog_titles, null);
    slideDescrButton = WidgetFactory.createCheckButton(bGroup, Messages.EditMetaDialog_descriptions, null);
    new Label(bGroup, SWT.NONE);
    lab = new Label(bGroup, SWT.NONE);
    lab.setFont(JFaceResources.getBannerFont());
    lab.setText(Messages.EditMetaDialog_exhibitions);
    exhibitionTitleButton = WidgetFactory.createCheckButton(bGroup, Messages.EditMetaDialog_titles, null);
    exhibitionDescrButton = WidgetFactory.createCheckButton(bGroup, Messages.EditMetaDialog_descriptions, null);
    exhibitionCredButton = WidgetFactory.createCheckButton(bGroup, Messages.EditMetaDialog_credits, null);
    lab = new Label(bGroup, SWT.NONE);
    lab.setFont(JFaceResources.getBannerFont());
    lab.setText(Messages.EditMetaDialog_webgalleries);
    webgalleryTitleButton = WidgetFactory.createCheckButton(bGroup, Messages.EditMetaDialog_titles, null);
    webgalleryDescrButton = WidgetFactory.createCheckButton(bGroup, Messages.EditMetaDialog_descriptions, null);
    webgalleryAltButton = WidgetFactory.createCheckButton(bGroup, Messages.EditMetaDialog_alt_texts, null);
}