Lines 81-89
Link Here
|
81 |
import org.netbeans.api.actions.Openable; |
81 |
import org.netbeans.api.actions.Openable; |
82 |
import org.netbeans.api.actions.Printable; |
82 |
import org.netbeans.api.actions.Printable; |
83 |
import org.netbeans.api.actions.Viewable; |
83 |
import org.netbeans.api.actions.Viewable; |
|
|
84 |
import org.openide.filesystems.FileObject; |
85 |
import org.openide.filesystems.FileUtil; |
84 |
import org.openide.util.ContextAwareAction; |
86 |
import org.openide.util.ContextAwareAction; |
85 |
import org.openide.util.ImageUtilities; |
87 |
import org.openide.util.ImageUtilities; |
86 |
import org.openide.util.LookupListener; |
88 |
import org.openide.util.LookupListener; |
|
|
89 |
import org.openide.util.Utilities; |
87 |
import org.openide.util.WeakListeners; |
90 |
import org.openide.util.WeakListeners; |
88 |
import org.openide.util.actions.BooleanStateAction; |
91 |
import org.openide.util.actions.BooleanStateAction; |
89 |
import org.openide.util.actions.SystemAction; |
92 |
import org.openide.util.actions.SystemAction; |
Lines 716-721
Link Here
|
716 |
} |
719 |
} |
717 |
throw new IllegalStateException(type); |
720 |
throw new IllegalStateException(type); |
718 |
} |
721 |
} |
|
|
722 |
|
723 |
/** |
724 |
* Locates a specific action programmatically. |
725 |
* The action will typically have been registered using {@link ActionRegistration}. |
726 |
* <p>Normally an {@link ActionReference} will suffice to insert the action |
727 |
* into various UI elements (typically using {@link Utilities#actionsForPath}), |
728 |
* but in special circumstances you may need to find a single known action. |
729 |
* This method is just a shortcut for using {@link FileUtil#getConfigObject} |
730 |
* with the correct arguments, plus using {@link AcceleratorBinding#setAccelerator}. |
731 |
* @param category as in {@link ActionID#category} |
732 |
* @param id as in {@link ActionID#id} |
733 |
* @return the action registered under that ID, or null |
734 |
* @since 7.42 |
735 |
*/ |
736 |
public static Action forID(String category, String id) { |
737 |
String path = "Actions/" + category + "/" + id.replace('.', '-') + ".instance"; |
738 |
Action a = FileUtil.getConfigObject(path, Action.class); |
739 |
if (a == null) { |
740 |
return null; |
741 |
} |
742 |
FileObject def = FileUtil.getConfigFile(path); |
743 |
if (def != null) { |
744 |
AcceleratorBinding.setAccelerator(a, def); |
745 |
} |
746 |
return a; |
747 |
} |
719 |
|
748 |
|
720 |
/** Extracts help from action. |
749 |
/** Extracts help from action. |
721 |
*/ |
750 |
*/ |