Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 122e10a07756128aeecdcc0d3a9deff82bd35abd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package org.eclipse.etrice.ui.behavior.dialogs;

import org.eclipse.core.databinding.conversion.Converter;
import org.eclipse.etrice.core.fsm.fSM.DetailCode;

public class DetailCodeToString extends Converter {

	private boolean nullIsEmpty;

	public DetailCodeToString() {
		this(false);
	}

	public DetailCodeToString(boolean nullIsEmpty) {
		super(DetailCode.class, String.class);
		this.nullIsEmpty = nullIsEmpty;
	}

	@Override
	public Object convert(Object fromObject) {
		if (fromObject instanceof DetailCode) {
			String result = "";
			for (String cmd : ((DetailCode) fromObject).getLines()) {
				result += cmd+"\n";
			}
			return result;
		}
		return nullIsEmpty? "":null;
	}
}

Back to the top