The union in this case is imposing their moral view on Sweden, if they stop imports you cant choose not to support the boycott . I think the onus is on them to petition the goverment to be allowed to boycott, and not the publics perogative to convince the goverment to change the law (If ive put that right). You have to absolutely be an automaton at work, otherwise your saying its ok for shopkeepers to refuse to serve foreigners, for cops to not investigate crimes against convicted offenders etc. I also dont think that the dockworkers action is different from the Israeli one just because it results in less suffering and hardship, i see it as sides on the same coin.
There are certain jobs where you are generally expected to simply follow the rules rather than your conscience - soldiers are the best example (although most states recognise the right of conscientious objection), and then we shade along through the police, emergency, and medical services. Those occupations in which one is entirely free to exercise one's conscience are fully civilian occupations, such as dockwork.
Even in the armed forces, though, the individual is still expected to exercise their conscience and judgement - that's why the excuse of "following orders" is not accepted in cases of war crime, genocide, etc.
On that subject, of what is legally allowed, I have to point out again that collective punishment against a civilian population is not legal, and that a dockworkers' embargo is not considered by any authority to constitute such action. Why do you think they're considered differently in law?