import org.tizen.emulator.manager.ui.renewal.widgets.TextBox;
import org.tizen.emulator.manager.ui.renewal.widgets.WidgetHelper;
-
-
public abstract class FileDialogItem extends ModifyDialogItem {
protected TextBox textBox;
protected String filePath;
protected BlueButton fileDialogButton;
+ // for detail mode dialog
+ protected Canvas textLabel;
private final static int BUTTON_SPACE = 5;
private final static int BUTTON_WIDTH = 32;
lastPath = path;
}
-
public int getContentRight(int boxWidth) {
return boxWidth + BUTTON_SPACE + BUTTON_WIDTH;
}
super(name, title);
}
-
protected void create(Composite parent, String title,
ImageResources iconResource, int textBoxWidth) {
item = new ModifyItem(this);
protected void makeBody(int textBoxWidth) {
item.setBodyLayoutForm();
+ if (getItemListComp().isDetailMode()) {
+ createDetailItem();
+ } else {
+ createTextBox(textBoxWidth);
+ createFileDialogButton();
+ }
+ }
- createTextBox(textBoxWidth);
- createFileDialogButton();
+ protected void createDetailItem() {
+ textLabel = new Canvas(item.getBody(), SWT.NONE);
+ textLabel.setLayoutData(getDetailItemFormData());
}
public void setFilePath(String path) {
filePath = path;
}
-
- public void settingDetailItemPath(String path, Canvas canvas) {
- String text = "";
- if (path == null || path.isEmpty()) {
- text = "";
-
- } else {
- text = path.substring(path
- .lastIndexOf(File.separator) + 1, path.length());
- canvas.setToolTipText(path);
- }
- WidgetHelper.drawText(canvas, text, SWT.LEFT);
- }
-
public void setTextBox(String path) {
- if (path == null || path.isEmpty()) {
- textBox.setText("");
- textBox.setToolTipText("");
- } else {
- String fileName = path.substring(path
+ String fileName = "";
+ if (path != null && !path.isEmpty()) {
+ fileName = path.substring(path
.lastIndexOf(File.separator) + 1, path.length());
- textBox.setText(fileName);
- textBox.setToolTipText(path);
+
}
if (getItemListComp().isDetailMode()) {
- textBox.setEnabled(false);
+ WidgetHelper.drawText(textLabel, fileName, SWT.LEFT);
+ if (!fileName.isEmpty()) {
+ textLabel.setToolTipText(path);
+ }
+ } else {
+ textBox.setText(fileName);
+ if (!fileName.isEmpty()) {
+ textBox.setToolTipText(path);
+ }
}
}
-
protected void createTextBox(int textBoxWidth) {
FormData data = new FormData();
data.left = new FormAttachment(0, ModifyItem.BODY_MARGIN_LEFT);
data.height = ModifyItem.WIDGET_HEIGHT;
textBox = new TextBox(item.getBody(), SWT.NONE, SWT.CENTER);
textBox.setLayoutData(data);
-
}
protected void createFileDialogButton() {
}
}
-
private void addButtonListener() {
fileDialogButton.addListener(SWT.Selection, new Listener(){
@Override
public void handleEvent(Event event) {
- if (event.type == SWT.Selection) {
- String path = clickFileDialogButon();
- if (path != null) {
- FileDialogItem.setLastDirectoryPath(path);
- filePath = path;
- setTextBox(filePath);
- fileSelected();
- }
+ if (event.type != SWT.Selection) {
+ return;
+ }
+ String path = clickFileDialogButon();
+ if (path != null) {
+ FileDialogItem.setLastDirectoryPath(path);
+ filePath = path;
+ setTextBox(filePath);
+ fileSelected();
}
}
});
public abstract void fileSelected();
-
public void setItemEnable(boolean enable) {
textBox.setEnabled(enable);
fileDialogButton.setShowImage(enable);
}
}
-
-
@Override
public void changeWidgetState(boolean isError) {
if (!getItemListComp().isDetailMode()) {
import java.io.File;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.tizen.emulator.manager.renewal.resources.ColorResources;
import org.tizen.emulator.manager.resources.FilePathResources;
makeBody(SubModifyItem.BOX_WIDTH);
- }
-
- @Override
- protected void makeBody(int textBoxWidth) {
- item.setBodyLayoutForm();
if (getItemListComp().isDetailMode()) {
- createDetailItem();
-
- } else {
- createTextBox(textBoxWidth);
- createFileDialogButton();
+ setTextBox(imagePath);
}
}
- private void createDetailItem() {
- item.setBodyLayoutForm();
- Canvas canvas = new Canvas(item.getBody(), SWT.NONE) ;
- canvas.setLayoutData(getDetailItemFormData());
-
- settingDetailItemPath(imagePath, canvas);
-
- }
-
-
@Override
public void setParentItem(ModifyDialogItem parentItem) {
super.setParentItem(parentItem);
package org.tizen.emulator.manager.ui.renewal.item.modify.vm;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Composite;
import org.tizen.emulator.manager.renewal.resources.ImageResources;
import org.tizen.emulator.manager.ui.renewal.item.modify.common.FileDialogItem;
super(NAME, TITLE);
}
-
@Override
public void create(Composite parent) {
create(parent, getTitle(), TITLE_ICON_RESOURCE, TEXT_BOX_WIDTH);
-
+ updateUI();
}
-
private void updateUI() {
- if (sharingPath == null || sharingPath.isEmpty()) {
- setTextBox("(select sharing path...)");
-
- } else {
- setTextBox(sharingPath);
- }
- }
-
- @Override
- protected void makeBody(int textBoxWidth) {
- item.setBodyLayoutForm();
if (getItemListComp().isDetailMode()) {
- createDetailItem();
-
+ setTextBox(sharingPath);
} else {
- createTextBox(textBoxWidth);
- createFileDialogButton();
- updateUI();
- }
- }
+ if (sharingPath == null || sharingPath.isEmpty()) {
+ setTextBox("(select sharing path...)");
- private void createDetailItem() {
- item.setBodyLayoutForm();
- Canvas canvas = new Canvas(item.getBody(), SWT.NONE);
- canvas.setLayoutData(getDetailItemFormData());
-
- settingDetailItemPath(sharingPath, canvas);
+ } else {
+ setTextBox(sharingPath);
+ }
+ }
}
-
@Override
public void setInitialValue(PropertyValue value) {
if (getItemListComp().isCreateMode()) {
return new FileSharingItem();
}
-
@Override
public void fileSelected() {
sharingPath = filePath;