stage.setScene(scene);
stage.show();
stage.setOnCloseRequest(new EventHandler<WindowEvent>() {
public void handle(WindowEvent we) {
System.out.println("Stage is closing");
}
});
2013/08/31
javaFx treeView color style
cannot use the [setStytle] methord...
because there is no such methord of treeItem
can set the style by rewrite the CellFactory
--------
treeView
.setCellFactory(new Callback<TreeView<Object>, TreeCell<Object>>() {
public TreeCell<Object> call(TreeView<Object> param) {
return new TreeCell<Object>() {
public void updateItem(Object item, boolean empty) {
super.updateItem(item, empty);
if (empty) {
setText(null);
setGraphic(null);
} else {
.......
setStyle(..........)
. ....
}
}
}
}
--------
because there is no such methord of treeItem
can set the style by rewrite the CellFactory
--------
treeView
.setCellFactory(new Callback<TreeView<Object>, TreeCell<Object>>() {
public TreeCell<Object> call(TreeView<Object> param) {
return new TreeCell<Object>() {
public void updateItem(Object item, boolean empty) {
super.updateItem(item, empty);
if (empty) {
setText(null);
setGraphic(null);
} else {
.......
setStyle(..........)
. ....
}
}
}
}
--------
2013/08/30
hibernate setparameter null
かなり不便だね。。。
=>解決方法
・Criteria=>Restrictions.eqOrIsNull("status", status)
・面倒なやり方:
String statusTerm = status==null ? "is null" : "= :status";
後で判断する
if(status!=null){
query.setParameter("status", status, Hibernate.STRING)
}
=>解決方法
・Criteria=>Restrictions.eqOrIsNull("status", status)
・面倒なやり方:
String statusTerm = status==null ? "is null" : "= :status";
後で判断する
if(status!=null){
query.setParameter("status", status, Hibernate.STRING)
}
2013/08/29
ruby xml操作 REXML
ーファイルーー
<root>
<a name="a1">
<b>bbb1</b>
<b>bbb2</b>
<b>bbb3</b>
<c>ccc1</c>
</a>
<a>
<b>bbb4</b>
<b>bbb5</b>
</a>
<a name="a3" price="100"></a>
</root>
puts doc.elements['root/a/b'].text
=>bbb1
puts doc.elements['root/a[2]/b[2]'].text
=>bbb5
doc.elements.each('root/a/b') do |element|
puts element.text
end
=>bbb1~bbb5
doc.elements.each('root/a[1]/b[2]') do |element|
puts element.previous_element.text
end
=>bbb1
doc.elements.each('root/a[1]/b[2]') do |element|
puts element.next_element.text
end
=>bbb3
doc.elements.each('root/a[1]') do |element|
puts element.name
end
=>a
doc.elements.each('root/a[2]') do |element|
puts element.elements.size
end
=>2
doc.elements.each('root/a[3]') do |element|
puts element.attributes["name"]
end
=>a3
hash = Hash.new
doc.elements.each('root/a[3]') do |element|
hash = element.attributes
end
puts hash.size #=>2
puts hash["name"] #=>a3
doc.elements.each("root/a[@name='a1']/b") do |element|
puts element.text
end
=>bbb1
bbb2
bbb3
puts doc.elements["root/a[@name='a3']"].attributes['price']
=>100
更新する
doc = Document.new File.new("guitars.xml")
elements["color"].text = "Red"
File.write("guitars.xml",doc)
rubyの古いバージョンで上記はエラーになった。
open(path, "w") {|f| f.write doc}
<root>
<a name="a1">
<b>bbb1</b>
<b>bbb2</b>
<b>bbb3</b>
<c>ccc1</c>
</a>
<a>
<b>bbb4</b>
<b>bbb5</b>
</a>
<a name="a3" price="100"></a>
</root>
puts doc.elements['root/a/b'].text
=>bbb1
puts doc.elements['root/a[2]/b[2]'].text
=>bbb5
doc.elements.each('root/a/b') do |element|
puts element.text
end
=>bbb1~bbb5
doc.elements.each('root/a[1]/b[2]') do |element|
puts element.previous_element.text
end
=>bbb1
doc.elements.each('root/a[1]/b[2]') do |element|
puts element.next_element.text
end
=>bbb3
doc.elements.each('root/a[1]') do |element|
puts element.name
end
=>a
doc.elements.each('root/a[2]') do |element|
puts element.elements.size
end
=>2
doc.elements.each('root/a[3]') do |element|
puts element.attributes["name"]
end
=>a3
hash = Hash.new
doc.elements.each('root/a[3]') do |element|
hash = element.attributes
end
puts hash.size #=>2
puts hash["name"] #=>a3
doc.elements.each("root/a[@name='a1']/b") do |element|
puts element.text
end
=>bbb1
bbb2
bbb3
puts doc.elements["root/a[@name='a3']"].attributes['price']
=>100
更新する
doc = Document.new File.new("guitars.xml")
elements["color"].text = "Red"
File.write("guitars.xml",doc)
rubyの古いバージョンで上記はエラーになった。
open(path, "w") {|f| f.write doc}
linux df 単位 sort
df [options] [file...]
主なオプション
-k キロバイト(1,024バイト)単位でサイズを表示
-m メガバイト(1,048,576バイト)単位でサイズを表示
-h サイズに合わせてキロ/メガ/ギガ単位と人が読みやすい単位で表示
-i inode の使用状況をリスト表示
sortと組み合わせて、
★linux sort
・sort -nr
-n 数値順に評価する、デフォルトはアルファベット順
-r 逆順
・sort -k3
-k ソートフィールド指定する
アルファベット順にソートし、第 1・第 2 フィールドは無視する。
3フィールドから末までが比較される。
・sort -t : -k 2,2n -k 5.3,5.4
-t フィールドSEPARATOR
第 2 フィールドの初めから第二文字まで数値的にソートし、
同じになったものを第 5 フィールドの第 3?第 4 文字で更にソートする。
フィールドの区切りとして `:' を用いる。
主なオプション
-k キロバイト(1,024バイト)単位でサイズを表示
-m メガバイト(1,048,576バイト)単位でサイズを表示
-h サイズに合わせてキロ/メガ/ギガ単位と人が読みやすい単位で表示
-i inode の使用状況をリスト表示
sortと組み合わせて、
★linux sort
・sort -nr
-n 数値順に評価する、デフォルトはアルファベット順
-r 逆順
・sort -k3
-k ソートフィールド指定する
アルファベット順にソートし、第 1・第 2 フィールドは無視する。
3フィールドから末までが比較される。
・sort -t : -k 2,2n -k 5.3,5.4
-t フィールドSEPARATOR
第 2 フィールドの初めから第二文字まで数値的にソートし、
同じになったものを第 5 フィールドの第 3?第 4 文字で更にソートする。
フィールドの区切りとして `:' を用いる。
2013/08/26
database catalog schema
いずれもも抽象的な物、名前衝突を防ぐために。。
SQL標準では
catalogー>schemaー>tables,view...
各DBの状況は違う。
SQL標準では
catalogー>schemaー>tables,view...
各DBの状況は違う。
2013/08/21
mysql_config_editor target file
mysql_config_editor の正体
ホームディレクトリしたの
.mylogin.cnf
である
mysql_config_editor print --all
ホームディレクトリしたの
.mylogin.cnf
である
mysql_config_editor print --all
mysql see binlog
=>mysqlbinlog
mysqlbinlog mysql-bin.000100 > /tmp/statement.sql
mysqlbinlog mysql-bin.000100 > /tmp/statement.sql
mysql root password 変更
sudo mysqld_safe --skip-grant-tables
mysql -u root mysql
update user set password=PASSWORD('newPassword') where user='root' and host='localhost';
FLUSH PRIVILEGES;
再起動する
mysql -u root mysql
update user set password=PASSWORD('newPassword') where user='root' and host='localhost';
FLUSH PRIVILEGES;
再起動する
2013/08/19
hibernate Envers Audited 操作履歴
名前通り、操作の履歴を残す..............
keep a record of the changes made in domain entity
@Entity
@Audited
public class MyEntity {
...
}
For each audited entity,a table will be created,
which will hold the history of changes made to the entity
・呼び出す:
AuditReader reader = AuditReaderFactory.get( entityManager );
Event firstRevision = reader.find( Event.class, 2L, 1 );
keep a record of the changes made in domain entity
@Entity
@Audited
public class MyEntity {
...
}
For each audited entity,a table will be created,
which will hold the history of changes made to the entity
・呼び出す:
AuditReader reader = AuditReaderFactory.get( entityManager );
Event firstRevision = reader.find( Event.class, 2L, 1 );