Hi Wim,
Thanks a lot. Turns out all I needed was just that one line. The application 
works like I want now.
I will be in touch if I have any more questions in the future.

Best regards,
Philip
    On Wednesday, 6 May 2020, 16:48:08 CEST, Wim Jongman 
<wim.jong...@gmail.com> wrote:  
 
 Philipe you have to set the minsize of the scrolledcomposite to a size that 
you want the squeeze to stop.
e.g.
ScrolledComposite.setMinsize(-1, timelineModel.getTracks().size() * 10)
try this:
import java.util.concurrent.TimeUnit;

import org.eclipse.nebula.widgets.timeline.ILane;
import org.eclipse.nebula.widgets.timeline.ITimeline;
import org.eclipse.nebula.widgets.timeline.ITrack;
import org.eclipse.nebula.widgets.timeline.TimelineDataBinding;
import org.eclipse.nebula.widgets.timeline.jface.TimelineViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class TimeLineApp {

 private static ITimeline fModel;

 public static void main(String[] args) {
 final Display display = new Display();
 final Shell shell = new Shell(display);
 shell.setText("Nebula Timeline");

 shell.setLayout(new GridLayout(1, false));

 final ScrolledComposite scrolledComposite = new ScrolledComposite(shell, 
SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
 scrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 
1, 1));
 scrolledComposite.setExpandHorizontal(true);
 scrolledComposite.setExpandVertical(true);

 final Control control = createControl(scrolledComposite);

 scrolledComposite.setContent(control);
 final int height = fModel.getTracks().size() * 50;
 scrolledComposite.setMinSize(-1, height);

 shell.open();

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

 public static Control createControl(Composite parent) {
 final TimelineViewer timelineViewer = new TimelineViewer(parent, SWT.NULL);
 fModel = (ITimeline) timelineViewer.getInput();
 new TimelineDataBinding(timelineViewer, fModel, 300);

 createRandomContent(fModel);

 timelineViewer.refresh();

 return timelineViewer.getControl();
 }

 private static void createRandomContent(ITimeline model) {

 final ITrack track1 = model.createTrack("Task 1");
 final ITrack track2 = model.createTrack("Task 2");
 final ITrack track3 = model.createTrack("Task 3");
 final ITrack track4 = model.createTrack("Task 4");
 final ITrack track5 = model.createTrack("Task 5");
 final ITrack track6 = model.createTrack("Task 6");

 final ILane taskLane1 = track1.createLane();
 final ILane taskLane2 = track2.createLane();
 final ILane taskLane3 = track3.createLane();
 final ILane taskLane4 = track4.createLane();
 final ILane taskLane5 = track5.createLane();
 final ILane taskLane6 = track6.createLane();

 int compTime = 5;
 int period = 5;
 int lastPosition = 0;
 for (int i = 0; i < 4; i++) {
 taskLane1.createEvent("", "task 1", lastPosition, compTime, 
TimeUnit.MICROSECONDS);
 lastPosition += period + compTime;
 }

 compTime = 2;
 period = 2;
 lastPosition = 0;
 for (int i = 0; i < 10; i++) {
 taskLane2.createEvent("", "task 2", lastPosition, compTime, 
TimeUnit.MICROSECONDS);
 lastPosition += period + compTime;
 }

 compTime = 2;
 period = 2;
 lastPosition = 0;
 for (int i = 0; i < 10; i++) {
 taskLane3.createEvent("", "task 3", lastPosition, compTime, 
TimeUnit.MICROSECONDS);
 lastPosition += period + compTime;
 }

 compTime = 2;
 period = 2;
 lastPosition = 0;
 for (int i = 0; i < 10; i++) {
 taskLane4.createEvent("", "task 4", lastPosition, compTime, 
TimeUnit.MICROSECONDS);
 lastPosition += period + compTime;
 }

 compTime = 2;
 period = 2;
 lastPosition = 0;
 for (int i = 0; i < 10; i++) {
 taskLane5.createEvent("", "task 5", lastPosition, compTime, 
TimeUnit.MICROSECONDS);
 lastPosition += period + compTime;
 }

 compTime = 2;
 period = 2;
 lastPosition = 0;
 for (int i = 0; i < 10; i++) {
 taskLane6.createEvent("", "task 6", lastPosition, compTime, 
TimeUnit.MICROSECONDS);
 lastPosition += period + compTime;
 }

 }

}



On Tue, May 5, 2020 at 8:42 PM Wim Jongman <wim.jong...@remainsoftware.com> 
wrote:


Hey Philip,

 

A snippet typically has a “main” method.

 

Cheers,

 

Wim

 

From: nebula-dev-boun...@eclipse.org <nebula-dev-boun...@eclipse.org>On Behalf 
Of philipcokon...@yahoo.com
Sent: dinsdag 5 mei 2020 17:13
To: Nebula Dev <nebula-dev@eclipse.org>; Laurent Caron <laurent.ca...@gmail.com>
Subject: Re: [nebula-dev] Nebula Timeline Widget Behaviour

 

Hi Laurent,

 

Thank you for the reply. Here is a snippet:

 

 

public Control createControl(Composite parent) {

TimelineViewer timelineViewer = new TimelineViewer(parent, SWT.NULL);

final ITimeline model = (ITimeline) timelineViewer.getInput();

new TimelineDataBinding(timelineViewer, model, 300);

 

createRandomContent(model);

 

return timelineViewer.getControl();

}

 

private void createRandomContent(ITimeline model) {

 

final ITrack track1 = model.createTrack("Task 1");

final ITrack track2 = model.createTrack("Task 2");

// final ITrack track3 = model.createTrack("Task 3");

// final ITrack track4 = model.createTrack("Task 4");

// final ITrack track5 = model.createTrack("Task 5");

// final ITrack track6 = model.createTrack("Task 6");

 

final ILane taskLane1 = track1.createLane();

final ILane taskLane2 = track2.createLane();

// final ILane taskLane3 = track3.createLane();

// final ILane taskLane4 = track4.createLane();

// final ILane taskLane5 = track5.createLane();

// final ILane taskLane6 = track6.createLane();

 

int compTime = 5;

int period = 5;

int lastPosition = 0;

for (int i = 0; i < 4; i++) {

taskLane1.createEvent("", "task 1", lastPosition, compTime, 
TimeUnit.MICROSECONDS);

lastPosition += period + compTime;

}

 

compTime = 2;

period = 2;

lastPosition = 0;

for (int i = 0; i < 10; i++) {

taskLane2.createEvent("", "task 2", lastPosition, compTime, 
TimeUnit.MICROSECONDS);

lastPosition += period + compTime;

}

 

// compTime = 2;

// period = 2;

// lastPosition = 0;

// for (int i = 0; i < 10; i++) {

// taskLane3.createEvent("", "task 3", lastPosition, compTime, 
TimeUnit.MICROSECONDS);

// lastPosition += period + compTime;

// }

//

// compTime = 2;

// period = 2;

// lastPosition = 0;

// for (int i = 0; i < 10; i++) {

// taskLane4.createEvent("", "task 4", lastPosition, compTime, 
TimeUnit.MICROSECONDS);

// lastPosition += period + compTime;

// }

//

// compTime = 2;

// period = 2;

// lastPosition = 0;

// for (int i = 0; i < 10; i++) {

// taskLane5.createEvent("", "task 5", lastPosition, compTime, 
TimeUnit.MICROSECONDS);

// lastPosition += period + compTime;

// }

//

// compTime = 2;

// period = 2;

// lastPosition = 0;

// for (int i = 0; i < 10; i++) {

// taskLane6.createEvent("", "task 6", lastPosition, compTime, 
TimeUnit.MICROSECONDS);

// lastPosition += period + compTime;

// }

 

}

 

I have attached two images to help you visualize what I am saying. The Timeline 
widget's parent is a ScrolledComposite. Using the code as is will result in 
this image:

 



 

But removing the comments will give this result:

 

 



What I want is for all the events in the second image to maintain the same 
thickness as in the first image and the to be able to scroll down the timeline 
if necessary to view the whole information.

 

Thank you.

 

Best regards,

 

Philip

 

On Tuesday, 5 May 2020, 15:28:31 CEST, Laurent Caron <laurent.ca...@gmail.com> 
wrote:

 

 

Hi Philip,

 

Can you post a little snippet so we can reproduce this behaviour ?

 

Thank you,

 

Laurent

 

Le mar. 5 mai 2020 à 08:40,philipcokon...@yahoo.com <philipcokon...@yahoo.com> 
a écrit :


Hi,

 

I am currently using the Nebula Timeline widget in an application that I have 
just started to work on. I am trying to make the widget scroll vertically when 
the height of the widget is too small to hold all the tracks and events I want 
to display. But I noticed that the default behaviour is to shrink and expand 
the heights of the events instead thus making them almost invisible or just 
reducing them to lines. 

 

Is there a way around this behaviour? How do I make the widget scroll 
vertically and set the height of the events to a constant value?

 

Thank you.

 

 

Best regards,

Philip

_______________________________________________
nebula-dev mailing list
nebula-dev@eclipse.org
To unsubscribe from this list, visit 
https://www.eclipse.org/mailman/listinfo/nebula-dev

_______________________________________________
nebula-dev mailing list
nebula-dev@eclipse.org
To unsubscribe from this list, visit 
https://www.eclipse.org/mailman/listinfo/nebula-dev

_______________________________________________
nebula-dev mailing list
nebula-dev@eclipse.org
To unsubscribe from this list, visit 
https://www.eclipse.org/mailman/listinfo/nebula-dev
  
_______________________________________________
nebula-dev mailing list
nebula-dev@eclipse.org
To unsubscribe from this list, visit 
https://www.eclipse.org/mailman/listinfo/nebula-dev

Reply via email to