import java.io.File;
import org.tizen.emulator.manager.device.xml.template.DeviceConfiguration;
+import org.tizen.emulator.manager.platform.Profile;
+import org.tizen.emulator.manager.platform.ProfileList;
+import org.tizen.emulator.manager.resources.StringResources;
+import org.tizen.emulator.manager.vms.helper.VMWorkerException;
public class DeviceTemplate {
private File templateFile;
+ private long lastModified;
+
private DeviceConfiguration conf;
private DeviceTemplateValue value;
public DeviceTemplate(File file, DeviceConfiguration conf) {
this.templateFile = file;
+ this.lastModified = file.lastModified();
this.conf = conf;
}
this.value = value;
}
+ public void reloadDeviceTemplate() {
+ DeviceTemplateList.reloadDeviceConfiguration(this);
+ this.lastModified = templateFile.lastModified();
+ value.settingConfigure(this);
+ }
+
public DeviceTemplateValue getValue() {
if (value == null) {
value = new DeviceTemplateValue(this);
public void setConf(DeviceConfiguration conf) {
this.conf = conf;
}
+
+ public long getLastModified() {
+ return lastModified;
+ }
+
+ public void delete() throws VMWorkerException{
+ // lock.acquire
+ if (!templateFile.exists()) {
+ throw new VMWorkerException("Failed to delete device template"
+ + StringResources.NEW_LINE
+ + "Device template file does not exist: "
+ + StringResources.NEW_LINE
+ + templateFile.getAbsolutePath(), true);
+ }
+
+ if (!templateFile.delete()) {
+ throw new VMWorkerException("Failed to delete device template"
+ + StringResources.NEW_LINE
+ + "Check your device template file: "
+ + StringResources.NEW_LINE
+ + templateFile.getAbsolutePath());
+ }
+
+ // TODO
+ Profile profile = ProfileList.getProfile(value.getProfile());
+ profile.removeDeviceTemplate(this);
+
+ // lock.release
+ }
}
import org.tizen.emulator.manager.EmulatorManager;
import org.tizen.emulator.manager.devices.DeviceTemplate;
import org.tizen.emulator.manager.devices.DeviceTemplateValue;
+import org.tizen.emulator.manager.logging.EMLogger;
import org.tizen.emulator.manager.platform.Profile;
import org.tizen.emulator.manager.platform.ProfileList;
import org.tizen.emulator.manager.renewal.resources.ColorResources;
import org.tizen.emulator.manager.ui.table.Table;
import org.tizen.emulator.manager.ui.table.TableColumn;
import org.tizen.emulator.manager.ui.table.TableItem;
+import org.tizen.emulator.manager.vms.helper.VMWorkerException;
public class DeviceTemplateTableViewer extends AbstractTableViewer {
private static final int BACK_BUTTON_WIDTH = 124;
@Override
public void handleEvent(Event event) {
if (event.type == SWT.Selection) {
- // TODO
+ TableItem[] items = table.getSelection();
+ if (items != null && items.length > 0) {
+ TableItem item = items[0];
+
+ deleteDeviceTemplate(item);
+ }
}
}
});
cloneButton.setEnabled(false);
}
+ private void deleteDeviceTemplate(TableItem item) {
+ if (item == null) {
+ return;
+ }
+
+ DeviceTemplate template = (DeviceTemplate)item.getData();
+ try {
+ template.delete();
+ table.remove(table.indexOf(item));
+ } catch (VMWorkerException e) {
+ EMLogger.getLogger().warning(e.getMessage());
+ // open message box
+ MessageBox.openMessageBox(e.getMessage());
+
+ if (e.isNeedRefresh()) {
+ refreshDeviceTemplateList();
+ }
+ }
+ }
+
private void tableSelected() {
if (table.getSelectionCount() == 0) {
deleteButton.setEnabled(false);
import org.eclipse.swt.widgets.Shell;
import org.tizen.emulator.manager.renewal.resources.ColorResources;
import org.tizen.emulator.manager.renewal.resources.FontResources;
+import org.tizen.emulator.manager.ui.renewal.MainDialog;
import org.tizen.emulator.manager.ui.renewal.widgets.CustomScrolledComposite;
import org.tizen.emulator.manager.ui.renewal.widgets.GrayButton;
private StyledText contentsBox = null;
// TODO: Icon SWT.ICON_ERROR ...
+ private static final Shell shell;
+ static {
+ shell = MainDialog.getShell();
+ }
+
+ public static int openMessageBox(String message) {
+ return openMessageBox(message, SWT.OK);
+ }
+
+ public static int openMessageBox(String message, int style) {
+ MessageBox msgBox = new MessageBox( shell, style);
+ msgBox.setMessage(message);
+
+ return msgBox.open();
+ }
/**
* style = SWT.OK