Skip to content
Snippets Groups Projects
Commit 5be1d922 authored by Simon Barner's avatar Simon Barner
Browse files

Move HierarchicalNameViewerComparator to kernel.ui

* Generalize interface to IModelElement
* Use anonymous class in GenericAnnotationView to adapt AnnotationEntry
  elements

Issue-Ref: 3223
Issue-Url: https://af3-developer.fortiss.org/issues/3223



Signed-off-by: default avatarSimon Barner <barner@fortiss.org>
parent 4cee192b
No related branches found
No related tags found
1 merge request!293223: Refactorying of hierarchical name (viewer) comparator
ColumnHandle.java 8fc5f04cbb0127e5df8c7a9e3b2620502bf93716 GREEN
GenericAnnotationView.java 9ece325e33056bc866aa842a7be5e0be3db84fe0 GREEN
HierarchicalNameViewerComparator.java c12e9216387618c518f7e7c15d21179a86aad472 GREEN
GenericAnnotationView.java 0fea0eafedcf1d24ea9faa34d84f3044443f951f YELLOW
......@@ -17,6 +17,7 @@ package org.fortiss.tooling.base.ui.annotation.view.generic;
import static org.fortiss.tooling.base.ui.annotation.editingsupport.EditingSupportFactory.createEditingSupport;
import static org.fortiss.tooling.base.ui.annotation.labelprovider.LabelProviderFactory.createLabelProvider;
import static org.fortiss.tooling.kernel.utils.HierarchicalNameComparator.compareByNameIdHashCode;
import java.lang.reflect.Method;
import java.util.Collection;
......@@ -41,6 +42,7 @@ import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerCell;
import org.eclipse.jface.window.ToolTip;
import org.eclipse.swt.SWT;
......@@ -81,6 +83,7 @@ import org.fortiss.tooling.base.ui.annotation.view.generic.filter.AnnotationFilt
import org.fortiss.tooling.base.ui.dialog.MultiFieldInputDialog;
import org.fortiss.tooling.kernel.extension.data.ITopLevelElement;
import org.fortiss.tooling.kernel.service.IPersistencyService;
import org.fortiss.tooling.kernel.ui.util.HierarchicalNameViewerComparator;
/**
* <p>
......@@ -504,7 +507,18 @@ public class GenericAnnotationView extends AnnotationViewPartBase {
fixedColumnCount = createFixedModelElementColumns();
columnWidthCache = new HashMap<String, Integer>();
tableViewer.setComparator(new HierarchicalNameViewerComparator());
tableViewer.setComparator(new HierarchicalNameViewerComparator() {
/** {@inheritDoc} */
@Override
public int compare(Viewer viewer, Object o1, Object o2) {
if(o1 instanceof AnnotationEntry && o2 instanceof AnnotationEntry) {
return super.compare(viewer, ((AnnotationEntry)o1).getModelElement(),
((AnnotationEntry)o2).getModelElement());
}
return compareByNameIdHashCode(o1, o2);
}
});
tableViewer.setComparer(new IElementComparer() {
......
......@@ -4,6 +4,7 @@ CopyPasteUtils.java bbc5cf9c9dc03ebf8dc75d42c919fe6eb60b388e GREEN
DataBindingUtils.java 6ae66457694227b69c13c092ef62babdd4a2a137 GREEN
DragAndDropUtils.java 7aab91518aa12d76533a345bf6ed0be9ac7ff0e5 GREEN
EObjectSelectionUtils.java 128cf8f96c6b9478171dff3deda662d5934f5f44 GREEN
HierarchicalNameViewerComparator.java f9a2a8add3ea2bedfa40bcde25b35389cb2dd005 YELLOW
KernelUIUtils.java 46d3279ef3523b104f89a6c526109f72d36f72f2 GREEN
ObservableUtils.java 34abfd1dfaf9c0acbb31caf1f525e7b39416c116 GREEN
PropertiesConstantUtils.java 59b1a1e4d594bb98db3aa396f2ff6474ba405920 GREEN
......
......@@ -13,20 +13,20 @@
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.ui.annotation.view.generic;
package org.fortiss.tooling.kernel.ui.util;
import static org.fortiss.tooling.kernel.utils.HierarchicalNameComparator.compareByNameIdHashCode;
import java.util.Comparator;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;
import org.fortiss.tooling.base.annotation.AnnotationEntry;
import org.fortiss.tooling.kernel.utils.HierarchicalNameComparator;
/**
* {@link ViewerComparator} that sorts rows according to hierarchy level. Elements within one
* hierarchy level are sorted by name.
* {@link ViewerComparator} whose {@link #compare(Viewer, Object, Object)} method sorts
* {@link EObject} model elements by wrapping {@link HierarchicalNameComparator}).
*
* @author barner
*/
......@@ -38,9 +38,8 @@ public class HierarchicalNameViewerComparator extends ViewerComparator {
/** {@inheritDoc} */
@Override
public int compare(Viewer viewer, Object o1, Object o2) {
if(o1 instanceof AnnotationEntry && o2 instanceof AnnotationEntry) {
return comp.compare(((AnnotationEntry)o1).getModelElement(),
((AnnotationEntry)o2).getModelElement());
if(o1 instanceof EObject && o2 instanceof EObject) {
return comp.compare((EObject)o1, (EObject)o2);
}
return compareByNameIdHashCode(o1, o2);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment