Example usage for org.joda.time.format DateTimeFormatter print

List of usage examples for org.joda.time.format DateTimeFormatter print

Introduction

In this page you can find the example usage for org.joda.time.format DateTimeFormatter print.

Prototype

public String print(ReadablePartial partial) 

Source Link

Document

Prints a ReadablePartial to a new String.

Usage

From source file:org.jasig.portlet.calendar.mvc.CalendarDisplayEvent.java

License:Apache License

/**
 * Constructs an object from specified data.
 *
 * @param event "Raw" Event object//from   www.  jav a 2s.  c om
 * @param eventInterval Interval portion of the event that applies to this specific day
 * @param theSpecificDay Interval of the specific day in question
 * @param df date formatter to represent date displays
 * @param tf time formatter to represent time displays
 */
public CalendarDisplayEvent(VEvent event, Interval eventInterval, Interval theSpecificDay, DateTimeFormatter df,
        DateTimeFormatter tf) {
    assert theSpecificDay.abuts(eventInterval)
            || theSpecificDay.overlaps(eventInterval) : "Event interval is not in the specified day!";

    this.summary = event.getSummary() != null ? event.getSummary().getValue() : null;
    this.description = event.getDescription() != null ? event.getDescription().getValue() : null;
    this.location = event.getLocation() != null ? event.getLocation().getValue() : null;

    boolean multi = false;
    if (eventInterval.getStart().isBefore(theSpecificDay.getStart())) {
        dayStart = theSpecificDay.getStart();
        multi = true;
    } else {
        dayStart = eventInterval.getStart();
    }

    if (event.getEndDate() == null) {
        dayEnd = dayStart;
    } else if (eventInterval.getEnd().isAfter(theSpecificDay.getEnd())) {
        dayEnd = theSpecificDay.getEnd();
        multi = true;
    } else {
        dayEnd = eventInterval.getEnd();
    }
    this.isMultiDay = multi;

    this.dateStartTime = tf.print(dayStart);
    this.startTime = tf.print(eventInterval.getStart());
    this.startDate = df.print(eventInterval.getStart());

    if (event.getEndDate() != null) {
        this.dateEndTime = tf.print(dayEnd);
        this.endTime = tf.print(eventInterval.getEnd());
        this.endDate = df.print(eventInterval.getEnd());
    } else {
        this.dateEndTime = null;
        this.endTime = null;
        this.endDate = null;
    }

    Interval dayEventInterval = new Interval(dayStart, dayEnd);
    this.isAllDay = dayEventInterval.equals(theSpecificDay);

}

From source file:org.jasig.portlet.calendar.mvc.controller.AjaxCalendarController.java

License:Apache License

@ResourceMapping
public ModelAndView getEventList(ResourceRequest request, ResourceResponse response) throws Exception {

    // Pull parameters out of the resourceId
    final String resourceId = request.getResourceID();
    final String[] resourceIdTokens = resourceId.split("-");
    final String startDate = resourceIdTokens[0];
    final int days = Integer.parseInt(resourceIdTokens[1]);

    final long startTime = System.currentTimeMillis();
    final List<String> errors = new ArrayList<String>();
    final Map<String, Object> model = new HashMap<String, Object>();
    final PortletSession session = request.getPortletSession();
    // get the user's configured time zone
    final String timezone = (String) session.getAttribute("timezone");
    final DateTimeZone tz = DateTimeZone.forID(timezone);

    // get the period for this request
    final Interval interval = DateUtil.getInterval(startDate, days, request);

    final Set<CalendarDisplayEvent> calendarEvents = helper.getEventList(errors, interval, request);

    int index = 0;
    final Set<JsonCalendarEventWrapper> events = new TreeSet<JsonCalendarEventWrapper>();
    for (CalendarDisplayEvent e : calendarEvents) {
        events.add(new JsonCalendarEventWrapper(e, index++));
    }/*from   w w  w .  j a  v a 2s.  c o  m*/

    /*
     * Transform the event set into a map keyed by day.  This code is
     * designed to separate events by day according to the user's configured
     * time zone.  This ensures that we keep complicated time-zone handling
     * logic out of the JavaScript.
     *
     * Events are keyed by a string uniquely representing the date that is
     * still orderable.  So that we can display a more user-friendly date
     * name, we also create a map representing date display names for each
     * date keyed in this response.
     */

    // define a DateFormat object that uniquely identifies dates in a way
    // that can easily be ordered
    DateTimeFormatter orderableDf = new DateTimeFormatterBuilder().appendPattern("yyyy-MM-dd").toFormatter()
            .withZone(tz);

    // define a DateFormat object that can produce user-facing display
    // as user-facing get it from i18N
    final String displayPattern = this.applicationContext.getMessage("date.formatter.display", null,
            "EEE MMM d", request.getLocale());
    // names for dates
    DateTimeFormatter displayDf = new DateTimeFormatterBuilder().appendPattern(displayPattern).toFormatter()
            .withZone(tz);

    // define "today" and "tomorrow" so we can display these specially in the user interface
    DateMidnight now = new DateMidnight(tz);
    String today = orderableDf.print(now);
    String tomorrow = orderableDf.print(now.plusDays(1));

    Map<String, String> dateDisplayNames = new HashMap<String, String>();
    Map<String, List<JsonCalendarEventWrapper>> eventsByDay = new LinkedHashMap<String, List<JsonCalendarEventWrapper>>();
    for (JsonCalendarEventWrapper event : events) {
        String day = orderableDf.print(event.getEvent().getDayStart());

        // if we haven't seen this day before, add entries to the event and date name maps
        if (!eventsByDay.containsKey(day)) {

            // add a list for this day to the eventsByDay map
            eventsByDay.put(day, new ArrayList<JsonCalendarEventWrapper>());

            // Add an appropriate day name for this date to the date names map.
            // If the day appears to be today or tomorrow display a special string value.
            // Otherwise, use the user-facing date format object.
            if (today.equals(day)) {
                dateDisplayNames.put(day,
                        applicationContext.getMessage("today", null, "Today", request.getLocale()));
            } else if (tomorrow.equals(day)) {
                dateDisplayNames.put(day,
                        this.applicationContext.getMessage("tomorrow", null, "Tomorrow", request.getLocale()));
            } else {
                dateDisplayNames.put(day, displayDf.print(event.getEvent().getDayStart()));
            }
        }

        // add the event to the by-day map
        eventsByDay.get(day).add(event);
    }

    log.trace("Prepared the following eventsByDay collection for user {}: {}", request.getRemoteUser(),
            eventsByDay);

    model.put("dateMap", eventsByDay);
    model.put("dateNames", dateDisplayNames);
    model.put("viewName", "jsonView");
    model.put("errors", errors);

    // eTag processing, see https://wiki.jasig.org/display/UPM41/Portlet+Caching
    String etag = String.valueOf(model.hashCode());
    String requestEtag = request.getETag();
    // if the request ETag matches the hash for this response, send back
    // an empty response indicating that cached content should be used
    if (etag.equals(requestEtag)) {
        log.debug("Sending an empty response (due to matched ETag {} for user {})'", requestEtag,
                request.getRemoteUser());

        // Must communicate new expiration time > 0 per Portlet Spec 22.2
        response.getCacheControl().setExpirationTime(1);
        response.getCacheControl().setUseCachedContent(true); // Portal will return cached content or HTTP 304
        // Return null so response is not committed before portal decides to return HTTP 304 or cached response.
        return null;
    }

    log.trace("Sending a full response for user {}", request.getRemoteUser());

    // create new content with new validation tag
    response.getCacheControl().setETag(etag);
    // Must have expiration time > 0 to use response.getCacheControl().setUseCachedContent(true)
    response.getCacheControl().setExpirationTime(1);

    long overallTime = System.currentTimeMillis() - startTime;
    log.debug("AjaxCalendarController took {} ms to produce JSON model", overallTime);

    return new ModelAndView("json", model);
}

From source file:org.jasig.portlet.conference.program.dao.ConferenceSessionDao.java

License:Apache License

@Scheduled(fixedRate = 900000)
protected void retrieveProgram() {
    log.debug("Requesting program data from " + this.programUrl);
    final ConferenceProgram program = restTemplate.getForObject(programUrl, ConferenceProgram.class,
            Collections.<String, String>emptyMap());

    if (program != null) {
        cache.put(new Element(PROGRAM_CACHE_KEY, program));

        final List<String> tracks = new ArrayList<String>();
        final List<String> types = new ArrayList<String>();
        final List<String> levels = new ArrayList<String>();
        final List<DateMidnight> dates = new ArrayList<DateMidnight>();

        final DateTimeFormatter providedDF = new DateTimeFormatterBuilder().appendPattern("dd-MMM-yyyy")
                .toFormatter();/*  w ww. j a v a  2 s.  com*/
        final DateTimeFormatter displayDF = new DateTimeFormatterBuilder().appendPattern("EEE MMMM d")
                .toFormatter();
        for (final ConferenceSession session : getProgram().getSessions()) {
            final String track = session.getTrack();
            if (shouldAddToList(track, tracks)) {
                tracks.add(track);
            }

            final String type = session.getType();
            if (shouldAddToList(type, types)) {
                types.add(type);
            }

            final String level = session.getLevel();
            if (shouldAddToList(level, levels)) {
                levels.add(level);
            }

            final String value = session.getDate();
            final DateMidnight date = providedDF.parseDateTime(value).toDateMidnight();
            if (!dates.contains(date)) {
                dates.add(date);
            }

        }
        Collections.sort(tracks);
        Collections.sort(levels);
        Collections.sort(types);

        Collections.sort(dates);
        LinkedHashMap<String, String> dateMap = new LinkedHashMap<String, String>();
        for (DateMidnight date : dates) {
            dateMap.put(providedDF.print(date), displayDF.print(date));
        }

        cache.put(new Element(PROGRAM_CACHE_KEY, program));
        cache.put(new Element(TRACK_LIST_KEY, tracks));
        cache.put(new Element(LEVEL_LIST_KEY, levels));
        cache.put(new Element(TYPE_LIST_KEY, types));
        cache.put(new Element(DATE_MAP_KEY, dateMap));

    }

}

From source file:org.jevis.commons.json.JsonFactory.java

License:Open Source License

public static JsonAttribute buildAttribute(JEVisAttribute att, boolean allSamples) throws JEVisException {
    JsonAttribute json = new JsonAttribute();
    DateTimeFormatter fmt = ISODateTimeFormat.dateTime();

    json.setName(att.getName());//  w  w w.  j  a  va 2  s.  c  o m
    if (att.hasSample()) {
        json.setFirstTS(fmt.print(att.getTimestampFromFirstSample()));
        json.setLastTS(fmt.print(att.getTimestampFromLastSample()));
        json.setLastvalue(att.getLatestSample().getValueAsString());

        if (allSamples) {
            json.setSamples(new ArrayList<JsonSample>());

            for (JEVisSample samp : att.getAllSamples()) {
                json.getSamples().add(JsonFactory.buildSample(samp));
            }

        }

    }
    json.setSamplecount(att.getSampleCount());
    json.setPeriod("P15m");
    json.setObject(att.getObject().getID());

    return json;

}

From source file:org.jevis.commons.json.JsonFactory.java

License:Open Source License

public static JsonSample buildSample(JEVisSample sample) throws JEVisException {
    JsonSample json = new JsonSample();
    DateTimeFormatter fmt = ISODateTimeFormat.dateTime();
    json.setTs(fmt.print(sample.getTimestamp()));
    json.setValue(sample.getValue().toString());
    json.setNote(sample.getNote());/* ww  w .  j  a v a2  s .c o m*/
    return json;
}

From source file:org.jevis.jealarm.AlarmHandler.java

License:Open Source License

/**
 * Checks the Data Objects for alarms and send an email.
 *
 * @param alarm//  ww  w .  j a va 2  s.c o  m
 * @throws JEVisException
 */
public void checkAlarm(Alarm alarm) throws JEVisException {
    List<JEVisObject> outOfBount = new ArrayList<>();
    List<JEVisObject> dps = getDataPoints(alarm);

    DateTime now = new DateTime();
    DateTime ignoreTS = now.minus(Period.hours(alarm.getIgnoreOld()));
    DateTime limit = now.minus(Period.hours(alarm.getTimeLimit()));

    for (JEVisObject obj : dps) {
        JEVisSample lsample = obj.getAttribute("Value").getLatestSample();
        if (lsample != null) {
            if (lsample.getTimestamp().isBefore(limit) && lsample.getTimestamp().isAfter(ignoreTS)) {
                outOfBount.add(obj);
            }
        }
    }
    DateTimeFormatter dtf = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm");
    StringBuilder sb = new StringBuilder();

    sb.append("<html>");
    sb.append(alarm.getGreeting());
    sb.append(",");
    sb.append("<br>");
    sb.append("<br>");
    sb.append(alarm.getMessage());
    sb.append("<br>");
    sb.append("<br>");

    String tabelCSS = "background-color:#FFF;" + "text-color: #024457;" + "outer-border: 1px solid #167F92;"
            + "empty-cells:show;" + "border-collapse:collapse;"
            //                + "border: 2px solid #D9E4E6;"
            + "cell-border: 1px solid #D9E4E6";

    String headerCSS = "background-color: #1a719c;" + "color: #FFF;";

    String rowCss = "text-color: #024457;padding: 5px;";//"border: 1px solid #D9E4E6;"

    String highlight = "background-color: #EAF3F3";

    sb.append("<table style=\"" + tabelCSS + "\" border=\"1\" >"); //border=\"0\"
    sb.append("<tr style=\"" + headerCSS + "\" >" + "    <th>Organisation</th>" + "    <th>Building</th>"
            + "    <th>Directory</th>" + "    <th>Datapoint</th>" + "    <th>Last Value</th>" + "  </tr>");

    JEVisClass orga = _ds.getJEVisClass("Organization");
    JEVisClass building = _ds.getJEVisClass("Monitored Object");
    JEVisClass dir = _ds.getJEVisClass("Data Directory");

    boolean odd = false;
    for (JEVisObject probelObj : outOfBount) {
        String css = rowCss;
        if (odd) {
            css += highlight;
        }
        odd = !odd;

        sb.append("<tr>");// style=\"border: 1px solid #D9E4E6;\">");

        sb.append("<td style=\"");
        sb.append(css);
        sb.append("\">");
        sb.append(getParentName(probelObj, orga));
        sb.append("</td>");

        sb.append("<td style=\"");
        sb.append(css);
        sb.append("\">");
        sb.append(getParentName(probelObj, building));
        sb.append("</td>");

        sb.append("<td style=\"");
        sb.append(css);
        sb.append("\">");
        sb.append(getParentName(probelObj, dir));
        sb.append("</td>");

        sb.append("<td style=\"");
        sb.append(css);
        sb.append("\">");
        sb.append(probelObj.getName());
        sb.append("</td>");

        //Last Sample
        //TODO: the fetch the sample again everytime is bad for the performace, store the sample somewhere
        sb.append("<td style=\"");
        sb.append(css);
        sb.append("\">");
        sb.append(dtf.print(probelObj.getAttribute("Value").getLatestSample().getTimestamp()));
        sb.append("</td>");

        sb.append("</tr>");
    }

    sb.append("</tr>");
    sb.append("</tr>");
    sb.append("</table>");
    sb.append("<br>");
    sb.append(_conf.getSmtpSignatur());
    sb.append("</html>");

    if (outOfBount.isEmpty() && alarm.isIgnoreFalse()) {
        //Do nothing then
    } else {
        sendAlarm(_conf, alarm, sb.toString());
    }

}

From source file:org.jevis.jeconfig.plugin.classes.ClassTree.java

License:Open Source License

public void fireEventExport(ObservableList<TreeItem<JEVisClass>> items) {

    FileChooser fileChooser = new FileChooser();
    fileChooser.setTitle("Save JEVisClasses to File");
    fileChooser.getExtensionFilters().addAll(new ExtensionFilter("JEVis Files", "*.jev"),
            new ExtensionFilter("All Files", "*.*"));

    DateTime now = DateTime.now();/*from  w  w  w .j a v a 2s  . c o m*/
    DateTimeFormatter fmt = DateTimeFormat.forPattern("yyyyMMdd");
    if (items.size() > 1) {
        fileChooser.setInitialFileName("JEViClassExport_" + fmt.print(now) + ".jev");
    } else {
        try {
            fileChooser.setInitialFileName(items.get(0).getValue().getName() + "_" + fmt.print(now) + ".jev");
        } catch (JEVisException ex) {
            Logger.getLogger(ClassTree.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    File selectedFile = fileChooser.showSaveDialog(JEConfig.getStage());
    if (selectedFile != null) {
        List<JEVisClass> classes = new ArrayList<>();
        for (TreeItem<JEVisClass> item : items) {
            classes.add(item.getValue());
        }

        String extension = FilenameUtils.getExtension(selectedFile.getName());
        if (extension.isEmpty()) {
            selectedFile = new File(selectedFile.getAbsoluteFile() + ".jsv");
        }

        ClassExporter ce = new ClassExporter(selectedFile, classes);
        //            mainStage.display(selectedFile);
    }
}

From source file:org.jevis.jeconfig.sample.AttributeStatesExtension.java

License:Open Source License

private XYChart buildChart(final List<JEVisSample> samples) {

    final NumberAxis xAxis = new NumberAxis();
    final NumberAxis yAxis = new NumberAxis();

    xAxis.setAutoRanging(false);/*from   w  w w.j  av a2s  . c  om*/
    yAxis.setAutoRanging(true);

    xAxis.setTickUnit(1);
    xAxis.setTickMarkVisible(true);
    xAxis.setTickLength(1);
    //        xAxis.setTickLabelFormatter(new StringConverter<Number>() {
    //
    //            @Override
    //            public String toString(Number t) {
    //
    //                DateTimeFormatter fmtDate = DateTimeFormat.forPattern("yyyy-MM-dd    HH:mm:ss");
    //                try {
    ////                    Number index = (t.doubleValue() - 1.5);
    //                    Number index = t.doubleValue();
    ////                    if (index.intValue() < 0) {
    ////                        index = 0;
    ////                    }
    ////                    if (index.intValue() > 100) {
    ////                        System.out.println(" is bigger 100");
    ////                    }
    //                    System.out.println("convert Major value: " + t.toString() + "=" + index);
    //                    return fmtDate.print(samples.get(index.intValue()).getTimestamp());
    ////                return fmtDate.print(new DateTime(t.longValue()));
    //                } catch (Exception ex) {
    //                    System.out.println("error");
    //                }
    //                return t.toString();
    //            }
    //
    //            @Override
    //            public Number fromString(String string) {
    //                System.out.println("from string: " + string);
    //                return 200;
    //            }
    //        });

    final DateTimeFormatter fmtDate = DateTimeFormat.forPattern("yyyy-MM-dd    HH:mm:ss");
    xAxis.setMinorTickCount(1);
    xAxis.setMinorTickLength(1);
    xAxis.setMinorTickVisible(true);
    xAxis.setTickLabelRotation(75d);
    xAxis.setTickLabelFormatter(new StringConverter<Number>() {

        @Override
        public String toString(Number t) {

            try {
                //                    System.out.println("number: " + t);
                //TODO: replace this DIRTY workaround. For this i will come in the DevHell
                //NOTE: the axis is % based, java 1.8 has an dateAxe use this if we migrate to it
                int index = samples.size() / 100 * t.intValue();
                return fmtDate.print(samples.get(index).getTimestamp());
                //                    return fmtDate.print(samples.get(t.intValue()).getTimestamp());
            } catch (Exception ex) {
                System.out.println("error: " + ex);
                return "";
            }

        }

        @Override
        public Number fromString(String string) {
            System.out.println("from string: " + string);
            return 200;
        }
    });

    //        xAxis.setLabel("Month");
    final LineChart<Number, Number> lineChart = new LineChart(xAxis, yAxis);
    //        final BarChart<String, Number> lineChart = new BarChart(xAxis, yAxis);

    String titel = String.format("");

    lineChart.setTitle(titel);
    //        lineChart.setAnimated(true);
    lineChart.setLegendVisible(false);
    lineChart.setCache(true);

    XYChart.Series series1 = new XYChart.Series();

    //        DateTimeFormatter fmttime = DateTimeFormat.forPattern("E HH:mm:ss");
    //        DateTimeFormatter fmttime2 = DateTimeFormat.forPattern("E HH:mm:ss");
    int pos = 0;

    for (JEVisSample sample : samples) {
        try {
            ////                String datelabel = "";
            ////                if (pos == 0 || samples.size() == pos || pos % 10 == 0) {
            ////                    datelabel = fmtDate.print(sample.getTimestamp());
            ////                }

            //                String datelabel = fmtDate.print(sample.getTimestamp());
            series1.getData().add(new XYChart.Data((Number) pos, sample.getValueAsDouble()));

            //                System.out.println("pos1: " + pos + " sample=" + sample);
            if (yAxis.getLowerBound() > sample.getValueAsDouble()) {
                yAxis.setLowerBound(sample.getValueAsDouble() * 0.9d);
            }

            pos++;
            //                series1.getData().add(new XYChart.Data(pos + "", sample.getValueAsDouble()));
        } catch (Exception ex) {
            Logger.getLogger(SampleEditor.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    yAxis.setLowerBound(10d);

    //        int size = 22 * samples.size();
    //        int size = 15 * samples.size();
    //        lineChart.setPrefWidth(size);
    lineChart.setPrefWidth(720);
    lineChart.getData().addAll(series1);

    return lineChart;
}

From source file:org.jevis.jeconfig.sample.SampleExportExtension.java

License:Open Source License

public void buildGUI(final JEVisAttribute attribute, final List<JEVisSample> samples) {
    _isBuild = true;/*from  ww w.j a  va 2  s .com*/
    TabPane tabPane = new TabPane();
    tabPane.setMaxWidth(2000);

    String sampleHeader = "";
    if (!samples.isEmpty()) {
        DateTimeFormatter dtfDateTime = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
        DateTimeFormatter timezone = DateTimeFormat.forPattern("z");
        try {
            sampleHeader = " " + dtfDateTime.print(samples.get(0).getTimestamp()) + " - "
                    + dtfDateTime.print(samples.get(samples.size() - 1).getTimestamp()) + " "
                    + timezone.print(samples.get(0).getTimestamp());
        } catch (JEVisException ex) {
            Logger.getLogger(SampleExportExtension.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    //        fHeader.setText(attribute.getObject().getName() + "[" + attribute.getObject().getID() + "] - " + attribute.getName());
    fHeader.setText(attribute.getObject().getName() + " " + attribute.getName() + " " + sampleHeader);

    _samples = samples;
    final ToggleGroup group = new ToggleGroup();

    bDateTime.setToggleGroup(group);
    bDateTime2.setToggleGroup(group);
    bDateTime.setSelected(true);

    fTimeFormate.setDisable(true);
    fDateFormat.setDisable(true);

    Button bValueFaormateHelp = new Button("?");

    HBox fielBox = new HBox(5d);
    HBox.setHgrow(fFile, Priority.ALWAYS);
    fFile.setPrefWidth(300);
    fielBox.getChildren().addAll(fFile, bFile);

    //        bFile.setStyle("-fx-background-color: #5db7de;");
    Label lFileOrder = new Label("Field Order:");

    fHeader.setPrefColumnCount(1);
    //        fHeader.setDisable(true);

    fTextArea.setPrefColumnCount(5);
    fTextArea.setPrefWidth(500d);
    fTextArea.setPrefHeight(110d);
    fTextArea.setStyle("-fx-font-size: 14;");

    GridPane gp = new GridPane();
    gp.setStyle("-fx-background-color: transparent;");
    gp.setPadding(new Insets(10));
    gp.setHgap(7);
    gp.setVgap(7);

    int y = 0;
    gp.add(lLineSep, 0, y);
    gp.add(fLineSep, 1, y);

    gp.add(lEnclosedBy, 0, ++y);
    gp.add(fEnclosedBy, 1, y);

    gp.add(lValueFormate, 0, ++y);
    gp.add(fValueFormat, 1, y);

    gp.add(new Separator(Orientation.HORIZONTAL), 0, ++y, 2, 1);

    gp.add(bDateTime, 0, ++y, 2, 1);
    gp.add(lDateTimeFormat, 0, ++y);
    gp.add(fDateTimeFormat, 1, y);

    gp.add(bDateTime2, 0, ++y, 2, 1);
    gp.add(lTimeFormate, 0, ++y);
    gp.add(fTimeFormate, 1, y);
    gp.add(lDateFormat, 0, ++y);
    gp.add(fDateFormat, 1, y);

    gp.add(new Separator(Orientation.HORIZONTAL), 0, ++y, 2, 1);

    //        gp.add(new Separator(Orientation.HORIZONTAL), 0, ++y, 2, 1);
    gp.add(lHeader, 0, ++y);
    gp.add(fHeader, 1, y);

    gp.add(lFileOrder, 0, ++y);
    gp.add(buildFildOrder(), 1, y);

    gp.add(lPFilePath, 0, ++y);
    gp.add(fielBox, 1, y);

    gp.add(lExample, 0, ++y, 2, 1);
    gp.add(fTextArea, 0, ++y, 2, 1);

    group.selectedToggleProperty().addListener(new ChangeListener<Toggle>() {
        @Override
        public void changed(ObservableValue<? extends Toggle> ov, Toggle old_toggle, Toggle new_toggle) {
            if (group.getSelectedToggle() != null) {
                dateChanged();
                updateOderField();
            }
        }
    });

    fEnclosedBy.setOnKeyReleased(new EventHandler<KeyEvent>() {

        @Override
        public void handle(KeyEvent t) {
            updatePreview();
        }
    });

    fLineSep.setOnKeyReleased(new EventHandler<KeyEvent>() {

        @Override
        public void handle(KeyEvent t) {
            updatePreview();
        }
    });

    fValueFormat.setOnKeyReleased(new EventHandler<KeyEvent>() {

        @Override
        public void handle(KeyEvent t) {
            System.out.println("key pressed");
            try {
                DateTimeFormat.forPattern(fDateTimeFormat.getText());
                updatePreview();
            } catch (Exception ex) {
                System.out.println("invalied Formate");
            }

        }
    });

    fDateTimeFormat.setOnKeyReleased(new EventHandler<KeyEvent>() {

        @Override
        public void handle(KeyEvent t) {
            System.out.println("update linesep");
            try {
                DateTimeFormat.forPattern(fDateTimeFormat.getText());
                updatePreview();
            } catch (Exception ex) {
                System.out.println("invalied Formate");
            }

        }
    });

    fDateFormat.setOnKeyReleased(new EventHandler<KeyEvent>() {

        @Override
        public void handle(KeyEvent t) {
            System.out.println("update linesep");
            try {
                DateTimeFormat.forPattern(fDateFormat.getText());
                updatePreview();
            } catch (Exception ex) {
                System.out.println("invalied Formate");
            }

        }
    });

    fTimeFormate.setOnKeyReleased(new EventHandler<KeyEvent>() {

        @Override
        public void handle(KeyEvent t) {
            System.out.println("update linesep");
            try {
                DateTimeFormat.forPattern(fTimeFormate.getText());
                updatePreview();
            } catch (Exception ex) {
                System.out.println("invalied Formate");

            }

        }
    });

    bFile.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent t) {
            FileChooser fileChooser = new FileChooser();
            fileChooser.setTitle("CSV File Destination");
            DateTimeFormatter fmtDate = DateTimeFormat.forPattern("yyyyMMdd");

            fileChooser.setInitialFileName(attribute.getObject().getName() + "_" + attribute.getName() + "_"
                    + fmtDate.print(new DateTime()) + ".csv");
            File file = fileChooser.showSaveDialog(JEConfig.getStage());
            if (file != null) {
                destinationFile = file;
                fFile.setText(file.toString());
            }
        }
    });

    //        export.setOnAction(new EventHandler<ActionEvent>() {
    //
    //            @Override
    //            public void handle(ActionEvent t) {
    //                writeFile(fFile.getText(), createCSVString(Integer.MAX_VALUE));
    //            }
    //        });
    fHeader.setOnKeyReleased(new EventHandler<KeyEvent>() {

        @Override
        public void handle(KeyEvent t) {
            updatePreview();
        }
    });

    updateOderField();
    updatePreview();

    ScrollPane scroll = new ScrollPane();
    scroll.setStyle("-fx-background-color: transparent");
    scroll.setMaxSize(10000, 10000);
    scroll.setContent(gp);
    //        _view.getChildren().setAll(scroll);
    _view.setCenter(scroll);
    //        return gp;
}