harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexey Petrenko" <alexey.a.petre...@gmail.com>
Subject Re: [classlib][swing] javax.swing.JComponent is not supposed to be imported by awt
Date Fri, 26 Oct 2007 11:49:37 GMT
I said in most cases :)

2007/10/26, Maenkova, Evgeniya G <evgeniya.g.maenkova@intel.com>:
> >I think it will not bring huge impact to startup time in most cases
> >because it's hard to imagine modern application using awt but not
> >swing
>
> Aleksey, look at jfreechart.
>
> Thanks,
> Evgeniya
>
> -----Original Message-----
> From: Alexey Petrenko [mailto:alexey.a.petrenko@gmail.com]
> Sent: Friday, October 26, 2007 1:03 PM
> To: dev@harmony.apache.org
> Subject: Re: [classlib][swing] javax.swing.JComponent is not supposed to
> be imported by awt
>
> Speaking of startup time...
> I think it will not bring huge impact to startup time in most cases
> because it's hard to imagine modern application using awt but not
> swing.
>
> However, from architectural point of view I agree that reference swing
> classes from awt is not good idea.
>
> SY, Alexey
>
> 2007/10/26, Maenkova, Evgeniya G <evgeniya.g.maenkova@intel.com>:
> > The point is: there is pretty big difference between references to
> some
> > classes with logic (like Document, Caret, etc) and references to
> > JComponent.
> >
> > If you use JComponent in awt it increases startup time (as a pretty
> big
> > part of swing is loaded actually) and makes awt text component
> heavier.
> >
> > 'Model' classes are pretty light. They don't load all swing.
> >
> > The idea was reuse in awt some swing logic, common for all text
> > component, w/o loading swing per se.
> >
> > Thanks,
> > Evgeniya
> >
> >
> >
> > -----Original Message-----
> > From: Alexey Petrenko [mailto:alexey.a.petrenko@gmail.com]
> > Sent: Friday, October 26, 2007 11:28 AM
> > To: dev@harmony.apache.org
> > Subject: Re: [classlib][swing] javax.swing.JComponent is not supposed
> to
> > be imported by awt
> >
> > As far as I remember we have one implementation of text processing
> > routines for awt and swing. That's why awt code could reference swing
> > classes.
> >
> > I'll take a look...
> >
> > SY, Alexey
> >
> > 2007/10/26, Alexei Fedotov <alexei.fedotov@gmail.com>:
> > > Hello,
> > >
> > > I'm currently looking through the swing and awt code to find out
> what
> > > should be done to make drag and drop work. Today I find out that the
> > > class org.apache.harmony.awt.text.TextUtils contains nearly the same
> > > functionality as javax.swing.TransferHandler [2]. Thanks to Evgeniya
> > > Maenkova! She explained me that AWT cannot reuse
> > > javax.swing.TransferHandler due to referenced javax.swing.JComponent
> > > which is heavy class. I have looked through the dev@ list and
> couldn't
> > > find that this core principle of our client API was referenced here
> > > before.
> > >
> > > Finally I've prepared a patch to remove another existing reference
> to
> > > JComponent from org.apache.harmony.awt.text.TextUtils [1]. Could
> > > anyone review and commit the patch?
> > >
> > > Thanks!
> > >
> > > [1] https://issues.apache.org/jira/browse/HARMONY-5023
> > > [2]
> > > org.apache.harmony.awt.text.TextUtils:
> > >     public static final boolean importData(final TextKit textKit,
> > >                                         final Transferable t) {
> > >
> > >         if (t == null) {
> > >             return false;
> > >         }
> > >         DataFlavor[] flavors = t.getTransferDataFlavors();
> > >         DataFlavor flavor = null;
> > >         for (DataFlavor element : flavors) {
> > >             flavor = element;
> > >             if
> > (String.class.isAssignableFrom(flavor.getRepresentationClass()))
> > > {
> > >                 break;
> > >             }
> > >             flavor = null;
> > >         }
> > >         if (flavor != null) {
> > >             try {
> > >                 String text = (String) t.getTransferData(flavor);
> > >                 textKit.replaceSelectedText(text);
> > >                 return true;
> > >             } catch (UnsupportedFlavorException e) {
> > >                 return false;
> > >             } catch (IOException e) {
> > >                 return false;
> > >             }
> > >         }
> > >         return false;
> > >     }
> > >
> > > javax.swing.TransferHandler:
> > >     public boolean importData(final JComponent c,
> > >                               final Transferable t) {
> > >         PropertyDescriptor descriptor = getPropertyDescriptor(c);
> > >         if (descriptor == null) {
> > >             return false;
> > >         }
> > >         Class propertyType = descriptor.getPropertyType();
> > >         DataFlavor flavor = getPrefferedFlavor(t, propertyType);
> > >         if (flavor == null) {
> > >             return false;
> > >         }
> > >
> > >         try {
> > >             Object value = t.getTransferData(flavor);
> > >             Method writer = descriptor.getWriteMethod();
> > >             writer.invoke(c, new Object[]{value});
> > >             return true;
> > >         } catch (UnsupportedFlavorException e) {
> > >         } catch (IOException e) {
> > >         } catch (InvocationTargetException e) {
> > >         } catch (IllegalAccessException e) {
> > >         }
> > >         return false;
> > >     }
> > >
> > >
> > >
> > >
> > > --
> > > With best regards,
> > > Alexei,
> > > ESSD, Intel
> > >
> > --------------------------------------------------------------------
> > Closed Joint Stock Company Intel A/O
> > Registered legal address: 125252, Moscow, Russian Federation,
> > Chapayevsky Per, 14.
> >
> > This e-mail and any attachments may contain confidential material for
> > the sole use of the intended recipient(s). Any review or distribution
> > by others is strictly prohibited. If you are not the intended
> > recipient, please contact the sender and delete all copies.
> >
> --------------------------------------------------------------------
> Closed Joint Stock Company Intel A/O
> Registered legal address: 125252, Moscow, Russian Federation,
> Chapayevsky Per, 14.
>
> This e-mail and any attachments may contain confidential material for
> the sole use of the intended recipient(s). Any review or distribution
> by others is strictly prohibited. If you are not the intended
> recipient, please contact the sender and delete all copies.
>

Mime
View raw message