1 17 package org.eclipse.emf.mapping.provider; 18 19 20 import java.util.Collection ; 21 import java.util.List ; 22 23 import org.eclipse.emf.common.command.Command; 24 import org.eclipse.emf.common.notify.AdapterFactory; 25 import org.eclipse.emf.common.notify.Notification; 26 import org.eclipse.emf.common.util.ResourceLocator; 27 import org.eclipse.emf.edit.command.CommandParameter; 28 import org.eclipse.emf.edit.domain.EditingDomain; 29 import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; 30 import org.eclipse.emf.edit.provider.IItemLabelProvider; 31 import org.eclipse.emf.edit.provider.IItemPropertySource; 32 import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; 33 import org.eclipse.emf.edit.provider.ITreeItemContentProvider; 34 36 import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; 37 import org.eclipse.emf.mapping.MappingPackage; 38 import org.eclipse.emf.mapping.MappingPlugin; 39 import org.eclipse.emf.mapping.MappingRoot; 40 import org.eclipse.emf.mapping.command.AddMappingCommand; 41 import org.eclipse.emf.mapping.command.CreateMappingCommand; 42 import org.eclipse.emf.mapping.command.RemoveMappingCommand; 43 import org.eclipse.emf.mapping.command.RestoreInitialStateCommand; 44 import org.eclipse.emf.mapping.domain.MappingDomain; 45 46 47 50 public class MappingRootItemProvider 51 extends MappingItemProvider 52 implements 53 IEditingDomainItemProvider, 54 IStructuredItemContentProvider, 55 ITreeItemContentProvider, 56 IItemLabelProvider, 57 IItemPropertySource 58 { 59 62 public MappingRootItemProvider(AdapterFactory adapterFactory) 63 { 64 super(adapterFactory); 65 } 66 67 70 public List getPropertyDescriptors(Object object) 71 { 72 if (itemPropertyDescriptors == null) 73 { 74 super.getPropertyDescriptors(object); 75 76 MappingRoot mappingRoot = (MappingRoot)object; 77 MappingPackage ePackage = MappingPackage.eINSTANCE; 79 80 boolean isTypeMapping = mappingRoot.getDomain() == null; 81 82 if (!isTypeMapping) 83 { 84 itemPropertyDescriptors.add 87 (new ItemPropertyDescriptor 88 (adapterFactory, 89 MappingPlugin.getPlugin().getString("_UI_OutputReadOnly_property_label"), 90 MappingPlugin.getPlugin().getString("_UI_OutputReadOnly_property_description"), 91 ePackage.getMappingRoot_OutputReadOnly(), 92 true, 93 ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE)); 94 95 itemPropertyDescriptors.add 98 (new ItemPropertyDescriptor 99 (adapterFactory, 100 MappingPlugin.getPlugin().getString("_UI_TopToBottom_property_label"), 101 MappingPlugin.getPlugin().getString("_UI_TopToBottom_property_description"), 102 ePackage.getMappingRoot_TopToBottom(), 103 false, 104 ItemPropertyDescriptor.BOOLEAN_VALUE_IMAGE)); 105 } 106 } 107 return itemPropertyDescriptors; 108 } 109 110 116 public String getText(Object object) 117 { 118 return super.getText(object); 119 } 120 121 124 public void notifyChanged(Notification msg) 125 { 126 MappingPackage ePackage = MappingPackage.eINSTANCE; 128 if (msg.getFeature() == ePackage.getMappingRoot_OutputReadOnly() || msg.getFeature() == ePackage.getMappingRoot_TopToBottom()) 129 { 130 fireNotifyChanged(msg); 131 return; 133 } 134 super.notifyChanged(msg); 135 } 136 137 public Command createCommand(Object object, EditingDomain editingDomain, Class commandClass, CommandParameter commandParameter) 138 { 139 if (editingDomain instanceof MappingDomain) { 141 MappingDomain mappingDomain = (MappingDomain)editingDomain; 142 143 if (commandClass == CreateMappingCommand.class) 144 { 145 return createCreateMappingCommand(mappingDomain, commandParameter.getCollection()); 146 } 147 else if (commandClass == AddMappingCommand.class) 148 { 149 return createAddMappingCommand(mappingDomain, commandParameter.getCollection()); 150 } 151 else if (commandClass == RemoveMappingCommand.class) 152 { 153 return createRemoveMappingCommand(mappingDomain, commandParameter.getCollection()); 154 } 155 else if (commandClass == RestoreInitialStateCommand.class) 156 { 157 return createRestoreInitialStateCommand(mappingDomain); 158 } 159 } 160 161 return super.createCommand(object, editingDomain, commandClass, commandParameter); 162 } 163 164 167 protected Command createCreateMappingCommand(MappingDomain domain, Collection collection) 168 { 169 return new CreateMappingCommand(domain, collection); 170 } 171 172 175 protected Command createAddMappingCommand(MappingDomain domain, Collection collection) 176 { 177 return new AddMappingCommand(domain, collection); 178 } 179 180 183 protected Command createRemoveMappingCommand(MappingDomain domain, Collection collection) 184 { 185 return new RemoveMappingCommand(domain, collection); 186 } 187 188 191 protected Command createRestoreInitialStateCommand(MappingDomain domain) 192 { 193 return new RestoreInitialStateCommand(domain); 194 } 195 196 202 public ResourceLocator getResourceLocator() 203 { 204 return MappingPlugin.INSTANCE; 205 } 206 207 } 208 | Popular Tags |