blob: c6d982ef2ce2258179cef0caba3b6e51f618db9f [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2003, 2004 IBM Corporation and others.
* 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:
* IBM Corporation - initial API and implementation
*******************************************************************************/
/*
* Created on Feb 10, 2004
*
* To change the template for this generated file go to
* Window - Preferences - Java - Code Generation - Code and Comments
*/
package org.eclipse.jst.j2ee.internal.web.operations;
import org.eclipse.jst.j2ee.webapplication.MimeMapping;
import org.eclipse.jst.j2ee.webapplication.WebApp;
import org.eclipse.jst.j2ee.webapplication.WebapplicationFactory;
import org.eclipse.jst.j2ee.webapplication.WebapplicationPackage;
import org.eclipse.wst.common.internal.emfworkbench.integration.ModifierHelper;
import org.eclipse.wst.common.internal.emfworkbench.operation.ModelModifierOperation;
/**
* @author jialin
*
* To change the template for this generated type comment go to Window - Preferences - Java - Code
* Generation - Code and Comments
*/
public class AddMimeMappingOperation extends ModelModifierOperation {
/**
* @param dataModel
*/
public AddMimeMappingOperation(AddMimeMappingDataModel dataModel) {
super(dataModel);
}
/*
* (non-Javadoc)
*
* @see org.eclipse.wst.common.internal.emfworkbench.operation.ModelModifierOperation#addHelpers()
*/
protected void addHelpers() {
AddMimeMappingDataModel model = (AddMimeMappingDataModel) this.operationDataModel;
ModifierHelper helper = createHelper(model);
this.modifier.addHelper(helper);
}
/**
* @param model
* @return
*/
private ModifierHelper createHelper(AddMimeMappingDataModel model) {
ModifierHelper helper = new ModifierHelper();
WebApp webApp = (WebApp) model.getDeploymentDescriptorRoot();
helper.setOwner(webApp);
helper.setFeature(WebapplicationPackage.eINSTANCE.getWebApp_MimeMappings());
MimeMapping mm = WebapplicationFactory.eINSTANCE.createMimeMapping();
String extension = model.getStringProperty(AddMimeMappingDataModel.MIME_MAPPING_EXTENSION);
String type = model.getStringProperty(AddMimeMappingDataModel.MIME_MAPPING_TYPE);
mm.setExtension(extension);
mm.setMimeType(type);
helper.setValue(mm);
return helper;
}
}