Java 类org.eclipse.ui.texteditor.ConfigurationElementSorter 实例源码

项目:Eclipse-Postfix-Code-Completion    文件:JavaPlugin.java   
/**
 * Returns all Java editor text hovers contributed to the workbench.
 *
 * @return an array of JavaEditorTextHoverDescriptor
 * @since 2.1
 */
public synchronized JavaEditorTextHoverDescriptor[] getJavaEditorTextHoverDescriptors() {
    if (fJavaEditorTextHoverDescriptors == null) {
        fJavaEditorTextHoverDescriptors= JavaEditorTextHoverDescriptor.getContributedHovers();
        ConfigurationElementSorter sorter= new ConfigurationElementSorter() {
            /*
             * @see org.eclipse.ui.texteditor.ConfigurationElementSorter#getConfigurationElement(java.lang.Object)
             */
            @Override
            public IConfigurationElement getConfigurationElement(Object object) {
                return ((JavaEditorTextHoverDescriptor)object).getConfigurationElement();
            }
        };
        sorter.sort(fJavaEditorTextHoverDescriptors);

        // Move Best Match hover to front
        for (int i= 0; i < fJavaEditorTextHoverDescriptors.length - 1; i++) {
            if (PreferenceConstants.ID_BESTMATCH_HOVER.equals(fJavaEditorTextHoverDescriptors[i].getId())) {
                JavaEditorTextHoverDescriptor hoverDescriptor= fJavaEditorTextHoverDescriptors[i];
                for (int j= i; j > 0; j--)
                    fJavaEditorTextHoverDescriptors[j]= fJavaEditorTextHoverDescriptors[j-1];
                fJavaEditorTextHoverDescriptors[0]= hoverDescriptor;
                break;
            }

        }
    }

    return fJavaEditorTextHoverDescriptors;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavaPlugin.java   
/**
 * Returns all Java editor text hovers contributed to the workbench.
 *
 * @return an array of JavaEditorTextHoverDescriptor
 * @since 2.1
 */
public synchronized JavaEditorTextHoverDescriptor[] getJavaEditorTextHoverDescriptors() {
    if (fJavaEditorTextHoverDescriptors == null) {
        fJavaEditorTextHoverDescriptors= JavaEditorTextHoverDescriptor.getContributedHovers();
        ConfigurationElementSorter sorter= new ConfigurationElementSorter() {
            /*
             * @see org.eclipse.ui.texteditor.ConfigurationElementSorter#getConfigurationElement(java.lang.Object)
             */
            @Override
            public IConfigurationElement getConfigurationElement(Object object) {
                return ((JavaEditorTextHoverDescriptor)object).getConfigurationElement();
            }
        };
        sorter.sort(fJavaEditorTextHoverDescriptors);

        // Move Best Match hover to front
        for (int i= 0; i < fJavaEditorTextHoverDescriptors.length - 1; i++) {
            if (PreferenceConstants.ID_BESTMATCH_HOVER.equals(fJavaEditorTextHoverDescriptors[i].getId())) {
                JavaEditorTextHoverDescriptor hoverDescriptor= fJavaEditorTextHoverDescriptors[i];
                for (int j= i; j > 0; j--)
                    fJavaEditorTextHoverDescriptors[j]= fJavaEditorTextHoverDescriptors[j-1];
                fJavaEditorTextHoverDescriptors[0]= hoverDescriptor;
                break;
            }

        }
    }

    return fJavaEditorTextHoverDescriptors;
}