Commit dbb68380 authored by Andrey Filippov's avatar Andrey Filippov

Added icon support for tool launch actions

parent f091be45
...@@ -33,6 +33,7 @@ import com.elphel.vdt.core.tools.config.*; ...@@ -33,6 +33,7 @@ import com.elphel.vdt.core.tools.config.*;
import com.elphel.vdt.core.tools.contexts.*; import com.elphel.vdt.core.tools.contexts.*;
import com.elphel.vdt.core.tools.menu.*; import com.elphel.vdt.core.tools.menu.*;
import com.elphel.vdt.ui.MessageUI; import com.elphel.vdt.ui.MessageUI;
import com.elphel.vdt.ui.VDTPluginImages;
import com.elphel.vdt.veditor.VerilogPlugin; import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.veditor.preference.PreferenceStrings; import com.elphel.vdt.veditor.preference.PreferenceStrings;
...@@ -106,6 +107,8 @@ public class XMLConfig extends Config { ...@@ -106,6 +107,8 @@ public class XMLConfig extends Config {
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_EXTENSION = "check-extension";
static final String CONTEXT_TOOL_ACTION_CHECK_EXISTENCE = "check-existence"; static final String CONTEXT_TOOL_ACTION_CHECK_EXISTENCE = "check-existence";
static final String CONTEXT_TOOL_ACTION_ICON = "icon";
static final String CONTEXT_TOOL_DFLT_ACTION_LABEL = "Run for"; 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_RESOURCE = "%%CurrentFile";
...@@ -976,7 +979,8 @@ public class XMLConfig extends Config { ...@@ -976,7 +979,8 @@ public class XMLConfig extends Config {
CONTEXT_TOOL_DFLT_ACTION_LABEL, CONTEXT_TOOL_DFLT_ACTION_LABEL,
CONTEXT_TOOL_DFLT_ACTION_RESOURCE, CONTEXT_TOOL_DFLT_ACTION_RESOURCE,
getBoolAttrValue(CONTEXT_TOOL_DFLT_ACTION_CHECK_EXTENSION), getBoolAttrValue(CONTEXT_TOOL_DFLT_ACTION_CHECK_EXTENSION),
getBoolAttrValue(CONTEXT_TOOL_DFLT_ACTION_CHECK_EXISTENCE))); getBoolAttrValue(CONTEXT_TOOL_DFLT_ACTION_CHECK_EXISTENCE),
null));
} else { } else {
if(runForNodesList.size() > 1) if(runForNodesList.size() > 1)
...@@ -995,6 +999,7 @@ public class XMLConfig extends Config { ...@@ -995,6 +999,7 @@ public class XMLConfig extends Config {
String label = getAttributeValue(node, CONTEXT_TOOL_ACTION_LABEL); String label = getAttributeValue(node, CONTEXT_TOOL_ACTION_LABEL);
if (label == null) if (label == null)
label=CONTEXT_TOOL_DFLT_ACTION_LABEL; label=CONTEXT_TOOL_DFLT_ACTION_LABEL;
String icon = getAttributeValue(node, CONTEXT_TOOL_ACTION_ICON);
String resource = getAttributeValue(node, CONTEXT_TOOL_ACTION_RESOURCE); String resource = getAttributeValue(node, CONTEXT_TOOL_ACTION_RESOURCE);
if ((resource == null) || (resource.length()==0)) { if ((resource == null) || (resource.length()==0)) {
// resource= CONTEXT_TOOL_DFLT_ACTION_RESOURCE; // resource= CONTEXT_TOOL_DFLT_ACTION_RESOURCE;
...@@ -1013,7 +1018,7 @@ public class XMLConfig extends Config { ...@@ -1013,7 +1018,7 @@ public class XMLConfig extends Config {
checkBoolAttr(checkExistenceAttr, CONTEXT_TOOL_ACTION_CHECK_EXISTENCE); checkBoolAttr(checkExistenceAttr, CONTEXT_TOOL_ACTION_CHECK_EXISTENCE);
checkExistence=getBoolAttrValue(checkExistenceAttr); checkExistence=getBoolAttrValue(checkExistenceAttr);
} }
runForList.add(new RunFor(label, resource, checkExtension, checkExistence)); runForList.add(new RunFor(label, resource, checkExtension, checkExistence, icon));
} }
} }
return runForList; return runForList;
......
...@@ -22,6 +22,7 @@ import java.io.*; ...@@ -22,6 +22,7 @@ import java.io.*;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import com.elphel.vdt.VDT;
import com.elphel.vdt.core.options.OptionsCore; import com.elphel.vdt.core.options.OptionsCore;
import com.elphel.vdt.core.tools.*; import com.elphel.vdt.core.tools.*;
import com.elphel.vdt.core.tools.contexts.*; import com.elphel.vdt.core.tools.contexts.*;
...@@ -29,9 +30,13 @@ import com.elphel.vdt.core.tools.config.*; ...@@ -29,9 +30,13 @@ import com.elphel.vdt.core.tools.config.*;
import com.elphel.vdt.core.tools.params.conditions.ConditionUtils; import com.elphel.vdt.core.tools.params.conditions.ConditionUtils;
import com.elphel.vdt.core.tools.params.recognizers.*; import com.elphel.vdt.core.tools.params.recognizers.*;
import com.elphel.vdt.core.tools.params.types.RunFor; import com.elphel.vdt.core.tools.params.types.RunFor;
import com.elphel.vdt.ui.VDTPluginImages;
public class Tool extends Context implements Cloneable, Inheritable { public class Tool extends Context implements Cloneable, Inheritable {
private static final String ICON_ID_PREFIX = VDT.ID_VDT + ".Tool.Image.";
private static final String ICON_ID_ACTION = ".action.";
private String baseToolName; private String baseToolName;
private String parentPackageName; private String parentPackageName;
private String parentProjectName; private String parentProjectName;
...@@ -56,6 +61,8 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -56,6 +61,8 @@ public class Tool extends Context implements Cloneable, Inheritable {
private boolean isShell = false; /* Tool is a shell, preserve first argument, merge all others */ private boolean isShell = false; /* Tool is a shell, preserve first argument, merge all others */
private String projectPath=null; private String projectPath=null;
private boolean initialized = false; private boolean initialized = false;
private String [] imageKeysActions = null;
public Tool(String name, public Tool(String name,
String controlInterfaceName, String controlInterfaceName,
String label, String label,
...@@ -98,6 +105,29 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -98,6 +105,29 @@ public class Tool extends Context implements Cloneable, Inheritable {
this.choice=0; this.choice=0;
} }
public void initIcons(boolean force) {
if (!force && (imageKeysActions!=null)) return;
if (runfor!=null){
String image;
imageKeysActions=new String [runfor.size()];
for (int i=0;i<imageKeysActions.length;i++){
imageKeysActions[i]=null;
image = runfor.get(i).getIconName();
if (image != null) {
imageKeysActions[i] = ICON_ID_PREFIX + (new File(getExeName())).getName()+ICON_ID_ACTION+i;
VDTPluginImages.addImage(image, imageKeysActions[i], null/*tool.getLaunchType()*/);
}
}
}
} // ToolUI()
public String getImageKey(int actionIndex) {
if (imageKeysActions==null) return null;
return imageKeysActions[actionIndex];
}
public List<RunFor> getRunFor(){ public List<RunFor> getRunFor(){
return runfor; return runfor;
} }
...@@ -277,7 +307,8 @@ public class Tool extends Context implements Cloneable, Inheritable { ...@@ -277,7 +307,8 @@ public class Tool extends Context implements Cloneable, Inheritable {
labels.get(0), labels.get(0),
resource, resource,
runfor.get(i).getCheckExtension(), runfor.get(i).getCheckExtension(),
runfor.get(i).getCheckExistence()); runfor.get(i).getCheckExistence(),
runfor.get(i).getIconName());
} }
return actualActions; return actualActions;
} }
......
...@@ -23,11 +23,13 @@ public class RunFor implements Cloneable{ ...@@ -23,11 +23,13 @@ public class RunFor implements Cloneable{
public String resource; public String resource;
public boolean checkExtension; public boolean checkExtension;
public boolean checkExistence; public boolean checkExistence;
public RunFor(String label, String resource, boolean checkExtension, boolean checkExistence){ public String iconName;
public RunFor(String label, String resource, boolean checkExtension, boolean checkExistence, String iconName){
this.label=label; this.label=label;
this.resource=resource; this.resource=resource;
this.checkExtension=checkExtension; this.checkExtension=checkExtension;
this.checkExistence=checkExistence; this.checkExistence=checkExistence;
this.iconName=iconName;
} }
public RunFor(RunFor runFor){ public RunFor(RunFor runFor){
...@@ -35,7 +37,8 @@ public class RunFor implements Cloneable{ ...@@ -35,7 +37,8 @@ public class RunFor implements Cloneable{
runFor.label, runFor.label,
runFor.resource, runFor.resource,
runFor.checkExtension, runFor.checkExtension,
runFor.checkExistence); runFor.checkExistence,
runFor.iconName);
} }
public String getLabel(){ public String getLabel(){
...@@ -44,6 +47,9 @@ public class RunFor implements Cloneable{ ...@@ -44,6 +47,9 @@ public class RunFor implements Cloneable{
public String getResource(){ public String getResource(){
return resource; return resource;
} }
public String getIconName(){
return iconName;
}
public boolean getCheckExtension(){ public boolean getCheckExtension(){
return checkExtension; return checkExtension;
......
...@@ -28,6 +28,7 @@ import org.eclipse.debug.ui.ILaunchConfigurationTab; ...@@ -28,6 +28,7 @@ import org.eclipse.debug.ui.ILaunchConfigurationTab;
import com.elphel.vdt.VDT; import com.elphel.vdt.VDT;
import com.elphel.vdt.core.tools.config.Config; import com.elphel.vdt.core.tools.config.Config;
import com.elphel.vdt.core.tools.params.Tool; import com.elphel.vdt.core.tools.params.Tool;
import com.elphel.vdt.core.tools.params.types.RunFor;
import com.elphel.vdt.ui.VDTPluginImages; import com.elphel.vdt.ui.VDTPluginImages;
/** /**
...@@ -40,11 +41,12 @@ import com.elphel.vdt.ui.VDTPluginImages; ...@@ -40,11 +41,12 @@ import com.elphel.vdt.ui.VDTPluginImages;
public class ToolUI { public class ToolUI {
private static final String ICON_ID_PREFIX = VDT.ID_VDT + ".Tool.Image."; private static final String ICON_ID_PREFIX = VDT.ID_VDT + ".Tool.Image.";
// private static final String ICON_ID_ACTION = ".action.";
private Tool tool; private Tool tool;
private Config config; private Config config;
private String imageKey = null; private String imageKey = null;
// private String [] imageKeysActions = null;
public ToolUI(Config config, Tool tool) { public ToolUI(Config config, Tool tool) {
this.tool = tool; this.tool = tool;
this.config = config; this.config = config;
...@@ -53,6 +55,21 @@ public class ToolUI { ...@@ -53,6 +55,21 @@ public class ToolUI {
imageKey = ICON_ID_PREFIX + (new File(tool.getExeName())).getName(); imageKey = ICON_ID_PREFIX + (new File(tool.getExeName())).getName();
VDTPluginImages.addImage(image, imageKey, null/*tool.getLaunchType()*/); VDTPluginImages.addImage(image, imageKey, null/*tool.getLaunchType()*/);
} }
/*
List<RunFor> runFor=tool.getRunFor();
if (runFor!=null){
imageKeysActions=new String [runFor.size()];
for (int i=0;i<imageKeysActions.length;i++){
imageKeysActions[i]=null;
image = runFor.get(i).getIconName();
if (image != null) {
imageKeysActions[i] = ICON_ID_PREFIX + (new File(tool.getExeName())).getName()+ICON_ID_ACTION+i;
VDTPluginImages.addImage(image, imageKeysActions[i], null);
}
}
}
*/
} // ToolUI() } // ToolUI()
public ILaunchConfigurationTab[] getLaunchConfigurationTabs() { public ILaunchConfigurationTab[] getLaunchConfigurationTabs() {
...@@ -111,4 +128,11 @@ public class ToolUI { ...@@ -111,4 +128,11 @@ public class ToolUI {
public String getImageKey() { public String getImageKey() {
return imageKey; return imageKey;
} }
/*
public String getImageKey(int actionIndex) {
if (imageKeysActions==null) return null;
return imageKeysActions[actionIndex];
}
*/
} // class ToolUI } // class ToolUI
...@@ -483,10 +483,12 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -483,10 +483,12 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
// Selected item should be not null, but resource - may be // Selected item should be not null, but resource - may be
// RunFor[] getMenuActions() // RunFor[] getMenuActions()
RunFor [] runFor=null; RunFor [] runFor=null;
Tool tool=null;
if (selectedItem != null){ if (selectedItem != null){
Tool tool= selectedItem.getTool(); tool= selectedItem.getTool();
if (tool!=null){ if (tool!=null){
runFor=tool.getMenuActions(project); runFor=tool.getMenuActions(project);
tool.initIcons(false); // if not done before - add icons list for actions
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER)) { if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_OTHER)) {
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){
...@@ -559,7 +561,11 @@ public class DesignFlowView extends ViewPart implements ISelectionListener { ...@@ -559,7 +561,11 @@ public class DesignFlowView extends ViewPart implements ISelectionListener {
launchActions[i].setToolTipText(i+": "+runFor[i].getLabel()+" "+shortName); launchActions[i].setToolTipText(i+": "+runFor[i].getLabel()+" "+shortName);
launchActions[i].setText(runFor[i].getLabel()+" "+shortName); launchActions[i].setText(runFor[i].getLabel()+" "+shortName);
launchActions[i].setEnabled(enabled); launchActions[i].setEnabled(enabled);
launchActions[i].setImageDescriptor(VDTPluginImages.DESC_RUN_TOOL); String actionIconKey=tool.getImageKey(i);
if ((actionIconKey!=null) && (VDTPluginImages.getImageDescriptor(actionIconKey)!=null))
launchActions[i].setImageDescriptor(VDTPluginImages.getImageDescriptor(actionIconKey));
else
launchActions[i].setImageDescriptor(VDTPluginImages.DESC_RUN_TOOL);
} }
IToolBarManager toolbarManager= getViewSite().getActionBars().getToolBarManager(); IToolBarManager toolbarManager= getViewSite().getActionBars().getToolBarManager();
toolbarManager.removeAll(); toolbarManager.removeAll();
......
...@@ -175,9 +175,9 @@ ...@@ -175,9 +175,9 @@
</extensions-list> </extensions-list>
<action-menu> <action-menu>
<action label="Simulate" resource="%SimulationTopFile" check-extension="false" check-existence="true" /> <action label="Simulate" resource="%SimulationTopFile" check-extension="false" check-existence="true" icon="iverilog.ico"/>
<action label="Simulate for" resource="%%SelectedFile" check-extension="true" check-existence="true"/> <action label="Simulate for" resource="%%SelectedFile" check-extension="true" check-existence="true"/>
<action label="Empty" resource="" /> <action label="Empty" resource="" icon="sample.gif"/>
<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