Example usage for org.eclipse.jface.resource JFaceResources getBannerFont

List of usage examples for org.eclipse.jface.resource JFaceResources getBannerFont

Introduction

In this page you can find the example usage for org.eclipse.jface.resource JFaceResources getBannerFont.

Prototype

public static Font getBannerFont() 

Source Link

Document

Returns the JFace's banner font.

Usage

From source file:com.bdaum.zoom.css.ZColumnLabelProvider.java

License:Open Source License

protected Font getFont(Object element) {
    if (element instanceof ITitle)
        return JFaceResources.getBannerFont();
    return null;//from w  w w  . j  av  a 2  s .c o m
}

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);//www.j  a  v a2 s  .c om
    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;/*  w w w .  ja va  2  s.c om*/
    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);/*  www.j  a  v  a  2  s  . c  o m*/
    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.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();/*www.j  av a 2s . 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/*from   w w  w .  j  av a 2s  .  c o m*/
        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);
}

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

License:Open Source License

protected void updateTabItems() {
    CTabItem selection = tabFolder.getSelection();
    for (CTabItem item : tabFolder.getItems())
        item.setFont(selection == item ? JFaceResources.getBannerFont() : JFaceResources.getDefaultFont());
}

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

License:Open Source License

public KeywordGroup(Composite area, String[] selectedKeywords, Set<String> predefinedKeywords,
        List<String> recentKeywords, boolean tags, IDialogSettings settings) {
    this.selectedKeywords = selectedKeywords;
    this.recentKeywords = recentKeywords;
    this.tags = tags;
    if (tags) {//from  w  w w. ja va  2 s.c  o  m
        meta = Core.getCore().getDbManager().getMeta(true);
        externalKeywords = new HashSet<String>(predefinedKeywords);
        externalKeywords.removeAll(meta.getKeywords());
    } else
        vocabManager = new VocabManager(Core.getCore().getDbManager().getMeta(true).getVocabularies(), this);
    Composite composite = new Composite(area, SWT.NONE);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    composite.setLayout(new GridLayout());
    if (recentKeywords != null) {
        Set<String> recentSet = new HashSet<String>(recentKeywords);
        recentSet.retainAll(predefinedKeywords);
        if (!recentSet.isEmpty()) {
            CGroup recentGroup = new CGroup(composite, SWT.NONE);
            recentGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
            recentGroup
                    .setText(tags ? Messages.KeywordGroup_recent_tags : Messages.KeywordGroup_recent_keywords);
            recentGroup.setLayout(new GridLayout());
            recentViewer = CheckboxTableViewer.newCheckList(recentGroup, SWT.NO_SCROLL | SWT.V_SCROLL);
            GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1);
            layoutData.heightHint = 100;
            recentViewer.getControl().setLayoutData(layoutData);
            recentViewer.setContentProvider(ArrayContentProvider.getInstance());
            recentViewer.setComparator(ZViewerComparator.INSTANCE);
            recentViewer.setLabelProvider(new KeywordLabelProvider(vocabManager, null));
            ZColumnViewerToolTipSupport.enableFor(recentViewer);
            recentViewer.setInput(recentSet);
            if (selectedKeywords != null)
                for (String kw : selectedKeywords)
                    if (kw != null && recentKeywords.contains(kw))
                        recentViewer.setChecked(kw, true);
            recentViewer.addCheckStateListener(new ICheckStateListener() {
                public void checkStateChanged(CheckStateChangedEvent event) {
                    String element = (String) event.getElement();
                    boolean checked = event.getChecked();
                    if (checked) {
                        appliedKeywords.add(element);
                        availableKeywords.remove(element);
                    } else {
                        appliedKeywords.remove(element);
                        availableKeywords.add(element);
                    }
                    updateKeywordViewer(element);
                }
            });
        }
    }
    CGroup keywordsGroup = new CGroup(composite, SWT.NONE);
    keywordsGroup.setText(tags ? Messages.KeywordGroup_all_tags : Messages.KeywordGroup_all_keywords);
    keywordsGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    keywordsGroup.setLayout(new GridLayout(3, false));
    radioGroup = new FlatGroup(keywordsGroup, SWT.NONE, settings, "hierarchicalKeywords"); //$NON-NLS-1$
    radioGroup.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false, 2, 1));
    radioGroup.addListener(new Listener() {
        @Override
        public void handleEvent(Event event) {
            updateKeywordViewer(((IStructuredSelection) viewer.getSelection()).getFirstElement());
        }
    });
    ExpandCollapseGroup expandCollapseGroup = new ExpandCollapseGroup(keywordsGroup, SWT.NONE);
    final FilterField filterField = new FilterField(keywordsGroup);
    GridData layoutData = new GridData(SWT.BEGINNING, SWT.CENTER, true, false, tags ? 3 : 2, 1);
    layoutData.widthHint = 300;
    filterField.setLayoutData(layoutData);
    filterField.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            viewer.setInput(viewer.getInput());
            viewer.expandAll();
        }
    });
    if (!tags) {
        final CheckboxButton excludeButton = WidgetFactory.createCheckButton(keywordsGroup,
                Messages.KeywordGroup_exclude_geographic, new GridData(SWT.END, SWT.CENTER, true, false));
        excludeButton.addListener(new Listener() {
            @Override
            public void handleEvent(Event event) {
                excludeGeographic = excludeButton.getSelection();
                updateKeywordViewer(null);
            }
        });
    }
    viewer = new CheckboxTreeViewer(keywordsGroup, SWT.NO_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.VIRTUAL);
    expandCollapseGroup.setViewer(viewer);
    layoutData = new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1);
    layoutData.heightHint = tags ? 200 : 300;
    viewer.getControl().setLayoutData(layoutData);
    viewer.setContentProvider(new KeywordContentProvider());
    KeywordLabelProvider labelProvider = new KeywordLabelProvider(vocabManager, ROOT) {
        @Override
        public Font getFont(Object element) {
            if (externalKeywords != null && externalKeywords.contains(element))
                return JFaceResources.getBannerFont();
            return super.getFont(element);
        }
    };
    viewer.setLabelProvider(labelProvider);
    viewer.setFilters(new ViewerFilter[] { new ViewerFilter() {
        @Override
        public boolean select(Viewer aViewer, Object parentElement, Object element) {
            if (element == AVAILABLE || element == APPLIED || element instanceof Character)
                return true;
            WildCardFilter filter = filterField.getFilter();
            return filter == null || filter.accept(labelProvider.getText(element));
        }
    } });
    UiUtilities.installDoubleClickExpansion(viewer);
    ZColumnViewerToolTipSupport.enableFor(viewer);
    availableKeywords = new HashSet<String>(predefinedKeywords);
    if (selectedKeywords != null)
        for (String kw : selectedKeywords)
            if (kw != null && predefinedKeywords.contains(kw))
                appliedKeywords.add(kw);
    availableKeywords.removeAll(appliedKeywords);
    keywordVerifyListener = new KeywordVerifyListener(viewer);
    updateKeywordViewer(null);
    if (externalKeywords != null) {
        importButton = new Button(keywordsGroup, SWT.PUSH);
        importButton.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
        importButton.setText(Messages.KeywordGroup_import_into_catalog);
        if (!externalKeywords.isEmpty())
            importButton.addSelectionListener(new SelectionAdapter() {
                @Override
                public void widgetSelected(SelectionEvent e) {
                    Set<String> newKeywords = meta.getKeywords();
                    newKeywords.addAll(externalKeywords);
                    ModifyMetaOperation op = new ModifyMetaOperation(meta, false, null, null, null, null, null,
                            null, null, null, meta.getCumulateImports(), null, null, newKeywords, null, null,
                            meta.getThumbnailFromPreview(), null, null, meta.getFolderWatchLatency(),
                            meta.getPauseFolderWatch(), meta.getReadonly(), meta.getAutoWatch(),
                            meta.getSharpen(), meta.getWebpCompression(), meta.getJpegQuality(),
                            meta.getNoIndex(), meta.getLocale(), meta.getCbirAlgorithms(),
                            meta.getIndexedTextFields(), meta.getPersonsToKeywords(), null,
                            meta.getVocabularies());
                    OperationJob.executeOperation(op, KeywordGroup.this);
                    importButton.setEnabled(false);
                    availableKeywords.addAll(externalKeywords);
                    externalKeywords.clear();
                    updateKeywordViewer(null);
                }
            });
        else
            importButton.setEnabled(false);
    }
    CGroup newKeywordsGroup = new CGroup(composite, SWT.NONE);
    newKeywordsGroup.setText(tags ? Messages.KeywordGroup_new_tags : Messages.KeywordGroup_new_keywords);
    boolean hasVocab = vocabManager != null && vocabManager.getVocabTree() != null;
    newKeywordsGroup.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 3, 1));
    newKeywordsGroup.setLayout(new GridLayout(hasVocab ? 2 : 1, false));
    GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
    data.heightHint = 50;
    newKeywordField = new CheckedText(newKeywordsGroup, SWT.BORDER | SWT.MULTI);
    newKeywordField.setLayoutData(data);
    newKeywordField.setSpellingOptions(8, ISpellCheckingService.KEYWORDOPTIONS);
    if (hasVocab) {
        Button button = new Button(newKeywordsGroup, SWT.PUSH);
        button.setLayoutData(new GridData(SWT.END, SWT.FILL, false, false));
        button.setText(Messages.KeywordGroup_vocab);
        button.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                ViewVocabDialog dialog = new ViewVocabDialog(composite.getShell(), vocabManager.getVocabTree(),
                        null, true);
                if (dialog.open() == ViewVocabDialog.OK) {
                    addSelectedKeywords(dialog.getResult());
                    updateVocabLabel();
                }
            }
        });
        vocabLabel = new CLabel(newKeywordsGroup, SWT.NONE);
        vocabLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
        vocabLabel.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseDoubleClick(MouseEvent e) {
                if (synonym != null) {
                    StringTokenizer st = new StringTokenizer(newKeywordField.getText(), "\n"); //$NON-NLS-1$
                    StringBuilder sb = new StringBuilder();
                    while (st.hasMoreTokens()) {
                        String token = st.nextToken().trim();
                        if (token.equals(synonym))
                            token = replacement;
                        if (token != null) {
                            if (sb.length() > 0)
                                sb.append('\n');
                            sb.append(token);
                        }
                    }
                    newKeywordField.removeVerifyListener(keywordVerifyListener);
                    newKeywordField.setText(sb.toString());
                    newKeywordField.addVerifyListener(keywordVerifyListener);
                    updateVocabLabel();
                }
            }
        });
        newKeywordField.addModifyListener(new ModifyListener() {
            @Override
            public void modifyText(ModifyEvent e) {
                updateVocabLabel();
            }
        });
    }
    viewer.addCheckStateListener(new ICheckStateListener() {
        public void checkStateChanged(CheckStateChangedEvent event) {
            Object e = event.getElement();
            if (e instanceof String) {
                String element = (String) e;
                boolean checked = event.getChecked();
                if (recentViewer != null)
                    recentViewer.setChecked(element, checked);
                if (checked) {
                    if (element != APPLIED && element != AVAILABLE) {
                        appliedKeywords.add(element);
                        availableKeywords.remove(element);
                    }
                } else if (element == APPLIED) {
                    availableKeywords.addAll(appliedKeywords);
                    appliedKeywords.clear();
                } else if (element != AVAILABLE) {
                    appliedKeywords.remove(element);
                    availableKeywords.add(element);
                }
                updateKeywordViewer(element);
                if (recentViewer != null)
                    recentViewer.setCheckedElements(appliedKeywords.toArray());
            } else
                updateKeywordViewer(e);
        }
    });
    StringBuilder sb = new StringBuilder();
    if (selectedKeywords != null)
        for (String kw : QueryField.getKeywordFilter().filter(selectedKeywords))
            if (kw != null && !predefinedKeywords.contains(kw)) {
                if (sb.length() > 0)
                    sb.append('\n');
                sb.append(kw);
            }
    newKeywordField.setText(sb.toString());
    newKeywordField.addVerifyListener(keywordVerifyListener);
    newKeywordField.setFocus();
}

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

License:Open Source License

@Override
public Font getFont(Object element) {
    return getAssetId(element) == null ? JFaceResources.getBannerFont() : null;
}

From source file:com.bdaum.zoom.ui.internal.UiUtilities.java

License:Open Source License

/**
 * Creates a tab item/*  w ww.  ja v  a2  s  .co  m*/
 *
 * @param tabFolder
 *            - tab folder
 * @param text
 *            - tab item label
 * @param tooltip
 *            - tool tip
 * @return - tab item
 */
public static CTabItem createTabItem(CTabFolder tabFolder, String text, String tooltip) {
    CTabItem tabItem = new CTabItem(tabFolder, SWT.NONE);
    tabItem.setFont(JFaceResources.getBannerFont());
    tabItem.setText(' ' + text + ' ');
    if (tooltip != null)
        tabItem.setToolTipText(tooltip);
    return tabItem;
}