| /** |
| * ******************************************************************************* |
| * Copyright (c) 2017 Timing-Architects Embedded Systems GmbH 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: |
| * Timing-Architects Embedded Systems GmbH - initial API and implementation |
| * |
| * ******************************************************************************* |
| */ |
| package org.eclipse.app4mc.amalthea.generator.ui; |
| |
| import org.eclipse.app4mc.amalthea.generator.configuration.Generation; |
| import org.eclipse.app4mc.amalthea.generator.configuration.IntegerDistribution; |
| import org.eclipse.app4mc.amalthea.generator.configuration.LabelProperties; |
| import org.eclipse.app4mc.amalthea.generator.configuration.RTMGC; |
| import org.eclipse.app4mc.amalthea.generator.configuration.RTMGCFactory; |
| import org.eclipse.swt.SWT; |
| import org.eclipse.swt.custom.ScrolledComposite; |
| import org.eclipse.swt.layout.GridLayout; |
| import org.eclipse.swt.widgets.Composite; |
| import org.eclipse.swt.widgets.TabFolder; |
| import org.eclipse.swt.widgets.TabItem; |
| |
| public class LabelsConfigurationHelper implements IConfigurationHelper { |
| |
| private IntegerDistributionGroup count; |
| private IntegerDistributionGroup size; |
| private IntegerDistributionGroup swc; |
| |
| public void addTabItem(TabFolder parent) { |
| TabItem tab = new TabItem(parent, SWT.NONE); |
| tab.setText("Labels"); |
| |
| ScrolledComposite sc = new ScrolledComposite(parent, SWT.BORDER | SWT.V_SCROLL); |
| |
| Composite container = new Composite(sc, SWT.NONE); |
| container.setLayout(new GridLayout()); |
| GridLayout gridLayout = new GridLayout(); |
| container.setLayout(gridLayout); |
| gridLayout.numColumns = 2; |
| |
| sc.setExpandVertical(true); |
| sc.setExpandHorizontal(true); |
| |
| this.count = new IntegerDistributionGroup(container, "Number of Labels to be Generated"); |
| this.size = new IntegerDistributionGroup(container, "Bit Size of Labels"); |
| this.swc = new IntegerDistributionGroup(container, "Number of Labels per SWC"); |
| |
| sc.setContent(container); |
| sc.setMinSize(container.computeSize(SWT.DEFAULT, SWT.DEFAULT)); |
| tab.setControl(sc); |
| } |
| |
| @Override |
| public void loadConfiguration(RTMGC rtmgc) { |
| if(null != rtmgc) { |
| Generation generation = rtmgc.getGeneration(); |
| if(null != generation) { |
| LabelProperties labels = generation.getLabels(); |
| if(null != labels) { |
| IntegerDistribution count = labels.getCount(); |
| this.count.set(count); |
| IntegerDistribution size = labels.getBitSize(); |
| this.size.set(size); |
| IntegerDistribution swc = labels.getPerSWC(); |
| this.swc.set(swc); |
| } |
| } |
| } |
| } |
| |
| @Override |
| public void updateConfiguration(RTMGC rtmgc) { |
| if(null != rtmgc) { |
| Generation generation = rtmgc.getGeneration(); |
| if(null == generation) { |
| generation = RTMGCFactory.eINSTANCE.createGeneration(); |
| rtmgc.setGeneration(generation); |
| } |
| LabelProperties labels = generation.getLabels(); |
| if(null == labels) { |
| labels = RTMGCFactory.eINSTANCE.createLabelProperties(); |
| generation.setLabels(labels); |
| } |
| IntegerDistribution count = this.count.get(); |
| labels.setCount(count); |
| IntegerDistribution size = this.size.get(); |
| labels.setBitSize(size); |
| IntegerDistribution swc = this.swc.get(); |
| labels.setPerSWC(swc); |
| } |
| } |
| |
| @Override |
| public boolean isValid() { |
| return true; |
| } |
| |
| } |