Skip to content
Snippets Groups Projects
Commit 51f4de6d authored by Lukas Ladenberger's avatar Lukas Ladenberger
Browse files

working on observer view + cleanup

parent 7a079836
No related branches found
No related tags found
No related merge requests found
Showing
with 62 additions and 400 deletions
de.bmotionstudio.gef.editor/icons/icon_add.gif

386 B

de.bmotionstudio.gef.editor/icons/icon_ascript.png

489 B

de.bmotionstudio.gef.editor/icons/icon_motion.gif

1017 B

de.bmotionstudio.gef.editor/icons/icon_motion_wiz.gif

1.09 KiB

de.bmotionstudio.gef.editor/icons/icon_screenshot.gif

613 B

...@@ -6,15 +6,23 @@ ...@@ -6,15 +6,23 @@
package de.bmotionstudio.gef.editor; package de.bmotionstudio.gef.editor;
import org.eclipse.jface.window.Window; import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.TrayDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
import de.bmotionstudio.gef.editor.model.BControl; import de.bmotionstudio.gef.editor.model.BControl;
public abstract class BMotionAbstractWizard extends Window { public abstract class BMotionAbstractWizard extends TrayDialog {
private BControl control; private BControl control;
public static final int CLOSE = 2;
public BMotionAbstractWizard(Shell shell, BControl control) { public BMotionAbstractWizard(Shell shell, BControl control) {
super(shell); super(shell);
this.control = control; this.control = control;
...@@ -26,4 +34,41 @@ public abstract class BMotionAbstractWizard extends Window { ...@@ -26,4 +34,41 @@ public abstract class BMotionAbstractWizard extends Window {
public abstract String getName(); public abstract String getName();
@Override
protected Control createDialogArea(Composite parent) {
GridLayout layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.verticalSpacing = 0;
Composite container = new Composite(parent, SWT.NONE);
container.setLayout(layout);
container.setLayoutData(new GridData(GridData.FILL_BOTH));
createWizardContent(container);
return container;
}
@Override
protected void createButtonsForButtonBar(Composite parent) {
createButton(parent, IDialogConstants.CLOSE_ID,
IDialogConstants.CLOSE_LABEL, true);
}
@Override
protected void buttonPressed(int buttonId) {
if (IDialogConstants.CLOSE_ID == buttonId)
closePressed();
}
protected void closePressed() {
setReturnCode(CLOSE);
close();
}
public abstract Control createWizardContent(Composite parent);
} }
...@@ -8,7 +8,7 @@ package de.bmotionstudio.gef.editor; ...@@ -8,7 +8,7 @@ package de.bmotionstudio.gef.editor;
public class EditorImageRegistry implements IBMotionStudioImageRegistry { public class EditorImageRegistry implements IBMotionStudioImageRegistry {
public static final String IMG_ICON_ADD = "icon_add"; // public static final String IMG_ICON_ADD = "icon_add";
public static final String IMG_ICON_CHOP = "icon_chop"; public static final String IMG_ICON_CHOP = "icon_chop";
public static final String IMG_ICON_DELETE = "icon_delete"; public static final String IMG_ICON_DELETE = "icon_delete";
public static final String IMG_ICON_DELETE21 = "icon_delete21"; public static final String IMG_ICON_DELETE21 = "icon_delete21";
...@@ -18,7 +18,6 @@ public class EditorImageRegistry implements IBMotionStudioImageRegistry { ...@@ -18,7 +18,6 @@ public class EditorImageRegistry implements IBMotionStudioImageRegistry {
public static final String IMG_ICON_OBSERVER = "icon_observer"; public static final String IMG_ICON_OBSERVER = "icon_observer";
public static final String IMG_ICON_LOADING = "icon_loading"; public static final String IMG_ICON_LOADING = "icon_loading";
public static final String IMG_ICON_LIBRARY = "icon_library"; public static final String IMG_ICON_LIBRARY = "icon_library";
public static final String IMG_ICON_ASCRIPT = "icon_ascript";
public static final String IMG_ICON_UP = "icon_up"; public static final String IMG_ICON_UP = "icon_up";
public static final String IMG_ICON_DOWN = "icon_down"; public static final String IMG_ICON_DOWN = "icon_down";
public static final String IMG_ICON_CONNECTION16 = "icon_connection16"; public static final String IMG_ICON_CONNECTION16 = "icon_connection16";
...@@ -28,6 +27,7 @@ public class EditorImageRegistry implements IBMotionStudioImageRegistry { ...@@ -28,6 +27,7 @@ public class EditorImageRegistry implements IBMotionStudioImageRegistry {
public static final String IMG_ICON_TR_UP = "icon_tr_up"; public static final String IMG_ICON_TR_UP = "icon_tr_up";
public static final String IMG_ICON_TR_LEFT = "icon_tr_left"; public static final String IMG_ICON_TR_LEFT = "icon_tr_left";
public static final String IMG_ICON_CONTROL_HIDDEN = "icon_control_hidden"; public static final String IMG_ICON_CONTROL_HIDDEN = "icon_control_hidden";
public static final String IMG_ICON_HELP = "icon_help";
public static final String IMG_ICON_JPG = "icon_jpg"; public static final String IMG_ICON_JPG = "icon_jpg";
public static final String IMG_ICON_GIF = "icon_gif"; public static final String IMG_ICON_GIF = "icon_gif";
...@@ -36,8 +36,8 @@ public class EditorImageRegistry implements IBMotionStudioImageRegistry { ...@@ -36,8 +36,8 @@ public class EditorImageRegistry implements IBMotionStudioImageRegistry {
public void registerImages() { public void registerImages() {
BMotionStudioImage.registerImage(IMG_ICON_ADD, // BMotionStudioImage.registerImage(IMG_ICON_ADD,
BMotionEditorPlugin.PLUGIN_ID, "icons/icon_add.gif"); // BMotionEditorPlugin.PLUGIN_ID, "icons/icon_add.gif");
BMotionStudioImage.registerImage(IMG_ICON_CHOP, BMotionStudioImage.registerImage(IMG_ICON_CHOP,
BMotionEditorPlugin.PLUGIN_ID, "icons/icon_chop.gif"); BMotionEditorPlugin.PLUGIN_ID, "icons/icon_chop.gif");
BMotionStudioImage.registerImage(IMG_ICON_DELETE, BMotionStudioImage.registerImage(IMG_ICON_DELETE,
...@@ -54,8 +54,6 @@ public class EditorImageRegistry implements IBMotionStudioImageRegistry { ...@@ -54,8 +54,6 @@ public class EditorImageRegistry implements IBMotionStudioImageRegistry {
BMotionEditorPlugin.PLUGIN_ID, "icons/icon_loading.gif"); BMotionEditorPlugin.PLUGIN_ID, "icons/icon_loading.gif");
BMotionStudioImage.registerImage(IMG_ICON_LIBRARY, BMotionStudioImage.registerImage(IMG_ICON_LIBRARY,
BMotionEditorPlugin.PLUGIN_ID, "icons/icon_library.gif"); BMotionEditorPlugin.PLUGIN_ID, "icons/icon_library.gif");
BMotionStudioImage.registerImage(IMG_ICON_ASCRIPT,
BMotionEditorPlugin.PLUGIN_ID, "icons/icon_ascript.png");
BMotionStudioImage.registerImage(IMG_ICON_UP, BMotionStudioImage.registerImage(IMG_ICON_UP,
BMotionEditorPlugin.PLUGIN_ID, "icons/icon_up.gif"); BMotionEditorPlugin.PLUGIN_ID, "icons/icon_up.gif");
BMotionStudioImage.registerImage(IMG_ICON_DOWN, BMotionStudioImage.registerImage(IMG_ICON_DOWN,
...@@ -72,6 +70,8 @@ public class EditorImageRegistry implements IBMotionStudioImageRegistry { ...@@ -72,6 +70,8 @@ public class EditorImageRegistry implements IBMotionStudioImageRegistry {
"org.eclipse.ui", "$nl$/icons/full/etool16/delete_edit.gif"); "org.eclipse.ui", "$nl$/icons/full/etool16/delete_edit.gif");
BMotionStudioImage.registerImage(IMG_ICON_DELETE_EDIT, BMotionStudioImage.registerImage(IMG_ICON_DELETE_EDIT,
"org.eclipse.ui", "$nl$/icons/full/etool16/delete_edit.gif"); "org.eclipse.ui", "$nl$/icons/full/etool16/delete_edit.gif");
BMotionStudioImage.registerImage(IMG_ICON_HELP, "org.eclipse.ui",
"$nl$/icons/full/dlcl16/linkto_help.gif");
BMotionStudioImage BMotionStudioImage
.registerImage(IMG_ICON_TR_UP, BMotionEditorPlugin.PLUGIN_ID, .registerImage(IMG_ICON_TR_UP, BMotionEditorPlugin.PLUGIN_ID,
"icons/eclipse16/updated_co.gif"); "icons/eclipse16/updated_co.gif");
......
...@@ -7,8 +7,6 @@ ...@@ -7,8 +7,6 @@
package de.bmotionstudio.gef.editor.observer; package de.bmotionstudio.gef.editor.observer;
import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
import de.bmotionstudio.gef.editor.BMotionAbstractWizard; import de.bmotionstudio.gef.editor.BMotionAbstractWizard;
...@@ -27,8 +25,6 @@ public abstract class ObserverWizard extends BMotionAbstractWizard { ...@@ -27,8 +25,6 @@ public abstract class ObserverWizard extends BMotionAbstractWizard {
private Observer observer; private Observer observer;
protected Boolean observerDelete = false;
public ObserverWizard(Shell shell, BControl control, Observer observer) { public ObserverWizard(Shell shell, BControl control, Observer observer) {
super(shell, control); super(shell, control);
this.observer = observer; this.observer = observer;
...@@ -45,8 +41,4 @@ public abstract class ObserverWizard extends BMotionAbstractWizard { ...@@ -45,8 +41,4 @@ public abstract class ObserverWizard extends BMotionAbstractWizard {
return observer.getName(); return observer.getName();
} }
public Control createControl(Composite parent) {
return createContents(parent);
}
} }
...@@ -65,14 +65,6 @@ public class SetAttribute extends Observer { ...@@ -65,14 +65,6 @@ public class SetAttribute extends Observer {
attributeVal.toString(), control, animation); attributeVal.toString(), control, animation);
String er = attributeObj.validateValue(strAtrVal, null); String er = attributeObj.validateValue(strAtrVal, null);
if (er != null) { if (er != null) {
// addError(
// control,
// animation,
// "You selected "
// + attributeObj.getName()
// +
// " as attribute. There is a problem with your value: "
// + strAtrVal + " - Reason: " + er);
obj.setHasError(true); obj.setHasError(true);
} else { } else {
attributeVal = attributeObj.unmarshal(strAtrVal); attributeVal = attributeObj.unmarshal(strAtrVal);
...@@ -134,23 +126,6 @@ public class SetAttribute extends Observer { ...@@ -134,23 +126,6 @@ public class SetAttribute extends Observer {
@Override @Override
public IFigure getToolTip(BControl control) { public IFigure getToolTip(BControl control) {
// // TODO: This method need rework!!!
// StringBuilder builder = new StringBuilder();
// builder.append("Set Attribute Observer:\n\n");
// for (SetAttributeObject obj : getSetAttributeObjects()) {
// if (obj.getEval() != null) {
// builder.append("[Predicate: " + obj.getEval());
// }
// if (obj.getAttribute() != null) {
// builder.append(" | Attribute: "
// + control.getAttribute(obj.getAttribute()).getName());
// }
// if (obj.getValue() != null) {
// builder.append(" | Value: " + obj.getValue() + "]");
// }
// builder.append("\n");
// }
// Label lb = new Label(builder.toString());
return null; return null;
} }
......
...@@ -131,7 +131,7 @@ public class ObserverPage extends Page implements ISelectionListener { ...@@ -131,7 +131,7 @@ public class ObserverPage extends Page implements ISelectionListener {
rightContainer.setLayoutData(new GridData( rightContainer.setLayoutData(new GridData(
GridData.FILL_BOTH)); GridData.FILL_BOTH));
rightContainer.setLayout(new FillLayout()); rightContainer.setLayout(new FillLayout());
wizard.createControl(rightContainer); wizard.createWizardContent(rightContainer);
} }
} }
container.layout(); container.layout();
......
...@@ -33,7 +33,7 @@ public class WizardColumnObserver extends ObserverWizard { ...@@ -33,7 +33,7 @@ public class WizardColumnObserver extends ObserverWizard {
private Text txtPredicate; private Text txtPredicate;
@Override @Override
protected Control createContents(Composite parent) { public Control createWizardContent(Composite parent) {
final DataBindingContext dbc = new DataBindingContext(); final DataBindingContext dbc = new DataBindingContext();
......
...@@ -50,7 +50,7 @@ public class WizardObserverCSwitchCoordinates extends ObserverWizard { ...@@ -50,7 +50,7 @@ public class WizardObserverCSwitchCoordinates extends ObserverWizard {
private TableViewer tableViewer; private TableViewer tableViewer;
@Override @Override
protected Control createContents(Composite parent) { public Control createWizardContent(Composite parent) {
DataBindingContext dbc = new DataBindingContext(); DataBindingContext dbc = new DataBindingContext();
......
...@@ -66,7 +66,7 @@ public class WizardObserverListenOperationByPredicate extends ObserverWizard { ...@@ -66,7 +66,7 @@ public class WizardObserverListenOperationByPredicate extends ObserverWizard {
private TableViewer tableViewer; private TableViewer tableViewer;
@Override @Override
protected Control createContents(Composite parent) { public Control createWizardContent(Composite parent) {
parent.setLayout(new FillLayout()); parent.setLayout(new FillLayout());
......
...@@ -68,7 +68,7 @@ public class WizardObserverSetAttribute extends ObserverWizard { ...@@ -68,7 +68,7 @@ public class WizardObserverSetAttribute extends ObserverWizard {
private TableViewer tableViewer; private TableViewer tableViewer;
@Override @Override
protected Control createContents(Composite parent) { public Control createWizardContent(Composite parent) {
parent.setLayout(new FillLayout()); parent.setLayout(new FillLayout());
......
...@@ -35,7 +35,7 @@ public class WizardObserverSimpleValueDisplay extends ObserverWizard { ...@@ -35,7 +35,7 @@ public class WizardObserverSimpleValueDisplay extends ObserverWizard {
private Text txtPredicate; private Text txtPredicate;
@Override @Override
protected Control createContents(Composite parent) { public Control createWizardContent(Composite parent) {
parent.setLayout(new FillLayout()); parent.setLayout(new FillLayout());
......
...@@ -52,7 +52,7 @@ public class WizardObserverSwitchCoordinates extends ObserverWizard { ...@@ -52,7 +52,7 @@ public class WizardObserverSwitchCoordinates extends ObserverWizard {
private TableViewer tableViewer; private TableViewer tableViewer;
@Override @Override
protected Control createContents(Composite parent) { public Control createWizardContent(Composite parent) {
parent.setLayout(new FillLayout()); parent.setLayout(new FillLayout());
......
...@@ -55,7 +55,7 @@ public class WizardObserverSwitchImage extends ObserverWizard { ...@@ -55,7 +55,7 @@ public class WizardObserverSwitchImage extends ObserverWizard {
private TableViewer tableViewer; private TableViewer tableViewer;
@Override @Override
protected Control createContents(Composite parent) { public Control createWizardContent(Composite parent) {
parent.setLayout(new FillLayout()); parent.setLayout(new FillLayout());
......
...@@ -66,7 +66,7 @@ public class WizardTableObserver extends ObserverWizard { ...@@ -66,7 +66,7 @@ public class WizardTableObserver extends ObserverWizard {
} }
@Override @Override
protected Control createContents(Composite parent) { public Control createWizardContent(Composite parent) {
final DataBindingContext dbc = new DataBindingContext(); final DataBindingContext dbc = new DataBindingContext();
parent.setLayout(new GridLayout(1, true)); parent.setLayout(new GridLayout(1, true));
......
...@@ -37,21 +37,6 @@ public abstract class SchedulerWizard extends BMotionAbstractWizard { ...@@ -37,21 +37,6 @@ public abstract class SchedulerWizard extends BMotionAbstractWizard {
return this.event; return this.event;
} }
// protected abstract Boolean prepareToFinish();
// @Override
// public boolean performFinish() {
// return prepareToFinish();
// }
// protected void setEventDelete(Boolean b) {
// this.eventDelete = b;
// }
//
// public Boolean isEventDelete() {
// return this.eventDelete;
// }
public abstract Point getSize(); public abstract Point getSize();
@Override @Override
......
/**
* (c) 2009 Lehrstuhl fuer Softwaretechnik und Programmiersprachen,
* Heinrich Heine Universitaet Duesseldorf
* This software is licenced under EPL 1.0 (http://www.eclipse.org/org/documents/epl-v10.html)
* */
package de.bmotionstudio.gef.editor.scheduler.wizard;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.databinding.beans.BeansObservables;
import org.eclipse.core.databinding.observable.list.ComputedList;
import org.eclipse.core.databinding.observable.list.WritableList;
import org.eclipse.jface.databinding.viewers.ObservableListContentProvider;
import org.eclipse.jface.databinding.viewers.ObservableMapLabelProvider;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.ComboBoxViewerCellEditor;
import org.eclipse.jface.viewers.EditingSupport;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CCombo;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import de.bmotionstudio.gef.editor.BMotionStudioImage;
import de.bmotionstudio.gef.editor.EditorImageRegistry;
import de.bmotionstudio.gef.editor.model.BControl;
import de.bmotionstudio.gef.editor.scheduler.AnimationScriptStep;
import de.bmotionstudio.gef.editor.scheduler.ObserverCallBackObject;
@Deprecated
public class ObserverCallBackDialog extends Dialog {
private TableViewer tableViewer;
private final AnimationScriptStep animationScriptStep;
private final BControl control;
// private IObservableValue controlObservable;
public ObserverCallBackDialog(final Shell parentShell,
final AnimationScriptStep animationScriptStep,
final BControl control) {
super(parentShell);
this.animationScriptStep = animationScriptStep;
this.control = control;
}
@Override
protected Control createDialogArea(final Composite parent) {
// DataBindingContext dbc = new DataBindingContext();
Composite container = (Composite) super.createDialogArea(parent);
container.setLayout(new GridLayout(1, true));
tableViewer = new TableViewer(container, SWT.BORDER
| SWT.FULL_SELECTION);
tableViewer.getTable().setLinesVisible(true);
tableViewer.getTable().setHeaderVisible(true);
tableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));
tableViewer.getTable().setFont(
new Font(Display.getDefault(), new FontData("Arial", 10,
SWT.NONE)));
TableViewerColumn column = new TableViewerColumn(tableViewer, SWT.NONE);
column.getColumn().setText("Control");
column.getColumn().setWidth(225);
column.setEditingSupport(new ControlValueEditing(tableViewer, control));
column = new TableViewerColumn(tableViewer, SWT.NONE);
column.getColumn().setText("Observer");
column.getColumn().setWidth(150);
// column.setEditingSupport(new TextEditingSupport(tableViewer, dbc,
// "observerID"));
column.setEditingSupport(new ObserverValueEditing(tableViewer, control));
ObservableListContentProvider contentProvider = new ObservableListContentProvider();
tableViewer.setContentProvider(contentProvider);
tableViewer.setLabelProvider(new ObservableMapLabelProvider(
BeansObservables.observeMaps(
contentProvider.getKnownElements(), new String[] {
"control", "observerID" })) {
@Override
public String getColumnText(final Object element,
final int columnIndex) {
if (columnIndex == 0) {
ObserverCallBackObject obj = (ObserverCallBackObject) element;
if (obj.getControl() != null) {
return obj.getControl().getID();
}
}
return super.getColumnText(element, columnIndex);
}
@Override
public Image getColumnImage(final Object element,
final int columnIndex) {
return null;
}
});
final WritableList input = new WritableList(
animationScriptStep.getCallBackList(),
ObserverCallBackObject.class);
tableViewer.setInput(input);
Composite comp = new Composite(container, SWT.NONE);
comp.setLayout(new RowLayout());
comp.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
Button btRemove = new Button(comp, SWT.PUSH);
btRemove.setText("Remove");
btRemove.setImage(BMotionStudioImage
.getImage(EditorImageRegistry.IMG_ICON_DELETE));
btRemove.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
if (tableViewer.getSelection().isEmpty()) {
return;
}
ObserverCallBackObject obj = (ObserverCallBackObject) ((IStructuredSelection) tableViewer
.getSelection()).getFirstElement();
input.remove(obj);
}
});
Button btAdd = new Button(comp, SWT.PUSH);
btAdd.setText("Add");
btAdd.setImage(BMotionStudioImage
.getImage(EditorImageRegistry.IMG_ICON_ADD));
btAdd.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(final SelectionEvent e) {
ObserverCallBackObject obj = new ObserverCallBackObject();
input.add(obj);
}
});
return container;
}
@Override
protected Point getInitialSize() {
return new Point(600, 500);
}
@Override
protected void okPressed() {
close();
}
@Override
protected void configureShell(final Shell newShell) {
super.configureShell(newShell);
newShell.setText("BMotion Studio - Observer Callback Editor");
}
private class ControlValueEditing extends EditingSupport {
private ComboBoxViewerCellEditor cellEditor = null;
private final BControl control;
public ControlValueEditing(final TableViewer cv, final BControl control) {
super(cv);
this.control = control;
}
@Override
protected boolean canEdit(final Object element) {
return true;
}
@Override
protected Object getValue(final Object element) {
if (((ObserverCallBackObject) element).getControl() != null) {
return ((ObserverCallBackObject) element).getControl().getID();
} else {
return "";
}
}
@Override
protected void setValue(final Object element, final Object value) {
if (value != null) {
((ObserverCallBackObject) element).setControl(control
.getVisualization().getBControl(value.toString()));
}
}
@Override
protected CellEditor getCellEditor(final Object element) {
if (cellEditor == null) {
cellEditor = new ComboBoxViewerCellEditor(
(Composite) getViewer().getControl(), SWT.READ_ONLY);
cellEditor
.setContenProvider(new ObservableListContentProvider());
cellEditor.setInput(new ComputedList() {
@Override
protected List<String> calculate() {
ArrayList<String> tmpList = new ArrayList<String>();
for (String controlID : control.getVisualization()
.getAllBControlIDs()) {
tmpList.add(controlID);
}
return tmpList;
}
});
((CCombo) cellEditor.getControl())
.addFocusListener(new FocusListener() {
String oldValue;
public void focusGained(final FocusEvent e) {
oldValue = ((CCombo) cellEditor.getControl())
.getText();
}
public void focusLost(final FocusEvent e) {
if (!oldValue.equals(((CCombo) cellEditor
.getControl()).getText())) {
IStructuredSelection selection = (IStructuredSelection) getViewer()
.getSelection();
ObserverCallBackObject obj = (ObserverCallBackObject) selection
.getFirstElement();
obj.setObserverID("");
tableViewer.refresh();
}
}
});
}
return cellEditor;
}
}
private static class ObserverValueEditing extends EditingSupport {
private ComboBoxViewerCellEditor cellEditor = null;
// private final BControl control;
public ObserverValueEditing(final TableViewer cv, final BControl control) {
super(cv);
// this.control = control;
}
@Override
protected boolean canEdit(final Object element) {
return true;
}
@Override
protected Object getValue(final Object element) {
if (((ObserverCallBackObject) element).getObserverID() != null) {
return ((ObserverCallBackObject) element).getObserverID();
} else {
return "";
}
}
@Override
protected void setValue(final Object element, final Object value) {
if (value != null) {
((ObserverCallBackObject) element).setObserverID(value
.toString());
}
}
@Override
protected CellEditor getCellEditor(final Object element) {
if (cellEditor == null) {
cellEditor = new ComboBoxViewerCellEditor(
(Composite) getViewer().getControl(), SWT.READ_ONLY);
cellEditor
.setContenProvider(new ObservableListContentProvider());
}
// cellEditor.setInput(new ComputedList() {
// @Override
// protected List<String> calculate() {
//
// ArrayList<String> tmpList = new ArrayList<String>();
//
// ObserverCallBackObject obj = (ObserverCallBackObject) element;
// BControl control = obj.getControl();
// if (control != null) {
//
// for (String id : control.getObservers().keySet()) {
// tmpList.add(id);
// }
//
// }
//
// return tmpList;
//
// }
// });
return cellEditor;
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment