Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'incoming/org.eclipse.papyrus.properties.customization/src/org/eclipse/papyrus/properties/customization/editor/actions/CreateSectionWidgetAction.java')
-rw-r--r--incoming/org.eclipse.papyrus.properties.customization/src/org/eclipse/papyrus/properties/customization/editor/actions/CreateSectionWidgetAction.java127
1 files changed, 0 insertions, 127 deletions
diff --git a/incoming/org.eclipse.papyrus.properties.customization/src/org/eclipse/papyrus/properties/customization/editor/actions/CreateSectionWidgetAction.java b/incoming/org.eclipse.papyrus.properties.customization/src/org/eclipse/papyrus/properties/customization/editor/actions/CreateSectionWidgetAction.java
deleted file mode 100644
index 5858d5f1245..00000000000
--- a/incoming/org.eclipse.papyrus.properties.customization/src/org/eclipse/papyrus/properties/customization/editor/actions/CreateSectionWidgetAction.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*****************************************************************************
- * Copyright (c) 2010 CEA LIST.
- *
- * All rights reserved. This program and the accompanying materials
- * are 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:
- * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
- *****************************************************************************/
-package org.eclipse.papyrus.properties.customization.editor.actions;
-
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.UnexecutableCommand;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.edit.command.SetCommand;
-import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.emf.edit.ui.action.StaticSelectionCommandAction;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.papyrus.properties.contexts.Section;
-import org.eclipse.papyrus.properties.runtime.ConfigurationManager;
-import org.eclipse.papyrus.properties.ui.CompositeWidget;
-import org.eclipse.papyrus.properties.ui.Layout;
-import org.eclipse.papyrus.properties.ui.UiFactory;
-import org.eclipse.papyrus.properties.ui.ValueAttribute;
-import org.eclipse.papyrus.widgets.Activator;
-
-/**
- * An Action to create a section's XWT Resource, with a default Composite
- * and layout.
- *
- * @author Camille Letavernier
- */
-public class CreateSectionWidgetAction extends StaticSelectionCommandAction {
-
- private Section section;
-
- /**
- * Constructor.
- *
- * @param selection
- * The current selection. The first element should be a Section.
- */
- public CreateSectionWidgetAction(ISelection selection) {
- if(selection instanceof IStructuredSelection) {
- IStructuredSelection sSelection = (IStructuredSelection)selection;
-
- Object selectedElement = sSelection.getFirstElement();
-
- if(selectedElement instanceof Section) {
- section = (Section)selectedElement;
- }
- }
- configureAction(selection);
- }
-
- @Override
- protected Command createActionCommand(EditingDomain editingDomain, Collection<?> collection) {
- if(section == null) {
- return UnexecutableCommand.INSTANCE;
- }
-
- CompositeWidget newWidget = createWidget();
-
- CompoundCommandActionDelegate createActionCommand = new CompoundCommandActionDelegate();
- createActionCommand.setImage(Activator.getDefault().getImage("org.eclipse.papyrus.properties.model.edit", "icons/full/obj16/CompositeWidget.gif")); //$NON-NLS-1$//$NON-NLS-2$
- createActionCommand.append(getCreateResourceCommand(newWidget));
- createActionCommand.append(getSetWidgetCommand(newWidget));
-
- return createActionCommand;
- }
-
- private CompositeWidget createWidget() {
- CompositeWidget newWidget = UiFactory.eINSTANCE.createCompositeWidget();
-
-
- for(Map.Entry<String, String> entry : getNamespaces().entrySet()) {
- ValueAttribute attribute = UiFactory.eINSTANCE.createValueAttribute();
- attribute.setName(entry.getKey());
- attribute.setValue(entry.getValue());
- newWidget.getAttributes().add(attribute);
- }
-
- newWidget.setWidgetType(ConfigurationManager.instance.getDefaultCompositeType());
-
- Layout layout = UiFactory.eINSTANCE.createLayout();
- layout.setLayoutType(ConfigurationManager.instance.getDefaultLayoutType());
- newWidget.setLayout(layout);
-
- return newWidget;
- }
-
- private Map<String, String> getNamespaces() {
- Map<String, String> namespaces = new HashMap<String, String>();
- namespaces.put("xmlns", "http://www.eclipse.org/xwt/presentation"); //$NON-NLS-1$ //$NON-NLS-2$
- namespaces.put("xmlns:x", "http://www.eclipse.org/xwt"); //$NON-NLS-1$ //$NON-NLS-2$
- namespaces.put("xmlns:ppe", "clr-namespace:org.eclipse.papyrus.properties.widgets"); //$NON-NLS-1$ //$NON-NLS-2$
- namespaces.put("xmlns:ppel", "clr-namespace:org.eclipse.papyrus.properties.widgets.layout"); //$NON-NLS-1$ //$NON-NLS-2$
- return namespaces;
- }
-
- private Command getCreateResourceCommand(CompositeWidget newWidget) {
- URI widgetURI;
- if(section.getSectionFile() == null || section.getSectionFile().equals("")) { //$NON-NLS-1$
- section.setSectionFile(section.getName() + ".xwt"); //$NON-NLS-1$
- }
-
- widgetURI = URI.createURI(section.getSectionFile());
- widgetURI = widgetURI.resolve(section.eResource().getURI());
- Command createWidget = new CreateResourceCommand(newWidget, widgetURI, section.eResource().getResourceSet());
-
- return createWidget;
- }
-
- private Command getSetWidgetCommand(CompositeWidget newWidget) {
- if(section.getWidget() == null)
- return SetCommand.create(editingDomain, section, section.eClass().getEStructuralFeature("widget"), newWidget); //$NON-NLS-1$
- else
- return UnexecutableCommand.INSTANCE;
- }
-}

Back to the top