- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试通过 maven 编译一个 JFXtras 项目,即默认 JFXtras Agenda 项目中给出的示例,但出现上述错误:
AgendaSample1Impl.java:[47,81] error: diamond operator is not supported in -source 1.5
XML 如下:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>Agenda</groupId>
<artifactId>Agenda</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Agenda</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jfxtras</groupId>
<artifactId>jfxtras-labs</artifactId>
<version>8.0-r1</version>
</dependency>
</dependencies>
</project>
java/maven版本如下:
Apache Maven 2.2.1 (rdebian-14)
Java version: 1.8.0_05
Java home: /usr/lib/jvm/java-8-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux" version: "3.13.0-24-generic" arch: "i386" Family: "unix"
上述 JFXtras 代码如下所示:
package agenda;
import java.io.IOException;
import javafx.application.Application;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
public class AgendaSample1 extends Application {
@FXML
public static StackPane rootAgenda;
@Override
public void start(Stage primaryStage) throws IOException {
Parent root = FXMLLoader.load(getClass().getResource("AgendaSample1.fxml"));
rootAgenda.getChildren().add(new AgendaSample1Impl().lAgenda);
Scene scene = new Scene(root, 490, 490);
primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
package agenda;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Collection;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.atomic.AtomicBoolean;
import javafx.beans.binding.Bindings;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
import javafx.scene.control.ListCell;
import javafx.scene.control.ListView;
import javafx.scene.layout.GridPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.util.Callback;
import jfxtras.labs.scene.control.Agenda;
import jfxtras.labs.scene.control.Agenda.Appointment;
public class AgendaSample1Impl {
final Agenda lAgenda;
public AgendaSample1Impl() {
GridPane lGridPane = new GridPane();
lGridPane.setMaxSize(Integer.MAX_VALUE, Integer.MAX_VALUE);
AgendaSample1.rootAgenda.getChildren().add(lGridPane);
int lRowIdx = 0;
{
lAgenda = new Agenda();
lAgenda.setPrefSize(600, 600);
lAgenda.setMaxSize(Integer.MAX_VALUE, Integer.MAX_VALUE);
lGridPane.add(lAgenda, 0, lRowIdx, 2, 1);
lRowIdx++;
// setup appointment groups
final Map<String, Agenda.AppointmentGroup> lAppointmentGroupMap = new HashMap<>();
lAppointmentGroupMap.put("group0", new Agenda.AppointmentGroupImpl().withStyleClass("group0"));
lAppointmentGroupMap.put("group1", new Agenda.AppointmentGroupImpl().withStyleClass("group1"));
lAppointmentGroupMap.put("group2", new Agenda.AppointmentGroupImpl().withStyleClass("group2"));
lAppointmentGroupMap.put("group3", new Agenda.AppointmentGroupImpl().withStyleClass("group3"));
lAppointmentGroupMap.put("group4", new Agenda.AppointmentGroupImpl().withStyleClass("group4"));
lAppointmentGroupMap.put("group5", new Agenda.AppointmentGroupImpl().withStyleClass("group5"));
lAppointmentGroupMap.put("group6", new Agenda.AppointmentGroupImpl().withStyleClass("group6"));
lAppointmentGroupMap.put("group7", new Agenda.AppointmentGroupImpl().withStyleClass("group7"));
lAppointmentGroupMap.put("group8", new Agenda.AppointmentGroupImpl().withStyleClass("group8"));
lAppointmentGroupMap.put("group9", new Agenda.AppointmentGroupImpl().withStyleClass("group9"));
lAppointmentGroupMap.put("group10", new Agenda.AppointmentGroupImpl().withStyleClass("group10"));
lAppointmentGroupMap.put("group11", new Agenda.AppointmentGroupImpl().withStyleClass("group11"));
lAppointmentGroupMap.put("group12", new Agenda.AppointmentGroupImpl().withStyleClass("group12"));
lAppointmentGroupMap.put("group13", new Agenda.AppointmentGroupImpl().withStyleClass("group13"));
lAppointmentGroupMap.put("group14", new Agenda.AppointmentGroupImpl().withStyleClass("group14"));
lAppointmentGroupMap.put("group15", new Agenda.AppointmentGroupImpl().withStyleClass("group15"));
lAppointmentGroupMap.put("group16", new Agenda.AppointmentGroupImpl().withStyleClass("group16"));
lAppointmentGroupMap.put("group17", new Agenda.AppointmentGroupImpl().withStyleClass("group17"));
lAppointmentGroupMap.put("group18", new Agenda.AppointmentGroupImpl().withStyleClass("group18"));
lAppointmentGroupMap.put("group19", new Agenda.AppointmentGroupImpl().withStyleClass("group19"));
lAppointmentGroupMap.put("group0", new Agenda.AppointmentGroupImpl().withStyleClass("group20"));
lAppointmentGroupMap.put("group1", new Agenda.AppointmentGroupImpl().withStyleClass("group21"));
lAppointmentGroupMap.put("group2", new Agenda.AppointmentGroupImpl().withStyleClass("group22"));
lAppointmentGroupMap.put("group3", new Agenda.AppointmentGroupImpl().withStyleClass("group23"));
for (String lId : lAppointmentGroupMap.keySet()) {
Agenda.AppointmentGroup lAppointmentGroup = lAppointmentGroupMap.get(lId);
lAppointmentGroup.setDescription(lId);
lAgenda.appointmentGroups().add(lAppointmentGroup);
}
// accept new appointments
lAgenda.createAppointmentCallbackProperty().set(new Callback<Agenda.CalendarRange, Agenda.Appointment>() {
public Agenda.Appointment call(Agenda.CalendarRange calendarRange) {
return new Agenda.AppointmentImpl()
.withStartTime(calendarRange.getStartCalendar())
.withEndTime(calendarRange.getEndCalendar())
.withSummary("new")
.withDescription("new")
.withAppointmentGroup(lAppointmentGroupMap.get("group1"));
}
});
lAgenda.selectedAppointments().addListener(new ListChangeListener<Appointment>() {
@Override
public void onChanged(Change<? extends Appointment> c) {
Collection<Appointment> selectedAppointments = lAgenda.selectedAppointments();
ObservableList<Appointment> observableList = FXCollections.observableArrayList();
Bindings.bindContent(observableList, lAgenda.selectedAppointments());
ListView<Appointment> listView = new ListView<>(lAgenda.selectedAppointments());
listView.getSelectionModel().selectedItemProperty().addListener(
new ChangeListener<Appointment>() {
public void changed(ObservableValue<? extends Appointment> ov,
Appointment old_val, Appointment new_val) {
System.out.println(new_val);
}
});
}
});
// initial set
Calendar lFirstDayOfWeekCalendar = getFirstDayOfWeekCalendar(lAgenda.getLocale(), lAgenda.getDisplayedCalendar());
int lYear = lFirstDayOfWeekCalendar.get(Calendar.YEAR);
int lMonth = lFirstDayOfWeekCalendar.get(Calendar.MONTH);
int lDay = lFirstDayOfWeekCalendar.get(Calendar.DATE);
lAgenda.appointments().addAll(
new Agenda.AppointmentImpl()
.withStartTime(new GregorianCalendar(lYear, lMonth, lDay, 8, 00))
.withEndTime(new GregorianCalendar(lYear, lMonth, lDay, 11, 30))
.withSummary("A")
.withDescription("A much longer test description")
.withAppointmentGroup(lAppointmentGroupMap.get("group7")), new Agenda.AppointmentImpl()
.withStartTime(new GregorianCalendar(lYear, lMonth, lDay, 8, 30))
.withEndTime(new GregorianCalendar(lYear, lMonth, lDay, 10, 00))
.withSummary("B")
.withDescription("A description 2")
.withAppointmentGroup(lAppointmentGroupMap.get("group8")), new Agenda.AppointmentImpl()
.withStartTime(new GregorianCalendar(lYear, lMonth, lDay, 8, 30))
.withEndTime(new GregorianCalendar(lYear, lMonth, lDay, 9, 30))
.withSummary("C")
.withDescription("A description 3")
.withAppointmentGroup(lAppointmentGroupMap.get("group9")), new Agenda.AppointmentImpl()
.withStartTime(new GregorianCalendar(lYear, lMonth, lDay, 9, 00))
.withEndTime(new GregorianCalendar(lYear, lMonth, lDay, 13, 30))
.withSummary("D")
.withDescription("A description 4")
.withAppointmentGroup(lAppointmentGroupMap.get("group7")), new Agenda.AppointmentImpl()
.withStartTime(new GregorianCalendar(lYear, lMonth, lDay, 10, 30))
.withEndTime(new GregorianCalendar(lYear, lMonth, lDay, 11, 00))
.withSummary("E")
.withDescription("A description 4")
.withAppointmentGroup(lAppointmentGroupMap.get("group7")), new Agenda.AppointmentImpl()
.withStartTime(new GregorianCalendar(lYear, lMonth, lDay, 12, 30))
.withEndTime(new GregorianCalendar(lYear, lMonth, lDay, 13, 30))
.withSummary("F")
.withDescription("A description 4")
.withAppointmentGroup(lAppointmentGroupMap.get("group7")), new Agenda.AppointmentImpl()
.withStartTime(new GregorianCalendar(lYear, lMonth, lDay, 13, 00))
.withEndTime(new GregorianCalendar(lYear, lMonth, lDay, 13, 30))
.withSummary("H")
.withDescription("A description 4")
.withAppointmentGroup(lAppointmentGroupMap.get("group7")), new Agenda.AppointmentImpl()
.withStartTime(new GregorianCalendar(lYear, lMonth, lDay, 14, 00))
.withEndTime(new GregorianCalendar(lYear, lMonth, lDay, 14, 45))
.withSummary("G")
.withDescription("A description 4")
.withAppointmentGroup(lAppointmentGroupMap.get("group7")), new Agenda.AppointmentImpl()
.withStartTime(new GregorianCalendar(lYear, lMonth, lDay, 15, 00))
.withEndTime(new GregorianCalendar(lYear, lMonth, lDay, 16, 00))
.withSummary("I")
.withDescription("A description 4")
.withAppointmentGroup(lAppointmentGroupMap.get("group7")), new Agenda.AppointmentImpl()
.withStartTime(new GregorianCalendar(lYear, lMonth, lDay, 15, 30))
.withEndTime(new GregorianCalendar(lYear, lMonth, lDay, 16, 00))
.withSummary("J")
.withDescription("A description 4")
.withAppointmentGroup(lAppointmentGroupMap.get("group7")) // -----
, new Agenda.AppointmentImpl()
.withStartTime(new GregorianCalendar(lYear, lMonth, lDay))
.withSummary("all day1")
.withDescription("A description")
.withAppointmentGroup(lAppointmentGroupMap.get("group7"))
.withWholeDay(true), new Agenda.AppointmentImpl()
.withStartTime(new GregorianCalendar(lYear, lMonth, lDay))
.withSummary("all day2")
.withDescription("A description")
.withAppointmentGroup(lAppointmentGroupMap.get("group8"))
.withWholeDay(true), new Agenda.AppointmentImpl()
.withStartTime(new GregorianCalendar(lYear, lMonth, lDay))
.withSummary("all day3")
.withDescription("A description3")
.withAppointmentGroup(lAppointmentGroupMap.get("group9"))
.withWholeDay(true), new Agenda.AppointmentImpl()
.withStartTime(new GregorianCalendar(lYear, lMonth, lDay + 1))
.withSummary("all day")
.withDescription("A description3")
.withAppointmentGroup(lAppointmentGroupMap.get("group3"))
.withWholeDay(true)
);
final String lIpsum = "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus, metus";
// day spanner
{
Calendar lStart = (Calendar) lFirstDayOfWeekCalendar.clone();
lStart.add(Calendar.SECOND, 5);
lStart.add(Calendar.DATE, 1);
Calendar lEnd = (Calendar) lStart.clone();
lEnd.add(Calendar.DATE, 2);
Agenda.Appointment lAppointment = new Agenda.AppointmentImpl()
.withStartTime(lStart)
.withEndTime(lEnd)
.withSummary(lIpsum.substring(0, new Random().nextInt(50)))
.withDescription(lIpsum.substring(0, 10 + new Random().nextInt(lIpsum.length() - 10)))
.withAppointmentGroup(lAppointmentGroupMap.get("group" + (new Random().nextInt(3) + 1)));
lAgenda.appointments().add(lAppointment);
}
// update range
final AtomicBoolean lSkippedFirstRangeChange = new AtomicBoolean(false);
lAgenda.calendarRangeCallbackProperty().set(new Callback<Agenda.CalendarRange, Void>() {
public Void call(Agenda.CalendarRange arg0) {
// the first change should not be processed, because it is set above
if (lSkippedFirstRangeChange.get() == false) {
lSkippedFirstRangeChange.set(true);
return null;
}
// add a whole bunch of random appointments
for (int i = 0; i < 20; i++) {
Calendar lFirstDayOfWeekCalendar = getFirstDayOfWeekCalendar(lAgenda.getLocale(), lAgenda.getDisplayedCalendar());
Calendar lStart = (Calendar) lFirstDayOfWeekCalendar.clone();
lStart.add(Calendar.DATE, new Random().nextInt(7));
lStart.add(Calendar.HOUR_OF_DAY, new Random().nextInt(24));
lStart.add(Calendar.MINUTE, new Random().nextInt(60));
Calendar lEnd = (Calendar) lStart.clone();
lEnd.add(Calendar.MINUTE, 15 + new Random().nextInt(24 * 60));
Agenda.Appointment lAppointment = new Agenda.AppointmentImpl()
.withStartTime(lStart)
.withEndTime(lEnd)
.withWholeDay(new Random().nextInt(50) > 40)
.withSummary(lIpsum.substring(0, new Random().nextInt(50)))
.withDescription(lIpsum.substring(0, new Random().nextInt(lIpsum.length())))
.withAppointmentGroup(lAppointmentGroupMap.get("group" + (new Random().nextInt(24))));
lAgenda.appointments().add(lAppointment);
}
return null;
}
});
lAgenda.selectedAppointments().addListener(new ListChangeListener< Appointment>() {
public void onChanged(ListChangeListener.Change<? extends Appointment> c) {
while (c.next()) {
if (c.wasPermutated()) {
for (int i = c.getFrom(); i < c.getTo(); ++i) {
//permutate
}
} else if (c.wasUpdated()) {
//update item
} else {
for (Appointment a : c.getRemoved()) {
}
for (Appointment a : c.getAddedSubList()) {
printAppointment(a);
}
}
}
}
});
// ComboBox<String> lComboBox = new ComboBox<String>(FXCollections.observableArrayList("Single", "Range", "Multiple"));
// lComboBox.valueProperty().addListener(new ChangeListener<String>()
// {
// @Override
// public void changed(ObservableValue<? extends String> observableValue, String oldValue, String newValue)
// {
// if (newValue.startsWith("S")) lAgenda.setMode(Agenda.Mode.SINGLE);
// if (newValue.startsWith("R")) lAgenda.setMode(Agenda.Mode.RANGE);
// if (newValue.startsWith("M")) lAgenda.setMode(Agenda.Mode.MULTIPLE);
// }
// });
// lComboBox.setValue("Single");
// lComboBox.setPrefWidth(200);
// lGridPane.add(new Label("Mode:"), 0, lRowIdx);
// lGridPane.add(lComboBox, 1, lRowIdx);
// lRowIdx++;
}
}
/**
* get the calendar for the first day of the week
*/
static private Calendar getFirstDayOfWeekCalendar(Locale locale, Calendar c) {
// result
int lFirstDayOfWeek = Calendar.getInstance(locale).getFirstDayOfWeek();
int lCurrentDayOfWeek = c.get(Calendar.DAY_OF_WEEK);
int lDelta = 0;
if (lFirstDayOfWeek <= lCurrentDayOfWeek) {
lDelta = -lCurrentDayOfWeek + lFirstDayOfWeek;
} else {
lDelta = -lCurrentDayOfWeek - (7 - lFirstDayOfWeek);
}
c = ((Calendar) c.clone());
c.add(Calendar.DATE, lDelta);
return c;
}
static class ColorRectCell extends ListCell<String> {
@Override
public void updateItem(String item, boolean empty) {
super.updateItem(item, empty);
Rectangle rect = new Rectangle(100, 20);
if (item != null) {
rect.setFill(Color.web(item));
setGraphic(rect);
}
}
}
void printAppointment(Appointment a) {
System.out.println(a.getSummary());
System.out.println(a.getDescription());
DateFormat formatter = new SimpleDateFormat("yyyy. MMM EEE.d h:mma");
System.out.println(formatter.format(a.getStartTime().getTime()));
System.out.println(formatter.format(a.getEndTime().getTime()));
System.out.println(a.getAppointmentGroup());
System.out.println(a.getLocation());
this.daysBetween(a.getStartTime().getTimeInMillis(), a.getEndTime().getTimeInMillis());
}
private void daysBetween(long t1, long t2) {
int diff = (int) (t2 - t1);
long diffSeconds = diff / 1000;
long diffMinutes = diff / (60 * 1000);
long diffHours = diff / (60 * 60 * 1000);
long diffDays = diff / (24 * 60 * 60 * 1000);
System.out.println("diffSeconds difference = " + diffSeconds);
System.out.println("diffMinutes difference = " + diffMinutes);
System.out.println("diffHours difference = " + diffHours);
System.out.println("diffDays difference = " + diffDays);
}
}
最佳答案
Maven 2.2 is end of life并且不再受支持 - 所以不要使用它,而是使用当前版本(当前为 Maven 3)。
您遇到的特定错误是因为您尝试编译的代码使用 Java 7 功能,但您的项目未设置为启用这些功能(即使您正在使用 Java 8 运行)。
编译器源、目标和目标选项设置为maven compiler plugin ,目前在其 3.1 版本文档中指出:
at present the default source setting is 1.5 and the default target setting is 1.5, independently of the JDK you run Maven with. If you want to change these defaults, you should set source and target.
有关如何为 compiler source and target 配置 Maven 的说明Java 8(您正在使用的 Java 版本)的版本是:
<project>
[...]
<build>
[...]
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
[...]
</build>
[...]
</project>
关于java - 通过maven编译议程代码错误: AgendaSample1Impl. java :[47, 81]错误: diamond operator is not supported in -source 1. 5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24561725/
我有一个包含用户及其每周日历的 mysql 表。 每个用户都可以设置自己一周的空闲时间(早上、下午、晚上/周一到周六),并且不会经常更改,几乎永远不会更改。 想象一下,这些用户是健身房的私有(priv
我无法动态更改选定的日期。例如,我想在离开屏幕时将选定的日期更改为今天;我不想在今天以外的其他日期离开...我该怎么做?我正在使用议程。另外,我想在用户单击该屏幕中的某个按钮时更改选定的日期。如果我只
如何添加操作监听器,以便在单击议程上的约会时打开一个新窗口,其中包含有关该特定单击约会的更多详细信息。 最佳答案 Agenda 似乎没有相应的 api。您可以看到议程的来源:AbstractAppoi
我在使用带有议程 View 的全日历时遇到了一些问题。在周 View 中,网格内没有垂直边框,如您在这张图片中所见: http://cjoint.com/14av/DDlkmc7Kjgp.htm在基本
议程/cron 支持这种情况的重复吗?示例:在周一和周二每两周重复一次工作,我可以每两周重复一次工作,但不能在特定日期重复一次工作,如果是,时间间隔的表达式是什么。周和日都可以是动态的。谢谢 最佳答案
我想在每天 8:30 到 17:00 的日程 View 中只显示营业时间, 像下面这样: 最佳答案 您是在问如何隐藏营业时间以外的时间吗?如果是这样,请使用 minTime 和 maxTime 选项:
从议程 View 中,我想按一个键并从该 TODO 条目中删除 SCHEDULED: 行。 最佳答案 按 C-u C-c C-s 要重建议程缓冲区,请按 r 请参阅 The manual 中的议程命
使用 Agenda ,是否可以设置作业在失败后多次重试? 最佳答案 不直接支持重试作为选项,但通过将失败的作业 nextRunAt 设置为 future 时间,它有一个简单的解决方法。 引用这篇文章:
我已将 FullCalendar 版本从 v. 2.3.1 更新到 2.4.0,之前一切正常,但现在在 周 View 和 议程 View 中 我无法添加该事件。这件事很奇怪,因为在月 View 中我看
我希望 Org-mode 议程在我打开 Emacs 时自动显示我今天必须做的事情。 org-agenda 命令是交互式的,因此它似乎不适用于此目的。 有没有办法在 Emacs 启动时显示 Org-mo
最近,我开始使用来自以下 repo 的日历控件:https://github.com/wix/react-native-calendars最初日历控件正确对齐所有项目,但似乎有些东西完全破坏了对齐。
我通过表单从用户那里收集了 Activity 日期、标题、地点、参加者、开始和结束时间、位置和其他元数据,然后存储在 mysql 数据库表中。我想从数据库中检索事件并以 Google 日历样式列出它们
我正在使用来自 http://jfxtras.org/ 的 FXtras(版本 8.0-r5)议程,我在其中定义了两种类型的约会:个人(group1)和共享(group2)。用户可以编辑个人约会的时间
我想安排这样的任务: 安排 11 月 1 日开始的任务 之后每个月重复该任务 我不想在任务安排在 11 月 1 日才开始的那一刻运行它。 我正在使用 Agenda.js我需要确保我正确地执行了此操作,
我尝试使用以下 CSS 隐藏 kendo 调度程序议程 View 中的时间列。 .k-scheduler-timecolumn{ visibility:collapse !important;
我是一名优秀的程序员,十分优秀!