DETAIL_LIST_MIDDLE("detail_list_middle"),
DETAIL_LIST_BOTTOM("detail_list_bottom"),
DETAIL_LIST_ITEM("detail_list_item"),
+ SCROLLBAR_BACK("scrollbar_back"),
CREATE_NEW_NOMAL("create_new_nml"),
CREATE_NEW_PUSH("create_new_pushed"),
return image;
}
+
+ public static Image getScrollbarBackground(int width, int height) {
+ Image image = new Image(Display.getCurrent(), width, height);
+ GC gc = new GC(image);
+ gc.fillRectangle(0, 0, width, height);
+ Image temp = ImageResources.SCROLLBAR_BACK.getImage();
+ gc.drawImage(temp, 0, 0, temp.getImageData().width, temp.getImageData().height,
+ 0, 0, width, height);
+ return image;
+ }
}
@Override
public void handleClickEvent(DACustomButton button) {
// reload vm list
- refreshVMPropertyList(true);
+ refreshVMPropertyList(false);
}
});
}
if (button == b) {
b.setSelected(true);
b.redraw();
- selectedIndex= i;
+ selectedIndex = i;
} else {
b.setSelected(false);
b.redraw();
}
public static VMButton getSelectedButton() {
- return buttons.get(selectedIndex);
+ return buttons.isEmpty()
+ ? null
+ : buttons.get(selectedIndex);
}
}
public void drawDetailVM(VMProperty property) {
detailView.drawPropertyView(property.getPropertyValue(), false);
+ //detailView.setDetailViewOrigin(modifyView.getDetailViewOrigin().x,
+ // modifyView.getDetailViewOrigin().y);
stackLayout.topControl = detailView.getComposite();
mainView.layout();
}
public void drawModifyVM(VMProperty property) {
modifyView.drawPropertyView(property.getPropertyValue(), false);
+ //modifyView.setDetailViewOrigin(detailView.getDetailViewOrigin().x,
+ // detailView.getDetailViewOrigin().y);
stackLayout.topControl = modifyView.getComposite();
mainView.layout();
}
}
public void redraw() {
+ emptyView.reset();
+ detailView.reset();
+ modifyView.reset();
stackLayout.topControl.redraw();
}
}
}
public class VMsListView {
private Composite parent = null;
- private Composite listView = null;
+ private Composite listView = null;
private int WIDTH = 510;
private int HEIGHT = 430;
// TODO
- private int LIST_WIDTH = WIDTH - 10;
- private int LIST_HEIGHT = HEIGHT - 55;
+ private int LIST_WIDTH = WIDTH - 10;
+ private int LIST_HEIGHT = HEIGHT - 55;
// for resize
private VIEW_STATE state;
return listView;
}
- private DACustomCombo imageCombo = null;
- private ScrolledComposite scrolledList = null;
+ private DACustomCombo imageCombo = null;
+ private ScrolledComposite scrolledList = null;
private Composite vmList = null;
public void init(int width, int height) {
FormData data = new FormData();
data.left = new FormAttachment(0, 10);
data.top = new FormAttachment(0, 10);
- data.width = COMBO_WIDTH;
- data.height = COMBO_HEIGHT;
+ data.width = COMBO_WIDTH;
+ data.height = COMBO_HEIGHT;
imageCombo.setLayoutData(data);
imageCombo.select(0);
private Text dumyText = null;
private void makeVMList() {
scrolledList = new ScrolledComposite(listView, SWT.V_SCROLL | SWT.BORDER);
- FormData data = new FormData();
- data.left = new FormAttachment(0, 10);
- data.top = new FormAttachment(0, 40);
- data.right = new FormAttachment(100, 0);
- data.bottom = new FormAttachment(100, -10);
- scrolledList.setLayoutData(data);
scrolledList.setBackground(ColorResources.LIST_BG_COLOR.getColor());
vmList = new Composite(scrolledList, SWT.NONE);
vmList.setBackground(ColorResources.LIST_BG_COLOR.getColor());
- data = new FormData();
- data.left = new FormAttachment(0, 0);
- data.top = new FormAttachment(0, 0);
- data.right = new FormAttachment(100);
- data.bottom = new FormAttachment(100);
- vmList.setLayoutData(data);
vmList.setLayout(new FormLayout());
scrolledList.setContent(vmList);
scrolledList.setExpandHorizontal(true);
-
// for key event
dumyText = new Text(listView, SWT.NONE);
dumyText.setText("");
+
+ FormData data = new FormData();
+ data.left = new FormAttachment(0, 10);
+ data.top = new FormAttachment(0, 40);
+ data.right = new FormAttachment(100, 0);
+ data.bottom = new FormAttachment(100, -10);
+ scrolledList.setLayoutData(data);
+
data = new FormData();
data.left = new FormAttachment(0, -100);
data.top = new FormAttachment(0, 0);
}
public void controlKeyEvent(KeyEvent event) {
- switch (event.keyCode) {
- case SWT.CR:
- case SWT.KEYPAD_CR:
- if (VMButtonFactory.getSelectedButton() instanceof VMCreateButton) {
+ if (createButton != null) {
+ switch(event.keyCode) {
+ case SWT.CR:
+ case SWT.KEYPAD_CR:
clickCreateButton();
- } else {
- VMButtonFactory.getSelectedButton().clickLaunchButton();
+ break;
+ default:
+ break;
}
- break;
- case SWT.ARROW_UP:
- int size = VMButtonFactory.getButtonList().size();
- int index = VMButtonFactory.getSelectedButtonIndex() - W_COUNT;
- if (index >= 0) {
- VMButtonFactory.clickVMButton(index);
- }
- break;
- case SWT.ARROW_DOWN:
- size = VMButtonFactory.getButtonList().size();
- index = VMButtonFactory.getSelectedButtonIndex() + W_COUNT;
- if (index < size) {
- VMButtonFactory.clickVMButton(index);
- } else {
- VMButtonFactory.clickVMButton(VMButtonFactory.getButtonList().size() - 1);
- }
- break;
- case SWT.ARROW_LEFT:
- size = VMButtonFactory.getButtonList().size();
- index = VMButtonFactory.getSelectedButtonIndex() - 1;
- if (index >= 0) {
- VMButtonFactory.clickVMButton(index);
- }
- break;
- case SWT.ARROW_RIGHT:
- size = VMButtonFactory.getButtonList().size();
- index = VMButtonFactory.getSelectedButtonIndex() + 1;
- if (index < size) {
- VMButtonFactory.clickVMButton(index);
- }
- break;
- case SWT.DEL:
- if (VMButtonFactory.getSelectedButton() instanceof VMCreateButton) {
- // nothing
- } else {
- VMsMainView.getInstance().deleteEmulator();
- // TODO
- return;
+ } else {
+ switch (event.keyCode) {
+ case SWT.CR:
+ case SWT.KEYPAD_CR:
+ if (VMButtonFactory.getSelectedButton() instanceof VMCreateButton) {
+ clickCreateButton();
+ } else {
+ VMButtonFactory.getSelectedButton().clickLaunchButton();
+ }
+ break;
+ case SWT.ARROW_UP:
+ int size = VMButtonFactory.getButtonList().size();
+ int index = VMButtonFactory.getSelectedButtonIndex() - W_COUNT;
+ if (index >= 0) {
+ VMButtonFactory.clickVMButton(index);
+ }
+ break;
+ case SWT.ARROW_DOWN:
+ size = VMButtonFactory.getButtonList().size();
+ index = VMButtonFactory.getSelectedButtonIndex() + W_COUNT;
+ if (index < size) {
+ VMButtonFactory.clickVMButton(index);
+ } else {
+ VMButtonFactory.clickVMButton(VMButtonFactory.getButtonList().size() - 1);
+ }
+ break;
+ case SWT.ARROW_LEFT:
+ size = VMButtonFactory.getButtonList().size();
+ index = VMButtonFactory.getSelectedButtonIndex() - 1;
+ if (index >= 0) {
+ VMButtonFactory.clickVMButton(index);
+ }
+ break;
+ case SWT.ARROW_RIGHT:
+ size = VMButtonFactory.getButtonList().size();
+ index = VMButtonFactory.getSelectedButtonIndex() + 1;
+ if (index < size) {
+ VMButtonFactory.clickVMButton(index);
+ }
+ break;
+ case SWT.DEL:
+ if (!(VMButtonFactory.getSelectedButton() instanceof VMCreateButton)) {
+ VMsMainView.getInstance().deleteEmulator();
+ return;
+ }
+ break;
+ case SWT.ESC:
+ if (VMsMainView.getInstance().isCreateMode()) {
+ VMsMainView.getInstance().drawCancelCreaetVM();
+ } else {
+ VMsMainView.getInstance().drawDetailVM();
+ }
}
- break;
- case SWT.ESC:
- if (!VMsMainView.getInstance().isCreateMode()) {
- VMsMainView.getInstance().drawDetailVM();
+
+ if (VMButtonFactory.getSelectedButton() != null) {
+ scrolledList.showControl(VMButtonFactory.getSelectedButton());
}
}
- scrolledList.showControl(VMButtonFactory.getSelectedButton());
}
public void cancelModify(int index) {
dumyText.setFocus();
}
- public void cancelModify() {
- cancelModify(-1);
- }
-
public void draw() {
vmList.layout(true, true);
scrolledList.layout(true, true);
import org.tizen.emulator.manager.vms.VMWorkerException;
public class VMsMainView {
- private Composite mainView;
- private VMsListView listView;
- private VMsDetailView detailView;
+ private Composite mainView;
+ private VMsListView listView;
+ private VMsDetailView detailView;
- private boolean isInitialize = false;
- private boolean isCreateMode = false;
- private boolean setFocus = false;
+ private boolean isInitialize = false;
+ private boolean isCreateMode = false;
+ private boolean setFocus = false;
private static VMsMainView view = new VMsMainView();
public static VMsMainView getInstance() {
if (isInitialize) {
// TODO
// dispose
+ return;
}
+
isInitialize = true;
mainView = new Composite(parent, SWT.NONE);
listView.redraw();
detailView.redraw();
}
-
});
-
- listView = new VMsListView(mainView);
- detailView = new VMsDetailView(mainView);
+ listView = new VMsListView(mainView);
+ detailView = new VMsDetailView(mainView);
FormData data = new FormData();
data.left = new FormAttachment(0, 0);
data.top = new FormAttachment(0, 0);
- data.bottom = new FormAttachment(100, 0);
+ data.bottom = new FormAttachment(100, 0);
data.right = new FormAttachment(100, -detailView.getSize().x);
listView.getComposite().setLayoutData(data);
data = new FormData();
data.left = new FormAttachment(listView.getComposite(), 0);
data.top = new FormAttachment(0, 0);
- //data.right = new FormAttachment(100, 0);
data.bottom = new FormAttachment(100, 0);
data.width = detailView.getSize().x;
detailView.getComposite().setLayoutData(data);
mainView.dispose();
}
+ public boolean isCreateMode() {
+ return isCreateMode;
+ }
+
+ public void setCreateMode(boolean isCreateMode) {
+ this.isCreateMode = isCreateMode;
+ }
+
+ public boolean isSetFocus() {
+ return setFocus;
+ }
+
+ public void setSetFocus(boolean setFocus) {
+ this.setFocus = setFocus;
+ }
+
private Platform currentPlatform = null;
private BaseImage currentImage = null;
- private VMProperty currentProperty = null;
+ private VMProperty currentProperty = null;
public void setPlatform(Platform platform, int index) {
- this.currentPlatform = platform;
if (platform == null) {
// TODO
return;
}
+ this.currentPlatform = platform;
if (platform.getImageList().isEmpty()) {
// TODO
} else {
}
public void resetPlatform() {
+ detailView.redraw();
setPlatform(currentPlatform,
currentPlatform.getImageList().indexOf(currentImage));
}
public void clearPlatform() {
currentPlatform = null;
currentImage = null;
- currentProperty = null;
+ currentProperty = null;
}
public Platform getPlatform() {
return currentPlatform;
}
- public void setCurrentImage(BaseImage image) {
+ void setCurrentImage(BaseImage image) {
this.currentImage = image;
}
return currentProperty;
}
- public void setCurrentProperty(VMProperty currentProperty) {
+ void setCurrentProperty(VMProperty currentProperty) {
this.currentProperty = currentProperty;
}
detailView.drawEmptyVM();
}
- public void drawDetailVM(VMProperty property) {
+ public void drawDetailVM(VMProperty property, int index) {
+ assert property == null;
+
currentProperty = property;
isCreateMode = false;
- listView.cancelModify();
+ listView.cancelModify(index);
detailView.drawDetailVM(property);
}
public void drawDetailVM() {
- drawDetailVM(currentProperty);
+ drawDetailVM(currentProperty, -1);
}
// for launch emulator
public void drawDetailVM(int index) {
- currentProperty = currentImage.getVmsList().get(index);
- isCreateMode = false;
- // select vm button
- listView.cancelModify(index);
- detailView.drawDetailVM(currentProperty);
+ if (index < 0
+ || index > currentImage.getVmsList().size()) {
+ return;
+ }
+
+ drawDetailVM(currentImage.getVmsList().get(index), index);
}
public void drawModifyVM(VMProperty property) {
+ assert property == null;
+
currentProperty = property;
MessageDialog msg = new MessageDialog();
}
isCreateMode = false;
+ setSetFocus(true);
detailView.drawModifyVM(property);
}
listView.drawVMList(currentImage, -1, true);
}
- BaseImage image = (currentPlatform.getName().equals("custom")) ? null : currentImage;
+ BaseImage image = (currentPlatform.getName().equals("custom"))
+ ? null : currentImage;
detailView.drawCreateVM(
new VMPropertyValue(image, SelectTemplate.getInstance().getDefaultTemplate()));
}
isCreateMode = false;
if (currentImage.getVmsList().isEmpty()) {
+ listView.cancelModify(-1);
drawEmptyVMList();
} else {
int i = currentImage.getVmsList().indexOf(currentProperty);
}
}
+ //
+ // handling vm
+ // launch, create, delete, modify, reset, create base image
+ //
public void launchEmulator(VMProperty property) {
if (property == null) {
property = getCurrentProperty();
handling.resetVirtualMachine(currentProperty);
return true;
}
-
- public boolean isCreateMode() {
- return isCreateMode;
- }
-
- public void setCreateMode(boolean isCreateMode) {
- this.isCreateMode = isCreateMode;
- }
-
- public boolean isSetFocus() {
- return setFocus;
- }
-
- public void setSetFocus(boolean setFocus) {
- this.setFocus = setFocus;
- }
}
protected Label titleLabel;
protected String title;
private boolean isCreateMode;
- private boolean isMinMode = false;
+ protected boolean isMinMode = false;
- private DACustomToggleButton arrowButton;
+ protected DACustomToggleButton arrowButton;
protected int count;
protected DetailViewItem item;
protected ArrayList<Composite> compList = new ArrayList<Composite>();
protected static int ITEM_HEIGHT = 20;
protected static int ITEM_WIDTH = 20;
- protected static int TiTLE_HEIGHT = 20;
+ protected static int TITLE_HEIGHT = 20;
protected static int TITLE_WIDTH = 100;
protected static int FILE_SELECT_BUTTON_WIDTH = 38;
protected static int INPUTBOX_OFFSET = 118;
protected static int INPUTBOX_TOP_GAP = 3;
- protected static int INPUTOBX_RIGHT_GAP = 10;
+ protected static int INPUTBOX_RIGHT_GAP = 10;
protected static int TITLE_TOP_GAP = 4;
protected static int TITLE_LEFT_GAP = 15;
FormData data = new FormData();
data.left = new FormAttachment(0, TITLE_LEFT_GAP);
data.top = new FormAttachment(0, TITLE_TOP_GAP);
- data.height = TiTLE_HEIGHT;
+ data.height = TITLE_HEIGHT;
data.width = TITLE_WIDTH;
titleLabel.setLayoutData(data);
titleLabel.setBackground(ColorResources.DETAIL_MIDDLE_COLOR.getColor());
}
- private void changeArrowState() {
+ protected void changeArrowState() {
if (arrowButton.isToggled()) {
/*
FormData data = new FormData();
compList.get(0).setLayoutData(data);
compList.get(0).getParent().layout(true, true);
*/
+ isMinMode = true;
for (int i = 1; i < count; i++) {
FormData data = new FormData();
data.height = 0;
compList.get(0).setLayoutData(data);
compList.get(0).getParent().layout(true, true);
*/
+ isMinMode = false;
for (int i = 1; i < count; i++) {
FormData data = new FormData();
data.left = new FormAttachment(0, ITEM_LEFT_GAP);
this.isCreateMode = isCreateMode;
}
- public boolean isMinMode() {
- return isMinMode;
- }
-
- public void setMinMode(boolean isMinMode) {
- this.isMinMode = isMinMode;
- }
-
public int getCount() {
if (isMinMode) {
return 1;
public abstract void setValue(VMPropertyValue value);
public abstract void drawDetail();
public abstract void drawModify();
+ // for min mode
+ public abstract void settingStatus(boolean isRefresh);
public abstract boolean settingDetailItem(VMPropertyValue value);
public abstract boolean settingModifyItem(VMPropertyValue value);
public abstract void closeItem();
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
itemListBack = new Composite(view, SWT.NONE);
scrolledList = new CustomScrolledComposite(itemListBack, SWT.V_SCROLL);
- itemList = new Composite(scrolledList, SWT.NONE);
+ itemList = new Composite(scrolledList, SWT.DOUBLE_BUFFERED);
itemListBack.setBackground(ColorResources.DETAIL_VIEW_PAGE_COLOR.getColor());
scrolledList.setBackground(ColorResources.DETAIL_VIEW_PAGE_COLOR.getColor());
data.left = new FormAttachment(0, 0);
data.top = new FormAttachment(0, 0);
data.bottom = new FormAttachment(100, -4);
- scrolledList.setSize(image2.getImageData().width, image2.getImageData().height);
+ data.height = image2.getImageData().height;
+ data.width = image2.getImageData().width;
+ scrolledList.setSize(data.width, data.height);
scrolledList.setLayoutData(data);
itemList.setSize(image3.getImageData().width, image3.getImageData().height);
+ //scrolledList.layout();
}
public void resize(int height) {
settingItemList();
}
+ public Point getDetailViewOrigin() {
+ return scrolledList.getOrigin();
+ }
+
+ public void setDetailViewOrigin(int x, int y) {
+ scrolledList.setOrigin(x, y);
+ }
+
protected abstract void drawInitView();
+ public abstract void reset();
public abstract void drawPropertyView(VMPropertyValue propertyValue, boolean isCreate);
}
public int checkItemCount() {
return checkItemCountwithSize();
}
+
+ @Override
+ public void reset() {
+ // TODO Auto-generated method stub
+ }
}
assert propertyValue == null;
for (DetailViewItem item : list) {
+ item.settingStatus(false);
item.settingDetailItem(propertyValue);
}
}
}
return count;
}
+
+ @Override
+ public void reset() {
+ /*
+ scrolledList.setOrigin(0, 0);
+ for (int i = 0; i < list.size(); i++) {
+ list.get(i).settingStatus(true);
+ }
+ */
+ }
}
public void drawPropertyView(VMPropertyValue propertyValue, boolean isCreate) {
assert propertyValue == null;
+ if (isCreate) {
+ scrolledList.setOrigin(0, 0);
+ }
+
confirmButton.setEnabled(false);
buttonComp.layout(true, true);
newValue = oldValue.clone();
for (DetailViewItem item : list) {
item.setCreateMode(isCreate);
+ item.settingStatus(false);
item.settingModifyItem(propertyValue);
}
}
}
return count;
}
+
+ @Override
+ public void reset() {
+ // TODO Auto-generated method stub
+ }
}
// SKIN
settingSkinList(re);
}
+
+ private static boolean isShareMinMode = false;
+
+ @Override
+ protected void changeArrowState() {
+ super.changeArrowState();
+ isShareMinMode = isMinMode;
+ }
+
+ @Override
+ public void settingStatus(boolean isRefresh) {
+ if (isRefresh) {
+ if (isMinMode) {
+ arrowButton.setToggled(false);
+ changeArrowState();
+ }
+ } else {
+ if (isShareMinMode != isMinMode) {
+ arrowButton.setToggled(isShareMinMode);
+ changeArrowState();
+ }
+ }
+ }
}
}
}
+ private static boolean isShareMinMode = false;
+
+ @Override
+ protected void changeArrowState() {
+ super.changeArrowState();
+ isShareMinMode = isMinMode;
+ }
+
+ @Override
+ public void settingStatus(boolean isRefresh) {
+ if (isRefresh) {
+ if (isMinMode) {
+ arrowButton.setToggled(false);
+ changeArrowState();
+ }
+ } else {
+ if (isShareMinMode != isMinMode) {
+ arrowButton.setToggled(isShareMinMode);
+ changeArrowState();
+ }
+ }
+ }
+
}
data = new FormData();
data.left = new FormAttachment(virtualButton, 10);
data.top = new FormAttachment(0, INPUTBOX_TOP_GAP + 1);
- data.width = INPUTBOX_WIDTH - TOGGLE_BUTTON_WIDTH - INPUTOBX_RIGHT_GAP;
+ data.width = INPUTBOX_WIDTH - TOGGLE_BUTTON_WIDTH - INPUTBOX_RIGHT_GAP;
virtualState.setLayoutData(data);
data = new FormData();
data = new FormData();
data.left = new FormAttachment(GPUButton, 10);
data.top = new FormAttachment(0, INPUTBOX_TOP_GAP + 1);
- data.width = INPUTBOX_WIDTH - TOGGLE_BUTTON_WIDTH - INPUTOBX_RIGHT_GAP;
+ data.width = INPUTBOX_WIDTH - TOGGLE_BUTTON_WIDTH - INPUTBOX_RIGHT_GAP;
GPUState.setLayoutData(data);
}
}
}
+ private static boolean isShareMinMode = false;
+ @Override
+ protected void changeArrowState() {
+ super.changeArrowState();
+ isShareMinMode = isMinMode;
+ }
+
+ @Override
+ public void settingStatus(boolean isRefresh) {
+ if (isRefresh) {
+ if (isMinMode) {
+ arrowButton.setToggled(false);
+ changeArrowState();
+ }
+ } else {
+ if (isShareMinMode != isMinMode) {
+ arrowButton.setToggled(isShareMinMode);
+ changeArrowState();
+ }
+ }
+ }
}
FormData data = new FormData();
data.left = new FormAttachment(0, TITLE_LEFT_GAP);
data.top = new FormAttachment(0, TITLE_TOP_GAP);
- data.height = TiTLE_HEIGHT;
+ data.height = TITLE_HEIGHT;
data.width = TITLE_WIDTH;
subTitleLabel.setLayoutData(data);
subTitleLabel.setBackground(ColorResources.DETAIL_MIDDLE_COLOR.getColor());
nameLabel.setFocus();
nameText.setFocus();
}
+
+ @Override
+ public void settingStatus(boolean isRefresh) {
+ // TODO Auto-generated method stub
+ }
}
ramSizeCombo.dispose();
}
}
+
+ @Override
+ public void settingStatus(boolean isRefresh) {
+ // TODO Auto-generated method stub
+ }
}
public void closeItem() {
touchPoint.dispose();
}
+
+ @Override
+ public void settingStatus(boolean isRefresh) {
+ // TODO Auto-generated method stub
+ }
}
tabComposite = new Composite(mainComposite, SWT.DOUBLE_BUFFERED);
tabComposite.setLayout(new FormLayout());
+ contentsComposite = new Composite(mainComposite, SWT.DOUBLE_BUFFERED);
+ contentsComposite.setLayout(new FillLayout());
+
+ // initialize main view
+ view = VMsMainView.getInstance();
+ view.setInit(contentsComposite);
+
FormData data = new FormData();
data.top = new FormAttachment(0, 0);
data.left = new FormAttachment(0, 2);
tabComposite.setLayoutData(data);
tabComposite.setBackground(ColorResources.TAB_BG_COLOR.getColor());
- contentsComposite = new Composite(mainComposite, SWT.DOUBLE_BUFFERED);
- contentsComposite.setLayout(new FillLayout());
-
data = new FormData();
data.top = new FormAttachment(tabComposite, 0);
data.left = new FormAttachment(0, 2);
data.bottom = new FormAttachment(100, 0);
contentsComposite.setLayoutData(data);
contentsComposite.setBackground(ColorResources.TAB_CONTENTS_BG_COLOR.getColor());
-
- // initialize main view
- view = VMsMainView.getInstance();
- view.setInit(contentsComposite);
}
- public void draw() {
+ public void draw() {
if(!items.isEmpty()) {
// clear
if (!buttons.isEmpty()) {
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
+import org.tizen.emulator.manager.resources.PatchImageResources;
enum MouseActionUsage {
UPBTN_HOVER, UPBTN_CLICK, DNBTN_HOVER, DNBTN_CLICK, UPPAGEINCREMENT, DNPAGEINCREMENT, THUMB_HOVER, DRAGGING, NOTHING
GC g = e.gc;
Point size = getSize();
+ if (screenSizeY != size.y) {
+ // draw background
+ this.setBackgroundImage(PatchImageResources.getScrollbarBackground(SCROLLBAR_WIDTH, size.y));
+ }
+
if (data.max > 0 && data.thumb > 0 && data.thumb <= data.max) {
// calculate the position of thumb and draw thumb
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.*;
+import org.tizen.emulator.manager.EmulatorManager;
import org.tizen.emulator.manager.resources.ColorResources;
/**
* A ScrolledComposite provides scrollbars and will scroll its content when the user
public CustomScrolledComposite(Composite parent, int style) {
super(parent, SWT.DOUBLE_BUFFERED);
super.setLayout(new FormLayout());
-
+
verticalBar = new CustomScrollBar(this);
if (verticalBar != null) {
verticalBar.setVisible(false);
}
});
}
-
+
FormData data = new FormData();
data.top = new FormAttachment(0, 2);
data.bottom = new FormAttachment(100, -2);
data.width = 5;
verticalBar.setLayoutData(data);
verticalBar.setBackground(ColorResources.DETAIL_MIDDLE_COLOR.getColor());
-
+
contentListener = new Listener() {
public void handleEvent(Event e) {
if (e.type != SWT.Resize) return;
settingScrollLayout(e);
}
};
-
+
filter = new Listener() {
public void handleEvent(Event event) {
if (event.widget instanceof Control) {
}
}
};
-
+
addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
getDisplay().removeFilter(SWT.FocusIn, filter);
}
});
+
+ this.addListener(SWT.Resize, contentListener);
+
+ this.addMouseWheelListener(new MouseWheelListener() {
+ @Override
+ public void mouseScrolled(MouseEvent e) {
+ if (verticalBar != null && verticalBar.isVisible()) {
+ verticalBar.mouseScrolled(e);
+ }
+ }
+ });
+
}
-
+
void settingScrollLayout(Event e) {
+ if (content == null) {
+ return;
+ }
+
layout(true, true);
if (needVScroll(content.getBounds(), false)) {
verticalBar.setVisible(true);
verticalBar.setVisible(false);
}
}
-
+
static int checkStyle (int style) {
int mask = SWT.V_SCROLL | SWT.BORDER | SWT.LEFT_TO_RIGHT | SWT.RIGHT_TO_LEFT; //SWT.H_SCROLL
return style & mask;
}
-
+
boolean contains(Control control) {
if (control == null || control.isDisposed()) {
return false;
}
-
+
Composite parent = control.getParent();
while (parent != null && !(parent instanceof Shell)) {
if (this == parent) return true;
parent = parent.getParent();
}
-
+
return false;
}
-
+
/**
* Returns the Always Show Scrollbars flag. True if the scrollbars are
* always shown even if they are not required. False if the scrollbars are only
//checkWidget();
return content;
}
-
+
/**
* Returns <code>true</code> if the receiver automatically scrolls to a focused child control
* to make it visible. Otherwise, returns <code>false</code>.
checkWidget();
return showFocusedControl;
}
-
+
public CustomScrollBar getVScrollBar() {
return verticalBar;
}
-
+
boolean needVScroll(Rectangle contentRect, boolean hVisible) {
if (verticalBar == null) {
return false;
}
-
+
Rectangle hostRect = getBounds();
int border = getBorderWidth();
hostRect.height -= 2*border;
-
+
/*
if (hVisible && verticalBar != null) {
hostRect.height -= verticalBar.getSize().y;
}
*/
-
+
if (contentRect.height > hostRect.height) {
return true;
}
return false;
}
-
+
/**
* Return the point in the content that currently appears in the top left
* corner of the scrolled composite.
}
content.setLocation(x, y);
}
-
+
/**
* Set the Always Show Scrollbars flag. True if the scrollbars are
* always shown even if they are not required. False if the scrollbars are only
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
* </ul>
*/
- public void setContent(Control content) {
+ public void setContent(Composite content) {
checkWidget();
if (this.content != null && !this.content.isDisposed()) {
this.content.removeListener(SWT.Resize, contentListener);
showControl(control);
}
}
-
+
/**
* Scrolls the content of the receiver so that the control is visible.
*
if (!contains(control)) {
SWT.error(SWT.ERROR_INVALID_ARGUMENT);
}
-
+
Rectangle itemRect = getDisplay().map(control.getParent(), this, control.getBounds());
Rectangle area = getClientArea();
Point origin = getOrigin();
}
setOrigin(origin);
}
-
+
void vScroll() {
if (content == null) return;
Point location = content.getLocation ();
int vSelection = verticalBar.getScrollPos();
content.setLocation (location.x, -vSelection);
+ if (EmulatorManager.isWin()) {
+ ((Composite)content).layout();
+ }
}
}
public void setSelected(boolean selected) {
((VMButtonAttribute)attr).setSelected(selected);
if (selected && property != null) {
- VMsMainView.getInstance().drawDetailVM(property);
+ VMsMainView.getInstance().drawDetailVM(property, -1);
}
}