This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 124 - Pages: 9 [ Previous | 1 2 3 4 5 6 7 8 | Next ] - Last Post: 25-Jul-2015 21:51 Last Post By: ctwist Threads: [ Previous | Next ]
ctwist

Posts: 546
Registered: 27-Sep-2003
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 03-Jun-2015 14:20   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
davidekholm wrote:
See our Javadocs for the correct method to call, i.e. showOpenDialog
Yes, I am sure I could get this working, but Andre doesn't seem interested in switching to compiled Java, so I decided not to spend any more time on this approach.
AndreWolff

Posts: 1,775
Registered: 14-Dec-2007
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 03-Jun-2015 16:43   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
davidekholm wrote:
See our Javadocs for the correct method to call, i.e. showOpenDialog
This document stays:

showOpenDialog
int showOpenDialog(java.awt.Component parent)
Returns:
Same as JFileChooser show... methods

What extra information is given here?
To make it more usefull, coding examples should be given!

I still don't known whether the code is wrong, this information does not help me, but I know that the result of the code is as expected!
AndreWolff

Posts: 1,775
Registered: 14-Dec-2007
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 03-Jun-2015 16:51   in response to: ctwist in response to: ctwist
 
  Click to reply to this thread Reply
ctwist wrote:
Yes, I am sure I could get this working, but Andre doesn't seem interested in switching to compiled Java, so I decided not to spend any more time on this approach.
That is correct, but does that mean that this problem can't be solved with uncompiled code?

Then I hope that David will implement my request for an automatic conversion.
ctwist

Posts: 546
Registered: 27-Sep-2003
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 03-Jun-2015 17:48   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
AndreWolff wrote:
ctwist wrote:
Yes, I am sure I could get this working, but Andre doesn't seem interested in switching to compiled Java, so I decided not to spend any more time on this approach.
That is correct, but does that mean that this problem can't be solved with uncompiled code?
No, but it is more difficult to fix problems without the assistance of a compiler. I just don't want to spend more time on this; I have other more important things that I need to work on.
AndreWolff

Posts: 1,775
Registered: 14-Dec-2007
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 04-Jun-2015 00:03   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
davidekholm wrote:
ctwist wrote:
I have attached an updated Java zip file to my previous message.

Eclipse identified these problems. I have not fixed them:

int returnVal = fc.showOpenDialog(window);
if (returnVal != null)
The operator != is undefined for the argument type(s) int, null
</div>
 
As returnVal is an integer you cannot compare it with null. You probably want returnVal != 0
 
<div class="jive-quote">DirectoryChooser dc = ChooserFactory.createDirectoryChooser(window);
dc.showDialog(window, "Ok");
The method showDialog(JAlbumFrame, String) is undefined for the type DirectoryChooser

See our Javadocs for the correct method to call, i.e. showOpenDialog

If I use this code:
DirectoryChooser dc = ChooserFactory.createDirectoryChooser(window);
		dc.showOpenDialog(window, "Ok");
		if (dc.getSelectedFile() != null) {	
the browser button gives no response.

But I use this code:
DirectoryChooser dc = ChooserFactory.createDirectoryChooser(window);
		dc.showDialog(window, "Ok");
		if (dc.getSelectedFile() != null) {	
and that works as expected!

So I wonder where is showDialog documented? Is this documented in Class JFileChooser here?
Or is the showOpenDialog documentation wrong?

Edited by: AndreWolff on 04-Jun-2015 00:12
davidekholm

Posts: 3,312
Registered: 18-Oct-2002
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 04-Jun-2015 20:12   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
You should use
dc.showOpenDialog(window);
and it's documented in PathChooser.

You can figure that out by starting at the javadocs for ChooserFactory. Looking at ChooserFactory.createDirectoryChooser reveals that it returns a DirectoryChooser. Inspecting that interface reveals that it extends PathChooser , and there you have the methods you need to call.
AndreWolff

Posts: 1,775
Registered: 14-Dec-2007
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 05-Jun-2015 08:04   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
davidekholm wrote:
You should use
dc.showOpenDialog(window);
and it's documented in PathChooser.
I told you already that this does not work!!

But apparently you don't believe me. so to convince you I tested this code:
		window.messageBox("before ");
		dc.showOpenDialog(window, "Ok");
		window.messageBox("after ");
		if (dc.getSelectedFile() != null) {
	  		linkField.setText(IO.relativePath(dc.getSelectedFile(),myOutputdirectory));
	  		window.messageBox("myOutputdirectory: " + myOutputdirectory.toString());
		}

I see the first message "before", but not the other 2.

If I replace showOpenDialog by showDialog, I see al 3 messages!

You can check it yourself with the onload.bsh of the current version of the Slide Show 4 skin!
AndreWolff

Posts: 1,775
Registered: 14-Dec-2007
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 05-Jun-2015 08:29   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
Attachment onload.bsh (43,3 KB)
davidekholm wrote:
True. As the StateMonitor attaches to a component that's bound to the class itself, it should only be called initially. However, when you call .done() it calls onChange() which refers to your vAO variable, which hasn't been set up yet. To solve this, remove the .done() call and add a myStateMonitor.done(); or myStateMonitor.onChange() call inside setAlbumObject(). You naturally need to assign the StateMonitor to a reference variable that's bound to that class. Furthermore, you don't need that vAO variable as the base class keeps a reference to the current AlbumObject. It's called "currentAO" and is documented in the Javadocs for JCustomPanel

I tried this:
public class PanCustomUI extends JCustomPanel {
	JCheckBox SIVPanorama = new JCheckBox("Enlarge the image of this panorama picture");	
 
   StateMonitor myStateMonitor = new StateMonitor()
		{	public void onChange()
			{ if (currentAO != null)
				{	AlbumObjectProperties vProps = currentAO.getProperties();
					HashMap vUserVars = (HashMap)vProps.get("userVariables");
					if (SIVPanorama.isSelected())
					{	if (vUserVars == null)
						{	vUserVars = new HashMap();
						}
						vUserVars.put("maxImageWidth", new String("50000"));
					}
					else
					{	if (vUserVars != null)
						{	vUserVars.remove("maxImageWidth");
						}
					}
					if (vUserVars == null || vUserVars.isEmpty())
					{ vProps.remove("userVariables");
					}
					else
					{ vProps.put("userVariables", vUserVars);
					}
					vProps.save();
				}
			}
		}.add(SIVPanorama);
		
 public void setAlbumObject(AlbumObject ao) {
    super.setAlbumObject(ao);
    removeAll();
    
    if (ao != null) {
      File currentContextFile = ao.getFile();
      if (currentContextFile.isDirectory()) {
		add("br", new JLabel(texts.getString("ui.noPanoramaPossible")));
      }
      else {
		add(SIVPanorama);	
      }
    }
    loadUI();
    myStateMonitor.done();
  }
 
	public PanCustomUI(JAlbumContext context) {
		super(context);	
		// Subclasses like us should call init after components are initiated
		init();
	}	
}
// Install custom panel in Jalbum's edit panel
PanCustomUI customUI2 = new PanCustomUI(context);
editPanel.addCustomTab("Panorama", customUI2);

But this does not work: black screen if I select Edit for a picture.

The onload.bsh file is enclosed.
davidekholm

Posts: 3,312
Registered: 18-Oct-2002
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 05-Jun-2015 12:26   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
AndreWolff wrote:
davidekholm wrote:
You should use
dc.showOpenDialog(window);
and it's documented in PathChooser.
I told you already that this does not work!!

What error message do you get and what OS do you test on? I've tested it to work fine on both Windows and Mac. You need to remove the , "Ok" argument. showOpenDialog only takes the "window" argument. The other variant happens to work on Windows but is not guaranteed to work, and doesn't work on Mac.
davidekholm

Posts: 3,312
Registered: 18-Oct-2002
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 05-Jun-2015 12:31   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
AndreWolff wrote:

I tried this:
code
public class PanCustomUI extends JCustomPanel {
...

Please pass the whole zipped skin (.jaskin format). I get missing text resources when trying to load your onload.bsh
AndreWolff

Posts: 1,775
Registered: 14-Dec-2007
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 05-Jun-2015 12:35   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
davidekholm wrote:
Please pass the whole zipped skin (.jaskin format). I get missing text resources when trying to load your onload.bsh
See enclosed file
AndreWolff

Posts: 1,775
Registered: 14-Dec-2007
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 05-Jun-2015 12:38   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
davidekholm wrote:
What error message do you get and what OS do you test on? I've tested it to work fine on both Windows and Mac. You need to remove the , "Ok" argument. showOpenDialog only takes the "window" argument. The other variant happens to work on Windows but is not guaranteed to work, and doesn't work on Mac.
I got no error message and I work with Windows 8.1

But your are correct, if I remove the "Ok" argument, it works too with showOpenDialog .

Thanks for your help!
ctwist

Posts: 546
Registered: 27-Sep-2003
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 05-Jun-2015 12:39   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
David told you that showOpenDialog takes one parameter but you continue to provide two parameters. This is causing it to fail.

This is a prime example of why working with uncompiled code is a time waster. An error like this would be identified by the compiler before you start testing.

Edited by: ctwist on 05-Jun-2015 06:39
I see you just fixed this.
davidekholm

Posts: 3,312
Registered: 18-Oct-2002
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 05-Jun-2015 16:32   in response to: AndreWolff in response to: AndreWolff
 
  Click to reply to this thread Reply
AndreWolff wrote:
davidekholm wrote:
Please pass the whole zipped skin (.jaskin format). I get missing text resources when trying to load your onload.bsh
See enclosed file

Thanks. Now testing it. I see that it errors out on not finding currentAO, which should work as currentAO is a protected class member variable. It seems like BeanShell has problems with inner classes sometimes. I strongly recommend you to compile your onload code instead, then it will work properly and you will get better syntax checking. It will save you a lot of time.

I also strongly advice you to not modify the preferred size of the settings window. Use tabs and collapsible panels to make your UI fit within the standard size. Now the rest of jAlbum's settings window simply looks ugly and the settings window occupies so much space that one cannot play with settings and apply the settings to see the result update in the browser view next to it.
AndreWolff

Posts: 1,775
Registered: 14-Dec-2007
Re: How to set maxImageWidth and maxImageHeight in a Custom panel?
Posted: 05-Jun-2015 18:04   in response to: davidekholm in response to: davidekholm
 
  Click to reply to this thread Reply
davidekholm wrote:
I see that it errors out on not finding currentAO, which should work as currentAO is a protected class member variable. It seems like BeanShell has problems with inner classes sometimes.
If I replace currentAO by a declared variable which is loaded in setAlbumObject :
public class PanCustomUI extends JCustomPanel {
	JCheckBox SIVPanorama = new JCheckBox("Enlarge the image of this panorama picture");	
   AlbumObject vAO;
   StateMonitor myStateMonitor = new StateMonitor()
		{	public void onChange()
			{ if (vAO != null)
.
.
 public void setAlbumObject(AlbumObject ao) {
    super.setAlbumObject(ao);
    vAO = ao;
the black screen disappears and some slides are indeed enlarged, but not all. They stay enlarged if I clear the check-mark.
I strongly recommend you to compile your onload code
I have no time to do that in short term, because I go on holidays next week (to Sweden !!).
I hope that you implement in the mean time my feature request Enlarge panoramic pictures automatically, in which case this panorama panel is no longer required.
I also strongly advice you to not modify the preferred size of the settings window.
I am not aware that I do that! Where? What is the preferred size of the settings window?
the settings window occupies so much space that one cannot play with settings and apply the settings to see the result update in the browser view next to it.
I never use the internal browser, so I did not notice this. I have already tabs in a logical order. If you make there sub-tabs or panels it is more difficult for a user to get a survey of the possible settings.

You can solve this problem for all skins by bringing the internal browser window to the foreground if you click the Apply button in the settings window. Bring the settings window in that case again to the foreground if you click the Settings button in the lower left corner.

Anyhow thanks for your time and your help.

Edited by: AndreWolff on 05-Jun-2015 18:34
Legend
Forum admins
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums