Java Code Examples for com.google.gwt.i18n.client.DateTimeFormat

The following are top voted examples for showing how to use com.google.gwt.i18n.client.DateTimeFormat. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: EasyML   File: DBController.java   Source Code and License 6 votes vote down vote up
/**
 * Get dataset panel show values .
 * 
 * @param dataset
 * @param isUpdate
 * @return  Data panel show value array
 */
public static String[] getDatasetPanelValue(final Dataset dataset, boolean isUpdate) {
	String[] values = new String[7];
	Date dateNow = new Date();
	DateTimeFormat dateFormat = DateTimeFormat
			.getFormat("yyyy-MM-dd KK:mm:ss a");
	values[4] = dateFormat.format(dateNow);
	double version = 0;
	if ((!dataset.getVersion().contains("n"))&&isUpdate){
		version = Double.parseDouble(dataset.getVersion()) + 0.1;
	}else version = Double.parseDouble(dataset.getVersion());     
	values[3] = NumberFormat.
			getFormat("#0.0").format(version);

	values[1] = null;
	String TypeString = dataset.getContenttype();
	if ("General".equals(TypeString)) values[2] = "General/TSV/CSV";
	if ("TSV".equals(TypeString)) values[2] = "TSV/General/TSV";
	if ("CSV".equals(TypeString)) values[2] = "CSV/General/TSV";
	else values[2] = "General/TSV/CSV";
	values[0] = dataset.getName();
	values[5] = AppController.email;
	values[6] = dataset.getDescription();
	return values;
}
 
Example 2
Project: unitimes   File: PeriodPreferencesWidget.java   Source Code and License 6 votes vote down vote up
Cell(int day, int slot, Date date, PeriodInterface period) {
	super("cell", "item", isEditable() && period != null ? "clickable" : null, period == null ? "disabled" : null, period != null && iModel.isAssigned(period) ? "highlight" : null);
	iDay = day;
	iSlot = slot;
	iDate = date;
	iPeriod = period;
	if (period != null) {
		PreferenceInterface preference = iModel.getPreference(day, slot);
		if (preference == null) {
			getElement().getStyle().clearBackgroundColor();
			setHTML("");
			setTitle("");
		} else {
			getElement().getStyle().setBackgroundColor(preference.getColor());
			setTitle(DateTimeFormat.getFormat(CONSTANTS.examPeriodDateFormat()).format(date) + " " + slot2short(slot) + (period == null ? "" : " - " + slot2short(slot + period.getLength())) + ": " + preference.getName());
		}
		if (isEditable())
			addMouseDownHandler(new MouseDownHandler() {
				@Override
				public void onMouseDown(MouseDownEvent event) {
					setOption(iPreference);
				}
			});				
	}
}
 
Example 3
Project: unitimes   File: PeriodPreferencesWidget.java   Source Code and License 6 votes vote down vote up
private D(int day, int slot, Date date, PeriodInterface period) {
	super("cell", "day", isEditable() && period != null ? "clickable" : null, period == null ? "unavailable" : null);
	iDay = day;
	iSlot = slot;
	iDate = date;
	iPeriod = period;
	setText(DateTimeFormat.getFormat("d").format(date));
	if (period != null) {
		PreferenceInterface preference = iModel.getPreference(day, slot);
		if (preference == null) {
			getElement().getStyle().clearBackgroundColor();
			setTitle("");
		} else {
			getElement().getStyle().setBackgroundColor(preference.getColor());
			setTitle(DateTimeFormat.getFormat(CONSTANTS.examPeriodDateFormat()).format(date) + " " + slot2short(slot) + (period == null ? "" : " - " + slot2short(slot + period.getLength())) + ": " + preference.getName());
		}
		if (isEditable())
			addMouseDownHandler(new MouseDownHandler() {
				@Override
				public void onMouseDown(MouseDownEvent event) {
					setOption(iPreference);
				}
			});				
	}
}
 
Example 4
Project: unitimes   File: EventRoomAvailability.java   Source Code and License 6 votes vote down vote up
@Override
public SessionMonth.Flag getDateFlag(EventType type, Date date) {
	if (iSessionMonths == null || iSessionMonths.isEmpty()) return null;
	if (date == null) return null;
	int m = Integer.parseInt(DateTimeFormat.getFormat("MM").format(date));
	for (SessionMonth month: iSessionMonths)
		if (m == month.getMonth() + 1) {
			int d = Integer.parseInt(DateTimeFormat.getFormat("dd").format(date)) - 1;
			if (month.hasFlag(d, SessionMonth.Flag.FINALS) && type != EventType.FinalExam) return SessionMonth.Flag.FINALS;
			if (month.hasFlag(d, SessionMonth.Flag.BREAK)) return SessionMonth.Flag.BREAK;
			if (month.hasFlag(d, SessionMonth.Flag.WEEKEND)) return SessionMonth.Flag.WEEKEND;
			if (month.hasFlag(d, SessionMonth.Flag.HOLIDAY)) return SessionMonth.Flag.HOLIDAY;
			if (month.hasFlag(d, SessionMonth.Flag.MIDTERMS) && type != EventType.MidtermExam) return SessionMonth.Flag.MIDTERMS;
			return null;
		}
	return null;
}
 
Example 5
Project: document-management-system   File: ExtendedScrollTable.java   Source Code and License 6 votes vote down vote up
/**
 * Refresh message received row
 *
 * @param messageReceived
 */
private void refreshMessageReceivedRow(final GWTMessageReceived messageReceived, int row) {
	boolean seen = (messageReceived.getSeenDate() == null);

	// Sets folder object
	data.put(new Integer(dataTable.getHTML(row, 5)), messageReceived);
	dataTable.setHTML(row, 0, "");
	dataTable.setHTML(row, 1, UtilComunicator.getTextAsBoldHTML(messageReceived.getFrom(), seen));
	dataTable.setHTML(
			row,
			2,
			UtilComunicator.getTextAsBoldHTML(
					GeneralComunicator.i18nExtension("messaging.message.type.message.sent"), seen));
	DateTimeFormat dtf = DateTimeFormat.getFormat(GeneralComunicator.i18nExtension("general.date.pattern"));
	dataTable.setHTML(row, 3, UtilComunicator.getTextAsBoldHTML(dtf.format(messageReceived.getSentDate()), seen));
	dataTable.setHTML(row, 4, UtilComunicator.getTextAsBoldHTML(messageReceived.getSubject(), seen));
}
 
Example 6
Project: document-management-system   File: WorkflowFormPanel.java   Source Code and License 6 votes vote down vote up
/**
 * Writes the note
 */
private void writeComment(GWTWorkflowComment comment) {
	int row = tableNotes.getRowCount();
	tableNotes.setHTML(row, 0, "<b>" + comment.getActorId() + "</b>");
	DateTimeFormat dtf = DateTimeFormat.getFormat(Main.i18n("general.date.pattern"));
	tableNotes.setHTML(row, 1, dtf.format(comment.getTime()));
	tableNotes.getCellFormatter().setHorizontalAlignment(row, 1, HasAlignment.ALIGN_RIGHT);
	tableNotes.getRowFormatter().setStyleName(row, "okm-Notes-Title");
	tableNotes.getCellFormatter().setHeight(row, 1, "30px");
	tableNotes.getCellFormatter().setVerticalAlignment(row, 0, HasAlignment.ALIGN_BOTTOM);
	tableNotes.getCellFormatter().setVerticalAlignment(row, 1, HasAlignment.ALIGN_BOTTOM);
	row++;
	tableNotes.setHTML(row, 0, "");
	tableNotes.getCellFormatter().setHeight(row, 0, "6px");
	tableNotes.getRowFormatter().setStyleName(row, "okm-Notes-Line");
	tableNotes.getFlexCellFormatter().setColSpan(row, 0, 2);
	row++;
	tableNotes.setHTML(row, 0, comment.getMessage());
	tableNotes.getFlexCellFormatter().setColSpan(row, 0, 2);
}
 
Example 7
Project: social-analytics   File: AnalyticsActivity.java   Source Code and License 6 votes vote down vote up
@Override
public void onDateSubmit(Date startDate, Date endDate, String account) {

    DateTimeFormat fmt = DateTimeFormat.getFormat("/yyyy/M/d");

    if (startDate.getTime() > endDate.getTime()) {

        MaterialToast.fireToast("Whoops! Invalid date range.", 1000);
    } else {
        String fromDate = fmt.format(startDate);
        String toDate = fmt.format(endDate);
        String dateRange = fromDate + toDate;

        clientFactory.getEventBus().fireEvent(new DateSubmitEvent(dateRange, startDate, endDate, account));
    }

}
 
Example 8
Project: social-analytics   File: AnalyticsViewImpl.java   Source Code and License 6 votes vote down vote up
private void getStartDate(){

        String url = Consts.HOST_URL + "/summary/startTime";

        JsonpRequestBuilder jsonp = new JsonpRequestBuilder();
        // Set timeout for 30 seconds (30000 milliseconds)
        jsonp.setTimeout(30000);
        jsonp.requestObject(url, new AsyncCallback<TweetTimes>() {

            @Override
            public void onFailure(Throwable caught) {
                Window.alert("Failure: " + caught.getMessage());
            }

            @Override
            public void onSuccess(TweetTimes result) {
                // Fire SetDateEvent to change date picker to default date from server
                DateTimeFormat dateTimeFormat = DateTimeFormat.getFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
                Date startDate = dateTimeFormat.parse(result.getStartDate());
                Date endDate = dateTimeFormat.parse(result.getEndDate());

                presenter.getEventBus().fireEvent(new SetDateEvent(startDate, endDate));

            }
        });
    }
 
Example 9
Project: Wiab.pro   File: DateUtils.java   Source Code and License 6 votes vote down vote up
/**
 * Package-private version, takes a fixed "now" time - used for testing
 */
String formatPastDate(Date date, Date now) {

  // NOTE(zdwang): For now skip it for junit code; also see formatDateTime()
  if (!GWT.isClient()) {
    return "formatPastDate is not yet implemented in unit test code";
  }

  if (!isValid(date, now)) {
    GWT.log("formatPastDate can only format time in the past, trying anyway", null);
  }

  if (isRecent(date, now, 12 * HOUR_MS) || onSameDay(date, now)) {
    return formatTime(date);
  } else if (isRecent(date, now, 30 * DAY_MS)) {
    return getMonthDayFormat().format(date) + " " + formatTime(date);
  } else if (isSameYear(date, now)) {
    return getMonthDayFormat().format(date);
  } else {
    return DateTimeFormat.getMediumDateFormat().format(date);
  }
}
 
Example 10
Project: Wiab.pro   File: DateUtils.java   Source Code and License 6 votes vote down vote up
/**
 * Package-private version, takes a fixed "now" time - used for testing
 */
String shortFormatPastDate(Date date, Date now) {

  // NOTE(zdwang): For now skip it for junit code; also see formatDateTime()
  if (!GWT.isClient()) {
    return "formatPastDate is not yet implemented in unit test code";
  }

  if (!isValid(date, now)) {
    GWT.log("formatPastDate can only format time in the past, trying anyway", null);
  }

  if (isRecent(date, now, 12 * HOUR_MS) || onSameDay(date, now)) {
    return formatTime(date);
  } else if (isSameYear(date, now)) {
    return getMonthDayFormat().format(date);
  } else {
    return DateTimeFormat.getShortDateFormat().format(date);
  }
}
 
Example 11
Project: x-cure-chat   File: ForumMessageWidget.java   Source Code and License 6 votes vote down vote up
protected void addNewFieldValuePair( final FlowPanel content, final String fieldName,
		   						   final Date dateValue, final boolean addEndCommaDelimiter ) {
	final Label fieldLabel = new Label( fieldName );
	fieldLabel.setStyleName( CommonResourcesContainer.USER_DIALOG_REGULAR_FIELD_STYLE );
	final DateTimeFormat dateTimeFormat = DateTimeFormat.getFormat( PredefinedFormat.DATE_TIME_SHORT );
	final Label dateTimeLabel = new Label( dateTimeFormat.format( dateValue ) );
	dateTimeLabel.setStyleName( CommonResourcesContainer.CONST_FIELD_VALUE_DEFAULT_STYLE_NAME );
	final int width = ( dateTimeLabel.getOffsetWidth() == 0 ? DEFAULT_PROGRESS_BAR_WIDTH_PIXELS : dateTimeLabel.getOffsetWidth() );
	DateOldProgressBarUI progressBarUI= new DateOldProgressBarUI( width, DEFAULT_PROGRESS_BAR_HEIGHT_PIXELS, dateValue );
	
	//If there are replies to this message
	VerticalPanel dateTimePanel = new VerticalPanel();
	dateTimePanel.setHorizontalAlignment( HasHorizontalAlignment.ALIGN_CENTER );
	dateTimePanel.setVerticalAlignment( HasVerticalAlignment.ALIGN_BOTTOM );
	dateTimePanel.add( dateTimeLabel );
	dateTimePanel.add( progressBarUI );
	
	//Add the widgets to the panel
	addNewFieldValuePair( content, fieldLabel, dateTimePanel, addEndCommaDelimiter );
}
 
Example 12
Project: dataworks-zeus   File: TableInfoTab.java   Source Code and License 6 votes vote down vote up
public void load(TableModel t) {
	getStore().clear();
	if (t != null) {
		store.add(new ModelPropertyModel("表名", t.getName()));
		store.add(new ModelPropertyModel("所有者", t.getOwner()));
		store.add(new ModelPropertyModel("创建时间", DateTimeFormat
				.getFormat("yyyy-MM-d HH:mm:ss").format(t.getCreateDate())
				.toString()));
		store.add(new ModelPropertyModel("路径", t.getPath()));
		String inputFormat = t.getInputFormat();
		if (inputFormat.equals("org.apache.hadoop.mapred.TextInputFormat")) {
			inputFormat = "TextFile";
		} else if (inputFormat
				.equals("org.apache.hadoop.mapred.SequenceFileInputFormat")) {
			inputFormat = "SequenceFile";
		} else if (inputFormat
				.equals("org.apache.hadoop.hive.ql.io.RCFileInputFormat")) {
			inputFormat = "RCFile";
		}
		store.add(new ModelPropertyModel("存储格式", inputFormat));
		store.add(new ModelPropertyModel("注释", t.getComment()));
		char fieldDelim = t.getFieldDelim()==null? '\001':t.getFieldDelim().toCharArray()[0];
		store.add(new ModelPropertyModel("列分割符", fieldDelim+"("+getUnicode(fieldDelim)+")"));
		store.add(new ModelPropertyModel("公共表数据字典","请在代码中配置"));
	}
}
 
Example 13
Project: scheduling-portal   File: MemoryLineChart.java   Source Code and License 6 votes vote down vote up
@Override
public void processResult(String result) {
    JSONArray array = controller.parseJSON(result).isArray();
    if (array != null) {
        String timeStamp = DateTimeFormat.getFormat(PredefinedFormat.HOUR24_MINUTE)
                                         .format(new Date(System.currentTimeMillis()));
        addRow();

        loadTable.setValue(loadTable.getNumberOfRows() - 1, 0, timeStamp);

        // getting primitive values of all attributes
        for (int i = 0; i < attrs.length; i++) {
            double value = array.get(i).isObject().get("value").isNumber().doubleValue();
            loadTable.setValue(loadTable.getNumberOfRows() - 1, i + 1, formatValue(value));
        }

        loadChart.draw(loadTable, loadOpts);
    }
}
 
Example 14
Project: scheduling-portal   File: SwapLineChart.java   Source Code and License 6 votes vote down vote up
@Override
public void processResult(String result) {
    JSONArray array = controller.parseJSON(result).isArray();
    if (array != null) {
        String timeStamp = DateTimeFormat.getFormat(PredefinedFormat.HOUR24_MINUTE)
                                         .format(new Date(System.currentTimeMillis()));
        addRow();

        loadTable.setValue(loadTable.getNumberOfRows() - 1, 0, timeStamp);

        // getting primitive values of all attributes
        for (int i = 0; i < attrs.length; i++) {
            double value = array.get(i).isObject().get("value").isNumber().doubleValue();
            loadTable.setValue(loadTable.getNumberOfRows() - 1, i + 1, formatValue(value));
        }

        loadChart.draw(loadTable, loadOpts);
    }
}
 
Example 15
Project: mgwt-traffic-flow   File: ParserUtils.java   Source Code and License 6 votes vote down vote up
/**
 * 
 * @param createdAt
 * @param datePattern
 * @param isUTC
 * @return
 */
public static String relativeTime(String createdAt, String datePattern, boolean isUTC) {
	DateTimeFormat parseDateFormat = DateTimeFormat.getFormat(datePattern);
	Date parseDate;

	try {
		if (isUTC) {
			parseDate = parseDateFormat.parse(parseDateFormat.format(
					parseDateFormat.parse(createdAt),
					TimeZone.createTimeZone(0)));
		} else {		
			parseDate = parseDateFormat.parse(createdAt);
		}
	} catch (IllegalArgumentException e) {
		return "Unavailable";
	}

	return getRelative(parseDate);

}
 
Example 16
Project: mgwt-traffic-flow   File: ParserUtils.java   Source Code and License 6 votes vote down vote up
/**
 * 
 * @param date
 * @return
 */
private static String getRelative(Date date) {
	DateTimeFormat displayDateFormat = DateTimeFormat.getFormat("MMMM d, yyyy h:mm a");	
	int delta = 0;

	try {
		Date relativeDate = new Date();
		delta = (int)((relativeDate.getTime() - date.getTime()) / 1000); // convert to seconds
		if (delta < 60) {
			return delta + " seconds ago";
		} else if (delta < 120) {
			return "1 minute ago";
		} else if (delta < (60*60)) {
			return Integer.toString(delta / 60) + " minutes ago";
		} else if (delta < (120*60)) {
			return "1 hour ago";
		} else if (delta < (24*60*60)) {
			return Integer.toString(delta / 3600) + " hours ago";
		} else {
			return displayDateFormat.format(date);
		}
	} catch (Exception e) {
		return "Unavailable";
	}		

}
 
Example 17
Project: google-apis-explorer   File: EmbeddedHistoryItemView.java   Source Code and License 6 votes vote down vote up
public EmbeddedHistoryItemView(ApiRequest request) {
  initWidget();

  this.request = request;

  // Stash the real URL in case we need it for loading media
  realPathFragment = request.getRequestPath();

  // Replace the API key with a fake version if the default was used
  if (ExplorerConfig.API_KEY.equals(request.getApiKey())) {
    request.setApiKey("{YOUR_API_KEY}");
  }

  String prefix = request.getMethod().getId() + " executed ";
  PrettyDate.keepMakingPretty(new Date(), prefix, title);

  String dateString =
      DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_SHORT).format(new Date());
  title.setTitle(dateString);

  requestDiv.setInnerText(getRequestString(request));
}
 
Example 18
Project: proarc   File: WorkflowTaskFormView.java   Source Code and License 6 votes vote down vote up
private Object getParameterValue(Record record, ValueType valueType, DisplayType displayType) {
    Object val = record.getAttributeAsObject(WorkflowParameterDataSource.FIELD_VALUE);
    if (valueType == ValueType.DATETIME && val instanceof String) {
        DateTimeFormat format = DateTimeFormat.getFormat(PredefinedFormat.ISO_8601);
        val = format.parse((String) val);
    } else if (displayType == DisplayType.CHECKBOX && val instanceof String) {
        if (Boolean.TRUE.toString().equalsIgnoreCase((String) val)) {
            val = true;
        } else if (Boolean.FALSE.toString().equalsIgnoreCase((String) val)) {
            val = false;
        } else {
            try {
                val = new BigDecimal((String) val).compareTo(BigDecimal.ZERO) > 0;
            } catch (NumberFormatException e) {
                // ignore
            }
        }
    } else if (displayType == DisplayType.CHECKBOX && val instanceof Number) {
        val = ((Number) val).doubleValue() > 0;
    }
    return val;
}
 
Example 19
Project: proarc   File: RepeatableFormItem.java   Source Code and License 6 votes vote down vote up
/**
     * Replace string values of record attributes with types declared by item children.
     * This is necessary as declarative forms do not use DataSource stuff.
     * @param record record to scan for attributes
     * @param item item with possible profile
     * @return resolved record
     */
    private static Record resolveRecordValues(Record record, FormItem item) {
        Field f = getProfile(item);
        if (f != null) {
            for (Field field : f.getFields()) {
                String fType = field.getType();
                if ("date".equals(fType) || "datetime".equals(fType)) {
                    // parses ISO dateTime to Date; otherwise DateItem cannot recognize the value!
                    Object value = record.getAttributeAsObject(field.getName());
                    if (!(value instanceof String)) {
                        continue;
                    }
                    String sd = (String) value;
//                    ClientUtils.severe(LOG, "name: %s, is date, %s", field.getName(), sd);
//                    Date d = DateTimeFormat.getFormat(PredefinedFormat.ISO_8601).parse("1994-11-05T13:15:30Z");
                    try {
                        Date d = DateTimeFormat.getFormat(PredefinedFormat.ISO_8601).parse(sd);
                        record.setAttribute(field.getName(), d);
                    } catch (IllegalArgumentException ex) {
                        LOG.log(Level.WARNING, sd, ex);
                    }
                }
            }
        }
        return record;
    }
 
Example 20
Project: OpenTripPlanner-client-gwt   File: AlertWidget.java   Source Code and License 6 votes vote down vote up
private String formatDateRange(Date from, Date to) {
	/*
	 * TODO Make this more human-readable (if from and to are on the same
	 * day, print only once the date; if from and to are today, do not print
	 * the date; etc...)
	 */
	// We assume the user will know the year... an alert is always nearby.
	DateTimeFormat dateTimeFormat = DateTimeFormat.getFormat("d MMM hh:mm");
	StringBuffer retval = new StringBuffer();
	if (from != null)
		retval.append(dateTimeFormat.format(from));
	else
		retval.append("...");
	if (from != null || to != null)
		retval.append(" → ");
	if (to != null)
		retval.append(dateTimeFormat.format(to));
	else
		retval.append("...");
	return retval.toString();
}
 
Example 21
Project: OpenTripPlanner-client-gwt   File: PlannerState.java   Source Code and License 6 votes vote down vote up
private void buildUrl() {
	UrlBuilder urlBuilder = Window.Location.createUrlBuilder();
	PlanRequestBean planRequest = getPlanRequestBean();
	if (planRequest.getDeparture().isSet(false))
		urlBuilder.setParameter("origin",
				getLocationAsStringParam(planRequest.getDeparture()));
	if (planRequest.getArrival().isSet(false))
		urlBuilder.setParameter("destination",
				getLocationAsStringParam(planRequest.getArrival()));
	DateTimeFormat dtf = DateTimeFormat.getFormat("yyyy/MM/[email protected]:mm");
	urlBuilder.setParameter(
			planRequest.isDateDeparture() ? "depart" : "arrive",
			dtf.format(planRequest.getDate()));
	if (planRequest.isWheelchairAccessible())
		urlBuilder.setParameter("wheelchair", "y");
	Set<TransportMode> modes = planRequest.getModes();
	String modesStr = "";
	for (TransportMode mode : modes) {
		modesStr = modesStr + mode.toString() + ",";
	}
	modesStr = modesStr.substring(0, modesStr.length() - 1);
	urlBuilder.setParameter("modes", modesStr);
	url = urlBuilder.buildString();
}
 
Example 22
Project: ErraiMessageBusChat   File: ChatClient.java   Source Code and License 6 votes vote down vote up
private void processMessage(MyMessage newMessage) {
  ListGroupItem message = new ListGroupItem();
  Icon icon = new Icon();
  icon.setSize(IconSize.LARGE);
  if (newMessage.getType().equals(MyMessage.MessageType.SYSTEM)) {
    icon.setType(IconType.COG);
  } else if (newMessage.getType().equals(MyMessage.MessageType.PUBLIC)) {
    icon.setType(IconType.USER);
  } else {
    icon.setType(IconType.USER_SECRET);
  }

  message.insert(icon, 0);
  message.setId("message_" + random.nextInt());
  message.setText(" " + DateTimeFormat.getFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + " "
      + newMessage.getAuthor().getUsername() + " says : " + newMessage.getMessage());
  message.getElement().addClassName(
      "list-group-item-" + newMessage.getAuthor().getColor().toLowerCase());
  chatList.add(message);
}
 
Example 23
Project: firefly   File: DateFieldDef.java   Source Code and License 6 votes vote down vote up
public Date getDate(Object val) {
    if (StringUtils.isEmpty(val)) return null;

    Date parsed = null;
    if (val instanceof Date) {
        return (Date) val;
    } else {
        DateTimeFormat dtFormat;
        if (formats != null) {
            for (String f : formats) {
                dtFormat = DateTimeFormat.getFormat(f);
                try {
                    parsed = dtFormat.parseStrict(val.toString().trim());
                    return parsed;
                } catch (Exception e) {
                }
            }
        }
        if (parsed == null) {
            throw new IllegalArgumentException("Unable to parse date from "+val.toString());
        } else {
            return parsed;
        }
    }
}
 
Example 24
Project: unitime   File: PeriodPreferencesWidget.java   Source Code and License 6 votes vote down vote up
Cell(int day, int slot, Date date, PeriodInterface period) {
	super("cell", "item", isEditable() && period != null ? "clickable" : null, period == null ? "disabled" : null, period != null && iModel.isAssigned(period) ? "highlight" : null);
	iDay = day;
	iSlot = slot;
	iDate = date;
	iPeriod = period;
	if (period != null) {
		PreferenceInterface preference = iModel.getPreference(day, slot);
		if (preference == null) {
			getElement().getStyle().clearBackgroundColor();
			setHTML("");
			setTitle("");
		} else {
			getElement().getStyle().setBackgroundColor(preference.getColor());
			setTitle(DateTimeFormat.getFormat(CONSTANTS.examPeriodDateFormat()).format(date) + " " + slot2short(slot) + (period == null ? "" : " - " + slot2short(slot + period.getLength())) + ": " + preference.getName());
		}
		if (isEditable())
			addMouseDownHandler(new MouseDownHandler() {
				@Override
				public void onMouseDown(MouseDownEvent event) {
					setOption(iPreference);
				}
			});				
	}
}
 
Example 25
Project: unitime   File: PeriodPreferencesWidget.java   Source Code and License 6 votes vote down vote up
private D(int day, int slot, Date date, PeriodInterface period) {
	super("cell", "day", isEditable() && period != null ? "clickable" : null, period == null ? "unavailable" : null);
	iDay = day;
	iSlot = slot;
	iDate = date;
	iPeriod = period;
	setText(DateTimeFormat.getFormat("d").format(date));
	if (period != null) {
		PreferenceInterface preference = iModel.getPreference(day, slot);
		if (preference == null) {
			getElement().getStyle().clearBackgroundColor();
			setTitle("");
		} else {
			getElement().getStyle().setBackgroundColor(preference.getColor());
			setTitle(DateTimeFormat.getFormat(CONSTANTS.examPeriodDateFormat()).format(date) + " " + slot2short(slot) + (period == null ? "" : " - " + slot2short(slot + period.getLength())) + ": " + preference.getName());
		}
		if (isEditable())
			addMouseDownHandler(new MouseDownHandler() {
				@Override
				public void onMouseDown(MouseDownEvent event) {
					setOption(iPreference);
				}
			});				
	}
}
 
Example 26
Project: unitime   File: EventRoomAvailability.java   Source Code and License 6 votes vote down vote up
@Override
public SessionMonth.Flag getDateFlag(EventType type, Date date) {
	if (iSessionMonths == null || iSessionMonths.isEmpty()) return null;
	if (date == null) return null;
	int m = Integer.parseInt(DateTimeFormat.getFormat("MM").format(date));
	for (SessionMonth month: iSessionMonths)
		if (m == month.getMonth() + 1) {
			int d = Integer.parseInt(DateTimeFormat.getFormat("dd").format(date)) - 1;
			if (month.hasFlag(d, SessionMonth.Flag.FINALS) && type != EventType.FinalExam) return SessionMonth.Flag.FINALS;
			if (month.hasFlag(d, SessionMonth.Flag.BREAK)) return SessionMonth.Flag.BREAK;
			if (month.hasFlag(d, SessionMonth.Flag.WEEKEND)) return SessionMonth.Flag.WEEKEND;
			if (month.hasFlag(d, SessionMonth.Flag.HOLIDAY)) return SessionMonth.Flag.HOLIDAY;
			if (month.hasFlag(d, SessionMonth.Flag.MIDTERMS) && type != EventType.MidtermExam) return SessionMonth.Flag.MIDTERMS;
			return null;
		}
	return null;
}
 
Example 27
Project: daris   File: Package.java   Source Code and License 6 votes vote down vote up
public Package(XmlElement pe) throws Throwable {
    _name = pe.value("@name");
    _version = pe.value("version");
    String buildTime = pe.value("build-time");
    if (buildTime != null) {
        if (buildTime.length() > 20) {
            buildTime = buildTime.substring(0, buildTime.lastIndexOf(' '));
        }
        try {
            _buildTime = DateTimeFormat.getFormat("dd-MMM-yyyy HH:mm:ss")
                    .parse(buildTime);
        } catch (IllegalArgumentException e) {
        }
    }
    _vendor = pe.value("vendor");
    _vendorURL = pe.value("vendorurl");
    _description = pe.value("description");
}
 
Example 28
Project: appformer   File: DatePickerTest.java   Source Code and License 6 votes vote down vote up
@Test
public void testSetFormat() {
    datePicker = new DatePicker(datePickerMock);
    String gwtDateFormat = "dd-MMM-yyyy";
    DateTimeFormat gwtDateTimeFormat = DateTimeFormat.getFormat(gwtDateFormat);

    datePicker.setLocaleName("en");
    datePicker.setFormat(gwtDateFormat);
    verify(datePickerMock).setLanguage(DatePickerLanguage.EN);
    verify(datePickerMock).setFormat(DatePickerFormatUtilities.convertToBS3DateFormat(gwtDateFormat));

    Date now = new Date();
    now = gwtDateTimeFormat.parse(gwtDateTimeFormat.format(now));

    datePicker.setValue(now);
    verify(textBox).setValue(gwtDateTimeFormat.format(now));
    when(textBox.getValue()).thenReturn(gwtDateTimeFormat.format(now));
    assertEquals(now,
                 datePicker.getValue());
}
 
Example 29
Project: appformer   File: VersionMenuItemLabel.java   Source Code and License 6 votes vote down vote up
public VersionMenuItemLabel(
        VersionRecord versionRecord,
        Integer number,
        boolean isSelected,
        Callback<VersionRecord> selectionCallback) {

    this.versionRecord = versionRecord;
    initWidget(uiBinder.createAndBindUi(this));

    if (isSelected) {
        setSelected();
    }

    this.selectionCallback = selectionCallback;
    this.number.setText(number.toString());
    author.setText(versionRecord.author());
    date.setText(DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_TIME_SHORT).format(versionRecord.date()));
    comment.setText(snip(versionRecord.comment()));
    base.setTitle(versionRecord.comment());
}
 
Example 30
Project: unitimes   File: PeriodPreferencesWidget.java   Source Code and License 5 votes vote down vote up
public void setOption(PreferenceInterface preference) {
	if (!isEditable() || iPeriod == null) return;
	iModel.setPreference(iDay, iSlot, preference);
	if (preference == null) {
		getElement().getStyle().clearBackgroundColor();
		setTitle("");
	} else {
		getElement().getStyle().setBackgroundColor(preference.getColor());
		setTitle(DateTimeFormat.getFormat(CONSTANTS.examPeriodDateFormat()).format(iDate) + " " + slot2short(iSlot) + " - " + slot2short(iSlot + iPeriod.getLength()) + ": " + preference.getName());
	}
	ValueChangeEvent.fire(PeriodPreferencesWidget.this, getValue());
}
 
Example 31
Project: unitimes   File: ServerDateTimeFormat.java   Source Code and License 5 votes vote down vote up
public static DateTimeFormat getFormat(String pattern) {
	ServerDateTimeFormat format = sFormatCache.get(pattern);
	if (format == null) {
		format = new ServerDateTimeFormat(pattern);
		sFormatCache.put(pattern, format);
	}
	return format;
}
 
Example 32
Project: unitimes   File: SingleDateSelector.java   Source Code and License 5 votes vote down vote up
public static SingleDateSelector insert(RootPanel panel) {
	String format = panel.getElement().getAttribute("format");
	final String onchange = panel.getElement().getAttribute("onchange");
	String error = panel.getElement().getAttribute("error");
	AriaTextBox text = new AriaTextBox(panel.getElement().getFirstChildElement());
	SingleDateSelector selector = new SingleDateSelector(text, null, false);
	if (format != null)
		selector.iFormat = DateTimeFormat.getFormat(format);
	if (onchange != null)
		selector.addValueChangeHandler(new ValueChangeHandler<Date>() {
			@Override
			public void onValueChange(ValueChangeEvent<Date> event) {
				ToolBox.eval(onchange);
			}
		});
	if (text.getText() != null && !text.getText().isEmpty()) {
		Date date = null;
		try {
			date = selector.iFormat.parse(text.getText());
		} catch (IllegalArgumentException e) {}
		if (date != null)
			selector.setValue(date);
	}
	if (error != null && !error.isEmpty())
		selector.setErrorHint(error);
	panel.add(selector);
	return selector;
}
 
Example 33
Project: unitimes   File: SessionDatesSelector.java   Source Code and License 5 votes vote down vote up
public void init(List<SessionMonth> months) {
	iPanel.getWidget().clear();
	int firstOutside = -1, start = -1, end = -1, finals = -1, midterms = -1, firstHoliday = - 1, firstBreak = -1, today = -1, firstPast = -1, firstEventDate = -1, firstClassDate = -1;
	int idx = 0;
	P lastWeek = null;
	for (SessionMonth month: months) {
		SingleMonth m = new SingleMonth(month, isCanSelectPast(), idx++, lastWeek);
		lastWeek = m.getWeeks().get(m.getWeeks().size() - 1);
		if (lastWeek.getDays().size() == 7) lastWeek = null;
		iPanel.getWidget().add(m);
		if (start < 0) start = month.getFirst(SessionMonth.Flag.START);
		if (end < 0) end = month.getFirst(SessionMonth.Flag.END);
		if (finals < 0) finals = month.getFirst(SessionMonth.Flag.FINALS);
		if (midterms < 0) midterms = month.getFirst(SessionMonth.Flag.MIDTERMS);
		if (firstHoliday < 0) firstHoliday = month.getFirst(SessionMonth.Flag.HOLIDAY);
		if (firstBreak < 0) firstBreak = month.getFirst(SessionMonth.Flag.BREAK);
		if (firstOutside < 0) firstOutside = month.getFirst(SessionMonth.Flag.DISABLED);
		if (firstPast < 0) firstPast = month.getFirst(SessionMonth.Flag.PAST);
		if (firstEventDate < 0) firstEventDate = month.getFirst(SessionMonth.Flag.DATE_MAPPING_EVENT);
		if (firstClassDate < 0) firstClassDate = month.getFirst(SessionMonth.Flag.DATE_MAPPING_CLASS);
		if (month.getYear() == Integer.parseInt(DateTimeFormat.getFormat("yyyy").format(new Date())) &&
			month.getMonth() + 1 == Integer.parseInt(DateTimeFormat.getFormat("MM").format(new Date())))
			today = Integer.parseInt(DateTimeFormat.getFormat("dd").format(new Date()));
		if (month.getFirst(SessionMonth.Flag.START) >= 0) iSessionYear = month.getYear();
	}
	iPanel.getWidget().add(new Legend(firstOutside, start, finals, midterms, firstHoliday, firstBreak, iCanSelectPast ? -1 : firstPast, today, firstClassDate, firstEventDate));
	iPanel.getWidget().setCursor(new Date());
}
 
Example 34
Project: unitimes   File: SessionDatesSelector.java   Source Code and License 5 votes vote down vote up
@Override
public List<Date> getValue() {
	List<Date> ret = new ArrayList<Date>();
	DateTimeFormat df = DateTimeFormat.getFormat("yyyy/MM/dd");
	for (int i = 0; i < iPanel.getWidget().getWidgetCount(); i ++) {
		Widget w = iPanel.getWidget().getWidget(i);
		if (w instanceof SingleMonth) {
			SingleMonth s = (SingleMonth)w;
			for (D d: s.getDays()) {
				if (d.getValue()) ret.add(df.parse(s.getYear() + "/" + (1 + s.getMonth()) + "/" + (1 + d.getNumber())));
			}
		}
	}
	return ret;
}
 
Example 35
Project: unitimes   File: SessionDatesSelector.java   Source Code and License 5 votes vote down vote up
public boolean isEnabled(Date date) {
	int year = Integer.parseInt(DateTimeFormat.getFormat("yyyy").format(date));
	int month = Integer.parseInt(DateTimeFormat.getFormat("MM").format(date));
	int day = Integer.parseInt(DateTimeFormat.getFormat("dd").format(date));
	for (int i = 0; i < iPanel.getWidget().getWidgetCount(); i ++) {
		Widget w = iPanel.getWidget().getWidget(i);
		if (w instanceof SingleMonth) {
			SingleMonth s = (SingleMonth)w;
			if (s.getYear() == year && s.getMonth() + 1 == month)
				return s.get(day - 1).isEnabled();
		}
	}
	return false;
}
 
Example 36
Project: unitimes   File: SessionDatesSelector.java   Source Code and License 5 votes vote down vote up
public boolean hasFlag(Date date, SessionMonth.Flag flag) {
	int year = Integer.parseInt(DateTimeFormat.getFormat("yyyy").format(date));
	int month = Integer.parseInt(DateTimeFormat.getFormat("MM").format(date));
	int day = Integer.parseInt(DateTimeFormat.getFormat("dd").format(date));
	for (int i = 0; i < iPanel.getWidget().getWidgetCount(); i ++) {
		Widget w = iPanel.getWidget().getWidget(i);
		if (w instanceof SingleMonth) {
			SingleMonth s = (SingleMonth)w;
			if (s.getYear() == year && s.getMonth() + 1 == month)
				return s.get(day - 1).hasFlag(flag);
		}
	}
	return false;
}
 
Example 37
Project: calendar-component   File: VCalendar.java   Source Code and License 5 votes vote down vote up
/**
 * Get the time format used to format time only (excludes date)
 *
 * @return the time format used to format time only (excludes date)
 */
public DateTimeFormat getTimeFormat() {
    if (is24HFormat()) {
        return time24format_date;
    }
    return time12format_date;
}
 
Example 38
Project: appinventor-extensions   File: SaveAllEditorsCommand.java   Source Code and License 5 votes vote down vote up
@Override
public void execute(final ProjectNode node) {
  // Ode.getInstance().getEditorManager().saveDirtyEditors(new Command() {
  final Ode ode = Ode.getInstance();
  ode.lockScreens(true);      // Lock out screen switching
  ode.getEditorManager().saveDirtyEditors(new Command() {
    @Override
    public void execute() {
      ode.lockScreens(false); // Screen switch OK now
      ErrorReporter.reportInfo(MESSAGES.savedProject(
          DateTimeFormat.getMediumDateTimeFormat().format(new Date())));
      executeNextCommand(node);
    }
  });
}
 
Example 39
Project: appinventor-extensions   File: ShowProgressBarCommand.java   Source Code and License 5 votes vote down vote up
/**
 * Creates a new command for showing a barcode for the target of a project.
 *
 * @param target the build target
 * @param nextCommand
 * @param serviceName
 */
public ShowProgressBarCommand(String target,ChainableCommand nextCommand, String serviceName) {
  // Since we don't know when the barcode dialog is finished, we can't
  // support a command after this one.
  super(nextCommand); // no next command
  this.target = target;
  this.nextCommand = nextCommand;
  this.buildRequestTime = DateTimeFormat.getMediumDateTimeFormat().format(new Date());
  this.serviceName = serviceName;
}
 
Example 40
Project: appinventor-extensions   File: CopyYoungAndroidProjectCommand.java   Source Code and License 5 votes vote down vote up
private Widget createPreviousCheckpointsTable(List<Project> checkpointProjects) {
  Grid table = new Grid(1 + checkpointProjects.size(), 3);
  table.addStyleName("ode-ProjectTable");

  // Set the widgets for the header row.
  table.getRowFormatter().setStyleName(0, "ode-ProjectHeaderRow");
  table.setWidget(0, 0, new Label(MESSAGES.projectNameHeader()));
  table.setWidget(0, 1, new Label(MESSAGES.projectDateCreatedHeader()));
  table.setWidget(0, 2, new Label(MESSAGES.projectDateModifiedHeader()));

  // Set the widgets for the rows representing previous checkpoints
  DateTimeFormat dateTimeFormat = DateTimeFormat.getMediumDateTimeFormat();
  int row = 1;
  for (Project checkpointProject : checkpointProjects) {
    table.getRowFormatter().setStyleName(row, "ode-ProjectRowUnHighlighted");
    Label nameLabel = new Label(checkpointProject.getProjectName());
    table.setWidget(row, 0, nameLabel);

    Date dateCreated = new Date(checkpointProject.getDateCreated());
    table.setWidget(row, 1, new Label(dateTimeFormat.format(dateCreated)));

    Date dateModified = new Date(checkpointProject.getDateModified());
    table.setWidget(row, 2, new Label(dateTimeFormat.format(dateModified)));
    row++;
  }

  return table;
}
 
Example 41
Project: appinventor-extensions   File: ReportList.java   Source Code and License 5 votes vote down vote up
/**
 * Constructor of ReportWidgets
 * @param report GalleryAppReport
 */
private ReportWidgets(final GalleryAppReport report) {

  reportTextLabel = new Label(report.getReportText());
  reportTextLabel.addStyleName("ode-ProjectNameLabel");
  reportTextLabel.setWordWrap(true);
  reportTextLabel.setWidth("200px");

  appLabel = new Label(report.getApp().getTitle());
  appLabel.addStyleName("primary-link");

  DateTimeFormat dateTimeFormat = DateTimeFormat.getMediumDateTimeFormat();
  Date dateCreated = new Date(report.getTimeStamp());
  dateCreatedLabel = new Label(dateTimeFormat.format(dateCreated));

  appAuthorlabel = new Label(report.getOffender().getUserName());
  appAuthorlabel.addStyleName("primary-link");

  reporterLabel = new Label(report.getReporter().getUserName());
  reporterLabel.addStyleName("primary-link");

  sendEmailButton = new Button(MESSAGES.buttonSendEmail());

  deactiveAppButton = new Button(MESSAGES.labelDeactivateApp());

  markAsResolvedButton = new Button(MESSAGES.labelmarkAsResolved());

  seeAllActions = new Button(MESSAGES.labelSeeAllActions());
}
 
Example 42
Project: document-management-system   File: LogScrollTable.java   Source Code and License 5 votes vote down vote up
/**
 * Adds new user name row
 *
 * @param userName The user name value
 */
public void addRow(GWTActivity activity) {
	int rows = dataTable.getRowCount();
	dataTable.insertRow(rows);
	dataTable.setHTML(rows, 0, activity.getAction());
	dataTable.setHTML(rows, 1, activity.getUser());
	DateTimeFormat dtf = DateTimeFormat.getFormat(GeneralComunicator.i18n("general.date.pattern"));
	dataTable.setHTML(rows, 2, dtf.format(activity.getDate()));
	dataTable.setHTML(rows, 3, activity.getParams());
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 1, HasAlignment.ALIGN_CENTER);
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 2, HasAlignment.ALIGN_CENTER);
}
 
Example 43
Project: document-management-system   File: WorkflowDetailTable.java   Source Code and License 5 votes vote down vote up
/**
 * addRow
 *
 * @param instanceLogEntry
 */
public void addRow(GWTProcessInstanceLogEntry instanceLogEntry) {
	int rows = dataTable.getRowCount();
	dataTable.insertRow(rows);
	dataTable.setHTML(rows, 0, String.valueOf(instanceLogEntry.getProcessDefinitionId()));
	dataTable.setHTML(rows, 1, instanceLogEntry.getProcessDefinitionName());
	dataTable.setHTML(rows, 2, instanceLogEntry.getToken());
	DateTimeFormat dtf = DateTimeFormat.getFormat(GeneralComunicator.i18n("general.date.pattern"));
	dataTable.setHTML(rows, 3, dtf.format(instanceLogEntry.getDate()));
	dataTable.setHTML(rows, 4, instanceLogEntry.getType());
	dataTable.setHTML(rows, 5, instanceLogEntry.getInfo());
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 0, HasAlignment.ALIGN_CENTER);
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 3, HasAlignment.ALIGN_CENTER);
}
 
Example 44
Project: document-management-system   File: ExtendedScrollTable.java   Source Code and License 5 votes vote down vote up
/**
 * Refresh proposed query row
 *
 * @param propose
 */
private void refreshProposedQueryRow(final GWTProposedQueryReceived propose, int row) {
	boolean seen = (propose.getSeenDate() == null);
	// Sets folder object
	data.put(new Integer(dataTable.getHTML(row, 5)), propose);

	if (propose.isAccepted()) {
		dataTable.setWidget(row, 0, new Image(OKMBundleResources.INSTANCE.yes()));
	} else {
		dataTable.setHTML(row, 0, "");
	}

	dataTable.setHTML(row, 1, UtilComunicator.getTextAsBoldHTML(propose.getFrom(), seen));
	String queryType = "";

	if (!propose.getParams().isDashboard()) {
		queryType = GeneralComunicator.i18nExtension("messaging.message.type.propose.query");
	} else {
		queryType = GeneralComunicator.i18nExtension("messaging.message.type.propose.user.query");
	}

	dataTable.setHTML(row, 2, UtilComunicator.getTextAsBoldHTML(queryType, seen));
	DateTimeFormat dtf = DateTimeFormat.getFormat(GeneralComunicator.i18nExtension("general.date.pattern"));
	dataTable.setHTML(row, 3, UtilComunicator.getTextAsBoldHTML(dtf.format(propose.getSentDate()), seen));
	Anchor anchor = new Anchor();
	String queryName = propose.getParams().getQueryName();
	anchor.setHTML(UtilComunicator.getTextAsBoldHTML(queryName, seen));
	anchor.setTitle(queryName);
	anchor.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent arg0) {
			WorkspaceComunicator.changeSelectedTab(UIDockPanelConstants.SEARCH);
			SearchComunicator.setSavedSearch(propose.getParams());
		}
	});

	anchor.setStyleName("okm-KeyMap-ImageHover");
	dataTable.setWidget(row, 4, anchor);
}
 
Example 45
Project: document-management-system   File: ExtendedScrollTable.java   Source Code and License 5 votes vote down vote up
/**
 * Adding addMessageSentRow
 *
 * @param messageSent
 */
private void addMessageSentRow(final GWTTextMessageSent messageSent) {
	int rows = dataTable.getRowCount();
	dataTable.insertRow(rows);
	// Sets folder object
	data.put(new Integer(dataIndexValue), messageSent);

	dataTable.setHTML(rows, 0, "");
	dataTable.setHTML(rows, 1, messageSent.getTo());
	dataTable.setHTML(rows, 2, GeneralComunicator.i18nExtension("messaging.message.type.message.sent"));
	DateTimeFormat dtf = DateTimeFormat.getFormat(GeneralComunicator.i18nExtension("general.date.pattern"));
	dataTable.setHTML(rows, 3, dtf.format(messageSent.getSentDate()));
	dataTable.setHTML(rows, 4, messageSent.getSubject());
	dataTable.setHTML(rows, 5, "" + (dataIndexValue++));

	// Format
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 0, HasHorizontalAlignment.ALIGN_CENTER);
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 1, HasHorizontalAlignment.ALIGN_LEFT);
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 2, HasHorizontalAlignment.ALIGN_LEFT);
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 3, HasHorizontalAlignment.ALIGN_CENTER);
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 4, HasHorizontalAlignment.ALIGN_LEFT);
	dataTable.getCellFormatter().setVisible(rows, 5, false);

	for (int i = 0; i < 5; i++) {
		dataTable.getCellFormatter().addStyleName(rows, i, "okm-DisableSelect");
	}
}
 
Example 46
Project: document-management-system   File: ExtendedScrollTable.java   Source Code and License 5 votes vote down vote up
/**
 * Adding addMessageReceivedRow
 *
 * @param messageReceived
 */
private void addMessageReceivedRow(final GWTMessageReceived messageReceived) {
	int rows = dataTable.getRowCount();
	boolean seen = (messageReceived.getSeenDate() == null);
	dataTable.insertRow(rows);

	// Sets folder object
	data.put(new Integer(dataIndexValue), messageReceived);

	dataTable.setHTML(rows, 0, "");
	dataTable.setHTML(rows, 1, UtilComunicator.getTextAsBoldHTML(messageReceived.getFrom(), seen));
	dataTable.setHTML(
			rows,
			2,
			UtilComunicator.getTextAsBoldHTML(
					GeneralComunicator.i18nExtension("messaging.message.type.message.sent"), seen));
	DateTimeFormat dtf = DateTimeFormat.getFormat(GeneralComunicator.i18nExtension("general.date.pattern"));
	dataTable.setHTML(rows, 3, UtilComunicator.getTextAsBoldHTML(dtf.format(messageReceived.getSentDate()), seen));
	dataTable.setHTML(rows, 4, UtilComunicator.getTextAsBoldHTML(messageReceived.getSubject(), seen));
	dataTable.setHTML(rows, 5, "" + (dataIndexValue++));

	// Format
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 0, HasHorizontalAlignment.ALIGN_CENTER);
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 1, HasHorizontalAlignment.ALIGN_LEFT);
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 2, HasHorizontalAlignment.ALIGN_LEFT);
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 3, HasHorizontalAlignment.ALIGN_CENTER);
	dataTable.getCellFormatter().setHorizontalAlignment(rows, 4, HasHorizontalAlignment.ALIGN_LEFT);
	dataTable.getCellFormatter().setVisible(rows, 5, false);

	for (int i = 0; i < 5; i++) {
		dataTable.getCellFormatter().addStyleName(rows, i, "okm-DisableSelect");
	}
}
 
Example 47
Project: document-management-system   File: MessageSentDetail.java   Source Code and License 5 votes vote down vote up
/**
 * set
 *
 * @param messageSent
 */
public void set(final GWTTextMessageSent messageSent) {
	from.setHTML(messageSent.getFrom());
	to.setHTML(messageSent.getTo());
	docType.setHTML(GeneralComunicator.i18nExtension("messaging.message.type.message.sent"));
	DateTimeFormat dtf = DateTimeFormat.getFormat(GeneralComunicator.i18nExtension("general.date.pattern"));
	date.setHTML(dtf.format(messageSent.getSentDate()));
	table.setHTML(2, 1, messageSent.getSubject());
	content.setHTML(messageSent.getContent().replaceAll("\n", "</br>"));
}
 
Example 48
Project: document-management-system   File: ProposedSubscriptionSentDetail.java   Source Code and License 5 votes vote down vote up
/**
 * set
 *
 * @param propose
 */
public void set(final GWTProposedSubscriptionSent propose) {
	this.propose = propose;
	from.setHTML(propose.getFrom());
	to.setHTML(propose.getTo());

	if (propose.getType().equals(GWTFolder.TYPE)) {
		docType.setHTML(GeneralComunicator.i18nExtension("messaging.message.type.propose.folder"));
		table.setHTML(2, 0, "<b>" + GeneralComunicator.i18nExtension("messaging.detail.folder") + "</b>");
	} else {
		docType.setHTML(GeneralComunicator.i18nExtension("messaging.message.type.propose.document"));
		table.setHTML(2, 0, "<b>" + GeneralComunicator.i18nExtension("messaging.detail.document") + "</b>");
	}

	DateTimeFormat dtf = DateTimeFormat.getFormat(GeneralComunicator.i18nExtension("general.date.pattern"));
	date.setHTML(dtf.format(propose.getSentDate()));
	String path = propose.getPath().substring(propose.getPath().lastIndexOf("/") + 1);
	anchor.setHTML(path);
	anchor.setTitle(propose.getPath());
	anchor.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent arg0) {
			if (propose.getType().equals(GWTFolder.TYPE)) {
				GeneralComunicator.openPath(propose.getPath(), null);
			} else if (propose.getType().equals(GWTDocument.TYPE)) {
				String fldPath = propose.getPath().substring(0, propose.getPath().lastIndexOf("/"));
				GeneralComunicator.openPath(fldPath, propose.getPath());
			}
		}
	});

	content.setHTML(propose.getComment().replaceAll("\n", "</br>"));
}
 
Example 49
Project: document-management-system   File: ProposedQuerySentDetail.java   Source Code and License 5 votes vote down vote up
/**
 * set
 *
 * @param propose
 */
public void set(final GWTProposedQuerySent propose) {
	from.setHTML(propose.getFrom());
	to.setHTML(propose.getTo());
	String queryType = "";
	if (!propose.getParams().isDashboard()) {
		queryType = GeneralComunicator.i18nExtension("messaging.message.type.propose.query");
	} else {
		queryType = GeneralComunicator.i18nExtension("messaging.message.type.propose.user.query");
	}
	docType.setHTML(queryType);
	table.setHTML(2, 0, "<b>" + GeneralComunicator.i18nExtension("messaging.detail.query") + "</b>");
	DateTimeFormat dtf = DateTimeFormat.getFormat(GeneralComunicator.i18nExtension("general.date.pattern"));
	date.setHTML(dtf.format(propose.getSentDate()));

	Anchor anchor = new Anchor();
	String queryName = propose.getParams().getQueryName();
	anchor.setHTML(queryName);
	anchor.setTitle(queryName);
	anchor.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent arg0) {
			WorkspaceComunicator.changeSelectedTab(UIDockPanelConstants.SEARCH);
			SearchComunicator.setSavedSearch(propose.getParams());
		}
	});
	anchor.setStyleName("okm-KeyMap-ImageHover");
	Image runImage = new Image(OKMBundleResources.INSTANCE.run());
	HorizontalPanel hPanel = new HorizontalPanel();
	hPanel.add(runImage);
	hPanel.add(anchor);
	hPanel.setCellVerticalAlignment(anchor, HasAlignment.ALIGN_MIDDLE);
	table.setWidget(2, 1, hPanel);

	content.setHTML(propose.getComment().replaceAll("\n", "</br>"));
}
 
Example 50
Project: document-management-system   File: MessageReceivedDetail.java   Source Code and License 5 votes vote down vote up
/**
 * set
 *
 * @param messageReceived
 */
public void set(final GWTMessageReceived messageReceived) {
	from.setHTML(messageReceived.getFrom());
	to.setHTML(messageReceived.getTo());
	docType.setHTML(GeneralComunicator.i18nExtension("messaging.message.type.message.sent"));
	DateTimeFormat dtf = DateTimeFormat.getFormat(GeneralComunicator.i18nExtension("general.date.pattern"));
	date.setHTML(dtf.format(messageReceived.getSentDate()));
	table.setHTML(2, 1, messageReceived.getSubject());
	content.setHTML(messageReceived.getContent().replaceAll("\n", "</br>"));
}
 
Example 51
Project: document-management-system   File: ISO8601.java   Source Code and License 5 votes vote down vote up
/**
 * Parse string date in format "YYYY-MM-DDThh:mm:ss.SSSTZD"
 */
public static Date parseExtended(String value) {
	if (value == null) {
		return null;
	} else {
		DateTimeFormat dtf = DateTimeFormat.getFormat(PredefinedFormat.ISO_8601);
		return dtf.parse(value);
	}
}
 
Example 52
Project: document-management-system   File: ISO8601.java   Source Code and License 5 votes vote down vote up
/**
 * Format date with format "YYYY-MM-DDThh:mm:ss.SSSTZD"
 */
public static String formatExtended(Date value) {
	if (value == null) {
		return null;
	} else {
		DateTimeFormat dtf = DateTimeFormat.getFormat(PredefinedFormat.ISO_8601);
		return dtf.format(value);
	}
}
 
Example 53
Project: document-management-system   File: ISO8601.java   Source Code and License 5 votes vote down vote up
/**
 * Parse string date in format "yyyyMMddHHmmss"
 */
public static Date parseBasic(String value) {
	if (value == null) {
		return null;
	} else {
		DateTimeFormat dtf = DateTimeFormat.getFormat(BASIC_PATTER);
		return dtf.parse(value);
	}
}
 
Example 54
Project: document-management-system   File: ISO8601.java   Source Code and License 5 votes vote down vote up
/**
 * Format date with format "yyyyMMddHHmmss"
 */
public static String formatBasic(Date value) {
	if (value == null) {
		return null;
	} else {
		DateTimeFormat dtf = DateTimeFormat.getFormat(BASIC_PATTER);
		return dtf.format(value);
	}
}
 
Example 55
Project: document-management-system   File: MsgPopup.java   Source Code and License 5 votes vote down vote up
/**
 * Add message notification.
 */
public void add(GWTUINotification uin) {
	int row = table.getRowCount();
	DateTimeFormat dtf = DateTimeFormat.getFormat(Main.i18n("general.date.pattern"));
	table.setHTML(row, 0, "<b>" + dtf.format(uin.getDate()) + "</b>");
	table.setHTML(row, 1, uin.getMessage());
	table.getCellFormatter().setWidth(row, 1, "100%");
	table.getCellFormatter().setVerticalAlignment(row, 0, HasAlignment.ALIGN_TOP);
	table.getCellFormatter().setVerticalAlignment(row, 1, HasAlignment.ALIGN_TOP);
	table.getCellFormatter().setStyleName(row, 0, "okm-NoWrap");
	if (uin.getId() > lastId) {
		if (uin.getAction() == GWTUINotification.ACTION_LOGOUT) {
			row++;
			int seconds = 240;
			HTML countDown = new HTML(Main.i18n("ui.logout") + " " + secondsToHTML(seconds));
			table.setWidget(row, 0, countDown);
			table.getFlexCellFormatter().setColSpan(row, 0, 2);
			table.getCellFormatter().setHorizontalAlignment(row, 0, HasAlignment.ALIGN_CENTER);
			logout(countDown, seconds);
			show();
		}
		if (uin.isShow()) {
			show();
		}
	}
	evaluateButtons();
}
 
Example 56
Project: document-management-system   File: TestPopup.java   Source Code and License 5 votes vote down vote up
/**
 * @param value
 * @param value2
 */
private void log(String value, String value2) {
	DateTimeFormat dtf = DateTimeFormat.getFormat(Main.i18n("general.date.pattern"));
	int row = table.getRowCount();
	table.setHTML(row, 0, dtf.format(new Date()) + " " + value);
	table.setHTML(row, 1, value2);
	table.getCellFormatter().setHeight(row, 0, "20px");
	table.getCellFormatter().setWidth(row, 0, "250px");
}
 
Example 57
Project: walkaround   File: LogPanel.java   Source Code and License 5 votes vote down vote up
@Override
public void receiveEntry(int num,
    double timestamp,
    String stream,
    Level level,
    Object[] objects,
    Throwable ex) {
  StringBuilder b = new StringBuilder();
  b.append(DateTimeFormat.getFormat("HH:mm:ss.SSS").format(new Date((long) timestamp)) + " "
      + LABELS.get(level) + " (" + stream + "): ");
  for (Object o : objects) {
    if (o instanceof Throwable) {
      printStackTrace((Throwable) o, b);
    } else {
      b.append(o != null ? o.toString() : "(null)");
    }
  }

  Element pre;
  if (numEntries < MAX_ENTRIES) {
    pre = Document.get().createPreElement();
    numEntries++;
  } else {
    pre = entries.getFirstChildElement();
  }
  String streamClass = getStreamFilter(stream).getItemClass();
  String levelClass = LEVEL_CLASSES.get(level);
  pre.setClassName(css.item() + " " + streamClass + " " + levelClass);
  pre.setInnerText(b.toString());
  entries.appendChild(pre);
  focuser.focusLater(pre);

  upTo = num + 1;
}
 
Example 58
Project: social-analytics   File: RankingView.java   Source Code and License 5 votes vote down vote up
public static void getRetweets(String account, Date start, Date end, final MaterialCollection list, final String listType){

        list.clear();

        DateTimeFormat fmt = DateTimeFormat.getFormat("/yyyy/M/d");
        String startDate = fmt.format(start);
        String endDate = fmt.format(end);
        String screenName = account;

        String url = Consts.HOST_URL + "/summary/statuses/retweets/" + listType + "/" + screenName + startDate + endDate;

        loader.setVisible(true);

        JsonpRequestBuilder jsonp = new JsonpRequestBuilder();
        // Set timeout for 30 seconds (30000 milliseconds)
        jsonp.setTimeout(30000);
        jsonp.requestObject(url, new AsyncCallback<Mention>() {

            @Override
            public void onFailure(Throwable caught) {
                Window.alert("Failure: " + caught.getMessage());
                loader.setVisible(false);
            }

            @Override
            public void onSuccess(Mention mention) {
                if (mention.getMentions() != null) {
                    list.clear();
                    updateRetweetList(mention.getMentions(), list, listType);
                    loader.setVisible(false);
                }
            }
        });
    }
 
Example 59
Project: social-analytics   File: RankingView.java   Source Code and License 5 votes vote down vote up
public static void getLikes(String account, Date start, Date end, final MaterialCollection list, final String listType){

        list.clear();

        DateTimeFormat fmt = DateTimeFormat.getFormat("/yyyy/M/d");
        String startDate = fmt.format(start);
        String endDate = fmt.format(end);
        String screenName = account;

        String url = Consts.HOST_URL + "/summary/statuses/favorites/" + listType + "/" + screenName + startDate + endDate;

        loader.setVisible(true);

        JsonpRequestBuilder jsonp = new JsonpRequestBuilder();
        // Set timeout for 30 seconds (30000 milliseconds)
        jsonp.setTimeout(30000);
        jsonp.requestObject(url, new AsyncCallback<Mention>() {

            @Override
            public void onFailure(Throwable caught) {
                Window.alert("Failure: " + caught.getMessage());
                loader.setVisible(false);
            }

            @Override
            public void onSuccess(Mention mention) {
                if (mention.getMentions() != null) {
                    list.clear();
                    updateLikesList(mention.getMentions(), list, listType);
                    loader.setVisible(false);
                }
            }
        });
    }
 
Example 60
Project: social-analytics   File: AdvSearchView.java   Source Code and License 5 votes vote down vote up
@UiHandler("searchBtn")
void onSearch(ClickEvent e){

    if (advSearchTextBox.getText().equalsIgnoreCase("")){
        advSearchTextBox.setText(" ");
    }

    DateTimeFormat fmt = DateTimeFormat.getFormat("/yyyy/M/d");

    String endDate = null;
    String startDate = null;

    if (searchdpStart.getDate() != null) {
        startDate = fmt.format(searchdpStart.getDate());
    }

    if (searchdpEnd.getDate() != null) {
        endDate = fmt.format(searchdpEnd.getDate());
    }

    String account = searchAccountPicker.getSelectedItemText();
    int searchType = Integer.valueOf(searchTypePicker.getSelectedValue());
    String searchTerm = advSearchTextBox.getText();

    int media = (mediaOnly.getValue() ? 1 : 0);

    SearchEvent searchEvent = new SearchEvent(searchTerm, searchType, account, media, startDate, endDate);

    this.clientFactory.getEventBus().fireEvent(searchEvent);
    advSearch.closeModal();

}