Search in sources :

Example 1 with OutlineViewSorter

use of org.eclipse.titan.designer.editors.OutlineViewSorter in project titan.EclipsePlug-ins by eclipse.

the class OutlinePage method createControl.

@Override
public void createControl(final Composite parent) {
    super.createControl(parent);
    final IPreferenceStore store = Activator.getDefault().getPreferenceStore();
    viewer = getTreeViewer();
    viewer.setContentProvider(new OutlineContentProvider());
    viewer.setLabelProvider(new OutlineLabelProvider());
    OutlineViewSorter comperator = new OutlineViewSorter();
    comperator.setSortByName(store.getBoolean(PreferenceConstants.OUTLINE_SORTED));
    viewer.setComparator(comperator);
    viewer.setAutoExpandLevel(2);
    viewer.setInput(getModule());
    viewer.addSelectionChangedListener(this);
    IActionBars bars = getSite().getActionBars();
    Action sortToggler = new Action("Sort") {

        @Override
        public void run() {
            ViewerComparator comperator = viewer.getComparator();
            if (comperator == null) {
                comperator = new OutlineViewSorter();
                viewer.setComparator(comperator);
            }
            if (comperator instanceof OutlineViewSorter) {
                store.setValue(PreferenceConstants.OUTLINE_SORTED, isChecked());
                ((OutlineViewSorter) comperator).setSortByName(isChecked());
            }
            viewer.refresh();
        }
    };
    sortToggler.setImageDescriptor(ImageCache.getImageDescriptor("sort_alphabetically.gif"));
    sortToggler.setChecked(store.getBoolean(PreferenceConstants.OUTLINE_SORTED));
    bars.getToolBarManager().add(sortToggler);
}
Also used : Action(org.eclipse.jface.action.Action) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) OutlineViewSorter(org.eclipse.titan.designer.editors.OutlineViewSorter) IActionBars(org.eclipse.ui.IActionBars)

Example 2 with OutlineViewSorter

use of org.eclipse.titan.designer.editors.OutlineViewSorter in project titan.EclipsePlug-ins by eclipse.

the class OutlinePage method createControl.

@Override
public void createControl(final Composite parent) {
    super.createControl(parent);
    final IPreferenceStore store = Activator.getDefault().getPreferenceStore();
    viewer = getTreeViewer();
    viewer.setContentProvider(new OutlineContentProvider());
    viewer.setLabelProvider(new OutlineLabelProvider());
    OutlineViewSorter comperator = new OutlineViewSorter();
    comperator.setSortByName(store.getBoolean(PreferenceConstants.OUTLINE_SORTED));
    comperator.setCategorizing(store.getBoolean(PreferenceConstants.OUTLINE_CATEGORISED));
    viewer.setComparator(comperator);
    ViewerFilter filterGroup = getGroupFilter();
    ViewerFilter filterUnderGroup = getUnderGroupFilter();
    if (store.getBoolean(PreferenceConstants.OUTLINE_GROUPED)) {
        viewer.removeFilter(filterGroup);
        viewer.addFilter(filterUnderGroup);
    } else {
        viewer.removeFilter(filterUnderGroup);
        viewer.addFilter(filterGroup);
    }
    ViewerFilter filter = getHideFunctionsFilter();
    if (store.getBoolean(PreferenceConstants.OUTLINE_HIDE_FUNCTIONS)) {
        viewer.addFilter(filter);
    } else {
        viewer.removeFilter(filter);
    }
    filter = getHideTemplatesFilter();
    if (store.getBoolean(PreferenceConstants.OUTLINE_HIDE_TEMPLATES)) {
        viewer.addFilter(filter);
    } else {
        viewer.removeFilter(filter);
    }
    filter = getHideTypesFilter();
    if (store.getBoolean(PreferenceConstants.OUTLINE_HIDE_TYPES)) {
        viewer.addFilter(filter);
    } else {
        viewer.removeFilter(filter);
    }
    viewer.setAutoExpandLevel(2);
    viewer.setInput(getModule());
    viewer.addSelectionChangedListener(this);
    IActionBars bars = getSite().getActionBars();
    Action sortToggler = new Action(ACTION_SORT) {

        @Override
        public void run() {
            ViewerComparator comperator = viewer.getComparator();
            if (comperator == null) {
                comperator = new OutlineViewSorter();
                viewer.setComparator(comperator);
            }
            if (comperator instanceof OutlineViewSorter) {
                store.setValue(PreferenceConstants.OUTLINE_SORTED, isChecked());
                ((OutlineViewSorter) comperator).setSortByName(isChecked());
            }
            viewer.refresh(false);
        }
    };
    sortToggler.setImageDescriptor(ImageCache.getImageDescriptor("sort_alphabetically.gif"));
    sortToggler.setChecked(store.getBoolean(PreferenceConstants.OUTLINE_SORTED));
    bars.getToolBarManager().add(sortToggler);
    Action categorise = new Action(USE_CATEGORIES) {

        @Override
        public void run() {
            ViewerComparator comperator = viewer.getComparator();
            if (comperator == null) {
                comperator = new OutlineViewSorter();
                viewer.setComparator(comperator);
            }
            if (comperator instanceof OutlineViewSorter) {
                store.setValue(PreferenceConstants.OUTLINE_CATEGORISED, isChecked());
                ((OutlineViewSorter) comperator).setCategorizing(isChecked());
            }
            viewer.refresh(false);
        }
    };
    categorise.setImageDescriptor(ImageCache.getImageDescriptor("categorize.gif"));
    categorise.setChecked(store.getBoolean(PreferenceConstants.OUTLINE_CATEGORISED));
    bars.getToolBarManager().add(categorise);
    Action toggleGroupMode = new Action(ACTION_TOGGLE_GROUP_MODE) {

        @Override
        public void run() {
            ViewerFilter filterGroup = getGroupFilter();
            ViewerFilter filterUnderGroup = getUnderGroupFilter();
            store.setValue(PreferenceConstants.OUTLINE_GROUPED, isChecked());
            if (isChecked()) {
                viewer.removeFilter(filterGroup);
                viewer.addFilter(filterUnderGroup);
            } else {
                viewer.removeFilter(filterUnderGroup);
                viewer.addFilter(filterGroup);
            }
            viewer.refresh(false);
        }
    };
    toggleGroupMode.setImageDescriptor(ImageCache.getImageDescriptor("outline_group.gif"));
    toggleGroupMode.setChecked(store.getBoolean(PreferenceConstants.OUTLINE_GROUPED));
    bars.getToolBarManager().add(toggleGroupMode);
    Action hideFunctions = new Action(ACTION_HIDE_FUNCTIONS) {

        @Override
        public void run() {
            ViewerFilter filter = getHideFunctionsFilter();
            store.setValue(PreferenceConstants.OUTLINE_HIDE_FUNCTIONS, isChecked());
            if (isChecked()) {
                viewer.addFilter(filter);
            } else {
                viewer.removeFilter(filter);
            }
            viewer.refresh(false);
        }
    };
    hideFunctions.setImageDescriptor(ImageCache.getImageDescriptor("filter_functions.gif"));
    hideFunctions.setChecked(store.getBoolean(PreferenceConstants.OUTLINE_HIDE_FUNCTIONS));
    bars.getToolBarManager().add(hideFunctions);
    Action hideTemplates = new Action(ACTION_HIDE_TEMPLATES) {

        @Override
        public void run() {
            ViewerFilter filter = getHideTemplatesFilter();
            store.setValue(PreferenceConstants.OUTLINE_HIDE_TEMPLATES, isChecked());
            if (isChecked()) {
                viewer.addFilter(filter);
            } else {
                viewer.removeFilter(filter);
            }
            viewer.refresh(false);
        }
    };
    hideTemplates.setImageDescriptor(ImageCache.getImageDescriptor("filter_templates.gif"));
    hideTemplates.setChecked(store.getBoolean(PreferenceConstants.OUTLINE_HIDE_TEMPLATES));
    bars.getToolBarManager().add(hideTemplates);
    Action hideTypes = new Action(ACTION_HIDE_TYPES) {

        @Override
        public void run() {
            ViewerFilter filter = getHideTypesFilter();
            store.setValue(PreferenceConstants.OUTLINE_HIDE_TYPES, isChecked());
            if (isChecked()) {
                viewer.addFilter(filter);
            } else {
                viewer.removeFilter(filter);
            }
            viewer.refresh(false);
        }
    };
    hideTypes.setImageDescriptor(ImageCache.getImageDescriptor("filter_types.gif"));
    hideTypes.setChecked(store.getBoolean(PreferenceConstants.OUTLINE_HIDE_TYPES));
    bars.getToolBarManager().add(hideTypes);
}
Also used : Action(org.eclipse.jface.action.Action) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) ViewerComparator(org.eclipse.jface.viewers.ViewerComparator) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) OutlineViewSorter(org.eclipse.titan.designer.editors.OutlineViewSorter) IActionBars(org.eclipse.ui.IActionBars)

Aggregations

Action (org.eclipse.jface.action.Action)2 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)2 ViewerComparator (org.eclipse.jface.viewers.ViewerComparator)2 OutlineViewSorter (org.eclipse.titan.designer.editors.OutlineViewSorter)2 IActionBars (org.eclipse.ui.IActionBars)2 ViewerFilter (org.eclipse.jface.viewers.ViewerFilter)1