Java Code Examples for javax.swing.event.HyperlinkEvent

The following are top voted examples for showing how to use javax.swing.event.HyperlinkEvent. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: intellij-ce-playground   File: ResetConfigurationModuleAdapter.java   Source Code and License 7 votes vote down vote up
@Override
protected void hyperlinkActivated(HyperlinkEvent e) {
  final Module moduleByName = ModuleManager.getInstance(myProject).findModuleByName(e.getDescription());
  if (moduleByName != null) {
    myConfiguration.getConfigurationModule().setModule(moduleByName);
    try {
      Executor executor = myIsDebug ? DefaultDebugExecutor.getDebugExecutorInstance()
                                    : DefaultRunExecutor.getRunExecutorInstance();
      ExecutionEnvironmentBuilder.create(myProject, executor, myConfiguration).contentToReuse(null).buildAndExecute();
      Balloon balloon = myToolWindowManager.getToolWindowBalloon(myTestRunDebugId);
      if (balloon != null) {
        balloon.hide();
      }
    }
    catch (ExecutionException e1) {
      LOG.error(e1);
    }
  }
}
 
Example 2
Project: incubator-netbeans   File: BrowserUtils.java   Source Code and License 6 votes vote down vote up
public static HyperlinkListener createHyperlinkListener() {
    return new HyperlinkListener() {

        public void hyperlinkUpdate(HyperlinkEvent hlevt) {
            if (HyperlinkEvent.EventType.ACTIVATED == hlevt.getEventType()) {
                final URL url = hlevt.getURL();
                if (url != null) {
                    try {
                        openBrowser(url.toURI());
                    } catch (URISyntaxException e) {
                        LogManager.log(e);
                    }
                }
            }
        }
    };
}
 
Example 3
Project: incubator-netbeans   File: NotificationsManager.java   Source Code and License 6 votes vote down vote up
public void setupPane(JTextPane pane, final File[] files, String fileNames, final File projectDir, final String url, final String revision) {
     String msg = revision == null
             ? NbBundle.getMessage(NotificationsManager.class, "MSG_NotificationBubble_DeleteDescription", fileNames, CMD_DIFF) //NOI18N
             : NbBundle.getMessage(NotificationsManager.class, "MSG_NotificationBubble_Description", fileNames, url, CMD_DIFF); //NOI18N
    pane.setText(msg);

    pane.addHyperlinkListener(new HyperlinkListener() {
        @Override
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
                if(CMD_DIFF.equals(e.getDescription())) {
                    Context ctx = new Context(files);
                    DiffAction.diff(ctx, Setup.DIFFTYPE_REMOTE, NbBundle.getMessage(NotificationsManager.class, "LBL_Remote_Changes", projectDir.getName()), false); //NOI18N
                } else if (revision != null) {
                    try {
                        SearchHistoryAction.openSearch(new SVNUrl(url), projectDir, Long.parseLong(revision));
                    } catch (MalformedURLException ex) {
                        LOG.log(Level.WARNING, null, ex);
                    }
                }
            }
        }
    });
}
 
Example 4
Project: incubator-netbeans   File: HyperlinkEventProcessor.java   Source Code and License 6 votes vote down vote up
public void hyperlinkUpdate(HyperlinkEvent hyperlinkEvent) {
    url = hyperlinkEvent.getURL();
    HyperlinkEvent.EventType type = hyperlinkEvent.getEventType();
    if (type == HyperlinkEvent.EventType.ENTERED) {
      isInsideHyperlink = true;
      pane.setToolTipText(getURLExternalForm()); // #176141
    }
    else if (type == HyperlinkEvent.EventType.ACTIVATED) {
      isInsideHyperlink = false;
      pane.setToolTipText(null);
    }
    else if (type == HyperlinkEvent.EventType.EXITED) {
      isInsideHyperlink = false;
      pane.setToolTipText(null);
    }
    else {
      Installer.log.log(Level.SEVERE, "Unknown hyperlinkEvent: " +
                                       hyperlinkEvent);
    }
}
 
Example 5
Project: incubator-netbeans   File: DocumentationScrollPane.java   Source Code and License 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 6
Project: incubator-netbeans   File: DocumentationScrollPane.java   Source Code and License 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 7
Project: incubator-netbeans   File: ShowNotifications.java   Source Code and License 6 votes vote down vote up
private static JTextPane createInfoPanel(String notification) {
    JTextPane balloon = new JTextPane();
    balloon.setContentType("text/html");
    String text = getDetails(notification).replaceAll("(\r\n|\n|\r)", "<br>");
    balloon.setText(text);
    balloon.setOpaque(false);
    balloon.setEditable(false);
    balloon.setBorder(new EmptyBorder(0, 0, 0, 0));


    if (UIManager.getLookAndFeel().getID().equals("Nimbus")) {
        //#134837
        //http://forums.java.net/jive/thread.jspa?messageID=283882
        balloon.setBackground(new Color(0, 0, 0, 0));
    }

    balloon.addHyperlinkListener(new HyperlinkListener() {

        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
                URLDisplayer.getDefault().showURL(e.getURL());
            }
        }
    });
    return balloon;
}
 
Example 8
Project: rapidminer   File: FixedWidthEditorPane.java   Source Code and License 6 votes vote down vote up
/**
 * Creates a pane with the given rootlessHTML as text with the given width.
 *
 * @param width
 *            the desired width
 * @param rootlessHTML
 *            the text, can contain hyperlinks that will be clickable
 */
public FixedWidthEditorPane(int width, String rootlessHTML) {
	super("text/html", "");
	this.width = width;
	this.rootlessHTML = rootlessHTML;
	updateLabel();

	setEditable(false);
	setFocusable(false);
	installDefaultStylesheet();
	addHyperlinkListener(new HyperlinkListener() {

		@Override
		public void hyperlinkUpdate(HyperlinkEvent e) {
			if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
				RMUrlHandler.handleUrl(e.getDescription());
			}
		}
	});

}
 
Example 9
Project: jmt   File: HtmlPanel.java   Source Code and License 6 votes vote down vote up
/**
 * Initialize this component
 */
private void init() {
	antiAliasing = false;
	// By default disable editing
	setEditable(false);
	setContentType("text/html");

	// Adds hyperlink listener
	this.addHyperlinkListener(new HyperlinkListener() {
		public void hyperlinkUpdate(HyperlinkEvent e) {
			if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
				// An hyperlink is activated
				if (getPage() != null && e.getURL().getPath() != null && e.getURL().getPath().equals(getPage().getPath())) {
					setURL(e.getURL());
				} else {
					// Open external links in default browser
					BrowserLauncher.openURL(e.getURL().toString());
				}
			}
		}
	});
}
 
Example 10
Project: TrafficPetri   File: MessageWithLink.java   Source Code and License 6 votes vote down vote up
public MessageWithLink(String htmlBody) {
    super("text/html", "<html><body style=\"" + getStyle() + "\">" + htmlBody + "</body></html>");
    addHyperlinkListener(e -> {
        if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
            // Process the click event on the link (for example with java.awt.Desktop.getDesktop().browse())
            URI uri = URI.create(String.valueOf(e.getURL()));
            try {
                Desktop.getDesktop().browse(uri);
            } catch (IOException e1) {
                e1.printStackTrace();
            }
        }
    });
    setEditable(false);
    setBorder(null);
}
 
Example 11
Project: QN-ACTR-Release   File: HtmlPanel.java   Source Code and License 6 votes vote down vote up
/**
 * Initialize this component
 */
private void init() {
	antiAliasing = false;
	// By default disable editing
	setEditable(false);
	setContentType("text/html");

	// Adds hyperlink listener
	this.addHyperlinkListener(new HyperlinkListener() {
		public void hyperlinkUpdate(HyperlinkEvent e) {
			if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
				// An hyperlink is activated
				if (getPage() != null && e.getURL().getPath() != null && e.getURL().getPath().equals(getPage().getPath())) {
					setURL(e.getURL());
				} else {
					// Open external links in default browser
					BareBonesBrowserLaunch.openURL(e.getURL().toString());
				}
			}
		}
	});
}
 
Example 12
Project: gate-core   File: JTextPaneTableCellRenderer.java   Source Code and License 6 votes vote down vote up
public JTextPaneTableCellRenderer() {
  textPane.setContentType("text/html");
  textPane.setEditable(false);
  textPane.setOpaque(true);
  textPane.setBorder(null);

  textPane.setForeground(UIManager.getColor("Table.selectionForeground"));
  textPane.setBackground(UIManager.getColor("Table.selectionBackground"));

  Font font = UIManager.getFont("Label.font");
  String bodyRule =
      "body { font-family: " + font.getFamily() + "; " + "font-size: "
          + font.getSize() + "pt; "
          + (font.isBold() ? "font-weight: bold;" : "") + "}";
  ((HTMLDocument)textPane.getDocument()).getStyleSheet().addRule(bodyRule);

  textPane.addHyperlinkListener(new HyperlinkListener() {

    @Override
    public void hyperlinkUpdate(HyperlinkEvent e) {
      if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED))
          MainFrame.getInstance().showHelpFrame(e.getURL().toString(), "CREOLE Plugin Manager");
    }
  });
}
 
Example 13
Project: imagetozxspec   File: AboutListener.java   Source Code and License 6 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {		
	long maxHeap = Runtime.getRuntime().maxMemory();
	int cpus = Runtime.getRuntime().availableProcessors();
	JTextPane aboutField = new JTextPane();
	aboutField.setContentType("text/html");
	aboutField.setText("Image to ZX Spec is a simple to use program which applies a Sinclair ZX Spectrum<br>" +
			"effect to images, creates Spectrum playable slideshows from images or \"video\"<br>" +
			"from compatible video files.<br><br>"+
			"This software is copyright Silent Software (Benjamin Brown), uses Caprica Software<br>"+
			"Limited's VLCJ and Art Clarke's Humble Video as well as other open source libraries.<br>"+
			"See the included licences.txt for full details.<br><br>" +
			"Processors: "+cpus+"<br>"+
			"Total Java Memory: "+maxHeap/1024/1024+"MB<br><br>"+
			"Visit Silent Software at <a href='"+HOME_PAGE+"'>"+HOME_PAGE+"</a><br><br>"+
			"If you like this program and find it useful don't forget to <a href='"+COFFEE_LINK+"'>buy the developer a coffee!</a>");
	aboutField.putClientProperty(JTextPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
	aboutField.setEditable(false);
	aboutField.setOpaque(false);
	aboutField.addHyperlinkListener(e1 -> {
           if (HyperlinkEvent.EventType.ACTIVATED == e1.getEventType())	{
               openLink(e1.getURL());
           }
       });
	JOptionPane.showMessageDialog(null, aboutField, "About Image to ZX Spec", JOptionPane.INFORMATION_MESSAGE, ImageToZxSpec.IMAGE_ICON);
}
 
Example 14
Project: imagetozxspec   File: CoffeeDialog.java   Source Code and License 6 votes vote down vote up
void showPopupIfNecessary() {
	log.debug("Application starts: {}", optionsObject.getStarts());
	if (optionsObject.getStarts() == STARTS_BEFORE_COFFEE) {
		JTextPane aboutField = new JTextPane();
		aboutField.setContentType("text/html");
		aboutField.setText("<h2>You seem to be enjoying Image to ZX Spec!</h2>" +
				"Did you know Image to ZX Spec has been in development for the last 7 years?<br>"+
				"That's a lot of coffee, so please consider a contribution of any amount to the<br>"+
				"developer's coffee buying budget!<br>"+
				"<h3><a href='"+COFFEE_LINK+"'>Buy the developer a coffee</a></h3>"+
				"This popup will never be shown again, but if you want to buy a coffee later you can<br>"+
				"always find the link in the About dialog.<br><br>"+
				"<b>Thank you for your support.</b>");
		aboutField.putClientProperty(JTextPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
		aboutField.setEditable(false);
		aboutField.setOpaque(false);
		aboutField.addHyperlinkListener(e -> {
               if (HyperlinkEvent.EventType.ACTIVATED == e.getEventType())	{
                   openLink(e.getURL());
               }
           });
		JOptionPane.showMessageDialog(null, aboutField, "Information", JOptionPane.INFORMATION_MESSAGE, ImageToZxSpec.IMAGE_ICON);
	}
	optionsObject.setStarts((optionsObject.getStarts()+1));
	PreferencesService.save();		
}
 
Example 15
Project: ramus   File: Navigator.java   Source Code and License 6 votes vote down vote up
@Override
public JComponent createComponent() {
    pane.addHyperlinkListener(new HyperlinkListener() {
        @Override
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == EventType.ACTIVATED) {
                location = e.getURL().toExternalForm();
                openLocation();
            }
        }
    });

    pane.setEditable(false);

    scrollPane = new JScrollPane();
    scrollPane.setViewportView(this.pane);
    return scrollPane;
}
 
Example 16
Project: freecol   File: ColopediaPanel.java   Source Code and License 6 votes vote down vote up
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
    HyperlinkEvent.EventType type = e.getEventType();
    if (type == HyperlinkEvent.EventType.ACTIVATED) {
        String[] path = e.getURL().getPath().split("/");
        if (null != path[1]) {
            switch (path[1]) {
            case FreeColObject.ID_ATTRIBUTE_TAG:
                select(path[2]);
                break;
            case "action":
                getFreeColClient().getActionManager()
                    .getFreeColAction(path[2]).actionPerformed(null);
                break;
            default:
                break;
            }
        }
    }
}
 
Example 17
Project: nativehtml   File: SwingTextComponent.java   Source Code and License 6 votes vote down vote up
public SwingTextComponent(final Document document)  {
  //super("text/html");
	this.document = document;
	
	configureEditor(this);
	addHyperlinkListener(new HyperlinkListener() {
         
         @Override
         public void hyperlinkUpdate(HyperlinkEvent event) {
           if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
             RequestHandler requestHandler = document.getRequestHandler();
             if (requestHandler != null) {
               try {
                 requestHandler.openLink(event.getURL().toURI());
               } catch (URISyntaxException e) {
                 e.printStackTrace();
               }
             }
           }
         }
       });
}
 
Example 18
Project: educational-plugin   File: StepicStudyOptions.java   Source Code and License 6 votes vote down vote up
@NotNull
private HyperlinkAdapter createAuthorizeListener() {
  return new HyperlinkAdapter() {

    @Override
    protected void hyperlinkActivated(HyperlinkEvent e) {
      ApplicationManager.getApplication().getMessageBus().connect().subscribe(StudySettings.SETTINGS_CHANGED, () -> {
        StepicUser user = StudySettings.getInstance().getUser();
        if (user != null && !user.equals(myStepicUser)) {
          StudySettings.getInstance().setUser(myStepicUser);
          myStepicUser = user;
          updateLoginLabels(myStepicUser);
        }
      });

      EduStepicConnector.doAuthorize(() -> showDialog());
    }
  };
}
 
Example 19
Project: MFM   File: MFMHTMLTextPane.java   Source Code and License 6 votes vote down vote up
@Override
public void hyperlinkUpdate(final HyperlinkEvent event) {
    if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
        try {
            Desktop.getDesktop().browse(event.getURL().toURI());
        } catch (final IOException | URISyntaxException e) {
            throw new RuntimeException("Can't open URL", e);
        }
    }
}
 
Example 20
Project: FreeCol   File: ColopediaPanel.java   Source Code and License 6 votes vote down vote up
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
    HyperlinkEvent.EventType type = e.getEventType();
    if (type == HyperlinkEvent.EventType.ACTIVATED) {
        String[] path = e.getURL().getPath().split("/");
        if (null != path[1]) {
            switch (path[1]) {
            case FreeColObject.ID_ATTRIBUTE_TAG:
                select(path[2]);
                break;
            case "action":
                getFreeColClient().getActionManager()
                    .getFreeColAction(path[2]).actionPerformed(null);
                break;
            default:
                break;
            }
        }
    }
}
 
Example 21
Project: intellij-ce-playground   File: PowerSaveModeNotifier.java   Source Code and License 6 votes vote down vote up
static void notifyOnPowerSaveMode(Project project) {
  if (PropertiesComponent.getInstance().getBoolean(IGNORE_POWER_SAVE_MODE)) {
    return;
  }
  
  String message = "Code insight and other background tasks are disabled." +
                   "<br/><a href=\"ignore\">Do not show again</a>" +
                   "<br/><a href=\"turnOff\">Disable Power Save Mode</a>";
  POWER_SAVE_MODE.createNotification("Power save mode is on", message, NotificationType.WARNING, new NotificationListener() {
    @Override
    public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
      final String description = event.getDescription();
      if ("ignore".equals(description)) {
        PropertiesComponent.getInstance().setValue(IGNORE_POWER_SAVE_MODE, true);
        notification.expire();
      }
      else if ("turnOff".equals(description)) {
        PowerSaveMode.setEnabled(false);
        notification.expire();
      }
    }
  }).notify(project);
}
 
Example 22
Project: DataRecorder   File: HtmlViewer.java   Source Code and License 6 votes vote down vote up
@Override
public void hyperlinkUpdate(final HyperlinkEvent e) {
    if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
        final JEditorPane pane = (JEditorPane) e.getSource();
        if (e instanceof HTMLFrameHyperlinkEvent) {
            final HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent) e;
            final HTMLDocument doc = (HTMLDocument) pane.getDocument();
            doc.processHTMLFrameHyperlinkEvent(evt);
        } else {
            try {
                pane.setPage(e.getURL());
            } catch (final Throwable t) {
                MessageBox.showError(HtmlViewer.this.getParent(), t.getMessage());
            }
        }
    }
}
 
Example 23
Project: terrier-desktop   File: HelpDialog.java   Source Code and License 6 votes vote down vote up
/**
 * This method initializes jTextPane	
 * 	
 * @return javax.swing.JTextPane	
 */    
private JTextPane getJTextPane() {
	if (jTextPane == null) {
		jTextPane = new JTextPane();
		jTextPane.setContentType("text/html");
		jTextPane.setText(helpText);
		jTextPane.addHyperlinkListener(new HyperlinkListener() {
			public void hyperlinkUpdate(HyperlinkEvent e) {
				if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
					try{
						FileOpener opener = new MultiOSFileOpener();
						opener.open(e.getURL().toString());
					}catch (Exception ex) {
						logger.error("", ex);
					}
				}
			}
		});
		jTextPane.setEditable(false);			
	}
	return jTextPane;
}
 
Example 24
Project: Universal-Pointer-Searcher   File: HTMLDialogUtilities.java   Source Code and License 6 votes vote down vote up
public static void addHyperLinkListener(JEditorPane editorPane)
{
	editorPane.addHyperlinkListener(hyperlinkListener ->
	{
		if (HyperlinkEvent.EventType.ACTIVATED.equals(hyperlinkListener.getEventType()))
		{
			Desktop desktop = Desktop.getDesktop();

			try
			{
				desktop.browse(hyperlinkListener.getURL().toURI());
			} catch (Exception exception)
			{
				exception.printStackTrace();
			}
		}
	});
}
 
Example 25
Project: intellij-ce-playground   File: DefaultSdksConfigurable.java   Source Code and License 6 votes vote down vote up
private void createNdkDownloadLink() {
  myNdkDownloadHyperlinkLabel = new HyperlinkLabel();
  myNdkDownloadHyperlinkLabel.setHyperlinkText("", "Download", " Android NDK.");
  myNdkDownloadHyperlinkLabel.addHyperlinkListener(new HyperlinkAdapter() {
    @Override
    protected void hyperlinkActivated(HyperlinkEvent e) {
      List<IPkgDesc> requested = ImmutableList.of(PkgDesc.Builder.newNdk(FullRevision.NOT_SPECIFIED).create());
      SdkQuickfixWizard wizard = new SdkQuickfixWizard(null, null, requested);
      wizard.init();
      if (wizard.showAndGet()) {
        File ndk = IdeSdks.getAndroidNdkPath();
        if (ndk != null) {
          myNdkLocationTextField.setText(ndk.getPath());
        }
        validateState();
      }
    }
  });
}
 
Example 26
Project: intellij-ce-playground   File: GitBranchUiHandlerImpl.java   Source Code and License 6 votes vote down vote up
@Override
public void showUnmergedFilesNotification(@NotNull final String operationName, @NotNull final Collection<GitRepository> repositories) {
  String title = unmergedFilesErrorTitle(operationName);
  String description = unmergedFilesErrorNotificationDescription(operationName);
  VcsNotifier.getInstance(myProject).notifyError(title, description,
    new NotificationListener() {
      @Override
      public void hyperlinkUpdate(@NotNull Notification notification,
                                  @NotNull HyperlinkEvent event) {
        if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED && event.getDescription().equals("resolve")) {
          GitConflictResolver.Params params = new GitConflictResolver.Params().
            setMergeDescription(String.format("The following files have unresolved conflicts. You need to resolve them before %s.",
                                              operationName)).
            setErrorNotificationTitle("Unresolved files remain.");
          new GitConflictResolver(myProject, myGit, myFacade, GitUtil.getRootsFromRepositories(repositories), params).merge();
        }
      }
    }
  );
}
 
Example 27
Project: CodeChickenCore   File: DepLoader.java   Source Code and License 6 votes vote down vote up
@Override
public void showErrorDialog(String name, String url) {
    JEditorPane ep = new JEditorPane("text/html", "<html>" + owner + " was unable to download required library " + name + "<br>Check your internet connection and try restarting or download it manually from" + "<br><a href=\"" + url + "\">" + url + "</a> and put it in your mods folder" + "</html>");

    ep.setEditable(false);
    ep.setOpaque(false);
    ep.addHyperlinkListener(new HyperlinkListener() {
        @Override
        public void hyperlinkUpdate(HyperlinkEvent event) {
            try {
                if (event.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
                    Desktop.getDesktop().browse(event.getURL().toURI());
                }
            } catch (Exception e) {
            }
        }
    });

    JOptionPane.showMessageDialog(null, ep, "A download error has occured", JOptionPane.ERROR_MESSAGE);
}
 
Example 28
Project: intellij-ce-playground   File: EnvironmentVariablesTextFieldWithBrowseButton.java   Source Code and License 6 votes vote down vote up
protected MyEnvironmentVariablesDialog() {
  super(EnvironmentVariablesTextFieldWithBrowseButton.this, true);
  myEnvVariablesTable = new EnvVariablesTable();
  myEnvVariablesTable.setValues(convertToVariables(myData.getEnvs(), false));

  myUseDefaultCb.setSelected(isPassParentEnvs());
  myWholePanel.add(myEnvVariablesTable.getComponent(), BorderLayout.CENTER);
  JPanel useDefaultPanel = new JPanel(new BorderLayout());
  useDefaultPanel.add(myUseDefaultCb, BorderLayout.CENTER);
  HyperlinkLabel showLink = new HyperlinkLabel(ExecutionBundle.message("env.vars.show.system"));
  useDefaultPanel.add(showLink, BorderLayout.EAST);
  showLink.addHyperlinkListener(new HyperlinkListener() {
    @Override
    public void hyperlinkUpdate(HyperlinkEvent e) {
      if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
        showParentEnvironmentDialog(MyEnvironmentVariablesDialog.this.getWindow());
      }
    }
  });

  myWholePanel.add(useDefaultPanel, BorderLayout.SOUTH);
  setTitle(ExecutionBundle.message("environment.variables.dialog.title"));
  init();
}
 
Example 29
Project: PhET   File: SoftwareAgreementManager.java   Source Code and License 6 votes vote down vote up
public MessagePane( final JDialog owner, final SessionMessage sessionMessage ) {
    super( "" );

    // insert our own hyperlink descriptions into the message, so translators can't mess them up
    Object[] args = { LINK_SHOW_STATISTICS_DETAILS, LINK_SHOW_SOFTWARE_AGREEMENT };
    String htmlFragment = MessageFormat.format( MESSAGE_PATTERN, args );
    setText( HTMLUtils.createStyledHTMLFromFragment( htmlFragment ) );

    addHyperlinkListener( new HyperlinkListener() {
        public void hyperlinkUpdate( HyperlinkEvent e ) {
            if ( e.getEventType() == HyperlinkEvent.EventType.ACTIVATED ) {
                if ( e.getDescription().equals( LINK_SHOW_STATISTICS_DETAILS ) ) {
                    showStatisticsDetails( owner, sessionMessage );
                }
                else if ( e.getDescription().equals( LINK_SHOW_SOFTWARE_AGREEMENT ) ) {
                    showSoftwareAgreement( owner );
                }
                else {
                    System.err.println( "SoftwareAgreementManager.MessagePane.hyperlinkUpdate: unsupported hyperlink, description=" + e.getDescription() );
                }
            }
        }
    } );
    setBackground( new JPanel().getBackground() );//see #1275
}
 
Example 30
Project: intellij-ce-playground   File: GitUnstashDialog.java   Source Code and License 6 votes vote down vote up
@Override
protected void notifyUnresolvedRemain() {
  VcsNotifier.getInstance(myProject).notifyImportantWarning("Conflicts were not resolved during unstash",
                                                            "Unstash is not complete, you have unresolved merges in your working tree<br/>" +
                                                            "<a href='resolve'>Resolve</a> conflicts.", new NotificationListener() {
      @Override
      public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
        if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
          if (event.getDescription().equals("resolve")) {
            new UnstashConflictResolver(myProject, myRoot, myStashInfo).mergeNoProceed();
          }
        }
      }
    }
  );
}
 
Example 31
Project: intellij-ce-playground   File: Browser.java   Source Code and License 6 votes vote down vote up
public Browser(@NotNull InspectionResultsView view) {
  super(new BorderLayout());
  myView = view;

  myCurrentEntity = null;
  myCurrentDescriptor = null;

  myHTMLViewer = new JEditorPane(UIUtil.HTML_MIME, InspectionsBundle.message("inspection.offline.view.empty.browser.text"));
  myHTMLViewer.setEditable(false);
  myHyperLinkListener = new HyperlinkListener() {
    @Override
    public void hyperlinkUpdate(HyperlinkEvent e) {
      Browser.this.hyperlinkUpdate(e);
    }
  };
  myHTMLViewer.addHyperlinkListener(myHyperLinkListener);

  final JScrollPane pane = ScrollPaneFactory.createScrollPane(myHTMLViewer);
  pane.setBorder(null);
  add(pane, BorderLayout.CENTER);
  setupStyle();
}
 
Example 32
Project: intellij-ce-playground   File: NotificationsUtil.java   Source Code and License 6 votes vote down vote up
@Nullable
public static HyperlinkListener wrapListener(@NotNull final Notification notification) {
  final NotificationListener listener = notification.getListener();
  if (listener == null) return null;

  return new HyperlinkListener() {
    public void hyperlinkUpdate(HyperlinkEvent e) {
      if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
        final NotificationListener listener1 = notification.getListener();
        if (listener1 != null) {
          listener1.hyperlinkUpdate(notification, e);
        }
      }
    }
  };
}
 
Example 33
Project: intellij-ce-playground   File: LabelWithEditLink.java   Source Code and License 6 votes vote down vote up
public LabelWithEditLink() {
  setLayout(new BorderLayout());
  myCardPanel.add(EDIT, myEditField);
  myCardPanel.add(DISPLAY, myContentLabel);
  myCardPanel.revalidate();
  myCardPanel.repaint();
  myCardLayout.show(myCardPanel, DISPLAY);

  add(myCardPanel, BorderLayout.CENTER);
  add(myEditLabel, BorderLayout.EAST);

  myContentLabel.setHorizontalTextPosition(SwingConstants.RIGHT);
  myEditLabel.addHyperlinkListener(new HyperlinkListener() {
    @Override
    public void hyperlinkUpdate(HyperlinkEvent e) {
      if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) {
        toggleEdit();
      }
    }
  });
  myContentLabel.setForeground(JBColor.gray);
  setFont(UIUtil.getLabelFont());
  myEditLabel.setHtmlText(EDIT_TEXT);
}
 
Example 34
Project: safe-java   File: UiUtil.java   Source Code and License 6 votes vote down vote up
public static JEditorPane createLinkEnabledEditorPane(final Component parent,
                                                      String text) {
    JEditorPane pane = createEditorPane(text);
    HyperlinkListener linkListener = new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                URL url = e.getURL();
                if (!openBrowser(e.getURL())) {
                    JOptionPane.showMessageDialog(parent,
                                                  "An error occurred while opening the URL: " + url.toString(),
                                                  "Error", JOptionPane.ERROR_MESSAGE);
                }
            }
        }
    };
    pane.addHyperlinkListener(linkListener);
    return pane;
}
 
Example 35
Project: eva2   File: HtmlDemo.java   Source Code and License 6 votes vote down vote up
/**
 *
 */
public HyperlinkListener createHyperLinkListener() {
    return e -> {
        if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
            if (e instanceof HTMLFrameHyperlinkEvent) {
                ((HTMLDocument) htmlEditorPane.getDocument()).processHTMLFrameHyperlinkEvent(
                        (HTMLFrameHyperlinkEvent) e);
            } else {
                try {
                    htmlEditorPane.setPage(e.getURL());
                } catch (IOException ioe) {
                    System.out.println("IOE: " + ioe);
                }
            }
        }
    };
}
 
Example 36
Project: intellij-ce-playground   File: ProjectManagerImpl.java   Source Code and License 6 votes vote down vote up
public UnableToSaveProjectNotification(@NotNull final Project project, @NotNull VirtualFile[] readOnlyFiles) {
  super("Project Settings", "Could not save project", "Unable to save project files. Please ensure project files are writable and you have permissions to modify them." +
                                                       " <a href=\"\">Try to save project again</a>.", NotificationType.ERROR, new NotificationListener() {
    @Override
    public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
      final UnableToSaveProjectNotification unableToSaveProjectNotification = (UnableToSaveProjectNotification)notification;
      final Project _project = unableToSaveProjectNotification.myProject;
      notification.expire();

      if (_project != null && !_project.isDisposed()) {
        _project.save();
      }
    }
  });

  myProject = project;
  myFiles = readOnlyFiles;
}
 
Example 37
Project: JSmooth   File: HTMLPane.java   Source Code and License 6 votes vote down vote up
public void hyperlinkUpdate(HyperlinkEvent e) {
  if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {

    JEditorPane pane = (JEditorPane)e.getSource();
    if (e instanceof HTMLFrameHyperlinkEvent) {
      HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent)e;
      HTMLDocument doc = (HTMLDocument)pane.getDocument();
      doc.processHTMLFrameHyperlinkEvent(evt);
    } else {
      try {
        URL nurl = e.getURL();
        if (nurl == null) nurl = new URL(m_baseurl, e.getDescription());
        if (jsmooth.Native.isAvailable()) {
          jsmooth.Native.shellExecute(jsmooth.Native.SHELLEXECUTE_OPEN, nurl.toString(), null, null, jsmooth.Native.SW_NORMAL);
        } else
          m_launcher.openURLinBrowser(nurl.toExternalForm());
      } catch (Throwable t) {
        t.printStackTrace();
      }
    }
  }
}
 
Example 38
Project: intellij-ce-playground   File: DvcsBranchPopup.java   Source Code and License 6 votes vote down vote up
private void notifyAboutSyncedBranches() {
  String description =
    "You have several " + myVcs.getDisplayName() + " roots in the project and they all are checked out at the same branch. " +
    "We've enabled synchronous branch control for the project. <br/>" +
    "If you wish to control branches in different roots separately, " +
    "you may <a href='settings'>disable</a> the setting.";
  NotificationListener listener = new NotificationListener() {
    @Override
    public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
      if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
        ShowSettingsUtil.getInstance().showSettingsDialog(myProject, myVcs.getConfigurable().getDisplayName());
        if (myVcsSettings.getSyncSetting() == DvcsSyncSettings.Value.DONT_SYNC) {
          notification.expire();
        }
      }
    }
  };
  VcsNotifier.getInstance(myProject).notifyImportantInfo("Synchronous branch control enabled", description, listener);
}
 
Example 39
Project: intellij-ce-playground   File: CloudGitRemoteDetector.java   Source Code and License 6 votes vote down vote up
public RepositoryNotifier(CloudGitDeploymentDetector deploymentDetector, GitRepository repository) {
  myDeploymentDetector = deploymentDetector;
  myRepositoryRoot = repository.getRoot();
  myCloudName = deploymentDetector.getCloudType().getPresentableName();
  String path = FileUtil.toSystemDependentName(myRepositoryRoot.getPath());
  myNotification = myNotifier.showMessage(CloudBundle.getText("git.cloud.app.detected", myCloudName, path),
                                          MessageType.INFO,
                                          new NotificationListener() {

                                            @Override
                                            public void hyperlinkUpdate(@NotNull Notification notification,
                                                                        @NotNull HyperlinkEvent event) {
                                              setupRunConfiguration();
                                            }
                                          });
}
 
Example 40
Project: littleluck   File: EditorPaneDemo.java   Source Code and License 6 votes vote down vote up
private HyperlinkListener createHyperLinkListener() {
    return new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                if (e instanceof HTMLFrameHyperlinkEvent) {
                    ((HTMLDocument) html.getDocument()).processHTMLFrameHyperlinkEvent(
                            (HTMLFrameHyperlinkEvent) e);
                } else {
                    try {
                        html.setPage(e.getURL());
                    } catch (IOException ioe) {
                        System.out.println("IOE: " + ioe);
                    }
                }
            }
        }
    };
}