--- /dev/null
+/*
+ * Emulator Manager
+ *
+ * Copyright (C) 2015 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * JiHye Kim <jihye424.kim@samsung.com>
+ * Minkee Lee <minkee.lee@samsung.com>
+ * SeokYeon Hwang <syeon.hwang@samsung.com>
+ * Sangho Park <sangho.p@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ */
+
+package org.tizen.emulator.manager.ui.renewal.tableviewer;
+
+import org.eclipse.swt.SWT;
+import org.tizen.emulator.manager.platform.Profile;
+import org.tizen.emulator.manager.ui.table.TableItem;
+import org.tizen.emulator.manager.ui.table.TableItemComparable;
+import org.tizen.emulator.manager.vms.VMProperty;
+
+public class ItemProfilePair extends TableItemComparable {
+ private int priority;
+ public ItemProfilePair(TableItem item, int index, int direction) {
+ super(item, index, direction);
+ Profile profile = ((VMProperty)item.getData()).getPropertyValue().baseImage.getPlatform().getProfileClass();
+ priority = profile.getPriority();
+ }
+
+ @Override
+ public int compareTo(Object o) {
+ int targetPriority = ((ItemProfilePair)o).priority;
+
+ if (direction == SWT.UP) {
+ return priority > targetPriority ? -1 : 1;
+ } else {
+ return priority < targetPriority ? -1 : 1;
+ }
+ }
+
+}
tableSelected();
}
}
+ });
+
+ table.getColumn(2).addListener(SWT.Selection, table.getDefaultSortListener());
+ table.getColumn(3).addListener(SWT.Selection, table.getDefaultSortListener());
+ table.getColumn(4).addListener(SWT.Selection, table.getDefaultSortListener());
+ table.getColumn(5).addListener(SWT.Selection, table.getDefaultSortListener());
+ table.getColumn(1).addListener(SWT.Selection, new Listener() {
+
+ @Override
+ public void handleEvent(Event event) {
+ TableColumn column = (TableColumn)event.widget;
+ // set column
+ table.settingSortColumn(column);
+ // make item compareable list
+ int dir = table.getSortDirection();
+ ItemProfilePair[] pairs = new ItemProfilePair[table.getItemCount()];
+ for (int i = 0; i < table.getItemCount(); i++) {
+ pairs[i] = new ItemProfilePair(table.getItem(i), 1, dir);
+ }
+ column.setTableItemPairs(pairs);
+ // sort table item
+ table.defaultSortTableItem(column);
+ }
});
}