PAGES: Apply synchronization between pages view and properties view 72/20672/1
authoryoungduk.hwang <youngduk.hwang@samsung.com>
Mon, 12 May 2014 02:42:27 +0000 (11:42 +0900)
committeryoungduk.hwang <youngduk.hwang@samsung.com>
Mon, 12 May 2014 02:42:27 +0000 (11:42 +0900)
properties view is changed to the page's When a user click a page in pages view

Change-Id: I1e7ad7f1cabea8ac5894609b43b0839a5c17b612
Signed-off-by: youngduk.hwang <youngduk.hwang@samsung.com>
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/pages/PagesPage.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/pages/PagesView.java
org.tizen.webuibuilder/src/org/tizen/webuibuilder/ui/views/properties/PropertiesPage.java

index af954e4..a02dc8d 100644 (file)
@@ -20,7 +20,6 @@
  *
  */
 
-
 package org.tizen.webuibuilder.ui.views.pages;
 
 import org.eclipse.draw2d.ColorConstants;
@@ -37,202 +36,209 @@ import org.tizen.webuibuilder.model.page.IPageDataSetListener;
 import org.tizen.webuibuilder.model.page.PageDataSet;
 import org.tizen.webuibuilder.model.page.PageDataSetEvent;
 
-
-public class PagesPage extends Page implements IAppListener, IPageDataSetListener {
-
-    private AppManager appManager;
-    // controls
-    private EditDomain editDomain;
-    private ImageViewer viewer;
-    // selections
-    private SelectionSynchronizer selectionSyncronizer;
-    // actions
-    private ActionRegistry actionRegistry;
-
-    public PagesPage(SelectionSynchronizer selectionSyncronizer, EditDomain editDomain,
-            ActionRegistry actionRegistry) {
-        this.viewer = new ImageViewer();
-        this.selectionSyncronizer = selectionSyncronizer;
-        this.editDomain = editDomain;
-        this.actionRegistry = actionRegistry;
-    }
-
-    public void setAppManager(AppManager appManager) {
-        this.appManager = appManager;
-    }
-
-    public AppManager getAppManager() {
-        return appManager;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.eclipse.ui.part.Page#createControl(org.eclipse.swt.widgets.Composite)
-     */
-    @Override
-    public void createControl(Composite parent) {
-        configureToolBar();
-        viewer.createControl(parent);
-        viewer.setEditDomain(editDomain);
-        viewer.setEditPartFactory(new ThumbnailEditPartFactory());
-        viewer.getControl().setBackground(ColorConstants.listBackground);
-        viewer.setContextMenu(new PagesViewContextMenu(viewer, actionRegistry));
-        getSite().setSelectionProvider(viewer);
-        selectionSyncronizer.addViewer(viewer);
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.eclipse.ui.part.Page#dispose()
-     */
-    @Override
-    public void dispose() {
-        selectionSyncronizer.removeViewer(viewer);
-        removeListeners();
-        super.dispose();
-    }
-
-    private void configureToolBar() {
-        // IActionBars actionBars = getSite().getActionBars();
-        // IToolBarManager toolBarManager = actionBars.getToolBarManager();
-        // IAction action = null;
-        // action = actionRegistry.getAction(ActionFactory.UNDO.getId());
-        // toolBarManager.add(action);
-        // action = actionRegistry.getAction(ActionFactory.REDO.getId());
-        // toolBarManager.add(action);
-        // actionBars.updateActionBars();
-    }
-
-    private void addListeners() {
-        getAppManager().addPageListener(this);
-    }
-
-    private void removeListeners() {
-        getAppManager().removePageListener(this);
-    }
-
-    public void setInput(AppManager appManager) {
-        if (appManager == null) {
-            return;
-        }
-        ((ThumbnailEditPartFactory) viewer.getEditPartFactory()).setAppManager(appManager);
-        PageDataSet pageDataSet = appManager.getPageDataSet();
-        if (pageDataSet != null) {
-            viewer.setContents(pageDataSet.getBaseRootPart());
-            pageDataSet.addPageListener(this);
-        }
-        setAppManager(appManager);
-        addListeners();
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.eclipse.ui.part.Page#getControl()
-     */
-    @Override
-    public Control getControl() {
-        return viewer.getControl();
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.eclipse.ui.part.Page#setFocus()
-     */
-    @Override
-    public void setFocus() {
-        viewer.getControl().setFocus();
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.tizen.webuibuilder.model.project.IProjectListener#pageAdded(org.tizen
-     * .webuibuilder.model.project.ProjectEvent)
-     */
-    @Override
-    public void pageAdded(PageDataSetEvent e) {
-        Object model = appManager.getPageDataSet().getBaseRootPart();
-        viewer.setContents(model);
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.tizen.webuibuilder.model.project.IProjectListener#pageRemoved(org
-     * .tizen.webuibuilder.model.project.ProjectEvent)
-     */
-    @Override
-    public void pageRemoved(PageDataSetEvent e) {
-        Object model = appManager.getPageDataSet().getBaseRootPart();
-        viewer.setContents(model);
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.tizen.webuibuilder.model.project.IProjectListener#pageRenamed(org
-     * .tizen.webuibuilder.model.project.ProjectEvent)
-     */
-    @Override
-    public void pageRenamed(PageDataSetEvent e) {
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.tizen.webuibuilder.model.project.IProjectListener#pageMoved(org.tizen
-     * .webuibuilder.model.project.ProjectEvent)
-     */
-    @Override
-    public void pageMoved(PageDataSetEvent e) {
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.tizen.webuibuilder.model.project.IProjectListener#pageStartupChanged
-     * (org.tizen.webuibuilder.model.project.ProjectEvent)
-     */
-    @Override
-    public void pageStartupChanged(AppEvent e) {
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.tizen.webuibuilder.model.project.IProjectListener#pageLayoutChanged
-     * (org.tizen.webuibuilder.model.project.ProjectEvent)
-     */
-    @Override
-    public void pageLayoutChanged(AppEvent e) {
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.tizen.webuibuilder.model.page.IPageDataSetListener#allPagesReseted(org.tizen.webuibuilder
-     * .model.page.PageDataSetEvent)
-     */
-    @Override
-    public void allPagesReseted(PageDataSetEvent e) {
-        Object model = appManager.getPageDataSet().getBaseRootPart();
-        viewer.setContents(model);
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * org.tizen.webuibuilder.model.page.IPageDataSetListener#pagePreDelete(org.tizen.webuibuilder
-     * .model.page.PageDataSetEvent)
-     */
-    @Override
-    public void pagePreDelete(PageDataSetEvent e) {
-    }
-
+public class PagesPage extends Page implements IAppListener,
+               IPageDataSetListener {
+
+       private AppManager appManager;
+       // controls
+       private EditDomain editDomain;
+       private ImageViewer viewer;
+       // selections
+       private SelectionSynchronizer selectionSyncronizer;
+       // actions
+       private ActionRegistry actionRegistry;
+
+       public PagesPage(SelectionSynchronizer selectionSyncronizer,
+                       EditDomain editDomain, ActionRegistry actionRegistry) {
+               this.viewer = new ImageViewer();
+               this.selectionSyncronizer = selectionSyncronizer;
+               this.editDomain = editDomain;
+               this.actionRegistry = actionRegistry;
+       }
+
+       public void setAppManager(AppManager appManager) {
+               this.appManager = appManager;
+       }
+
+       public AppManager getAppManager() {
+               return appManager;
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see
+        * org.eclipse.ui.part.Page#createControl(org.eclipse.swt.widgets.Composite)
+        */
+       @Override
+       public void createControl(Composite parent) {
+               configureToolBar();
+               viewer.createControl(parent);
+               viewer.setEditDomain(editDomain);
+               viewer.setEditPartFactory(new ThumbnailEditPartFactory());
+               viewer.getControl().setBackground(ColorConstants.listBackground);
+               viewer.setContextMenu(new PagesViewContextMenu(viewer, actionRegistry));
+               getSite().setSelectionProvider(viewer);
+               selectionSyncronizer.addViewer(viewer);
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.ui.part.Page#dispose()
+        */
+       @Override
+       public void dispose() {
+               selectionSyncronizer.removeViewer(viewer);
+               removeListeners();
+               super.dispose();
+       }
+
+       private void configureToolBar() {
+               // IActionBars actionBars = getSite().getActionBars();
+               // IToolBarManager toolBarManager = actionBars.getToolBarManager();
+               // IAction action = null;
+               // action = actionRegistry.getAction(ActionFactory.UNDO.getId());
+               // toolBarManager.add(action);
+               // action = actionRegistry.getAction(ActionFactory.REDO.getId());
+               // toolBarManager.add(action);
+               // actionBars.updateActionBars();
+       }
+
+       private void addListeners() {
+               getAppManager().addPageListener(this);
+       }
+
+       private void removeListeners() {
+               getAppManager().removePageListener(this);
+       }
+
+       public void setInput(AppManager appManager) {
+               if (appManager == null) {
+                       return;
+               }
+               ((ThumbnailEditPartFactory) viewer.getEditPartFactory())
+                               .setAppManager(appManager);
+               PageDataSet pageDataSet = appManager.getPageDataSet();
+               if (pageDataSet != null) {
+                       viewer.setContents(pageDataSet.getBaseRootPart());
+                       pageDataSet.addPageListener(this);
+               }
+               setAppManager(appManager);
+               addListeners();
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.ui.part.Page#getControl()
+        */
+       @Override
+       public Control getControl() {
+               return viewer.getControl();
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see org.eclipse.ui.part.Page#setFocus()
+        */
+       @Override
+       public void setFocus() {
+               viewer.getControl().setFocus();
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see
+        * org.tizen.webuibuilder.model.project.IProjectListener#pageAdded(org.tizen
+        * .webuibuilder.model.project.ProjectEvent)
+        */
+       @Override
+       public void pageAdded(PageDataSetEvent e) {
+               Object model = appManager.getPageDataSet().getBaseRootPart();
+               viewer.setContents(model);
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see
+        * org.tizen.webuibuilder.model.project.IProjectListener#pageRemoved(org
+        * .tizen.webuibuilder.model.project.ProjectEvent)
+        */
+       @Override
+       public void pageRemoved(PageDataSetEvent e) {
+               Object model = appManager.getPageDataSet().getBaseRootPart();
+               viewer.setContents(model);
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see
+        * org.tizen.webuibuilder.model.project.IProjectListener#pageRenamed(org
+        * .tizen.webuibuilder.model.project.ProjectEvent)
+        */
+       @Override
+       public void pageRenamed(PageDataSetEvent e) {
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see
+        * org.tizen.webuibuilder.model.project.IProjectListener#pageMoved(org.tizen
+        * .webuibuilder.model.project.ProjectEvent)
+        */
+       @Override
+       public void pageMoved(PageDataSetEvent e) {
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see
+        * org.tizen.webuibuilder.model.project.IProjectListener#pageStartupChanged
+        * (org.tizen.webuibuilder.model.project.ProjectEvent)
+        */
+       @Override
+       public void pageStartupChanged(AppEvent e) {
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see
+        * org.tizen.webuibuilder.model.project.IProjectListener#pageLayoutChanged
+        * (org.tizen.webuibuilder.model.project.ProjectEvent)
+        */
+       @Override
+       public void pageLayoutChanged(AppEvent e) {
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see
+        * org.tizen.webuibuilder.model.page.IPageDataSetListener#allPagesReseted
+        * (org.tizen.webuibuilder .model.page.PageDataSetEvent)
+        */
+       @Override
+       public void allPagesReseted(PageDataSetEvent e) {
+               Object model = appManager.getPageDataSet().getBaseRootPart();
+               viewer.setContents(model);
+       }
+
+       /*
+        * (non-Javadoc)
+        * 
+        * @see
+        * org.tizen.webuibuilder.model.page.IPageDataSetListener#pagePreDelete(
+        * org.tizen.webuibuilder .model.page.PageDataSetEvent)
+        */
+       @Override
+       public void pagePreDelete(PageDataSetEvent e) {
+       }
 }
index c131145..e51337d 100644 (file)
@@ -34,16 +34,16 @@ import org.eclipse.ui.IWorkbenchPage;
 import org.eclipse.ui.IWorkbenchPart;
 import org.eclipse.ui.IWorkbenchWindow;
 import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.part.IContributedContentsView;
 import org.eclipse.ui.part.IPage;
 import org.eclipse.ui.part.MessagePage;
 import org.eclipse.ui.part.PageBook;
 import org.eclipse.ui.part.PageBookView;
-import org.tizen.common.util.Assert;
 import org.tizen.webuibuilder.model.app.AppManager;
 import org.tizen.webuibuilder.ui.editor.PageDesigner;
 
 
-public class PagesView extends PageBookView {
+public class PagesView extends PageBookView implements IContributedContentsView {
     private Clipboard clipboard;
 
     public PagesView() {
@@ -123,7 +123,10 @@ public class PagesView extends PageBookView {
      */
     @Override
     protected PageRec doCreatePage(IWorkbenchPart part) {
-        Assert.isTrue((part instanceof PageDesigner));
+//        Assert.isTrue((part instanceof PageDesigner));
+       if(!(part instanceof PageDesigner)) {
+               return null;
+       }
         PageDesigner pageDesigner = (PageDesigner) part;
         SelectionSynchronizer selectionSyncronizer = pageDesigner.getSelectionSynchronizer();
         if (selectionSyncronizer == null) {
@@ -167,10 +170,25 @@ public class PagesView extends PageBookView {
      */
     @Override
     protected boolean isImportant(IWorkbenchPart part) {
-        if (!(part instanceof PageDesigner)) {
+        return (part instanceof IEditorPart);
+       /*if (!(part instanceof PageDesigner)) {
             return false;
         }
-        return true;
+        return true;*/
+    }
+    
+    @Override
+    @SuppressWarnings("rawtypes")
+    public Object getAdapter(Class key) {
+        if (key == IContributedContentsView.class) {
+               return this;
+        }
+
+        return super.getAdapter(key);
     }
 
+       @Override
+       public IWorkbenchPart getContributingPart() {
+               return getCurrentContributingPart();
+       }
 }
index 67363e8..07f2203 100644 (file)
@@ -57,6 +57,7 @@ import org.tizen.webuibuilder.model.PartEvent;
 import org.tizen.webuibuilder.model.descriptors.DescriptorManager;
 import org.tizen.webuibuilder.model.page.PageData;
 import org.tizen.webuibuilder.ui.editor.PageDesigner;
+import org.tizen.webuibuilder.ui.views.pages.PagesView;
 import org.tizen.webuibuilder.ui.views.properties.action.ActionTab;
 import org.tizen.webuibuilder.ui.views.properties.attributes.AttributesTab;
 import org.tizen.webuibuilder.ui.views.properties.method.MethodCreationFactory;
@@ -297,7 +298,7 @@ public class PropertiesPage extends Page implements IPropertySheetPage, IPartLis
             StructuredSelection ssel = (StructuredSelection) selection;
             // if (mode == PropertiesMode.DESIGN)
             if (part instanceof PageDesigner || part instanceof ContentOutline
-                    || part instanceof TimelineView) {
+                    || part instanceof TimelineView || part instanceof PagesView) {
                 List<Part> selModels = new ArrayList<Part>();
 
                 for (Iterator<?> iter = ssel.iterator(); iter.hasNext();) {