This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 28145 - ClassCastException from NbFrameOperator, if JInternalFrame is iconified
Summary: ClassCastException from NbFrameOperator, if JInternalFrame is iconified
Status: CLOSED FIXED
Alias: None
Product: qa
Classification: Unclassified
Component: Jellytools (show other bugs)
Version: 3.x
Hardware: All All
: P2 blocker (vote)
Assignee: issues@qa
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-10-21 16:56 UTC by Marian Mirilovic
Modified: 2002-11-07 09:35 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
ClassCastException (6.77 KB, text/plain)
2002-10-21 16:57 UTC, Marian Mirilovic
Details
fixed NbFrameOperator (9.88 KB, text/plain)
2002-10-21 16:58 UTC, Marian Mirilovic
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marian Mirilovic 2002-10-21 16:56:20 UTC
When you use 

new NbFrameOperator("Source Editor");

and Source Editor window is iconified, than
ClassCastException arise (see attachment).

I have made the fix ( see attachment).
Comment 1 Marian Mirilovic 2002-10-21 16:57:21 UTC
Created attachment 7718 [details]
ClassCastException
Comment 2 Marian Mirilovic 2002-10-21 16:58:54 UTC
Created attachment 7719 [details]
fixed NbFrameOperator
Comment 3 Alexandre Iline 2002-10-23 08:01:17 UTC
As far as I see your fix is not correct.

In case of finding JDesktopIcon, "result" variable should be set to
ifr.getInternalFrame() as it's done in Jemmy.

I'll implement it.

Thanks.


Comment 4 Marian Mirilovic 2002-10-23 09:08:32 UTC
Shura, why ? What is incorrect?

I am using NbFrameOperator at time , when I don't know whether frame I
am looking for is JinternalFrame or JFrame, so for this reason , as I
know we have NbFrameOperator. 

I really don't understand what is incorrect on my fix??? Please let me
know !

In this case we need only prohibit ClassCastException and if somebody
looks for some J(Internal)Frame by title, and this J(Internal)Frame is
iconified it will be nice to return founded frame (JFrame,
JInternalFrame or/and JInternalFrame.JDesktopIcon.
Comment 5 Adam Sotona 2002-10-23 09:21:54 UTC
I am sorry, I made some changes to NbFrameOperator as Marian proposed.
I was not able to access Issuezilla to see you started to work on this
bug Shura.
Change it as you considered.
Comment 6 Alexandre Iline 2002-10-23 10:00:32 UTC
NbFrameOperator can be created for a container - that's how it 
works.

Using you code, you will find JDesktopIcon instance. Thus, you  
will create an operator for component you found - JDesctopPane, 
again - not JInternalFrame. Thus, even if there would be method
unminimizing NbFrameOperator, you wouldn't be able to do so,
because you would receive ClassCastException, probably, when
JDesktopPane would be casted to JInternalFrame.

Your fix is _almost_ correct - you would just add one more line:
if(result instanceof JInternalFrame){
//...
}else if(result instanceof JInternalFrame.JDesktopIcon){
    JInternalFrame.JDesktopIcon ifr = 
(JInternalFrame.JDesktopIcon)result;
    result = ifr.getInternalFrame(); //this one
    params[0] = new Rectangle(ifr.getWidth(), ifr.getHeight());
}

Full fix, however, will be bigger: mizimizing/maximazing methods 
should be implemented as well.


Comment 7 Marian Mirilovic 2002-10-23 10:13:59 UTC
Shura, I used NbFrameOperator only for determine whether my frame is
instanceof JInternalFrame, JFrame or JInternalFrame.JDesktopIcon , and
I used JInternalFrameOpeator for actions with iconified internal
frame. So I used NbFrameOperator as "a general find operator" if I
don't know type of frame.

I agree with additional methods , but in my opinion it will duplicate
methods in JInternalFrameOperator, so again we are doing the same
things on differetn parts of Jelly. 
Comment 8 Jiri Skrivanek 2002-10-23 10:19:34 UTC
I wouldn't add minimizing, maximizing or whatever else functionality
into NbFrameOperator. It is not intended to be used to test such
features. JFrameOeprator or JInternalFrameOperator is enough to
provide it. It is easy to convert NbFrameOperator to proper one:

        NbFrameOperator frame = new NbFrameOperator("Explorer");
        JInternalFrameOperator intFrame = new
JInternalFrameOperator(frame);
        intFrame.iconify();
Comment 9 Alexandre Iline 2002-10-24 01:53:23 UTC
2Jiri. I am not sure myself that those methods should be added. 
However we have to provide some king of shorcut for deminimizing.

Any ideas?

Frame could be deminimized in constructor, what do you think?

Comment 10 Jiri Skrivanek 2002-10-24 07:27:41 UTC
I wouldn't do this. Actually, internal frame should not be minimized
when I am going to use NbFrameOperator constructor. If the frame is
minimized, test probably fails in consequent steps. I think it is
allright because it detects unusual state of frame.
Comment 11 Alexandre Iline 2002-10-24 09:06:02 UTC
So, you mean that issue should not be fixed?

Well, I am not so sure. 

Just think: we do switch tabbed pages, scroll scroll panes, 
activate
windows for components. We even search for invisible TopComponents
lately. Why can't we unminimize internal frames as well?

Generally speaking it could even be a mode in DefaultVisualizer. :)



Comment 12 Jiri Skrivanek 2002-10-24 09:59:12 UTC
OK, you are right we do a lot of things like that. So, go ahead and
implement deminimizing it is doable.
Comment 13 Marian Mirilovic 2002-10-24 12:48:43 UTC
Shura:
If we will do deiconify in constructor of NbFrameOperator, than
instance of object for that we construct operator will be changed
during construction from JInternalFrame.JDesktopIcon to
JInternalFrame, it is a bit different as scrolling to or switching tab
!!!!!

Method NbFrameOperator.findJFrameOrJinternalFrame(String, int) returns
container and JInternalFrame.JDesktopIcon is a container, so why we
cann't return it ?

IMHO:
If new JInternalFrameOperator(ContainerOperator, String) returns
JInternalFrameOperator for iconified JInternalFrame - means
JInternalFrame.JDesktopIcon, and if you want deiconify it you use
JInternalFrameOperator.deiconify() too, why we cann't return as new
NbFrameOperator(String) - operator for JInternalFrame.JDesktopIcon ???

Once again I am using it in Window System test library, I don't know
whether it is JFrame or JInternalFrame (rason using NbFrameOperator)
and I don't know it is iconified or not, my resolutions depends on
returned instance.

I hope it's my last comment during issue resolving.
Guys please don't speak, just do it.
Comment 14 Alexandre Iline 2002-10-25 03:38:17 UTC
Paragraph by paragraph. :)

1. Nothing will be changed during constructor, because constructor 
will receive JInternalFrame instance. Because 
findJFrameOrJinternalFrame(String, int)
will return JInternalFrame.

2. findJFrameOrJinternalFrame(String, int) cannot return a 
Container
simply because NbFrame is designed to represent "frame" idea 
which, depending on mode, could bi either JFrame or 
JInternalFrame - nothing more. Common ancestor of these two is
Container - that's why NbFrame has a constructor with Container
parameter.

You are right about one thing: NbFrame constructor should throw an 
exception when object passed is neither JFrame nor JInternalFrame. 
:)

4. Unminimizing of JInternalFrame could not possible have any bad 
effect on you.

5. I will make right fix. :)
I was waiting for an approval from guys - Jiri gave it. Now I'll 
fix it.

Comment 15 Alexandre Iline 2002-10-29 02:29:24 UTC
NbFrame now unminimized after finding.
Comment 16 Marian Mirilovic 2002-10-31 14:07:59 UTC
You really did it, I don't believe it ?!

Well, please explain me how can I write next method in Window System
test library :

-------------------------------------------------
    public void deIconify(String iconName) {
        makeLog("Deiconifying window(icon) with name " + iconName);
        
        NbFrameOperator frame = new NbFrameOperator(iconName);
        
        if((frame.getSource() instanceof JInternalFrame) ||
(frame.getSource() i
nstanceof JInternalFrame.JDesktopIcon)){
            JInternalFrameOperator internalOp =
getJInternalFrameOperator(iconNa
me);
            internalOp.deiconify();
        } else {                //SDI
            JFrameOperator frameOp = getJFrameOperator(iconName);
            frameOp.setState(javax.swing.JFrame.NORMAL);
        }
        
        makeLog("Deiconifying window(icon) with name " + iconName + "
- finished
.");
    }
-------------------------------------------------

or

-------------------------------------------------
   public boolean isMinimized(String windowTitle) {
        boolean icon = false;
        
        makeLog("Checking window=["+windowTitle+"] is minimized");
        
        NbFrameOperator frame = new NbFrameOperator(windowTitle);
        
        if(frame.getSource() instanceof JInternalFrame ||
frame.getSource() inst
anceof JInternalFrame.JDesktopIcon){
            JInternalFrameOperator internalOp =
getJInternalFrameOperator(window
Title);
            icon = internalOp.isIcon();
        } else {                //SDI
            makeLog("DOESN'T WORK IN SDI !!!");
        }
        
        makeLog("Checking if window=["+windowTitle+"] minimized
["+icon+"]- fini
shed.");
        return icon;
    }

--------------------------------------------------


because now constructor :
NbFrameOperator frame = new NbFrameOperator(iconName);

deiconify minimized JInternalFrame !!!
Thanks
 
Comment 17 Alexandre Iline 2002-10-31 21:02:42 UTC
This is intresting. :)

The stuff you do in the isMinimized(String) methods is 
really low-level functionality in terms of NB GUI functional 
testing, so I would use Jemmy directly there.

However, that direct Jemmy usage would look very much the same 
as waitContainer/findJFrameOrJInternalFrame methods from
NbFrame, so why not to open that functionality.

It, of course, would suppose removing deminimization from
findJFrameOrJInternalFrame(String, index) where I put it
simply because the method is private.

Still, most of the test developers have nothing to do
with minimized frame - they only use frames to find
something inside it.

So, having all this in mind, I see two possibilities:

1. 
  - Make both waitContainer and findJFrameOrJInternalFrame public. 
  - Move deminimization into NbFrame constructor.
  - Rename waitContainer to waitJFrameOrJInternalFrame. :)

It will allow you, Marian, to use NbFrame:
((JInternalFrame)NbFrame.waitJFrameOrJInternalFrame(...).getSource()).isIcon()

It won't affect other test developers.


2.
  - implement minimize/deminimize together with maximize/demaximize
    methods in NbFrame.

This way, test developer will only have to call deminimize() method
to turn a frame into the working state.

I'm comfortable with either approach. Jiri, you seemed to be 
objecting
against second. If you still object, I'll implement first.

Comment 18 Jiri Skrivanek 2002-11-01 08:23:07 UTC
From given arguments and examples second approach seems to me better.
I didn't want to add methods for minimizing/maximizing to
NbFrameOperator because I thought developer knows if it is JFrame or
JInternalFrame when he is going to minimize/maximize it. So, it seemed
to me as duplication of work.
Now I see Marian's test case where it is reasonable, so no objections
to implement it.
Comment 19 Alexandre Iline 2002-11-01 08:37:49 UTC
So be it! :)

Marian, in case you have any tescase where this won't work, share with
us! :)
Comment 20 Marian Mirilovic 2002-11-01 09:08:49 UTC
I agree with next solution:
- remove deminimalization from NbFrameOperator - constructor
- implement new methods in NbFrameOperator :
	void minimize()
	void restore()
	void maximize()
	boolean isMinimized()
	boolean isMaximized()

method restore() is wrapper for deminimize and demaximize depends on
frame status.
Comment 21 Alexandre Iline 2002-11-06 01:12:26 UTC
Fixed as proposed.

New methods: isMinimum(), isMaximum(), minimize(), maximize(),
normalize().

NOTE: maximize() and isMaximum() do not completely work for JFrame,
because there is no API to define if JFrame is maximazed or to
maximize it.

maximize() simply deiconifies JFrame if it was iconified.
isMaximum() returns true whenever frame is not iconified.
Comment 22 Marian Mirilovic 2002-11-07 09:24:58 UTC
verified