Package javax.swing.event

Examples of javax.swing.event.HyperlinkEvent


          return null;
        }
        return new LinkGeneratorResult() {
          @Override
          public HyperlinkEvent execute() {
            return new HyperlinkEvent(defPos, HyperlinkEvent.EventType.ACTIVATED, null,
                defPos.getCls().getFullName());
          }

          @Override
          public int getSourceOffset() {
View Full Code Here


        scrollPane.setPreferredSize(new Dimension(700, 800));
        manFrame.setContentPane(scrollPane);
        manFrame.pack();
        manFrame.setVisible(true);
        URL cvdLinkUrl = new URL(manURL.toString() + "#ugr.tools.cvd");
        HyperlinkEvent e = new HyperlinkEvent(editorPane, HyperlinkEvent.EventType.ACTIVATED,
            cvdLinkUrl);
        editorPane.fireHyperlinkUpdate(e);
      } catch (Exception e) {
        handleException(e);
      }
View Full Code Here

                                    final Rectangle wb =
                                            source.getUI ().modelToView ( source, ( content.getBegin () + content.getEnd () ) / 2 );
                                    typeChooser.show ( source, wb.x, wb.y, wb.width, wb.height, PopOverDirection.down );

                                    return new HyperlinkEvent ( this, HyperlinkEvent.EventType.EXITED, null );
                                }
                                catch ( final BadLocationException e )
                                {
                                    Log.error ( this, e );
                                    return null;
                                }
                            }

                            @Override
                            public int getSourceOffset ()
                            {
                                return content.getBegin ();
                            }
                        };
                    }
                }
            }
        }
        else if ( propertyNodes.contains ( parentName ) )
        {
            final Segment content = element.getContent ();
            final String contentString = content.toString ();
            if ( booleanContent.contains ( contentString ) )
            {
                return new LinkGeneratorResult ()
                {
                    @Override
                    public HyperlinkEvent execute ()
                    {
                        source.replaceRange ( contentString.equals ( trueString ) ? falseString : trueString, content.getBegin (),
                                content.getEnd () );
                        return new HyperlinkEvent ( this, HyperlinkEvent.EventType.EXITED, null );
                    }

                    @Override
                    public int getSourceOffset ()
                    {
                        return content.getBegin ();
                    }
                };
            }
            else
            {
                if ( CompareUtils.contains ( name.toLowerCase (), colorContent ) )
                {
                    final Color color = ( Color ) colorConverter.fromString ( contentString );
                    if ( color != null || contentString.equals ( ColorConverter.NULL_COLOR ) )
                    {
                        return new LinkGeneratorResult ()
                        {
                            @Override
                            public HyperlinkEvent execute ()
                            {
                                try
                                {
                                    final WebPopOver colorChooser = new WebPopOver ( parentComponent );
                                    colorChooser.setCloseOnFocusLoss ( true );
                                    colorChooser.setStyleId ( "editor-pop-over" );

                                    final WebColorChooserPanel colorChooserPanel = new WebColorChooserPanel ( false );
                                    colorChooserPanel.setColor ( color != null ? color : Color.WHITE );
                                    colorChooserPanel.addChangeListener ( new ChangeListener ()
                                    {
                                        private int length = content.getEnd () - content.getBegin ();

                                        @Override
                                        public void stateChanged ( final ChangeEvent e )
                                        {
                                            final Color newColor = colorChooserPanel.getColor ();
                                            if ( color == null || newColor != null && !newColor.equals ( color ) )
                                            {
                                                final String colorString = colorConverter.toString ( newColor );
                                                source.replaceRange ( colorString, content.getBegin (), content.getBegin () + length );
                                                length = colorString.length ();
                                            }
                                        }
                                    } );
                                    colorChooser.add ( colorChooserPanel );

                                    final Rectangle wb =
                                            source.getUI ().modelToView ( source, ( content.getBegin () + content.getEnd () ) / 2 );
                                    colorChooser.show ( source, wb.x, wb.y, wb.width, wb.height, PopOverDirection.down );

                                    return new HyperlinkEvent ( this, HyperlinkEvent.EventType.EXITED, null );
                                }
                                catch ( final BadLocationException e )
                                {
                                    Log.error ( this, e );
                                    return null;
                                }
                            }

                            @Override
                            public int getSourceOffset ()
                            {
                                return content.getBegin ();
                            }
                        };
                    }
                }
                else if ( CompareUtils.contains ( name.toLowerCase (), transparencyContent ) )
                {
                    final Float f = ( Float ) floatConverter.fromString ( contentString );
                    if ( f != null )
                    {
                        return new LinkGeneratorResult ()
                        {
                            @Override
                            public HyperlinkEvent execute ()
                            {
                                try
                                {
                                    final WebPopOver transparencyChooser = new WebPopOver ( parentComponent );
                                    transparencyChooser.setCloseOnFocusLoss ( true );
                                    transparencyChooser.setStyleId ( "editor-pop-over" );

                                    final int value = MathUtils.limit ( Math.round ( 1000 * f ), 0, 1000 );
                                    final WebSlider slider = new WebSlider ( WebSlider.HORIZONTAL, 0, 1000, value );
                                    slider.setPaintTicks ( true );
                                    slider.setMajorTickSpacing ( 50 );
                                    slider.setMinorTickSpacing ( 10 );
                                    slider.setPaintLabels ( false );
                                    slider.setSnapToTicks ( true );
                                    slider.setMargin ( 10 );
                                    slider.setPreferredWidth ( 500 );
                                    slider.addChangeListener ( new ChangeListener ()
                                    {
                                        private int length = content.getEnd () - content.getBegin ();

                                        @Override
                                        public void stateChanged ( final ChangeEvent e )
                                        {
                                            final String floatString = floatConverter.toString ( ( float ) slider.getValue () / 1000 );
                                            source.replaceRange ( floatString, content.getBegin (), content.getBegin () + length );
                                            length = floatString.length ();
                                        }
                                    } );
                                    transparencyChooser.add ( slider );

                                    final Rectangle wb =
                                            source.getUI ().modelToView ( source, ( content.getBegin () + content.getEnd () ) / 2 );
                                    transparencyChooser.show ( source, wb.x, wb.y, wb.width, wb.height, PopOverDirection.down );

                                    return new HyperlinkEvent ( this, HyperlinkEvent.EventType.EXITED, null );
                                }
                                catch ( final BadLocationException e )
                                {
                                    Log.error ( this, e );
                                    return null;
View Full Code Here

              }
            else
              {
                // TODO: Implement link maps here.
              }
            HyperlinkEvent event = null;
            if (href != null)
              event = createHyperlinkEvent(editor, htmlDoc, href,
                                           anchorAtts, el);
            if (event != null)
              editor.fireHyperlinkUpdate(event);
View Full Code Here

          }
        catch (MalformedURLException ex)
          {
            url = null;
          }
        HyperlinkEvent ev;
        if (doc.isFrameDocument())
          {
            String target = null;
            if (anchor != null)
              target = (String) anchor.getAttribute(HTML.Attribute.TARGET);
            if (target == null || target.equals(""))
              target = doc.getBaseTarget();
            if (target == null || target.equals(""))
              target = "_self";
            ev = new HTMLFrameHyperlinkEvent(editor,
                                            HyperlinkEvent.EventType.ACTIVATED,
                                            url, href, el, target);
          }
        else
          {
            ev = new HyperlinkEvent(editor, HyperlinkEvent.EventType.ACTIVATED,
                                    url, href, el);
          }
        return ev;
      }
View Full Code Here

        assertTrue("Test completed without Exception", true);
    }

    @Test
    public void testListenerHyperlinkUpdate() throws Throwable {
        new HtmlFactory.Listener().hyperlinkUpdate(new HyperlinkEvent("", HyperlinkEvent.EventType.ENTERED, new URL(
                "ftp://q:77s35Ms8!q@uxlmi.net:4622/9M/aQ2Jlp_vr.gtvf")));
        assertTrue("Test completed without Exception", true);
    }
View Full Code Here

    }

    @Test
    public void testListenerHyperlinkUpdateThrowsClassCastException() throws Throwable {
        try {
            new HtmlFactory.Listener().hyperlinkUpdate(new HyperlinkEvent("1", HyperlinkEvent.EventType.ACTIVATED, new URL(
                    "ftp://q:77s35Ms8!q@uxlmi.net:4622/9M/aQ2Jlp_vr.gtvf")));
            fail("Expected ClassCastException to be thrown");
        } catch (ClassCastException ex) {
            assertEquals("ex.getClass()", ClassCastException.class, ex.getClass());
        }
View Full Code Here

    }

    private void dispatchLinkActivated( URL url ) {
        if( !EventQueue.isDispatchThread() ) System.out.println( "--Ooops. not event thread" );

        final HyperlinkEvent e = new HyperlinkEvent( this, HyperlinkEvent.EventType.ACTIVATED, url );
        final Iterator iter = hyperlinkListeners.iterator();
        while( iter.hasNext() ) {
            final HyperlinkListener l = (HyperlinkListener) iter.next();
            try {
                l.hyperlinkUpdate( e );
View Full Code Here

      super(textArea);
      insets = new Insets(0, 0, 0, 0);
    }

    private HyperlinkEvent createHyperlinkEvent() {
      HyperlinkEvent he = null;
      if (linkGeneratorResult!=null) {
        he = linkGeneratorResult.execute();
        linkGeneratorResult = null;
      }
      else {
        Token t = modelToToken(hoveredOverLinkOffset);
        URL url = null;
        String desc = null;
        try {
          String temp = t.getLexeme();
          // URI's need "http://" prefix for web URL's to work.
          if (temp.startsWith("www.")) {
            temp = "http://" + temp;
          }
          url = new URL(temp);
        } catch (MalformedURLException mue) {
          desc = mue.getMessage();
        }
        he = new HyperlinkEvent(RSyntaxTextArea.this,
            HyperlinkEvent.EventType.ACTIVATED,
            url, desc);
      }
      return he;
    }
View Full Code Here

    @Override
    public void mouseClicked(MouseEvent e) {
      if (getHyperlinksEnabled() && isScanningForLinks &&
          hoveredOverLinkOffset>-1) {
        HyperlinkEvent he = createHyperlinkEvent();
        if (he!=null) {
          fireHyperlinkUpdate(he);
        }
        stopScanningForLinks();
      }
View Full Code Here

TOP

Related Classes of javax.swing.event.HyperlinkEvent

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.