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

Added possibility to insert horizontal separators to the configuration

dialogs, updated documentation
parent 35b57a4b
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -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";


+5 −2
Original line number Original line Diff line number Diff line
@@ -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 {
        		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 {
                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 + 
+43 −4
Original line number Original line Diff line number Diff line
@@ -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;
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 {
        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 {
    } // 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 {
        } 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 {
            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 {
//              component.setPreferenceStore(store);
//              component.setPreferenceStore(store);
                component.createControl(tabComposites[i]);
                component.createControl(tabComposites[i]);
                component.setChangeListener(changeListener);
                component.setChangeListener(changeListener);
*/                
            }
            }
        }
        }
    } // addProperties()
    } // addProperties()
+13 −7
Original line number Original line Diff line number Diff line
@@ -76,9 +76,11 @@ 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;
        if (param!=null) {// Andrey - to add labels
        	labelField = createLabel(parent, param.getLabel());
        	labelField = createLabel(parent, param.getLabel());
        	labelField.setMenu(createPopupMenu(labelField.getShell()));
        	labelField.setMenu(createPopupMenu(labelField.getShell()));
        }
        }
    }


    protected void endCreateControl() {
    protected void endCreateControl() {
//        System.out.println("-- Component.finalizeCreateControl: id= "+param.getID()+"; label= "+param.getLabel());
//        System.out.println("-- Component.finalizeCreateControl: id= "+param.getID()+"; label= "+param.getLabel());
@@ -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) {
    	if (labelField!=null) 
    		labelField.setVisible(visible);
    		labelField.setVisible(visible);
    }
    }
    
    
    public void setEnabled (boolean enabled) {
    public void setEnabled (boolean enabled) {
    	if (labelField!=null) 
    		labelField.setEnabled(enabled);
    		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;
    	if (labelField!=null) 
    		labelField.setForeground(defaulted ? colorForegroundDefault
    		labelField.setForeground(defaulted ? colorForegroundDefault
    				: colorForeground );     
    				: 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)
+6 −4
Original line number Original line Diff line number Diff line
@@ -36,10 +36,12 @@ public abstract class GeneralComponent extends Component {
    
    
    GeneralComponent(Parameter param) {
    GeneralComponent(Parameter param) {
    	super(param);
    	super(param);
    	if (param!=null) { //Andrey
    		option = new ParamBasedOption(param);
    		option = new ParamBasedOption(param);
    		isDefault = option.isStoredDefault();
    		isDefault = option.isStoredDefault();
    		modifyListener = createModifyListener();
    		modifyListener = createModifyListener();
    	}
    	}
    }


    protected void endCreateControl() {
    protected void endCreateControl() {
//        System.out.println("    -- GeneralComponent.finalizeCreateControl: id= "+param.getID()+"; label= "+param.getLabel());
//        System.out.println("    -- GeneralComponent.finalizeCreateControl: id= "+param.getID()+"; label= "+param.getLabel());