MCPcopy Create free account
hub / github.com/GateNLP/gate-core / rebuildMenu

Method rebuildMenu

src/main/java/gate/gui/MainFrame.java:4355–4437  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4353 }
4354
4355 private void rebuildMenu() {
4356 // clear the menu and start over
4357 removeAll();
4358
4359 // find out the available types of LRs and repopulate the menu
4360 CreoleRegister reg = Gate.getCreoleRegister();
4361 List<String> resTypes;
4362 switch(type){
4363 case LR:
4364 resTypes = reg.getPublicLrTypes();
4365 break;
4366 case PR:
4367 resTypes = new ArrayList<String>( reg.getPublicPrTypes() );
4368 //GATE default controllers are now also PRs, but we don't want
4369 //them here
4370 resTypes.removeAll(reg.getPublicControllerTypes());
4371 break;
4372 case APP:
4373 resTypes = reg.getPublicControllerTypes();
4374 break;
4375 default:
4376 throw new GateRuntimeException("Unknown LiveMenu type: " + type);
4377 }
4378
4379 if(resTypes != null) {
4380 if (!resTypes.isEmpty()) {
4381 HashMap<String, ResourceData> resourcesByName
4382 = new HashMap<String, ResourceData>();
4383 Iterator<String> resIter = resTypes.iterator();
4384 while(resIter.hasNext()) {
4385 ResourceData rData = reg.get(resIter.next());
4386 resourcesByName.put(rData.getName(), rData);
4387 }
4388 List<String> resNames =
4389 new ArrayList<String>(resourcesByName.keySet());
4390 Collections.sort(resNames);
4391 resIter = resNames.iterator();
4392 while(resIter.hasNext()) {
4393 ResourceData rData = resourcesByName.get(resIter.next());
4394 add(new XJMenuItem(new NewResourceAction(rData), MainFrame.this));
4395 }
4396 } else if (type == PR) {
4397 // empty PR menu -> add an action to load ANNIE plugin
4398 add(new AbstractAction("Add ANNIE Resources to this Menu") {
4399 { putValue(SHORT_DESCRIPTION, "Load the ANNIE plugin."); }
4400 @Override
4401 public void actionPerformed(ActionEvent e) {
4402 try {
4403 for (Plugin plugin : PluginUpdateManager.getDefaultPlugins()) {
4404 if (plugin instanceof Plugin.Maven) {
4405 Plugin.Maven mp = (Plugin.Maven)plugin;
4406
4407 if (mp.getGroup().equals("uk.ac.gate.plugins") && mp.getArtifact().equals("annie")) {
4408 Gate.getCreoleRegister().registerPlugin(plugin);
4409 return;
4410 }
4411
4412 }

Callers 1

initMethod · 0.95

Calls 15

getCreoleRegisterMethod · 0.95
getPublicLrTypesMethod · 0.95
getPublicPrTypesMethod · 0.95
getNameMethod · 0.95
iteratorMethod · 0.65
hasNextMethod · 0.65
getMethod · 0.65
nextMethod · 0.65
addMethod · 0.65
statusChangedMethod · 0.65
removeAllMethod · 0.45

Tested by

no test coverage detected