import org.eclipse.gef.commands.CommandStack;
import org.tizen.webuibuilder.BuilderConstants;
import org.tizen.webuibuilder.gef.commands.SetPartPropertyCommand;
-import org.tizen.webuibuilder.model.IPartListener;
import org.tizen.webuibuilder.model.Part;
-import org.tizen.webuibuilder.model.PartEvent;
+import org.tizen.webuibuilder.model.page.IPageDataListener;
+import org.tizen.webuibuilder.model.page.PageDataEvent;
-public class DataBindingEventDelegater implements IPartListener {
+public class DataBindingEventDelegater implements IPageDataListener {
private CommandStack commandStack;
private DataBindingPage dataBindingPage;
this.commandStack = commandStack;
this.dataBindingPage = dataBindingPage;
}
-
- @Override
- public void childAdded(PartEvent event) {
- }
-
+
@Override
- public void childMoved(PartEvent event) {
+ public void pagePreDelete(PageDataEvent e) {
}
@Override
- public void childRemoved(PartEvent event) {
+ public void pageRenamed(PageDataEvent e) {
}
@Override
- public void propertyChanged(PartEvent event) {
+ public void pageChanged(PageDataEvent e) {
dataBindingPage.refresh();
}
-
- @Override
- public void positionChanged(PartEvent event) {
- }
-
- @Override
- public void eventChanged(PartEvent event) {
- }
-
- @Override
- public void visualPositionChanged(PartEvent event) {
- }
-
- @Override
- public void needRefresh(PartEvent event) {
- }
public void valueChanged(Part part, String attributeDataBind,
String value, boolean undoable) {
private RemoveBindingInfoAction removeBindingInfoAction;
private PageDesigner pageDesigner = null;
private DataBindingEventDelegater delegater;
- private Part oldSelectedModel = null;
+ private List<Part> pageList = new ArrayList<Part>();
private IAction undoHandler;
private IAction redoHandler;
//private List<String> itemPath;
}
private void addListeners(Part model) {
- if (model != null) {
- model.addPartListener(delegater);
+ if (pageDesigner != null) {
+ PageData pageData = pageDesigner.getAppManager().getPageData(model.getPropertyValue("id"));
+ pageData.addPageListener(delegater);
}
}
private void removeListeners(Part model) {
- if (model != null) {
- // TODO : support multi selection
- model.removePartListener(delegater);
- }
+ if (pageDesigner != null) {
+ PageData pageData = pageDesigner.getAppManager().getPageData(model.getPropertyValue("id"));
+ pageData.removePageListener(delegater);
+ }
}
/**
for (PageData pageData : pages) {
List<Part> parts = pageData.getPagePart().getChildren();
// parts.get(0).getProperty(BuilderConstants.ATTRIBUTE_DATA_BIND);
- refreshBindingInfo(parts);
+ refreshBindingInfo(parts);
}
}
}
@Override
public void dispose() {
- pageDesigner.getAppManager().getBindingDataSet().removePageListener(this);
+ if (pageDesigner != null) {
+ pageDesigner.getAppManager().getBindingDataSet().removeBindingDataListener(this);
+ }
+
+ for (Part pagePart : pageList) {
+ removeListeners(pagePart);
+ }
+ pageList.clear();
super.dispose();
}
}
});
-
makeBindingInfoContextMenu();
}
return this.pageDesigner;
}
-
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
if (selection instanceof StructuredSelection && !selection.isEmpty()) {
StructuredSelection ssel = (StructuredSelection) selection;
}
}
-
- if ((oldSelectedModel == null) || (!oldSelectedModel.equals(selModels.get(0)))) {
- removeListeners(oldSelectedModel);
- addListeners(selModels.get(0));
- oldSelectedModel = selModels.get(0);
- }
-
+ if (selModels.get(0).getOwnerPage() != null) {
+ if (!pageList.contains(selModels.get(0).getOwnerPage())) {
+ pageList.add(selModels.get(0).getOwnerPage());
+ addListeners(selModels.get(0).getOwnerPage());
+ }
+ }
}
}
}