org.dslforge.workspace.ui.BasicViewerComparator.java Source code

Java tutorial

Introduction

Here is the source code for org.dslforge.workspace.ui.BasicViewerComparator.java

Source

/**
 * <copyright>
 *
 * Copyright (c) 2015 PlugBee. All rights reserved.
 * 
 * This program and the accompanying materials are made available 
 * under the terms of the Eclipse Public License v1.0 which 
 * accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Amine Lajmi - Initial API and implementation
 *
 * </copyright>
 */
package org.dslforge.workspace.ui;

import java.io.File;

import org.eclipse.jface.viewers.ViewerComparator;

@SuppressWarnings("serial")
public class BasicViewerComparator extends ViewerComparator {

    @Override
    public int category(Object element) {
        if (element instanceof File) {
            File file = (File) element;
            if (file.isDirectory())
                return 0;
            else
                return 1;
        }
        return super.category(element);
    }
}