Commit 216443b3 authored by Andrey Filippov's avatar Andrey Filippov

Continue with tool launch menus

parent e52ad884
...@@ -104,6 +104,13 @@ public class XMLConfig extends Config { ...@@ -104,6 +104,13 @@ public class XMLConfig extends Config {
static final String CONTEXT_TOOL_ACTION_TAG = "action"; static final String CONTEXT_TOOL_ACTION_TAG = "action";
static final String CONTEXT_TOOL_ACTION_LABEL = "label"; static final String CONTEXT_TOOL_ACTION_LABEL = "label";
static final String CONTEXT_TOOL_ACTION_RESOURCE = "resource"; static final String CONTEXT_TOOL_ACTION_RESOURCE = "resource";
static final String CONTEXT_TOOL_ACTION_CHECK_EXTENSION = "check-extension";
static final String CONTEXT_TOOL_ACTION_CHECK_EXISTENCE = "check-existence";
static final String CONTEXT_TOOL_DFLT_ACTION_LABEL = "Run for";
static final String CONTEXT_TOOL_DFLT_ACTION_RESOURCE = "%%CurrentFile";
static final String CONTEXT_TOOL_DFLT_ACTION_CHECK_EXTENSION = "true";
static final String CONTEXT_TOOL_DFLT_ACTION_CHECK_EXISTENCE = "false";
static final String CONTEXT_TOOL_EXTENSION_MASK_ATTR = "mask"; static final String CONTEXT_TOOL_EXTENSION_MASK_ATTR = "mask";
static final String CONTEXT_TOOL_SYNTAX_ERRORS = "errors"; static final String CONTEXT_TOOL_SYNTAX_ERRORS = "errors";
...@@ -957,38 +964,58 @@ public class XMLConfig extends Config { ...@@ -957,38 +964,58 @@ public class XMLConfig extends Config {
return extList; return extList;
} }
private List<RunFor> readToolRunForList(Node toolNode, String toolName) private List<RunFor> readToolRunForList(Node toolNode, String toolName) throws ConfigException {
throws ConfigException String toolInfo = "Tool '" + toolName + "'";
{
String toolInfo = "Tool '" + toolName + "'"; List<RunFor> runForList = new ArrayList<RunFor>();
List<Node> runForNodesList = findChildNodes(toolNode, CONTEXT_TOOL_ACTION_LIST_TAG);
List<RunFor> runForList = new ArrayList<RunFor>();
List<Node> runForNodesList = findChildNodes(toolNode, CONTEXT_TOOL_ACTION_LIST_TAG); if(runForNodesList.isEmpty()) {
runForList.add(new RunFor(
if(runForNodesList.isEmpty()) CONTEXT_TOOL_DFLT_ACTION_LABEL,
return null; CONTEXT_TOOL_DFLT_ACTION_RESOURCE,
if(runForNodesList.size() > 1) getBoolAttrValue(CONTEXT_TOOL_DFLT_ACTION_CHECK_EXTENSION),
throw new ConfigException(toolInfo + getBoolAttrValue(CONTEXT_TOOL_DFLT_ACTION_CHECK_EXISTENCE)));
" definition cannot contain several '" +
CONTEXT_OUTPUT_SECTION_TAG + } else {
"' nodes"); if(runForNodesList.size() > 1)
throw new ConfigException(toolInfo +
Node runForNode = runForNodesList.get(0); " definition cannot contain several '" +
List<Node> runForNodes = findChildNodes(runForNode, CONTEXT_TOOL_ACTION_TAG); CONTEXT_TOOL_ACTION_LIST_TAG +
"' nodes");
for(Iterator<Node> n = runForNodes.iterator(); n.hasNext();) {
Node node = (Node)n.next(); Node runForNode = runForNodesList.get(0);
String label = getAttributeValue(node, CONTEXT_TOOL_ACTION_LABEL); List<Node> runForNodes = findChildNodes(runForNode, CONTEXT_TOOL_ACTION_TAG);
if (label == null)
throw new ConfigException(toolInfo + ": Attribute '" + CONTEXT_TOOL_ACTION_LABEL + "' is absent"); for(Iterator<Node> n = runForNodes.iterator(); n.hasNext();) {
String resource = getAttributeValue(node, CONTEXT_TOOL_ACTION_RESOURCE); Node node = (Node)n.next();
if (resource == null) String label = getAttributeValue(node, CONTEXT_TOOL_ACTION_LABEL);
throw new ConfigException(toolInfo + ": Attribute '" + CONTEXT_TOOL_ACTION_RESOURCE + "' is absent"); if (label == null)
runForList.add(new RunFor(label, resource)); label=CONTEXT_TOOL_DFLT_ACTION_LABEL;
} String resource = getAttributeValue(node, CONTEXT_TOOL_ACTION_RESOURCE);
if (resource == null)
return runForList; resource= CONTEXT_TOOL_DFLT_ACTION_RESOURCE;
String checkExtensionAttr=getAttributeValue(node, CONTEXT_TOOL_ACTION_CHECK_EXTENSION);
if (checkExtensionAttr==null){
checkExtensionAttr=CONTEXT_TOOL_DFLT_ACTION_CHECK_EXTENSION;
}
checkBoolAttr(checkExtensionAttr, CONTEXT_TOOL_ACTION_CHECK_EXTENSION);
boolean checkExtension=getBoolAttrValue(checkExtensionAttr);
String checkExistenceAttr=getAttributeValue(node, CONTEXT_TOOL_ACTION_CHECK_EXISTENCE);
if (checkExistenceAttr==null){
checkExistenceAttr=CONTEXT_TOOL_DFLT_ACTION_CHECK_EXISTENCE;
}
checkBoolAttr(checkExistenceAttr, CONTEXT_TOOL_ACTION_CHECK_EXISTENCE);
boolean checkExistence=getBoolAttrValue(checkExistenceAttr);
runForList.add(new RunFor(label, resource, checkExtension, checkExistence));
}
}
return runForList;
} }
private List<Parameter> readParameters(Node node, Context context) private List<Parameter> readParameters(Node node, Context context)
......
...@@ -83,7 +83,7 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -83,7 +83,7 @@ public class Tool extends Context implements Cloneable, Inheritable {
params, params,
paramGroups, paramGroups,
commandLinesBlocks); commandLinesBlocks);
this.runfor=runfor; this.runfor=runfor; // should it be cloned?
this.baseToolName = baseToolName; this.baseToolName = baseToolName;
this.label = label; this.label = label;
this.parentPackageName = parentPackageName; this.parentPackageName = parentPackageName;
...@@ -264,7 +264,11 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -264,7 +264,11 @@ public class Tool extends Context implements Cloneable, Inheritable {
assert ((resources==null) || (resources.size() == 1)); assert ((resources==null) || (resources.size() == 1));
resource = resources.get(0); resource = resources.get(0);
} }
actualActions[i] = new RunFor(labels.get(0), resource); actualActions[i] = new RunFor(
labels.get(0),
resource,
runfor.get(i).getCheckExtension(),
runfor.get(i).getCheckExistence());
} }
return actualActions; return actualActions;
} }
......
...@@ -18,17 +18,39 @@ ...@@ -18,17 +18,39 @@
package com.elphel.vdt.core.tools.params.types; package com.elphel.vdt.core.tools.params.types;
public class RunFor{ public class RunFor implements Cloneable{
public String label; public String label;
public String resource; public String resource;
public RunFor(String label, String resource){ public boolean checkExtension;
public boolean checkExistence;
public RunFor(String label, String resource, boolean checkExtension, boolean checkExistence){
this.label=label; this.label=label;
this.resource=resource; this.resource=resource;
this.checkExtension=checkExtension;
this.checkExistence=checkExistence;
} }
public RunFor(RunFor runFor){
this (
runFor.label,
runFor.resource,
runFor.checkExtension,
runFor.checkExistence);
}
public String getLabel(){ public String getLabel(){
return label; return label;
} }
public String getResource(){ public String getResource(){
return resource; return resource;
} }
public boolean getCheckExtension(){
return checkExtension;
}
public boolean getCheckExistence(){
return checkExistence;
}
public Object clone() { // did not clone context (intentionally)
return new RunFor(this);
}
} }
...@@ -87,6 +87,8 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -87,6 +87,8 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
private DrillDownAdapter drillDownAdapter; private DrillDownAdapter drillDownAdapter;
private Action showLaunchConfigAction; private Action showLaunchConfigAction;
private Action launchAction; private Action launchAction;
private Action [] launchActions;
private Action showInstallationPropertiesAction; private Action showInstallationPropertiesAction;
private ClearAction clearInstallationPropertiesAction; private ClearAction clearInstallationPropertiesAction;
...@@ -176,7 +178,7 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -176,7 +178,7 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
} }
private void doLoadDesignMenu(String menuName) { private void doLoadDesignMenu(String menuName) {
if (menuName != null) { if (menuName != null) { // Horizontal menu bar
DesignMenu designMenu = ToolsCore.getDesignMenuManager().findDesignMenu(menuName); DesignMenu designMenu = ToolsCore.getDesignMenuManager().findDesignMenu(menuName);
viewer.setInput(designMenu); viewer.setInput(designMenu);
List<Context> packages = ToolsCore.getDesignMenuManager().getPackageContexts(designMenu); List<Context> packages = ToolsCore.getDesignMenuManager().getPackageContexts(designMenu);
...@@ -226,10 +228,16 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -226,10 +228,16 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
} }
private void fillContextMenu(IMenuManager manager) { private void fillContextMenu(IMenuManager manager) {
manager.add(launchAction); manager.add(launchAction);
// manager.add(new Separator());
// manager.add(new Separator()); // test
// manager.add(launchAction); // test
// manager.add(new Separator());
// drillDownAdapter.addNavigationActions(manager); // drillDownAdapter.addNavigationActions(manager);
// Other plug-ins can contribute there actions here // Other plug-ins can contribute their actions here
manager.add(new Separator()); manager.add(new Separator());
manager.add(showInstallationPropertiesAction); manager.add(showInstallationPropertiesAction);
manager.add(showPackagePropertiesAction); manager.add(showPackagePropertiesAction);
...@@ -239,8 +247,9 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -239,8 +247,9 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
} }
private void fillLocalToolBar(IToolBarManager manager) { private void fillLocalToolBar(IToolBarManager manager) { // On Horizontal bar
manager.add(launchAction); manager.add(launchAction);
// manager.add(launchAction); // test
// manager.add(new Separator()); // manager.add(new Separator());
// drillDownAdapter.addNavigationActions(manager); // drillDownAdapter.addNavigationActions(manager);
manager.add(new Separator()); manager.add(new Separator());
...@@ -351,7 +360,7 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -351,7 +360,7 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
} }
}; };
showLaunchConfigAction.setText("Launch configuration"); showLaunchConfigAction.setText("Launch configuration");
showLaunchConfigAction.setToolTipText("Open launch configuration dialog for this tool"); showLaunchConfigAction.setToolTipText("Open launch configuration dialog for this tool"+" ** DBG **");
showLaunchConfigAction.setImageDescriptor(VDTPluginImages.DESC_LAUNCH_CONFIG); showLaunchConfigAction.setImageDescriptor(VDTPluginImages.DESC_LAUNCH_CONFIG);
launchAction = new Action() { launchAction = new Action() {
...@@ -366,7 +375,7 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -366,7 +375,7 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
} }
}; };
launchAction.setText(Txt.s("Action.ToolLaunch.Caption.Default")); launchAction.setText(Txt.s("Action.ToolLaunch.Caption.Default"));
launchAction.setToolTipText(Txt.s("Action.ToolLaunch.ToolTip.Default")); launchAction.setToolTipText(Txt.s("Action.ToolLaunch.ToolTip.Default")+" **DEBUGGING**");
launchAction.setImageDescriptor(VDTPluginImages.DESC_RUN_TOOL); launchAction.setImageDescriptor(VDTPluginImages.DESC_RUN_TOOL);
launchAction.setEnabled(false); launchAction.setEnabled(false);
// launchAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages(). // launchAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
...@@ -436,7 +445,12 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -436,7 +445,12 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
System.out.println("Got Runfor["+((runFor!=null)?runFor.length:"null")+"]"); System.out.println("Got Runfor["+((runFor!=null)?runFor.length:"null")+"]");
if (runFor!=null){ if (runFor!=null){
for (int i=0;i<runFor.length;i++){ for (int i=0;i<runFor.length;i++){
System.out.println(" label='"+runFor[i].getLabel()+"', resource='"+runFor[i].getResource()+"'"); System.out.println(
" label='"+runFor[i].getLabel()+
"', resource='"+runFor[i].getResource()+
"', checkExtension='"+runFor[i].getCheckExtension()+
"', checkExistence='"+runFor[i].getCheckExistence()+
"'");
} }
} }
} }
...@@ -447,9 +461,10 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -447,9 +461,10 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
&& (selectedItem.isEnabled(selectedResource)); && (selectedItem.isEnabled(selectedResource));
launchAction.setEnabled(enabled); launchAction.setEnabled(enabled);
if (enabled){ if (enabled){
launchAction.setText(Txt.s("Action.ToolLaunch.Caption", new String[]{selectedResource.getName()})); /* Andrey: Next apperas on right-click (context) menu for selected tool */
launchAction.setText(Txt.s("Action.ToolLaunch.Caption", new String[]{selectedResource.getName()})+"<<<<<");
/* Andrey: below sets tooltip on the horizontal bar */
launchAction.setToolTipText(Txt.s("Action.ToolLaunch.ToolTip", new String[]{selectedItem.getLabel(), selectedResource.getName()})); launchAction.setToolTipText(Txt.s("Action.ToolLaunch.ToolTip", new String[]{selectedItem.getLabel(), selectedResource.getName()}));
Tool tool = selectedItem.getTool(); Tool tool = selectedItem.getTool();
if (tool!=null){ if (tool!=null){
......
...@@ -177,8 +177,8 @@ ...@@ -177,8 +177,8 @@
</extensions-list> </extensions-list>
<action-menu> <action-menu>
<action label="Simulate" resource="%SimulationTopFile" /> <action label="Simulate" resource="%SimulationTopFile" check-extension="false" check-existence="true" />
<action label="Simulate for" resource="%%CurrentFile" /> <action label="Simulate for" resource="%%CurrentFile" check-extension="true"/>
<action label="Empty" resource="" /> <action label="Empty" resource="" />
<action label="Just try for" resource="%%OS" /> <action label="Just try for" resource="%%OS" />
</action-menu> </action-menu>
......
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