Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [nebula-dev] Nebula Timeline Widget Behaviour

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.jongman@xxxxxxxxxxxxxxxxxx> wrote:

Hey Philip,

 

A snippet typically has a “main” method.

 

Cheers,

 

Wim

 

From: nebula-dev-bounces@xxxxxxxxxxx <nebula-dev-bounces@xxxxxxxxxxx> On Behalf Of philipcokonkwo@xxxxxxxxx
Sent: dinsdag 5 mei 2020 17:13
To: Nebula Dev <nebula-dev@xxxxxxxxxxx>; Laurent Caron <laurent.caron@xxxxxxxxx>
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:

 

Inline image

 

But removing the comments will give this result:

 

 

Inline image

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.caron@xxxxxxxxx> 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, philipcokonkwo@xxxxxxxxx <philipcokonkwo@xxxxxxxxx> 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@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/nebula-dev

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

Back to the top