View unanswered posts | View active topics It is currently Mon Feb 27, 2017 3:05 pm



Reply to topic  [ 4 posts ] 
 Behavior changes between two versions of Miglayout 
Author Message

Joined: Mon Jun 22, 2009 12:27 pm
Posts: 6
Post Behavior changes between two versions of Miglayout
Hello,

I am using MigLayout in Eclipse RCP context (SWT).
I am giving you a code example containing a text control with a MofifyListener which ask to compute the clientArea.
in 3.7.2, a horinzontal scrollbar appears when adding character to the text.
in 4.2 nothing appears.

Is it a bug or a desired behavior?

Code:
Code:
package org.adichatz.admin.test;
import net.miginfocom.swt.MigLayout;
import org.adichatz.engine.common.EngineConstants;
import org.adichatz.engine.data.GencodePath;
import org.adichatz.generator.common.FileUtil;
import org.eclipse.jface.window.ApplicationWindow;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.ManagedForm;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.eclipse.ui.forms.widgets.SharedScrolledComposite;

public class TestWindow extends ApplicationWindow {

   private ScrolledForm form;

   public TestWindow() {
      super(null);
   }

   @Override
   protected Control createContents(Composite parent) {
      EngineConstants.WORKSPACE_DIRECTORY = "E:/YVES/MyWork/eclipse/workspace_3_7_2/adichatz";
      GencodePath gencodePath = new GencodePath(FileUtil.getPluginHome(EngineConstants.ENGINE_BUNDLE),
            EngineConstants.ENGINE_BUNDLE, EngineConstants.GENCODE_DIR, this.getClass().getClassLoader());
      // /new AdiPluginResources(pluginName, pluginName, gencodePath);
      new AdminPluginResources(EngineConstants.ENGINE_BUNDLE, EngineConstants.ENGINE_BUNDLE, gencodePath);

      final ManagedForm managedForm = new ManagedForm(parent);
      FormToolkit toolkit = new FormToolkit(parent.getDisplay());
      form = managedForm.getForm();
      form.setText("FormView.title"); //$NON-NLS-1$
      form.getBody().setLayout(new MigLayout("wrap 1", "grow,fill", "grow,fill"));

      final ScrolledComposite scrolledComposite = new SharedScrolledComposite(form.getBody(), SWT.NONE) {
      };
      scrolledComposite.setExpandVertical(true);
      scrolledComposite.setExpandHorizontal(true);
      toolkit.adapt(scrolledComposite);
      final Composite composite = toolkit.createComposite(scrolledComposite);
      composite.setLayout(new MigLayout("wrap 2", "[align right, fill]25[grow,fill]"));
      scrolledComposite.setContent(composite);

      toolkit.createLabel(composite, "Text");
      final Text text = toolkit.createText(composite, "My text to be completed...");
      text.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLUE));
      text.addModifyListener(new ModifyListener() {
         @Override
         public void modifyText(ModifyEvent e) {
            text.pack();
            form.reflow(true);
         }
      });
      return parent;
   }

   public static void main(String[] args) {
      TestWindow t = new TestWindow();
      t.setBlockOnOpen(true);
      t.open();
      Display.getCurrent().dispose();
   }

}



Best regards
Yves


Wed Nov 21, 2012 6:56 pm
Profile
Site Admin

Joined: Mon Dec 06, 2004 4:24 pm
Posts: 2485
Location: Sweden
Post Re: Behavior changes between two versions of Miglayout
Hello,

I'm not sure. I don't think I can compile a RPC app. At least I have never done it.

What do you think, is the 4.2 behavior correct?

Cheers,
Mikael


Wed Nov 21, 2012 9:12 pm
Profile WWW

Joined: Mon Jun 22, 2009 12:27 pm
Posts: 6
Post Re: Behavior changes between two versions of Miglayout
Hello,

Thanks for answering.
I must use "ScrolledForm" to show the matter.
A ScrolledForm extends ScrolledComposite with mechanisms to manage toolbar, scrollbar and message area.
The reflow(boolean flushCache) method on the ScrolledForm is a kind of layout() which computes the need of scrollbars.

So when I type a long text in the text control, width of the control changes.
- In 3.7.2 version of miglayout, composite.getClientArea() changes following the text control size. A scrollbar appears in the windows when client area is bigger than the window.
- In 4.2 composite.getClientArea() doesn't change.


You do not have to use RCP to test example. You need these jar files to be added to the build path:
- org.eclipse.swt_3.7.2.v3740f.jar
- org.eclipse.ui.forms_3.5.101.v20111011-1919.jar
- org.eclipse.swt.win32.win32.x86_3.7.2.v3740f.jar
- org.eclipse.jface_3.7.0.v20110928-1505.jar

I send you a simplified code example.
Code:
package org.adichatz.admin.test;

import net.miginfocom.swt.MigLayout;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.forms.widgets.ScrolledForm;

public class TestWindow {

   private ScrolledForm form;

   public TestWindow(Shell shell) {

      shell.setSize(250, 110);
      form = new ScrolledForm(shell, SWT.V_SCROLL | SWT.H_SCROLL);
      form.setExpandHorizontal(true);
      form.setExpandVertical(true);
      form.setLayout(new MigLayout("wrap, ins 0", "grow,fill", "grow,fill"));

      form.getBody().setLayout(new MigLayout());
      final Composite composite = new Composite(form.getBody(), SWT.NONE);
      composite.setLayout(new MigLayout("wrap 2", "[align right, fill]25[grow,fill]"));

      Label label = new Label(composite, SWT.NONE);
      label.setText("text:");
      final Text text = new Text(composite, SWT.BORDER);
      text.setText("My text to be completed...");
      text.addModifyListener(new ModifyListener() {
         @Override
         public void modifyText(ModifyEvent e) {
            text.pack();
            form.reflow(true);
         }
      });
      form.getForm().pack();
   }

   public static void main(String[] args) {
      Display display = new Display();
      Shell shell = new Shell(display);
      shell.setLayout(new FillLayout());
      new TestWindow(shell);
      shell.open();

      while (!shell.isDisposed()) {
         if (!display.readAndDispatch())
            display.sleep();
      }

      display.dispose();
   }

}

If you prefer, I can try to simulate ScrolledForm with only SWT controls, but it seems to be a verbose and hard matter.


Cheers
Yves


Thu Nov 22, 2012 10:22 pm
Profile
Site Admin

Joined: Mon Dec 06, 2004 4:24 pm
Posts: 2485
Location: Sweden
Post Re: Behavior changes between two versions of Miglayout
Ok, thanks. I have put this on the work queue for the next version.

Cheers,
Mikael


Thu Nov 22, 2012 10:49 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.