| /******************************************************************************* |
| * Copyright (c) 2008,2011 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 |
| *******************************************************************************/ |
| package org.eclipse.stem.ui.adapters.loggerpropertyeditor; |
| |
| import org.eclipse.core.resources.IProject; |
| import org.eclipse.emf.ecore.EClass; |
| import org.eclipse.emf.ecore.EStructuralFeature; |
| import org.eclipse.stem.core.logger.Logger; |
| import org.eclipse.stem.loggers.SimulationLoggerPackage; |
| import org.eclipse.stem.ui.editors.GenericPropertyEditor; |
| import org.eclipse.swt.events.ModifyListener; |
| import org.eclipse.swt.widgets.Composite; |
| |
| abstract public class LoggerPropertyEditor extends GenericPropertyEditor { |
| |
| /** |
| * @param feature |
| * @return <code>true</code> if the feature is a dublin core feature that |
| * is specified by a user. |
| */ |
| @Override |
| public boolean isUserSpecifiedProperty(final EStructuralFeature feature) { |
| boolean retValue = false; |
| final EClass containingClass = feature.getEContainingClass(); |
| if (containingClass.equals(SimulationLoggerPackage.eINSTANCE.getSimulationLogger()) |
| || containingClass.getEAllSuperTypes().contains( |
| SimulationLoggerPackage.eINSTANCE.getSimulationLogger())) { |
| |
| retValue = true; |
| } |
| return retValue; |
| } |
| |
| |
| public LoggerPropertyEditor(Composite parent, int style, IProject project) { |
| super(parent,style, project); |
| } |
| |
| /** |
| * Create the composite |
| * |
| * @param parent |
| * @param style |
| * @param projectValidator |
| */ |
| public LoggerPropertyEditor(final Composite parent, final int style, |
| final Logger diseaseModel, |
| final ModifyListener projectValidator, IProject project) { |
| super(parent, style, diseaseModel, projectValidator, project); |
| } |
| |
| public void populate(Logger logger) { |
| // for (final Map.Entry<EStructuralFeature, Text> entry : map.entrySet()) { |
| // switch (entry.getKey().getFeatureID()) { |
| // case LoggerPackage..DISEASE_MODEL__DISEASE_NAME: |
| // diseaseModel.setDiseaseName(entry.getValue().getText()); |
| // break; |
| // case StandardPackage.DISEASE_MODEL__POPULATION_IDENTIFIER: |
| // diseaseModel |
| // .setPopulationIdentifier(entry.getValue().getText()); |
| // break; |
| // case StandardPackage.DISEASE_MODEL__TIME_PERIOD: |
| // diseaseModel.setTimePeriod(Long.parseLong(entry.getValue() |
| // .getText())); |
| // break; |
| // |
| // default: |
| // break; |
| // } // switch |
| // } // for each Map.entry |
| } |
| |
| @Override |
| public boolean validate() { |
| // Nothing to validate in the base logger |
| return true; |
| } // validate |
| |
| |
| |
| |
| @Override |
| public void dispose() { |
| super.dispose(); |
| } |
| |
| @Override |
| protected void checkSubclass() { |
| // Disable the check that prevents sub-classing of SWT components |
| } |
| |
| |
| } // DiseaseModelPropertyEditor |