blob: 1687ce976c6fb274cc2f99c3992947a1fd82dd5f [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2004-2008 Istvan Rath and Daniel Varro
* 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:
* Istvan Rath - initial API and implementation
*******************************************************************************/
package org.eclipse.viatra2.frameworkgui.content.transformation;
import java.text.Collator;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerSorter;
import org.eclipse.viatra2.core.IModelElement;
public class ViatraTreeviewSorter extends ViewerSorter {
public ViatraTreeviewSorter() {
super();
}
public ViatraTreeviewSorter(Collator collator) {
super(collator);
}
@Override
public int compare(Viewer viewer, Object arg0, Object arg1) {
IModelElement a0 = (IModelElement) arg0;
IModelElement a1 = (IModelElement) arg1;
if (a0.getClass().equals(a1.getClass()))
return (a0.getName().compareTo(a1.getName()));
else if (a0.isEntity() && a1.isRelation())
return +1;
else
return -1;
}
}