if (null == deck)
throw new IllegalArgumentException("No such toolSet: " + toolSetId);
// select tool
ToolSet selectedToolSet = deck.toolSet;
Tool selectedTool = null;
if (toolId != null) // particular tool
{
for (Tool t : selectedToolSet.getAllProvidedTools()) {
if (toolId.equals(t.getId())) {
selectedTool = t;
break;
}
}
} else // default tool, the first one
{
Tool[] availableTools = selectedToolSet.getAllProvidedTools();
if (availableTools == null || availableTools.length == 0)
throw new IllegalArgumentException("Empty toolset: " + toolSetId);
selectedTool = availableTools[0];
}
// is it already open?
boolean isOpen = false;
for (int i = 0; i < deck.tabLayout.getWidgetCount(); i++) {
ToolTabPanel toolTab = (ToolTabPanel) deck.tabLayout.getWidget(i);
if (toolTab.toolId.equals(selectedTool.getId())) {
isOpen = true;
deck.tabLayout.selectTab(i);
}
}
if (!isOpen) // & selectedTool.multipleAllowed()==false
{
final ToolTabPanel panelTool = new ToolTabPanel(toolSetId, selectedTool);
panelTool.invalidate();
ResourceFactory resourceFactory = GWT.create(ResourceFactory.class);
ErraiImageBundle erraiImageBundle = GWT.create(ErraiImageBundle.class);
ImageResource resource = resourceFactory.createImage(selectedTool.getName()) != null ?
resourceFactory.createImage(selectedTool.getName()) : erraiImageBundle.application();
deck.tabLayout.add(
panelTool,
AbstractImagePrototype.create(resource).getHTML() + " " + selectedTool.getName(),
true
);
deck.tabLayout.selectTab(