<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="jaxb_src"/>
<classpathentry kind="src" path="resource"/>
- <classpathentry kind="lib" path="lib/swt/gtk-linux/swt-debug.jar"/>
+ <classpathentry kind="lib" path="lib/swt/gtk-linux/swt-debug.jar" sourcepath="lib/swt/gtk-linux/src.zip"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="output" path="bin"/>
</classpath>
import org.tizen.emulator.manager.vms.VMsProperty;
public class EmulatorManager {
+ private static final String ICON_FILE_NAME = "res/em.ico";
+
private static EmulatorManager instance;
Display display;
shell.setText("Emulator Manager");
shell.setLayout(new FillLayout());
- InputStream is = this.getClass().getClassLoader().getResourceAsStream("res/em.ico");
+ InputStream is = this.getClass().getClassLoader().getResourceAsStream(ICON_FILE_NAME);
if(is != null) {
icon = new Image(display, is);
shell.setImage(icon);
// Left : VMs Table
{
final Composite leftView = new Composite(sashForm, SWT.FILL);
- GridLayout gl = new GridLayout(1, false);
- gl.horizontalSpacing = 0;
- gl.verticalSpacing = 0;
- gl.marginBottom = 0;
- gl.marginHeight = 0;
- gl.marginLeft = 0;
- gl.marginRight = 0;
- gl.marginTop = 0;
- gl.marginWidth = 0;
- leftView.setLayout(gl);
+ GridLayout layout = getNopaddedGridLayout();
+ leftView.setLayout(layout);
imageListTable = new VMsTable(this, leftView);
SelectionListener archSelectionListener = new SelectionListener() {
// LEFT : detail table
{
final Composite rightView = new Composite(sashForm, SWT.FILL);
- GridLayout gl = new GridLayout(1, false);
- gl.horizontalSpacing = 0;
- gl.verticalSpacing = 0;
- gl.marginBottom = 0;
- gl.marginHeight = 0;
- gl.marginLeft = 0;
- gl.marginRight = 0;
- gl.marginTop = 0;
- gl.marginWidth = 0;
- rightView.setLayout(gl);
+ GridLayout layout = getNopaddedGridLayout();
+ rightView.setLayout(layout);
detailView = new DetailTableView(this);
detailView.createDetailView(shell, rightView);
EmulatorVMs.getInstance().refreshProperties();
imageListTable.refreshTableList();
}
+
+ public int[] getSashFormWeight() {
+ return sashForm.getWeights();
+ }
- public void setDetailViewWeights(int weight) {
- sashForm.setWeights(new int[] {100-weight, weight});
+ public void setDetailViewWeights(int[] weight) {
+ sashForm.setWeights(weight);
}
public void openDetailView(VMsProperty property) {
}
public void closeDetailView() {
- if (imageListTable.getCountSelectionItem() > 1) {
+ if (imageListTable.getSelectionContentCount() > 1) {
deleteButton.setEnabled(true);
} else {
deleteButton.setEnabled(false);
public void dispose() {
ResourceRegistry.dispose();
}
+
+ private GridLayout getNopaddedGridLayout() {
+ GridLayout layout = new GridLayout(1, false);
+ layout.horizontalSpacing = 0;
+ layout.verticalSpacing = 0;
+ layout.marginBottom = 0;
+ layout.marginHeight = 0;
+ layout.marginLeft = 0;
+ layout.marginRight = 0;
+ layout.marginTop = 0;
+ layout.marginWidth = 0;
+
+ return layout;
+ }
}
import java.util.HashMap;
import java.util.Map;
+import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
import org.tizen.emulator.manager.EmulatorManager;
}
}
+ public enum FontType {
+ BOLD("bold");
+
+ String name;
+
+ FontType(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public String toString() {
+ return name;
+ }
+ }
+
private static ResourceRegistry instance;
Map<ImageName, Image> imagesMap = new HashMap<ImageName, Image>();
}
}
- public static Image getImage(ImageName imageName) {
- return instance.imagesMap.get(imageName);
+ Map<Integer, Font> fontsMap = new HashMap<Integer, Font>();
+
+ public static Image getImage(ImageName imagename) {
+ return instance.imagesMap.get(imagename);
+ }
+
+ public static void addFont(int fontStyle, Font font) {
+ instance.fontsMap.put(fontStyle, font);
+ }
+
+ public static Font getFont(int fonttype) {
+ return instance.fontsMap.get(fonttype);
}
public static void dispose() {
for(Image image : instance.imagesMap.values()) {
image.dispose();
}
+
+ for(Font font : instance.fontsMap.values()) {
+ font.dispose();
+ }
}
private ResourceRegistry() {}
import org.tizen.emulator.manager.vms.VMsProperty;
public class DetailTableView {
+ static final int[] DEFAULT_WEIGHT = new int[] { 60, 40 };
+
private static String Modify = "Modify";
private static String Create = "Create";
private static String Detail = "Datail";
private VMsProperty currentProperty;
private VMPropertyView vmView = null;
+ private int[] weight = new int[] { 60, 40 };
public DetailTableView(MainDialog mainDialog) {
this.mainDialog = mainDialog;
detailTable.getColumn(1).pack();
if(!isDetailOpened) {
- mainDialog.setDetailViewWeights(40);
+ mainDialog.setDetailViewWeights(weight);
isDetailOpened = true;
}
}
} else if (isCreateState) {
closeCreateView();
}
-
- mainDialog.setDetailViewWeights(0);
- isDetailOpened = false;
+
+ if(isDetailOpened) {
+ weight = mainDialog.getSashFormWeight();
+ mainDialog.setDetailViewWeights(new int[] { 100, 0 });
+ isDetailOpened = false;
+ }
}
public void openModifyView(VMsProperty property, Button confirmButton)
detailTable.setEnabled(false);
if (!isDetailOpened) {
- mainDialog.setDetailViewWeights(40);
+ mainDialog.setDetailViewWeights(weight);
isDetailOpened = true;
}
}
import org.eclipse.swt.widgets.Text;
import org.tizen.emulator.manager.ui.ResourceRegistry;
import org.tizen.emulator.manager.ui.ResourceRegistry.ImageName;
-import org.tizen.emulator.manager.vms.EmulatorVMs;
import org.tizen.emulator.manager.vms.VMCreateHelper;
import org.tizen.emulator.manager.vms.VMProcess;
import org.tizen.emulator.manager.vms.VMPropertyValue;
--- /dev/null
+package org.tizen.emulator.manager.ui.vmstree;
+
+import org.tizen.emulator.manager.vms.VMsProperty;
+import org.tizen.emulator.manager.vms.xml.DeviceType;
+import org.tizen.emulator.manager.vms.xml.DisplayType;
+
+
+// TODO: Support dynamic column editing...
+public abstract class ColumnContentHelper {
+ static final int numberOfColumns = 4;
+ static final String[] columnTitles = new String[] { "Name", "Resolution", "Density", "RAM size", };
+ static final ColumnContentHelper[] helpers = new ColumnContentHelper[] {
+ new NameContentHelper(0),
+ new ResolutionContentHelper(1),
+ new DensityContentHelper(2),
+ new RAMSizeContentHelper(3),
+ };
+
+ int index;
+
+ protected ColumnContentHelper(int index) {
+ this.index = index;
+ }
+
+ public String getTitle() {
+ return columnTitles[index];
+ }
+
+ public int getIndex() {
+ return index;
+ }
+
+ public abstract String getContent(VMsProperty property);
+
+ public static int getContentCount() {
+ return numberOfColumns;
+ }
+
+ public static ColumnContentHelper[] getContentHelpers() {
+ return helpers;
+ }
+
+}
+
+class NameContentHelper extends ColumnContentHelper {
+ public NameContentHelper(int index) {
+ super(index);
+ }
+
+ @Override
+ public String getContent(VMsProperty property) {
+ return property.getName();
+ }
+}
+
+class ResolutionContentHelper extends ColumnContentHelper {
+ public ResolutionContentHelper(int index) {
+ super(index);
+ }
+
+ @Override
+ public String getContent(VMsProperty property) {
+ DisplayType displayType = property.getConfiguration().getDevice().getDisplay();
+
+ return displayType.getResolution().getWidth()
+ + " x " + displayType.getResolution().getHeight();
+ }
+}
+
+class DensityContentHelper extends ColumnContentHelper {
+ public DensityContentHelper(int index) {
+ super(index);
+ }
+
+ @Override
+ public String getContent(VMsProperty property) {
+ DisplayType displayType = property.getConfiguration().getDevice().getDisplay();
+ return displayType.getDensity().getValue() + "";
+ }
+}
+
+class RAMSizeContentHelper extends ColumnContentHelper {
+ public RAMSizeContentHelper(int index) {
+ super(index);
+ }
+
+ @Override
+ public String getContent(VMsProperty property) {
+ DeviceType deviceType = property.getConfiguration().getDevice();
+ return deviceType.getRAM().getSize().getValue() + "";
+ }
+}
--- /dev/null
+package org.tizen.emulator.manager.ui.vmstree;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.swt.widgets.TreeColumn;
+import org.eclipse.swt.widgets.TreeItem;
+
+public class ColumnSortListner implements SelectionListener {
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ TreeColumn column = (TreeColumn)event.widget;
+ Tree tree = column.getParent();
+
+ tree.setSortColumn(column);
+ if(tree.getSortDirection() == SWT.NONE)
+ tree.setSortDirection(SWT.UP);
+ else if(tree.getSortDirection() == SWT.UP)
+ tree.setSortDirection(SWT.DOWN);
+ else if(tree.getSortDirection() == SWT.DOWN)
+ tree.setSortDirection(SWT.UP);
+
+ for(TreeItem item : tree.getItems()) {
+ if(!(item.getData() instanceof Container)) // double checking...
+ continue;
+
+ int count = item.getItemCount();
+
+ for(int i = 0; i < count - 1; ++i) {
+ TreeItem subItem0 = item.getItem(i);
+ if(subItem0.getData() instanceof TreeMarker)
+ continue;
+
+ for(int j = i + 1; j < count; ++j) {
+ TreeItem subItem1 = item.getItem(j);
+
+ if(subItem1.getData() instanceof TreeMarker)
+ continue;
+
+ if(tree.getSortDirection() == SWT.UP) {
+ if(subItem0.getText().compareTo(subItem1.getText()) > 0) {
+ PropertyContent content0 = (PropertyContent)subItem0.getData();
+ PropertyContent content1 = (PropertyContent)subItem1.getData();
+
+ RowItem rowItem = new PropertyContent(content1.getProperty(), subItem0);
+ subItem0.setData(rowItem);
+ rowItem = new PropertyContent(content0.getProperty(), subItem1);
+ subItem1.setData(rowItem);
+ }
+ }
+ else if(tree.getSortDirection() == SWT.DOWN) {
+ if(subItem0.getText().compareTo(subItem1.getText()) < 0) {
+ PropertyContent content0 = (PropertyContent)subItem0.getData();
+ PropertyContent content1 = (PropertyContent)subItem1.getData();
+
+ RowItem rowItem = new PropertyContent(content1.getProperty(), subItem0);
+ subItem0.setData(rowItem);
+ rowItem = new PropertyContent(content0.getProperty(), subItem1);
+ subItem1.setData(rowItem);
+ }
+ }
+ }
+ }
+ tree.redraw();
+ }
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent event) {
+ // TODO Auto-generated method stub
+ }
+
+}
+++ /dev/null
-package org.tizen.emulator.manager.ui.vmstree;
-
-import org.tizen.emulator.manager.vms.VMsProperty;
-import org.tizen.emulator.manager.vms.xml.DeviceType;
-import org.tizen.emulator.manager.vms.xml.DisplayType;
-
-
-// TODO: Support dynamic column editing...
-public class ContentProvider {
- static final int numberOfColumns = 4;
-
- String[] columnTitles = new String[] { "Name", "Resolution", "Density", "RAM size" };
-
- public String[] getColumnTitles() {
- return columnTitles;
- }
-
- public int getNumberOfColumns() {
- return numberOfColumns;
- }
-
- public String[] getColumnContents(VMsProperty property) {
- String[] texts = new String[numberOfColumns];
-
- texts[0] = property.getName();
-
- DeviceType deviceType = property.getConfiguration().getDevice();
- DisplayType displayType = deviceType.getDisplay();
- texts[1] = displayType.getResolution().getWidth()
- + " x " + displayType.getResolution().getHeight();
-
- texts[2] = displayType.getDensity().getValue() + "";
- texts[3] = deviceType.getRAM().getSize().getValue() + "";
-
- return texts;
- }
-
-}
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;
import org.tizen.emulator.manager.EmulatorManager;
+import org.tizen.emulator.manager.ui.ResourceRegistry;
+import org.tizen.emulator.manager.ui.ResourceRegistry.ImageName;
import org.tizen.emulator.manager.vms.VMsProperty;
public class ContextMenu {
final MenuItem launchItem = new MenuItem(treeMenu, SWT.NONE);
launchItem.setText("Launch");
+ launchItem.setImage(ResourceRegistry.getImage(ImageName.LAUNCH));
launchItem.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
});
final MenuItem modifyItem = new MenuItem(treeMenu, SWT.NONE);
modifyItem.setText("Modify");
+ modifyItem.setImage(ResourceRegistry.getImage(ImageName.MODIFY));
modifyItem.addSelectionListener(new SelectionListener(){
@Override
public void widgetDefaultSelected(SelectionEvent arg0) {
});
final MenuItem deleteItem = new MenuItem(treeMenu, SWT.NONE);
deleteItem.setText("Delete");
+ deleteItem.setImage(ResourceRegistry.getImage(ImageName.DELETE));
deleteItem.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent arg0) {
});
final MenuItem resetItem = new MenuItem(treeMenu, SWT.NONE);
resetItem.setText("Reset");
+ resetItem.setImage(ResourceRegistry.getImage(ImageName.RESET));
resetItem.addSelectionListener(new SelectionListener() {
@Override
public void widgetDefaultSelected(SelectionEvent arg0) {
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.widgets.TreeItem;
import org.tizen.emulator.manager.EmulatorManager;
+import org.tizen.emulator.manager.ui.ResourceRegistry;
import org.tizen.emulator.manager.vms.VMsProperty;
-public abstract class RowItem {}
+public interface RowItem {}
-class PropertyContent extends RowItem {
+interface TreeMarker extends RowItem {}
+
+interface TreeContent extends RowItem {}
+
+
+class PropertyContent implements TreeContent {
VMsProperty property;
- public PropertyContent(VMsProperty property, ContentProvider provider, TreeItem item) {
+ public PropertyContent(VMsProperty property, TreeItem item) {
this.property = property;
- item.setText(provider.getColumnContents(property));
+
+ for(ColumnContentHelper helper : ColumnContentHelper.getContentHelpers()) {
+ item.setText(helper.getIndex(), helper.getContent(property));
+ }
+ }
+
+ public VMsProperty getProperty() {
+ return property;
}
}
-abstract class TreeMarker extends RowItem {
- public TreeMarker(String text, TreeItem item) {
- item.setText(text);
+class CreateMarker implements TreeMarker {
+ public CreateMarker(TreeItem item) {
+ item.setText("<< Create new... >> ");
+
+ Font font = ResourceRegistry.getFont(SWT.BOLD);
+ if(font == null) {
+ FontData[] fontData = item.getFont().getFontData();
+ fontData[0].setStyle(SWT.BOLD);
+ font = new Font(EmulatorManager.getInstance().getDisplay(), fontData);
+ ResourceRegistry.addFont(SWT.BOLD, font);
+ }
+ item.setFont(font);
}
}
-class CreateMarker extends TreeMarker {
- public CreateMarker(TreeItem item) {
- super("<< Create new... >>\t", item);
- FontData[] fontData = item.getFont().getFontData();
- fontData[0].setStyle(SWT.BOLD);
- Font boldFont = new Font(EmulatorManager.getInstance().getDisplay(), fontData);
- item.setFont(boldFont);
- boldFont.dispose();
+
+abstract class Container {
+ public Container(String text, TreeItem item) {
+ item.setText(text);
}
}
-class StandardVMsMarker extends TreeMarker {
+class StandardVMsMarker extends Container implements TreeMarker {
public StandardVMsMarker(String version, TreeItem item) {
super(version, item);
}
}
-class CustomVMsMarker extends TreeMarker {
+class CustomVMsMarker extends Container implements TreeMarker {
public CustomVMsMarker(TreeItem item) {
super("Custom", item);
}
}
+
\ No newline at end of file
MainDialog mainDialog;
Tree vmsTree;
- ContentProvider contentProvider = new ContentProvider();
ContextMenu contextMenu = new ContextMenu();
EmulatorVMs fsImage = EmulatorVMs.getInstance();
vmsTree.setHeaderVisible(true);
vmsTree.setLinesVisible(true);
- for(String columnTitle : contentProvider.getColumnTitles()) {
+ for(ColumnContentHelper helper : ColumnContentHelper.getContentHelpers()) {
TreeColumn treeColumn = new TreeColumn(vmsTree, SWT.NONE);
- treeColumn.setText(columnTitle);
+ treeColumn.setText(helper.getTitle());
+
+ if("Name".equalsIgnoreCase(treeColumn.getText())) {
+ treeColumn.addSelectionListener(new ColumnSortListner());
+ }
}
refreshTableList();
TreeItem createItem = new TreeItem(customItem, SWT.NONE);
rowItem = new CreateMarker(createItem);
createItem.setData(rowItem);
-
+
Map<String, TreeItem> itemsMap = new HashMap<String, TreeItem>();
// FIXME !!
propertyItem = new TreeItem(vmsTree, SWT.NONE);
rowItem = new StandardVMsMarker(version, propertyItem);
propertyItem.setData(rowItem);
-
+
itemsMap.put(version, propertyItem);
-
+
createItem = new TreeItem(propertyItem, SWT.NONE);
rowItem = new CreateMarker(createItem);
createItem.setData(rowItem);
propertyItem = new TreeItem(customItem, SWT.NONE);
}
- rowItem = new PropertyContent(properties[i], contentProvider, propertyItem);
+ rowItem = new PropertyContent(properties[i], propertyItem);
propertyItem.setData(rowItem);
}
}
for(TreeItem item : itemsMap.values()) {
item.setExpanded(true);
}
-
+
}
- public int getCountSelectionItem() {
+ public int getSelectionContentCount() {
int count = 0;
Object data;
for (int i = 0; i < vmsTree.getSelectionCount(); i++) {
- data = vmsTree.getSelection()[i].getData();
- if(!(data instanceof RowItem))
- continue;
-
- if (data instanceof CreateMarker || data instanceof TreeMarker) {
+ data = vmsTree.getSelection()[i].getData();
+ if (data instanceof TreeMarker) {
return 0;
}
public class VMsProperty {
File configFile;
- EmulatorConfiguration rootElement;
+ EmulatorConfiguration configuration;
public VMsProperty(File configFile, EmulatorConfiguration element) {
this.configFile = configFile;
- this.rootElement = element;
+ this.configuration = element;
}
public String getName() {
- if(rootElement.getBaseInformation() == null)
+ if(configuration.getBaseInformation() == null)
return null;
- return rootElement.getBaseInformation().getName();
+ return configuration.getBaseInformation().getName();
}
public Architecture getArch() {
- if(rootElement.getBaseInformation() == null)
+ if(configuration.getBaseInformation() == null)
return null;
- return Architecture.x86.toString().equals(rootElement.getBaseInformation().getArchitecture()) ?
+ return Architecture.x86.toString().equals(configuration.getBaseInformation().getArchitecture()) ?
Architecture.x86 : Architecture.ARM;
}
public FSImageType getImageType() {
- if(rootElement.getBaseInformation() == null || rootElement.getBaseInformation().getDiskImage() == null)
+ if(configuration.getBaseInformation() == null || configuration.getBaseInformation().getDiskImage() == null)
return null;
- return FSImageType.standard.toString().equals(rootElement.getBaseInformation().getDiskImage().getType()) ?
+ return FSImageType.standard.toString().equals(configuration.getBaseInformation().getDiskImage().getType()) ?
FSImageType.standard : FSImageType.custom;
}
public EmulatorConfiguration getConfiguration() {
- return rootElement;
+ return configuration;
}
public enum Architecture {