Package org.wikipediacleaner.gui.swing.action

Examples of org.wikipediacleaner.gui.swing.action.ChangePreferredDisambiguationAction


                  submenu2, pageTmp, null, true,
                  new ReplaceLinkAction(page.getTitle(), pageTmp.getTitle(), text, element, textPane, true));

              addItem(
                  submenu3, pageTmp, null, true,
                  new ChangePreferredDisambiguationAction(
                      page.getWikipedia(), page.getTitle(), pageTmp.getTitle(), true));

              if ((anchors != null) && (anchors.size() > 0)) {
                for (String anchor : anchors) {
                  addItem(
                      submenu1, pageTmp, anchor, true,
                      new ReplaceLinkAction(page.getTitle(), anchor, text, element, textPane, false));

                  addItem(
                      submenu2, pageTmp, anchor, true,
                      new ReplaceLinkAction(page.getTitle(), anchor, text, element, textPane, true));

                  if (!preferredDabs.contains(anchor)) {
                    addItem(
                        submenu3, pageTmp, anchor, true,
                        new ChangePreferredDisambiguationAction(
                            page.getWikipedia(), page.getTitle(), anchor, true));
                  }
                }
              }
            }
           
            submenuLink.add(submenu1);
            submenuReplace.add(submenu2);
            submenuAddPreferred.add(submenu3);
          } else if ((p.getNamespace() != null) &&
                     (p.getNamespace().intValue() == Namespace.CATEGORY)) {
            JMenu submenu1 = new JMenu(p.getTitle());
            JMenu submenu2 = new JMenu(p.getTitle());

            addItem(
                submenu1, p, null, true,
                new ReplaceLinkAction(page.getTitle(), p.getTitle(), text, element, textPane, false));
            addItem(
                submenu2, p, null, true,
                new ReplaceLinkAction(page.getTitle(), p.getTitle(), text, element, textPane, true));

            addSeparator(submenu1);
            addSeparator(submenu2);

            List<Page> categoryMembers = p.getRelatedPages(Page.RelatedPages.CATEGORY_MEMBERS);
            if (categoryMembers == null) {
              addItem(
                  submenu1, null, GT._("Reload category members"), true,
                  new ReloadCategoryMembersAction(wiki, p, null));
            } else {
              for (Page p2 : categoryMembers) {
                boolean already = false;
                for (Page p3 : links) {
                  if (Page.areSameTitle(p2.getTitle(), p3.getTitle())) {
                    already = true;
                  }
                }
                if (!already) {
                  addItem(
                      submenu1, p2, null, true,
                      new ReplaceLinkAction(page.getTitle(), p2.getTitle(), text, element, textPane, false));
                  addItem(
                      submenu2, p2, null, true,
                      new ReplaceLinkAction(page.getTitle(), p2.getTitle(), text, element, textPane, true));
                }
              }
            }

            addSubmenu(submenuLink, submenu1, 2, 0);
            addSubmenu(submenuReplace, submenu2, 2, 0);
          } else {
            addItem(
                submenuLink, p, null, true,
                new ReplaceLinkAction(page.getTitle(), p.getTitle(), text, element, textPane, false));

            addItem(
                submenuReplace, p, null, true,
                new ReplaceLinkAction(page.getTitle(), p.getTitle(), text, element, textPane, true));

            if (!preferredDabs.contains(p.getTitle())) {
              addItem(
                  submenuAddPreferred, p, null, true,
                  new ChangePreferredDisambiguationAction(
                      page.getWikipedia(), page.getTitle(), p.getTitle(), true));
            }

            // Anchors
            List<String> anchors = anchorsMap.get(p);
            if (anchors != null) {
              for (String anchor : anchors) {
                addItem(
                    submenuLink, p, anchor, true,
                    new ReplaceLinkAction(page.getTitle(), anchor, text, element, textPane, false));

                addItem(
                    submenuReplace, p, anchor, true,
                    new ReplaceLinkAction(page.getTitle(), anchor, text, element, textPane, true));

                if (!preferredDabs.contains(anchor)) {
                  addItem(
                      submenuAddPreferred, p, anchor, true,
                      new ChangePreferredDisambiguationAction(
                          page.getWikipedia(), page.getTitle(), anchor, true));
                }
              }
            }
          }
        }
      }

      // Last replacement
      if (separators) {
        if (!preferredDabs.isEmpty()) {
          fixedEndLink += addSeparator(submenuLink);
          fixedEndReplace += addSeparator(submenuReplace);
          for (String title : preferredDabs) {
            if ((withLastSuffix != null) && (withLastSuffix.equals(title))) {
              withLastSuffix = null;
            }
            fixedEndLink += addItem(
                submenuLink, null, title, true,
                new ReplaceLinkAction(page.getTitle(), title, text, element, textPane, false),
                (preferredDabs.size() == 1) ? lastLinkKeyStroke : null);
            fixedEndReplace += addItem(
                submenuReplace, null, title, true,
                new ReplaceLinkAction(page.getTitle(), title, text, element, textPane, true),
                (preferredDabs.size() == 1) ? lastReplaceKeyStroke : null);
          }
        }
      }

      addSubmenu(popup, submenuLink, fixedBeginLink, fixedEndLink);
      addSubmenu(popup, submenuReplace, fixedBeginReplace, fixedEndReplace);

      submenuAddPreferred.addSeparator();
      addItem(
          submenuAddPreferred, null, GT._("Add other preferred disambiguation..."), true,
          new ChangePreferredDisambiguationAction(
              page.getWikipedia(),
              page.getTitle(), textPane,
              GT._("What link do you want to add to the preferred disambiguations?"),
              null,
              new StringCheckerUnauthorizedCharacters("[|]")),
          null);
      addSubmenu(popup, submenuAddPreferred, 0, 2);

      if (!preferredDabs.isEmpty()) {
        JMenu submenuRemove = new JMenu(GT._("Remove from preferred disambiguations"));
        for (String title : preferredDabs) {
          addItem(
              submenuRemove, null, title, true,
              new ChangePreferredDisambiguationAction(
                  page.getWikipedia(), page.getTitle(), title, false),
              null);
        }
        addSubmenu(popup, submenuRemove, 0, 0);
      }
View Full Code Here

TOP

Related Classes of org.wikipediacleaner.gui.swing.action.ChangePreferredDisambiguationAction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.