Commit 9adc4c4e authored by Andrey Filippov's avatar Andrey Filippov

Added possibility to insert horizontal separators to the configuration

dialogs, updated documentation
parent 35b57a4b
...@@ -65,6 +65,7 @@ public class XMLConfig extends Config { ...@@ -65,6 +65,7 @@ public class XMLConfig extends Config {
static final String PARAMGROUP_NAME_ATTR = "name"; static final String PARAMGROUP_NAME_ATTR = "name";
static final String PARAMGROUP_LABEL_ATTR = "label"; static final String PARAMGROUP_LABEL_ATTR = "label";
static final String PARAMGROUP_VISIBLE_ATTR = "visible"; static final String PARAMGROUP_VISIBLE_ATTR = "visible";
public static final String PARAMGROUP_SEPARATOR = "---";
static final String PARAMETER_TAG = "parameter"; static final String PARAMETER_TAG = "parameter";
......
...@@ -28,6 +28,7 @@ import java.util.List; ...@@ -28,6 +28,7 @@ import java.util.List;
import com.elphel.vdt.core.tools.config.Config; import com.elphel.vdt.core.tools.config.Config;
import com.elphel.vdt.core.tools.config.ConfigException; import com.elphel.vdt.core.tools.config.ConfigException;
import com.elphel.vdt.core.tools.config.xml.XMLConfig;
import com.elphel.vdt.core.tools.params.*; import com.elphel.vdt.core.tools.params.*;
import com.elphel.vdt.core.tools.params.recognizers.*; import com.elphel.vdt.core.tools.params.recognizers.*;
import com.elphel.vdt.core.tools.params.types.ParamTypeString; import com.elphel.vdt.core.tools.params.types.ParamTypeString;
...@@ -224,14 +225,14 @@ public abstract class Context { ...@@ -224,14 +225,14 @@ public abstract class Context {
timeout=Integer.parseInt(sTimeout); timeout=Integer.parseInt(sTimeout);
} catch(Exception e){ } catch(Exception e){
} }
prompt=commandLinesBlock.parseCntrl(prompt); // replace control character codes (\n,\t,\x) prompt=CommandLinesBlock.parseCntrl(prompt); // replace control character codes (\n,\t,\x)
prompt=commandLinesBlock.applyMark(prompt); // remove mark sequence prompt=commandLinesBlock.applyMark(prompt); // remove mark sequence
String interrupt=commandLinesBlock.getInterrupt(); String interrupt=commandLinesBlock.getInterrupt();
List<String> lines = commandLinesBlock.getLines(); // [%Param_Shell_Options, echo BuildDir=%BuildDir ;, echo SimulationTopFile=%SimulationTopFile ;, echo SimulationTopModule=%SimulationTopModule ;, echo BuildDir=%BuildDir;, %Param_PreExe, %Param_Exe, %Param_TopModule, %TopModulesOther, %ModuleLibrary, %LegacyModel, %NoSpecify, %v, %SourceList, %ExtraFiles, %Filter_String] List<String> lines = commandLinesBlock.getLines(); // [%Param_Shell_Options, echo BuildDir=%BuildDir ;, echo SimulationTopFile=%SimulationTopFile ;, echo SimulationTopModule=%SimulationTopModule ;, echo BuildDir=%BuildDir;, %Param_PreExe, %Param_Exe, %Param_TopModule, %TopModulesOther, %ModuleLibrary, %LegacyModel, %NoSpecify, %v, %SourceList, %ExtraFiles, %Filter_String]
if ((lines.size()==0) && commandLinesBlock.hadStrings()){ if ((lines.size()==0) && commandLinesBlock.hadStrings()){
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING)) if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_LAUNCHING))
System.out.println("Removing command lines block by false condition"); System.out.println("Removing command lines block by false condition");
continue; // to enable conditionals for the command line blocks, still making possible to use emty blocks for no-arguments programs continue; // to enable conditionals for the command line blocks, still making possible to use empty blocks for no-arguments programs
} }
List<List<String>> commandSequence = new ArrayList<List<String>>(); List<List<String>> commandSequence = new ArrayList<List<String>>();
for(Iterator<String> lineIter = lines.iterator(); lineIter.hasNext();) { for(Iterator<String> lineIter = lines.iterator(); lineIter.hasNext();) {
...@@ -386,6 +387,8 @@ public abstract class Context { ...@@ -386,6 +387,8 @@ public abstract class Context {
continue; continue;
for(String id : paramIDs) { for(String id : paramIDs) {
if (id.equals(XMLConfig.PARAMGROUP_SEPARATOR)) // Will try to add separator to the dialog
continue;
if(findParam(id) == null) if(findParam(id) == null)
throw new ConfigException("Parameter '" + id + throw new ConfigException("Parameter '" + id +
"' in context '" + name + "' in context '" + name +
......
...@@ -33,6 +33,7 @@ import org.eclipse.swt.widgets.Group; ...@@ -33,6 +33,7 @@ import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.TabFolder; import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem; import org.eclipse.swt.widgets.TabItem;
import com.elphel.vdt.core.tools.config.xml.XMLConfig;
import com.elphel.vdt.core.tools.contexts.Context; import com.elphel.vdt.core.tools.contexts.Context;
import com.elphel.vdt.core.tools.params.ParamGroup; import com.elphel.vdt.core.tools.params.ParamGroup;
import com.elphel.vdt.core.tools.params.Parameter; import com.elphel.vdt.core.tools.params.Parameter;
...@@ -48,6 +49,7 @@ import com.elphel.vdt.ui.options.component.DirComponent; ...@@ -48,6 +49,7 @@ import com.elphel.vdt.ui.options.component.DirComponent;
import com.elphel.vdt.ui.options.component.DirListComponent; import com.elphel.vdt.ui.options.component.DirListComponent;
import com.elphel.vdt.ui.options.component.FileComponent; import com.elphel.vdt.ui.options.component.FileComponent;
import com.elphel.vdt.ui.options.component.FileListComponent; import com.elphel.vdt.ui.options.component.FileListComponent;
import com.elphel.vdt.ui.options.component.LabelComponent;
import com.elphel.vdt.ui.options.component.NumberComponent; import com.elphel.vdt.ui.options.component.NumberComponent;
import com.elphel.vdt.ui.options.component.StringListComponent; import com.elphel.vdt.ui.options.component.StringListComponent;
import com.elphel.vdt.ui.options.component.TextComponent; import com.elphel.vdt.ui.options.component.TextComponent;
...@@ -96,7 +98,8 @@ public class OptionsBlock { ...@@ -96,7 +98,8 @@ public class OptionsBlock {
ParamGroup paramGroups[] = getParamGroups(); ParamGroup paramGroups[] = getParamGroups();
tabComposites = new Composite[paramGroups.length]; tabComposites = new Composite[paramGroups.length];
scrolledComposite = new ScrolledComposite[paramGroups.length]; scrolledComposite = new ScrolledComposite[paramGroups.length];
if (paramGroups.length==0)
return;
if (paramGroups.length > 1) if (paramGroups.length > 1)
createTabFolder(parent, paramGroups); createTabFolder(parent, paramGroups);
else else
...@@ -172,11 +175,21 @@ public class OptionsBlock { ...@@ -172,11 +175,21 @@ public class OptionsBlock {
} // createTabFolders() } // createTabFolders()
protected Component createComponent(Parameter param) { protected Component createComponent(Parameter param) {
Component component = null;
ParamType paramType = (param==null)?null:param.getType();
if (param == null) {
component = new LabelComponent(param);
} else if (paramType instanceof ParamTypeNumber) {
component = new NumberComponent(param);
/*
Component component = null; Component component = null;
ParamType paramType = param.getType(); ParamType paramType = param.getType();
if (paramType instanceof ParamTypeNumber) { if (paramType instanceof ParamTypeNumber) {
component = new NumberComponent(param); component = new NumberComponent(param);
*/
} else if (paramType instanceof ParamTypeBool) { } else if (paramType instanceof ParamTypeBool) {
component = new BoolComponent(param); component = new BoolComponent(param);
} else if (paramType instanceof ParamTypeString) { } else if (paramType instanceof ParamTypeString) {
...@@ -194,8 +207,9 @@ public class OptionsBlock { ...@@ -194,8 +207,9 @@ public class OptionsBlock {
} else { } else {
System.out.println("Param type " + param.getType().getName() + " unknown (not implemented?)"); System.out.println("Param type " + param.getType().getName() + " unknown (not implemented?)");
} }
if (param!=null) { // Andrey
components.put(param, component); components.put(param, component);
}
return component; return component;
} // createComponent() } // createComponent()
...@@ -213,6 +227,30 @@ public class OptionsBlock { ...@@ -213,6 +227,30 @@ public class OptionsBlock {
ParamGroup paramGroup = paramGroups[i]; ParamGroup paramGroup = paramGroups[i];
for (Iterator<String> pi = paramGroup.getParams().iterator(); pi.hasNext();) { for (Iterator<String> pi = paramGroup.getParams().iterator(); pi.hasNext();) {
String paramID = (String)pi.next();
Component component;
if (paramID.equals(XMLConfig.PARAMGROUP_SEPARATOR)){
component = createComponent(null); // will create horizontal separator?
component.createControl(tabComposites[i]);
continue;
} else {
//
Parameter param = context.findParam(paramID);
if (!param.isVisible())
continue;
component = components.get(param);
if (component == null)
component = createComponent(param);
if (component == null)
continue;
}
activeComponents.add(component);
// component.setPreferenceStore(store);
component.createControl(tabComposites[i]);
component.setChangeListener(changeListener);
/*
String paramID = (String)pi.next(); String paramID = (String)pi.next();
Parameter param = context.findParam(paramID); Parameter param = context.findParam(paramID);
...@@ -229,6 +267,7 @@ public class OptionsBlock { ...@@ -229,6 +267,7 @@ public class OptionsBlock {
// component.setPreferenceStore(store); // component.setPreferenceStore(store);
component.createControl(tabComposites[i]); component.createControl(tabComposites[i]);
component.setChangeListener(changeListener); component.setChangeListener(changeListener);
*/
} }
} }
} // addProperties() } // addProperties()
......
...@@ -76,8 +76,10 @@ public abstract class Component { ...@@ -76,8 +76,10 @@ public abstract class Component {
// System.out.println("-- Component.createControl: id= "+param.getID()+"; label= "+param.getLabel()); // System.out.println("-- Component.createControl: id= "+param.getID()+"; label= "+param.getLabel());
this.parent = parent; this.parent = parent;
activated = false; activated = false;
labelField = createLabel(parent, param.getLabel()); if (param!=null) {// Andrey - to add labels
labelField.setMenu(createPopupMenu(labelField.getShell())); labelField = createLabel(parent, param.getLabel());
labelField.setMenu(createPopupMenu(labelField.getShell()));
}
} }
protected void endCreateControl() { protected void endCreateControl() {
...@@ -134,27 +136,31 @@ public abstract class Component { ...@@ -134,27 +136,31 @@ public abstract class Component {
} }
public boolean isEnable() { public boolean isEnable() {
if (param==null) return true; // label
return ! param.isReadOnly(); return ! param.isReadOnly();
} }
public void setVisible (boolean visible) { public void setVisible (boolean visible) {
labelField.setVisible(visible); if (labelField!=null)
labelField.setVisible(visible);
} }
public void setEnabled (boolean enabled) { public void setEnabled (boolean enabled) {
labelField.setEnabled(enabled); if (labelField!=null)
labelField.setEnabled(enabled);
} }
protected void setDefault(boolean defaulted) { protected void setDefault(boolean defaulted) {
// System.out.println("-- Component.setDefault: id= "+param.getID()+"; label= "+param.getLabel()); // System.out.println("-- Component.setDefault: id= "+param.getID()+"; label= "+param.getLabel());
isDefault = defaulted; isDefault = defaulted;
labelField.setForeground(defaulted ? colorForegroundDefault if (labelField!=null)
: colorForeground ); labelField.setForeground(defaulted ? colorForegroundDefault
: colorForeground );
} }
protected void selectionChanged() { protected void selectionChanged() {
// System.out.println("-- Component.selectionChanged: id= "+param.getID()+"; label= "+param.getLabel()); // System.out.println("-- Component.selectionChanged: id= "+param.getID()+"; label= "+param.getLabel());
if (! param.hasDependentParameters()) if ((param == null) || (! param.hasDependentParameters()))
return; return;
if (changeNotifier == null) if (changeNotifier == null)
......
...@@ -35,10 +35,12 @@ public abstract class GeneralComponent extends Component { ...@@ -35,10 +35,12 @@ public abstract class GeneralComponent extends Component {
protected Menu popupMenu; protected Menu popupMenu;
GeneralComponent(Parameter param) { GeneralComponent(Parameter param) {
super(param); super(param);
option = new ParamBasedOption(param); if (param!=null) { //Andrey
isDefault = option.isStoredDefault(); option = new ParamBasedOption(param);
modifyListener = createModifyListener(); isDefault = option.isStoredDefault();
modifyListener = createModifyListener();
}
} }
protected void endCreateControl() { protected void endCreateControl() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment