Author: DartPeng
Date: 2009-04-07 06:15:45 -0400 (Tue, 07 Apr 2009)
New Revision: 14542
Added:
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/IPropertyUICreator.java
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/PropertyUICreatorManager.java
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksStuffDetailsPageProvider.java
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksStuffPropertyDetailPage.java
Modified:
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/edit/common/provider/AbstractAnyTypeItemProvider.java
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksMasterDetailBlock.java
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksMultiFormEditor.java
Log:
Modified:
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/edit/common/provider/AbstractAnyTypeItemProvider.java
===================================================================
---
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/edit/common/provider/AbstractAnyTypeItemProvider.java 2009-04-07
09:48:50 UTC (rev 14541)
+++
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.core/src/org/jboss/tools/smooks/edit/common/provider/AbstractAnyTypeItemProvider.java 2009-04-07
10:15:45 UTC (rev 14542)
@@ -15,7 +15,6 @@
import org.eclipse.emf.common.util.ResourceLocator;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.util.FeatureMapUtil;
-import org.eclipse.emf.ecore.xml.type.XMLTypeFactory;
import org.eclipse.emf.ecore.xml.type.XMLTypePackage;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
@@ -28,10 +27,6 @@
import org.jboss.tools.smooks.edit.xsl.provider.Xsl1EditPlugin;
import org.jboss.tools.smooks.model.common.AbstractAnyType;
import org.jboss.tools.smooks.model.common.CommonPackage;
-import org.jboss.tools.smooks.model.smooks.SmooksFactory;
-import org.jboss.tools.smooks.model.smooks.SmooksPackage;
-import org.jboss.tools.smooks.model.xsl.XslFactory;
-import org.jboss.tools.smooks.model.xsl.XslPackage;
/**
@@ -58,6 +53,10 @@
super(adapterFactory);
}
+ protected boolean isWrappingNeeded(Object object){
+ wrappingNeeded = null;
+ return super.isWrappingNeeded(object);
+ }
/**
* This returns the property descriptors for the adapted class.
* <!-- begin-user-doc -->
Added:
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/IPropertyUICreator.java
===================================================================
---
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/IPropertyUICreator.java
(rev 0)
+++
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/IPropertyUICreator.java 2009-04-07
10:15:45 UTC (rev 14542)
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.configuration.editors;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ * <p>
+ * Apr 7, 2009
+ */
+public interface IPropertyUICreator {
+ public void createPropertyUI(FormToolkit toolkit, Composite parent,
+ IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute feature);
+}
Property changes on:
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/IPropertyUICreator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/PropertyUICreatorManager.java
===================================================================
---
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/PropertyUICreatorManager.java
(rev 0)
+++
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/PropertyUICreatorManager.java 2009-04-07
10:15:45 UTC (rev 14542)
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.configuration.editors;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)<p>
+ * Apr 7, 2009
+ */
+public class PropertyUICreatorManager {
+ private static PropertyUICreatorManager instance;
+
+ private Map<Class<?>,IPropertyUICreator> map = null;
+
+ private PropertyUICreatorManager(){
+ map = new HashMap<Class<?>,IPropertyUICreator>();
+ }
+
+ public void registePropertyUICreator(Class<?> key,IPropertyUICreator creator){
+ map.put(key, creator);
+ }
+
+ public IPropertyUICreator getPropertyUICreator(Class<?> key){
+ return map.get(key);
+ }
+
+ public IPropertyUICreator getPropertyUICreator(Object model){
+ return map.get(model.getClass());
+ }
+
+ public static synchronized PropertyUICreatorManager getInstance() {
+ if(instance == null){
+ instance = new PropertyUICreatorManager();
+ }
+ return instance;
+ }
+}
Property changes on:
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/PropertyUICreatorManager.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksMasterDetailBlock.java
===================================================================
---
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksMasterDetailBlock.java 2009-04-07
09:48:50 UTC (rev 14541)
+++
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksMasterDetailBlock.java 2009-04-07
10:15:45 UTC (rev 14542)
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008 Red Hat, Inc.
+ * Copyright (c) 2009 Red Hat, Inc.
* Distributed under license by Red Hat, Inc. All rights reserved.
* This program is made available under the terms of the
* Eclipse Public License v1.0 which accompanies this distribution,
@@ -10,12 +10,12 @@
******************************************************************************/
package org.jboss.tools.smooks.configuration.editors;
+import java.util.ArrayList;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.impl.EStructuralFeatureImpl.BasicFeatureMapEntry;
-import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.xml.type.XMLTypePackage;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.provider.IWrapperItemProvider;
@@ -27,6 +27,9 @@
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
@@ -46,9 +49,12 @@
import org.eclipse.ui.forms.widgets.Section;
/**
- * @author Dart Peng (dpeng(a)redhat.com) Date Apr 1, 2009
+ * @author Dart Peng (dpeng(a)redhat.com)
+ * <p>
+ * Date Apr 1, 2009
*/
-public class SmooksMasterDetailBlock extends MasterDetailsBlock implements IMenuListener
{
+public class SmooksMasterDetailBlock extends MasterDetailsBlock implements
IMenuListener,
+ ISelectionChangedListener {
private Section configurationSection;
private SectionPart sectionPart;
@@ -101,7 +107,12 @@
*/
@Override
protected void registerPages(DetailsPart detailsPart) {
-
+ SmooksStuffDetailsPageProvider provider = new SmooksStuffDetailsPageProvider();
+ detailsPart.setPageProvider(provider);
+ // provider.registePage(ResourceType.class, new
+ // SmooksStuffPropertyDetailPage());
+ detailsPart.registerPage(EObject.class, new SmooksStuffPropertyDetailPage(
+ (SmooksMultiFormEditor) this.formEditor));
}
protected void createSmooksTreeViewer(FormToolkit tool, final IManagedForm managedForm,
@@ -126,14 +137,17 @@
fillLayout.marginHeight = 1;
fillLayout.marginWidth = 1;
tableComposite.setLayout(fillLayout);
- smooksTreeViewer = new TreeViewer(tableComposite, SWT.NONE);
+ smooksTreeViewer = new TreeViewer(tableComposite, SWT.NONE) {
+
+ };
+ smooksTreeViewer.addSelectionChangedListener(this);
smooksTreeViewer.setContentProvider(new AdapterFactoryContentProvider(editingDomain
.getAdapterFactory()));
smooksTreeViewer.setLabelProvider(new
AdapterFactoryLabelProvider(editingDomain.getAdapterFactory()));
smooksTreeViewer.setFilters(new ViewerFilter[] { new TextEObjectModelFilter() });
Object smooksModel = ((SmooksMultiFormEditor) this.formEditor).getSmooksModel();
if (smooksModel != null) {
- smooksTreeViewer.setInput(smooksModel);
+ smooksTreeViewer.setInput(editingDomain.getResourceSet());
}
createMenuForViewer(smooksTreeViewer);
formEditor.getSite().setSelectionProvider(smooksTreeViewer);
@@ -142,6 +156,7 @@
smooksTreeViewer.addSelectionChangedListener((ISelectionChangedListener) formEditor
.getEditorSite().getActionBarContributor());
}
+ smooksTreeViewer.addSelectionChangedListener(this);
gd = new GridData(GridData.FILL_BOTH);
tableComposite.setLayoutData(gd);
@@ -213,7 +228,36 @@
}
public void setSmooksModel(Object model) {
- smooksTreeViewer.setInput(model);
+ if (model != null) {
+ smooksTreeViewer.setInput(model);
+ } else {
+ smooksTreeViewer.setInput(new Object());
+ }
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(
+ * org.eclipse.jface.viewers.SelectionChangedEvent)
+ */
+ public void selectionChanged(SelectionChangedEvent event) {
+ if (sectionPart != null && sectionPart.getManagedForm() != null) {
+ Object[] objs = ((IStructuredSelection) event.getSelection()).toArray();
+ List<Object> objList = new ArrayList<Object>();
+ for (int i = 0; i < objs.length; i++) {
+ Object obj = objs[i];
+ obj = AdapterFactoryEditingDomain.unwrap(obj);
+ objList.add(obj);
+ }
+ if (objList.isEmpty()) {
+ sectionPart.getManagedForm().fireSelectionChanged(sectionPart,
event.getSelection());
+ } else {
+ sectionPart.getManagedForm().fireSelectionChanged(sectionPart,
+ new StructuredSelection(objList.toArray()));
+ }
+ }
+ }
+
}
Modified:
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksMultiFormEditor.java
===================================================================
---
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksMultiFormEditor.java 2009-04-07
09:48:50 UTC (rev 14541)
+++
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksMultiFormEditor.java 2009-04-07
10:15:45 UTC (rev 14542)
@@ -13,6 +13,7 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.EventObject;
@@ -34,10 +35,12 @@
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
+import org.eclipse.emf.edit.command.AddCommand;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.domain.EditingDomain;
import org.eclipse.emf.edit.domain.IEditingDomainProvider;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.emf.edit.provider.IWrapperItemProvider;
import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory;
import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory;
import org.eclipse.jface.text.DocumentEvent;
@@ -95,7 +98,7 @@
// Try to select the affected objects.
//
Command mostRecentCommand = ((CommandStack)
event.getSource()).getMostRecentCommand();
- if (mostRecentCommand != null) {
+ if (mostRecentCommand != null && (mostRecentCommand instanceof AddCommand))
{
setSelectionToViewer(mostRecentCommand.getAffectedObjects());
}
if (propertySheetPage != null &&
!propertySheetPage.getControl().isDisposed()) {
@@ -169,7 +172,14 @@
public void setSelectionToViewer(Collection<?> collection) {
final Collection<?> theSelection = collection;
if (theSelection != null && !theSelection.isEmpty() &&
configurationPage != null) {
- configurationPage.setSelectionToViewer(collection);
+ List<Object> newList = new ArrayList<Object>();
+ for (Iterator<?> iterator = theSelection.iterator(); iterator.hasNext();) {
+ Object object = (Object) iterator.next();
+ if(object instanceof IWrapperItemProvider){
+ newList.add(((IWrapperItemProvider)object).getValue());
+ }
+ }
+ configurationPage.setSelectionToViewer(newList);
}
}
@@ -223,7 +233,6 @@
if (handleEMFModelChange) {
handleEMFModelChange = false;
-// handleDocumentChange();
} else {
timerTask = new TimerTask() {
@Override
@@ -258,10 +267,11 @@
try {
resource.load(new ByteArrayInputStream(conents.getBytes()), Collections.emptyMap());
this.smooksModel = resource.getContents().get(0);
- configurationPage.setSmooksModel(this.smooksModel);
} catch (IOException e) {
- e.printStackTrace();
+ smooksModel = null;
+ SmooksConfigurationActivator.getDefault().log(e);
}
+ configurationPage.setSmooksModel(this.smooksModel);
}
protected SmooksConfigurationFormPage createSmooksConfigurationFormPage() {
@@ -280,6 +290,13 @@
*/
@Override
public void doSave(IProgressMonitor monitor) {
+ IEditorPart activeEditor = getActiveEditor();
+ if(activeEditor != null && activeEditor == textEditor){
+ textEditor.doSave(monitor);
+ ((BasicCommandStack) editingDomain.getCommandStack()).saveIsDone();
+ firePropertyChange(PROP_DIRTY);
+ return;
+ }
Map<?, ?> options = Collections.emptyMap();
initSaveOptions(options);
if (editingDomain != null) {
@@ -339,30 +356,6 @@
}
- protected void pageChange(int newPageIndex) {
- int index = this.getActivePage();
- if (index == newPageIndex) {
- super.pageChange(newPageIndex);
- return;
- }
- if (isDirty()) {
- if (index == 0 && newPageIndex == 1) {
- synchronizeModelToText();
- }
- if (index == 1 && newPageIndex == 0) {
- synchronizeTextToModel();
- }
- }
- }
-
- private void synchronizeTextToModel() {
-
- }
-
- private void synchronizeModelToText() {
-
- }
-
public ComposedAdapterFactory getAdapterFactory() {
return adapterFactory;
}
Added:
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksStuffDetailsPageProvider.java
===================================================================
---
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksStuffDetailsPageProvider.java
(rev 0)
+++
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksStuffDetailsPageProvider.java 2009-04-07
10:15:45 UTC (rev 14542)
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.configuration.editors;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.ui.forms.IDetailsPage;
+import org.eclipse.ui.forms.IDetailsPageProvider;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ * <p>
+ * Apr 7, 2009
+ */
+public class SmooksStuffDetailsPageProvider implements IDetailsPageProvider {
+ private Map<Object, IDetailsPage> pages = new HashMap<Object,
IDetailsPage>();
+
+ public void registePage(Object key , IDetailsPage page){
+ pages.put(key, page);
+ }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.ui.forms.IDetailsPageProvider#getPage(java.lang.Object)
+ */
+ public IDetailsPage getPage(Object key) {
+ return pages.get(key);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.forms.IDetailsPageProvider#getPageKey(java.lang.Object)
+ */
+ public Object getPageKey(Object object) {
+ if(object instanceof EObject){
+ return EObject.class;
+ }
+ return object.getClass();
+ }
+
+}
Property changes on:
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksStuffDetailsPageProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksStuffPropertyDetailPage.java
===================================================================
---
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksStuffPropertyDetailPage.java
(rev 0)
+++
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksStuffPropertyDetailPage.java 2009-04-07
10:15:45 UTC (rev 14542)
@@ -0,0 +1,258 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.configuration.editors;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
+import org.eclipse.emf.edit.provider.IItemPropertySource;
+import org.eclipse.emf.edit.provider.ItemPropertyDescriptor.PropertyValueWrapper;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.IDetailsPage;
+import org.eclipse.ui.forms.IFormPart;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Section;
+
+/**
+ *
+ * @author Dart (dpeng(a)redhat.com)
+ * <p>
+ * Apr 7, 2009
+ */
+public class SmooksStuffPropertyDetailPage implements IDetailsPage {
+ FormToolkit formToolKit = null;
+ private IManagedForm managedForm;
+ private ISelection selection;
+ private IFormPart formPart;
+ private Section section;
+ private SmooksMultiFormEditor formEditor;
+ private AdapterFactoryLabelProvider labelProvider = null;
+ private AdapterFactoryEditingDomain editingDomain = null;
+ private IItemPropertySource itemPropertySource = null;
+
+ private Object oldModel = null;
+
+ private boolean isStale = false;
+ private Composite propertyMainComposite;
+ private Composite propertyComposite;
+
+ public SmooksStuffPropertyDetailPage(SmooksMultiFormEditor formEditor) {
+ super();
+ this.formEditor = formEditor;
+ editingDomain = (AdapterFactoryEditingDomain) formEditor.getEditingDomain();
+ labelProvider = new AdapterFactoryLabelProvider(editingDomain.getAdapterFactory());
+ }
+
+ public void createContents(Composite parent) {
+ parent.setLayout(new FillLayout());
+ section = formToolKit.createSection(parent, Section.DESCRIPTION | Section.TITLE_BAR);
+
+ Composite client = formToolKit.createComposite(section);
+ section.setLayout(new FillLayout());
+ section.setClient(client);
+ createSectionContents(client);
+ }
+
+ private void createSectionContents(Composite client) {
+ client.setLayout(new FillLayout());
+ propertyMainComposite = new Composite(client, SWT.NONE);
+ propertyMainComposite.setLayout(new FillLayout());
+ propertyComposite = new Composite(propertyMainComposite, SWT.NONE);
+ }
+
+ /**
+ *
+ * @param propertyComposite
+ */
+ protected void createPropertyComposite(Composite propertyComposite) {
+ try {
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ propertyComposite.setLayout(layout);
+ IPropertyUICreator creator =
PropertyUICreatorManager.getInstance().getPropertyUICreator(
+ getModel());
+ List<IItemPropertyDescriptor> propertyDes =
itemPropertySource.getPropertyDescriptors(getModel());
+ for (Iterator<IItemPropertyDescriptor> iterator = propertyDes.iterator();
iterator.hasNext();) {
+ final IItemPropertyDescriptor itemPropertyDescriptor = (IItemPropertyDescriptor)
iterator.next();
+ EAttribute feature = (EAttribute) itemPropertyDescriptor.getFeature(getModel());
+ if (creator != null) {
+ creator.createPropertyUI(formToolKit, propertyComposite, itemPropertyDescriptor,
+ getModel(), feature);
+ } else {
+ String displayName = itemPropertyDescriptor.getDisplayName(getModel());
+ formToolKit.createLabel(propertyComposite, displayName + " :");
+ EClassifier typeClazz = feature.getEType();
+ if (typeClazz.getInstanceClass() == String.class) {
+ final Text text = formToolKit.createText(propertyComposite, "",
SWT.NONE);
+ final Object value = itemPropertyDescriptor.getPropertyValue(getModel());
+ if (value != null && value instanceof PropertyValueWrapper) {
+ Object editValue = ((PropertyValueWrapper) value).getEditableValue(getModel());
+ if (editValue != null)
+ text.setText(editValue.toString());
+ }
+ text.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ if (value != null && value instanceof PropertyValueWrapper) {
+ Object editValue = ((PropertyValueWrapper) value).getEditableValue(getModel());
+ if (editValue != null){
+ if(!editValue.equals(text.getText())){
+ itemPropertyDescriptor.setPropertyValue(getModel(), text.getText());
+ }
+ }else{
+ itemPropertyDescriptor.setPropertyValue(getModel(), text.getText());
+ }
+ }else{
+ itemPropertyDescriptor.setPropertyValue(getModel(), text.getText());
+ }
+ }
+ });
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ text.setLayoutData(gd);
+ }
+ }
+ }
+ formToolKit.paintBordersFor(propertyComposite);
+ propertyComposite.pack();
+ propertyMainComposite.layout();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.forms.IPartSelectionListener#selectionChanged(org.eclipse
+ * .ui.forms.IFormPart, org.eclipse.jface.viewers.ISelection)
+ */
+ public void selectionChanged(IFormPart part, ISelection selection) {
+ Object oldModel = getModel();
+ setOldModel(oldModel);
+ this.selection = selection;
+ this.formPart = part;
+ this.itemPropertySource = (IItemPropertySource)
editingDomain.getAdapterFactory().adapt(getModel(),
+ IItemPropertySource.class);
+ if (getOldModel() == getModel())
+ return;
+ if (getOldModel() != getModel()) {
+ if (propertyComposite != null) {
+ propertyComposite.dispose();
+ propertyComposite = new Composite(propertyMainComposite, SWT.NONE);
+ }
+ createPropertyComposite(propertyComposite);
+ }
+// if ((getModel() != null && getOldModel() != null)) {
+// if ((getModel().getClass() != getOldModel().getClass())) {
+// if (propertyComposite != null) {
+// propertyComposite.dispose();
+// propertyComposite = new Composite(propertyMainComposite, SWT.NONE);
+// }
+// createPropertyComposite(propertyComposite);
+// }
+// }
+ refreshWhenSelectionChanged();
+ }
+
+ public void commit(boolean onSave) {
+
+ }
+
+ public void dispose() {
+
+ }
+
+ public IFormPart getFormPart() {
+ return formPart;
+ }
+
+ public void initialize(IManagedForm form) {
+ this.managedForm = form;
+ if (managedForm != null) {
+ formToolKit = managedForm.getToolkit();
+ }
+ }
+
+ public boolean isDirty() {
+ return false;
+ }
+
+ public boolean isStale() {
+ return this.isStale;
+ }
+
+ public void refresh() {
+ }
+
+ public void setFocus() {
+
+ }
+
+ public boolean setFormInput(Object input) {
+ return false;
+ }
+
+ public ISelection getSelection() {
+ return selection;
+ }
+
+ public void setSelection(ISelection selection) {
+ this.selection = selection;
+ }
+
+ public Object getModel() {
+ if (selection != null && selection instanceof IStructuredSelection) {
+ return ((IStructuredSelection) selection).getFirstElement();
+ }
+ return null;
+ }
+
+ protected void refreshWhenSelectionChanged() {
+ Object model = getModel();
+ if (model instanceof EObject) {
+ String text = labelProvider.getText(model);
+ section.setText(text);
+ section.setDescription("Details of " + text);
+ }
+ }
+
+ public SmooksMultiFormEditor getFormEditor() {
+ return formEditor;
+ }
+
+ protected Object getOldModel() {
+ return oldModel;
+ }
+
+ protected void setOldModel(Object oldModel) {
+ this.oldModel = oldModel;
+ }
+
+ public void setStale(boolean isStale) {
+ this.isStale = isStale;
+ }
+}
Property changes on:
workspace/dart/smooksConfigurationsEditor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksStuffPropertyDetailPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain