
org.csstudio.utility.adlparser.fileParser.widgets.ShellCommand Maven / Gradle / Ivy
package org.csstudio.utility.adlparser.fileParser.widgets;
import java.util.ArrayList;
import org.csstudio.utility.adlparser.fileParser.ADLWidget;
import org.csstudio.utility.adlparser.fileParser.FileLine;
import org.csstudio.utility.adlparser.fileParser.WrongADLFormatException;
import org.csstudio.utility.adlparser.fileParser.widgetParts.ADLObject;
import org.csstudio.utility.adlparser.fileParser.widgetParts.CommandItem;
import org.csstudio.utility.adlparser.internationalization.Messages;
/**
*
* @author hammonds
*
*/
public class ShellCommand extends ADLAbstractWidget implements IWidgetWithColorsInBase {
private int _clr;
private int _bclr;
private boolean _isBackColorDefined;
private boolean _isForeColorDefined;
private String label = new String();
private ArrayList cmdItems = new ArrayList<>();
public ShellCommand(ADLWidget adlWidget) {
super(adlWidget);
name = new String("shell command");
try {
for (ADLWidget childWidget : adlWidget.getObjects()) {
if (childWidget.getType().equals("object")){
_adlObject = new ADLObject(childWidget);
if (_adlObject != null){
_hasObject = true;
}
}
}
for (FileLine fileLine : adlWidget.getBody()){
String bodyPart = fileLine.getLine();
String[] row = bodyPart.trim().split("=");
if (row.length < 2){
throw new WrongADLFormatException(Messages.Label_WrongADLFormatException_Parameter_Begin + bodyPart + Messages.Label_WrongADLFormatException_Parameter_End);
}
if(FileLine.argEquals(row[0], "clr")){ //$NON-NLS-1$
setClr(FileLine.getIntValue(row[1]));
set_isForeColorDefined(true);
}else if(FileLine.argEquals(row[0], "bclr")){ //$NON-NLS-1$
setBclr(FileLine.getIntValue(row[1]));
set_isBackColorDefined(true);
}else if(FileLine.argEquals(row[0], "label")){ //$NON-NLS-1$
setLabel(FileLine.getTrimmedValue(row[1]));
}
}
for (ADLWidget item : adlWidget.getObjects()){
if (item.getType().startsWith("command[")){
cmdItems.add(new CommandItem(item));
}
}
}
catch (WrongADLFormatException ex) {
}
}
/**
* @param label the label to set
*/
private void setLabel(String label) {
this.label = label;
}
/**
* @return the label
*/
public String getLabel() {
return label;
}
@Override
public Object[] getChildren() {
ArrayList
© 2015 - 2025 Weber Informatics LLC | Privacy Policy