Example usage for org.eclipse.jface.viewers StructuredViewer getComparator

List of usage examples for org.eclipse.jface.viewers StructuredViewer getComparator

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers StructuredViewer getComparator.

Prototype

public ViewerComparator getComparator() 

Source Link

Document

Return this viewer's comparator used to sort elements.

Usage

From source file:com.liferay.ide.portlet.ui.action.SortAction.java

License:Open Source License

/**
 * @param viewer//from  w  ww.j  av a  2s  . co m
 * @param tooltipText
 * @param sorter
 * @param defaultSorter
 * @param listener
 * @param useMiniImage
 */
public SortAction(StructuredViewer viewer, String tooltipText, ViewerComparator sorter,
        ViewerComparator defaultSorter, IPropertyChangeListener listener) {

    super(tooltipText, IAction.AS_CHECK_BOX);
    // Set the tooltip
    setToolTipText(tooltipText);
    // Set the image
    setImageDescriptor(ImageDescriptor
            .createFromURL(PortletUIPlugin.getDefault().getBundle().getEntry("/icons/e16/alphab_sort_co.gif"))); //$NON-NLS-1$
    // Set the default comparator
    fDefaultComparator = defaultSorter;
    // Set the viewer
    fViewer = viewer;
    // Set the comparator
    // If one was not specified, use the default
    if (sorter == null) {
        fComparator = new ViewerComparator();
    } else {
        fComparator = sorter;
    }
    // Determine if the viewer is already sorted
    // Note: Most likely the default comparator is null
    if (viewer.getComparator() == fDefaultComparator) {
        fSorted = false;
    } else {
        fSorted = true;
    }
    // Set the status of this action depending on whether it is sorted or
    // not
    setChecked(fSorted);
    // If a listener was specified, use it
    if (listener != null) {
        addListenerObject(listener);
    }
}

From source file:com.siteview.mde.internal.ui.editor.actions.SortAction.java

License:Open Source License

/**
 * @param viewer//from ww  w  .  j  av  a  2  s  . c  o m
 * @param tooltipText
 * @param sorter
 * @param defaultSorter
 * @param listener
 * @param useMiniImage
 */
public SortAction(StructuredViewer viewer, String tooltipText, ViewerComparator sorter,
        ViewerComparator defaultSorter, IPropertyChangeListener listener) {

    super(tooltipText, IAction.AS_CHECK_BOX);
    // Set the tooltip
    setToolTipText(tooltipText);
    // Set the image
    setImageDescriptor(MDEPluginImages.DESC_ALPHAB_SORT_CO);
    // Set the default comparator
    fDefaultComparator = defaultSorter;
    // Set the viewer
    fViewer = viewer;
    // Set the comparator
    // If one was not specified, use the default
    if (sorter == null) {
        fComparator = new ViewerComparator();
    } else {
        fComparator = sorter;
    }
    // Determine if the viewer is already sorted
    // Note: Most likely the default comparator is null
    if (viewer.getComparator() == fDefaultComparator) {
        fSorted = false;
    } else {
        fSorted = true;
    }
    // Set the status of this action depending on whether it is sorted or
    // not
    setChecked(fSorted);
    // If a listener was specified, use it
    if (listener != null) {
        addListenerObject(listener);
    }
}

From source file:gov.redhawk.ui.actions.SortAction.java

License:Open Source License

/**
 * The Constructor.//from  w  ww.ja va  2s .co  m
 * 
 * @param viewer the viewer
 * @param tooltipText the tooltip text
 * @param sorter the sorter
 * @param defaultSorter the default sorter
 * @param listener the listener
 */
public SortAction(final StructuredViewer viewer, final String tooltipText, final ViewerComparator sorter,
        final ViewerComparator defaultSorter, final IPropertyChangeListener listener) {

    super(tooltipText, IAction.AS_CHECK_BOX);
    // Set the tooltip
    setToolTipText(tooltipText);
    // Set the image
    setImageDescriptor(ScaPluginImages.DESC_ALPHAB_SORT_CO);
    // Set the default comparator
    this.fDefaultComparator = defaultSorter;
    // Set the viewer
    this.fViewer = viewer;
    // Set the comparator
    // If one was not specified, use the default
    if (sorter == null) {
        this.fComparator = new ViewerComparator();
    } else {
        this.fComparator = sorter;
    }
    // Determine if the viewer is already sorted
    // Note: Most likely the default comparator is null
    if (viewer.getComparator() == this.fDefaultComparator) {
        this.fSorted = false;
    } else {
        this.fSorted = true;
    }
    // Set the status of this action depending on whether it is sorted or
    // not
    setChecked(this.fSorted);
    // If a listener was specified, use it
    if (listener != null) {
        addListenerObject(listener);
    }
}

From source file:org.ebayopensource.turmeric.eclipse.ui.actions.SOASortAction.java

License:Open Source License

/**
 * Instantiates a new sOA sort action.//from w  w w.  j av  a2  s .  c  o m
 *
 * @param viewer the viewer
 * @param sorter the sorter
 */
public SOASortAction(StructuredViewer viewer, ViewerComparator sorter) {
    super("", IAction.AS_CHECK_BOX);
    setText(getTitle());
    setToolTipText(getToolTip());
    setImageDescriptor(UIActivator.getImageDescriptor("icons/sort.gif"));
    fViewer = viewer;
    // Set the comparator
    // If one was not specified, use the default
    if (sorter == null) {
        fComparator = new ViewerComparator();
    } else {
        fComparator = sorter;
    }
    // Determine if the viewer is already sorted
    // Note: Most likely the default comparator is null
    if (viewer.getComparator() != sorter) {
        fSorted = false;
    } else {
        fSorted = true;
    }
    // Set the status of this action depending on whether it is sorted or
    // not
    setChecked(fSorted);
}

From source file:org.eclipse.pde.internal.ui.editor.actions.SortAction.java

License:Open Source License

/**
 * @param viewer/*from  ww w . j  a v  a  2 s  .c om*/
 * @param tooltipText
 * @param sorter
 * @param defaultSorter
 * @param listener
 * @param useMiniImage
 */
public SortAction(StructuredViewer viewer, String tooltipText, ViewerComparator sorter,
        ViewerComparator defaultSorter, IPropertyChangeListener listener) {

    super(tooltipText, IAction.AS_CHECK_BOX);
    // Set the tooltip
    setToolTipText(tooltipText);
    // Set the image
    setImageDescriptor(PDEPluginImages.DESC_ALPHAB_SORT_CO);
    // Set the default comparator
    fDefaultComparator = defaultSorter;
    // Set the viewer
    fViewer = viewer;
    // Set the comparator
    // If one was not specified, use the default
    if (sorter == null) {
        fComparator = new ViewerComparator();
    } else {
        fComparator = sorter;
    }
    // Determine if the viewer is already sorted
    // Note: Most likely the default comparator is null
    if (viewer.getComparator() == fDefaultComparator) {
        fSorted = false;
    } else {
        fSorted = true;
    }
    // Set the status of this action depending on whether it is sorted or
    // not
    setChecked(fSorted);
    // If a listener was specified, use it
    if (listener != null) {
        addListenerObject(listener);
    }
}

From source file:org.seasar.uruma.debug.action.UrumaDebugViewAction.java

License:Apache License

private void createWidgetHandle(final WidgetHandle wh) {
    html += HtmlTagUtil.createTrSub1("WidgetHandle Id", wh.getId());
    html += HtmlTagUtil.createTr("Class Name", wh.getClass().getName());
    html += HtmlTagUtil.createTr("widgetClass", wh.getWidgetClass().getName());

    if (StructuredViewer.class.isAssignableFrom(wh.getWidgetClass())) {
        StructuredViewer viewer = wh.<StructuredViewer>getCastWidget();
        html += HtmlTagUtil.createTr("LabelProvider", getSimpleName(viewer.getLabelProvider()));
        html += HtmlTagUtil.createTr("ContentProvider", getSimpleName(viewer.getContentProvider()));
        html += HtmlTagUtil.createTr("Comparator", getSimpleName(viewer.getComparator()));
        html += HtmlTagUtil.createTr("Sorter", getSimpleName(viewer.getSorter()));

    } else if (GenericAction.class.isAssignableFrom(wh.getWidgetClass())) {
        // TODO ?
    } else if (UrumaApplicationWindow.class.isAssignableFrom(wh.getWidgetClass())) {
        // TODO ?
    } else if (Widget.class.isAssignableFrom(wh.getWidgetClass())) {
        // TODO ?
    } else if (MenuManager.class.isAssignableFrom(wh.getWidgetClass())) {
        // TODO ?
    } else if (Control.class.isAssignableFrom(wh.getWidgetClass())) {
        // TODO ?
    }//from  w  w  w . j a va  2  s . c om

    UIComponent uc = wh.getUiComponent();
    if (uc != null) {
        html += HtmlTagUtil.createTrSub2("UIComponent id", uc.getId());
        html += HtmlTagUtil.createTr("Class Name", uc.getClass().getName());
        html += HtmlTagUtil.createTr("ParentURL", uc.getParentURL().toString());
        html += HtmlTagUtil.createTr("Location", uc.getLocation());
        html += HtmlTagUtil.createTr("URL", uc.getURL().toString());
        html += HtmlTagUtil.createTr("style", uc.getStyle());
        html += HtmlTagUtil.createTr("renderer", uc.getRenderer().getClass().getName());
    }
}