svnno****@sourc*****
svnno****@sourc*****
2009年 4月 7日 (火) 18:58:53 JST
Revision: 3157 http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=3157 Author: daisuke_m Date: 2009-04-07 18:58:53 +0900 (Tue, 07 Apr 2009) Log Message: ----------- EmitConfig#emitCreateSchemaStatement() を追加し、CREATE SCHEMA文の出力を調整可能にした。 / commonsのテストケースをcoreからcommonsに移動。 / vesta-uiにおけるinternal依存を回避。 / DBテストの整備。 / javadoc / refactor Modified Paths: -------------- artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/DatabaseTest.java artemis/trunk/jiemamy-artemis-test/src/test/resources/database_hudson.properties artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/exporter/DefaultSqlExportConfig.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/internal/impl/DefaultSqlEmitter.java artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/model/AbstractElementReference.java artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/dialect/DefaultSqlEmitterTest.java artemis/trunk/jiemamy-dialect-mysql/src/test/java/org/jiemamy/dialect/mysql/MySqlEmitterTest.java eros/maven-jiemamy-plugin/trunk/src/test/java/org/jiemamy/maven/JiemamyMojoTest.java hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/action/AutoLayoutAction.java hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/action/ChangeNodeBackgroundColorAction.java hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/action/SaveDiagramImageAction.java hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/composer/SqlExportWizard.java hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/composer/SqlExportWizardPage.java hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/DiagramEditor.java hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/DiagramEditorContextMenuProvider.java hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/tools/MultiLineTextCellEditor.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResourceBundleUtil.java leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResourceTraversal.java metis/trunk/src/main/java/com/docbook/extract/Extractor.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/dialect/EmitConfig.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/attribute/RepresentationAdapter.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/adapter/PrecisionedDataTypeAdapter.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/adapter/SerialDataTypeAdapter.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/adapter/SizedDataTypeAdapter.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/adapter/TimezonedDataTypeAdapter.java zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/package-info.java Added Paths: ----------- hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/ui/FileSelectWizardPage.java leto/jiemamy-commons/trunk/src/test/java/org/ leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/ leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/ leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/JmStringUtilTest.java leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/ListUtilTest.java leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/ReflectionUtilTest.java leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/UUIDUtilTest.java Removed Paths: ------------- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/JmStringUtilTest.java artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/ListUtilTest.java artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/ReflectionUtilTest.java artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/UUIDUtilTest.java hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/composer/FileSelectWizardPage.java hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/extension/ hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/ui/FolderSelectWizardPage.java hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/view/ -------------- next part -------------- Modified: artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/DatabaseTest.java =================================================================== --- artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/DatabaseTest.java 2009-04-07 08:50:52 UTC (rev 3156) +++ artemis/trunk/jiemamy-artemis-test/src/test/java/org/jiemamy/DatabaseTest.java 2009-04-07 09:58:53 UTC (rev 3157) @@ -28,13 +28,13 @@ import java.util.List; import java.util.Properties; +import org.apache.commons.beanutils.BeanUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.jiemamy.composer.exporter.DefaultSqlExportConfig; -import org.jiemamy.composer.importer.DatabaseImportConfig; +import org.jiemamy.composer.importer.DefaultDatabaseImportConfig; import org.jiemamy.dialect.Dialect; -import org.jiemamy.dialect.generic.GenericDialect; import org.jiemamy.internal.test.TestModelBuilders; import org.jiemamy.internal.test.TestModelsTestBase; import org.jiemamy.model.RootModel; @@ -79,54 +79,13 @@ assertThat(connection, is(notNullValue())); DatabaseCleaner databaseCleaner = new DatabaseCleaner(); - databaseCleaner.clean(new DatabaseImportConfig() { - - public Dialect getDialect() { - try { - return jiemamy.getDialect(jiemamy.getFactory().getRootModel()); - } catch (ClassNotFoundException e) { - } - return new GenericDialect(); - } - - public String getDriverClassName() { - return connectionConfig.getDriverClassName(); - } - - public URL[] getDriverJarPaths() { - return connectionConfig.getDriverJarPaths(); - } - - public String[] getEntityTypes() { - return null; - } - - public String getPassword() { - return connectionConfig.getPassword(); - } - - public String getSchema() { - return jiemamy.getFactory().getRootModel().getSchemaName(); - } - - public String[] getSelectedEntities() { - return new String[0]; - } - - public String getUri() { - return connectionConfig.getUri(); - } - - public String getUsername() { - return connectionConfig.getUsername(); - } - - public boolean isImportDataSet() { - return false; - } - - }); + DefaultDatabaseImportConfig importConfig = new DefaultDatabaseImportConfig(); + BeanUtils.copyProperties(connectionConfig, importConfig); + importConfig.setDialect(jiemamy.getDialect(jiemamy.getFactory().getRootModel())); + importConfig.setSchema(jiemamy.getFactory().getRootModel().getSchemaName()); + databaseCleaner.clean(importConfig); + SqlExecuter executer = new SqlExecuter(connection); for (SqlStatement stmt : statements) { Modified: artemis/trunk/jiemamy-artemis-test/src/test/resources/database_hudson.properties =================================================================== --- artemis/trunk/jiemamy-artemis-test/src/test/resources/database_hudson.properties 2009-04-07 08:50:52 UTC (rev 3156) +++ artemis/trunk/jiemamy-artemis-test/src/test/resources/database_hudson.properties 2009-04-07 09:58:53 UTC (rev 3157) @@ -10,9 +10,9 @@ MySQL_user = jiemamy01 MySQL_password = dummy -Oracle_driverJar = TODO +Oracle_driverJar = /usr/local/jdbc/ojdbc14.jar Oracle_driverClass = oracle.jdbc.driver.OracleDriver -Oracle_uri = jdbc:oracle:thin:@griffon.jiemamy.org:1521:jiemamy01 +Oracle_uri = jdbc:oracle:thin:@griffon.jiemamy.org:1521:XE Oracle_user = jiemamy01 Oracle_password = dummy Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/exporter/DefaultSqlExportConfig.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/exporter/DefaultSqlExportConfig.java 2009-04-07 08:50:52 UTC (rev 3156) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/composer/exporter/DefaultSqlExportConfig.java 2009-04-07 09:58:53 UTC (rev 3157) @@ -25,6 +25,9 @@ */ public class DefaultSqlExportConfig extends AbstractFileExportConfig implements SqlExportConfig { + /** CREATE SCHAMA文を出力するかどうか */ + private boolean emitCreateSchema; + /** CREATE文の前にDROP文を出力するかどうか */ private boolean emitDropStatements; @@ -32,6 +35,10 @@ private int dataSetIndex; + public boolean emitCreateSchemaStatement() { + return emitCreateSchema; + } + public boolean emitDropStatements() { return emitDropStatements; } @@ -41,6 +48,15 @@ } /** + * CREATE文の前にCREATE SCHAMA文を出力するかどうかを設定する。 + * + * @param emitCreateSchema 出力する場合は{@code true}、そうでない場合は{@code false} + */ + public void setEmitCreateSchema(boolean emitCreateSchema) { + this.emitCreateSchema = emitCreateSchema; + } + + /** * 出力するデータセットのインデックスを設定する。 * * <p>INSERT文を出力しない場合は、負数を設定する。</p> Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/internal/impl/DefaultSqlEmitter.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/internal/impl/DefaultSqlEmitter.java 2009-04-07 08:50:52 UTC (rev 3156) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/dialect/internal/impl/DefaultSqlEmitter.java 2009-04-07 09:58:53 UTC (rev 3157) @@ -101,7 +101,7 @@ result.add(new SqlStatementImpl(Literal.of(rootModel.getBeginScript(), LiteralType.FRAGMENT))); } - if (StringUtils.isEmpty(rootModel.getSchemaName()) == false) { + if (StringUtils.isEmpty(rootModel.getSchemaName()) == false && config.emitCreateSchemaStatement()) { if (config.emitDropStatements()) { result.add(emitDropSchemaStatement(rootModel.getSchemaName())); } Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/model/AbstractElementReference.java =================================================================== --- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/model/AbstractElementReference.java 2009-04-07 08:50:52 UTC (rev 3156) +++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/model/AbstractElementReference.java 2009-04-07 09:58:53 UTC (rev 3157) @@ -84,7 +84,7 @@ if (other.referenceId != null) { return false; } - } else if (!referenceId.equals(other.referenceId)) { + } else if (referenceId.equals(other.referenceId) == false) { return false; } return true; Modified: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/dialect/DefaultSqlEmitterTest.java =================================================================== --- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/dialect/DefaultSqlEmitterTest.java 2009-04-07 08:50:52 UTC (rev 3156) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/dialect/DefaultSqlEmitterTest.java 2009-04-07 09:58:53 UTC (rev 3157) @@ -64,6 +64,10 @@ private static class MockEmitConfig implements EmitConfig { + public boolean emitCreateSchemaStatement() { + return false; + } + public boolean emitDropStatements() { return false; } Deleted: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/JmStringUtilTest.java =================================================================== --- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/JmStringUtilTest.java 2009-04-07 08:50:52 UTC (rev 3156) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/JmStringUtilTest.java 2009-04-07 09:58:53 UTC (rev 3157) @@ -1,193 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/01/29 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.utils; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -/** - * {@link JmStringUtil}のテストクラス。 - * - * @author daisuke - */ -public class JmStringUtilTest { - - private String[] array; - - - /** - * テストを初期化する。 - * - * @throws Exception 例外が発生した場合 - */ - @Before - public void setUp() throws Exception { - array = new String[] { - "foo", - "bar", - "baz" - }; - } - - /** - * テストの情報を破棄する。 - * - * @throws Exception 例外が発生した場合 - */ - @After - public void tearDown() throws Exception { - array = null; - } - - /** - * Test method for {@link JmStringUtil#containsIgnoreCase(String[], String)}. - */ - @Test - public void testContainsIgnoreCase() { - assertThat(JmStringUtil.containsIgnoreCase(array, "foo"), is(true)); - assertThat(JmStringUtil.containsIgnoreCase(array, "bar"), is(true)); - assertThat(JmStringUtil.containsIgnoreCase(array, "baz"), is(true)); - assertThat(JmStringUtil.containsIgnoreCase(array, "qux"), is(false)); - - assertThat(JmStringUtil.containsIgnoreCase(array, "FOO"), is(true)); - assertThat(JmStringUtil.containsIgnoreCase(array, "Bar"), is(true)); - assertThat(JmStringUtil.containsIgnoreCase(array, "bAz"), is(true)); - assertThat(JmStringUtil.containsIgnoreCase(array, "quX"), is(false)); - } - - /** - * Test method for {@link JmStringUtil#indexOfIgnoreCase(String[], String)}. - */ - @Test - public void testIndexOfIgnoreCaseStringArrayString() { - assertThat(JmStringUtil.indexOfIgnoreCase(array, "foo"), is(0)); - assertThat(JmStringUtil.indexOfIgnoreCase(array, "bar"), is(1)); - assertThat(JmStringUtil.indexOfIgnoreCase(array, "baz"), is(2)); - assertThat(JmStringUtil.indexOfIgnoreCase(array, "qux"), is(-1)); - - assertThat(JmStringUtil.indexOfIgnoreCase(array, "FOO"), is(0)); - assertThat(JmStringUtil.indexOfIgnoreCase(array, "Bar"), is(1)); - assertThat(JmStringUtil.indexOfIgnoreCase(array, "bAz"), is(2)); - assertThat(JmStringUtil.indexOfIgnoreCase(array, "quX"), is(-1)); - } - - /** - * Test method for {@link JmStringUtil#indexOfIgnoreCase(String[], String, int)}. - */ - @Test - public void testIndexOfIgnoreCaseStringArrayStringInt() { - assertThat(JmStringUtil.indexOfIgnoreCase(array, "foo", 1), is(-1)); - assertThat(JmStringUtil.indexOfIgnoreCase(array, "bar", 1), is(1)); - assertThat(JmStringUtil.indexOfIgnoreCase(array, "baz", 1), is(2)); - assertThat(JmStringUtil.indexOfIgnoreCase(array, "qux", 1), is(-1)); - - assertThat(JmStringUtil.indexOfIgnoreCase(array, "FOO", 1), is(-1)); - assertThat(JmStringUtil.indexOfIgnoreCase(array, "Bar", 1), is(1)); - assertThat(JmStringUtil.indexOfIgnoreCase(array, "bAz", 1), is(2)); - assertThat(JmStringUtil.indexOfIgnoreCase(array, "quX", 1), is(-1)); - } - - /** - * Test method for {@link JmStringUtil#toCapital(String)}. - */ - @Test - public void testToCapital() { - assertThat(JmStringUtil.toCapital("foo"), is("Foo")); - assertThat(JmStringUtil.toCapital("fooBar"), is("FooBar")); - assertThat(JmStringUtil.toCapital("qName"), is("QName")); - } - - /** - * Test method for {@link JmStringUtil#toJavaClassName(String)}. - */ - @Test - public void testToJavaClassNameString() { - assertThat(JmStringUtil.toJavaClassName("foo"), is("Foo")); -// assertThat(JmStringUtil.toJavaClassName("fooBar"), is("FooBar")); - assertThat(JmStringUtil.toJavaClassName("FOO_BAR"), is("FooBar")); - assertThat(JmStringUtil.toJavaClassName("Q_NAME"), is("QName")); - assertThat(JmStringUtil.toJavaClassName("SQL_STRING"), is("SqlString")); - } - - /** - * Test method for {@link JmStringUtil#toJavaClassName(String, String)}. - */ - @Test - public void testToJavaClassNameStringString() { - assertThat(JmStringUtil.toJavaClassName("HOGE_foo", "HOGE"), is("Foo")); -// assertThat(JmStringUtil.toJavaClassName("HOGE_fooBar", "HOGE"), is("FooBar")); - assertThat(JmStringUtil.toJavaClassName("HOGE_FOO_BAR", "HOGE"), is("FooBar")); - assertThat(JmStringUtil.toJavaClassName("HOGE_Q_NAME", "HOGE"), is("QName")); - assertThat(JmStringUtil.toJavaClassName("HOGE_SQL_STRING", "HOGE"), is("SqlString")); - } - - /** - * Test method for {@link JmStringUtil#toJavaName(String)}. - */ - @Test - public void testToJavaNameString() { - assertThat(JmStringUtil.toJavaName("foo"), is("foo")); -// assertThat(JmStringUtil.toJavaName("fooBar"), is("fooBar")); - assertThat(JmStringUtil.toJavaName("FOO_BAR"), is("fooBar")); - assertThat(JmStringUtil.toJavaName("Q_NAME"), is("qName")); - assertThat(JmStringUtil.toJavaName("SQL_STRING"), is("sqlString")); - } - - /** - * Test method for {@link JmStringUtil#toJavaName(String, String)}. - */ - @Test - public void testToJavaNameStringString() { -// fail("Not yet implemented"); - } - - /** - * Test method for {@link JmStringUtil#toSQLName(String, String)}. - */ - @Test - public void testToSQLName() { - assertThat(JmStringUtil.toSQLName("foo"), is("FOO")); -// assertThat(JmStringUtil.toSQLName("Foo"), is("FOO")); -// assertThat(JmStringUtil.toSQLName("FOO"), is("FOO")); - assertThat(JmStringUtil.toSQLName("fooBar"), is("FOO_BAR")); -// assertThat(JmStringUtil.toSQLName("FooBar"), is("FOO_BAR")); -// assertThat(JmStringUtil.toSQLName("FOO_BAR"), is("FOO_BAR")); - assertThat(JmStringUtil.toSQLName("qName"), is("Q_NAME")); -// assertThat(JmStringUtil.toSQLName("QName"), is("Q_NAME")); -// assertThat(JmStringUtil.toSQLName("Q_NAME"), is("Q_NAME")); - assertThat(JmStringUtil.toSQLName("sqlString"), is("SQL_STRING")); -// assertThat(JmStringUtil.toSQLName("SqlString"), is("SQL_STRING")); -// assertThat(JmStringUtil.toSQLName("SQL_STRING"), is("SQL_STRING")); - } - - /** - * Test method for {@link JmStringUtil#toUnCapital(String)}. - */ - @Test - public void testToUnCapital() { - assertThat(JmStringUtil.toUnCapital("Foo"), is("foo")); - assertThat(JmStringUtil.toUnCapital("FooBar"), is("fooBar")); - assertThat(JmStringUtil.toUnCapital("QName"), is("qName")); - } - -} Deleted: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/ListUtilTest.java =================================================================== --- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/ListUtilTest.java 2009-04-07 08:50:52 UTC (rev 3156) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/ListUtilTest.java 2009-04-07 09:58:53 UTC (rev 3157) @@ -1,134 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/02/23 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.utils; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; - -import java.util.ArrayList; -import java.util.List; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -/** - * {@link ListUtil}のテストクラス。 - * - * @author daisuke - */ -public class ListUtilTest { - - private List<String> list; - - - /** - * テストを初期化する。 - * - * @throws Exception 例外が発生した場合 - */ - @Before - public void setUp() throws Exception { - list = new ArrayList<String>(); - list.add("foo"); - list.add("bar"); - list.add("baz"); - } - - /** - * テストの情報を破棄する。 - * - * @throws Exception 例外が発生した場合 - */ - @After - public void tearDown() throws Exception { - list = null; - } - -// /** -// * {@link ListUtil#moveDown(List, int)}のテスト。 -// * -// * @throws Exception 例外が発生した場合 -// */ -// @Test -// public void test01_moveDown() throws Exception { -// try { -// ListUtil.moveDown(null, 0); -// fail(); -// } catch (IllegalArgumentException e) { -// // success -// } -// -// ListUtil.moveDown(list, 0); -// assertThat(list.get(0), is("bar")); -// assertThat(list.get(1), is("foo")); -// assertThat(list.get(2), is("baz")); -// -// ListUtil.moveDown(list, 1); -// assertThat(list.get(0), is("bar")); -// assertThat(list.get(1), is("baz")); -// assertThat(list.get(2), is("foo")); -// } -// -// /** -// * {@link ListUtil#moveUp(List, int)}のテスト。 -// * -// * @throws Exception 例外が発生した場合 -// */ -// @Test -// public void test02_moveUp() throws Exception { -// try { -// ListUtil.moveUp(list, -1); -// fail(); -// } catch (IllegalArgumentException e) { -// // success -// } -// -// ListUtil.moveUp(list, 1); -// assertThat(list.get(0), is("bar")); -// assertThat(list.get(1), is("foo")); -// assertThat(list.get(2), is("baz")); -// -// ListUtil.moveUp(list, 2); -// assertThat(list.get(0), is("bar")); -// assertThat(list.get(1), is("baz")); -// assertThat(list.get(2), is("foo")); -// } - - /** - * {@link ListUtil#reverse(List)}のテスト。 - * - * @throws Exception 例外が発生した場合 - */ - @Test - public void test03_reverse() throws Exception { - try { - ListUtil.reverse(null); - fail(); - } catch (IllegalArgumentException e) { - // success - } - - ListUtil.reverse(list); - assertThat(list.get(0), is("baz")); - assertThat(list.get(1), is("bar")); - assertThat(list.get(2), is("foo")); - } -} Deleted: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/ReflectionUtilTest.java =================================================================== --- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/ReflectionUtilTest.java 2009-04-07 08:50:52 UTC (rev 3156) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/ReflectionUtilTest.java 2009-04-07 09:58:53 UTC (rev 3157) @@ -1,291 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/01/29 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.utils; - -import static org.hamcrest.CoreMatchers.is; -import static org.junit.Assert.assertThat; -import static org.junit.Assert.fail; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; - -/** - * {@link ReflectionUtil}のテストクラス。 - * - * @author daisuke - */ -public class ReflectionUtilTest { - - private Method getFoo; - - private Method getBar; - - private Method isBaz; - - private Method getQux; - - private Method getQux2; - - private Method setFoo; - - private Method setBar; - - private Method setBaz; - - private Method setQux; - - private Method setQux2; - - private Field foo; - - private Field bar; - - private Field baz; - - private Field qux; - - - /** - * テストを初期化する。 - * - * @throws Exception 例外が発生した場合 - */ - @Before - public void setUp() throws Exception { - foo = TestBean.class.getDeclaredField("foo"); - bar = TestBean.class.getDeclaredField("bar"); - baz = TestBean.class.getDeclaredField("baz"); - qux = TestBean.class.getDeclaredField("qux"); - - getFoo = TestBean.class.getDeclaredMethod("getFoo"); - getBar = TestBean.class.getDeclaredMethod("getBar"); - isBaz = TestBean.class.getDeclaredMethod("isBaz"); - getQux = TestBean.class.getDeclaredMethod("getQux"); - getQux2 = TestBean.class.getDeclaredMethod("getQux2"); - - setFoo = TestBean.class.getDeclaredMethod("setFoo", int.class); - setBar = TestBean.class.getDeclaredMethod("setBar", String.class); - setBaz = TestBean.class.getDeclaredMethod("setBaz", boolean.class); - setQux = TestBean.class.getDeclaredMethod("setQux", Boolean.class); - setQux2 = TestBean.class.getDeclaredMethod("setQux2"); - } - - /** - * テストの情報を破棄する。 - * - * @throws Exception 例外が発生した場合 - */ - @After - public void tearDown() throws Exception { - getFoo = null; - getBar = null; - isBaz = null; - getQux = null; - getQux2 = null; - - setFoo = null; - setBar = null; - setBaz = null; - setQux = null; - setQux2 = null; - } - - /** - * Test method for {@link ReflectionUtil#convertFieldToAccessorName(java.lang.reflect.Field, String)}. - */ - @Test - public void testConvertFieldToAccessorName() { - assertThat(ReflectionUtil.convertFieldToAccessorName(foo, "get"), is("getFoo")); - assertThat(ReflectionUtil.convertFieldToAccessorName(bar, "get"), is("getBar")); - assertThat(ReflectionUtil.convertFieldToAccessorName(baz, "is"), is("isBaz")); - assertThat(ReflectionUtil.convertFieldToAccessorName(qux, "get"), is("getQux")); - - assertThat(ReflectionUtil.convertFieldToAccessorName(foo, "set"), is("setFoo")); - assertThat(ReflectionUtil.convertFieldToAccessorName(bar, "set"), is("setBar")); - assertThat(ReflectionUtil.convertFieldToAccessorName(baz, "set"), is("setBaz")); - assertThat(ReflectionUtil.convertFieldToAccessorName(qux, "set"), is("setQux")); - } - - /** - * Test method for {@link ReflectionUtil#convertFieldToGetterName(java.lang.reflect.Field)}. - */ - @Test - public void testConvertFieldToGetterName() { - assertThat(ReflectionUtil.convertFieldToGetterName(foo), is("getFoo")); - assertThat(ReflectionUtil.convertFieldToGetterName(bar), is("getBar")); - assertThat(ReflectionUtil.convertFieldToGetterName(baz), is("isBaz")); - assertThat(ReflectionUtil.convertFieldToGetterName(qux), is("isQux")); - } - - /** - * Test method for {@link ReflectionUtil#convertFieldToSetterName(java.lang.reflect.Field)}. - */ - @Test - public void testConvertFieldToSetterName() { - assertThat(ReflectionUtil.convertFieldToSetterName(foo), is("setFoo")); - assertThat(ReflectionUtil.convertFieldToSetterName(bar), is("setBar")); - assertThat(ReflectionUtil.convertFieldToSetterName(baz), is("setBaz")); - assertThat(ReflectionUtil.convertFieldToSetterName(qux), is("setQux")); - } - - /** - * Test method for {@link ReflectionUtil#convertAccessorToFieldName(java.lang.reflect.Method)}. - */ - @Test - public void testConvertGetterToFieldName() { - assertThat(ReflectionUtil.convertAccessorToFieldName(getFoo), is("foo")); - assertThat(ReflectionUtil.convertAccessorToFieldName(getBar), is("bar")); - assertThat(ReflectionUtil.convertAccessorToFieldName(isBaz), is("baz")); - assertThat(ReflectionUtil.convertAccessorToFieldName(getQux), is("qux")); - try { - ReflectionUtil.convertAccessorToFieldName(getQux2); - fail(); - } catch (IllegalArgumentException e) { - // success - } - - assertThat(ReflectionUtil.convertAccessorToFieldName(setFoo), is("foo")); - assertThat(ReflectionUtil.convertAccessorToFieldName(setBar), is("bar")); - assertThat(ReflectionUtil.convertAccessorToFieldName(setBaz), is("baz")); - assertThat(ReflectionUtil.convertAccessorToFieldName(setQux), is("qux")); - try { - ReflectionUtil.convertAccessorToFieldName(setQux2); - fail(); - } catch (IllegalArgumentException e) { - // success - } - - } - - /** - * Test method for {@link ReflectionUtil#isAccessor(java.lang.reflect.Method)}. - * - * @throws Exception 例外が発生した場合 - */ - @Test - public void testIsAccessor() throws Exception { - assertThat(ReflectionUtil.isAccessor(getFoo), is(true)); - assertThat(ReflectionUtil.isAccessor(getBar), is(true)); - assertThat(ReflectionUtil.isAccessor(isBaz), is(true)); - assertThat(ReflectionUtil.isAccessor(getQux), is(true)); - assertThat(ReflectionUtil.isAccessor(getQux2), is(false)); - - assertThat(ReflectionUtil.isAccessor(setFoo), is(true)); - assertThat(ReflectionUtil.isAccessor(setBar), is(true)); - assertThat(ReflectionUtil.isAccessor(setBaz), is(true)); - assertThat(ReflectionUtil.isAccessor(setQux), is(true)); - assertThat(ReflectionUtil.isAccessor(setQux2), is(false)); - } - - /** - * Test method for {@link ReflectionUtil#isGetter(java.lang.reflect.Method)}. - * - * @throws Exception 例外が発生した場合 - */ - @Test - public void testIsGetter() throws Exception { - assertThat(ReflectionUtil.isGetter(getFoo), is(true)); - assertThat(ReflectionUtil.isGetter(getBar), is(true)); - assertThat(ReflectionUtil.isGetter(isBaz), is(true)); - assertThat(ReflectionUtil.isGetter(getQux), is(true)); - assertThat(ReflectionUtil.isGetter(getQux2), is(false)); - - assertThat(ReflectionUtil.isGetter(setFoo), is(false)); - assertThat(ReflectionUtil.isGetter(setBar), is(false)); - assertThat(ReflectionUtil.isGetter(setBaz), is(false)); - assertThat(ReflectionUtil.isGetter(setQux), is(false)); - assertThat(ReflectionUtil.isGetter(setQux2), is(false)); - } - - /** - * Test method for {@link ReflectionUtil#isSetter(java.lang.reflect.Method)}. - * - * @throws Exception 例外が発生した場合 - */ - @Test - public void testIsSetter() throws Exception { - assertThat(ReflectionUtil.isSetter(getFoo), is(false)); - assertThat(ReflectionUtil.isSetter(getBar), is(false)); - assertThat(ReflectionUtil.isSetter(isBaz), is(false)); - assertThat(ReflectionUtil.isSetter(getQux), is(false)); - assertThat(ReflectionUtil.isSetter(getQux2), is(false)); - - assertThat(ReflectionUtil.isSetter(setFoo), is(true)); - assertThat(ReflectionUtil.isSetter(setBar), is(true)); - assertThat(ReflectionUtil.isSetter(setBaz), is(true)); - assertThat(ReflectionUtil.isSetter(setQux), is(true)); - assertThat(ReflectionUtil.isSetter(setQux2), is(false)); - } - - - class TestBean { - - private int foo; - - private String bar; - - private boolean baz; - - private Boolean qux; - - - String getBar() { - return bar; - } - - int getFoo() { - return foo; - } - - Boolean getQux() { - return qux; - } - - void getQux2() { - } - - boolean isBaz() { - return baz; - } - - void setBar(String bar) { - this.bar = bar; - } - - void setBaz(boolean baz) { - this.baz = baz; - } - - void setFoo(int foo) { - this.foo = foo; - } - - void setQux(Boolean qux) { - this.qux = qux; - } - - void setQux2() { - } - - } -} Deleted: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/UUIDUtilTest.java =================================================================== --- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/UUIDUtilTest.java 2009-04-07 08:50:52 UTC (rev 3156) +++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/utils/UUIDUtilTest.java 2009-04-07 09:58:53 UTC (rev 3157) @@ -1,50 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/12/17 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.utils; - -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.CoreMatchers.not; -import static org.junit.Assert.assertThat; - -import java.util.UUID; - -import org.junit.Test; - -/** - * {@link UUIDUtil}のテストクラス。 - * - * @author daisuke - */ -public class UUIDUtilTest { - - /** - * Test method for {@link org.jiemamy.utils.UUIDUtil#valueOfOrRandom(java.lang.String)}. - */ - @Test - public void testValueOfOrRandom() { - // UUID化できるStringを与えた場合 → fromString生成 - UUID uuid1 = UUIDUtil.valueOfOrRandom("ffffffff-ffff-ffff-ffff-ffffffffffff"); - assertThat(uuid1.toString(), is("ffffffff-ffff-ffff-ffff-ffffffffffff")); - - // UUID化できないStringを与えた場合 → randomUUID生成 - UUID uuid2 = UUIDUtil.valueOfOrRandom("hoge"); - assertThat(uuid2.toString(), not("hoge")); - } - -} Modified: artemis/trunk/jiemamy-dialect-mysql/src/test/java/org/jiemamy/dialect/mysql/MySqlEmitterTest.java =================================================================== --- artemis/trunk/jiemamy-dialect-mysql/src/test/java/org/jiemamy/dialect/mysql/MySqlEmitterTest.java 2009-04-07 08:50:52 UTC (rev 3156) +++ artemis/trunk/jiemamy-dialect-mysql/src/test/java/org/jiemamy/dialect/mysql/MySqlEmitterTest.java 2009-04-07 09:58:53 UTC (rev 3157) @@ -137,17 +137,7 @@ dataType.getAdapter(SerialDataTypeAdapter.class).setSerial(true); columnModel.setDataType(dataType); - List<SqlStatement> stmts = sqlEmitter.emit(rootModel, new EmitConfig() { - - public boolean emitDropStatements() { - return false; - } - - public int getDataSetIndex() { - return -1; - } - - }); + List<SqlStatement> stmts = sqlEmitter.emit(rootModel, new MockEmitConfig()); System.out.println(stmts.get(0)); assertThat(stmts.get(0).toString(), is("CREATE TABLE TABLE1(COLUMN1 INTEGER PRIMARY KEY AUTO_INCREMENT);")); } @@ -155,14 +145,17 @@ private static class MockEmitConfig implements EmitConfig { + public boolean emitCreateSchemaStatement() { + return false; + } + public boolean emitDropStatements() { - return true; + return false; } public int getDataSetIndex() { - return 0; + return -1; } - } } Modified: eros/maven-jiemamy-plugin/trunk/src/test/java/org/jiemamy/maven/JiemamyMojoTest.java =================================================================== --- eros/maven-jiemamy-plugin/trunk/src/test/java/org/jiemamy/maven/JiemamyMojoTest.java 2009-04-07 08:50:52 UTC (rev 3156) +++ eros/maven-jiemamy-plugin/trunk/src/test/java/org/jiemamy/maven/JiemamyMojoTest.java 2009-04-07 09:58:53 UTC (rev 3157) @@ -85,7 +85,7 @@ /** * エクスポート先にファイルが生成される。 * - * @throws Exception + * @throws Exception 例外が発生した場合 */ @Test public void test01_エクスポート先にファイルが生成される() throws Exception { Modified: hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/action/AutoLayoutAction.java =================================================================== --- hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/action/AutoLayoutAction.java 2009-04-07 08:50:52 UTC (rev 3156) +++ hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/action/AutoLayoutAction.java 2009-04-07 09:58:53 UTC (rev 3157) @@ -56,6 +56,10 @@ */ public class AutoLayoutAction extends AbstractJiemamyAction { + /** TODO for daisuke */ + private static final int PADDING = 40; + + private static Node getNode(List<Node> list, NodeAdapter model) { for (Node obj : list) { EntityNode node = (EntityNode) obj; @@ -129,7 +133,7 @@ } } DirectedGraph graph = new DirectedGraph(); - graph.setDefaultPadding(new Insets(40)); + graph.setDefaultPadding(new Insets(PADDING)); graph.nodes = (NodeList) graphNodes; graph.edges = (EdgeList) graphEdges; new DirectedGraphLayout().visit(graph); @@ -193,7 +197,7 @@ * * @param rootModel ルートモデル * @param diagramIndex ダイアグラムエディタのインデックス(エディタ内のタブインデックス) - * @param target + * @param target 対象ノード * @param x X座標 * @param y Y座標 */ Modified: hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/action/ChangeNodeBackgroundColorAction.java =================================================================== --- hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/action/ChangeNodeBackgroundColorAction.java 2009-04-07 08:50:52 UTC (rev 3156) +++ hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/action/ChangeNodeBackgroundColorAction.java 2009-04-07 09:58:53 UTC (rev 3157) @@ -61,7 +61,7 @@ } } - if (!editParts.isEmpty()) { + if (editParts.isEmpty() == false) { ColorDialog colorDialog = new ColorDialog(getViewer().getControl().getShell(), SWT.NULL); RGB rgb = colorDialog.open(); if (rgb != null) { Modified: hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/action/SaveDiagramImageAction.java =================================================================== --- hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/action/SaveDiagramImageAction.java 2009-04-07 08:50:52 UTC (rev 3156) +++ hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/action/SaveDiagramImageAction.java 2009-04-07 09:58:53 UTC (rev 3157) @@ -25,12 +25,6 @@ import java.util.List; import org.apache.commons.io.IOUtils; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.SWTGraphics; import org.eclipse.draw2d.Viewport; @@ -48,17 +42,12 @@ import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.ImageData; import org.eclipse.swt.graphics.ImageLoader; -import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.IFileEditorInput; -import org.jiemamy.eclipse.editor.DiagramEditor; -import org.jiemamy.eclipse.ui.FolderSelectWizardPage; -import org.jiemamy.eclipse.utils.EditorUtil; +import org.jiemamy.eclipse.ui.FileSelectWizardPage; import org.jiemamy.eclipse.utils.ExceptionHandler; import org.jiemamy.model.RootModel; @@ -71,12 +60,8 @@ private static final int MARGIN = 50; - private DiagramEditor editor; + private File file; - private IPath path; - - private IFile file; - private int format; private boolean overwrite; @@ -86,32 +71,26 @@ * インスタンスを生成する。 * * @param viewer ビューア - * @param editor ダイアグラムエディタオブジェクト */ - public SaveDiagramImageAction(GraphicalViewer viewer, DiagramEditor editor) { + public SaveDiagramImageAction(GraphicalViewer viewer) { super(Messages.SaveDiagramImageAction_name, viewer); - this.editor = editor; } @Override public void run() { if (prepare()) { try { - export(getViewer(), file.getLocation().toString(), format, overwrite); - file.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor()); - } catch (CoreException e) { - ExceptionHandler.handleException(e); + export(getViewer(), file, format, overwrite); } catch (IOException e) { ExceptionHandler.handleException(e); } } } - private void export(GraphicalViewer viewer, String location, int format, boolean overwrite) throws IOException { + private void export(GraphicalViewer viewer, File file, int format, boolean overwrite) throws IOException { IFigure figure = ((AbstractGraphicalEditPart) viewer.getRootEditPart()).getFigure(); - File file = new File(location); - if (file.exists() && !overwrite) { + if (file.exists() && overwrite == false) { if (MessageDialog.openQuestion(null, Messages.OverwriteDialog_title, Messages.OverwriteDialog_message) == false) { return; } @@ -147,16 +126,13 @@ private boolean prepare() { RootModel rootModel = (RootModel) getViewer().getContents().getModel(); - IFileEditorInput input = (IFileEditorInput) editor.getEditorInput(); - IProject project = input.getFile().getProject(); - WizardDialog dialog = new WizardDialog(null, new GraphicWizard(project, rootModel)); + WizardDialog dialog = new WizardDialog(null, new GraphicWizard(rootModel)); if (dialog.open() == Dialog.CANCEL) { return false; } - file = project.getFile(path); overwrite = false; if (file.exists() && MessageDialog.openConfirm(null, Messages.OverwriteDialog_title, Messages.OverwriteDialog_message)) { @@ -168,41 +144,34 @@ private class GraphicWizard extends Wizard { - private IProject project; - private GraphicWizardPage page; /** * インスタンスを生成する。 * - * @param project * @param rootModel ルートモデル */ - public GraphicWizard(IProject project, RootModel rootModel) { - this.project = project; + public GraphicWizard(RootModel rootModel) { setWindowTitle(Messages.GraphicWizard_title); } @Override public void addPages() { - page = new GraphicWizardPage(project); + page = new GraphicWizardPage(); addPage(page); } @Override public boolean performFinish() { - IPath pathx = page.getOutputFolderResource().getProjectRelativePath(); - path = pathx.append(page.getFilename()); + file = new File(page.getPath()); format = page.getFormat(); return true; } } - private static class GraphicWizardPage extends FolderSelectWizardPage { + private static class GraphicWizardPage extends FileSelectWizardPage { - private Text txtFilename; - private Combo cmbFormat; private List<ImageFileFormat> formatList = new ArrayList<ImageFileFormat>(6); @@ -210,18 +179,20 @@ /** * インスタンスを生成する。 - * - * @param project */ - public GraphicWizardPage(IProject project) { - super(project, Messages.GraphicWizard_title); + public GraphicWizardPage() { + super("GraphicWizardPage", Messages.GraphicWizard_title, null, new String[] { + "すべて" + }, new String[] { + "*.*" + }); setDescription(Messages.GraphicWizard_description); formatList.add(new ImageFileFormat(Messages.FileFormat_jpg_description, "jpeg", SWT.IMAGE_JPEG)); // THINK GIF は org.eclipse.swt.SWTException: Unsupported color depth が飛ぶ。何故? -// formatList.add(new ImageFileFormat("GIF file format", "gif", SWT.IMAGE_GIF)); + formatList.add(new ImageFileFormat("GIF file format", "gif", SWT.IMAGE_GIF)); // THINK PNG は org.eclipse.swt.SWTException: Unsupported or unrecognized format が飛ぶ。何故? -// formatList.add(new ImageFileFormat("PNG file format", "png", SWT.IMAGE_PNG)); + formatList.add(new ImageFileFormat("PNG file format", "png", SWT.IMAGE_PNG)); formatList.add(new ImageFileFormat(Messages.FileFormat_bmp_description, "bmp", SWT.IMAGE_BMP)); formatList.add(new ImageFileFormat(Messages.FileFormat_bmpRLE_description, "bmp", SWT.IMAGE_BMP_RLE)); formatList.add(new ImageFileFormat(Messages.FileFormat_ico_description, "ico", SWT.IMAGE_ICO)); @@ -234,16 +205,6 @@ Composite composite = (Composite) getControl(); Label label = new Label(composite, SWT.NULL); - label.setText(Messages.GraphicWizard_fileName_label); - - txtFilename = new Text(composite, SWT.BORDER); - txtFilename.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - txtFilename.setText(getDefaultFilename()); - - label = new Label(composite, SWT.NULL); // ダミー - label.setText(""); - - label = new Label(composite, SWT.NULL); label.setText(Messages.GraphicWizard_fileFormat_label); cmbFormat = new Combo(composite, SWT.READ_ONLY); @@ -256,18 +217,18 @@ @Override public void widgetSelected(SelectionEvent e) { - String filename = txtFilename.getText(); - int extensionIndex = filename.lastIndexOf(".") + 1; + String path = getPath(); + int extensionIndex = path.lastIndexOf(".") + 1; StringBuilder sb = new StringBuilder(); if (extensionIndex > 0) { - sb.append(filename.substring(0, extensionIndex)); + sb.append(path.substring(0, extensionIndex)); } else { - sb.append(filename).append("."); + sb.append(path).append("."); } sb.append(getExtension()); - txtFilename.setText(sb.toString()); + setPath(sb.toString()); } }); cmbFormat.setFocus(); @@ -275,6 +236,7 @@ /** * 拡張子を取得する。 + * * @return 拡張子 */ public String getExtension() { @@ -282,14 +244,6 @@ } /** - * 出力ファイル名を取得する。 - * @return 出力ファイル名 - */ - public String getFilename() { - return txtFilename.getText(); - } - - /** * 出力フォーマットを取得する。 * @return 出力フォーマット */ @@ -297,16 +251,6 @@ return formatList.get(cmbFormat.getSelectionIndex()).getFormat(); } - private String getDefaultFilename() { - String filename = EditorUtil.getActiveEditor().getEditorInput().getName(); - int dotIndex = filename.lastIndexOf("."); - if (dotIndex > -1) { - filename = filename.substring(0, dotIndex); - } - - return filename + ".jpeg"; - } - private static class ImageFileFormat { Deleted: hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/composer/FileSelectWizardPage.java =================================================================== --- hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/composer/FileSelectWizardPage.java 2009-04-07 08:50:52 UTC (rev 3156) +++ hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/composer/FileSelectWizardPage.java 2009-04-07 09:58:53 UTC (rev 3157) @@ -1,127 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2009/02/26 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.eclipse.composer; - -import org.apache.commons.lang.StringUtils; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; - -/** - * ファイルを選択するウィザードページ。 - * - * @author daisuke - */ -public class FileSelectWizardPage extends WizardPage { - - private Text text; - - private Button chkOverwrite; - - - /** - * インスタンスを生成する。 - */ - protected FileSelectWizardPage() { - super("出力ファイル選択pageName", "出力ファイル選択", (ImageDescriptor) null); - } - - public void createControl(final Composite parent) { - Composite composite = new Composite(parent, SWT.NULL); - composite.setLayout(new GridLayout(3, false)); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - - Label label = new Label(composite, SWT.NONE); - label.setText("出力先:"); - - text = new Text(composite, SWT.BORDER); - text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - text.setText(""); - text.addModifyListener(new ModifyListener() { - - public void modifyText(ModifyEvent e) { - if (StringUtils.isEmpty(text.getText())) { - setPageComplete(false); - } else { - setPageComplete(true); - } - } - - }); - setPageComplete(false); - - Button btnBrowse = new Button(composite, SWT.PUSH); - btnBrowse.setText("参照(&B)"); // RESOURCE - btnBrowse.addSelectionListener(new SelectionAdapter() { - - @Override - public void widgetSelected(SelectionEvent e) { - FileDialog dialog = new FileDialog(parent.getShell(), SWT.SAVE); - dialog.setFilterNames(new String[] { - "SQLファイル(.sql)", - "すべて" - }); - dialog.setFilterExtensions(new String[] { - "*.sql", - "*.*" - }); - dialog.setText("保存先"); - String fileName = dialog.open(); - text.setText(fileName); - } - }); - - chkOverwrite = new Button(composite, SWT.CHECK); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan = 3; - chkOverwrite.setLayoutData(gd); - chkOverwrite.setText("存在したら上書きする"); - - setControl(composite); - } - - /** - * 上書きを行うかどうかを取得する。 - * - * @return 上書きを行う場合は{@code true}、そうでない場合は{@code false} - */ - public boolean getOverwrite() { - return chkOverwrite.getSelection(); - } - - /** - * 出力ファイルのパスを取得する。 - * - * @return 出力ファイルのパス - */ - public String getPath() { - return text.getText(); - } -} Modified: hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/composer/SqlExportWizard.java =================================================================== --- hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/composer/SqlExportWizard.java 2009-04-07 08:50:52 UTC (rev 3156) +++ hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/composer/SqlExportWizard.java 2009-04-07 09:58:53 UTC (rev 3157) @@ -22,6 +22,7 @@ import java.util.List; import org.eclipse.jface.dialogs.IDialogSettings; +import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.wizard.Wizard; import org.eclipse.ui.IEditorPart; @@ -35,6 +36,7 @@ import org.jiemamy.eclipse.JiemamyUIPlugin; import org.jiemamy.eclipse.editor.JiemamyEditor; import org.jiemamy.eclipse.ui.ExporterWizard; +import org.jiemamy.eclipse.ui.FileSelectWizardPage; import org.jiemamy.eclipse.utils.EditorUtil; import org.jiemamy.model.RootModel; import org.jiemamy.model.dataset.DataSetModel; @@ -79,8 +81,17 @@ } } super.addPages(); - page1 = new FileSelectWizardPage(); + + // RESOURCE + page1 = new FileSelectWizardPage("出力ファイル選択", "出力ファイル選択", (ImageDescriptor) null, new String[] { + "SQLファイル(.sql)", + "すべて" + }, new String[] { + "*.sql", + "*.*" + }); addPage(page1); + page2 = new SqlExportWizardPage(dataSetNames); addPage(page2); } @@ -102,6 +113,7 @@ config.setOverwrite(page1.getOverwrite()); config.setDataSetIndex(page2.getDataSetIndex()); config.setEmitDropStatements(page2.getEmitDropStatements()); + config.setEmitCreateSchema(page2.getEmitCreateSchema()); return true; } Modified: hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/composer/SqlExportWizardPage.java =================================================================== --- hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/composer/SqlExportWizardPage.java 2009-04-07 08:50:52 UTC (rev 3156) +++ hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/composer/SqlExportWizardPage.java 2009-04-07 09:58:53 UTC (rev 3157) @@ -40,6 +40,8 @@ private Button chkDropStatements; + private Button chkCreateSchema; + private Combo cmbDataSets; private final List<String> dataSetNames; @@ -66,6 +68,12 @@ chkDropStatements.setLayoutData(gd); chkDropStatements.setText("DROP文を出力する"); // RESOURCE + chkCreateSchema = new Button(composite, SWT.CHECK); + gd = new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalSpan = 2; + chkCreateSchema.setLayoutData(gd); + chkCreateSchema.setText("CREATE SCHEMA文を出力する"); // RESOURCE + Label label = new Label(composite, SWT.NONE); label.setText("出力するデータセット"); // RESOURCE @@ -88,6 +96,15 @@ } /** + * CREATE SCHEMA文を出力するかどうかを取得する。 + * + * @return 出力する場合は{@code true}、そうでない場合は{@code false} + */ + public boolean getEmitCreateSchema() { + return chkCreateSchema.getSelection(); + } + + /** * DROP文を出力するかどうかを取得する。 * * @return 出力する場合は{@code true}、そうでない場合は{@code false} Modified: hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/DiagramEditor.java =================================================================== --- hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/DiagramEditor.java 2009-04-07 08:50:52 UTC (rev 3156) +++ hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/DiagramEditor.java 2009-04-07 09:58:53 UTC (rev 3157) @@ -129,7 +129,7 @@ /** TODO for daisuke */ private static final int KEYCODE_DEL = 127; - + private static Logger logger = LoggerFactory.getLogger(DiagramEditor.class); /** Palette component, holding the tools and shapes. */ @@ -385,10 +385,10 @@ public void run() { IFile file = ((IFileEditorInput) input).getFile(); - if (!file.exists()) { + if (file.exists() == false) { IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); page.closeEditor(DiagramEditor.this, true); - } else if (!getPartName().equals(file.getName())) { + } else if (getPartName().equals(file.getName()) == false) { setPartName(file.getName()); } } @@ -437,7 +437,8 @@ // to make 'del' and 'f2' key work GraphicalViewerKeyHandler keyHandler = new GraphicalViewerKeyHandler(viewer); - keyHandler.put(KeyStroke.getPressed(SWT.DEL, KEYCODE_DEL, 0), actionRegistry.getAction(ActionFactory.DELETE.getId())); + keyHandler.put(KeyStroke.getPressed(SWT.DEL, KEYCODE_DEL, 0), actionRegistry.getAction(ActionFactory.DELETE + .getId())); keyHandler.put(KeyStroke.getPressed(SWT.F2, 0), actionRegistry.getAction(GEFActionConstants.DIRECT_EDIT)); viewer.setKeyHandler(keyHandler); Modified: hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/DiagramEditorContextMenuProvider.java =================================================================== --- hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/DiagramEditorContextMenuProvider.java 2009-04-07 08:50:52 UTC (rev 3156) +++ hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/DiagramEditorContextMenuProvider.java 2009-04-07 09:58:53 UTC (rev 3157) @@ -110,7 +110,7 @@ } menu.appendToGroup(GEFActionConstants.GROUP_EDIT, new ChangeNodeBackgroundColorAction(viewer)); - menu.appendToGroup(GEFActionConstants.GROUP_EDIT, new SaveDiagramImageAction(viewer, editorPart)); + menu.appendToGroup(GEFActionConstants.GROUP_EDIT, new SaveDiagramImageAction(viewer)); menu.appendToGroup(GEFActionConstants.GROUP_EDIT, new AutoLayoutAction(viewer)); buildImporterMenu(menu, viewer); @@ -152,7 +152,7 @@ if (action.isEnabled()) { alignMenu.add(action); } - if (!alignMenu.isEmpty()) { + if (alignMenu.isEmpty() == false) { menu.appendToGroup(GEFActionConstants.GROUP_REST, alignMenu); } @@ -171,7 +171,7 @@ if (action.isEnabled()) { matchSizeMenu.add(action); } - if (!matchSizeMenu.isEmpty()) { + if (matchSizeMenu.isEmpty() == false) { menu.appendToGroup(GEFActionConstants.GROUP_REST, matchSizeMenu); } } Modified: hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/tools/MultiLineTextCellEditor.java =================================================================== --- hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/tools/MultiLineTextCellEditor.java 2009-04-07 08:50:52 UTC (rev 3156) +++ hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/editor/tools/MultiLineTextCellEditor.java 2009-04-07 09:58:53 UTC (rev 3157) @@ -44,7 +44,7 @@ @Override protected void keyReleaseOccured(KeyEvent keyEvent) { if (keyEvent.character == '\r') { // Return key - if (text != null && !text.isDisposed() && (text.getStyle() & SWT.MULTI) != 0) { + if (text != null && text.isDisposed() == false && (text.getStyle() & SWT.MULTI) != 0) { if ((keyEvent.stateMask & SWT.CTRL) == 0) { fireApplyEditorValue(); deactivate(); Copied: hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/ui/FileSelectWizardPage.java (from rev 3154, hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/composer/FileSelectWizardPage.java) =================================================================== --- hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/ui/FileSelectWizardPage.java (rev 0) +++ hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/ui/FileSelectWizardPage.java 2009-04-07 09:58:53 UTC (rev 3157) @@ -0,0 +1,144 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/02/26 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.eclipse.ui; + +import org.apache.commons.lang.StringUtils; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + +/** + * ファイルを選択するウィザードページ。 + * + * @author daisuke + */ +public class FileSelectWizardPage extends WizardPage { + + private Text txtFolder; + + private Button chkOverwrite; + + private final String[] filterNames; + + private final String[] filterExtensions; + + + /** + * インスタンスを生成する。 + * + * @param pageName ウィザードページ名 + * @param title タイトル + * @param titleImage タイトル画像. may be null. + * @param filterNames 選択ダイアログにおける拡張子フィルタの名前の配列 + * @param filterExtensions 選択ダイアログにおける拡張子フィルタの配列 + */ + public FileSelectWizardPage(String pageName, String title, ImageDescriptor titleImage, String[] filterNames, + String[] filterExtensions) { + super(pageName, title, titleImage); + this.filterNames = filterNames.clone(); + this.filterExtensions = filterExtensions.clone(); + } + + public void createControl(final Composite parent) { + Composite composite = new Composite(parent, SWT.NULL); + composite.setLayout(new GridLayout(3, false)); + composite.setLayoutData(new GridData(GridData.FILL_BOTH)); + + Label label = new Label(composite, SWT.NONE); + label.setText("出力先:"); + + txtFolder = new Text(composite, SWT.BORDER); + txtFolder.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + txtFolder.setText(""); + txtFolder.addModifyListener(new ModifyListener() { + + public void modifyText(ModifyEvent e) { + if (StringUtils.isEmpty(txtFolder.getText())) { + setPageComplete(false); + } else { + setPageComplete(true); + } + } + + }); + setPageComplete(false); + + Button btnBrowse = new Button(composite, SWT.PUSH); + btnBrowse.setText("参照(&B)"); // RESOURCE + btnBrowse.addSelectionListener(new SelectionAdapter() { + + @Override + public void widgetSelected(SelectionEvent e) { + FileDialog dialog = new FileDialog(parent.getShell(), SWT.SAVE); + dialog.setFilterNames(filterNames); + dialog.setFilterExtensions(filterExtensions); + dialog.setText("保存先"); // RESOURCE + String fileName = dialog.open(); + txtFolder.setText(fileName); + } + }); + + chkOverwrite = new Button(composite, SWT.CHECK); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalSpan = 3; + chkOverwrite.setLayoutData(gd); + chkOverwrite.setText("存在したら上書きする"); // RESOURCE + chkOverwrite.setSelection(true); + + setControl(composite); + } + + /** + * 上書きを行うかどうかを取得する。 + * + * @return 上書きを行う場合は{@code true}、そうでない場合は{@code false} + */ + public boolean getOverwrite() { + return chkOverwrite.getSelection(); + } + + /** + * 出力ファイルのパスを取得する。 + * + * @return 出力ファイルのパス + */ + public String getPath() { + return txtFolder.getText(); + } + + /** + * 出力ファイルのパスを設定する。 + * + * @param path 出力ファイルのパス + */ + public void setPath(String path) { + txtFolder.setText(path); + } +} Property changes on: hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/ui/FileSelectWizardPage.java ___________________________________________________________________ Added: svn:mime-type + text/plain Deleted: hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/ui/FolderSelectWizardPage.java =================================================================== --- hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/ui/FolderSelectWizardPage.java 2009-04-07 08:50:52 UTC (rev 3156) +++ hestia/trunk/org.jiemamy.eclipse.ui/src/main/java/org/jiemamy/eclipse/ui/FolderSelectWizardPage.java 2009-04-07 09:58:53 UTC (rev 3157) @@ -1,196 +0,0 @@ -/* - * Copyright 2007-2009 Jiemamy Project and the Others. - * Created on 2008/08/03 - * - * This file is part of Jiemamy. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language - * governing permissions and limitations under the License. - */ -package org.jiemamy.eclipse.ui; - -import java.io.File; -import java.util.ArrayList; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.jdt.internal.ui.wizards.TypedElementSelectionValidator; -import org.eclipse.jdt.internal.ui.wizards.TypedViewerFilter; -import org.eclipse.jdt.internal.ui.wizards.buildpaths.FolderSelectionDialog; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.jface.window.Window; -import org.eclipse.jface.wizard.WizardPage; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.dialogs.ISelectionStatusValidator; -import org.eclipse.ui.model.WorkbenchContentProvider; -import org.eclipse.ui.model.WorkbenchLabelProvider; - -import org.jiemamy.eclipse.utils.ExceptionHandler; - -/** - * フォルダー選択ウィザードのページクラス。 - * - * @author daisuke - */ -public class FolderSelectWizardPage extends WizardPage { - - private IProject project; - - private String defaultDirectory; - - private Text txtOutputFolder; - - - /** - * インスタンスを生成する。 - * - * @param project - * @param pageName ページ名 - */ - public FolderSelectWizardPage(IProject project, String pageName) { - this(project, pageName, "/"); - } - - /** - * インスタンスを生成する。 - * - * @param project - * @param pageName ページ名 - * @param defaultDirectory 初期のディレクトリ - */ - public FolderSelectWizardPage(IProject project, String pageName, String defaultDirectory) { - super(pageName); - setTitle(pageName); - this.project = project; - this.defaultDirectory = defaultDirectory; - } - - public void createControl(Composite parent) { - Composite composite = new Composite(parent, SWT.NULL); - composite.setLayout(new GridLayout(3, false)); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - - Label label = new Label(composite, SWT.NULL); - label.setText("wizard.export.folder"); // RESOURCE - txtOutputFolder = new Text(composite, SWT.BORDER); - txtOutputFolder.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - txtOutputFolder.setEditable(false); - txtOutputFolder.setText(defaultDirectory); - - Button btnBrowse = new Button(composite, SWT.PUSH); - btnBrowse.setText("label.button.browse"); // RESOURCE - btnBrowse.addSelectionListener(new SelectionAdapter() { - - @Override - public void widgetSelected(SelectionEvent e) { - selectFolder(); - } - }); - - setControl(composite); - } - - /** - * 出力先フォルダを取得する。 - * - * @return 出力先フォルダ - */ - public File getOutputDirectory() { - IResource resource = getOutputFolderResource(); - if (resource instanceof IContainer) { - return ((IContainer) resource).getLocation().makeAbsolute().toFile(); - } - return null; - } - - /** - * 出力先フォルダをリソースとして取得する。 - * - * @return 出力先フォルダ - */ - public IResource getOutputFolderResource() { - String outputDir = txtOutputFolder.getText(); - if (outputDir.startsWith("/")) { - outputDir = outputDir.substring(1); - } - if (outputDir.endsWith("/")) { - outputDir = outputDir.substring(0, outputDir.length() - 1); - } - return project.findMember(outputDir); - } - - private String getFolderName(Object result) { - if (result instanceof IFolder) { - IFolder folder = (IFolder) result; - return folder.getProjectRelativePath().toString(); - } - return ""; - } - - private void selectFolder() { - try { - IProject currProject = project.getProject(); - IResource init = null; - if (!txtOutputFolder.getText().equals("")) { - init = currProject.findMember(txtOutputFolder.getText()); - } - Class<?>[] acceptedClasses = new Class[] { - IProject.class, - IFolder.class - }; - @SuppressWarnings("restriction") - ISelectionStatusValidator validator = new TypedElementSelectionValidator(acceptedClasses, false); - - IWorkspaceRoot wsroot = ResourcesPlugin.getWorkspace().getRoot(); - IProject[] allProjects = wsroot.getProjects(); - - ArrayList<IProject> rejectedElements = new ArrayList<IProject>(allProjects.length); - for (int i = 0; i < allProjects.length; i++) { - if (!allProjects[i].equals(currProject)) { - rejectedElements.add(allProjects[i]); - } - } - @SuppressWarnings("restriction") - ViewerFilter filter = new TypedViewerFilter(acceptedClasses, rejectedElements.toArray()); - - @SuppressWarnings("restriction") - FolderSelectionDialog dialog = - new FolderSelectionDialog(getShell(), new WorkbenchLabelProvider(), new WorkbenchContentProvider()); - - dialog.setTitle("wizard.export.browse.title"); // RESOURCE - dialog.setMessage("wizard.export.browse.message"); // RESOURCE - - dialog.setInput(wsroot); - dialog.setValidator(validator); - dialog.addFilter(filter); - dialog.setInitialSelection(init); - if (dialog.open() == Window.OK) { - txtOutputFolder.setText("/" + getFolderName(dialog.getFirstResult())); - } - - } catch (Exception e) { - ExceptionHandler.handleException(e); - } - } -} Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResourceBundleUtil.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResourceBundleUtil.java 2009-04-07 08:50:52 UTC (rev 3156) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResourceBundleUtil.java 2009-04-07 09:58:53 UTC (rev 3157) @@ -104,7 +104,7 @@ /** * インスタンスを構築します。 */ - protected ResourceBundleUtil() { + private ResourceBundleUtil() { throw new JiemamyError("不到達ポイント"); } } Modified: leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResourceTraversal.java =================================================================== --- leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResourceTraversal.java 2009-04-07 08:50:52 UTC (rev 3156) +++ leto/jiemamy-commons/trunk/src/main/java/org/jiemamy/utils/ResourceTraversal.java 2009-04-07 09:58:53 UTC (rev 3157) @@ -34,23 +34,6 @@ public class ResourceTraversal { /** - * リソースを処理するインターフェースです。 - * - */ - public interface ResourceHandler { - - /** - * リソースを処理します。 - * - * @param path パス - * @param is {@link InputStream} - * @throws TraversalHandlerException ハンドラの処理に失敗した場合 - */ - void processResource(String path, InputStream is) throws TraversalHandlerException; - } - - - /** * リソースを横断的に処理する。 * * @param rootDir ルートディレクトリ @@ -140,7 +123,24 @@ /** * インスタンスを構築します。 */ - protected ResourceTraversal() { + private ResourceTraversal() { throw new JiemamyError("不到達ポイント"); } + + + /** + * リソースを処理するインターフェースです。 + * + */ + public interface ResourceHandler { + + /** + * リソースを処理します。 + * + * @param path パス + * @param is {@link InputStream} + * @throws TraversalHandlerException ハンドラの処理に失敗した場合 + */ + void processResource(String path, InputStream is) throws TraversalHandlerException; + } } Added: leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/JmStringUtilTest.java =================================================================== --- leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/JmStringUtilTest.java (rev 0) +++ leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/JmStringUtilTest.java 2009-04-07 09:58:53 UTC (rev 3157) @@ -0,0 +1,193 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/01/29 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.utils; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * {@link JmStringUtil}のテストクラス。 + * + * @author daisuke + */ +public class JmStringUtilTest { + + private String[] array; + + + /** + * テストを初期化する。 + * + * @throws Exception 例外が発生した場合 + */ + @Before + public void setUp() throws Exception { + array = new String[] { + "foo", + "bar", + "baz" + }; + } + + /** + * テストの情報を破棄する。 + * + * @throws Exception 例外が発生した場合 + */ + @After + public void tearDown() throws Exception { + array = null; + } + + /** + * Test method for {@link JmStringUtil#containsIgnoreCase(String[], String)}. + */ + @Test + public void testContainsIgnoreCase() { + assertThat(JmStringUtil.containsIgnoreCase(array, "foo"), is(true)); + assertThat(JmStringUtil.containsIgnoreCase(array, "bar"), is(true)); + assertThat(JmStringUtil.containsIgnoreCase(array, "baz"), is(true)); + assertThat(JmStringUtil.containsIgnoreCase(array, "qux"), is(false)); + + assertThat(JmStringUtil.containsIgnoreCase(array, "FOO"), is(true)); + assertThat(JmStringUtil.containsIgnoreCase(array, "Bar"), is(true)); + assertThat(JmStringUtil.containsIgnoreCase(array, "bAz"), is(true)); + assertThat(JmStringUtil.containsIgnoreCase(array, "quX"), is(false)); + } + + /** + * Test method for {@link JmStringUtil#indexOfIgnoreCase(String[], String)}. + */ + @Test + public void testIndexOfIgnoreCaseStringArrayString() { + assertThat(JmStringUtil.indexOfIgnoreCase(array, "foo"), is(0)); + assertThat(JmStringUtil.indexOfIgnoreCase(array, "bar"), is(1)); + assertThat(JmStringUtil.indexOfIgnoreCase(array, "baz"), is(2)); + assertThat(JmStringUtil.indexOfIgnoreCase(array, "qux"), is(-1)); + + assertThat(JmStringUtil.indexOfIgnoreCase(array, "FOO"), is(0)); + assertThat(JmStringUtil.indexOfIgnoreCase(array, "Bar"), is(1)); + assertThat(JmStringUtil.indexOfIgnoreCase(array, "bAz"), is(2)); + assertThat(JmStringUtil.indexOfIgnoreCase(array, "quX"), is(-1)); + } + + /** + * Test method for {@link JmStringUtil#indexOfIgnoreCase(String[], String, int)}. + */ + @Test + public void testIndexOfIgnoreCaseStringArrayStringInt() { + assertThat(JmStringUtil.indexOfIgnoreCase(array, "foo", 1), is(-1)); + assertThat(JmStringUtil.indexOfIgnoreCase(array, "bar", 1), is(1)); + assertThat(JmStringUtil.indexOfIgnoreCase(array, "baz", 1), is(2)); + assertThat(JmStringUtil.indexOfIgnoreCase(array, "qux", 1), is(-1)); + + assertThat(JmStringUtil.indexOfIgnoreCase(array, "FOO", 1), is(-1)); + assertThat(JmStringUtil.indexOfIgnoreCase(array, "Bar", 1), is(1)); + assertThat(JmStringUtil.indexOfIgnoreCase(array, "bAz", 1), is(2)); + assertThat(JmStringUtil.indexOfIgnoreCase(array, "quX", 1), is(-1)); + } + + /** + * Test method for {@link JmStringUtil#toCapital(String)}. + */ + @Test + public void testToCapital() { + assertThat(JmStringUtil.toCapital("foo"), is("Foo")); + assertThat(JmStringUtil.toCapital("fooBar"), is("FooBar")); + assertThat(JmStringUtil.toCapital("qName"), is("QName")); + } + + /** + * Test method for {@link JmStringUtil#toJavaClassName(String)}. + */ + @Test + public void testToJavaClassNameString() { + assertThat(JmStringUtil.toJavaClassName("foo"), is("Foo")); +// assertThat(JmStringUtil.toJavaClassName("fooBar"), is("FooBar")); + assertThat(JmStringUtil.toJavaClassName("FOO_BAR"), is("FooBar")); + assertThat(JmStringUtil.toJavaClassName("Q_NAME"), is("QName")); + assertThat(JmStringUtil.toJavaClassName("SQL_STRING"), is("SqlString")); + } + + /** + * Test method for {@link JmStringUtil#toJavaClassName(String, String)}. + */ + @Test + public void testToJavaClassNameStringString() { + assertThat(JmStringUtil.toJavaClassName("HOGE_foo", "HOGE"), is("Foo")); +// assertThat(JmStringUtil.toJavaClassName("HOGE_fooBar", "HOGE"), is("FooBar")); + assertThat(JmStringUtil.toJavaClassName("HOGE_FOO_BAR", "HOGE"), is("FooBar")); + assertThat(JmStringUtil.toJavaClassName("HOGE_Q_NAME", "HOGE"), is("QName")); + assertThat(JmStringUtil.toJavaClassName("HOGE_SQL_STRING", "HOGE"), is("SqlString")); + } + + /** + * Test method for {@link JmStringUtil#toJavaName(String)}. + */ + @Test + public void testToJavaNameString() { + assertThat(JmStringUtil.toJavaName("foo"), is("foo")); +// assertThat(JmStringUtil.toJavaName("fooBar"), is("fooBar")); + assertThat(JmStringUtil.toJavaName("FOO_BAR"), is("fooBar")); + assertThat(JmStringUtil.toJavaName("Q_NAME"), is("qName")); + assertThat(JmStringUtil.toJavaName("SQL_STRING"), is("sqlString")); + } + + /** + * Test method for {@link JmStringUtil#toJavaName(String, String)}. + */ + @Test + public void testToJavaNameStringString() { +// fail("Not yet implemented"); + } + + /** + * Test method for {@link JmStringUtil#toSQLName(String, String)}. + */ + @Test + public void testToSQLName() { + assertThat(JmStringUtil.toSQLName("foo"), is("FOO")); +// assertThat(JmStringUtil.toSQLName("Foo"), is("FOO")); +// assertThat(JmStringUtil.toSQLName("FOO"), is("FOO")); + assertThat(JmStringUtil.toSQLName("fooBar"), is("FOO_BAR")); +// assertThat(JmStringUtil.toSQLName("FooBar"), is("FOO_BAR")); +// assertThat(JmStringUtil.toSQLName("FOO_BAR"), is("FOO_BAR")); + assertThat(JmStringUtil.toSQLName("qName"), is("Q_NAME")); +// assertThat(JmStringUtil.toSQLName("QName"), is("Q_NAME")); +// assertThat(JmStringUtil.toSQLName("Q_NAME"), is("Q_NAME")); + assertThat(JmStringUtil.toSQLName("sqlString"), is("SQL_STRING")); +// assertThat(JmStringUtil.toSQLName("SqlString"), is("SQL_STRING")); +// assertThat(JmStringUtil.toSQLName("SQL_STRING"), is("SQL_STRING")); + } + + /** + * Test method for {@link JmStringUtil#toUnCapital(String)}. + */ + @Test + public void testToUnCapital() { + assertThat(JmStringUtil.toUnCapital("Foo"), is("foo")); + assertThat(JmStringUtil.toUnCapital("FooBar"), is("fooBar")); + assertThat(JmStringUtil.toUnCapital("QName"), is("qName")); + } + +} Added: leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/ListUtilTest.java =================================================================== --- leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/ListUtilTest.java (rev 0) +++ leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/ListUtilTest.java 2009-04-07 09:58:53 UTC (rev 3157) @@ -0,0 +1,134 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/02/23 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.utils; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.fail; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * {@link ListUtil}のテストクラス。 + * + * @author daisuke + */ +public class ListUtilTest { + + private List<String> list; + + + /** + * テストを初期化する。 + * + * @throws Exception 例外が発生した場合 + */ + @Before + public void setUp() throws Exception { + list = new ArrayList<String>(); + list.add("foo"); + list.add("bar"); + list.add("baz"); + } + + /** + * テストの情報を破棄する。 + * + * @throws Exception 例外が発生した場合 + */ + @After + public void tearDown() throws Exception { + list = null; + } + +// /** +// * {@link ListUtil#moveDown(List, int)}のテスト。 +// * +// * @throws Exception 例外が発生した場合 +// */ +// @Test +// public void test01_moveDown() throws Exception { +// try { +// ListUtil.moveDown(null, 0); +// fail(); +// } catch (IllegalArgumentException e) { +// // success +// } +// +// ListUtil.moveDown(list, 0); +// assertThat(list.get(0), is("bar")); +// assertThat(list.get(1), is("foo")); +// assertThat(list.get(2), is("baz")); +// +// ListUtil.moveDown(list, 1); +// assertThat(list.get(0), is("bar")); +// assertThat(list.get(1), is("baz")); +// assertThat(list.get(2), is("foo")); +// } +// +// /** +// * {@link ListUtil#moveUp(List, int)}のテスト。 +// * +// * @throws Exception 例外が発生した場合 +// */ +// @Test +// public void test02_moveUp() throws Exception { +// try { +// ListUtil.moveUp(list, -1); +// fail(); +// } catch (IllegalArgumentException e) { +// // success +// } +// +// ListUtil.moveUp(list, 1); +// assertThat(list.get(0), is("bar")); +// assertThat(list.get(1), is("foo")); +// assertThat(list.get(2), is("baz")); +// +// ListUtil.moveUp(list, 2); +// assertThat(list.get(0), is("bar")); +// assertThat(list.get(1), is("baz")); +// assertThat(list.get(2), is("foo")); +// } + + /** + * {@link ListUtil#reverse(List)}のテスト。 + * + * @throws Exception 例外が発生した場合 + */ + @Test + public void test03_reverse() throws Exception { + try { + ListUtil.reverse(null); + fail(); + } catch (IllegalArgumentException e) { + // success + } + + ListUtil.reverse(list); + assertThat(list.get(0), is("baz")); + assertThat(list.get(1), is("bar")); + assertThat(list.get(2), is("foo")); + } +} Added: leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/ReflectionUtilTest.java =================================================================== --- leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/ReflectionUtilTest.java (rev 0) +++ leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/ReflectionUtilTest.java 2009-04-07 09:58:53 UTC (rev 3157) @@ -0,0 +1,291 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2009/01/29 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.utils; + +import static org.hamcrest.CoreMatchers.is; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.fail; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +/** + * {@link ReflectionUtil}のテストクラス。 + * + * @author daisuke + */ +public class ReflectionUtilTest { + + private Method getFoo; + + private Method getBar; + + private Method isBaz; + + private Method getQux; + + private Method getQux2; + + private Method setFoo; + + private Method setBar; + + private Method setBaz; + + private Method setQux; + + private Method setQux2; + + private Field foo; + + private Field bar; + + private Field baz; + + private Field qux; + + + /** + * テストを初期化する。 + * + * @throws Exception 例外が発生した場合 + */ + @Before + public void setUp() throws Exception { + foo = TestBean.class.getDeclaredField("foo"); + bar = TestBean.class.getDeclaredField("bar"); + baz = TestBean.class.getDeclaredField("baz"); + qux = TestBean.class.getDeclaredField("qux"); + + getFoo = TestBean.class.getDeclaredMethod("getFoo"); + getBar = TestBean.class.getDeclaredMethod("getBar"); + isBaz = TestBean.class.getDeclaredMethod("isBaz"); + getQux = TestBean.class.getDeclaredMethod("getQux"); + getQux2 = TestBean.class.getDeclaredMethod("getQux2"); + + setFoo = TestBean.class.getDeclaredMethod("setFoo", int.class); + setBar = TestBean.class.getDeclaredMethod("setBar", String.class); + setBaz = TestBean.class.getDeclaredMethod("setBaz", boolean.class); + setQux = TestBean.class.getDeclaredMethod("setQux", Boolean.class); + setQux2 = TestBean.class.getDeclaredMethod("setQux2"); + } + + /** + * テストの情報を破棄する。 + * + * @throws Exception 例外が発生した場合 + */ + @After + public void tearDown() throws Exception { + getFoo = null; + getBar = null; + isBaz = null; + getQux = null; + getQux2 = null; + + setFoo = null; + setBar = null; + setBaz = null; + setQux = null; + setQux2 = null; + } + + /** + * Test method for {@link ReflectionUtil#convertFieldToAccessorName(java.lang.reflect.Field, String)}. + */ + @Test + public void testConvertFieldToAccessorName() { + assertThat(ReflectionUtil.convertFieldToAccessorName(foo, "get"), is("getFoo")); + assertThat(ReflectionUtil.convertFieldToAccessorName(bar, "get"), is("getBar")); + assertThat(ReflectionUtil.convertFieldToAccessorName(baz, "is"), is("isBaz")); + assertThat(ReflectionUtil.convertFieldToAccessorName(qux, "get"), is("getQux")); + + assertThat(ReflectionUtil.convertFieldToAccessorName(foo, "set"), is("setFoo")); + assertThat(ReflectionUtil.convertFieldToAccessorName(bar, "set"), is("setBar")); + assertThat(ReflectionUtil.convertFieldToAccessorName(baz, "set"), is("setBaz")); + assertThat(ReflectionUtil.convertFieldToAccessorName(qux, "set"), is("setQux")); + } + + /** + * Test method for {@link ReflectionUtil#convertFieldToGetterName(java.lang.reflect.Field)}. + */ + @Test + public void testConvertFieldToGetterName() { + assertThat(ReflectionUtil.convertFieldToGetterName(foo), is("getFoo")); + assertThat(ReflectionUtil.convertFieldToGetterName(bar), is("getBar")); + assertThat(ReflectionUtil.convertFieldToGetterName(baz), is("isBaz")); + assertThat(ReflectionUtil.convertFieldToGetterName(qux), is("isQux")); + } + + /** + * Test method for {@link ReflectionUtil#convertFieldToSetterName(java.lang.reflect.Field)}. + */ + @Test + public void testConvertFieldToSetterName() { + assertThat(ReflectionUtil.convertFieldToSetterName(foo), is("setFoo")); + assertThat(ReflectionUtil.convertFieldToSetterName(bar), is("setBar")); + assertThat(ReflectionUtil.convertFieldToSetterName(baz), is("setBaz")); + assertThat(ReflectionUtil.convertFieldToSetterName(qux), is("setQux")); + } + + /** + * Test method for {@link ReflectionUtil#convertAccessorToFieldName(java.lang.reflect.Method)}. + */ + @Test + public void testConvertGetterToFieldName() { + assertThat(ReflectionUtil.convertAccessorToFieldName(getFoo), is("foo")); + assertThat(ReflectionUtil.convertAccessorToFieldName(getBar), is("bar")); + assertThat(ReflectionUtil.convertAccessorToFieldName(isBaz), is("baz")); + assertThat(ReflectionUtil.convertAccessorToFieldName(getQux), is("qux")); + try { + ReflectionUtil.convertAccessorToFieldName(getQux2); + fail(); + } catch (IllegalArgumentException e) { + // success + } + + assertThat(ReflectionUtil.convertAccessorToFieldName(setFoo), is("foo")); + assertThat(ReflectionUtil.convertAccessorToFieldName(setBar), is("bar")); + assertThat(ReflectionUtil.convertAccessorToFieldName(setBaz), is("baz")); + assertThat(ReflectionUtil.convertAccessorToFieldName(setQux), is("qux")); + try { + ReflectionUtil.convertAccessorToFieldName(setQux2); + fail(); + } catch (IllegalArgumentException e) { + // success + } + + } + + /** + * Test method for {@link ReflectionUtil#isAccessor(java.lang.reflect.Method)}. + * + * @throws Exception 例外が発生した場合 + */ + @Test + public void testIsAccessor() throws Exception { + assertThat(ReflectionUtil.isAccessor(getFoo), is(true)); + assertThat(ReflectionUtil.isAccessor(getBar), is(true)); + assertThat(ReflectionUtil.isAccessor(isBaz), is(true)); + assertThat(ReflectionUtil.isAccessor(getQux), is(true)); + assertThat(ReflectionUtil.isAccessor(getQux2), is(false)); + + assertThat(ReflectionUtil.isAccessor(setFoo), is(true)); + assertThat(ReflectionUtil.isAccessor(setBar), is(true)); + assertThat(ReflectionUtil.isAccessor(setBaz), is(true)); + assertThat(ReflectionUtil.isAccessor(setQux), is(true)); + assertThat(ReflectionUtil.isAccessor(setQux2), is(false)); + } + + /** + * Test method for {@link ReflectionUtil#isGetter(java.lang.reflect.Method)}. + * + * @throws Exception 例外が発生した場合 + */ + @Test + public void testIsGetter() throws Exception { + assertThat(ReflectionUtil.isGetter(getFoo), is(true)); + assertThat(ReflectionUtil.isGetter(getBar), is(true)); + assertThat(ReflectionUtil.isGetter(isBaz), is(true)); + assertThat(ReflectionUtil.isGetter(getQux), is(true)); + assertThat(ReflectionUtil.isGetter(getQux2), is(false)); + + assertThat(ReflectionUtil.isGetter(setFoo), is(false)); + assertThat(ReflectionUtil.isGetter(setBar), is(false)); + assertThat(ReflectionUtil.isGetter(setBaz), is(false)); + assertThat(ReflectionUtil.isGetter(setQux), is(false)); + assertThat(ReflectionUtil.isGetter(setQux2), is(false)); + } + + /** + * Test method for {@link ReflectionUtil#isSetter(java.lang.reflect.Method)}. + * + * @throws Exception 例外が発生した場合 + */ + @Test + public void testIsSetter() throws Exception { + assertThat(ReflectionUtil.isSetter(getFoo), is(false)); + assertThat(ReflectionUtil.isSetter(getBar), is(false)); + assertThat(ReflectionUtil.isSetter(isBaz), is(false)); + assertThat(ReflectionUtil.isSetter(getQux), is(false)); + assertThat(ReflectionUtil.isSetter(getQux2), is(false)); + + assertThat(ReflectionUtil.isSetter(setFoo), is(true)); + assertThat(ReflectionUtil.isSetter(setBar), is(true)); + assertThat(ReflectionUtil.isSetter(setBaz), is(true)); + assertThat(ReflectionUtil.isSetter(setQux), is(true)); + assertThat(ReflectionUtil.isSetter(setQux2), is(false)); + } + + + class TestBean { + + private int foo; + + private String bar; + + private boolean baz; + + private Boolean qux; + + + String getBar() { + return bar; + } + + int getFoo() { + return foo; + } + + Boolean getQux() { + return qux; + } + + void getQux2() { + } + + boolean isBaz() { + return baz; + } + + void setBar(String bar) { + this.bar = bar; + } + + void setBaz(boolean baz) { + this.baz = baz; + } + + void setFoo(int foo) { + this.foo = foo; + } + + void setQux(Boolean qux) { + this.qux = qux; + } + + void setQux2() { + } + + } +} Added: leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/UUIDUtilTest.java =================================================================== --- leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/UUIDUtilTest.java (rev 0) +++ leto/jiemamy-commons/trunk/src/test/java/org/jiemamy/utils/UUIDUtilTest.java 2009-04-07 09:58:53 UTC (rev 3157) @@ -0,0 +1,50 @@ +/* + * Copyright 2007-2009 Jiemamy Project and the Others. + * Created on 2008/12/17 + * + * This file is part of Jiemamy. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language + * governing permissions and limitations under the License. + */ +package org.jiemamy.utils; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.not; +import static org.junit.Assert.assertThat; + +import java.util.UUID; + +import org.junit.Test; + +/** + * {@link UUIDUtil}のテストクラス。 + * + * @author daisuke + */ +public class UUIDUtilTest { + + /** + * Test method for {@link org.jiemamy.utils.UUIDUtil#valueOfOrRandom(java.lang.String)}. + */ + @Test + public void testValueOfOrRandom() { + // UUID化できるStringを与えた場合 → fromString生成 + UUID uuid1 = UUIDUtil.valueOfOrRandom("ffffffff-ffff-ffff-ffff-ffffffffffff"); + assertThat(uuid1.toString(), is("ffffffff-ffff-ffff-ffff-ffffffffffff")); + + // UUID化できないStringを与えた場合 → randomUUID生成 + UUID uuid2 = UUIDUtil.valueOfOrRandom("hoge"); + assertThat(uuid2.toString(), not("hoge")); + } + +} Modified: metis/trunk/src/main/java/com/docbook/extract/Extractor.java =================================================================== --- metis/trunk/src/main/java/com/docbook/extract/Extractor.java 2009-04-07 08:50:52 UTC (rev 3156) +++ metis/trunk/src/main/java/com/docbook/extract/Extractor.java 2009-04-07 09:58:53 UTC (rev 3157) @@ -60,7 +60,7 @@ if (file.isDirectory()) { extractCode(file); } else if (file.getName().endsWith(".java") - && !file.getName().equals("Extractor.java")) { + && file.getName().equals("Extractor.java") == false) { extractAnnotatedCode(file); } // fi } // rof Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/dialect/EmitConfig.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/dialect/EmitConfig.java 2009-04-07 08:50:52 UTC (rev 3156) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/dialect/EmitConfig.java 2009-04-07 09:58:53 UTC (rev 3157) @@ -27,6 +27,14 @@ public interface EmitConfig { /** + * CREATE SCHEMA文を出力するかどうかを取得する。 + * + * @return 出力する場合は{@code true}、そうでない場合は{@code false} + * @since 0.2 + */ + boolean emitCreateSchemaStatement(); + + /** * CREATE文の前にDROP文を出力するかどうかを取得する。 * * @return 出力する場合は{@code true}、そうでない場合は{@code false} Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/attribute/RepresentationAdapter.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/attribute/RepresentationAdapter.java 2009-04-07 08:50:52 UTC (rev 3156) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/attribute/RepresentationAdapter.java 2009-04-07 09:58:53 UTC (rev 3157) @@ -52,7 +52,7 @@ if (other.representation != null) { return false; } - } else if (!representation.equals(other.representation)) { + } else if (representation.equals(other.representation) == false) { return false; } return true; Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/adapter/PrecisionedDataTypeAdapter.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/adapter/PrecisionedDataTypeAdapter.java 2009-04-07 08:50:52 UTC (rev 3156) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/adapter/PrecisionedDataTypeAdapter.java 2009-04-07 09:58:53 UTC (rev 3157) @@ -66,14 +66,14 @@ if (other.precision != null) { return false; } - } else if (!precision.equals(other.precision)) { + } else if (precision.equals(other.precision) == false) { return false; } if (scale == null) { if (other.scale != null) { return false; } - } else if (!scale.equals(other.scale)) { + } else if (scale.equals(other.scale) == false) { return false; } return true; Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/adapter/SerialDataTypeAdapter.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/adapter/SerialDataTypeAdapter.java 2009-04-07 08:50:52 UTC (rev 3156) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/adapter/SerialDataTypeAdapter.java 2009-04-07 09:58:53 UTC (rev 3157) @@ -54,7 +54,7 @@ if (other.serial != null) { return false; } - } else if (!serial.equals(other.serial)) { + } else if (serial.equals(other.serial) == false) { return false; } return true; Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/adapter/SizedDataTypeAdapter.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/adapter/SizedDataTypeAdapter.java 2009-04-07 08:50:52 UTC (rev 3156) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/adapter/SizedDataTypeAdapter.java 2009-04-07 09:58:53 UTC (rev 3157) @@ -61,7 +61,7 @@ if (other.size != null) { return false; } - } else if (!size.equals(other.size)) { + } else if (size.equals(other.size) == false) { return false; } return true; Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/adapter/TimezonedDataTypeAdapter.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/adapter/TimezonedDataTypeAdapter.java 2009-04-07 08:50:52 UTC (rev 3156) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/adapter/TimezonedDataTypeAdapter.java 2009-04-07 09:58:53 UTC (rev 3157) @@ -62,7 +62,7 @@ if (other.withTimezone != null) { return false; } - } else if (!withTimezone.equals(other.withTimezone)) { + } else if (withTimezone.equals(other.withTimezone) == false) { return false; } return true; Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/package-info.java =================================================================== --- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/package-info.java 2009-04-07 08:50:52 UTC (rev 3156) +++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/package-info.java 2009-04-07 09:58:53 UTC (rev 3157) @@ -4,7 +4,7 @@ * <p>このパッケージは、Jiemamyモデルに対する各種操作の中枢となる仕様を含む。 * 特に{@link org.jiemamy.Jiemamy}クラスはJiemamyの制御の起点となる最も重要なクラスである。</p> * - * <p>Jiemamyは、Jiemamy自身のバグを検知した場合、{@link org.jiemamy.utils.UnexpectedConditionError} + * <p>Jiemamyは、Jiemamy自身のバグを検知した場合、{@link org.jiemamy.exception.UnexpectedConditionError} * をスローする。このエラーがスローされた場合は、確実にJiemamy実装のバグである。 * また、各メソッドを呼び出した際、Javadocに記述されていない例外がスローされた場合も、 * Jiemamyのバグ(実装バグ、またはJavadoc記述ミス等による仕様バグ)であると判断します。