Java Code Examples for javax.swing.event.HyperlinkEvent#getDescription()

The following examples show how to use javax.swing.event.HyperlinkEvent#getDescription() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GHelpHTMLEditorKit.java    From ghidra with Apache License 2.0 6 votes vote down vote up
/** Generates a new event with a URL based upon Ghidra's resources if needed. */
private HyperlinkEvent maybeCreateNewHyperlinkEventWithUpdatedURL(HyperlinkEvent event) {
	Element element = event.getSourceElement();
	if (element == null) {
		return event;// this shouldn't happen since we were triggered from an A tag
	}

	AttributeSet a = element.getAttributes();
	AttributeSet anchor = (AttributeSet) a.getAttribute(HTML.Tag.A);
	if (anchor == null) {
		return event;// this shouldn't happen since we were triggered from an A tag
	}

	String HREF = (String) anchor.getAttribute(HTML.Attribute.HREF);
	Msg.trace(this, "HREF of <a> tag: " + HREF);
	URL newUrl = getURLForHREFFromResources(HREF);
	if (newUrl == null) {
		return event;// unable to locate a resource by the name--bad link!
	}

	return new HyperlinkEvent(event.getSource(), event.getEventType(), newUrl,
		event.getDescription(), event.getSourceElement());
}
 
Example 2
Source File: DocumentationScrollPane.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void hyperlinkUpdate(HyperlinkEvent e) {
    if (e != null && HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) {
        final String desc = e.getDescription();
        if (desc != null) {
            RP.post(new Runnable() {
                public @Override void run() {
                    final ElementJavadoc cd;
                    synchronized (DocumentationScrollPane.this) {
                        cd = currentDocumentation;
                    }
                    if (cd != null) {
                        final ElementJavadoc doc = cd.resolveLink(desc);
                        if (doc != null) {
                            EventQueue.invokeLater(new Runnable() {
                                public @Override void run() {
                                    setData(doc, false);
                                }
                            });
                        }
                    }
                }
            });
        }
    }
}
 
Example 3
Source File: DocumentationScrollPane.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void hyperlinkUpdate(HyperlinkEvent e) {
    if (e != null && HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) {
        final String desc = e.getDescription();
        if (desc != null) {
            RP.post(new Runnable() {
                public @Override void run() {
                    CompletionDocumentation cd = currentDocumentation;
                    if (cd != null) {
                        final CompletionDocumentation doc = cd.resolveLink(desc);
                        if (doc != null) {
                            EventQueue.invokeLater(new Runnable() {
                                public @Override void run() {
                                    setData(doc);
                                }
                            });
                        }
                    }
                }
            });
        }                    
    }
}
 
Example 4
Source File: ReportDisplay.java    From megamek with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void hyperlinkUpdate(HyperlinkEvent evt) {
    if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
        String evtDesc = evt.getDescription();
        if (evtDesc.startsWith("#entity")) {
            String idString = evtDesc.substring(evtDesc.indexOf(":") + 1);
            int id;
            try {
                id = Integer.parseInt(idString);
            } catch (Exception ex) {
                id = -1;
            }
            Entity ent = clientgui.getClient().getGame().getEntity(id);
            if (ent != null) {
                clientgui.mechD.displayEntity(ent);
                clientgui.setDisplayVisible(true);
            }
        }
    }
}
 
Example 5
Source File: SearchView.java    From Raccoon with Apache License 2.0 6 votes vote down vote up
@Override
public void hyperlinkUpdate(HyperlinkEvent event) {
	String prefix = "market://details?id="; //$NON-NLS-1$
	if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
		try {
			String url = event.getDescription();
			if (url.startsWith(prefix) && url.length() > prefix.length()) {
				// Let's keep it simple.
				query.setText(url.substring(prefix.length(), url.length()));
				doSearch();
			}
		}
		catch (Exception e) {
			e.printStackTrace();
		}
	}
}
 
Example 6
Source File: KeyboardInternationalizationNotificationManager.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void hyperlinkUpdate(@Nonnull Notification notification, @Nonnull HyperlinkEvent event) {
  if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
    final String description = event.getDescription();
    if ("enable".equals(description)) {
      KeyboardSettingsExternalizable.getInstance().setNonEnglishKeyboardSupportEnabled(true);
    }
    else if ("settings".equals(description)) {
      final ShowSettingsUtil util = ShowSettingsUtil.getInstance();
      IdeFrame ideFrame = WindowManagerEx.getInstanceEx().findFrameFor(null);
      //util.editConfigurable((JFrame)ideFrame, new StatisticsConfigurable(true));
      util.showSettingsDialog(ideFrame.getProject(), KeymapPanel.class);
    }

    NotificationsConfiguration.getNotificationsConfiguration().changeSettings(LOCALIZATION_GROUP_DISPLAY_ID, NotificationDisplayType.NONE, false, false);
    notification.expire();
  }
}
 
Example 7
Source File: CtrlMouseHandler.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void hyperlinkUpdate(@Nonnull HyperlinkEvent e) {
  if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED) {
    return;
  }

  String description = e.getDescription();
  if (StringUtil.isEmpty(description) || !description.startsWith(DocumentationManagerProtocol.PSI_ELEMENT_PROTOCOL)) {
    return;
  }

  String elementName = e.getDescription().substring(DocumentationManagerProtocol.PSI_ELEMENT_PROTOCOL.length());

  DumbService.getInstance(myProject).withAlternativeResolveEnabled(() -> {
    PsiElement targetElement = myProvider.getDocumentationElementForLink(PsiManager.getInstance(myProject), elementName, myContext);
    if (targetElement != null) {
      LightweightHint hint = myHint;
      if (hint != null) {
        hint.hide(true);
      }
      DocumentationManager.getInstance(myProject).showJavaDocInfo(targetElement, myContext, null);
    }
  });
}
 
Example 8
Source File: HomeView.java    From javamoney-examples with Apache License 2.0 6 votes vote down vote up
public
void
hyperlinkUpdate(HyperlinkEvent event)
{
  if(event.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
  {
    String command = event.getDescription();

    if(command.equals(ACTION_EDIT) == true)
    {
      PreferencesDialog.showPreferencesDialog(PreferencesKeys.ACCOUNTS);
    }
    else
    {
      // Get the account reference.
      Account account = (Account)getAccounts().get(command);

      // Show the account's register.
      getFrame().getViews().openRegisterFor(account);
    }
  }
}
 
Example 9
Source File: DocumentationScrollPane.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void hyperlinkUpdate(HyperlinkEvent e) {
    if (e != null && HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) {
        final String desc = e.getDescription();
        if (desc != null) {
            ElementJavadoc doc = currentDocumentation.resolveLink(desc);
            if (doc != null) {
                setData(doc, false);
            }
        }                    
    }
}
 
Example 10
Source File: ProgressLog.java    From stendhal with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void hyperlinkUpdate(HyperlinkEvent event) {
	if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
		/*
		 * It would be more correct to read the parameter from the link
		 * target, but swing does not give access to that when it fails
		 * to parse it as an URL.
		 */
		contentQueryData = event.getDescription();
		if (contentQuery != null) {
			contentQuery.fire(contentQueryData);
		}
	}
}
 
Example 11
Source File: SummaryInfoTab.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void hyperlinkUpdate(HyperlinkEvent e)
{
	if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
	{
		// We get two messages on a click, so ignore duplicates
		if (lastDest.equals(e.getDescription()))
		{
			lastDest = ""; //$NON-NLS-1$
			return;
		}
		lastDest = e.getDescription();
		firePropertyChange(TodoFacade.SWITCH_TABS, "", e.getDescription()); //$NON-NLS-1$
	}
}
 
Example 12
Source File: SummaryInfoTab.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void hyperlinkUpdate(HyperlinkEvent e)
{
	if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
	{
		// We get two messages on a click, so ignore duplicates
		if (lastDest.equals(e.getDescription()))
		{
			lastDest = ""; //$NON-NLS-1$
			return;
		}
		lastDest = e.getDescription();
		firePropertyChange(TodoFacade.SWITCH_TABS, "", e.getDescription()); //$NON-NLS-1$
	}
}
 
Example 13
Source File: TagInfoPanel.java    From jpexs-decompiler with GNU General Public License v3.0 5 votes vote down vote up
public TagInfoPanel(MainPanel mainPanel) {
    this.mainPanel = mainPanel;
    setLayout(new BorderLayout());
    JLabel topLabel = new JLabel(AppStrings.translate("taginfo.header"), JLabel.CENTER);
    add(topLabel, BorderLayout.NORTH);
    add(new JScrollPane(editorPane), BorderLayout.CENTER);

    editorPane.setContentType("text/html");
    editorPane.setEditable(false);

    HyperlinkListener listener = new HyperlinkListener() {
        @Override
        public void hyperlinkUpdate(HyperlinkEvent hyperLink) {

            if (HyperlinkEvent.EventType.ACTIVATED.equals(hyperLink.getEventType())) {
                String url = hyperLink.getDescription();
                String strId = url.substring(7);
                Integer id = Integer.parseInt(strId);

                mainPanel.setTagTreeSelectedNode(mainPanel.getCurrentSwf().getCharacter(id));
            }
        }

    };

    editorPane.addHyperlinkListener(listener);
}
 
Example 14
Source File: SystemHealthMonitor.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected void hyperlinkActivated(HyperlinkEvent e) {
  String url = e.getDescription();
  if ("ack".equals(url)) {
    myProperties.setValue("ignore." + key, "true");
  }
  else {
    BrowserUtil.browse(url);
  }
}
 
Example 15
Source File: BuckAddDependencyIntention.java    From buck with Apache License 2.0 4 votes vote down vote up
/**
 * Implementation of {@link
 * com.intellij.notification.NotificationListener#hyperlinkUpdate(Notification, HyperlinkEvent)}.
 */
private void hyperlinkActivated(
    @NotNull Notification notification, @NotNull HyperlinkEvent event) {
  String href = event.getDescription();
  switch (href) {
    case "editTarget":
      if (BuckTargetLocator.getInstance(project)
          .findElementForTarget(editTarget)
          .filter(target -> target instanceof NavigatablePsiElement)
          .map(target -> (NavigatablePsiElement) target)
          .filter(Navigatable::canNavigate)
          .map(
              e -> {
                e.navigate(true);
                return true;
              })
          .orElse(false)) {
        break;
      }
      // fallthrough
    case "editBuildFile":
      FileEditorManager.getInstance(project).openFile(editBuildFile, true);
      break;
    case "editSourceFile":
      FileEditorManager.getInstance(project).openFile(editSourceFile, true);
      break;
    case "importTarget":
      if (BuckTargetLocator.getInstance(project)
          .findElementForTarget(importTarget)
          .filter(target -> target instanceof NavigatablePsiElement)
          .map(target -> (NavigatablePsiElement) target)
          .filter(Navigatable::canNavigate)
          .map(
              e -> {
                e.navigate(true);
                return true;
              })
          .orElse(false)) {
        break;
      }
      // fallthrough
    case "importBuildFile":
      FileEditorManager.getInstance(project).openFile(importBuildFile, true);
      break;
    case "importSourceFile":
      FileEditorManager.getInstance(project).openFile(importSourceFile, true);
      break;
  }
}