org.tltv.gantt.Gantt Java Examples

The following examples show how to use org.tltv.gantt.Gantt. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UriFragmentWrapperFactory.java    From gantt with Apache License 2.0 6 votes vote down vote up
/**
 * Wrap the given component into a component identified by the given uri
 * fragment.
 * <p>
 * 'tabsheet' wraps it to Tabsheet component.
 * <p>
 * Returns by default the component itself.
 *
 * @param uriragment
 * @param component
 * @return
 */
public static Component wrapByUriFragment(String uriragment, Gantt gantt) {
    if (uriragment == null) {
        return gantt;
    }
    if (uriragment.contains("tabsheet")) {
        TabSheet tabsheet = new TabSheet();
        tabsheet.setSizeFull();
        Tab tab = tabsheet.addTab(gantt);
        tab.setCaption("Tabsheet test");
        return tabsheet;

    } else if (uriragment.startsWith("grid")) {
        return new GridGanttLayout(gantt);

    } else if (uriragment.startsWith("treegrid")) {
        return new TreeGridGanttLayout(gantt);
    }

    return gantt;
}
 
Example #2
Source File: AbstractGhantChartManagerImpl.java    From cia with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the gantt.
 *
 * @return the gantt
 */
private static final Gantt createGantt() {
	final Gantt gantt = new Gantt();
	gantt.setSizeFull();
	gantt.setWidth(100, Unit.PERCENTAGE);
	gantt.setHeight(100, Unit.PERCENTAGE);
	gantt.setResizableSteps(false);
	gantt.setMovableSteps(false);
	gantt.setResolution(Resolution.Week);
	return gantt;
}
 
Example #3
Source File: GridGanttLayout.java    From gantt with Apache License 2.0 5 votes vote down vote up
public GridGanttLayout(Gantt gantt) {
    this.gantt = gantt;

    setSizeFull();
    setMargin(false);
    setSpacing(false);

    UI.getCurrent().getPage().getStyles().add(".v-grid tr th, .v-grid tr td { height: 37px; }");

    ganttGrid = createGridForGantt();

    addComponent(ganttGrid);
    addComponent(gantt);
    setExpandRatio(gantt, 1);
}
 
Example #4
Source File: TreeGridGanttLayout.java    From gantt with Apache License 2.0 5 votes vote down vote up
public TreeGridGanttLayout(Gantt gantt) {
    this.gantt = gantt;

    setSizeFull();
    setMargin(false);
    setSpacing(false);

    UI.getCurrent().getPage().getStyles().add(".v-treegrid tr th, .v-treegrid tr td { height: 37px; }");

    ganttTreeGrid = createGridForGantt();

    addComponent(ganttTreeGrid);
    addComponent(gantt);
    setExpandRatio(gantt, 1);
}
 
Example #5
Source File: DemoUI.java    From gantt with Apache License 2.0 5 votes vote down vote up
private TimeZone getDefaultTimeZone() {
    if (defaultTimeZone != null) {
        return defaultTimeZone;
    }
    TimeZone tz = TimeZone.getDefault();
    if (Gantt.getSupportedTimeZoneIDs().contains(tz.getID())) {
        defaultTimeZone = tz;
    } else {
        defaultTimeZone = TimeZone.getTimeZone("Europe/Helsinki");
    }
    return defaultTimeZone;
}
 
Example #6
Source File: AbstractGhantChartManagerImpl.java    From cia with Apache License 2.0 4 votes vote down vote up
/**
 * Creates the role ghant.
 *
 * @param roleSummaryLayoutTabsheet the role summary layout tabsheet
 * @param assignmentList            the assignment list
 */
public final void createRoleGhant(final AbstractOrderedLayout roleSummaryLayoutTabsheet, final Collection<T> assignmentList) {

	final Comparator<T> compare = getComparator();

	final List<T> list = assignmentList.stream().filter(
			(final T x) -> new DateTime(getStepMapping().getFromDate(x).getTime()).getYear() > FILTER_DATA_BEFORE_YEAR)
			.collect(Collectors.toList());

	Collections.sort(list, compare);

	final Gantt createGantt = createGenericGantt(list, getRoleMapping(), getStepMapping());
	roleSummaryLayoutTabsheet.addComponent(createGantt);
	roleSummaryLayoutTabsheet.setExpandRatio(createGantt, ContentRatio.GRID);

}
 
Example #7
Source File: StorageAdminPanel.java    From sensorhub with Mozilla Public License 2.0 4 votes vote down vote up
protected Gantt buildGantt(IRecordStorageModule<?> storage, IRecordStoreInfo recordInfo)
{
    double[] timeRange = storage.getRecordsTimeRange(recordInfo.getName());
    timeRange[0] -= 3600;
    timeRange[1] += 3600;
    
    Gantt gantt = new Gantt();
    gantt.setWidth(100, Unit.PERCENTAGE);
    gantt.setHeight(130, Unit.PIXELS);
    gantt.setResizableSteps(false);
    gantt.setMovableSteps(false);
    gantt.setStartDate(new Date((long)(timeRange[0]*1000)));
    gantt.setEndDate(new Date((long)(timeRange[1]*1000)));        
    gantt.setYearsVisible(false);
    gantt.setTimelineMonthFormat("MMMM yyyy");
    gantt.setResolution(Resolution.Hour);
    
    Step dataTimeRange = new Step(getPrettyName(recordInfo.getRecordDescription()));
    dataTimeRange.setBackgroundColor("FFFFFF");
    dataTimeRange.setStartDate((long)(timeRange[0]*1000));
    dataTimeRange.setEndDate((long)(timeRange[1]*1000));
            
    // add periods when data is actually available
    Iterator<double[]> clusterTimes = storage.getRecordsTimeClusters(recordInfo.getName());
    while (clusterTimes.hasNext())
    {
        timeRange = clusterTimes.next();
        SubStep clusterPeriod = new SubStep();
        clusterPeriod.setStartDate((long)(timeRange[0]*1000));
        clusterPeriod.setEndDate((long)(timeRange[1]*1000));
        dataTimeRange.addSubStep(clusterPeriod);
        
        clusterPeriod.setDescription(
                new DateTimeFormat().formatIso(timeRange[0], 0) + " / " +
                new DateTimeFormat().formatIso(timeRange[1], 0)
        );
    }        
    
    gantt.addStep(dataTimeRange);
    
    gantt.addClickListener(new Gantt.ClickListener() {
        private static final long serialVersionUID = 1L;
        public void onGanttClick(org.tltv.gantt.Gantt.ClickEvent event) {
            System.out.println("click");
        }
    });
    
    return gantt;
}
 
Example #8
Source File: DemoUI.java    From gantt with Apache License 2.0 4 votes vote down vote up
private Panel createControls() {
    Panel panel = new Panel();
    panel.setWidth(100, Unit.PERCENTAGE);

    controls = new HorizontalLayout();
    controls.setSpacing(true);
    controls.setMargin(true);
    panel.setContent(controls);

    subControls = new HorizontalLayout();
    subControls.setSpacing(true);
    subControls.setVisible(false);

    start = createStartDateField();
    end = createEndDateField();

    Button createStep = new Button("Create New Step...", createStepClickListener);

    HorizontalLayout heightAndUnit = new HorizontalLayout(Util.createHeightEditor(gantt),
            Util.createHeightUnitEditor(gantt));

    HorizontalLayout widthAndUnit = new HorizontalLayout(Util.createWidthEditor(gantt),
            Util.createWidthUnitEditor(gantt));

    reso = new NativeSelect<Resolution>("Resolution");
    reso.setEmptySelectionAllowed(false);
    reso.setItems(org.tltv.gantt.client.shared.Resolution.Hour, org.tltv.gantt.client.shared.Resolution.Day,
            org.tltv.gantt.client.shared.Resolution.Week);
    reso.setValue(gantt.getResolution());
    resolutionValueChangeRegistration = Optional.of(reso.addValueChangeListener(resolutionValueChangeListener));

    localeSelect = new NativeSelect<Locale>("Locale") {
        @Override
        public void attach() {
            super.attach();

            if (getValue() == null) {
                // use default locale
                setValue(gantt.getLocale());
                addValueChangeListener(localeValueChangeListener);
            }
        }
    };
    localeSelect.setEmptySelectionAllowed(false);
    localeSelect.setItems(Locale.getAvailableLocales());
    localeSelect.setItemCaptionGenerator((l) -> l.getDisplayName(getLocale()));

    ComboBox<String> timezoneSelect = new ComboBox<String>("Timezone");
    timezoneSelect.setWidth(300, Unit.PIXELS);
    timezoneSelect.setEmptySelectionAllowed(false);
    timezoneSelect.setItemCaptionGenerator(new ItemCaptionGenerator<String>() {

        @Override
        public String apply(String item) {
            if ("Default".equals(item)) {
                return "Default (" + getDefaultTimeZone().getDisplayName() + ")";
            }
            TimeZone tz = TimeZone.getTimeZone(item);
            return tz.getID() + " (raw offset " + (tz.getRawOffset() / 60000) + "m)";
        }
    });
    List<String> items = new ArrayList<>();
    items.add("Default");
    items.addAll(Gantt.getSupportedTimeZoneIDs());
    timezoneSelect.setItems((caption, fltr) -> caption.contains(fltr), items);
    timezoneSelect.setValue("Default");
    timezoneSelect.addValueChangeListener(timezoneValueChangeListener);

    final Button toggleSubControlsBtn = new Button("Show More Settings...");
    toggleSubControlsBtn.addStyleName("link");
    toggleSubControlsBtn.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            subControls.setVisible(!subControls.isVisible());
            toggleSubControlsBtn.setCaption(subControls.isVisible() ? "Less Settings..." : "More Settings...");
        }
    });

    controls.addComponent(start);
    controls.addComponent(end);
    controls.addComponent(reso);
    controls.addComponent(subControls);
    controls.addComponent(toggleSubControlsBtn);
    controls.setComponentAlignment(toggleSubControlsBtn, Alignment.BOTTOM_CENTER);

    subControls.addComponent(localeSelect);
    subControls.addComponent(timezoneSelect);
    subControls.addComponent(heightAndUnit);
    subControls.addComponent(widthAndUnit);
    subControls.addComponent(createStep);
    subControls.setComponentAlignment(createStep, Alignment.MIDDLE_LEFT);

    return panel;
}
 
Example #9
Source File: AbstractGhantChartManagerImpl.java    From cia with Apache License 2.0 3 votes vote down vote up
/**
 * Creates the generic gantt.
 *
 * @param assignmentList
 *            the assignment list
 * @param roleMapping
 *            the role mapping
 * @param stepMapping
 *            the step mapping
 * @return the gantt
 */
private Gantt createGenericGantt(final List<T> assignmentList, final Function<T, String> roleMapping,
		final StepMapping<T> stepMapping) {

	final Map<String, List<T>> assignmentListMap = assignmentList.stream()
			.collect(Collectors.groupingBy(roleMapping, TreeMap::new, Collectors.toList()));

	final Gantt gantt = createGantt();

	if (!assignmentList.isEmpty()) {

		gantt.setStartDate(stepMapping.getFromDate(assignmentList.get(0)));
		gantt.setEndDate(
				stripDatesAfterCurrentDate(stepMapping.getToDate(assignmentList.get(assignmentList.size() - 1))));

		for (final Entry<String, List<T>> entry : entriesSortedByValues(assignmentListMap, stepMapping)) {

			final String stepName = entry.getKey();

			final Step step = new Step(stepName,CaptionMode.HTML);
			step.setDescription(stepName);

			final List<T> assignments = entry.getValue();

			Collections.sort(assignments, getComparator());

			addViewGenericRoleMemberToStep(stepName, step, assignments, stepMapping);

			gantt.addStep(step);
		}
	}

	return gantt;
}