You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by se...@apache.org on 2015/07/27 19:27:37 UTC
[1/7] incubator-ignite git commit: Merge remote-tracking branch
'remotes/origin/ignite-961' into ignite-1121
Repository: incubator-ignite
Updated Branches:
refs/heads/ignite-1155 [created] e8d71b552
Merge remote-tracking branch 'remotes/origin/ignite-961' into ignite-1121
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/d5925e68
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/d5925e68
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/d5925e68
Branch: refs/heads/ignite-1155
Commit: d5925e688b118a401247722b787c4ba40853e6b7
Parents: aa3fc51 70a8b2f
Author: sevdokimov <se...@gridgain.com>
Authored: Mon Jul 27 15:26:53 2015 +0300
Committer: sevdokimov <se...@gridgain.com>
Committed: Mon Jul 27 15:26:53 2015 +0300
----------------------------------------------------------------------
RELEASE_NOTES.txt | 5 +
assembly/release-base.xml | 5 +
config/ignite-log4j2.xml | 81 +++
config/ignite-log4j2.xml~ | 65 ++
examples/config/example-ignite.xml | 2 +-
.../ignite/examples/ExampleNodeStartup.java | 2 +-
.../examples/js/ExampleJsNodeStartup.java | 2 +-
examples/src/main/js/cache-query-example.js | 24 +-
.../main/js/cache-sql-fields-query-example.js | 95 +--
modules/apache-license-gen/pom.xml | 13 -
modules/clients/README.txt | 16 +
modules/clients/readme.md | 32 -
modules/clients/readme.pdf | Bin 47887 -> 0 bytes
.../JettyRestProcessorAbstractSelfTest.java | 715 +++++++++++--------
.../rest/protocols/tcp/MockNioSession.java | 15 -
.../src/main/java/org/apache/ignite/Ignite.java | 2 +-
.../java/org/apache/ignite/IgniteCache.java | 3 +-
.../apache/ignite/IgniteSystemProperties.java | 8 +
.../AffinityNodeAddressHashResolver.java | 8 +-
.../affinity/AffinityNodeHashResolver.java | 5 +
.../affinity/AffinityNodeIdHashResolver.java | 6 +
.../rendezvous/RendezvousAffinityFunction.java | 22 +-
.../store/jdbc/CacheJdbcBlobStoreFactory.java | 2 +-
.../configuration/CacheConfiguration.java | 4 +-
.../configuration/ConnectorConfiguration.java | 32 +
.../configuration/IgniteConfiguration.java | 89 ++-
.../apache/ignite/internal/IgniteKernal.java | 94 ++-
.../ignite/internal/IgniteNodeAttributes.java | 3 +
.../GridClientConnectionManagerAdapter.java | 2 +-
.../client/router/impl/GridTcpRouterImpl.java | 2 +-
.../client/ssl/GridSslBasicContextFactory.java | 3 +
.../client/ssl/GridSslContextFactory.java | 5 +-
.../discovery/GridDiscoveryManager.java | 7 +-
.../cache/CacheEvictableEntryImpl.java | 2 +-
.../processors/cache/GridCacheAdapter.java | 15 +-
.../processors/cache/GridCacheAttributes.java | 8 +-
.../processors/cache/GridCacheEntryEx.java | 32 +-
.../cache/GridCacheEvictionManager.java | 12 +-
.../processors/cache/GridCacheMapEntry.java | 208 +-----
.../processors/cache/GridCacheMvccManager.java | 14 +
.../processors/cache/GridCacheProcessor.java | 113 +--
.../processors/cache/GridCacheUtils.java | 18 +-
.../processors/cache/IgniteCacheProxy.java | 2 +-
.../processors/cache/IgniteInternalCache.java | 4 +-
.../distributed/dht/GridDhtTxFinishFuture.java | 13 +-
.../distributed/dht/GridDhtTxPrepareFuture.java | 16 +-
.../GridDhtPartitionsExchangeFuture.java | 10 +-
.../near/GridNearOptimisticTxPrepareFuture.java | 4 +-
.../GridNearPessimisticTxPrepareFuture.java | 2 +-
.../near/GridNearTxFinishFuture.java | 17 +-
.../extras/GridCacheAttributesEntryExtras.java | 37 +-
.../GridCacheAttributesMvccEntryExtras.java | 35 +-
...dCacheAttributesMvccObsoleteEntryExtras.java | 35 +-
...cheAttributesMvccObsoleteTtlEntryExtras.java | 35 +-
.../GridCacheAttributesMvccTtlEntryExtras.java | 35 +-
.../GridCacheAttributesObsoleteEntryExtras.java | 36 +-
...idCacheAttributesObsoleteTtlEntryExtras.java | 36 +-
.../GridCacheAttributesTtlEntryExtras.java | 36 +-
.../cache/extras/GridCacheEntryExtras.java | 14 -
.../extras/GridCacheEntryExtrasAdapter.java | 8 -
.../cache/extras/GridCacheMvccEntryExtras.java | 8 -
.../GridCacheMvccObsoleteEntryExtras.java | 8 -
.../GridCacheMvccObsoleteTtlEntryExtras.java | 9 -
.../extras/GridCacheMvccTtlEntryExtras.java | 8 -
.../extras/GridCacheObsoleteEntryExtras.java | 8 -
.../extras/GridCacheObsoleteTtlEntryExtras.java | 9 -
.../cache/extras/GridCacheTtlEntryExtras.java | 8 -
.../store/GridCacheStoreManagerAdapter.java | 2 +-
.../cache/transactions/IgniteInternalTx.java | 16 +-
.../cache/transactions/IgniteTxAdapter.java | 6 +-
.../cache/transactions/IgniteTxManager.java | 5 +-
.../processors/query/GridQueryProcessor.java | 2 +-
.../processors/rest/GridRestCommand.java | 28 +-
.../processors/rest/GridRestProcessor.java | 26 +
.../handlers/cache/GridCacheCommandHandler.java | 70 +-
.../query/CacheQueryFieldsMetaResult.java | 133 ++++
.../rest/handlers/query/CacheQueryResult.java | 19 +
.../handlers/query/QueryCommandHandler.java | 105 +--
.../IgniteScriptingCommandHandler.java | 5 +-
.../rest/protocols/tcp/GridTcpRestProtocol.java | 20 +-
.../scripting/IgniteScriptingConverter.java | 15 +-
.../scripting/IgniteScriptingProcessor.java | 13 +-
.../processors/scripting/ScriptingJsCache.java | 15 +-
.../processors/task/GridTaskProcessor.java | 3 +-
.../ignite/internal/util/IgniteUtils.java | 31 +-
.../util/lang/GridMetadataAwareAdapter.java | 296 ++++----
.../ignite/internal/util/nio/GridNioServer.java | 37 +-
.../util/nio/GridNioSessionMetaKey.java | 5 +-
.../util/nio/GridSelectorNioSessionImpl.java | 8 +
.../util/nio/ssl/BlockingSslHandler.java | 519 ++++++++++++++
.../internal/util/nio/ssl/GridNioSslFilter.java | 53 +-
.../util/nio/ssl/GridNioSslHandler.java | 79 +-
.../org/apache/ignite/json/JSONCacheObject.java | 95 ---
.../org/apache/ignite/spi/IgniteSpiAdapter.java | 58 ++
.../spi/IgniteSpiOperationTimeoutException.java | 43 ++
.../spi/IgniteSpiOperationTimeoutHelper.java | 102 +++
.../communication/tcp/TcpCommunicationSpi.java | 294 ++++++--
.../ignite/spi/discovery/tcp/ClientImpl.java | 52 +-
.../ignite/spi/discovery/tcp/ServerImpl.java | 587 +++++++++------
.../spi/discovery/tcp/TcpDiscoveryImpl.java | 11 +-
.../spi/discovery/tcp/TcpDiscoverySpi.java | 172 ++++-
.../tcp/internal/TcpDiscoveryNode.java | 39 +-
.../TcpDiscoveryConnectionCheckMessage.java | 64 ++
.../apache/ignite/ssl/SslContextFactory.java | 458 ++++++++++++
.../org/apache/ignite/ssl/package-info.java | 22 +
modules/core/src/test/config/log4j2-test.xml | 57 ++
modules/core/src/test/config/log4j2-test.xml~ | 63 ++
.../src/test/config/log4j2-verbose-test.xml | 48 ++
.../IgniteClientReconnectAbstractTest.java | 4 +-
.../IgniteClientReconnectFailoverTest.java | 6 +
.../IgniteTopologyPrintFormatSelfTest.java | 6 +-
.../cache/CacheAffinityCallSelfTest.java | 10 +-
.../cache/GridCachePutAllFailoverSelfTest.java | 3 +
.../CacheGetFutureHangsSelfTest.java | 214 ++++++
.../GridCacheAbstractNodeRestartSelfTest.java | 9 +
...NearDisabledOptimisticTxNodeRestartTest.java | 31 +
.../IgniteCachePutRetryAbstractSelfTest.java | 52 +-
...gniteCachePutRetryTransactionalSelfTest.java | 17 +-
.../GridCachePartitionedFailoverSelfTest.java | 5 -
...achePartitionedMultiNodeFullApiSelfTest.java | 4 +-
...ePartitionedOptimisticTxNodeRestartTest.java | 12 +-
.../cache/eviction/GridCacheMockEntry.java | 12 +-
.../internal/util/nio/GridNioSelfTest.java | 88 ++-
.../internal/util/nio/GridNioSslSelfTest.java | 16 +-
.../nio/impl/GridNioFilterChainSelfTest.java | 15 -
.../GridMetadataAwareAdapterLoadSelfTest.java | 135 ++++
.../lang/GridMetadataAwareAdapterSelfTest.java | 58 +-
.../GridAbstractCommunicationSelfTest.java | 13 +
.../GridTcpCommunicationSpiAbstractTest.java | 2 +-
...dTcpCommunicationSpiRecoveryAckSelfTest.java | 3 +-
...tionSpiRecoveryFailureDetectionSelfTest.java | 54 ++
...GridTcpCommunicationSpiRecoverySelfTest.java | 23 +-
.../tcp/GridTcpCommunicationSpiSslSelfTest.java | 38 +
...unicationSpiTcpFailureDetectionSelfTest.java | 75 ++
.../tcp/IgniteCacheSslStartStopSelfTest.java | 46 ++
.../discovery/AbstractDiscoverySelfTest.java | 36 +-
...lientDiscoverySpiFailureTimeoutSelfTest.java | 205 ++++++
.../tcp/TcpClientDiscoverySpiSelfTest.java | 116 ++-
.../tcp/TcpDiscoveryMultiThreadedTest.java | 2 +
...DiscoveryNodeConfigConsistentIdSelfTest.java | 76 ++
.../tcp/TcpDiscoverySpiConfigSelfTest.java | 1 +
.../TcpDiscoverySpiFailureTimeoutSelfTest.java | 402 +++++++++++
.../tcp/TcpDiscoverySpiSslSelfTest.java | 28 +
.../discovery/tcp/TcpDiscoverySslSelfTest.java | 42 ++
.../ignite/testframework/GridTestUtils.java | 20 +
.../testframework/junits/GridAbstractTest.java | 3 +-
.../ignite/testframework/junits/IgniteMock.java | 13 +
.../IgniteCacheFailoverTestSuite.java | 4 +-
.../IgniteCacheFailoverTestSuite2.java | 4 +
.../testsuites/IgniteCacheRestartTestSuite.java | 5 +-
.../IgniteSpiCommunicationSelfTestSuite.java | 3 +
.../IgniteSpiDiscoverySelfTestSuite.java | 6 +
modules/hadoop/docs/HADOOP_README.txt | 122 ++++
modules/hadoop/docs/hadoop_readme.md | 135 ----
modules/hadoop/docs/hadoop_readme.pdf | Bin 82219 -> 0 bytes
.../processors/query/h2/sql/GridSqlAlias.java | 4 +
.../processors/query/h2/sql/GridSqlColumn.java | 4 +
.../processors/query/h2/sql/GridSqlConst.java | 4 +
.../processors/query/h2/sql/GridSqlElement.java | 40 +-
.../query/h2/sql/GridSqlFunction.java | 2 +
.../processors/query/h2/sql/GridSqlJoin.java | 4 +
.../query/h2/sql/GridSqlOperation.java | 21 +-
.../query/h2/sql/GridSqlOperationType.java | 2 +
.../query/h2/sql/GridSqlParameter.java | 4 +
.../query/h2/sql/GridSqlPlaceholder.java | 4 +
.../processors/query/h2/sql/GridSqlQuery.java | 25 +-
.../query/h2/sql/GridSqlQueryParser.java | 11 +-
.../query/h2/sql/GridSqlQuerySplitter.java | 405 +++++++----
.../processors/query/h2/sql/GridSqlSelect.java | 91 +--
.../query/h2/sql/GridSqlSubquery.java | 4 +
.../processors/query/h2/sql/GridSqlTable.java | 4 +
.../processors/query/h2/sql/GridSqlType.java | 10 +-
.../processors/query/h2/sql/GridSqlUnion.java | 11 -
.../cache/GridCacheCrossCacheQuerySelfTest.java | 77 +-
...QueryOffheapEvictsMultiThreadedSelfTest.java | 5 +
.../IgniteCacheQueryNodeRestartSelfTest.java | 5 -
modules/json/pom.xml | 6 -
.../processors/json/IgniteJsonObject.java | 13 +
.../processors/json/JsonCacheObject.java | 15 +
.../processors/json/IgniteJsonCacheTest.java | 25 +
modules/log4j/README.txt | 2 +-
.../apache/ignite/logger/log4j/Log4JLogger.java | 2 +-
modules/log4j2/README.txt | 32 +
modules/log4j2/licenses/apache-2.0.txt | 202 ++++++
modules/log4j2/pom.xml | 63 ++
modules/log4j2/pom.xml~ | 45 ++
.../ignite/logger/log4j2/Log4J2Logger.java | 486 +++++++++++++
.../ignite/logger/log4j2/Log4J2Logger.java~ | 542 ++++++++++++++
.../ignite/logger/log4j2/Log4j2FileAware.java | 35 +
.../ignite/logger/log4j2/Log4j2FileAware.java~ | 33 +
.../ignite/logger/log4j2/Log4jFileAware.java~ | 13 +
.../ignite/logger/log4j2/package-info.java | 22 +
.../log4j2/GridLog4j2CorrectFileNameTest.java | 95 +++
.../log4j2/GridLog4j2CorrectFileNameTest.java~ | 95 +++
.../log4j2/GridLog4j2InitializedTest.java | 79 ++
.../log4j2/GridLog4j2InitializedTest.java~ | 79 ++
.../log4j2/GridLog4j2LoggingFileTest.java | 72 ++
.../log4j2/GridLog4j2LoggingFileTest.java~ | 74 ++
.../logger/log4j2/Log4j2LoggerSelfTest.java | 174 +++++
.../log4j2/Log4j2LoggerVerboseModeSelfTest.java | 117 +++
.../ignite/logger/log4j2/package-info.java | 22 +
.../testsuites/IgniteLog4j2TestSuite.java | 38 +
modules/nodejs/src/main/js/cache.js | 56 +-
modules/nodejs/src/main/js/ignite.js | 4 +-
modules/nodejs/src/main/js/server.js | 2 +-
modules/nodejs/src/main/js/sql-fields-query.js | 2 +-
.../ignite/internal/NodeJsCacheApiSelfTest.java | 7 -
.../ignite/internal/NodeJsSqlQuerySelfTest.java | 12 +-
modules/nodejs/src/test/js/test-cache-api.js | 21 -
modules/nodejs/src/test/js/test-compute.js | 6 +-
modules/nodejs/src/test/js/test-query.js | 53 +-
modules/rest-http/pom.xml | 6 +
.../http/jetty/GridJettyRestHandler.java | 40 +-
.../jetty/RestGlassFishScriptingConverter.java | 99 ++-
.../org/apache/ignite/spark/IgniteContext.scala | 14 +
.../visor/commands/open/VisorOpenCommand.scala | 17 +-
.../scala/org/apache/ignite/visor/visor.scala | 3 +
modules/yardstick/README.md | 85 ---
modules/yardstick/README.txt | 93 +++
parent/pom.xml | 4 +-
pom.xml | 13 +-
221 files changed, 8957 insertions(+), 2772 deletions(-)
----------------------------------------------------------------------
[2/7] incubator-ignite git commit: IGNITE-1155 Extract
ignite-schema-import-ui module.
Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/Objects.txt
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/Objects.txt b/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/Objects.txt
deleted file mode 100644
index c448ab5..0000000
--- a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/Objects.txt
+++ /dev/null
@@ -1,502 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.apache.ignite.schema.test.model;
-
-import java.io.*;
-
-/**
- * Objects definition.
- *
- * Code generated by Apache Ignite Schema Import utility: 01/27/2015.
- */
-public class Objects implements Serializable {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** Value for pk. */
- private int pk;
-
- /** Value for boolcol. */
- private Boolean boolcol;
-
- /** Value for bytecol. */
- private Byte bytecol;
-
- /** Value for shortcol. */
- private Short shortcol;
-
- /** Value for intcol. */
- private Integer intcol;
-
- /** Value for longcol. */
- private Long longcol;
-
- /** Value for floatcol. */
- private Float floatcol;
-
- /** Value for doublecol. */
- private Double doublecol;
-
- /** Value for doublecol2. */
- private Double doublecol2;
-
- /** Value for bigdecimalcol. */
- private java.math.BigDecimal bigdecimalcol;
-
- /** Value for strcol. */
- private String strcol;
-
- /** Value for datecol. */
- private java.sql.Date datecol;
-
- /** Value for timecol. */
- private java.sql.Time timecol;
-
- /** Value for tscol. */
- private java.sql.Timestamp tscol;
-
- /** Value for arrcol. */
- private Object arrcol;
-
- /**
- * Empty constructor.
- */
- public Objects() {
- // No-op.
- }
-
- /**
- * Full constructor.
- */
- public Objects(
- int pk,
- Boolean boolcol,
- Byte bytecol,
- Short shortcol,
- Integer intcol,
- Long longcol,
- Float floatcol,
- Double doublecol,
- Double doublecol2,
- java.math.BigDecimal bigdecimalcol,
- String strcol,
- java.sql.Date datecol,
- java.sql.Time timecol,
- java.sql.Timestamp tscol,
- Object arrcol
- ) {
- this.pk = pk;
- this.boolcol = boolcol;
- this.bytecol = bytecol;
- this.shortcol = shortcol;
- this.intcol = intcol;
- this.longcol = longcol;
- this.floatcol = floatcol;
- this.doublecol = doublecol;
- this.doublecol2 = doublecol2;
- this.bigdecimalcol = bigdecimalcol;
- this.strcol = strcol;
- this.datecol = datecol;
- this.timecol = timecol;
- this.tscol = tscol;
- this.arrcol = arrcol;
- }
-
- /**
- * Gets pk.
- *
- * @return Value for pk.
- */
- public int getPk() {
- return pk;
- }
-
- /**
- * Sets pk.
- *
- * @param pk New value for pk.
- */
- public void setPk(int pk) {
- this.pk = pk;
- }
-
- /**
- * Gets boolcol.
- *
- * @return Value for boolcol.
- */
- public Boolean getBoolcol() {
- return boolcol;
- }
-
- /**
- * Sets boolcol.
- *
- * @param boolcol New value for boolcol.
- */
- public void setBoolcol(Boolean boolcol) {
- this.boolcol = boolcol;
- }
-
- /**
- * Gets bytecol.
- *
- * @return Value for bytecol.
- */
- public Byte getBytecol() {
- return bytecol;
- }
-
- /**
- * Sets bytecol.
- *
- * @param bytecol New value for bytecol.
- */
- public void setBytecol(Byte bytecol) {
- this.bytecol = bytecol;
- }
-
- /**
- * Gets shortcol.
- *
- * @return Value for shortcol.
- */
- public Short getShortcol() {
- return shortcol;
- }
-
- /**
- * Sets shortcol.
- *
- * @param shortcol New value for shortcol.
- */
- public void setShortcol(Short shortcol) {
- this.shortcol = shortcol;
- }
-
- /**
- * Gets intcol.
- *
- * @return Value for intcol.
- */
- public Integer getIntcol() {
- return intcol;
- }
-
- /**
- * Sets intcol.
- *
- * @param intcol New value for intcol.
- */
- public void setIntcol(Integer intcol) {
- this.intcol = intcol;
- }
-
- /**
- * Gets longcol.
- *
- * @return Value for longcol.
- */
- public Long getLongcol() {
- return longcol;
- }
-
- /**
- * Sets longcol.
- *
- * @param longcol New value for longcol.
- */
- public void setLongcol(Long longcol) {
- this.longcol = longcol;
- }
-
- /**
- * Gets floatcol.
- *
- * @return Value for floatcol.
- */
- public Float getFloatcol() {
- return floatcol;
- }
-
- /**
- * Sets floatcol.
- *
- * @param floatcol New value for floatcol.
- */
- public void setFloatcol(Float floatcol) {
- this.floatcol = floatcol;
- }
-
- /**
- * Gets doublecol.
- *
- * @return Value for doublecol.
- */
- public Double getDoublecol() {
- return doublecol;
- }
-
- /**
- * Sets doublecol.
- *
- * @param doublecol New value for doublecol.
- */
- public void setDoublecol(Double doublecol) {
- this.doublecol = doublecol;
- }
-
- /**
- * Gets doublecol2.
- *
- * @return Value for doublecol2.
- */
- public Double getDoublecol2() {
- return doublecol2;
- }
-
- /**
- * Sets doublecol2.
- *
- * @param doublecol2 New value for doublecol2.
- */
- public void setDoublecol2(Double doublecol2) {
- this.doublecol2 = doublecol2;
- }
-
- /**
- * Gets bigdecimalcol.
- *
- * @return Value for bigdecimalcol.
- */
- public java.math.BigDecimal getBigdecimalcol() {
- return bigdecimalcol;
- }
-
- /**
- * Sets bigdecimalcol.
- *
- * @param bigdecimalcol New value for bigdecimalcol.
- */
- public void setBigdecimalcol(java.math.BigDecimal bigdecimalcol) {
- this.bigdecimalcol = bigdecimalcol;
- }
-
- /**
- * Gets strcol.
- *
- * @return Value for strcol.
- */
- public String getStrcol() {
- return strcol;
- }
-
- /**
- * Sets strcol.
- *
- * @param strcol New value for strcol.
- */
- public void setStrcol(String strcol) {
- this.strcol = strcol;
- }
-
- /**
- * Gets datecol.
- *
- * @return Value for datecol.
- */
- public java.sql.Date getDatecol() {
- return datecol;
- }
-
- /**
- * Sets datecol.
- *
- * @param datecol New value for datecol.
- */
- public void setDatecol(java.sql.Date datecol) {
- this.datecol = datecol;
- }
-
- /**
- * Gets timecol.
- *
- * @return Value for timecol.
- */
- public java.sql.Time getTimecol() {
- return timecol;
- }
-
- /**
- * Sets timecol.
- *
- * @param timecol New value for timecol.
- */
- public void setTimecol(java.sql.Time timecol) {
- this.timecol = timecol;
- }
-
- /**
- * Gets tscol.
- *
- * @return Value for tscol.
- */
- public java.sql.Timestamp getTscol() {
- return tscol;
- }
-
- /**
- * Sets tscol.
- *
- * @param tscol New value for tscol.
- */
- public void setTscol(java.sql.Timestamp tscol) {
- this.tscol = tscol;
- }
-
- /**
- * Gets arrcol.
- *
- * @return Value for arrcol.
- */
- public Object getArrcol() {
- return arrcol;
- }
-
- /**
- * Sets arrcol.
- *
- * @param arrcol New value for arrcol.
- */
- public void setArrcol(Object arrcol) {
- this.arrcol = arrcol;
- }
-
- /** {@inheritDoc} */
- @Override public boolean equals(Object o) {
- if (this == o)
- return true;
-
- if (!(o instanceof Objects))
- return false;
-
- Objects that = (Objects)o;
-
- if (pk != that.pk)
- return false;
-
- if (boolcol != null ? !boolcol.equals(that.boolcol) : that.boolcol != null)
- return false;
-
- if (bytecol != null ? !bytecol.equals(that.bytecol) : that.bytecol != null)
- return false;
-
- if (shortcol != null ? !shortcol.equals(that.shortcol) : that.shortcol != null)
- return false;
-
- if (intcol != null ? !intcol.equals(that.intcol) : that.intcol != null)
- return false;
-
- if (longcol != null ? !longcol.equals(that.longcol) : that.longcol != null)
- return false;
-
- if (floatcol != null ? !floatcol.equals(that.floatcol) : that.floatcol != null)
- return false;
-
- if (doublecol != null ? !doublecol.equals(that.doublecol) : that.doublecol != null)
- return false;
-
- if (doublecol2 != null ? !doublecol2.equals(that.doublecol2) : that.doublecol2 != null)
- return false;
-
- if (bigdecimalcol != null ? !bigdecimalcol.equals(that.bigdecimalcol) : that.bigdecimalcol != null)
- return false;
-
- if (strcol != null ? !strcol.equals(that.strcol) : that.strcol != null)
- return false;
-
- if (datecol != null ? !datecol.equals(that.datecol) : that.datecol != null)
- return false;
-
- if (timecol != null ? !timecol.equals(that.timecol) : that.timecol != null)
- return false;
-
- if (tscol != null ? !tscol.equals(that.tscol) : that.tscol != null)
- return false;
-
- if (arrcol != null ? !arrcol.equals(that.arrcol) : that.arrcol != null)
- return false;
-
- return true;
- }
-
- /** {@inheritDoc} */
- @Override public int hashCode() {
- int res = pk;
-
- res = 31 * res + (boolcol != null ? boolcol.hashCode() : 0);
-
- res = 31 * res + (bytecol != null ? bytecol.hashCode() : 0);
-
- res = 31 * res + (shortcol != null ? shortcol.hashCode() : 0);
-
- res = 31 * res + (intcol != null ? intcol.hashCode() : 0);
-
- res = 31 * res + (longcol != null ? longcol.hashCode() : 0);
-
- res = 31 * res + (floatcol != null ? floatcol.hashCode() : 0);
-
- res = 31 * res + (doublecol != null ? doublecol.hashCode() : 0);
-
- res = 31 * res + (doublecol2 != null ? doublecol2.hashCode() : 0);
-
- res = 31 * res + (bigdecimalcol != null ? bigdecimalcol.hashCode() : 0);
-
- res = 31 * res + (strcol != null ? strcol.hashCode() : 0);
-
- res = 31 * res + (datecol != null ? datecol.hashCode() : 0);
-
- res = 31 * res + (timecol != null ? timecol.hashCode() : 0);
-
- res = 31 * res + (tscol != null ? tscol.hashCode() : 0);
-
- res = 31 * res + (arrcol != null ? arrcol.hashCode() : 0);
-
- return res;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return "Objects [pk=" + pk +
- ", boolcol=" + boolcol +
- ", bytecol=" + bytecol +
- ", shortcol=" + shortcol +
- ", intcol=" + intcol +
- ", longcol=" + longcol +
- ", floatcol=" + floatcol +
- ", doublecol=" + doublecol +
- ", doublecol2=" + doublecol2 +
- ", bigdecimalcol=" + bigdecimalcol +
- ", strcol=" + strcol +
- ", datecol=" + datecol +
- ", timecol=" + timecol +
- ", tscol=" + tscol +
- ", arrcol=" + arrcol +
- "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/ObjectsKey.txt
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/ObjectsKey.txt b/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/ObjectsKey.txt
deleted file mode 100644
index cad109c..0000000
--- a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/ObjectsKey.txt
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.apache.ignite.schema.test.model;
-
-import java.io.*;
-
-/**
- * ObjectsKey definition.
- *
- * Code generated by Apache Ignite Schema Import utility: 01/27/2015.
- */
-public class ObjectsKey implements Serializable {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** Value for pk. */
- private int pk;
-
- /**
- * Empty constructor.
- */
- public ObjectsKey() {
- // No-op.
- }
-
- /**
- * Full constructor.
- */
- public ObjectsKey(
- int pk
- ) {
- this.pk = pk;
- }
-
- /**
- * Gets pk.
- *
- * @return Value for pk.
- */
- public int getPk() {
- return pk;
- }
-
- /**
- * Sets pk.
- *
- * @param pk New value for pk.
- */
- public void setPk(int pk) {
- this.pk = pk;
- }
-
- /** {@inheritDoc} */
- @Override public boolean equals(Object o) {
- if (this == o)
- return true;
-
- if (!(o instanceof ObjectsKey))
- return false;
-
- ObjectsKey that = (ObjectsKey)o;
-
- if (pk != that.pk)
- return false;
-
- return true;
- }
-
- /** {@inheritDoc} */
- @Override public int hashCode() {
- int res = pk;
-
- return res;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return "ObjectsKey [pk=" + pk +
- "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/Primitives.txt
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/Primitives.txt b/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/Primitives.txt
deleted file mode 100644
index ef8f902..0000000
--- a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/Primitives.txt
+++ /dev/null
@@ -1,506 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.apache.ignite.schema.test.model;
-
-import java.io.*;
-
-/**
- * Primitives definition.
- *
- * Code generated by Apache Ignite Schema Import utility: 01/27/2015.
- */
-public class Primitives implements Serializable {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** Value for pk. */
- private int pk;
-
- /** Value for boolcol. */
- private boolean boolcol;
-
- /** Value for bytecol. */
- private byte bytecol;
-
- /** Value for shortcol. */
- private short shortcol;
-
- /** Value for intcol. */
- private int intcol;
-
- /** Value for longcol. */
- private long longcol;
-
- /** Value for floatcol. */
- private float floatcol;
-
- /** Value for doublecol. */
- private double doublecol;
-
- /** Value for doublecol2. */
- private double doublecol2;
-
- /** Value for bigdecimalcol. */
- private java.math.BigDecimal bigdecimalcol;
-
- /** Value for strcol. */
- private String strcol;
-
- /** Value for datecol. */
- private java.sql.Date datecol;
-
- /** Value for timecol. */
- private java.sql.Time timecol;
-
- /** Value for tscol. */
- private java.sql.Timestamp tscol;
-
- /** Value for arrcol. */
- private Object arrcol;
-
- /**
- * Empty constructor.
- */
- public Primitives() {
- // No-op.
- }
-
- /**
- * Full constructor.
- */
- public Primitives(
- int pk,
- boolean boolcol,
- byte bytecol,
- short shortcol,
- int intcol,
- long longcol,
- float floatcol,
- double doublecol,
- double doublecol2,
- java.math.BigDecimal bigdecimalcol,
- String strcol,
- java.sql.Date datecol,
- java.sql.Time timecol,
- java.sql.Timestamp tscol,
- Object arrcol
- ) {
- this.pk = pk;
- this.boolcol = boolcol;
- this.bytecol = bytecol;
- this.shortcol = shortcol;
- this.intcol = intcol;
- this.longcol = longcol;
- this.floatcol = floatcol;
- this.doublecol = doublecol;
- this.doublecol2 = doublecol2;
- this.bigdecimalcol = bigdecimalcol;
- this.strcol = strcol;
- this.datecol = datecol;
- this.timecol = timecol;
- this.tscol = tscol;
- this.arrcol = arrcol;
- }
-
- /**
- * Gets pk.
- *
- * @return Value for pk.
- */
- public int getPk() {
- return pk;
- }
-
- /**
- * Sets pk.
- *
- * @param pk New value for pk.
- */
- public void setPk(int pk) {
- this.pk = pk;
- }
-
- /**
- * Gets boolcol.
- *
- * @return Value for boolcol.
- */
- public boolean getBoolcol() {
- return boolcol;
- }
-
- /**
- * Sets boolcol.
- *
- * @param boolcol New value for boolcol.
- */
- public void setBoolcol(boolean boolcol) {
- this.boolcol = boolcol;
- }
-
- /**
- * Gets bytecol.
- *
- * @return Value for bytecol.
- */
- public byte getBytecol() {
- return bytecol;
- }
-
- /**
- * Sets bytecol.
- *
- * @param bytecol New value for bytecol.
- */
- public void setBytecol(byte bytecol) {
- this.bytecol = bytecol;
- }
-
- /**
- * Gets shortcol.
- *
- * @return Value for shortcol.
- */
- public short getShortcol() {
- return shortcol;
- }
-
- /**
- * Sets shortcol.
- *
- * @param shortcol New value for shortcol.
- */
- public void setShortcol(short shortcol) {
- this.shortcol = shortcol;
- }
-
- /**
- * Gets intcol.
- *
- * @return Value for intcol.
- */
- public int getIntcol() {
- return intcol;
- }
-
- /**
- * Sets intcol.
- *
- * @param intcol New value for intcol.
- */
- public void setIntcol(int intcol) {
- this.intcol = intcol;
- }
-
- /**
- * Gets longcol.
- *
- * @return Value for longcol.
- */
- public long getLongcol() {
- return longcol;
- }
-
- /**
- * Sets longcol.
- *
- * @param longcol New value for longcol.
- */
- public void setLongcol(long longcol) {
- this.longcol = longcol;
- }
-
- /**
- * Gets floatcol.
- *
- * @return Value for floatcol.
- */
- public float getFloatcol() {
- return floatcol;
- }
-
- /**
- * Sets floatcol.
- *
- * @param floatcol New value for floatcol.
- */
- public void setFloatcol(float floatcol) {
- this.floatcol = floatcol;
- }
-
- /**
- * Gets doublecol.
- *
- * @return Value for doublecol.
- */
- public double getDoublecol() {
- return doublecol;
- }
-
- /**
- * Sets doublecol.
- *
- * @param doublecol New value for doublecol.
- */
- public void setDoublecol(double doublecol) {
- this.doublecol = doublecol;
- }
-
- /**
- * Gets doublecol2.
- *
- * @return Value for doublecol2.
- */
- public double getDoublecol2() {
- return doublecol2;
- }
-
- /**
- * Sets doublecol2.
- *
- * @param doublecol2 New value for doublecol2.
- */
- public void setDoublecol2(double doublecol2) {
- this.doublecol2 = doublecol2;
- }
-
- /**
- * Gets bigdecimalcol.
- *
- * @return Value for bigdecimalcol.
- */
- public java.math.BigDecimal getBigdecimalcol() {
- return bigdecimalcol;
- }
-
- /**
- * Sets bigdecimalcol.
- *
- * @param bigdecimalcol New value for bigdecimalcol.
- */
- public void setBigdecimalcol(java.math.BigDecimal bigdecimalcol) {
- this.bigdecimalcol = bigdecimalcol;
- }
-
- /**
- * Gets strcol.
- *
- * @return Value for strcol.
- */
- public String getStrcol() {
- return strcol;
- }
-
- /**
- * Sets strcol.
- *
- * @param strcol New value for strcol.
- */
- public void setStrcol(String strcol) {
- this.strcol = strcol;
- }
-
- /**
- * Gets datecol.
- *
- * @return Value for datecol.
- */
- public java.sql.Date getDatecol() {
- return datecol;
- }
-
- /**
- * Sets datecol.
- *
- * @param datecol New value for datecol.
- */
- public void setDatecol(java.sql.Date datecol) {
- this.datecol = datecol;
- }
-
- /**
- * Gets timecol.
- *
- * @return Value for timecol.
- */
- public java.sql.Time getTimecol() {
- return timecol;
- }
-
- /**
- * Sets timecol.
- *
- * @param timecol New value for timecol.
- */
- public void setTimecol(java.sql.Time timecol) {
- this.timecol = timecol;
- }
-
- /**
- * Gets tscol.
- *
- * @return Value for tscol.
- */
- public java.sql.Timestamp getTscol() {
- return tscol;
- }
-
- /**
- * Sets tscol.
- *
- * @param tscol New value for tscol.
- */
- public void setTscol(java.sql.Timestamp tscol) {
- this.tscol = tscol;
- }
-
- /**
- * Gets arrcol.
- *
- * @return Value for arrcol.
- */
- public Object getArrcol() {
- return arrcol;
- }
-
- /**
- * Sets arrcol.
- *
- * @param arrcol New value for arrcol.
- */
- public void setArrcol(Object arrcol) {
- this.arrcol = arrcol;
- }
-
- /** {@inheritDoc} */
- @Override public boolean equals(Object o) {
- if (this == o)
- return true;
-
- if (!(o instanceof Primitives))
- return false;
-
- Primitives that = (Primitives)o;
-
- if (pk != that.pk)
- return false;
-
- if (boolcol != that.boolcol)
- return false;
-
- if (bytecol != that.bytecol)
- return false;
-
- if (shortcol != that.shortcol)
- return false;
-
- if (intcol != that.intcol)
- return false;
-
- if (longcol != that.longcol)
- return false;
-
- if (Float.compare(floatcol, that.floatcol) != 0)
- return false;
-
- if (Double.compare(doublecol, that.doublecol) != 0)
- return false;
-
- if (Double.compare(doublecol2, that.doublecol2) != 0)
- return false;
-
- if (bigdecimalcol != null ? !bigdecimalcol.equals(that.bigdecimalcol) : that.bigdecimalcol != null)
- return false;
-
- if (strcol != null ? !strcol.equals(that.strcol) : that.strcol != null)
- return false;
-
- if (datecol != null ? !datecol.equals(that.datecol) : that.datecol != null)
- return false;
-
- if (timecol != null ? !timecol.equals(that.timecol) : that.timecol != null)
- return false;
-
- if (tscol != null ? !tscol.equals(that.tscol) : that.tscol != null)
- return false;
-
- if (arrcol != null ? !arrcol.equals(that.arrcol) : that.arrcol != null)
- return false;
-
- return true;
- }
-
- /** {@inheritDoc} */
- @Override public int hashCode() {
- int res = pk;
-
- res = 31 * res + (boolcol ? 1 : 0);
-
- res = 31 * res + (int)bytecol;
-
- res = 31 * res + (int)shortcol;
-
- res = 31 * res + intcol;
-
- res = 31 * res + (int)(longcol ^ (longcol >>> 32));
-
- res = 31 * res + (floatcol != +0.0f ? Float.floatToIntBits(floatcol) : 0);
-
- long ig_hash_temp = Double.doubleToLongBits(doublecol);
-
- res = 31 * res + (int)(ig_hash_temp ^ (ig_hash_temp >>> 32));
-
- ig_hash_temp = Double.doubleToLongBits(doublecol2);
-
- res = 31 * res + (int)(ig_hash_temp ^ (ig_hash_temp >>> 32));
-
- res = 31 * res + (bigdecimalcol != null ? bigdecimalcol.hashCode() : 0);
-
- res = 31 * res + (strcol != null ? strcol.hashCode() : 0);
-
- res = 31 * res + (datecol != null ? datecol.hashCode() : 0);
-
- res = 31 * res + (timecol != null ? timecol.hashCode() : 0);
-
- res = 31 * res + (tscol != null ? tscol.hashCode() : 0);
-
- res = 31 * res + (arrcol != null ? arrcol.hashCode() : 0);
-
- return res;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return "Primitives [pk=" + pk +
- ", boolcol=" + boolcol +
- ", bytecol=" + bytecol +
- ", shortcol=" + shortcol +
- ", intcol=" + intcol +
- ", longcol=" + longcol +
- ", floatcol=" + floatcol +
- ", doublecol=" + doublecol +
- ", doublecol2=" + doublecol2 +
- ", bigdecimalcol=" + bigdecimalcol +
- ", strcol=" + strcol +
- ", datecol=" + datecol +
- ", timecol=" + timecol +
- ", tscol=" + tscol +
- ", arrcol=" + arrcol +
- "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/PrimitivesKey.txt
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/PrimitivesKey.txt b/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/PrimitivesKey.txt
deleted file mode 100644
index 0844e63..0000000
--- a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/PrimitivesKey.txt
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.apache.ignite.schema.test.model;
-
-import java.io.*;
-
-/**
- * PrimitivesKey definition.
- *
- * Code generated by Apache Ignite Schema Import utility: 01/27/2015.
- */
-public class PrimitivesKey implements Serializable {
- /** */
- private static final long serialVersionUID = 0L;
-
- /** Value for pk. */
- private int pk;
-
- /**
- * Empty constructor.
- */
- public PrimitivesKey() {
- // No-op.
- }
-
- /**
- * Full constructor.
- */
- public PrimitivesKey(
- int pk
- ) {
- this.pk = pk;
- }
-
- /**
- * Gets pk.
- *
- * @return Value for pk.
- */
- public int getPk() {
- return pk;
- }
-
- /**
- * Sets pk.
- *
- * @param pk New value for pk.
- */
- public void setPk(int pk) {
- this.pk = pk;
- }
-
- /** {@inheritDoc} */
- @Override public boolean equals(Object o) {
- if (this == o)
- return true;
-
- if (!(o instanceof PrimitivesKey))
- return false;
-
- PrimitivesKey that = (PrimitivesKey)o;
-
- if (pk != that.pk)
- return false;
-
- return true;
- }
-
- /** {@inheritDoc} */
- @Override public int hashCode() {
- int res = pk;
-
- return res;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return "PrimitivesKey [pk=" + pk +
- "]";
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/ignite-type-metadata.xml
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/ignite-type-metadata.xml b/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/ignite-type-metadata.xml
deleted file mode 100644
index 2de9c62..0000000
--- a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/model/ignite-type-metadata.xml
+++ /dev/null
@@ -1,362 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You 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.
--->
-
-<!--
- XML generated by Apache Ignite Schema Import utility: 02/05/2015
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:util="http://www.springframework.org/schema/util"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/util
- http://www.springframework.org/schema/util/spring-util.xsd">
- <bean class="org.apache.ignite.cache.CacheTypeMetadata">
- <property name="databaseSchema" value="PUBLIC"/>
- <property name="databaseTable" value="OBJECTS"/>
- <property name="keyType" value="org.apache.ignite.schema.test.model.ObjectsKey"/>
- <property name="valueType" value="org.apache.ignite.schema.test.model.Objects"/>
- <property name="keyFields">
- <list>
- <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
- <property name="databaseName" value="PK"/>
- <property name="databaseType">
- <util:constant static-field="java.sql.Types.INTEGER"/>
- </property>
- <property name="javaName" value="pk"/>
- <property name="javaType" value="int"/>
- </bean>
- </list>
- </property>
- <property name="valueFields">
- <list>
- <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
- <property name="databaseName" value="PK"/>
- <property name="databaseType">
- <util:constant static-field="java.sql.Types.INTEGER"/>
- </property>
- <property name="javaName" value="pk"/>
- <property name="javaType" value="int"/>
- </bean>
- <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
- <property name="databaseName" value="BOOLCOL"/>
- <property name="databaseType">
- <util:constant static-field="java.sql.Types.BOOLEAN"/>
- </property>
- <property name="javaName" value="boolcol"/>
- <property name="javaType" value="java.lang.Boolean"/>
- </bean>
- <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
- <property name="databaseName" value="BYTECOL"/>
- <property name="databaseType">
- <util:constant static-field="java.sql.Types.TINYINT"/>
- </property>
- <property name="javaName" value="bytecol"/>
- <property name="javaType" value="java.lang.Byte"/>
- </bean>
- <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
- <property name="databaseName" value="SHORTCOL"/>
- <property name="databaseType">
- <util:constant static-field="java.sql.Types.SMALLINT"/>
- </property>
- <property name="javaName" value="shortcol"/>
- <property name="javaType" value="java.lang.Short"/>
- </bean>
- <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
- <property name="databaseName" value="INTCOL"/>
- <property name="databaseType">
- <util:constant static-field="java.sql.Types.INTEGER"/>
- </property>
- <property name="javaName" value="intcol"/>
- <property name="javaType" value="java.lang.Integer"/>
- </bean>
- <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
- <property name="databaseName" value="LONGCOL"/>
- <property name="databaseType">
- <util:constant static-field="java.sql.Types.BIGINT"/>
- </property>
- <property name="javaName" value="longcol"/>
- <property name="javaType" value="java.lang.Long"/>
- </bean>
- <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
- <property name="databaseName" value="FLOATCOL"/>
- <property name="databaseType">
- <util:constant static-field="java.sql.Types.REAL"/>
- </property>
- <property name="javaName" value="floatcol"/>
- <property name="javaType" value="java.lang.Float"/>
- </bean>
- <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
- <property name="databaseName" value="DOUBLECOL"/>
- <property name="databaseType">
- <util:constant static-field="java.sql.Types.DOUBLE"/>
- </property>
- <property name="javaName" value="doublecol"/>
- <property name="javaType" value="java.lang.Double"/>
- </bean>
- <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
- <property name="databaseName" value="DOUBLECOL2"/>
- <property name="databaseType">
- <util:constant static-field="java.sql.Types.DOUBLE"/>
- </property>
- <property name="javaName" value="doublecol2"/>
- <property name="javaType" value="java.lang.Double"/>
- </bean>
- <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
- <property name="databaseName" value="BIGDECIMALCOL"/>
- <property name="databaseType">
- <util:constant static-field="java.sql.Types.DECIMAL"/>
- </property>
- <property name="javaName" value="bigdecimalcol"/>
- <property name="javaType" value="java.math.BigDecimal"/>
- </bean>
- <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
- <property name="databaseName" value="STRCOL"/>
- <property name="databaseType">
- <util:constant static-field="java.sql.Types.VARCHAR"/>
- </property>
- <property name="javaName" value="strcol"/>
- <property name="javaType" value="java.lang.String"/>
- </bean>
- <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
- <property name="databaseName" value="DATECOL"/>
- <property name="databaseType">
- <util:constant static-field="java.sql.Types.DATE"/>
- </property>
- <property name="javaName" value="datecol"/>
- <property name="javaType" value="java.sql.Date"/>
- </bean>
- <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
- <property name="databaseName" value="TIMECOL"/>
- <property name="databaseType">
- <util:constant static-field="java.sql.Types.TIME"/>
- </property>
- <property name="javaName" value="timecol"/>
- <property name="javaType" value="java.sql.Time"/>
- </bean>
- <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
- <property name="databaseName" value="TSCOL"/>
- <property name="databaseType">
- <util:constant static-field="java.sql.Types.TIMESTAMP"/>
- </property>
- <property name="javaName" value="tscol"/>
- <property name="javaType" value="java.sql.Timestamp"/>
- </bean>
- <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
- <property name="databaseName" value="ARRCOL"/>
- <property name="databaseType">
- <util:constant static-field="java.sql.Types.VARBINARY"/>
- </property>
- <property name="javaName" value="arrcol"/>
- <property name="javaType" value="java.lang.Object"/>
- </bean>
- </list>
- </property>
- <property name="queryFields">
- <map>
- <entry key="pk" value="int"/>
- <entry key="boolcol" value="java.lang.Boolean"/>
- <entry key="bytecol" value="java.lang.Byte"/>
- <entry key="shortcol" value="java.lang.Short"/>
- <entry key="intcol" value="java.lang.Integer"/>
- <entry key="longcol" value="java.lang.Long"/>
- <entry key="floatcol" value="java.lang.Float"/>
- <entry key="doublecol" value="java.lang.Double"/>
- <entry key="doublecol2" value="java.lang.Double"/>
- <entry key="bigdecimalcol" value="java.math.BigDecimal"/>
- <entry key="strcol" value="java.lang.String"/>
- <entry key="datecol" value="java.sql.Date"/>
- <entry key="timecol" value="java.sql.Time"/>
- <entry key="tscol" value="java.sql.Timestamp"/>
- <entry key="arrcol" value="java.lang.Object"/>
- </map>
- </property>
- <property name="ascendingFields">
- <map>
- <entry key="pk" value="int"/>
- </map>
- </property>
- </bean>
- <bean class="org.apache.ignite.cache.CacheTypeMetadata">
- <property name="databaseSchema" value="PUBLIC"/>
- <property name="databaseTable" value="PRIMITIVES"/>
- <property name="keyType" value="org.apache.ignite.schema.test.model.PrimitivesKey"/>
- <property name="valueType" value="org.apache.ignite.schema.test.model.Primitives"/>
- <property name="keyFields">
- <list>
- <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
- <property name="databaseName" value="PK"/>
- <property name="databaseType">
- <util:constant static-field="java.sql.Types.INTEGER"/>
- </property>
- <property name="javaName" value="pk"/>
- <property name="javaType" value="int"/>
- </bean>
- </list>
- </property>
- <property name="valueFields">
- <list>
- <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
- <property name="databaseName" value="PK"/>
- <property name="databaseType">
- <util:constant static-field="java.sql.Types.INTEGER"/>
- </property>
- <property name="javaName" value="pk"/>
- <property name="javaType" value="int"/>
- </bean>
- <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
- <property name="databaseName" value="BOOLCOL"/>
- <property name="databaseType">
- <util:constant static-field="java.sql.Types.BOOLEAN"/>
- </property>
- <property name="javaName" value="boolcol"/>
- <property name="javaType" value="boolean"/>
- </bean>
- <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
- <property name="databaseName" value="BYTECOL"/>
- <property name="databaseType">
- <util:constant static-field="java.sql.Types.TINYINT"/>
- </property>
- <property name="javaName" value="bytecol"/>
- <property name="javaType" value="byte"/>
- </bean>
- <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
- <property name="databaseName" value="SHORTCOL"/>
- <property name="databaseType">
- <util:constant static-field="java.sql.Types.SMALLINT"/>
- </property>
- <property name="javaName" value="shortcol"/>
- <property name="javaType" value="short"/>
- </bean>
- <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
- <property name="databaseName" value="INTCOL"/>
- <property name="databaseType">
- <util:constant static-field="java.sql.Types.INTEGER"/>
- </property>
- <property name="javaName" value="intcol"/>
- <property name="javaType" value="int"/>
- </bean>
- <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
- <property name="databaseName" value="LONGCOL"/>
- <property name="databaseType">
- <util:constant static-field="java.sql.Types.BIGINT"/>
- </property>
- <property name="javaName" value="longcol"/>
- <property name="javaType" value="long"/>
- </bean>
- <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
- <property name="databaseName" value="FLOATCOL"/>
- <property name="databaseType">
- <util:constant static-field="java.sql.Types.REAL"/>
- </property>
- <property name="javaName" value="floatcol"/>
- <property name="javaType" value="float"/>
- </bean>
- <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
- <property name="databaseName" value="DOUBLECOL"/>
- <property name="databaseType">
- <util:constant static-field="java.sql.Types.DOUBLE"/>
- </property>
- <property name="javaName" value="doublecol"/>
- <property name="javaType" value="double"/>
- </bean>
- <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
- <property name="databaseName" value="DOUBLECOL2"/>
- <property name="databaseType">
- <util:constant static-field="java.sql.Types.DOUBLE"/>
- </property>
- <property name="javaName" value="doublecol2"/>
- <property name="javaType" value="double"/>
- </bean>
- <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
- <property name="databaseName" value="BIGDECIMALCOL"/>
- <property name="databaseType">
- <util:constant static-field="java.sql.Types.DECIMAL"/>
- </property>
- <property name="javaName" value="bigdecimalcol"/>
- <property name="javaType" value="java.math.BigDecimal"/>
- </bean>
- <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
- <property name="databaseName" value="STRCOL"/>
- <property name="databaseType">
- <util:constant static-field="java.sql.Types.VARCHAR"/>
- </property>
- <property name="javaName" value="strcol"/>
- <property name="javaType" value="java.lang.String"/>
- </bean>
- <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
- <property name="databaseName" value="DATECOL"/>
- <property name="databaseType">
- <util:constant static-field="java.sql.Types.DATE"/>
- </property>
- <property name="javaName" value="datecol"/>
- <property name="javaType" value="java.sql.Date"/>
- </bean>
- <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
- <property name="databaseName" value="TIMECOL"/>
- <property name="databaseType">
- <util:constant static-field="java.sql.Types.TIME"/>
- </property>
- <property name="javaName" value="timecol"/>
- <property name="javaType" value="java.sql.Time"/>
- </bean>
- <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
- <property name="databaseName" value="TSCOL"/>
- <property name="databaseType">
- <util:constant static-field="java.sql.Types.TIMESTAMP"/>
- </property>
- <property name="javaName" value="tscol"/>
- <property name="javaType" value="java.sql.Timestamp"/>
- </bean>
- <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
- <property name="databaseName" value="ARRCOL"/>
- <property name="databaseType">
- <util:constant static-field="java.sql.Types.VARBINARY"/>
- </property>
- <property name="javaName" value="arrcol"/>
- <property name="javaType" value="java.lang.Object"/>
- </bean>
- </list>
- </property>
- <property name="queryFields">
- <map>
- <entry key="pk" value="int"/>
- <entry key="boolcol" value="boolean"/>
- <entry key="bytecol" value="byte"/>
- <entry key="shortcol" value="short"/>
- <entry key="intcol" value="int"/>
- <entry key="longcol" value="long"/>
- <entry key="floatcol" value="float"/>
- <entry key="doublecol" value="double"/>
- <entry key="doublecol2" value="double"/>
- <entry key="bigdecimalcol" value="java.math.BigDecimal"/>
- <entry key="strcol" value="java.lang.String"/>
- <entry key="datecol" value="java.sql.Date"/>
- <entry key="timecol" value="java.sql.Time"/>
- <entry key="tscol" value="java.sql.Timestamp"/>
- <entry key="arrcol" value="java.lang.Object"/>
- </map>
- </property>
- <property name="ascendingFields">
- <map>
- <entry key="pk" value="int"/>
- </map>
- </property>
- </bean>
-</beans>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import/src/test/java/org/apache/ignite/schema/test/parser/DbMetadataParserTest.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/parser/DbMetadataParserTest.java b/modules/schema-import/src/test/java/org/apache/ignite/schema/test/parser/DbMetadataParserTest.java
deleted file mode 100644
index b73b8b3..0000000
--- a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/parser/DbMetadataParserTest.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.apache.ignite.schema.test.parser;
-
-import org.apache.ignite.schema.test.*;
-import org.apache.ignite.schema.model.*;
-
-import java.math.*;
-import java.sql.Date;
-import java.sql.*;
-import java.util.*;
-
-/**
- * Tests for metadata parsing.
- */
-public class DbMetadataParserTest extends AbstractSchemaImportTest {
- /**
- * Check that field is correspond to expected.
- *
- * @param field Field descriptor.
- * @param name Expected field name.
- * @param primitive Expected field primitive type.
- * @param cls Expected field type.
- */
- private void checkField(PojoField field, String name, boolean primitive, Class<?> cls) {
- assertEquals("Name of field should be " + name, name, field.javaName());
-
- assertEquals("Type of field should be " + cls.getName(), cls.getName(), field.javaTypeName());
-
- assertEquals("Field primitive should be " + primitive, primitive, field.primitive());
- }
-
- /**
- * Check that type is correspond to expected.
- *
- * @param type Type descriptor.
- */
- private void checkType(PojoDescriptor type) {
- assertFalse("Type key class name should be defined", type.keyClassName().isEmpty());
-
- assertFalse("Type value class name should be defined", type.valueClassName().isEmpty());
-
- Collection<PojoField> keyFields = type.keyFields();
-
- assertEquals("Key type should have 1 field", 1, keyFields.size());
-
- checkField(keyFields.iterator().next(), "pk", true, int.class);
-
- List<PojoField> fields = type.fields();
-
- assertEquals("Value type should have 15 fields", 15, fields.size());
-
- Iterator<PojoField> fieldsIt = fields.iterator();
-
- checkField(fieldsIt.next(), "pk", true, int.class);
-
- if ("Objects".equals(type.valueClassName())) {
- checkField(fieldsIt.next(), "boolcol", false, Boolean.class);
- checkField(fieldsIt.next(), "bytecol", false, Byte.class);
- checkField(fieldsIt.next(), "shortcol", false, Short.class);
- checkField(fieldsIt.next(), "intcol", false, Integer.class);
- checkField(fieldsIt.next(), "longcol", false, Long.class);
- checkField(fieldsIt.next(), "floatcol", false, Float.class);
- checkField(fieldsIt.next(), "doublecol", false, Double.class);
- checkField(fieldsIt.next(), "doublecol2", false, Double.class);
- }
- else {
- checkField(fieldsIt.next(), "boolcol", true, boolean.class);
- checkField(fieldsIt.next(), "bytecol", true, byte.class);
- checkField(fieldsIt.next(), "shortcol", true, short.class);
- checkField(fieldsIt.next(), "intcol", true, int.class);
- checkField(fieldsIt.next(), "longcol", true, long.class);
- checkField(fieldsIt.next(), "floatcol", true, float.class);
- checkField(fieldsIt.next(), "doublecol", true, double.class);
- checkField(fieldsIt.next(), "doublecol2", true, double.class);
- }
-
- checkField(fieldsIt.next(), "bigdecimalcol", false, BigDecimal.class);
- checkField(fieldsIt.next(), "strcol", false, String.class);
- checkField(fieldsIt.next(), "datecol", false, Date.class);
- checkField(fieldsIt.next(), "timecol", false, Time.class);
- checkField(fieldsIt.next(), "tscol", false, Timestamp.class);
- checkField(fieldsIt.next(), "arrcol", false, Object.class);
- }
-
- /**
- * Test that metadata generated correctly.
- */
- public void testCheckMetadata() {
- assertEquals("Metadata should contain 3 element", 3, pojos.size());
-
- Iterator<PojoDescriptor> it = pojos.iterator();
-
- PojoDescriptor schema = it.next();
-
- assertTrue("First element is schema description. Its class name should be empty",
- schema.valueClassName().isEmpty());
-
- checkType(it.next());
-
- checkType(it.next());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import/src/test/java/org/apache/ignite/schema/test/testsuites/IgniteSchemaImportTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/testsuites/IgniteSchemaImportTestSuite.java b/modules/schema-import/src/test/java/org/apache/ignite/schema/test/testsuites/IgniteSchemaImportTestSuite.java
deleted file mode 100644
index 571264e..0000000
--- a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/testsuites/IgniteSchemaImportTestSuite.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.apache.ignite.schema.test.testsuites;
-
-import junit.framework.*;
-import org.apache.ignite.schema.test.generator.*;
-import org.apache.ignite.schema.test.parser.*;
-
-/**
- * Ignite Schema Import Utility Tests.
- */
-public class IgniteSchemaImportTestSuite {
- /**
- * @return Test suite.
- * @throws Exception Thrown in case of the failure.
- */
- public static TestSuite suite() throws Exception {
- TestSuite suite = new TestSuite("Ignite Apache Schema Import Utility Test Suite");
-
- suite.addTestSuite(CodeGeneratorTest.class);
- suite.addTestSuite(XmlGeneratorTest.class);
- suite.addTestSuite(DbMetadataParserTest.class);
-
- return suite;
- }
-}
[3/7] incubator-ignite git commit: IGNITE-1155 Extract
ignite-schema-import-ui module.
Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java b/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java
deleted file mode 100644
index 7b9c220..0000000
--- a/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java
+++ /dev/null
@@ -1,1764 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.apache.ignite.schema.ui;
-
-import javafx.application.*;
-import javafx.beans.value.*;
-import javafx.collections.*;
-import javafx.concurrent.*;
-import javafx.event.*;
-import javafx.geometry.*;
-import javafx.geometry.Insets;
-import javafx.scene.*;
-import javafx.scene.control.*;
-import javafx.scene.layout.*;
-import javafx.stage.*;
-import javafx.util.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.apache.ignite.schema.generator.*;
-import org.apache.ignite.schema.model.*;
-import org.apache.ignite.schema.parser.*;
-
-import java.io.*;
-import java.net.*;
-import java.sql.*;
-import java.util.*;
-import java.util.List;
-import java.util.concurrent.*;
-import java.util.logging.*;
-
-import static javafx.embed.swing.SwingFXUtils.*;
-import static org.apache.ignite.schema.ui.Controls.*;
-
-/**
- * Schema Import utility application.
- */
-@SuppressWarnings("UnnecessaryFullyQualifiedName")
-public class SchemaImportApp extends Application {
- /** Logger. */
- private static final Logger log = Logger.getLogger(SchemaImportApp.class.getName());
-
- /** Presets for database settings. */
- private static class Preset {
- /** Name in preferences. */
- private String pref;
-
- /** RDBMS name to show on screen. */
- private String name;
-
- /** Path to JDBC driver jar. */
- private String jar;
-
- /** JDBC driver class name. */
- private String drv;
-
- /** JDBC URL. */
- private String url;
-
- /** User name. */
- private String user;
-
- /**
- * Preset constructor.
- *
- * @param pref Name in preferences.
- * @param name RDBMS name to show on screen.
- * @param jar Path to JDBC driver jar..
- * @param drv JDBC driver class name.
- * @param url JDBC URL.
- * @param user User name.
- */
- Preset(String pref, String name, String jar, String drv, String url, String user) {
- this.pref = pref;
- this.name = name;
- this.jar = jar;
- this.drv = drv;
- this.url = url;
- this.user = user;
- }
-
- /** {@inheritDoc} */
- @Override public String toString() {
- return name;
- }
- }
-
- /** Default presets for popular databases. */
- private final Preset[] presets = {
- new Preset("h2", "H2 Database", "h2.jar", "org.h2.Driver", "jdbc:h2:[database]", "sa"),
- new Preset("db2", "DB2", "db2jcc4.jar", "com.ibm.db2.jcc.DB2Driver", "jdbc:db2://[host]:[port]/[database]",
- "db2admin"),
- new Preset("oracle", "Oracle", "ojdbc6.jar", "oracle.jdbc.OracleDriver",
- "jdbc:oracle:thin:@[host]:[port]:[database]", "system"),
- new Preset("mysql", "MySQL", "mysql-connector-java-5-bin.jar", "com.mysql.jdbc.Driver",
- "jdbc:mysql://[host]:[port]/[database]", "root"),
- new Preset("mssql", "Microsoft SQL Server", "sqljdbc41.jar", "com.microsoft.sqlserver.jdbc.SQLServerDriver",
- "jdbc:sqlserver://[host]:[port][;databaseName=database]", "sa"),
- new Preset("postgresql", "PostgreSQL", "postgresql-9.3.jdbc4.jar", "org.postgresql.Driver",
- "jdbc:postgresql://[host]:[port]/[database]", "sa"),
- new Preset("custom", "Custom server...", "custom-jdbc.jar", "org.custom.Driver", "jdbc:custom", "sa")
- };
-
- /** */
- private static final String PREF_WINDOW_X = "window.x";
- /** */
- private static final String PREF_WINDOW_Y = "window.y";
- /** */
- private static final String PREF_WINDOW_WIDTH = "window.width";
- /** */
- private static final String PREF_WINDOW_HEIGHT = "window.height";
-
- /** */
- private static final String PREF_JDBC_DB_PRESET = "jdbc.db.preset";
- /** */
- private static final String PREF_JDBC_DRIVER_JAR = "jdbc.driver.jar";
- /** */
- private static final String PREF_JDBC_DRIVER_CLASS = "jdbc.driver.class";
- /** */
- private static final String PREF_JDBC_URL = "jdbc.url";
- /** */
- private static final String PREF_JDBC_USER = "jdbc.user";
-
- /** */
- private static final String PREF_OUT_FOLDER = "out.folder";
-
- /** */
- private static final String PREF_POJO_PACKAGE = "pojo.package";
- /** */
- private static final String PREF_POJO_INCLUDE = "pojo.include";
- /** */
- private static final String PREF_POJO_CONSTRUCTOR = "pojo.constructor";
-
- /** */
- private static final String PREF_XML_SINGLE = "xml.single";
-
- /** */
- private static final String PREF_NAMING_PATTERN = "naming.pattern";
- /** */
- private static final String PREF_NAMING_REPLACE = "naming.replace";
-
- /** */
- private Stage owner;
-
- /** */
- private BorderPane rootPane;
-
- /** Header pane. */
- private BorderPane hdrPane;
-
- /** */
- private HBox dbIcon;
-
- /** */
- private HBox genIcon;
-
- /** */
- private Label titleLb;
-
- /** */
- private Label subTitleLb;
-
- /** */
- private Button prevBtn;
-
- /** */
- private Button nextBtn;
-
- /** */
- private ComboBox<Preset> rdbmsCb;
-
- /** */
- private TextField jdbcDrvJarTf;
-
- /** */
- private TextField jdbcDrvClsTf;
-
- /** */
- private TextField jdbcUrlTf;
-
- /** */
- private TextField userTf;
-
- /** */
- private PasswordField pwdTf;
-
- /** */
- private ComboBox<String> parseCb;
-
- /** */
- private GridPaneEx connPnl;
-
- /** */
- private StackPane connLayerPnl;
-
- /** */
- private TableView<PojoDescriptor> pojosTbl;
-
- /** */
- private TableView<PojoField> fieldsTbl;
-
- /** */
- private Node curTbl;
-
- /** */
- private TextField outFolderTf;
-
- /** */
- private TextField pkgTf;
-
- /** */
- private CheckBox pojoConstructorCh;
-
- /** */
- private CheckBox pojoIncludeKeysCh;
-
- /** */
- private CheckBox xmlSingleFileCh;
-
- /** */
- private TextField regexTf;
-
- /** */
- private TextField replaceTf;
-
- /** */
- private GridPaneEx genPnl;
-
- /** */
- private StackPane genLayerPnl;
-
- /** */
- private ProgressIndicator pi;
-
- /** List with POJOs descriptors. */
- private ObservableList<PojoDescriptor> pojos = FXCollections.emptyObservableList();
-
- /** Currently selected POJO. */
- private PojoDescriptor curPojo;
-
- /** */
- private final Map<String, Driver> drivers = new HashMap<>();
-
- /** Application preferences. */
- private final Properties prefs = new Properties();
-
- /** File path for storing on local file system. */
- private final File prefsFile = new File(System.getProperty("user.home"), ".ignite-schema-import");
-
- /** Empty POJO fields model. */
- private static final ObservableList<PojoField> NO_FIELDS = FXCollections.emptyObservableList();
-
- /** */
- private final ExecutorService exec = Executors.newSingleThreadExecutor(new ThreadFactory() {
- @Override public Thread newThread(Runnable r) {
- Thread t = new Thread(r, "ignite-schema-import-worker");
-
- t.setDaemon(true);
-
- return t;
- }
- });
-
- /**
- * Lock UI before start long task.
- *
- * @param layer Stack pane to add progress indicator.
- * @param controls Controls to disable.
- */
- private void lockUI(StackPane layer, Node... controls) {
- for (Node control : controls)
- control.setDisable(true);
-
- layer.getChildren().add(pi);
- }
-
- /**
- * Unlock UI after long task finished.
- *
- * @param layer Stack pane to remove progress indicator.
- * @param controls Controls to enable.
- */
- private void unlockUI(StackPane layer, Node... controls) {
- for (Node control : controls)
- control.setDisable(false);
-
- layer.getChildren().remove(pi);
- }
-
- /**
- * Perceptual delay to avoid UI flickering.
- *
- * @param started Time when background progress started.
- */
- private void perceptualDelay(long started) {
- long delta = System.currentTimeMillis() - started;
-
- if (delta < 500)
- try {
- Thread.sleep(500 - delta);
- }
- catch (InterruptedException ignored) {
- Thread.currentThread().interrupt();
- }
- }
-
- /**
- * Fill tree with database metadata.
- */
- private void fill() {
- lockUI(connLayerPnl, connPnl, nextBtn);
-
- final String jdbcDrvJarPath = jdbcDrvJarTf.getText().trim();
-
- final String jdbcDrvCls = jdbcDrvClsTf.getText();
-
- final String jdbcUrl = jdbcUrlTf.getText();
-
- String user = userTf.getText().trim();
-
- String pwd = pwdTf.getText().trim();
-
- final Properties jdbcInfo = new Properties();
-
- if (!user.isEmpty())
- jdbcInfo.put("user", user);
-
- if (!pwd.isEmpty())
- jdbcInfo.put("password", pwd);
-
- final boolean tblsOnly = parseCb.getSelectionModel().getSelectedIndex() == 0;
-
- Runnable task = new Task<Void>() {
- /** {@inheritDoc} */
- @Override protected Void call() throws Exception {
- long started = System.currentTimeMillis();
-
- try (Connection conn = connect(jdbcDrvJarPath, jdbcDrvCls, jdbcUrl, jdbcInfo)) {
- pojos = DatabaseMetadataParser.parse(conn, tblsOnly);
- }
-
- perceptualDelay(started);
-
- return null;
- }
-
- /** {@inheritDoc} */
- @Override protected void succeeded() {
- try {
- super.succeeded();
-
- pojosTbl.setItems(pojos);
-
- if (pojos.isEmpty()) {
- MessageBox.warningDialog(owner, "No tables found in database. Recheck JDBC URL.\n" +
- "JDBC URL: " + jdbcUrl);
-
- return;
- }
- else
- pojosTbl.getSelectionModel().clearAndSelect(0);
-
- curTbl = pojosTbl;
-
- pojosTbl.requestFocus();
-
-
- hdrPane.setLeft(genIcon);
-
- titleLb.setText("Generate XML And POJOs");
- subTitleLb.setText(jdbcUrlTf.getText());
-
- rootPane.setCenter(genLayerPnl);
-
- prevBtn.setDisable(false);
- nextBtn.setText("Generate");
- tooltip(nextBtn, "Generate XML and POJO files");
- }
- finally {
- unlockUI(connLayerPnl, connPnl, nextBtn);
- }
- }
-
- /** {@inheritDoc} */
- @Override protected void cancelled() {
- super.cancelled();
-
- unlockUI(connLayerPnl, connPnl, nextBtn);
- }
-
- /** {@inheritDoc} */
- @Override protected void failed() {
- super.succeeded();
-
- unlockUI(connLayerPnl, connPnl, nextBtn);
-
- MessageBox.errorDialog(owner, "Failed to get tables list from database.", getException());
- }
- };
-
- exec.submit(task);
- }
-
- /**
- * Generate XML and POJOs.
- */
- private void generate() {
- final Collection<PojoDescriptor> selPojos = checkedPojos();
-
- if (selPojos.isEmpty()) {
- MessageBox.warningDialog(owner, "Please select tables to generate XML and POJOs files!");
-
- return;
- }
-
- if (checkInput(outFolderTf, true, "Output folder should not be empty!"))
- return;
-
- lockUI(genLayerPnl, genPnl, prevBtn, nextBtn);
-
- final String outFolder = outFolderTf.getText();
-
- final String pkg = pkgTf.getText();
-
- final File destFolder = new File(outFolder);
-
- final boolean constructor = pojoConstructorCh.isSelected();
-
- final boolean includeKeys = pojoIncludeKeysCh.isSelected();
-
- final boolean singleXml = xmlSingleFileCh.isSelected();
-
- Runnable task = new Task<Void>() {
- /**
- * @param pojo POJO descriptor to check.
- * @param selected Selected flag.
- * @param msg Message to show in case of check failed.
- */
- private void checkEmpty(final PojoDescriptor pojo, boolean selected, String msg) {
- if (!selected) {
- Platform.runLater(new Runnable() {
- @Override public void run() {
- TableView.TableViewSelectionModel<PojoDescriptor> selMdl = pojosTbl.getSelectionModel();
-
- selMdl.clearSelection();
- selMdl.select(pojo);
- pojosTbl.scrollTo(selMdl.getSelectedIndex());
- }
- });
-
- throw new IllegalStateException(msg + pojo.table());
- }
- }
-
- /** {@inheritDoc} */
- @Override protected Void call() throws Exception {
- long started = System.currentTimeMillis();
-
- if (!destFolder.exists() && !destFolder.mkdirs())
- throw new IOException("Failed to create output folder: " + destFolder);
-
- Collection<PojoDescriptor> all = new ArrayList<>();
-
- ConfirmCallable askOverwrite = new ConfirmCallable(owner, "File already exists: %s\nOverwrite?");
-
- // Generate XML and POJO.
- for (PojoDescriptor pojo : selPojos) {
- if (pojo.checked()) {
- checkEmpty(pojo, pojo.hasFields(), "No fields selected for type: ");
- checkEmpty(pojo, pojo.hasKeyFields(), "No key fields selected for type: ");
- checkEmpty(pojo, pojo.hasValueFields(includeKeys), "No value fields selected for type: ");
-
- all.add(pojo);
- }
- }
-
- for (PojoDescriptor pojo : all) {
- if (!singleXml)
- XmlGenerator.generate(pkg, pojo, includeKeys, new File(destFolder, pojo.table() + ".xml"),
- askOverwrite);
-
- CodeGenerator.pojos(pojo, outFolder, pkg, constructor, includeKeys, askOverwrite);
- }
-
- if (singleXml)
- XmlGenerator.generate(pkg, all, includeKeys, new File(outFolder, "ignite-type-metadata.xml"), askOverwrite);
-
- CodeGenerator.snippet(all, pkg, includeKeys, outFolder, askOverwrite);
-
- perceptualDelay(started);
-
- return null;
- }
-
- /** {@inheritDoc} */
- @Override protected void succeeded() {
- super.succeeded();
-
- unlockUI(genLayerPnl, genPnl, prevBtn, nextBtn);
-
- if (MessageBox.confirmDialog(owner, "Generation complete!\n\n" +
- "Reveal output folder in system default file browser?"))
- try {
- java.awt.Desktop.getDesktop().open(destFolder);
- }
- catch (IOException e) {
- MessageBox.errorDialog(owner, "Failed to open folder with results.", e);
- }
- }
-
- /** {@inheritDoc} */
- @Override protected void cancelled() {
- super.cancelled();
-
- unlockUI(genLayerPnl, genPnl, prevBtn, nextBtn);
-
- MessageBox.warningDialog(owner, "Generation canceled.");
- }
-
- /** {@inheritDoc} */
- @Override protected void failed() {
- super.succeeded();
-
- unlockUI(genLayerPnl, genPnl, prevBtn, nextBtn);
-
- MessageBox.errorDialog(owner, "Generation failed.", getException());
- }
- };
-
- exec.submit(task);
- }
-
- /**
- * @return Header pane with title label.
- */
- private BorderPane createHeaderPane() {
- dbIcon = hBox(0, true, imageView("data_connection", 48));
- genIcon = hBox(0, true, imageView("text_tree", 48));
-
- titleLb = label("");
- titleLb.setId("banner");
-
- subTitleLb = label("");
-
- BorderPane bp = borderPane(null, vBox(5, titleLb, subTitleLb), null, dbIcon, hBox(0, true, imageView("ignite", 48)));
- bp.setId("banner");
-
- return bp;
- }
-
- /**
- * @return Panel with control buttons.
- */
- private Pane createButtonsPane() {
- prevBtn = button("Prev", "Go to \"Database connection\" page", new EventHandler<ActionEvent>() {
- @Override public void handle(ActionEvent evt) {
- prev();
- }
- });
-
- nextBtn = button("Next", "Go to \"POJO and XML generation\" page", new EventHandler<ActionEvent>() {
- @Override public void handle(ActionEvent evt) {
- next();
- }
- });
-
- return buttonsPane(Pos.BOTTOM_RIGHT, true, prevBtn, nextBtn);
- }
-
- /**
- * @return {@code true} if some changes were made to fields metadata.
- */
- private boolean changed() {
- for (PojoDescriptor pojo : pojos)
- if (pojo.changed())
- return true;
-
- return false;
- }
-
- /**
- * Go to "Connect To Database" panel.
- */
- private void prev() {
- if (changed() && !MessageBox.confirmDialog(owner, "Are you sure you want to return to previous page?\n" +
- "This will discard all your changes."))
- return;
-
- hdrPane.setLeft(dbIcon);
-
- titleLb.setText("Connect To Database");
- subTitleLb.setText("Specify database connection properties...");
-
- rootPane.setCenter(connLayerPnl);
-
- prevBtn.setDisable(true);
- nextBtn.setText("Next");
- tooltip(nextBtn, "Go to \"XML and POJO generation\" page");
- }
-
- /**
- * Check that text field is non empty.
- *
- * @param tf Text field check.
- * @param trim If {@code true} then
- * @param msg Warning message.
- * @return {@code true} If text field is empty.
- */
- private boolean checkInput(TextField tf, boolean trim, String msg) {
- String s = tf.getText();
-
- s = trim ? s.trim() : s;
-
- if (s.isEmpty()) {
- tf.requestFocus();
-
- MessageBox.warningDialog(owner, msg);
-
- return true;
- }
-
- return false;
- }
-
- /**
- * Go to "Generate XML And POJOs" panel or generate XML and POJOs.
- */
- private void next() {
- if (rootPane.getCenter() == connLayerPnl) {
- if (checkInput(jdbcDrvJarTf, true, "Path to JDBC driver is not specified!") ||
- checkInput(jdbcDrvClsTf, true, "JDBC driver class name is not specified!") ||
- checkInput(jdbcUrlTf, true, "JDBC URL connection string is not specified!") ||
- checkInput(userTf, true, "User name is not specified!"))
- return;
-
- fill();
- }
- else
- generate();
- }
-
- /**
- * Connect to database.
- *
- * @param jdbcDrvJarPath Path to JDBC driver.
- * @param jdbcDrvCls JDBC class name.
- * @param jdbcUrl JDBC connection URL.
- * @param jdbcInfo Connection properties.
- * @return Connection to database.
- * @throws SQLException if connection failed.
- */
- private Connection connect(String jdbcDrvJarPath, String jdbcDrvCls, String jdbcUrl, Properties jdbcInfo)
- throws SQLException {
- Driver drv = drivers.get(jdbcDrvCls);
-
- if (drv == null) {
- if (jdbcDrvJarPath.isEmpty())
- throw new IllegalStateException("Driver jar file name is not specified.");
-
- File drvJar = new File(jdbcDrvJarPath);
-
- if (!drvJar.exists())
- throw new IllegalStateException("Driver jar file is not found.");
-
- try {
- URL u = new URL("jar:" + drvJar.toURI() + "!/");
-
- URLClassLoader ucl = URLClassLoader.newInstance(new URL[] {u});
-
- drv = (Driver)Class.forName(jdbcDrvCls, true, ucl).newInstance();
-
- drivers.put(jdbcDrvCls, drv);
- }
- catch (Exception e) {
- throw new IllegalStateException(e);
- }
- }
-
- Connection conn = drv.connect(jdbcUrl, jdbcInfo);
-
- if (conn == null)
- throw new IllegalStateException("Connection was not established (JDBC driver returned null value).");
-
- return conn;
- }
-
- /**
- * Create connection pane with controls.
- *
- * @return Pane with connection controls.
- */
- private Pane createConnectionPane() {
- connPnl = paneEx(10, 10, 0, 10);
-
- connPnl.addColumn();
- connPnl.addColumn(100, 100, Double.MAX_VALUE, Priority.ALWAYS);
- connPnl.addColumn(35, 35, 35, Priority.NEVER);
-
- connPnl.add(text("This utility is designed to automatically generate configuration XML files and" +
- " POJO classes from database schema information.", 550), 3);
-
- connPnl.wrap();
-
- GridPaneEx presetPnl = paneEx(0, 0, 0, 0);
- presetPnl.addColumn(100, 100, Double.MAX_VALUE, Priority.ALWAYS);
- presetPnl.addColumn();
-
- rdbmsCb = presetPnl.add(comboBox("Select database server to get predefined settings", presets));
-
- presetPnl.add(button("Save preset", "Save current settings in preferences", new EventHandler<ActionEvent>() {
- @Override public void handle(ActionEvent evt) {
- Preset preset = rdbmsCb.getSelectionModel().getSelectedItem();
-
- savePreset(preset);
- }
- }));
-
- connPnl.add(label("DB Preset:"));
- connPnl.add(presetPnl, 2);
-
- jdbcDrvJarTf = connPnl.addLabeled("Driver JAR:", textField("Path to driver jar"));
-
- connPnl.add(button("...", "Select JDBC driver jar or zip", new EventHandler<ActionEvent>() {
- /** {@inheritDoc} */
- @Override public void handle(ActionEvent evt) {
- FileChooser fc = new FileChooser();
-
- try {
- File jarFolder = new File(jdbcDrvJarTf.getText()).getParentFile();
-
- if (jarFolder.exists())
- fc.setInitialDirectory(jarFolder);
- }
- catch (Exception ignored) {
- // No-op.
- }
-
- jdbcDrvJarTf.getText();
-
- fc.getExtensionFilters().addAll(
- new FileChooser.ExtensionFilter("JDBC Drivers (*.jar)", "*.jar"),
- new FileChooser.ExtensionFilter("ZIP archives (*.zip)", "*.zip"));
-
- File drvJar = fc.showOpenDialog(owner);
-
- if (drvJar != null)
- jdbcDrvJarTf.setText(drvJar.getAbsolutePath());
- }
- }));
-
- jdbcDrvClsTf = connPnl.addLabeled("JDBC Driver:", textField("Enter class name for JDBC driver"), 2);
-
- jdbcUrlTf = connPnl.addLabeled("JDBC URL:", textField("JDBC URL of the database connection string"), 2);
-
- rdbmsCb.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Preset>() {
- @Override public void changed(ObservableValue<? extends Preset> val, Preset oldVal, Preset newVal) {
- jdbcDrvJarTf.setText(newVal.jar);
- jdbcDrvClsTf.setText(newVal.drv);
- jdbcUrlTf.setText(newVal.url);
- userTf.setText(newVal.user);
- }
- });
-
- userTf = connPnl.addLabeled("User:", textField("User name"), 2);
-
- pwdTf = connPnl.addLabeled("Password:", passwordField("User password"), 2);
-
- parseCb = connPnl.addLabeled("Parse:", comboBox("Type of tables to parse", "Tables only", "Tables and Views"), 2);
-
- connLayerPnl = stackPane(connPnl);
-
- return connLayerPnl;
- }
-
- /**
- * Check if new class name is unique.
- *
- * @param pojo Current edited POJO.
- * @param newVal New value for class name.
- * @param key {@code true} if key class name is checked.
- * @return {@code true} if class name is valid.
- */
- private boolean checkClassNameUnique(PojoDescriptor pojo, String newVal, boolean key) {
- for (PojoDescriptor otherPojo : pojos)
- if (pojo != otherPojo) {
- String otherKeyCls = otherPojo.keyClassName();
- String otherValCls = otherPojo.valueClassName();
-
- if (newVal.equals(otherKeyCls) || newVal.equals(otherValCls)) {
- MessageBox.warningDialog(owner, (key ? "Key" : "Value") + " class name must be unique!");
-
- return false;
- }
- }
-
- return true;
- }
-
- /**
- * Check if new class name is valid.
- *
- * @param pojo Current edited POJO.
- * @param newVal New value for class name.
- * @param key {@code true} if key class name is checked.
- * @return {@code true} if class name is valid.
- */
- private boolean checkClassName(PojoDescriptor pojo, String newVal, boolean key) {
- if (newVal.trim().isEmpty()) {
- MessageBox.warningDialog(owner, (key ? "Key" : "Value") + " class name must be non empty!");
-
- return false;
- }
-
- if (key) {
- if (newVal.equals(pojo.valueClassName())) {
- MessageBox.warningDialog(owner, "Key class name must be different from value class name!");
-
- return false;
- }
- }
- else if (newVal.equals(pojo.keyClassName())) {
- MessageBox.warningDialog(owner, "Value class name must be different from key class name!");
-
- return false;
- }
-
- return checkClassNameUnique(pojo, newVal, key);
- }
-
- /**
- * Create generate pane with controls.
- */
- private void createGeneratePane() {
- genPnl = paneEx(10, 10, 0, 10);
-
- genPnl.addColumn();
- genPnl.addColumn(100, 100, Double.MAX_VALUE, Priority.ALWAYS);
- genPnl.addColumn(35, 35, 35, Priority.NEVER);
-
- genPnl.addRow(100, 100, Double.MAX_VALUE, Priority.ALWAYS);
- genPnl.addRows(7);
-
- TableColumn<PojoDescriptor, Boolean> useCol = customColumn("Schema / Table", "use",
- "If checked then this table will be used for XML and POJOs generation", PojoDescriptorCell.cellFactory());
-
- TableColumn<PojoDescriptor, String> keyClsCol = textColumn("Key Class Name", "keyClassName", "Key class name",
- new TextColumnValidator<PojoDescriptor>() {
- @Override public boolean valid(PojoDescriptor rowVal, String newVal) {
- boolean valid = checkClassName(rowVal, newVal, true);
-
- if (valid)
- rowVal.keyClassName(newVal);
-
- return valid;
- }
- });
-
- TableColumn<PojoDescriptor, String> valClsCol = textColumn("Value Class Name", "valueClassName", "Value class name",
- new TextColumnValidator<PojoDescriptor>() {
- @Override public boolean valid(PojoDescriptor rowVal, String newVal) {
- boolean valid = checkClassName(rowVal, newVal, false);
-
- if (valid)
- rowVal.valueClassName(newVal);
-
- return valid;
- }
- });
-
- pojosTbl = tableView("Tables not found in database", useCol, keyClsCol, valClsCol);
-
- TableColumn<PojoField, Boolean> useFldCol = customColumn("Use", "use",
- "Check to use this field for XML and POJO generation\n" +
- "Note that NOT NULL columns cannot be unchecked", PojoFieldUseCell.cellFactory());
- useFldCol.setMinWidth(50);
- useFldCol.setMaxWidth(50);
-
- TableColumn<PojoField, Boolean> keyCol = booleanColumn("Key", "key",
- "Check to include this field into key object");
-
- TableColumn<PojoField, Boolean> akCol = booleanColumn("AK", "affinityKey",
- "Check to annotate key filed with @AffinityKeyMapped annotation in generated POJO class\n" +
- "Note that a class can have only ONE key field annotated with @AffinityKeyMapped annotation");
-
- TableColumn<PojoField, String> dbNameCol = tableColumn("DB Name", "dbName", "Field name in database");
-
- TableColumn<PojoField, String> dbTypeNameCol = tableColumn("DB Type", "dbTypeName", "Field type in database");
-
- TableColumn<PojoField, String> javaNameCol = textColumn("Java Name", "javaName", "Field name in POJO class",
- new TextColumnValidator<PojoField>() {
- @Override public boolean valid(PojoField rowVal, String newVal) {
- if (newVal.trim().isEmpty()) {
- MessageBox.warningDialog(owner, "Java name must be non empty!");
-
- return false;
- }
-
- for (PojoField field : curPojo.fields())
- if (rowVal != field && newVal.equals(field.javaName())) {
- MessageBox.warningDialog(owner, "Java name must be unique!");
-
- return false;
- }
-
- rowVal.javaName(newVal);
-
- return true;
- }
- });
-
- TableColumn<PojoField, String> javaTypeNameCol = customColumn("Java Type", "javaTypeName",
- "Field java type in POJO class", JavaTypeCell.cellFactory());
-
- fieldsTbl = tableView("Select table to see table columns",
- useFldCol, keyCol, akCol, dbNameCol, dbTypeNameCol, javaNameCol, javaTypeNameCol);
-
- genPnl.add(splitPane(pojosTbl, fieldsTbl, 0.6), 3);
-
- final GridPaneEx keyValPnl = paneEx(0, 0, 0, 0);
- keyValPnl.addColumn(100, 100, Double.MAX_VALUE, Priority.ALWAYS);
- keyValPnl.addColumn();
- keyValPnl.addColumn(100, 100, Double.MAX_VALUE, Priority.ALWAYS);
- keyValPnl.addColumn();
-
- pkgTf = genPnl.addLabeled("Package:", textField("Package that will be used for POJOs generation"), 2);
-
- outFolderTf = genPnl.addLabeled("Output Folder:", textField("Output folder for XML and POJOs files"));
-
- genPnl.add(button("...", "Select output folder", new EventHandler<ActionEvent>() {
- @Override public void handle(ActionEvent evt) {
- DirectoryChooser dc = new DirectoryChooser();
-
- try {
- File outFolder = new File(outFolderTf.getText());
-
- if (outFolder.exists())
- dc.setInitialDirectory(outFolder);
- }
- catch (Exception ignored) {
- // No-op.
- }
-
- File folder = dc.showDialog(owner);
-
- if (folder != null)
- outFolderTf.setText(folder.getAbsolutePath());
- }
- }));
-
- pojoIncludeKeysCh = genPnl.add(checkBox("Include key fields into value POJOs",
- "If selected then include key fields into value object", true), 3);
-
- pojoConstructorCh = genPnl.add(checkBox("Generate constructors for POJOs",
- "If selected then generate empty and full constructors for POJOs", false), 3);
-
- xmlSingleFileCh = genPnl.add(checkBox("Write all configurations to a single XML file",
- "If selected then all configurations will be saved into the file 'ignite-type-metadata.xml'", true), 3);
-
- GridPaneEx regexPnl = paneEx(5, 5, 5, 5);
- regexPnl.addColumn();
- regexPnl.addColumn(100, 100, Double.MAX_VALUE, Priority.ALWAYS);
- regexPnl.addColumn();
- regexPnl.addColumn(100, 100, Double.MAX_VALUE, Priority.ALWAYS);
-
- regexTf = regexPnl.addLabeled(" Regexp:", textField("Regular expression. For example: (\\w+)"));
-
- replaceTf = regexPnl.addLabeled(" Replace with:", textField("Replace text. For example: $1_SomeText"));
-
- final ComboBox<String> replaceCb = regexPnl.addLabeled(" Replace:", comboBox("Replacement target",
- "Key class names", "Value class names", "Java names"));
-
- regexPnl.add(buttonsPane(Pos.CENTER_LEFT, false,
- button("Rename Selected", "Replaces each substring of this string that matches the given regular expression" +
- " with the given replacement",
- new EventHandler<ActionEvent>() {
- @Override public void handle(ActionEvent evt) {
- if (checkInput(regexTf, false, "Regular expression should not be empty!"))
- return;
-
- String sel = replaceCb.getSelectionModel().getSelectedItem();
-
- boolean isFields = "Java names".equals(sel) && curTbl == fieldsTbl;
-
- String src = isFields ? "fields" : "tables";
-
- String target = "\"" + sel + "\"";
-
- Collection<PojoDescriptor> selPojos = pojosTbl.getSelectionModel().getSelectedItems();
-
- Collection<PojoField> selFields = fieldsTbl.getSelectionModel().getSelectedItems();
-
- boolean isEmpty = isFields ? selFields.isEmpty() : selPojos.isEmpty();
-
- if (isEmpty) {
- MessageBox.warningDialog(owner, "Please select " + src + " to rename " + target + "!");
-
- return;
- }
-
- if (!MessageBox.confirmDialog(owner, "Are you sure you want to rename " + target +
- " for all selected " + src + "?"))
- return;
-
- String regex = regexTf.getText();
-
- String replace = replaceTf.getText();
-
- try {
- switch (replaceCb.getSelectionModel().getSelectedIndex()) {
- case 0:
- renameKeyClassNames(selPojos, regex, replace);
- break;
-
- case 1:
- renameValueClassNames(selPojos, regex, replace);
- break;
-
- default:
- if (isFields)
- renameFieldsJavaNames(selFields, regex, replace);
- else
- renamePojosJavaNames(selPojos, regex, replace);
- }
- }
- catch (Exception e) {
- MessageBox.errorDialog(owner, "Failed to rename " + target + "!", e);
- }
- }
- }),
- button("Reset Selected", "Revert changes for selected items to initial auto-generated values", new EventHandler<ActionEvent>() {
- @Override public void handle(ActionEvent evt) {
- String sel = replaceCb.getSelectionModel().getSelectedItem();
-
- boolean isFields = "Java names".equals(sel) && curTbl == fieldsTbl;
-
- String src = isFields ? "fields" : "tables";
-
- String target = "\"" + sel + "\"";
-
- Collection<PojoDescriptor> selPojos = pojosTbl.getSelectionModel().getSelectedItems();
-
- Collection<PojoField> selFields = fieldsTbl.getSelectionModel().getSelectedItems();
-
- boolean isEmpty = isFields ? selFields.isEmpty() : selPojos.isEmpty();
-
- if (isEmpty) {
- MessageBox.warningDialog(owner, "Please select " + src + "to revert " + target + "!");
-
- return;
- }
-
- if (!MessageBox.confirmDialog(owner,
- "Are you sure you want to revert " + target + " for all selected " + src + "?"))
- return;
-
- switch (replaceCb.getSelectionModel().getSelectedIndex()) {
- case 0:
- revertKeyClassNames(selPojos);
- break;
-
- case 1:
- revertValueClassNames(selPojos);
- break;
-
- default:
- if (isFields)
- revertFieldsJavaNames(selFields);
- else
- revertPojosJavaNames(selPojos);
- }
- }
- })
- ), 2).setPadding(new Insets(0, 0, 0, 10));
-
- pojosTbl.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<PojoDescriptor>() {
- @Override public void changed(ObservableValue<? extends PojoDescriptor> val,
- PojoDescriptor oldVal, PojoDescriptor newItem) {
- if (newItem != null && newItem.parent() != null) {
- curPojo = newItem;
-
- fieldsTbl.setItems(curPojo.fields());
- fieldsTbl.getSelectionModel().clearSelection();
-
- keyValPnl.setDisable(false);
- }
- else {
- curPojo = null;
- fieldsTbl.setItems(NO_FIELDS);
-
- keyValPnl.setDisable(true);
- }
- }
- });
-
- pojosTbl.focusedProperty().addListener(new ChangeListener<Boolean>() {
- @Override public void changed(ObservableValue<? extends Boolean> val, Boolean oldVal, Boolean newVal) {
- if (newVal)
- curTbl = pojosTbl;
- }
- });
-
- fieldsTbl.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() {
- @Override public void changed(ObservableValue<? extends Number> val, Number oldVal, Number newVal) {
- if (curPojo != null) {
- TableView.TableViewSelectionModel<PojoDescriptor> selMdl = pojosTbl.getSelectionModel();
-
- List<Integer> selIndices = new ArrayList<>(selMdl.getSelectedIndices());
-
- if (selIndices.size() > 1) {
- for (Integer idx : selIndices) {
- if (pojos.get(idx) != curPojo)
- selMdl.clearSelection(idx);
- }
- }
- }
- }
- });
-
- fieldsTbl.focusedProperty().addListener(new ChangeListener<Boolean>() {
- @Override public void changed(ObservableValue<? extends Boolean> val, Boolean oldVal, Boolean newVal) {
- if (newVal)
- curTbl = fieldsTbl;
- }
- });
-
- genPnl.add(titledPane("Rename \"Key class name\", \"Value class name\" or \"Java name\" for selected tables",
- regexPnl), 3);
-
- genLayerPnl = stackPane(genPnl);
- }
-
- /**
- * Rename key class name for selected POJOs.
- *
- * @param selPojos Selected POJOs to rename.
- * @param regex Regex to search.
- * @param replace Text for replacement.
- */
- private void renameKeyClassNames(Collection<PojoDescriptor> selPojos, String regex, String replace) {
- for (PojoDescriptor pojo : selPojos)
- pojo.keyClassName(pojo.keyClassName().replaceAll(regex, replace));
- }
-
- /**
- * Rename value class name for selected POJOs.
- *
- * @param selPojos Selected POJOs to rename.
- * @param regex Regex to search.
- * @param replace Text for replacement.
- */
- private void renameValueClassNames(Collection<PojoDescriptor> selPojos, String regex, String replace) {
- for (PojoDescriptor pojo : selPojos)
- pojo.valueClassName(pojo.valueClassName().replaceAll(regex, replace));
- }
-
- /**
- * Rename fields java name for selected POJOs.
- *
- * @param selPojos Selected POJOs to rename.
- * @param regex Regex to search.
- * @param replace Text for replacement.
- */
- private void renamePojosJavaNames(Collection<PojoDescriptor> selPojos, String regex, String replace) {
- for (PojoDescriptor pojo : selPojos)
- for (PojoField field : pojo.fields())
- field.javaName(field.javaName().replaceAll(regex, replace));
- }
-
- /**
- * Rename fields java name for current POJO.
- *
- * @param selFields Selected fields for current POJO to rename.
- * @param regex Regex to search.
- * @param replace Text for replacement.
- */
- private void renameFieldsJavaNames(Collection<PojoField> selFields, String regex, String replace) {
- for (PojoField field : selFields)
- field.javaName(field.javaName().replaceAll(regex, replace));
- }
-
- /**
- * Revert key class name for selected POJOs to initial value.
- *
- * @param selPojos Selected POJOs to revert.
- */
- private void revertKeyClassNames(Collection<PojoDescriptor> selPojos) {
- for (PojoDescriptor pojo : selPojos)
- pojo.revertKeyClassName();
- }
-
- /**
- * Revert value class name for selected POJOs to initial value.
- *
- * @param selPojos Selected POJOs to revert.
- */
- private void revertValueClassNames(Collection<PojoDescriptor> selPojos) {
- for (PojoDescriptor pojo : selPojos)
- pojo.revertValueClassName();
- }
-
- /**
- * Revert fields java name for selected POJOs to initial value.
- *
- * @param selPojos Selected POJOs to revert.
- */
- private void revertPojosJavaNames(Collection<PojoDescriptor> selPojos) {
- for (PojoDescriptor pojo : selPojos)
- pojo.revertJavaNames();
- }
-
- /**
- * Revert fields java name for current POJO to initial value.
- *
- * @param selFields Selected POJO fields to revert.
- */
- private void revertFieldsJavaNames(Collection<PojoField> selFields) {
- for (PojoField field : selFields)
- field.resetJavaName();
- }
-
- /**
- * @return POJOs checked in table-tree-view.
- */
- private Collection<PojoDescriptor> checkedPojos() {
- Collection<PojoDescriptor> res = new ArrayList<>();
-
- for (PojoDescriptor pojo : pojos)
- if (pojo.checked())
- res.add(pojo);
-
- return res;
- }
-
- /**
- * Gets string property.
- *
- * @param key Property key.
- * @param dflt Default value.
- * @return Property value as string.
- */
- private String getStringProp(String key, String dflt) {
- String val = prefs.getProperty(key);
-
- if (val != null)
- return val;
-
- return dflt;
- }
-
- /**
- * Sets string property.
- *
- * @param key Property key.
- * @param val Value to set.
- */
- private void setStringProp(String key, String val) {
- prefs.put(key, val);
- }
-
- /**
- * Gets int property.
- *
- * @param key Property key.
- * @param dflt Default value.
- * @return Property value as int.
- */
- private int getIntProp(String key, int dflt) {
- String val = prefs.getProperty(key);
-
- if (val != null)
- try {
- return Integer.parseInt(val);
- }
- catch (NumberFormatException ignored) {
- return dflt;
- }
-
- return dflt;
- }
-
- /**
- * Sets int property.
- *
- * @param key Property key.
- * @param val Value to set.
- */
- private void setIntProp(String key, int val) {
- prefs.put(key, String.valueOf(val));
- }
-
- /**
- * Gets boolean property.
- *
- * @param key Property key.
- * @param dflt Default value.
- * @return Property value as boolean.
- */
- private boolean getBoolProp(String key, boolean dflt) {
- String val = prefs.getProperty(key);
-
- if (val != null)
- return Boolean.parseBoolean(val);
-
- return dflt;
- }
-
- /**
- * Sets boolean property.
- *
- * @param key Property key.
- * @param val Value to set.
- */
- private void setBoolProp(String key, boolean val) {
- prefs.put(key, String.valueOf(val));
- }
-
- /**
- * Resolve path.
- *
- * @param key Preferences key.
- * @param dflt Default value.
- * @return String with full file path or default value.
- */
- private String resolveFilePath(String key, String dflt) {
- String path = prefs.getProperty(key);
-
- if (path != null) {
- File file = U.resolveIgnitePath(path);
-
- if (file != null)
- return file.getAbsolutePath();
- }
-
- return dflt;
- }
-
- /** {@inheritDoc} */
- @Override public void start(Stage primaryStage) {
- owner = primaryStage;
-
- if (prefsFile.exists())
- try (BufferedInputStream in = new BufferedInputStream(new FileInputStream(prefsFile))) {
- prefs.load(in);
- }
- catch (IOException e) {
- log.log(Level.SEVERE, "Failed to load preferences. Default preferences will be used", e);
- }
-
- // Load custom preferences.
- List<String> params = getParameters().getRaw();
-
- if (!params.isEmpty()) {
- String customPrefsFileName = params.get(0);
-
- if (customPrefsFileName.isEmpty())
- log.log(Level.WARNING, "Path to file with custom preferences is not specified.");
- else {
- File customPrefsFile = U.resolveIgnitePath(customPrefsFileName);
-
- if (customPrefsFile == null)
- log.log(Level.WARNING, "Failed to resolve path to file with custom preferences: " +
- customPrefsFile);
- else {
- Properties customPrefs = new Properties();
-
- try (BufferedInputStream in = new BufferedInputStream(new FileInputStream(customPrefsFile))) {
- customPrefs.load(in);
- }
- catch (IOException e) {
- log.log(Level.SEVERE, "Failed to load custom preferences.", e);
- }
-
- prefs.putAll(customPrefs);
- }
- }
- }
-
- // Restore presets.
- for (Preset preset : presets) {
- String key = "presets." + preset.pref + ".";
-
- preset.jar = getStringProp(key + "jar", preset.jar);
- preset.drv = getStringProp(key + "drv", preset.drv);
- preset.url = getStringProp(key + "url", preset.url);
- preset.user = getStringProp(key + "user", preset.user);
- }
-
- primaryStage.setTitle("Apache Ignite Auto Schema Import Utility");
-
- primaryStage.getIcons().addAll(
- image("ignite", 16),
- image("ignite", 24),
- image("ignite", 32),
- image("ignite", 48),
- image("ignite", 64),
- image("ignite", 128));
-
- pi = progressIndicator(50);
-
- createGeneratePane();
-
- hdrPane = createHeaderPane();
- rootPane = borderPane(hdrPane, createConnectionPane(), createButtonsPane(), null, null);
-
- primaryStage.setScene(scene(rootPane));
-
- primaryStage.setWidth(650);
- primaryStage.setMinWidth(650);
-
- primaryStage.setHeight(650);
- primaryStage.setMinHeight(650);
-
- prev();
-
- // Restore window pos and size.
- if (prefs.getProperty(PREF_WINDOW_X) != null) {
- int x = getIntProp(PREF_WINDOW_X, 100);
- int y = getIntProp(PREF_WINDOW_Y, 100);
- int w = getIntProp(PREF_WINDOW_WIDTH, 650);
- int h = getIntProp(PREF_WINDOW_HEIGHT, 650);
-
- // Ensure that window fit any available screen.
- if (!Screen.getScreensForRectangle(x, y, w, h).isEmpty()) {
- primaryStage.setX(x);
- primaryStage.setY(y);
-
- primaryStage.setWidth(w);
- primaryStage.setHeight(h);
- }
- }
- else
- primaryStage.centerOnScreen();
-
- String userHome = System.getProperty("user.home").replace('\\', '/');
-
- // Restore connection pane settings.
- rdbmsCb.getSelectionModel().select(getIntProp(PREF_JDBC_DB_PRESET, 0));
- jdbcDrvJarTf.setText(resolveFilePath(PREF_JDBC_DRIVER_JAR, "h2.jar"));
- jdbcDrvClsTf.setText(getStringProp(PREF_JDBC_DRIVER_CLASS, "org.h2.Driver"));
- jdbcUrlTf.setText(getStringProp(PREF_JDBC_URL, "jdbc:h2:" + userHome + "/ignite-schema-import/db"));
- userTf.setText(getStringProp(PREF_JDBC_USER, "sa"));
-
- // Restore generation pane settings.
- outFolderTf.setText(resolveFilePath(PREF_OUT_FOLDER, userHome + "/ignite-schema-import/out"));
-
- pkgTf.setText(getStringProp(PREF_POJO_PACKAGE, "org.apache.ignite"));
- pojoIncludeKeysCh.setSelected(getBoolProp(PREF_POJO_INCLUDE, true));
- pojoConstructorCh.setSelected(getBoolProp(PREF_POJO_CONSTRUCTOR, false));
-
- xmlSingleFileCh.setSelected(getBoolProp(PREF_XML_SINGLE, true));
-
- regexTf.setText(getStringProp(PREF_NAMING_PATTERN, "(\\w+)"));
- replaceTf.setText(getStringProp(PREF_NAMING_REPLACE, "$1_SomeText"));
-
- primaryStage.show();
- }
-
- /**
- * Save preset.
- *
- * @param preset Preset to save.
- */
- private void savePreset(Preset preset) {
- String key = "presets." + preset.pref + ".";
-
- preset.jar = jdbcDrvJarTf.getText();
- setStringProp(key + "jar", preset.jar);
-
- preset.drv = jdbcDrvClsTf.getText();
- setStringProp(key + "drv", preset.drv);
-
- preset.url = jdbcUrlTf.getText();
- setStringProp(key + "url", preset.url);
-
- preset.user = userTf.getText();
- setStringProp(key + "user", preset.user);
-
- savePreferences();
- }
-
- /**
- * Save user preferences.
- */
- private void savePreferences() {
- try (FileOutputStream out = new FileOutputStream(prefsFile)) {
- prefs.store(out, "Apache Ignite Schema Import Utility");
- }
- catch (IOException e) {
- MessageBox.errorDialog(owner, "Failed to save preferences!", e);
- }
- }
-
- /** {@inheritDoc} */
- @Override public void stop() throws Exception {
- // Save window pos and size.
- setIntProp(PREF_WINDOW_X, (int)owner.getX());
- setIntProp(PREF_WINDOW_Y, (int)owner.getY());
- setIntProp(PREF_WINDOW_WIDTH, (int)owner.getWidth());
- setIntProp(PREF_WINDOW_HEIGHT, (int)owner.getHeight());
-
- // Save connection pane settings.
- setIntProp(PREF_JDBC_DB_PRESET, rdbmsCb.getSelectionModel().getSelectedIndex());
- setStringProp(PREF_JDBC_DRIVER_JAR, jdbcDrvJarTf.getText());
- setStringProp(PREF_JDBC_DRIVER_CLASS, jdbcDrvClsTf.getText());
- setStringProp(PREF_JDBC_URL, jdbcUrlTf.getText());
- setStringProp(PREF_JDBC_USER, userTf.getText());
-
- // Save generation pane settings.
- setStringProp(PREF_OUT_FOLDER, outFolderTf.getText());
-
- setStringProp(PREF_POJO_PACKAGE, pkgTf.getText());
- setBoolProp(PREF_POJO_INCLUDE, pojoIncludeKeysCh.isSelected());
- setBoolProp(PREF_POJO_CONSTRUCTOR, pojoConstructorCh.isSelected());
-
- setBoolProp(PREF_XML_SINGLE, xmlSingleFileCh.isSelected());
-
- setStringProp(PREF_NAMING_PATTERN, regexTf.getText());
- setStringProp(PREF_NAMING_REPLACE, replaceTf.getText());
-
- savePreferences();
- }
-
- /**
- * Schema Import utility launcher.
- *
- * @param args Command line arguments passed to the application.
- */
- public static void main(String[] args) {
- // Workaround for JavaFX ugly text AA.
- System.setProperty("prism.lcdtext", "false");
- System.setProperty("prism.text", "t2k");
-
- // Workaround for AWT + JavaFX: we should initialize AWT before JavaFX.
- java.awt.Toolkit.getDefaultToolkit();
-
- // Workaround for JavaFX + Mac OS dock icon.
- if (System.getProperty("os.name").toLowerCase().contains("mac os")) {
- System.setProperty("javafx.macosx.embedded", "true");
-
- try {
- Class<?> appCls = Class.forName("com.apple.eawt.Application");
-
- Object osxApp = appCls.getDeclaredMethod("getApplication").invoke(null);
-
- appCls.getDeclaredMethod("setDockIconImage", java.awt.Image.class)
- .invoke(osxApp, fromFXImage(image("ignite", 128), null));
- }
- catch (Exception ignore) {
- // No-op.
- }
- }
-
- launch(args);
- }
-
- /**
- * Special table cell to select possible java type conversions.
- */
- private static class JavaTypeCell extends TableCell<PojoField, String> {
- /** Combo box. */
- private final ComboBox<String> comboBox;
-
- /**
- * Creates a ComboBox cell factory for use in TableColumn controls.
- *
- * @return Cell factory for cell with java types combobox.
- */
- public static Callback<TableColumn<PojoField, String>, TableCell<PojoField, String>> cellFactory() {
- return new Callback<TableColumn<PojoField, String>, TableCell<PojoField, String>>() {
- @Override public TableCell<PojoField, String> call(TableColumn<PojoField, String> col) {
- return new JavaTypeCell();
- }
- };
- }
-
- /**
- * Default constructor.
- */
- private JavaTypeCell() {
- comboBox = new ComboBox<>(FXCollections.<String>emptyObservableList());
-
- comboBox.valueProperty().addListener(new ChangeListener<String>() {
- @Override public void changed(ObservableValue<? extends String> val, String oldVal, String newVal) {
- if (isEditing())
- commitEdit(newVal);
- }
- });
-
- getStyleClass().add("combo-box-table-cell");
- }
-
- /** {@inheritDoc} */
- @Override public void startEdit() {
- if (comboBox.getItems().size() > 1) {
- comboBox.getSelectionModel().select(getItem());
-
- super.startEdit();
-
- setText(null);
- setGraphic(comboBox);
- }
- }
-
- /** {@inheritDoc} */
- @Override public void cancelEdit() {
- super.cancelEdit();
-
- setText(getItem());
-
- setGraphic(null);
- }
-
- /** {@inheritDoc} */
- @Override public void updateItem(String item, boolean empty) {
- super.updateItem(item, empty);
-
- setGraphic(null);
- setText(null);
-
- if (!empty) {
- setText(item);
-
- TableRow row = getTableRow();
-
- if (row != null) {
- PojoField pojo = (PojoField)row.getItem();
-
- if (pojo != null) {
- comboBox.setItems(pojo.conversions());
- comboBox.getSelectionModel().select(pojo.javaTypeName());
- }
- }
- }
- }
- }
-
- /**
- * Special table cell to select schema or table.
- */
- private static class PojoDescriptorCell extends TableCell<PojoDescriptor, Boolean> {
- /**
- * Creates a ComboBox cell factory for use in TableColumn controls.
- *
- * @return Cell factory for schema / table selection.
- */
- public static Callback<TableColumn<PojoDescriptor, Boolean>, TableCell<PojoDescriptor, Boolean>> cellFactory() {
- return new Callback<TableColumn<PojoDescriptor, Boolean>, TableCell<PojoDescriptor, Boolean>>() {
- @Override public TableCell<PojoDescriptor, Boolean> call(TableColumn<PojoDescriptor, Boolean> col) {
- return new PojoDescriptorCell();
- }
- };
- }
-
- /** Previous POJO bound to cell. */
- private PojoDescriptor prevPojo;
-
- /** Previous cell graphic. */
- private Pane prevGraphic;
-
- /** {@inheritDoc} */
- @Override public void updateItem(Boolean item, boolean empty) {
- super.updateItem(item, empty);
-
- setGraphic(null);
-
- if (!empty) {
- TableRow row = getTableRow();
-
- if (row != null) {
- final PojoDescriptor pojo = (PojoDescriptor)row.getItem();
-
- if (pojo != null) {
- if (prevGraphic == null || pojo != prevPojo) {
- boolean isTbl = pojo.parent() != null;
-
- CheckBox ch = new CheckBox();
- ch.setAllowIndeterminate(false);
- ch.indeterminateProperty().bindBidirectional(pojo.indeterminate());
- ch.selectedProperty().bindBidirectional(pojo.useProperty());
-
- Label lb = new Label(isTbl ? pojo.table() : pojo.schema());
-
- Pane pnl = new HBox(5);
- pnl.setPadding(new Insets(0, 0, 0, isTbl ? 25 : 5));
- pnl.getChildren().addAll(ch, lb);
-
- prevPojo = pojo;
- prevGraphic = pnl;
- }
-
- setGraphic(prevGraphic);
- }
- }
- }
- }
- }
-
- /**
- * Special table cell to select "used" fields for code generation.
- */
- private static class PojoFieldUseCell extends TableCell<PojoField, Boolean> {
- /**
- * Creates a ComboBox cell factory for use in TableColumn controls.
- *
- * @return Cell factory for used fields selection.
- */
- public static Callback<TableColumn<PojoField, Boolean>, TableCell<PojoField, Boolean>> cellFactory() {
- return new Callback<TableColumn<PojoField, Boolean>, TableCell<PojoField, Boolean>>() {
- @Override public TableCell<PojoField, Boolean> call(TableColumn<PojoField, Boolean> col) {
- return new PojoFieldUseCell();
- }
- };
- }
-
- /** Previous POJO field bound to cell. */
- private PojoField prevField;
-
- /** Previous cell graphic. */
- private CheckBox prevGraphic;
-
- /** {@inheritDoc} */
- @Override public void updateItem(Boolean item, boolean empty) {
- super.updateItem(item, empty);
-
- setGraphic(null);
-
- if (!empty) {
- TableRow row = getTableRow();
-
- if (row != null) {
- final PojoField field = (PojoField)row.getItem();
-
- if (field != null) {
- if (prevGraphic == null || prevField != field) {
- setAlignment(Pos.CENTER);
-
- CheckBox ch = new CheckBox();
- ch.setDisable(!field.nullable());
- ch.selectedProperty().bindBidirectional(field.useProperty());
-
- prevField = field;
- prevGraphic = ch;
- }
-
- setGraphic(prevGraphic);
- }
- }
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/TextColumnValidator.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/TextColumnValidator.java b/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/TextColumnValidator.java
deleted file mode 100644
index d92ae08..0000000
--- a/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/TextColumnValidator.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.apache.ignite.schema.ui;
-
-/**
- * Validator for editable table view text column.
- */
-public interface TextColumnValidator<T> {
- /**
- * Validate new value of text.
- *
- * @param rowVal Row value.
- * @param newVal New value of text.
- * @return {@code true} if text is valid.
- */
- public boolean valid(T rowVal, String newVal);
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import/src/main/java/org/apache/ignite/schema/utils/ChangeListener.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/utils/ChangeListener.java b/modules/schema-import/src/main/java/org/apache/ignite/schema/utils/ChangeListener.java
new file mode 100644
index 0000000..1961c6c
--- /dev/null
+++ b/modules/schema-import/src/main/java/org/apache/ignite/schema/utils/ChangeListener.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.ignite.schema.utils;
+
+/**
+ *
+ */
+public interface ChangeListener<T> {
+ /**
+ * @param var1 Property instance.
+ * @param oldVal Old value.
+ * @param newVal new value.
+ */
+ public void changed(Property<? extends T> var1, T oldVal, T newVal);
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import/src/main/java/org/apache/ignite/schema/utils/Property.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/utils/Property.java b/modules/schema-import/src/main/java/org/apache/ignite/schema/utils/Property.java
new file mode 100644
index 0000000..0e8cd56
--- /dev/null
+++ b/modules/schema-import/src/main/java/org/apache/ignite/schema/utils/Property.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.ignite.schema.utils;
+
+import java.util.*;
+import java.util.concurrent.*;
+
+/**
+ *
+ */
+public class Property<T> {
+ /** */
+ private T val;
+
+ /** */
+ private final CopyOnWriteArrayList<ChangeListener<? super T>> lsnrs = new CopyOnWriteArrayList<>();
+
+ /** */
+ private Object fxProperty;
+
+ /**
+ * @param val Value.
+ */
+ public Property(T val) {
+ this.val = val;
+ }
+
+ /**
+ *
+ */
+ public T get() {
+ return val;
+ }
+
+ /**
+ * @param val Value.
+ */
+ public void set(T val) {
+ if (!Objects.equals(val, this.val)) {
+ T oldVal = this.val;
+
+ this.val = val;
+
+ for (ChangeListener<? super T> lsnr : lsnrs)
+ lsnr.changed(this, oldVal, val);
+ }
+ }
+
+ /**
+ * @param var1 Var 1.
+ */
+ public void addListener(ChangeListener<? super T> var1) {
+ lsnrs.add(var1);
+ }
+
+ /**
+ * @return Instance of FX property.
+ */
+ public Object fxProperty() {
+ return fxProperty;
+ }
+
+ /**
+ * @param fxProp New fx property.
+ */
+ public void fxProperty(Object fxProp) {
+ fxProperty = fxProp;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import/src/test/java/org/apache/ignite/schema/test/AbstractSchemaImportTest.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/AbstractSchemaImportTest.java b/modules/schema-import/src/test/java/org/apache/ignite/schema/test/AbstractSchemaImportTest.java
deleted file mode 100644
index 0c3ecb1..0000000
--- a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/AbstractSchemaImportTest.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.apache.ignite.schema.test;
-
-import junit.framework.*;
-import org.apache.ignite.internal.util.typedef.internal.*;
-import org.apache.ignite.schema.model.PojoDescriptor;
-import org.apache.ignite.schema.parser.DatabaseMetadataParser;
-import org.apache.ignite.schema.ui.*;
-
-import java.io.*;
-import java.sql.*;
-import java.util.List;
-
-import static org.apache.ignite.schema.ui.MessageBox.Result.*;
-
-/**
- * Base functional for Ignite Schema Import utility tests.
- */
-public abstract class AbstractSchemaImportTest extends TestCase {
- /** DB connection URL. */
- private static final String CONN_URL = "jdbc:h2:mem:autoCacheStore;DB_CLOSE_DELAY=-1";
-
- /** Path to temp folder where generated POJOs will be saved. */
- protected static final String OUT_DIR_PATH = System.getProperty("java.io.tmpdir") + "/ignite-schema-import/out";
-
- /** Auto confirmation of file conflicts. */
- protected ConfirmCallable askOverwrite = new ConfirmCallable(null, "") {
- @Override public MessageBox.Result confirm(String msg) {
- return YES_TO_ALL;
- }
- };
-
- /** List of generated for test database POJO objects. */
- protected List<PojoDescriptor> pojos;
-
- /** {@inheritDoc} */
- @Override public void setUp() throws Exception {
- Class.forName("org.h2.Driver");
-
- Connection conn = DriverManager.getConnection(CONN_URL, "sa", "");
-
- Statement stmt = conn.createStatement();
-
- stmt.executeUpdate("CREATE TABLE IF NOT EXISTS PRIMITIVES (pk INTEGER PRIMARY KEY, " +
- " boolCol BOOLEAN NOT NULL," +
- " byteCol TINYINT NOT NULL," +
- " shortCol SMALLINT NOT NULL," +
- " intCol INTEGER NOT NULL, " +
- " longCol BIGINT NOT NULL," +
- " floatCol REAL NOT NULL," +
- " doubleCol DOUBLE NOT NULL," +
- " doubleCol2 DOUBLE NOT NULL, " +
- " bigDecimalCol DECIMAL(10, 0)," +
- " strCol VARCHAR(10)," +
- " dateCol DATE," +
- " timeCol TIME," +
- " tsCol TIMESTAMP, " +
- " arrCol BINARY(10))");
-
- stmt.executeUpdate("CREATE TABLE IF NOT EXISTS OBJECTS (pk INTEGER PRIMARY KEY, " +
- " boolCol BOOLEAN," +
- " byteCol TINYINT," +
- " shortCol SMALLINT," +
- " intCol INTEGER," +
- " longCol BIGINT," +
- " floatCol REAL," +
- " doubleCol DOUBLE," +
- " doubleCol2 DOUBLE," +
- " bigDecimalCol DECIMAL(10, 0)," +
- " strCol VARCHAR(10), " +
- " dateCol DATE," +
- " timeCol TIME," +
- " tsCol TIMESTAMP," +
- " arrCol BINARY(10))");
-
- conn.commit();
-
- U.closeQuiet(stmt);
-
- pojos = DatabaseMetadataParser.parse(conn, false);
-
- U.closeQuiet(conn);
- }
-
- /**
- * Compare files by lines.
- *
- * @param exp Stream to read of expected file from test resources.
- * @param generated Generated file instance.
- * @param excludePtrn Marker string to exclude lines from comparing.
- * @return true if generated file correspond to expected.
- */
- protected boolean compareFilesInt(InputStream exp, File generated, String excludePtrn) {
- try (BufferedReader baseReader = new BufferedReader(new InputStreamReader(exp))) {
- try (BufferedReader generatedReader = new BufferedReader(new FileReader(generated))) {
- String baseLine;
-
- while ((baseLine = baseReader.readLine()) != null) {
- String generatedLine = generatedReader.readLine();
-
- if (!baseLine.equals(generatedLine) && !baseLine.contains(excludePtrn)
- && !generatedLine.contains(excludePtrn)) {
- System.out.println("Expected: " + baseLine);
- System.out.println("Generated: " + generatedLine);
-
- return false;
- }
- }
-
- return true;
- }
- } catch (IOException e) {
- e.printStackTrace();
-
- return false;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import/src/test/java/org/apache/ignite/schema/test/generator/CodeGeneratorTest.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/generator/CodeGeneratorTest.java b/modules/schema-import/src/test/java/org/apache/ignite/schema/test/generator/CodeGeneratorTest.java
deleted file mode 100644
index c458aad..0000000
--- a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/generator/CodeGeneratorTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.apache.ignite.schema.test.generator;
-
-import org.apache.ignite.schema.generator.CodeGenerator;
-import org.apache.ignite.schema.test.AbstractSchemaImportTest;
-import org.apache.ignite.schema.model.PojoDescriptor;
-
-import java.io.File;
-
-/**
- * Tests for POJO generator.
- */
-public class CodeGeneratorTest extends AbstractSchemaImportTest {
- /** Marker string to skip date generation while comparing.*/
- private static final String GEN_PTRN = "Code generated by Apache Ignite Schema Import utility";
-
- /**
- * Test that POJOs generated correctly.
- */
- public void testPojoGeneration() throws Exception {
- String pkg = "org.apache.ignite.schema.test.model";
- String intPath = "org/apache/ignite/schema/test/model";
-
- Boolean containsSchema = false;
-
- for (PojoDescriptor pojo : pojos) {
- if (pojo.valueClassName().isEmpty())
- containsSchema = true;
- else {
- CodeGenerator.pojos(pojo, OUT_DIR_PATH, pkg, true, true, askOverwrite);
-
- assertTrue("Generated key class POJO content is differ from expected for type " + pojo.keyClassName(),
- compareFiles(pojo.keyClassName(), intPath, GEN_PTRN));
-
- assertTrue("Generated value class POJO content is differ from expected for type " + pojo.valueClassName(),
- compareFiles(pojo.valueClassName(), intPath, GEN_PTRN));
- }
- }
-
- assertTrue("Generated POJOs does not contains schema.", containsSchema);
- }
-
- /**
- * @param typeName Type name.
- * @param intPath Internal path.
- * @return {@code true} if generated POJO as expected.
- */
- private boolean compareFiles(String typeName, String intPath, String excludePtrn) {
- String relPath = intPath + "/" + typeName;
-
- return compareFilesInt(getClass().getResourceAsStream("/" + relPath + ".txt"),
- new File(OUT_DIR_PATH + "/" + relPath + ".java"), excludePtrn);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import/src/test/java/org/apache/ignite/schema/test/generator/XmlGeneratorTest.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/generator/XmlGeneratorTest.java b/modules/schema-import/src/test/java/org/apache/ignite/schema/test/generator/XmlGeneratorTest.java
deleted file mode 100644
index 3353421..0000000
--- a/modules/schema-import/src/test/java/org/apache/ignite/schema/test/generator/XmlGeneratorTest.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.apache.ignite.schema.test.generator;
-
-import org.apache.ignite.schema.generator.*;
-import org.apache.ignite.schema.test.*;
-import org.apache.ignite.schema.model.*;
-
-import java.io.*;
-import java.util.*;
-
-/**
- * Tests for XML generator.
- */
-public class XmlGeneratorTest extends AbstractSchemaImportTest {
- /**
- * Test that XML generated correctly.
- */
- public void testXmlGeneration() throws Exception {
- Collection<PojoDescriptor> all = new ArrayList<>();
-
- for (PojoDescriptor pojo : pojos)
- if (pojo.parent() != null)
- all.add(pojo);
-
- String fileName = "ignite-type-metadata.xml";
-
- XmlGenerator.generate("org.apache.ignite.schema.test.model", all, true, new File(OUT_DIR_PATH, fileName),
- askOverwrite);
-
- assertTrue("Generated XML file content is differ from expected one",
- compareFilesInt(getClass().getResourceAsStream("/org/apache/ignite/schema/test/model/" + fileName),
- new File(OUT_DIR_PATH + "/" + fileName), "XML generated by Apache Ignite Schema Import utility"));
- }
-}
[6/7] incubator-ignite git commit: IGNITE-1155 Extract
ignite-schema-import-ui module.
Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import-ui/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java
----------------------------------------------------------------------
diff --git a/modules/schema-import-ui/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java b/modules/schema-import-ui/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java
new file mode 100644
index 0000000..8779dac
--- /dev/null
+++ b/modules/schema-import-ui/src/main/java/org/apache/ignite/schema/ui/SchemaImportApp.java
@@ -0,0 +1,1768 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.ignite.schema.ui;
+
+import javafx.application.*;
+import javafx.beans.value.*;
+import javafx.collections.*;
+import javafx.concurrent.*;
+import javafx.event.*;
+import javafx.geometry.Insets;
+import javafx.geometry.*;
+import javafx.scene.*;
+import javafx.scene.control.Button;
+import javafx.scene.control.*;
+import javafx.scene.control.Label;
+import javafx.scene.control.TextField;
+import javafx.scene.layout.*;
+import javafx.stage.*;
+import javafx.util.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.schema.generator.*;
+import org.apache.ignite.schema.model.*;
+import org.apache.ignite.schema.parser.*;
+
+import java.awt.*;
+import java.io.*;
+import java.net.*;
+import java.sql.*;
+import java.util.*;
+import java.util.List;
+import java.util.concurrent.*;
+import java.util.logging.*;
+
+import static javafx.embed.swing.SwingFXUtils.*;
+import static org.apache.ignite.schema.ui.Controls.*;
+
+/**
+ * Schema Import utility application.
+ */
+@SuppressWarnings("UnnecessaryFullyQualifiedName")
+public class SchemaImportApp extends Application {
+ /** Logger. */
+ private static final Logger log = Logger.getLogger(SchemaImportApp.class.getName());
+
+ /** Presets for database settings. */
+ private static class Preset {
+ /** Name in preferences. */
+ private String pref;
+
+ /** RDBMS name to show on screen. */
+ private String name;
+
+ /** Path to JDBC driver jar. */
+ private String jar;
+
+ /** JDBC driver class name. */
+ private String drv;
+
+ /** JDBC URL. */
+ private String url;
+
+ /** User name. */
+ private String user;
+
+ /**
+ * Preset constructor.
+ *
+ * @param pref Name in preferences.
+ * @param name RDBMS name to show on screen.
+ * @param jar Path to JDBC driver jar..
+ * @param drv JDBC driver class name.
+ * @param url JDBC URL.
+ * @param user User name.
+ */
+ Preset(String pref, String name, String jar, String drv, String url, String user) {
+ this.pref = pref;
+ this.name = name;
+ this.jar = jar;
+ this.drv = drv;
+ this.url = url;
+ this.user = user;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return name;
+ }
+ }
+
+ /** Default presets for popular databases. */
+ private final Preset[] presets = {
+ new Preset("h2", "H2 Database", "h2.jar", "org.h2.Driver", "jdbc:h2:[database]", "sa"),
+ new Preset("db2", "DB2", "db2jcc4.jar", "com.ibm.db2.jcc.DB2Driver", "jdbc:db2://[host]:[port]/[database]",
+ "db2admin"),
+ new Preset("oracle", "Oracle", "ojdbc6.jar", "oracle.jdbc.OracleDriver",
+ "jdbc:oracle:thin:@[host]:[port]:[database]", "system"),
+ new Preset("mysql", "MySQL", "mysql-connector-java-5-bin.jar", "com.mysql.jdbc.Driver",
+ "jdbc:mysql://[host]:[port]/[database]", "root"),
+ new Preset("mssql", "Microsoft SQL Server", "sqljdbc41.jar", "com.microsoft.sqlserver.jdbc.SQLServerDriver",
+ "jdbc:sqlserver://[host]:[port][;databaseName=database]", "sa"),
+ new Preset("postgresql", "PostgreSQL", "postgresql-9.3.jdbc4.jar", "org.postgresql.Driver",
+ "jdbc:postgresql://[host]:[port]/[database]", "sa"),
+ new Preset("custom", "Custom server...", "custom-jdbc.jar", "org.custom.Driver", "jdbc:custom", "sa")
+ };
+
+ /** */
+ private static final String PREF_WINDOW_X = "window.x";
+ /** */
+ private static final String PREF_WINDOW_Y = "window.y";
+ /** */
+ private static final String PREF_WINDOW_WIDTH = "window.width";
+ /** */
+ private static final String PREF_WINDOW_HEIGHT = "window.height";
+
+ /** */
+ private static final String PREF_JDBC_DB_PRESET = "jdbc.db.preset";
+ /** */
+ private static final String PREF_JDBC_DRIVER_JAR = "jdbc.driver.jar";
+ /** */
+ private static final String PREF_JDBC_DRIVER_CLASS = "jdbc.driver.class";
+ /** */
+ private static final String PREF_JDBC_URL = "jdbc.url";
+ /** */
+ private static final String PREF_JDBC_USER = "jdbc.user";
+
+ /** */
+ private static final String PREF_OUT_FOLDER = "out.folder";
+
+ /** */
+ private static final String PREF_POJO_PACKAGE = "pojo.package";
+ /** */
+ private static final String PREF_POJO_INCLUDE = "pojo.include";
+ /** */
+ private static final String PREF_POJO_CONSTRUCTOR = "pojo.constructor";
+
+ /** */
+ private static final String PREF_XML_SINGLE = "xml.single";
+
+ /** */
+ private static final String PREF_NAMING_PATTERN = "naming.pattern";
+ /** */
+ private static final String PREF_NAMING_REPLACE = "naming.replace";
+
+ /** */
+ private Stage owner;
+
+ /** */
+ private BorderPane rootPane;
+
+ /** Header pane. */
+ private BorderPane hdrPane;
+
+ /** */
+ private HBox dbIcon;
+
+ /** */
+ private HBox genIcon;
+
+ /** */
+ private Label titleLb;
+
+ /** */
+ private Label subTitleLb;
+
+ /** */
+ private Button prevBtn;
+
+ /** */
+ private Button nextBtn;
+
+ /** */
+ private ComboBox<Preset> rdbmsCb;
+
+ /** */
+ private TextField jdbcDrvJarTf;
+
+ /** */
+ private TextField jdbcDrvClsTf;
+
+ /** */
+ private TextField jdbcUrlTf;
+
+ /** */
+ private TextField userTf;
+
+ /** */
+ private PasswordField pwdTf;
+
+ /** */
+ private ComboBox<String> parseCb;
+
+ /** */
+ private GridPaneEx connPnl;
+
+ /** */
+ private StackPane connLayerPnl;
+
+ /** */
+ private TableView<PojoDescriptor> pojosTbl;
+
+ /** */
+ private TableView<PojoField> fieldsTbl;
+
+ /** */
+ private Node curTbl;
+
+ /** */
+ private TextField outFolderTf;
+
+ /** */
+ private TextField pkgTf;
+
+ /** */
+ private CheckBox pojoConstructorCh;
+
+ /** */
+ private CheckBox pojoIncludeKeysCh;
+
+ /** */
+ private CheckBox xmlSingleFileCh;
+
+ /** */
+ private TextField regexTf;
+
+ /** */
+ private TextField replaceTf;
+
+ /** */
+ private GridPaneEx genPnl;
+
+ /** */
+ private StackPane genLayerPnl;
+
+ /** */
+ private ProgressIndicator pi;
+
+ /** List with POJOs descriptors. */
+ private ObservableList<PojoDescriptor> pojos = FXCollections.emptyObservableList();
+
+ /** Currently selected POJO. */
+ private PojoDescriptor curPojo;
+
+ /** */
+ private final Map<String, Driver> drivers = new HashMap<>();
+
+ /** Application preferences. */
+ private final Properties prefs = new Properties();
+
+ /** File path for storing on local file system. */
+ private final File prefsFile = new File(System.getProperty("user.home"), ".ignite-schema-import");
+
+ /** Empty POJO fields model. */
+ private static final ObservableList<PojoField> NO_FIELDS = FXCollections.emptyObservableList();
+
+ /** */
+ private final ExecutorService exec = Executors.newSingleThreadExecutor(new ThreadFactory() {
+ @Override public Thread newThread(Runnable r) {
+ Thread t = new Thread(r, "ignite-schema-import-worker");
+
+ t.setDaemon(true);
+
+ return t;
+ }
+ });
+
+ /**
+ * Lock UI before start long task.
+ *
+ * @param layer Stack pane to add progress indicator.
+ * @param controls Controls to disable.
+ */
+ private void lockUI(StackPane layer, Node... controls) {
+ for (Node control : controls)
+ control.setDisable(true);
+
+ layer.getChildren().add(pi);
+ }
+
+ /**
+ * Unlock UI after long task finished.
+ *
+ * @param layer Stack pane to remove progress indicator.
+ * @param controls Controls to enable.
+ */
+ private void unlockUI(StackPane layer, Node... controls) {
+ for (Node control : controls)
+ control.setDisable(false);
+
+ layer.getChildren().remove(pi);
+ }
+
+ /**
+ * Perceptual delay to avoid UI flickering.
+ *
+ * @param started Time when background progress started.
+ */
+ private void perceptualDelay(long started) {
+ long delta = System.currentTimeMillis() - started;
+
+ if (delta < 500)
+ try {
+ Thread.sleep(500 - delta);
+ }
+ catch (InterruptedException ignored) {
+ Thread.currentThread().interrupt();
+ }
+ }
+
+ /**
+ * Fill tree with database metadata.
+ */
+ private void fill() {
+ lockUI(connLayerPnl, connPnl, nextBtn);
+
+ final String jdbcDrvJarPath = jdbcDrvJarTf.getText().trim();
+
+ final String jdbcDrvCls = jdbcDrvClsTf.getText();
+
+ final String jdbcUrl = jdbcUrlTf.getText();
+
+ String user = userTf.getText().trim();
+
+ String pwd = pwdTf.getText().trim();
+
+ final Properties jdbcInfo = new Properties();
+
+ if (!user.isEmpty())
+ jdbcInfo.put("user", user);
+
+ if (!pwd.isEmpty())
+ jdbcInfo.put("password", pwd);
+
+ final boolean tblsOnly = parseCb.getSelectionModel().getSelectedIndex() == 0;
+
+ Runnable task = new Task<Void>() {
+ /** {@inheritDoc} */
+ @Override protected Void call() throws Exception {
+ long started = System.currentTimeMillis();
+
+ try (Connection conn = connect(jdbcDrvJarPath, jdbcDrvCls, jdbcUrl, jdbcInfo)) {
+ pojos = FXCollections.observableList(DatabaseMetadataParser.parse(conn, tblsOnly));
+ }
+
+ perceptualDelay(started);
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void succeeded() {
+ try {
+ super.succeeded();
+
+ pojosTbl.setItems(pojos);
+
+ if (pojos.isEmpty()) {
+ MessageBox.warningDialog(owner, "No tables found in database. Recheck JDBC URL.\n" +
+ "JDBC URL: " + jdbcUrl);
+
+ return;
+ }
+ else
+ pojosTbl.getSelectionModel().clearAndSelect(0);
+
+ curTbl = pojosTbl;
+
+ pojosTbl.requestFocus();
+
+
+ hdrPane.setLeft(genIcon);
+
+ titleLb.setText("Generate XML And POJOs");
+ subTitleLb.setText(jdbcUrlTf.getText());
+
+ rootPane.setCenter(genLayerPnl);
+
+ prevBtn.setDisable(false);
+ nextBtn.setText("Generate");
+ tooltip(nextBtn, "Generate XML and POJO files");
+ }
+ finally {
+ unlockUI(connLayerPnl, connPnl, nextBtn);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void cancelled() {
+ super.cancelled();
+
+ unlockUI(connLayerPnl, connPnl, nextBtn);
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void failed() {
+ super.succeeded();
+
+ unlockUI(connLayerPnl, connPnl, nextBtn);
+
+ MessageBox.errorDialog(owner, "Failed to get tables list from database.", getException());
+ }
+ };
+
+ exec.submit(task);
+ }
+
+ /**
+ * Generate XML and POJOs.
+ */
+ private void generate() {
+ final Collection<PojoDescriptor> selPojos = checkedPojos();
+
+ if (selPojos.isEmpty()) {
+ MessageBox.warningDialog(owner, "Please select tables to generate XML and POJOs files!");
+
+ return;
+ }
+
+ if (checkInput(outFolderTf, true, "Output folder should not be empty!"))
+ return;
+
+ lockUI(genLayerPnl, genPnl, prevBtn, nextBtn);
+
+ final String outFolder = outFolderTf.getText();
+
+ final String pkg = pkgTf.getText();
+
+ final File destFolder = new File(outFolder);
+
+ final boolean constructor = pojoConstructorCh.isSelected();
+
+ final boolean includeKeys = pojoIncludeKeysCh.isSelected();
+
+ final boolean singleXml = xmlSingleFileCh.isSelected();
+
+ Runnable task = new Task<Void>() {
+ /**
+ * @param pojo POJO descriptor to check.
+ * @param selected Selected flag.
+ * @param msg Message to show in case of check failed.
+ */
+ private void checkEmpty(final PojoDescriptor pojo, boolean selected, String msg) {
+ if (!selected) {
+ Platform.runLater(new Runnable() {
+ @Override public void run() {
+ TableView.TableViewSelectionModel<PojoDescriptor> selMdl = pojosTbl.getSelectionModel();
+
+ selMdl.clearSelection();
+ selMdl.select(pojo);
+ pojosTbl.scrollTo(selMdl.getSelectedIndex());
+ }
+ });
+
+ throw new IllegalStateException(msg + pojo.table());
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override protected Void call() throws Exception {
+ long started = System.currentTimeMillis();
+
+ if (!destFolder.exists() && !destFolder.mkdirs())
+ throw new IOException("Failed to create output folder: " + destFolder);
+
+ Collection<PojoDescriptor> all = new ArrayList<>();
+
+ ConfirmCallable askOverwrite = new ConfirmCallable(owner, "File already exists: %s\nOverwrite?");
+
+ // Generate XML and POJO.
+ for (PojoDescriptor pojo : selPojos) {
+ if (pojo.checked()) {
+ checkEmpty(pojo, pojo.hasFields(), "No fields selected for type: ");
+ checkEmpty(pojo, pojo.hasKeyFields(), "No key fields selected for type: ");
+ checkEmpty(pojo, pojo.hasValueFields(includeKeys), "No value fields selected for type: ");
+
+ all.add(pojo);
+ }
+ }
+
+ for (PojoDescriptor pojo : all) {
+ if (!singleXml)
+ XmlGenerator.generate(pkg, pojo, includeKeys, new File(destFolder, pojo.table() + ".xml"),
+ askOverwrite);
+
+ CodeGenerator.pojos(pojo, outFolder, pkg, constructor, includeKeys, askOverwrite);
+ }
+
+ if (singleXml)
+ XmlGenerator.generate(pkg, all, includeKeys, new File(outFolder, "ignite-type-metadata.xml"), askOverwrite);
+
+ CodeGenerator.snippet(all, pkg, includeKeys, outFolder, askOverwrite);
+
+ perceptualDelay(started);
+
+ return null;
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void succeeded() {
+ super.succeeded();
+
+ unlockUI(genLayerPnl, genPnl, prevBtn, nextBtn);
+
+ if (Desktop.isDesktopSupported() && MessageBox.confirmDialog(owner, "Generation complete!\n\n" +
+ "Reveal output folder in system default file browser?"))
+ try {
+ java.awt.Desktop.getDesktop().open(destFolder);
+ }
+ catch (IOException e) {
+ MessageBox.errorDialog(owner, "Failed to open folder with results.", e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void cancelled() {
+ super.cancelled();
+
+ unlockUI(genLayerPnl, genPnl, prevBtn, nextBtn);
+
+ MessageBox.warningDialog(owner, "Generation canceled.");
+ }
+
+ /** {@inheritDoc} */
+ @Override protected void failed() {
+ super.succeeded();
+
+ unlockUI(genLayerPnl, genPnl, prevBtn, nextBtn);
+
+ MessageBox.errorDialog(owner, "Generation failed.", getException());
+ }
+ };
+
+ exec.submit(task);
+ }
+
+ /**
+ * @return Header pane with title label.
+ */
+ private BorderPane createHeaderPane() {
+ dbIcon = hBox(0, true, imageView("data_connection", 48));
+ genIcon = hBox(0, true, imageView("text_tree", 48));
+
+ titleLb = label("");
+ titleLb.setId("banner");
+
+ subTitleLb = label("");
+
+ BorderPane bp = borderPane(null, vBox(5, titleLb, subTitleLb), null, dbIcon, hBox(0, true, imageView("ignite", 48)));
+ bp.setId("banner");
+
+ return bp;
+ }
+
+ /**
+ * @return Panel with control buttons.
+ */
+ private Pane createButtonsPane() {
+ prevBtn = button("Prev", "Go to \"Database connection\" page", new EventHandler<ActionEvent>() {
+ @Override public void handle(ActionEvent evt) {
+ prev();
+ }
+ });
+
+ nextBtn = button("Next", "Go to \"POJO and XML generation\" page", new EventHandler<ActionEvent>() {
+ @Override public void handle(ActionEvent evt) {
+ next();
+ }
+ });
+
+ return buttonsPane(Pos.BOTTOM_RIGHT, true, prevBtn, nextBtn);
+ }
+
+ /**
+ * @return {@code true} if some changes were made to fields metadata.
+ */
+ private boolean changed() {
+ for (PojoDescriptor pojo : pojos)
+ if (pojo.changed())
+ return true;
+
+ return false;
+ }
+
+ /**
+ * Go to "Connect To Database" panel.
+ */
+ private void prev() {
+ if (changed() && !MessageBox.confirmDialog(owner, "Are you sure you want to return to previous page?\n" +
+ "This will discard all your changes."))
+ return;
+
+ hdrPane.setLeft(dbIcon);
+
+ titleLb.setText("Connect To Database");
+ subTitleLb.setText("Specify database connection properties...");
+
+ rootPane.setCenter(connLayerPnl);
+
+ prevBtn.setDisable(true);
+ nextBtn.setText("Next");
+ tooltip(nextBtn, "Go to \"XML and POJO generation\" page");
+ }
+
+ /**
+ * Check that text field is non empty.
+ *
+ * @param tf Text field check.
+ * @param trim If {@code true} then
+ * @param msg Warning message.
+ * @return {@code true} If text field is empty.
+ */
+ private boolean checkInput(TextField tf, boolean trim, String msg) {
+ String s = tf.getText();
+
+ s = trim ? s.trim() : s;
+
+ if (s.isEmpty()) {
+ tf.requestFocus();
+
+ MessageBox.warningDialog(owner, msg);
+
+ return true;
+ }
+
+ return false;
+ }
+
+ /**
+ * Go to "Generate XML And POJOs" panel or generate XML and POJOs.
+ */
+ private void next() {
+ if (rootPane.getCenter() == connLayerPnl) {
+ if (checkInput(jdbcDrvJarTf, true, "Path to JDBC driver is not specified!") ||
+ checkInput(jdbcDrvClsTf, true, "JDBC driver class name is not specified!") ||
+ checkInput(jdbcUrlTf, true, "JDBC URL connection string is not specified!") ||
+ checkInput(userTf, true, "User name is not specified!"))
+ return;
+
+ fill();
+ }
+ else
+ generate();
+ }
+
+ /**
+ * Connect to database.
+ *
+ * @param jdbcDrvJarPath Path to JDBC driver.
+ * @param jdbcDrvCls JDBC class name.
+ * @param jdbcUrl JDBC connection URL.
+ * @param jdbcInfo Connection properties.
+ * @return Connection to database.
+ * @throws SQLException if connection failed.
+ */
+ private Connection connect(String jdbcDrvJarPath, String jdbcDrvCls, String jdbcUrl, Properties jdbcInfo)
+ throws SQLException {
+ Driver drv = drivers.get(jdbcDrvCls);
+
+ if (drv == null) {
+ if (jdbcDrvJarPath.isEmpty())
+ throw new IllegalStateException("Driver jar file name is not specified.");
+
+ File drvJar = new File(jdbcDrvJarPath);
+
+ if (!drvJar.exists())
+ throw new IllegalStateException("Driver jar file is not found.");
+
+ try {
+ URL u = new URL("jar:" + drvJar.toURI() + "!/");
+
+ URLClassLoader ucl = URLClassLoader.newInstance(new URL[] {u});
+
+ drv = (Driver)Class.forName(jdbcDrvCls, true, ucl).newInstance();
+
+ drivers.put(jdbcDrvCls, drv);
+ }
+ catch (Exception e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ Connection conn = drv.connect(jdbcUrl, jdbcInfo);
+
+ if (conn == null)
+ throw new IllegalStateException("Connection was not established (JDBC driver returned null value).");
+
+ return conn;
+ }
+
+ /**
+ * Create connection pane with controls.
+ *
+ * @return Pane with connection controls.
+ */
+ private Pane createConnectionPane() {
+ connPnl = paneEx(10, 10, 0, 10);
+
+ connPnl.addColumn();
+ connPnl.addColumn(100, 100, Double.MAX_VALUE, Priority.ALWAYS);
+ connPnl.addColumn(35, 35, 35, Priority.NEVER);
+
+ connPnl.add(text("This utility is designed to automatically generate configuration XML files and" +
+ " POJO classes from database schema information.", 550), 3);
+
+ connPnl.wrap();
+
+ GridPaneEx presetPnl = paneEx(0, 0, 0, 0);
+ presetPnl.addColumn(100, 100, Double.MAX_VALUE, Priority.ALWAYS);
+ presetPnl.addColumn();
+
+ rdbmsCb = presetPnl.add(comboBox("Select database server to get predefined settings", presets));
+
+ presetPnl.add(button("Save preset", "Save current settings in preferences", new EventHandler<ActionEvent>() {
+ @Override public void handle(ActionEvent evt) {
+ Preset preset = rdbmsCb.getSelectionModel().getSelectedItem();
+
+ savePreset(preset);
+ }
+ }));
+
+ connPnl.add(label("DB Preset:"));
+ connPnl.add(presetPnl, 2);
+
+ jdbcDrvJarTf = connPnl.addLabeled("Driver JAR:", textField("Path to driver jar"));
+
+ connPnl.add(button("...", "Select JDBC driver jar or zip", new EventHandler<ActionEvent>() {
+ /** {@inheritDoc} */
+ @Override public void handle(ActionEvent evt) {
+ FileChooser fc = new FileChooser();
+
+ try {
+ File jarFolder = new File(jdbcDrvJarTf.getText()).getParentFile();
+
+ if (jarFolder.exists())
+ fc.setInitialDirectory(jarFolder);
+ }
+ catch (Exception ignored) {
+ // No-op.
+ }
+
+ jdbcDrvJarTf.getText();
+
+ fc.getExtensionFilters().addAll(
+ new FileChooser.ExtensionFilter("JDBC Drivers (*.jar)", "*.jar"),
+ new FileChooser.ExtensionFilter("ZIP archives (*.zip)", "*.zip"));
+
+ File drvJar = fc.showOpenDialog(owner);
+
+ if (drvJar != null)
+ jdbcDrvJarTf.setText(drvJar.getAbsolutePath());
+ }
+ }));
+
+ jdbcDrvClsTf = connPnl.addLabeled("JDBC Driver:", textField("Enter class name for JDBC driver"), 2);
+
+ jdbcUrlTf = connPnl.addLabeled("JDBC URL:", textField("JDBC URL of the database connection string"), 2);
+
+ rdbmsCb.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<Preset>() {
+ @Override public void changed(ObservableValue<? extends Preset> val, Preset oldVal, Preset newVal) {
+ jdbcDrvJarTf.setText(newVal.jar);
+ jdbcDrvClsTf.setText(newVal.drv);
+ jdbcUrlTf.setText(newVal.url);
+ userTf.setText(newVal.user);
+ }
+ });
+
+ userTf = connPnl.addLabeled("User:", textField("User name"), 2);
+
+ pwdTf = connPnl.addLabeled("Password:", passwordField("User password"), 2);
+
+ parseCb = connPnl.addLabeled("Parse:", comboBox("Type of tables to parse", "Tables only", "Tables and Views"), 2);
+
+ connLayerPnl = stackPane(connPnl);
+
+ return connLayerPnl;
+ }
+
+ /**
+ * Check if new class name is unique.
+ *
+ * @param pojo Current edited POJO.
+ * @param newVal New value for class name.
+ * @param key {@code true} if key class name is checked.
+ * @return {@code true} if class name is valid.
+ */
+ private boolean checkClassNameUnique(PojoDescriptor pojo, String newVal, boolean key) {
+ for (PojoDescriptor otherPojo : pojos)
+ if (pojo != otherPojo) {
+ String otherKeyCls = otherPojo.keyClassName();
+ String otherValCls = otherPojo.valueClassName();
+
+ if (newVal.equals(otherKeyCls) || newVal.equals(otherValCls)) {
+ MessageBox.warningDialog(owner, (key ? "Key" : "Value") + " class name must be unique!");
+
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Check if new class name is valid.
+ *
+ * @param pojo Current edited POJO.
+ * @param newVal New value for class name.
+ * @param key {@code true} if key class name is checked.
+ * @return {@code true} if class name is valid.
+ */
+ private boolean checkClassName(PojoDescriptor pojo, String newVal, boolean key) {
+ if (newVal.trim().isEmpty()) {
+ MessageBox.warningDialog(owner, (key ? "Key" : "Value") + " class name must be non empty!");
+
+ return false;
+ }
+
+ if (key) {
+ if (newVal.equals(pojo.valueClassName())) {
+ MessageBox.warningDialog(owner, "Key class name must be different from value class name!");
+
+ return false;
+ }
+ }
+ else if (newVal.equals(pojo.keyClassName())) {
+ MessageBox.warningDialog(owner, "Value class name must be different from key class name!");
+
+ return false;
+ }
+
+ return checkClassNameUnique(pojo, newVal, key);
+ }
+
+ /**
+ * Create generate pane with controls.
+ */
+ private void createGeneratePane() {
+ genPnl = paneEx(10, 10, 0, 10);
+
+ genPnl.addColumn();
+ genPnl.addColumn(100, 100, Double.MAX_VALUE, Priority.ALWAYS);
+ genPnl.addColumn(35, 35, 35, Priority.NEVER);
+
+ genPnl.addRow(100, 100, Double.MAX_VALUE, Priority.ALWAYS);
+ genPnl.addRows(7);
+
+ TableColumn<PojoDescriptor, Boolean> useCol = customColumn("Schema / Table", "use",
+ "If checked then this table will be used for XML and POJOs generation", PojoDescriptorCell.cellFactory());
+
+ TableColumn<PojoDescriptor, String> keyClsCol = textColumn("Key Class Name", "keyClassName", "Key class name",
+ new TextColumnValidator<PojoDescriptor>() {
+ @Override public boolean valid(PojoDescriptor rowVal, String newVal) {
+ boolean valid = checkClassName(rowVal, newVal, true);
+
+ if (valid)
+ rowVal.keyClassName(newVal);
+
+ return valid;
+ }
+ });
+
+ TableColumn<PojoDescriptor, String> valClsCol = textColumn("Value Class Name", "valueClassName", "Value class name",
+ new TextColumnValidator<PojoDescriptor>() {
+ @Override public boolean valid(PojoDescriptor rowVal, String newVal) {
+ boolean valid = checkClassName(rowVal, newVal, false);
+
+ if (valid)
+ rowVal.valueClassName(newVal);
+
+ return valid;
+ }
+ });
+
+ pojosTbl = tableView("Tables not found in database", useCol, keyClsCol, valClsCol);
+
+ TableColumn<PojoField, Boolean> useFldCol = customColumn("Use", "use",
+ "Check to use this field for XML and POJO generation\n" +
+ "Note that NOT NULL columns cannot be unchecked", PojoFieldUseCell.cellFactory());
+ useFldCol.setMinWidth(50);
+ useFldCol.setMaxWidth(50);
+
+ TableColumn<PojoField, Boolean> keyCol = booleanColumn("Key", "key",
+ "Check to include this field into key object");
+
+ TableColumn<PojoField, Boolean> akCol = booleanColumn("AK", "affinityKey",
+ "Check to annotate key filed with @AffinityKeyMapped annotation in generated POJO class\n" +
+ "Note that a class can have only ONE key field annotated with @AffinityKeyMapped annotation");
+
+ TableColumn<PojoField, String> dbNameCol = tableColumn("DB Name", "dbName", "Field name in database");
+
+ TableColumn<PojoField, String> dbTypeNameCol = tableColumn("DB Type", "dbTypeName", "Field type in database");
+
+ TableColumn<PojoField, String> javaNameCol = textColumn("Java Name", "javaName", "Field name in POJO class",
+ new TextColumnValidator<PojoField>() {
+ @Override public boolean valid(PojoField rowVal, String newVal) {
+ if (newVal.trim().isEmpty()) {
+ MessageBox.warningDialog(owner, "Java name must be non empty!");
+
+ return false;
+ }
+
+ for (PojoField field : curPojo.fields())
+ if (rowVal != field && newVal.equals(field.javaName())) {
+ MessageBox.warningDialog(owner, "Java name must be unique!");
+
+ return false;
+ }
+
+ rowVal.javaName(newVal);
+
+ return true;
+ }
+ });
+
+ TableColumn<PojoField, String> javaTypeNameCol = customColumn("Java Type", "javaTypeName",
+ "Field java type in POJO class", JavaTypeCell.cellFactory());
+
+ fieldsTbl = tableView("Select table to see table columns",
+ useFldCol, keyCol, akCol, dbNameCol, dbTypeNameCol, javaNameCol, javaTypeNameCol);
+
+ genPnl.add(splitPane(pojosTbl, fieldsTbl, 0.6), 3);
+
+ final GridPaneEx keyValPnl = paneEx(0, 0, 0, 0);
+ keyValPnl.addColumn(100, 100, Double.MAX_VALUE, Priority.ALWAYS);
+ keyValPnl.addColumn();
+ keyValPnl.addColumn(100, 100, Double.MAX_VALUE, Priority.ALWAYS);
+ keyValPnl.addColumn();
+
+ pkgTf = genPnl.addLabeled("Package:", textField("Package that will be used for POJOs generation"), 2);
+
+ outFolderTf = genPnl.addLabeled("Output Folder:", textField("Output folder for XML and POJOs files"));
+
+ genPnl.add(button("...", "Select output folder", new EventHandler<ActionEvent>() {
+ @Override public void handle(ActionEvent evt) {
+ DirectoryChooser dc = new DirectoryChooser();
+
+ try {
+ File outFolder = new File(outFolderTf.getText());
+
+ if (outFolder.exists())
+ dc.setInitialDirectory(outFolder);
+ }
+ catch (Exception ignored) {
+ // No-op.
+ }
+
+ File folder = dc.showDialog(owner);
+
+ if (folder != null)
+ outFolderTf.setText(folder.getAbsolutePath());
+ }
+ }));
+
+ pojoIncludeKeysCh = genPnl.add(checkBox("Include key fields into value POJOs",
+ "If selected then include key fields into value object", true), 3);
+
+ pojoConstructorCh = genPnl.add(checkBox("Generate constructors for POJOs",
+ "If selected then generate empty and full constructors for POJOs", false), 3);
+
+ xmlSingleFileCh = genPnl.add(checkBox("Write all configurations to a single XML file",
+ "If selected then all configurations will be saved into the file 'ignite-type-metadata.xml'", true), 3);
+
+ GridPaneEx regexPnl = paneEx(5, 5, 5, 5);
+ regexPnl.addColumn();
+ regexPnl.addColumn(100, 100, Double.MAX_VALUE, Priority.ALWAYS);
+ regexPnl.addColumn();
+ regexPnl.addColumn(100, 100, Double.MAX_VALUE, Priority.ALWAYS);
+
+ regexTf = regexPnl.addLabeled(" Regexp:", textField("Regular expression. For example: (\\w+)"));
+
+ replaceTf = regexPnl.addLabeled(" Replace with:", textField("Replace text. For example: $1_SomeText"));
+
+ final ComboBox<String> replaceCb = regexPnl.addLabeled(" Replace:", comboBox("Replacement target",
+ "Key class names", "Value class names", "Java names"));
+
+ regexPnl.add(buttonsPane(Pos.CENTER_LEFT, false,
+ button("Rename Selected", "Replaces each substring of this string that matches the given regular expression" +
+ " with the given replacement",
+ new EventHandler<ActionEvent>() {
+ @Override public void handle(ActionEvent evt) {
+ if (checkInput(regexTf, false, "Regular expression should not be empty!"))
+ return;
+
+ String sel = replaceCb.getSelectionModel().getSelectedItem();
+
+ boolean isFields = "Java names".equals(sel) && curTbl == fieldsTbl;
+
+ String src = isFields ? "fields" : "tables";
+
+ String target = "\"" + sel + "\"";
+
+ Collection<PojoDescriptor> selPojos = pojosTbl.getSelectionModel().getSelectedItems();
+
+ Collection<PojoField> selFields = fieldsTbl.getSelectionModel().getSelectedItems();
+
+ boolean isEmpty = isFields ? selFields.isEmpty() : selPojos.isEmpty();
+
+ if (isEmpty) {
+ MessageBox.warningDialog(owner, "Please select " + src + " to rename " + target + "!");
+
+ return;
+ }
+
+ if (!MessageBox.confirmDialog(owner, "Are you sure you want to rename " + target +
+ " for all selected " + src + "?"))
+ return;
+
+ String regex = regexTf.getText();
+
+ String replace = replaceTf.getText();
+
+ try {
+ switch (replaceCb.getSelectionModel().getSelectedIndex()) {
+ case 0:
+ renameKeyClassNames(selPojos, regex, replace);
+ break;
+
+ case 1:
+ renameValueClassNames(selPojos, regex, replace);
+ break;
+
+ default:
+ if (isFields)
+ renameFieldsJavaNames(selFields, regex, replace);
+ else
+ renamePojosJavaNames(selPojos, regex, replace);
+ }
+ }
+ catch (Exception e) {
+ MessageBox.errorDialog(owner, "Failed to rename " + target + "!", e);
+ }
+ }
+ }),
+ button("Reset Selected", "Revert changes for selected items to initial auto-generated values", new EventHandler<ActionEvent>() {
+ @Override public void handle(ActionEvent evt) {
+ String sel = replaceCb.getSelectionModel().getSelectedItem();
+
+ boolean isFields = "Java names".equals(sel) && curTbl == fieldsTbl;
+
+ String src = isFields ? "fields" : "tables";
+
+ String target = "\"" + sel + "\"";
+
+ Collection<PojoDescriptor> selPojos = pojosTbl.getSelectionModel().getSelectedItems();
+
+ Collection<PojoField> selFields = fieldsTbl.getSelectionModel().getSelectedItems();
+
+ boolean isEmpty = isFields ? selFields.isEmpty() : selPojos.isEmpty();
+
+ if (isEmpty) {
+ MessageBox.warningDialog(owner, "Please select " + src + "to revert " + target + "!");
+
+ return;
+ }
+
+ if (!MessageBox.confirmDialog(owner,
+ "Are you sure you want to revert " + target + " for all selected " + src + "?"))
+ return;
+
+ switch (replaceCb.getSelectionModel().getSelectedIndex()) {
+ case 0:
+ revertKeyClassNames(selPojos);
+ break;
+
+ case 1:
+ revertValueClassNames(selPojos);
+ break;
+
+ default:
+ if (isFields)
+ revertFieldsJavaNames(selFields);
+ else
+ revertPojosJavaNames(selPojos);
+ }
+ }
+ })
+ ), 2).setPadding(new Insets(0, 0, 0, 10));
+
+ pojosTbl.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<PojoDescriptor>() {
+ @Override public void changed(ObservableValue<? extends PojoDescriptor> val,
+ PojoDescriptor oldVal, PojoDescriptor newItem) {
+ if (newItem != null && newItem.parent() != null) {
+ curPojo = newItem;
+
+ fieldsTbl.setItems(FXCollections.observableList(curPojo.fields()));
+ fieldsTbl.getSelectionModel().clearSelection();
+
+ keyValPnl.setDisable(false);
+ }
+ else {
+ curPojo = null;
+ fieldsTbl.setItems(NO_FIELDS);
+
+ keyValPnl.setDisable(true);
+ }
+ }
+ });
+
+ pojosTbl.focusedProperty().addListener(new ChangeListener<Boolean>() {
+ @Override public void changed(ObservableValue<? extends Boolean> val, Boolean oldVal, Boolean newVal) {
+ if (newVal)
+ curTbl = pojosTbl;
+ }
+ });
+
+ fieldsTbl.getSelectionModel().selectedIndexProperty().addListener(new ChangeListener<Number>() {
+ @Override public void changed(ObservableValue<? extends Number> val, Number oldVal, Number newVal) {
+ if (curPojo != null) {
+ TableView.TableViewSelectionModel<PojoDescriptor> selMdl = pojosTbl.getSelectionModel();
+
+ List<Integer> selIndices = new ArrayList<>(selMdl.getSelectedIndices());
+
+ if (selIndices.size() > 1) {
+ for (Integer idx : selIndices) {
+ if (pojos.get(idx) != curPojo)
+ selMdl.clearSelection(idx);
+ }
+ }
+ }
+ }
+ });
+
+ fieldsTbl.focusedProperty().addListener(new ChangeListener<Boolean>() {
+ @Override public void changed(ObservableValue<? extends Boolean> val, Boolean oldVal, Boolean newVal) {
+ if (newVal)
+ curTbl = fieldsTbl;
+ }
+ });
+
+ genPnl.add(titledPane("Rename \"Key class name\", \"Value class name\" or \"Java name\" for selected tables",
+ regexPnl), 3);
+
+ genLayerPnl = stackPane(genPnl);
+ }
+
+ /**
+ * Rename key class name for selected POJOs.
+ *
+ * @param selPojos Selected POJOs to rename.
+ * @param regex Regex to search.
+ * @param replace Text for replacement.
+ */
+ private void renameKeyClassNames(Collection<PojoDescriptor> selPojos, String regex, String replace) {
+ for (PojoDescriptor pojo : selPojos)
+ pojo.keyClassName(pojo.keyClassName().replaceAll(regex, replace));
+ }
+
+ /**
+ * Rename value class name for selected POJOs.
+ *
+ * @param selPojos Selected POJOs to rename.
+ * @param regex Regex to search.
+ * @param replace Text for replacement.
+ */
+ private void renameValueClassNames(Collection<PojoDescriptor> selPojos, String regex, String replace) {
+ for (PojoDescriptor pojo : selPojos)
+ pojo.valueClassName(pojo.valueClassName().replaceAll(regex, replace));
+ }
+
+ /**
+ * Rename fields java name for selected POJOs.
+ *
+ * @param selPojos Selected POJOs to rename.
+ * @param regex Regex to search.
+ * @param replace Text for replacement.
+ */
+ private void renamePojosJavaNames(Collection<PojoDescriptor> selPojos, String regex, String replace) {
+ for (PojoDescriptor pojo : selPojos)
+ for (PojoField field : pojo.fields())
+ field.javaName(field.javaName().replaceAll(regex, replace));
+ }
+
+ /**
+ * Rename fields java name for current POJO.
+ *
+ * @param selFields Selected fields for current POJO to rename.
+ * @param regex Regex to search.
+ * @param replace Text for replacement.
+ */
+ private void renameFieldsJavaNames(Collection<PojoField> selFields, String regex, String replace) {
+ for (PojoField field : selFields)
+ field.javaName(field.javaName().replaceAll(regex, replace));
+ }
+
+ /**
+ * Revert key class name for selected POJOs to initial value.
+ *
+ * @param selPojos Selected POJOs to revert.
+ */
+ private void revertKeyClassNames(Collection<PojoDescriptor> selPojos) {
+ for (PojoDescriptor pojo : selPojos)
+ pojo.revertKeyClassName();
+ }
+
+ /**
+ * Revert value class name for selected POJOs to initial value.
+ *
+ * @param selPojos Selected POJOs to revert.
+ */
+ private void revertValueClassNames(Collection<PojoDescriptor> selPojos) {
+ for (PojoDescriptor pojo : selPojos)
+ pojo.revertValueClassName();
+ }
+
+ /**
+ * Revert fields java name for selected POJOs to initial value.
+ *
+ * @param selPojos Selected POJOs to revert.
+ */
+ private void revertPojosJavaNames(Collection<PojoDescriptor> selPojos) {
+ for (PojoDescriptor pojo : selPojos)
+ pojo.revertJavaNames();
+ }
+
+ /**
+ * Revert fields java name for current POJO to initial value.
+ *
+ * @param selFields Selected POJO fields to revert.
+ */
+ private void revertFieldsJavaNames(Collection<PojoField> selFields) {
+ for (PojoField field : selFields)
+ field.resetJavaName();
+ }
+
+ /**
+ * @return POJOs checked in table-tree-view.
+ */
+ private Collection<PojoDescriptor> checkedPojos() {
+ Collection<PojoDescriptor> res = new ArrayList<>();
+
+ for (PojoDescriptor pojo : pojos)
+ if (pojo.checked())
+ res.add(pojo);
+
+ return res;
+ }
+
+ /**
+ * Gets string property.
+ *
+ * @param key Property key.
+ * @param dflt Default value.
+ * @return Property value as string.
+ */
+ private String getStringProp(String key, String dflt) {
+ String val = prefs.getProperty(key);
+
+ if (val != null)
+ return val;
+
+ return dflt;
+ }
+
+ /**
+ * Sets string property.
+ *
+ * @param key Property key.
+ * @param val Value to set.
+ */
+ private void setStringProp(String key, String val) {
+ prefs.put(key, val);
+ }
+
+ /**
+ * Gets int property.
+ *
+ * @param key Property key.
+ * @param dflt Default value.
+ * @return Property value as int.
+ */
+ private int getIntProp(String key, int dflt) {
+ String val = prefs.getProperty(key);
+
+ if (val != null)
+ try {
+ return Integer.parseInt(val);
+ }
+ catch (NumberFormatException ignored) {
+ return dflt;
+ }
+
+ return dflt;
+ }
+
+ /**
+ * Sets int property.
+ *
+ * @param key Property key.
+ * @param val Value to set.
+ */
+ private void setIntProp(String key, int val) {
+ prefs.put(key, String.valueOf(val));
+ }
+
+ /**
+ * Gets boolean property.
+ *
+ * @param key Property key.
+ * @param dflt Default value.
+ * @return Property value as boolean.
+ */
+ private boolean getBoolProp(String key, boolean dflt) {
+ String val = prefs.getProperty(key);
+
+ if (val != null)
+ return Boolean.parseBoolean(val);
+
+ return dflt;
+ }
+
+ /**
+ * Sets boolean property.
+ *
+ * @param key Property key.
+ * @param val Value to set.
+ */
+ private void setBoolProp(String key, boolean val) {
+ prefs.put(key, String.valueOf(val));
+ }
+
+ /**
+ * Resolve path.
+ *
+ * @param key Preferences key.
+ * @param dflt Default value.
+ * @return String with full file path or default value.
+ */
+ private String resolveFilePath(String key, String dflt) {
+ String path = prefs.getProperty(key);
+
+ if (path != null) {
+ File file = U.resolveIgnitePath(path);
+
+ if (file != null)
+ return file.getAbsolutePath();
+ }
+
+ return dflt;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void start(Stage primaryStage) {
+ owner = primaryStage;
+
+ if (prefsFile.exists())
+ try (BufferedInputStream in = new BufferedInputStream(new FileInputStream(prefsFile))) {
+ prefs.load(in);
+ }
+ catch (IOException e) {
+ log.log(Level.SEVERE, "Failed to load preferences. Default preferences will be used", e);
+ }
+
+ // Load custom preferences.
+ List<String> params = getParameters().getRaw();
+
+ if (!params.isEmpty()) {
+ String customPrefsFileName = params.get(0);
+
+ if (customPrefsFileName.isEmpty())
+ log.log(Level.WARNING, "Path to file with custom preferences is not specified.");
+ else {
+ File customPrefsFile = U.resolveIgnitePath(customPrefsFileName);
+
+ if (customPrefsFile == null)
+ log.log(Level.WARNING, "Failed to resolve path to file with custom preferences: " +
+ customPrefsFile);
+ else {
+ Properties customPrefs = new Properties();
+
+ try (BufferedInputStream in = new BufferedInputStream(new FileInputStream(customPrefsFile))) {
+ customPrefs.load(in);
+ }
+ catch (IOException e) {
+ log.log(Level.SEVERE, "Failed to load custom preferences.", e);
+ }
+
+ prefs.putAll(customPrefs);
+ }
+ }
+ }
+
+ // Restore presets.
+ for (Preset preset : presets) {
+ String key = "presets." + preset.pref + ".";
+
+ preset.jar = getStringProp(key + "jar", preset.jar);
+ preset.drv = getStringProp(key + "drv", preset.drv);
+ preset.url = getStringProp(key + "url", preset.url);
+ preset.user = getStringProp(key + "user", preset.user);
+ }
+
+ primaryStage.setTitle("Apache Ignite Auto Schema Import Utility");
+
+ primaryStage.getIcons().addAll(
+ image("ignite", 16),
+ image("ignite", 24),
+ image("ignite", 32),
+ image("ignite", 48),
+ image("ignite", 64),
+ image("ignite", 128));
+
+ pi = progressIndicator(50);
+
+ createGeneratePane();
+
+ hdrPane = createHeaderPane();
+ rootPane = borderPane(hdrPane, createConnectionPane(), createButtonsPane(), null, null);
+
+ primaryStage.setScene(scene(rootPane));
+
+ primaryStage.setWidth(650);
+ primaryStage.setMinWidth(650);
+
+ primaryStage.setHeight(650);
+ primaryStage.setMinHeight(650);
+
+ prev();
+
+ // Restore window pos and size.
+ if (prefs.getProperty(PREF_WINDOW_X) != null) {
+ int x = getIntProp(PREF_WINDOW_X, 100);
+ int y = getIntProp(PREF_WINDOW_Y, 100);
+ int w = getIntProp(PREF_WINDOW_WIDTH, 650);
+ int h = getIntProp(PREF_WINDOW_HEIGHT, 650);
+
+ // Ensure that window fit any available screen.
+ if (!Screen.getScreensForRectangle(x, y, w, h).isEmpty()) {
+ primaryStage.setX(x);
+ primaryStage.setY(y);
+
+ primaryStage.setWidth(w);
+ primaryStage.setHeight(h);
+ }
+ }
+ else
+ primaryStage.centerOnScreen();
+
+ String userHome = System.getProperty("user.home").replace('\\', '/');
+
+ // Restore connection pane settings.
+ rdbmsCb.getSelectionModel().select(getIntProp(PREF_JDBC_DB_PRESET, 0));
+ jdbcDrvJarTf.setText(resolveFilePath(PREF_JDBC_DRIVER_JAR, "h2.jar"));
+ jdbcDrvClsTf.setText(getStringProp(PREF_JDBC_DRIVER_CLASS, "org.h2.Driver"));
+ jdbcUrlTf.setText(getStringProp(PREF_JDBC_URL, "jdbc:h2:" + userHome + "/ignite-schema-import/db"));
+ userTf.setText(getStringProp(PREF_JDBC_USER, "sa"));
+
+ // Restore generation pane settings.
+ outFolderTf.setText(resolveFilePath(PREF_OUT_FOLDER, userHome + "/ignite-schema-import/out"));
+
+ pkgTf.setText(getStringProp(PREF_POJO_PACKAGE, "org.apache.ignite"));
+ pojoIncludeKeysCh.setSelected(getBoolProp(PREF_POJO_INCLUDE, true));
+ pojoConstructorCh.setSelected(getBoolProp(PREF_POJO_CONSTRUCTOR, false));
+
+ xmlSingleFileCh.setSelected(getBoolProp(PREF_XML_SINGLE, true));
+
+ regexTf.setText(getStringProp(PREF_NAMING_PATTERN, "(\\w+)"));
+ replaceTf.setText(getStringProp(PREF_NAMING_REPLACE, "$1_SomeText"));
+
+ primaryStage.show();
+ }
+
+ /**
+ * Save preset.
+ *
+ * @param preset Preset to save.
+ */
+ private void savePreset(Preset preset) {
+ String key = "presets." + preset.pref + ".";
+
+ preset.jar = jdbcDrvJarTf.getText();
+ setStringProp(key + "jar", preset.jar);
+
+ preset.drv = jdbcDrvClsTf.getText();
+ setStringProp(key + "drv", preset.drv);
+
+ preset.url = jdbcUrlTf.getText();
+ setStringProp(key + "url", preset.url);
+
+ preset.user = userTf.getText();
+ setStringProp(key + "user", preset.user);
+
+ savePreferences();
+ }
+
+ /**
+ * Save user preferences.
+ */
+ private void savePreferences() {
+ try (FileOutputStream out = new FileOutputStream(prefsFile)) {
+ prefs.store(out, "Apache Ignite Schema Import Utility");
+ }
+ catch (IOException e) {
+ MessageBox.errorDialog(owner, "Failed to save preferences!", e);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void stop() throws Exception {
+ // Save window pos and size.
+ setIntProp(PREF_WINDOW_X, (int)owner.getX());
+ setIntProp(PREF_WINDOW_Y, (int)owner.getY());
+ setIntProp(PREF_WINDOW_WIDTH, (int)owner.getWidth());
+ setIntProp(PREF_WINDOW_HEIGHT, (int)owner.getHeight());
+
+ // Save connection pane settings.
+ setIntProp(PREF_JDBC_DB_PRESET, rdbmsCb.getSelectionModel().getSelectedIndex());
+ setStringProp(PREF_JDBC_DRIVER_JAR, jdbcDrvJarTf.getText());
+ setStringProp(PREF_JDBC_DRIVER_CLASS, jdbcDrvClsTf.getText());
+ setStringProp(PREF_JDBC_URL, jdbcUrlTf.getText());
+ setStringProp(PREF_JDBC_USER, userTf.getText());
+
+ // Save generation pane settings.
+ setStringProp(PREF_OUT_FOLDER, outFolderTf.getText());
+
+ setStringProp(PREF_POJO_PACKAGE, pkgTf.getText());
+ setBoolProp(PREF_POJO_INCLUDE, pojoIncludeKeysCh.isSelected());
+ setBoolProp(PREF_POJO_CONSTRUCTOR, pojoConstructorCh.isSelected());
+
+ setBoolProp(PREF_XML_SINGLE, xmlSingleFileCh.isSelected());
+
+ setStringProp(PREF_NAMING_PATTERN, regexTf.getText());
+ setStringProp(PREF_NAMING_REPLACE, replaceTf.getText());
+
+ savePreferences();
+ }
+
+ /**
+ * Schema Import utility launcher.
+ *
+ * @param args Command line arguments passed to the application.
+ */
+ public static void main(String[] args) {
+ // Workaround for JavaFX ugly text AA.
+ System.setProperty("prism.lcdtext", "false");
+ System.setProperty("prism.text", "t2k");
+
+ // Workaround for AWT + JavaFX: we should initialize AWT before JavaFX.
+ java.awt.Toolkit.getDefaultToolkit();
+
+ // Workaround for JavaFX + Mac OS dock icon.
+ if (System.getProperty("os.name").toLowerCase().contains("mac os")) {
+ System.setProperty("javafx.macosx.embedded", "true");
+
+ try {
+ Class<?> appCls = Class.forName("com.apple.eawt.Application");
+
+ Object osxApp = appCls.getDeclaredMethod("getApplication").invoke(null);
+
+ appCls.getDeclaredMethod("setDockIconImage", java.awt.Image.class)
+ .invoke(osxApp, fromFXImage(image("ignite", 128), null));
+ }
+ catch (Exception ignore) {
+ // No-op.
+ }
+ }
+
+ launch(args);
+ }
+
+ /**
+ * Special table cell to select possible java type conversions.
+ */
+ private static class JavaTypeCell extends TableCell<PojoField, String> {
+ /** Combo box. */
+ private final ComboBox<String> comboBox;
+
+ /**
+ * Creates a ComboBox cell factory for use in TableColumn controls.
+ *
+ * @return Cell factory for cell with java types combobox.
+ */
+ public static Callback<TableColumn<PojoField, String>, TableCell<PojoField, String>> cellFactory() {
+ return new Callback<TableColumn<PojoField, String>, TableCell<PojoField, String>>() {
+ @Override public TableCell<PojoField, String> call(TableColumn<PojoField, String> col) {
+ return new JavaTypeCell();
+ }
+ };
+ }
+
+ /**
+ * Default constructor.
+ */
+ private JavaTypeCell() {
+ comboBox = new ComboBox<>(FXCollections.<String>emptyObservableList());
+
+ comboBox.valueProperty().addListener(new ChangeListener<String>() {
+ @Override public void changed(ObservableValue<? extends String> val, String oldVal, String newVal) {
+ if (isEditing())
+ commitEdit(newVal);
+ }
+ });
+
+ getStyleClass().add("combo-box-table-cell");
+ }
+
+ /** {@inheritDoc} */
+ @Override public void startEdit() {
+ if (comboBox.getItems().size() > 1) {
+ comboBox.getSelectionModel().select(getItem());
+
+ super.startEdit();
+
+ setText(null);
+ setGraphic(comboBox);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void cancelEdit() {
+ super.cancelEdit();
+
+ setText(getItem());
+
+ setGraphic(null);
+ }
+
+ /** {@inheritDoc} */
+ @Override public void updateItem(String item, boolean empty) {
+ super.updateItem(item, empty);
+
+ setGraphic(null);
+ setText(null);
+
+ if (!empty) {
+ setText(item);
+
+ TableRow row = getTableRow();
+
+ if (row != null) {
+ PojoField pojo = (PojoField)row.getItem();
+
+ if (pojo != null) {
+ comboBox.setItems(FXCollections.observableList(pojo.conversions()));
+ comboBox.getSelectionModel().select(pojo.javaTypeName());
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Special table cell to select schema or table.
+ */
+ private static class PojoDescriptorCell extends TableCell<PojoDescriptor, Boolean> {
+ /**
+ * Creates a ComboBox cell factory for use in TableColumn controls.
+ *
+ * @return Cell factory for schema / table selection.
+ */
+ public static Callback<TableColumn<PojoDescriptor, Boolean>, TableCell<PojoDescriptor, Boolean>> cellFactory() {
+ return new Callback<TableColumn<PojoDescriptor, Boolean>, TableCell<PojoDescriptor, Boolean>>() {
+ @Override public TableCell<PojoDescriptor, Boolean> call(TableColumn<PojoDescriptor, Boolean> col) {
+ return new PojoDescriptorCell();
+ }
+ };
+ }
+
+ /** Previous POJO bound to cell. */
+ private PojoDescriptor prevPojo;
+
+ /** Previous cell graphic. */
+ private Pane prevGraphic;
+
+ /** {@inheritDoc} */
+ @Override public void updateItem(Boolean item, boolean empty) {
+ super.updateItem(item, empty);
+
+ setGraphic(null);
+
+ if (!empty) {
+ TableRow row = getTableRow();
+
+ if (row != null) {
+ final PojoDescriptor pojo = (PojoDescriptor)row.getItem();
+
+ if (pojo != null) {
+ if (prevGraphic == null || pojo != prevPojo) {
+ boolean isTbl = pojo.parent() != null;
+
+ CheckBox ch = new CheckBox();
+ ch.setAllowIndeterminate(false);
+ ch.indeterminateProperty().bindBidirectional(JavaFxUtils.booleanProperty(pojo.indeterminate()));
+ ch.selectedProperty().bindBidirectional(JavaFxUtils.booleanProperty(pojo.useProperty()));
+
+ Label lb = new Label(isTbl ? pojo.table() : pojo.schema());
+
+ Pane pnl = new HBox(5);
+ pnl.setPadding(new Insets(0, 0, 0, isTbl ? 25 : 5));
+ pnl.getChildren().addAll(ch, lb);
+
+ prevPojo = pojo;
+ prevGraphic = pnl;
+ }
+
+ setGraphic(prevGraphic);
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Special table cell to select "used" fields for code generation.
+ */
+ private static class PojoFieldUseCell extends TableCell<PojoField, Boolean> {
+ /**
+ * Creates a ComboBox cell factory for use in TableColumn controls.
+ *
+ * @return Cell factory for used fields selection.
+ */
+ public static Callback<TableColumn<PojoField, Boolean>, TableCell<PojoField, Boolean>> cellFactory() {
+ return new Callback<TableColumn<PojoField, Boolean>, TableCell<PojoField, Boolean>>() {
+ @Override public TableCell<PojoField, Boolean> call(TableColumn<PojoField, Boolean> col) {
+ return new PojoFieldUseCell();
+ }
+ };
+ }
+
+ /** Previous POJO field bound to cell. */
+ private PojoField prevField;
+
+ /** Previous cell graphic. */
+ private CheckBox prevGraphic;
+
+ /** {@inheritDoc} */
+ @Override public void updateItem(Boolean item, boolean empty) {
+ super.updateItem(item, empty);
+
+ setGraphic(null);
+
+ if (!empty) {
+ TableRow row = getTableRow();
+
+ if (row != null) {
+ final PojoField field = (PojoField)row.getItem();
+
+ if (field != null) {
+ if (prevGraphic == null || prevField != field) {
+ setAlignment(Pos.CENTER);
+
+ CheckBox ch = new CheckBox();
+ ch.setDisable(!field.nullable());
+ ch.selectedProperty().bindBidirectional(JavaFxUtils.booleanProperty(field.useProperty()));
+
+ prevField = field;
+ prevGraphic = ch;
+ }
+
+ setGraphic(prevGraphic);
+ }
+ }
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import-ui/src/main/java/org/apache/ignite/schema/ui/TextColumnValidator.java
----------------------------------------------------------------------
diff --git a/modules/schema-import-ui/src/main/java/org/apache/ignite/schema/ui/TextColumnValidator.java b/modules/schema-import-ui/src/main/java/org/apache/ignite/schema/ui/TextColumnValidator.java
new file mode 100644
index 0000000..d92ae08
--- /dev/null
+++ b/modules/schema-import-ui/src/main/java/org/apache/ignite/schema/ui/TextColumnValidator.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.ignite.schema.ui;
+
+/**
+ * Validator for editable table view text column.
+ */
+public interface TextColumnValidator<T> {
+ /**
+ * Validate new value of text.
+ *
+ * @param rowVal Row value.
+ * @param newVal New value of text.
+ * @return {@code true} if text is valid.
+ */
+ public boolean valid(T rowVal, String newVal);
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import-ui/src/test/java/org/apache/ignite/schema/test/AbstractSchemaImportTest.java
----------------------------------------------------------------------
diff --git a/modules/schema-import-ui/src/test/java/org/apache/ignite/schema/test/AbstractSchemaImportTest.java b/modules/schema-import-ui/src/test/java/org/apache/ignite/schema/test/AbstractSchemaImportTest.java
new file mode 100644
index 0000000..191f929
--- /dev/null
+++ b/modules/schema-import-ui/src/test/java/org/apache/ignite/schema/test/AbstractSchemaImportTest.java
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.ignite.schema.test;
+
+import junit.framework.*;
+import org.apache.ignite.internal.util.typedef.internal.*;
+import org.apache.ignite.schema.model.*;
+import org.apache.ignite.schema.parser.*;
+import org.apache.ignite.schema.ui.*;
+
+import java.io.*;
+import java.sql.*;
+import java.util.*;
+
+/**
+ * Base functional for Ignite Schema Import utility tests.
+ */
+public abstract class AbstractSchemaImportTest extends TestCase {
+ /** DB connection URL. */
+ private static final String CONN_URL = "jdbc:h2:mem:autoCacheStore;DB_CLOSE_DELAY=-1";
+
+ /** Path to temp folder where generated POJOs will be saved. */
+ protected static final String OUT_DIR_PATH = System.getProperty("java.io.tmpdir") + "/ignite-schema-import/out";
+
+ /** Auto confirmation of file conflicts. */
+ protected ConfirmCallable askOverwrite = new ConfirmCallable(null, "") {
+ @Override public Result confirm(String msg) {
+ return Result.OVERRIDE;
+ }
+ };
+
+ /** List of generated for test database POJO objects. */
+ protected List<PojoDescriptor> pojos;
+
+ /** {@inheritDoc} */
+ @Override public void setUp() throws Exception {
+ Class.forName("org.h2.Driver");
+
+ Connection conn = DriverManager.getConnection(CONN_URL, "sa", "");
+
+ Statement stmt = conn.createStatement();
+
+ stmt.executeUpdate("CREATE TABLE IF NOT EXISTS PRIMITIVES (pk INTEGER PRIMARY KEY, " +
+ " boolCol BOOLEAN NOT NULL," +
+ " byteCol TINYINT NOT NULL," +
+ " shortCol SMALLINT NOT NULL," +
+ " intCol INTEGER NOT NULL, " +
+ " longCol BIGINT NOT NULL," +
+ " floatCol REAL NOT NULL," +
+ " doubleCol DOUBLE NOT NULL," +
+ " doubleCol2 DOUBLE NOT NULL, " +
+ " bigDecimalCol DECIMAL(10, 0)," +
+ " strCol VARCHAR(10)," +
+ " dateCol DATE," +
+ " timeCol TIME," +
+ " tsCol TIMESTAMP, " +
+ " arrCol BINARY(10))");
+
+ stmt.executeUpdate("CREATE TABLE IF NOT EXISTS OBJECTS (pk INTEGER PRIMARY KEY, " +
+ " boolCol BOOLEAN," +
+ " byteCol TINYINT," +
+ " shortCol SMALLINT," +
+ " intCol INTEGER," +
+ " longCol BIGINT," +
+ " floatCol REAL," +
+ " doubleCol DOUBLE," +
+ " doubleCol2 DOUBLE," +
+ " bigDecimalCol DECIMAL(10, 0)," +
+ " strCol VARCHAR(10), " +
+ " dateCol DATE," +
+ " timeCol TIME," +
+ " tsCol TIMESTAMP," +
+ " arrCol BINARY(10))");
+
+ conn.commit();
+
+ U.closeQuiet(stmt);
+
+ pojos = DatabaseMetadataParser.parse(conn, false);
+
+ U.closeQuiet(conn);
+ }
+
+ /**
+ * Compare files by lines.
+ *
+ * @param exp Stream to read of expected file from test resources.
+ * @param generated Generated file instance.
+ * @param excludePtrn Marker string to exclude lines from comparing.
+ * @return true if generated file correspond to expected.
+ */
+ protected boolean compareFilesInt(InputStream exp, File generated, String excludePtrn) {
+ try (BufferedReader baseReader = new BufferedReader(new InputStreamReader(exp))) {
+ try (BufferedReader generatedReader = new BufferedReader(new FileReader(generated))) {
+ String baseLine;
+
+ while ((baseLine = baseReader.readLine()) != null) {
+ String generatedLine = generatedReader.readLine();
+
+ if (!baseLine.equals(generatedLine) && !baseLine.contains(excludePtrn)
+ && !generatedLine.contains(excludePtrn)) {
+ System.out.println("Expected: " + baseLine);
+ System.out.println("Generated: " + generatedLine);
+
+ return false;
+ }
+ }
+
+ return true;
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+
+ return false;
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import-ui/src/test/java/org/apache/ignite/schema/test/generator/CodeGeneratorTest.java
----------------------------------------------------------------------
diff --git a/modules/schema-import-ui/src/test/java/org/apache/ignite/schema/test/generator/CodeGeneratorTest.java b/modules/schema-import-ui/src/test/java/org/apache/ignite/schema/test/generator/CodeGeneratorTest.java
new file mode 100644
index 0000000..d758e65
--- /dev/null
+++ b/modules/schema-import-ui/src/test/java/org/apache/ignite/schema/test/generator/CodeGeneratorTest.java
@@ -0,0 +1,70 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.ignite.schema.test.generator;
+
+import org.apache.ignite.schema.generator.*;
+import org.apache.ignite.schema.model.*;
+import org.apache.ignite.schema.test.*;
+
+import java.io.*;
+
+/**
+ * Tests for POJO generator.
+ */
+public class CodeGeneratorTest extends AbstractSchemaImportTest {
+ /** Marker string to skip date generation while comparing.*/
+ private static final String GEN_PTRN = "Code generated by Apache Ignite Schema Import utility";
+
+ /**
+ * Test that POJOs generated correctly.
+ */
+ public void testPojoGeneration() throws Exception {
+ String pkg = "org.apache.ignite.schema.test.model";
+ String intPath = "org/apache/ignite/schema/test/model";
+
+ Boolean containsSchema = false;
+
+ for (PojoDescriptor pojo : pojos) {
+ if (pojo.valueClassName().isEmpty())
+ containsSchema = true;
+ else {
+ CodeGenerator.pojos(pojo, OUT_DIR_PATH, pkg, true, true, askOverwrite);
+
+ assertTrue("Generated key class POJO content is differ from expected for type " + pojo.keyClassName(),
+ compareFiles(pojo.keyClassName(), intPath, GEN_PTRN));
+
+ assertTrue("Generated value class POJO content is differ from expected for type " + pojo.valueClassName(),
+ compareFiles(pojo.valueClassName(), intPath, GEN_PTRN));
+ }
+ }
+
+ assertTrue("Generated POJOs does not contains schema.", containsSchema);
+ }
+
+ /**
+ * @param typeName Type name.
+ * @param intPath Internal path.
+ * @return {@code true} if generated POJO as expected.
+ */
+ private boolean compareFiles(String typeName, String intPath, String excludePtrn) {
+ String relPath = intPath + "/" + typeName;
+
+ return compareFilesInt(getClass().getResourceAsStream("/" + relPath + ".txt"),
+ new File(OUT_DIR_PATH + "/" + relPath + ".java"), excludePtrn);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import-ui/src/test/java/org/apache/ignite/schema/test/generator/XmlGeneratorTest.java
----------------------------------------------------------------------
diff --git a/modules/schema-import-ui/src/test/java/org/apache/ignite/schema/test/generator/XmlGeneratorTest.java b/modules/schema-import-ui/src/test/java/org/apache/ignite/schema/test/generator/XmlGeneratorTest.java
new file mode 100644
index 0000000..af6469d
--- /dev/null
+++ b/modules/schema-import-ui/src/test/java/org/apache/ignite/schema/test/generator/XmlGeneratorTest.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.ignite.schema.test.generator;
+
+import org.apache.ignite.schema.generator.*;
+import org.apache.ignite.schema.model.*;
+import org.apache.ignite.schema.test.*;
+
+import java.io.*;
+import java.util.*;
+
+/**
+ * Tests for XML generator.
+ */
+public class XmlGeneratorTest extends AbstractSchemaImportTest {
+ /**
+ * Test that XML generated correctly.
+ */
+ public void testXmlGeneration() throws Exception {
+ Collection<PojoDescriptor> all = new ArrayList<>();
+
+ for (PojoDescriptor pojo : pojos)
+ if (pojo.parent() != null)
+ all.add(pojo);
+
+ String fileName = "ignite-type-metadata.xml";
+
+ XmlGenerator.generate("org.apache.ignite.schema.test.model", all, true, new File(OUT_DIR_PATH, fileName),
+ askOverwrite);
+
+ assertTrue("Generated XML file content is differ from expected one",
+ compareFilesInt(getClass().getResourceAsStream("/org/apache/ignite/schema/test/model/" + fileName),
+ new File(OUT_DIR_PATH + "/" + fileName), "XML generated by Apache Ignite Schema Import utility"));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import-ui/src/test/java/org/apache/ignite/schema/test/model/Objects.txt
----------------------------------------------------------------------
diff --git a/modules/schema-import-ui/src/test/java/org/apache/ignite/schema/test/model/Objects.txt b/modules/schema-import-ui/src/test/java/org/apache/ignite/schema/test/model/Objects.txt
new file mode 100644
index 0000000..c448ab5
--- /dev/null
+++ b/modules/schema-import-ui/src/test/java/org/apache/ignite/schema/test/model/Objects.txt
@@ -0,0 +1,502 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.ignite.schema.test.model;
+
+import java.io.*;
+
+/**
+ * Objects definition.
+ *
+ * Code generated by Apache Ignite Schema Import utility: 01/27/2015.
+ */
+public class Objects implements Serializable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Value for pk. */
+ private int pk;
+
+ /** Value for boolcol. */
+ private Boolean boolcol;
+
+ /** Value for bytecol. */
+ private Byte bytecol;
+
+ /** Value for shortcol. */
+ private Short shortcol;
+
+ /** Value for intcol. */
+ private Integer intcol;
+
+ /** Value for longcol. */
+ private Long longcol;
+
+ /** Value for floatcol. */
+ private Float floatcol;
+
+ /** Value for doublecol. */
+ private Double doublecol;
+
+ /** Value for doublecol2. */
+ private Double doublecol2;
+
+ /** Value for bigdecimalcol. */
+ private java.math.BigDecimal bigdecimalcol;
+
+ /** Value for strcol. */
+ private String strcol;
+
+ /** Value for datecol. */
+ private java.sql.Date datecol;
+
+ /** Value for timecol. */
+ private java.sql.Time timecol;
+
+ /** Value for tscol. */
+ private java.sql.Timestamp tscol;
+
+ /** Value for arrcol. */
+ private Object arrcol;
+
+ /**
+ * Empty constructor.
+ */
+ public Objects() {
+ // No-op.
+ }
+
+ /**
+ * Full constructor.
+ */
+ public Objects(
+ int pk,
+ Boolean boolcol,
+ Byte bytecol,
+ Short shortcol,
+ Integer intcol,
+ Long longcol,
+ Float floatcol,
+ Double doublecol,
+ Double doublecol2,
+ java.math.BigDecimal bigdecimalcol,
+ String strcol,
+ java.sql.Date datecol,
+ java.sql.Time timecol,
+ java.sql.Timestamp tscol,
+ Object arrcol
+ ) {
+ this.pk = pk;
+ this.boolcol = boolcol;
+ this.bytecol = bytecol;
+ this.shortcol = shortcol;
+ this.intcol = intcol;
+ this.longcol = longcol;
+ this.floatcol = floatcol;
+ this.doublecol = doublecol;
+ this.doublecol2 = doublecol2;
+ this.bigdecimalcol = bigdecimalcol;
+ this.strcol = strcol;
+ this.datecol = datecol;
+ this.timecol = timecol;
+ this.tscol = tscol;
+ this.arrcol = arrcol;
+ }
+
+ /**
+ * Gets pk.
+ *
+ * @return Value for pk.
+ */
+ public int getPk() {
+ return pk;
+ }
+
+ /**
+ * Sets pk.
+ *
+ * @param pk New value for pk.
+ */
+ public void setPk(int pk) {
+ this.pk = pk;
+ }
+
+ /**
+ * Gets boolcol.
+ *
+ * @return Value for boolcol.
+ */
+ public Boolean getBoolcol() {
+ return boolcol;
+ }
+
+ /**
+ * Sets boolcol.
+ *
+ * @param boolcol New value for boolcol.
+ */
+ public void setBoolcol(Boolean boolcol) {
+ this.boolcol = boolcol;
+ }
+
+ /**
+ * Gets bytecol.
+ *
+ * @return Value for bytecol.
+ */
+ public Byte getBytecol() {
+ return bytecol;
+ }
+
+ /**
+ * Sets bytecol.
+ *
+ * @param bytecol New value for bytecol.
+ */
+ public void setBytecol(Byte bytecol) {
+ this.bytecol = bytecol;
+ }
+
+ /**
+ * Gets shortcol.
+ *
+ * @return Value for shortcol.
+ */
+ public Short getShortcol() {
+ return shortcol;
+ }
+
+ /**
+ * Sets shortcol.
+ *
+ * @param shortcol New value for shortcol.
+ */
+ public void setShortcol(Short shortcol) {
+ this.shortcol = shortcol;
+ }
+
+ /**
+ * Gets intcol.
+ *
+ * @return Value for intcol.
+ */
+ public Integer getIntcol() {
+ return intcol;
+ }
+
+ /**
+ * Sets intcol.
+ *
+ * @param intcol New value for intcol.
+ */
+ public void setIntcol(Integer intcol) {
+ this.intcol = intcol;
+ }
+
+ /**
+ * Gets longcol.
+ *
+ * @return Value for longcol.
+ */
+ public Long getLongcol() {
+ return longcol;
+ }
+
+ /**
+ * Sets longcol.
+ *
+ * @param longcol New value for longcol.
+ */
+ public void setLongcol(Long longcol) {
+ this.longcol = longcol;
+ }
+
+ /**
+ * Gets floatcol.
+ *
+ * @return Value for floatcol.
+ */
+ public Float getFloatcol() {
+ return floatcol;
+ }
+
+ /**
+ * Sets floatcol.
+ *
+ * @param floatcol New value for floatcol.
+ */
+ public void setFloatcol(Float floatcol) {
+ this.floatcol = floatcol;
+ }
+
+ /**
+ * Gets doublecol.
+ *
+ * @return Value for doublecol.
+ */
+ public Double getDoublecol() {
+ return doublecol;
+ }
+
+ /**
+ * Sets doublecol.
+ *
+ * @param doublecol New value for doublecol.
+ */
+ public void setDoublecol(Double doublecol) {
+ this.doublecol = doublecol;
+ }
+
+ /**
+ * Gets doublecol2.
+ *
+ * @return Value for doublecol2.
+ */
+ public Double getDoublecol2() {
+ return doublecol2;
+ }
+
+ /**
+ * Sets doublecol2.
+ *
+ * @param doublecol2 New value for doublecol2.
+ */
+ public void setDoublecol2(Double doublecol2) {
+ this.doublecol2 = doublecol2;
+ }
+
+ /**
+ * Gets bigdecimalcol.
+ *
+ * @return Value for bigdecimalcol.
+ */
+ public java.math.BigDecimal getBigdecimalcol() {
+ return bigdecimalcol;
+ }
+
+ /**
+ * Sets bigdecimalcol.
+ *
+ * @param bigdecimalcol New value for bigdecimalcol.
+ */
+ public void setBigdecimalcol(java.math.BigDecimal bigdecimalcol) {
+ this.bigdecimalcol = bigdecimalcol;
+ }
+
+ /**
+ * Gets strcol.
+ *
+ * @return Value for strcol.
+ */
+ public String getStrcol() {
+ return strcol;
+ }
+
+ /**
+ * Sets strcol.
+ *
+ * @param strcol New value for strcol.
+ */
+ public void setStrcol(String strcol) {
+ this.strcol = strcol;
+ }
+
+ /**
+ * Gets datecol.
+ *
+ * @return Value for datecol.
+ */
+ public java.sql.Date getDatecol() {
+ return datecol;
+ }
+
+ /**
+ * Sets datecol.
+ *
+ * @param datecol New value for datecol.
+ */
+ public void setDatecol(java.sql.Date datecol) {
+ this.datecol = datecol;
+ }
+
+ /**
+ * Gets timecol.
+ *
+ * @return Value for timecol.
+ */
+ public java.sql.Time getTimecol() {
+ return timecol;
+ }
+
+ /**
+ * Sets timecol.
+ *
+ * @param timecol New value for timecol.
+ */
+ public void setTimecol(java.sql.Time timecol) {
+ this.timecol = timecol;
+ }
+
+ /**
+ * Gets tscol.
+ *
+ * @return Value for tscol.
+ */
+ public java.sql.Timestamp getTscol() {
+ return tscol;
+ }
+
+ /**
+ * Sets tscol.
+ *
+ * @param tscol New value for tscol.
+ */
+ public void setTscol(java.sql.Timestamp tscol) {
+ this.tscol = tscol;
+ }
+
+ /**
+ * Gets arrcol.
+ *
+ * @return Value for arrcol.
+ */
+ public Object getArrcol() {
+ return arrcol;
+ }
+
+ /**
+ * Sets arrcol.
+ *
+ * @param arrcol New value for arrcol.
+ */
+ public void setArrcol(Object arrcol) {
+ this.arrcol = arrcol;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o)
+ return true;
+
+ if (!(o instanceof Objects))
+ return false;
+
+ Objects that = (Objects)o;
+
+ if (pk != that.pk)
+ return false;
+
+ if (boolcol != null ? !boolcol.equals(that.boolcol) : that.boolcol != null)
+ return false;
+
+ if (bytecol != null ? !bytecol.equals(that.bytecol) : that.bytecol != null)
+ return false;
+
+ if (shortcol != null ? !shortcol.equals(that.shortcol) : that.shortcol != null)
+ return false;
+
+ if (intcol != null ? !intcol.equals(that.intcol) : that.intcol != null)
+ return false;
+
+ if (longcol != null ? !longcol.equals(that.longcol) : that.longcol != null)
+ return false;
+
+ if (floatcol != null ? !floatcol.equals(that.floatcol) : that.floatcol != null)
+ return false;
+
+ if (doublecol != null ? !doublecol.equals(that.doublecol) : that.doublecol != null)
+ return false;
+
+ if (doublecol2 != null ? !doublecol2.equals(that.doublecol2) : that.doublecol2 != null)
+ return false;
+
+ if (bigdecimalcol != null ? !bigdecimalcol.equals(that.bigdecimalcol) : that.bigdecimalcol != null)
+ return false;
+
+ if (strcol != null ? !strcol.equals(that.strcol) : that.strcol != null)
+ return false;
+
+ if (datecol != null ? !datecol.equals(that.datecol) : that.datecol != null)
+ return false;
+
+ if (timecol != null ? !timecol.equals(that.timecol) : that.timecol != null)
+ return false;
+
+ if (tscol != null ? !tscol.equals(that.tscol) : that.tscol != null)
+ return false;
+
+ if (arrcol != null ? !arrcol.equals(that.arrcol) : that.arrcol != null)
+ return false;
+
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ int res = pk;
+
+ res = 31 * res + (boolcol != null ? boolcol.hashCode() : 0);
+
+ res = 31 * res + (bytecol != null ? bytecol.hashCode() : 0);
+
+ res = 31 * res + (shortcol != null ? shortcol.hashCode() : 0);
+
+ res = 31 * res + (intcol != null ? intcol.hashCode() : 0);
+
+ res = 31 * res + (longcol != null ? longcol.hashCode() : 0);
+
+ res = 31 * res + (floatcol != null ? floatcol.hashCode() : 0);
+
+ res = 31 * res + (doublecol != null ? doublecol.hashCode() : 0);
+
+ res = 31 * res + (doublecol2 != null ? doublecol2.hashCode() : 0);
+
+ res = 31 * res + (bigdecimalcol != null ? bigdecimalcol.hashCode() : 0);
+
+ res = 31 * res + (strcol != null ? strcol.hashCode() : 0);
+
+ res = 31 * res + (datecol != null ? datecol.hashCode() : 0);
+
+ res = 31 * res + (timecol != null ? timecol.hashCode() : 0);
+
+ res = 31 * res + (tscol != null ? tscol.hashCode() : 0);
+
+ res = 31 * res + (arrcol != null ? arrcol.hashCode() : 0);
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return "Objects [pk=" + pk +
+ ", boolcol=" + boolcol +
+ ", bytecol=" + bytecol +
+ ", shortcol=" + shortcol +
+ ", intcol=" + intcol +
+ ", longcol=" + longcol +
+ ", floatcol=" + floatcol +
+ ", doublecol=" + doublecol +
+ ", doublecol2=" + doublecol2 +
+ ", bigdecimalcol=" + bigdecimalcol +
+ ", strcol=" + strcol +
+ ", datecol=" + datecol +
+ ", timecol=" + timecol +
+ ", tscol=" + tscol +
+ ", arrcol=" + arrcol +
+ "]";
+ }
+}
[5/7] incubator-ignite git commit: IGNITE-1155 Extract
ignite-schema-import-ui module.
Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import-ui/src/test/java/org/apache/ignite/schema/test/model/ObjectsKey.txt
----------------------------------------------------------------------
diff --git a/modules/schema-import-ui/src/test/java/org/apache/ignite/schema/test/model/ObjectsKey.txt b/modules/schema-import-ui/src/test/java/org/apache/ignite/schema/test/model/ObjectsKey.txt
new file mode 100644
index 0000000..cad109c
--- /dev/null
+++ b/modules/schema-import-ui/src/test/java/org/apache/ignite/schema/test/model/ObjectsKey.txt
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.ignite.schema.test.model;
+
+import java.io.*;
+
+/**
+ * ObjectsKey definition.
+ *
+ * Code generated by Apache Ignite Schema Import utility: 01/27/2015.
+ */
+public class ObjectsKey implements Serializable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Value for pk. */
+ private int pk;
+
+ /**
+ * Empty constructor.
+ */
+ public ObjectsKey() {
+ // No-op.
+ }
+
+ /**
+ * Full constructor.
+ */
+ public ObjectsKey(
+ int pk
+ ) {
+ this.pk = pk;
+ }
+
+ /**
+ * Gets pk.
+ *
+ * @return Value for pk.
+ */
+ public int getPk() {
+ return pk;
+ }
+
+ /**
+ * Sets pk.
+ *
+ * @param pk New value for pk.
+ */
+ public void setPk(int pk) {
+ this.pk = pk;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o)
+ return true;
+
+ if (!(o instanceof ObjectsKey))
+ return false;
+
+ ObjectsKey that = (ObjectsKey)o;
+
+ if (pk != that.pk)
+ return false;
+
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ int res = pk;
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return "ObjectsKey [pk=" + pk +
+ "]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import-ui/src/test/java/org/apache/ignite/schema/test/model/Primitives.txt
----------------------------------------------------------------------
diff --git a/modules/schema-import-ui/src/test/java/org/apache/ignite/schema/test/model/Primitives.txt b/modules/schema-import-ui/src/test/java/org/apache/ignite/schema/test/model/Primitives.txt
new file mode 100644
index 0000000..ef8f902
--- /dev/null
+++ b/modules/schema-import-ui/src/test/java/org/apache/ignite/schema/test/model/Primitives.txt
@@ -0,0 +1,506 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.ignite.schema.test.model;
+
+import java.io.*;
+
+/**
+ * Primitives definition.
+ *
+ * Code generated by Apache Ignite Schema Import utility: 01/27/2015.
+ */
+public class Primitives implements Serializable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Value for pk. */
+ private int pk;
+
+ /** Value for boolcol. */
+ private boolean boolcol;
+
+ /** Value for bytecol. */
+ private byte bytecol;
+
+ /** Value for shortcol. */
+ private short shortcol;
+
+ /** Value for intcol. */
+ private int intcol;
+
+ /** Value for longcol. */
+ private long longcol;
+
+ /** Value for floatcol. */
+ private float floatcol;
+
+ /** Value for doublecol. */
+ private double doublecol;
+
+ /** Value for doublecol2. */
+ private double doublecol2;
+
+ /** Value for bigdecimalcol. */
+ private java.math.BigDecimal bigdecimalcol;
+
+ /** Value for strcol. */
+ private String strcol;
+
+ /** Value for datecol. */
+ private java.sql.Date datecol;
+
+ /** Value for timecol. */
+ private java.sql.Time timecol;
+
+ /** Value for tscol. */
+ private java.sql.Timestamp tscol;
+
+ /** Value for arrcol. */
+ private Object arrcol;
+
+ /**
+ * Empty constructor.
+ */
+ public Primitives() {
+ // No-op.
+ }
+
+ /**
+ * Full constructor.
+ */
+ public Primitives(
+ int pk,
+ boolean boolcol,
+ byte bytecol,
+ short shortcol,
+ int intcol,
+ long longcol,
+ float floatcol,
+ double doublecol,
+ double doublecol2,
+ java.math.BigDecimal bigdecimalcol,
+ String strcol,
+ java.sql.Date datecol,
+ java.sql.Time timecol,
+ java.sql.Timestamp tscol,
+ Object arrcol
+ ) {
+ this.pk = pk;
+ this.boolcol = boolcol;
+ this.bytecol = bytecol;
+ this.shortcol = shortcol;
+ this.intcol = intcol;
+ this.longcol = longcol;
+ this.floatcol = floatcol;
+ this.doublecol = doublecol;
+ this.doublecol2 = doublecol2;
+ this.bigdecimalcol = bigdecimalcol;
+ this.strcol = strcol;
+ this.datecol = datecol;
+ this.timecol = timecol;
+ this.tscol = tscol;
+ this.arrcol = arrcol;
+ }
+
+ /**
+ * Gets pk.
+ *
+ * @return Value for pk.
+ */
+ public int getPk() {
+ return pk;
+ }
+
+ /**
+ * Sets pk.
+ *
+ * @param pk New value for pk.
+ */
+ public void setPk(int pk) {
+ this.pk = pk;
+ }
+
+ /**
+ * Gets boolcol.
+ *
+ * @return Value for boolcol.
+ */
+ public boolean getBoolcol() {
+ return boolcol;
+ }
+
+ /**
+ * Sets boolcol.
+ *
+ * @param boolcol New value for boolcol.
+ */
+ public void setBoolcol(boolean boolcol) {
+ this.boolcol = boolcol;
+ }
+
+ /**
+ * Gets bytecol.
+ *
+ * @return Value for bytecol.
+ */
+ public byte getBytecol() {
+ return bytecol;
+ }
+
+ /**
+ * Sets bytecol.
+ *
+ * @param bytecol New value for bytecol.
+ */
+ public void setBytecol(byte bytecol) {
+ this.bytecol = bytecol;
+ }
+
+ /**
+ * Gets shortcol.
+ *
+ * @return Value for shortcol.
+ */
+ public short getShortcol() {
+ return shortcol;
+ }
+
+ /**
+ * Sets shortcol.
+ *
+ * @param shortcol New value for shortcol.
+ */
+ public void setShortcol(short shortcol) {
+ this.shortcol = shortcol;
+ }
+
+ /**
+ * Gets intcol.
+ *
+ * @return Value for intcol.
+ */
+ public int getIntcol() {
+ return intcol;
+ }
+
+ /**
+ * Sets intcol.
+ *
+ * @param intcol New value for intcol.
+ */
+ public void setIntcol(int intcol) {
+ this.intcol = intcol;
+ }
+
+ /**
+ * Gets longcol.
+ *
+ * @return Value for longcol.
+ */
+ public long getLongcol() {
+ return longcol;
+ }
+
+ /**
+ * Sets longcol.
+ *
+ * @param longcol New value for longcol.
+ */
+ public void setLongcol(long longcol) {
+ this.longcol = longcol;
+ }
+
+ /**
+ * Gets floatcol.
+ *
+ * @return Value for floatcol.
+ */
+ public float getFloatcol() {
+ return floatcol;
+ }
+
+ /**
+ * Sets floatcol.
+ *
+ * @param floatcol New value for floatcol.
+ */
+ public void setFloatcol(float floatcol) {
+ this.floatcol = floatcol;
+ }
+
+ /**
+ * Gets doublecol.
+ *
+ * @return Value for doublecol.
+ */
+ public double getDoublecol() {
+ return doublecol;
+ }
+
+ /**
+ * Sets doublecol.
+ *
+ * @param doublecol New value for doublecol.
+ */
+ public void setDoublecol(double doublecol) {
+ this.doublecol = doublecol;
+ }
+
+ /**
+ * Gets doublecol2.
+ *
+ * @return Value for doublecol2.
+ */
+ public double getDoublecol2() {
+ return doublecol2;
+ }
+
+ /**
+ * Sets doublecol2.
+ *
+ * @param doublecol2 New value for doublecol2.
+ */
+ public void setDoublecol2(double doublecol2) {
+ this.doublecol2 = doublecol2;
+ }
+
+ /**
+ * Gets bigdecimalcol.
+ *
+ * @return Value for bigdecimalcol.
+ */
+ public java.math.BigDecimal getBigdecimalcol() {
+ return bigdecimalcol;
+ }
+
+ /**
+ * Sets bigdecimalcol.
+ *
+ * @param bigdecimalcol New value for bigdecimalcol.
+ */
+ public void setBigdecimalcol(java.math.BigDecimal bigdecimalcol) {
+ this.bigdecimalcol = bigdecimalcol;
+ }
+
+ /**
+ * Gets strcol.
+ *
+ * @return Value for strcol.
+ */
+ public String getStrcol() {
+ return strcol;
+ }
+
+ /**
+ * Sets strcol.
+ *
+ * @param strcol New value for strcol.
+ */
+ public void setStrcol(String strcol) {
+ this.strcol = strcol;
+ }
+
+ /**
+ * Gets datecol.
+ *
+ * @return Value for datecol.
+ */
+ public java.sql.Date getDatecol() {
+ return datecol;
+ }
+
+ /**
+ * Sets datecol.
+ *
+ * @param datecol New value for datecol.
+ */
+ public void setDatecol(java.sql.Date datecol) {
+ this.datecol = datecol;
+ }
+
+ /**
+ * Gets timecol.
+ *
+ * @return Value for timecol.
+ */
+ public java.sql.Time getTimecol() {
+ return timecol;
+ }
+
+ /**
+ * Sets timecol.
+ *
+ * @param timecol New value for timecol.
+ */
+ public void setTimecol(java.sql.Time timecol) {
+ this.timecol = timecol;
+ }
+
+ /**
+ * Gets tscol.
+ *
+ * @return Value for tscol.
+ */
+ public java.sql.Timestamp getTscol() {
+ return tscol;
+ }
+
+ /**
+ * Sets tscol.
+ *
+ * @param tscol New value for tscol.
+ */
+ public void setTscol(java.sql.Timestamp tscol) {
+ this.tscol = tscol;
+ }
+
+ /**
+ * Gets arrcol.
+ *
+ * @return Value for arrcol.
+ */
+ public Object getArrcol() {
+ return arrcol;
+ }
+
+ /**
+ * Sets arrcol.
+ *
+ * @param arrcol New value for arrcol.
+ */
+ public void setArrcol(Object arrcol) {
+ this.arrcol = arrcol;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o)
+ return true;
+
+ if (!(o instanceof Primitives))
+ return false;
+
+ Primitives that = (Primitives)o;
+
+ if (pk != that.pk)
+ return false;
+
+ if (boolcol != that.boolcol)
+ return false;
+
+ if (bytecol != that.bytecol)
+ return false;
+
+ if (shortcol != that.shortcol)
+ return false;
+
+ if (intcol != that.intcol)
+ return false;
+
+ if (longcol != that.longcol)
+ return false;
+
+ if (Float.compare(floatcol, that.floatcol) != 0)
+ return false;
+
+ if (Double.compare(doublecol, that.doublecol) != 0)
+ return false;
+
+ if (Double.compare(doublecol2, that.doublecol2) != 0)
+ return false;
+
+ if (bigdecimalcol != null ? !bigdecimalcol.equals(that.bigdecimalcol) : that.bigdecimalcol != null)
+ return false;
+
+ if (strcol != null ? !strcol.equals(that.strcol) : that.strcol != null)
+ return false;
+
+ if (datecol != null ? !datecol.equals(that.datecol) : that.datecol != null)
+ return false;
+
+ if (timecol != null ? !timecol.equals(that.timecol) : that.timecol != null)
+ return false;
+
+ if (tscol != null ? !tscol.equals(that.tscol) : that.tscol != null)
+ return false;
+
+ if (arrcol != null ? !arrcol.equals(that.arrcol) : that.arrcol != null)
+ return false;
+
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ int res = pk;
+
+ res = 31 * res + (boolcol ? 1 : 0);
+
+ res = 31 * res + (int)bytecol;
+
+ res = 31 * res + (int)shortcol;
+
+ res = 31 * res + intcol;
+
+ res = 31 * res + (int)(longcol ^ (longcol >>> 32));
+
+ res = 31 * res + (floatcol != +0.0f ? Float.floatToIntBits(floatcol) : 0);
+
+ long ig_hash_temp = Double.doubleToLongBits(doublecol);
+
+ res = 31 * res + (int)(ig_hash_temp ^ (ig_hash_temp >>> 32));
+
+ ig_hash_temp = Double.doubleToLongBits(doublecol2);
+
+ res = 31 * res + (int)(ig_hash_temp ^ (ig_hash_temp >>> 32));
+
+ res = 31 * res + (bigdecimalcol != null ? bigdecimalcol.hashCode() : 0);
+
+ res = 31 * res + (strcol != null ? strcol.hashCode() : 0);
+
+ res = 31 * res + (datecol != null ? datecol.hashCode() : 0);
+
+ res = 31 * res + (timecol != null ? timecol.hashCode() : 0);
+
+ res = 31 * res + (tscol != null ? tscol.hashCode() : 0);
+
+ res = 31 * res + (arrcol != null ? arrcol.hashCode() : 0);
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return "Primitives [pk=" + pk +
+ ", boolcol=" + boolcol +
+ ", bytecol=" + bytecol +
+ ", shortcol=" + shortcol +
+ ", intcol=" + intcol +
+ ", longcol=" + longcol +
+ ", floatcol=" + floatcol +
+ ", doublecol=" + doublecol +
+ ", doublecol2=" + doublecol2 +
+ ", bigdecimalcol=" + bigdecimalcol +
+ ", strcol=" + strcol +
+ ", datecol=" + datecol +
+ ", timecol=" + timecol +
+ ", tscol=" + tscol +
+ ", arrcol=" + arrcol +
+ "]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import-ui/src/test/java/org/apache/ignite/schema/test/model/PrimitivesKey.txt
----------------------------------------------------------------------
diff --git a/modules/schema-import-ui/src/test/java/org/apache/ignite/schema/test/model/PrimitivesKey.txt b/modules/schema-import-ui/src/test/java/org/apache/ignite/schema/test/model/PrimitivesKey.txt
new file mode 100644
index 0000000..0844e63
--- /dev/null
+++ b/modules/schema-import-ui/src/test/java/org/apache/ignite/schema/test/model/PrimitivesKey.txt
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.ignite.schema.test.model;
+
+import java.io.*;
+
+/**
+ * PrimitivesKey definition.
+ *
+ * Code generated by Apache Ignite Schema Import utility: 01/27/2015.
+ */
+public class PrimitivesKey implements Serializable {
+ /** */
+ private static final long serialVersionUID = 0L;
+
+ /** Value for pk. */
+ private int pk;
+
+ /**
+ * Empty constructor.
+ */
+ public PrimitivesKey() {
+ // No-op.
+ }
+
+ /**
+ * Full constructor.
+ */
+ public PrimitivesKey(
+ int pk
+ ) {
+ this.pk = pk;
+ }
+
+ /**
+ * Gets pk.
+ *
+ * @return Value for pk.
+ */
+ public int getPk() {
+ return pk;
+ }
+
+ /**
+ * Sets pk.
+ *
+ * @param pk New value for pk.
+ */
+ public void setPk(int pk) {
+ this.pk = pk;
+ }
+
+ /** {@inheritDoc} */
+ @Override public boolean equals(Object o) {
+ if (this == o)
+ return true;
+
+ if (!(o instanceof PrimitivesKey))
+ return false;
+
+ PrimitivesKey that = (PrimitivesKey)o;
+
+ if (pk != that.pk)
+ return false;
+
+ return true;
+ }
+
+ /** {@inheritDoc} */
+ @Override public int hashCode() {
+ int res = pk;
+
+ return res;
+ }
+
+ /** {@inheritDoc} */
+ @Override public String toString() {
+ return "PrimitivesKey [pk=" + pk +
+ "]";
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import-ui/src/test/java/org/apache/ignite/schema/test/model/ignite-type-metadata.xml
----------------------------------------------------------------------
diff --git a/modules/schema-import-ui/src/test/java/org/apache/ignite/schema/test/model/ignite-type-metadata.xml b/modules/schema-import-ui/src/test/java/org/apache/ignite/schema/test/model/ignite-type-metadata.xml
new file mode 100644
index 0000000..2de9c62
--- /dev/null
+++ b/modules/schema-import-ui/src/test/java/org/apache/ignite/schema/test/model/ignite-type-metadata.xml
@@ -0,0 +1,362 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+-->
+
+<!--
+ XML generated by Apache Ignite Schema Import utility: 02/05/2015
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:util="http://www.springframework.org/schema/util"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans
+ http://www.springframework.org/schema/beans/spring-beans.xsd
+ http://www.springframework.org/schema/util
+ http://www.springframework.org/schema/util/spring-util.xsd">
+ <bean class="org.apache.ignite.cache.CacheTypeMetadata">
+ <property name="databaseSchema" value="PUBLIC"/>
+ <property name="databaseTable" value="OBJECTS"/>
+ <property name="keyType" value="org.apache.ignite.schema.test.model.ObjectsKey"/>
+ <property name="valueType" value="org.apache.ignite.schema.test.model.Objects"/>
+ <property name="keyFields">
+ <list>
+ <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
+ <property name="databaseName" value="PK"/>
+ <property name="databaseType">
+ <util:constant static-field="java.sql.Types.INTEGER"/>
+ </property>
+ <property name="javaName" value="pk"/>
+ <property name="javaType" value="int"/>
+ </bean>
+ </list>
+ </property>
+ <property name="valueFields">
+ <list>
+ <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
+ <property name="databaseName" value="PK"/>
+ <property name="databaseType">
+ <util:constant static-field="java.sql.Types.INTEGER"/>
+ </property>
+ <property name="javaName" value="pk"/>
+ <property name="javaType" value="int"/>
+ </bean>
+ <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
+ <property name="databaseName" value="BOOLCOL"/>
+ <property name="databaseType">
+ <util:constant static-field="java.sql.Types.BOOLEAN"/>
+ </property>
+ <property name="javaName" value="boolcol"/>
+ <property name="javaType" value="java.lang.Boolean"/>
+ </bean>
+ <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
+ <property name="databaseName" value="BYTECOL"/>
+ <property name="databaseType">
+ <util:constant static-field="java.sql.Types.TINYINT"/>
+ </property>
+ <property name="javaName" value="bytecol"/>
+ <property name="javaType" value="java.lang.Byte"/>
+ </bean>
+ <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
+ <property name="databaseName" value="SHORTCOL"/>
+ <property name="databaseType">
+ <util:constant static-field="java.sql.Types.SMALLINT"/>
+ </property>
+ <property name="javaName" value="shortcol"/>
+ <property name="javaType" value="java.lang.Short"/>
+ </bean>
+ <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
+ <property name="databaseName" value="INTCOL"/>
+ <property name="databaseType">
+ <util:constant static-field="java.sql.Types.INTEGER"/>
+ </property>
+ <property name="javaName" value="intcol"/>
+ <property name="javaType" value="java.lang.Integer"/>
+ </bean>
+ <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
+ <property name="databaseName" value="LONGCOL"/>
+ <property name="databaseType">
+ <util:constant static-field="java.sql.Types.BIGINT"/>
+ </property>
+ <property name="javaName" value="longcol"/>
+ <property name="javaType" value="java.lang.Long"/>
+ </bean>
+ <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
+ <property name="databaseName" value="FLOATCOL"/>
+ <property name="databaseType">
+ <util:constant static-field="java.sql.Types.REAL"/>
+ </property>
+ <property name="javaName" value="floatcol"/>
+ <property name="javaType" value="java.lang.Float"/>
+ </bean>
+ <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
+ <property name="databaseName" value="DOUBLECOL"/>
+ <property name="databaseType">
+ <util:constant static-field="java.sql.Types.DOUBLE"/>
+ </property>
+ <property name="javaName" value="doublecol"/>
+ <property name="javaType" value="java.lang.Double"/>
+ </bean>
+ <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
+ <property name="databaseName" value="DOUBLECOL2"/>
+ <property name="databaseType">
+ <util:constant static-field="java.sql.Types.DOUBLE"/>
+ </property>
+ <property name="javaName" value="doublecol2"/>
+ <property name="javaType" value="java.lang.Double"/>
+ </bean>
+ <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
+ <property name="databaseName" value="BIGDECIMALCOL"/>
+ <property name="databaseType">
+ <util:constant static-field="java.sql.Types.DECIMAL"/>
+ </property>
+ <property name="javaName" value="bigdecimalcol"/>
+ <property name="javaType" value="java.math.BigDecimal"/>
+ </bean>
+ <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
+ <property name="databaseName" value="STRCOL"/>
+ <property name="databaseType">
+ <util:constant static-field="java.sql.Types.VARCHAR"/>
+ </property>
+ <property name="javaName" value="strcol"/>
+ <property name="javaType" value="java.lang.String"/>
+ </bean>
+ <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
+ <property name="databaseName" value="DATECOL"/>
+ <property name="databaseType">
+ <util:constant static-field="java.sql.Types.DATE"/>
+ </property>
+ <property name="javaName" value="datecol"/>
+ <property name="javaType" value="java.sql.Date"/>
+ </bean>
+ <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
+ <property name="databaseName" value="TIMECOL"/>
+ <property name="databaseType">
+ <util:constant static-field="java.sql.Types.TIME"/>
+ </property>
+ <property name="javaName" value="timecol"/>
+ <property name="javaType" value="java.sql.Time"/>
+ </bean>
+ <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
+ <property name="databaseName" value="TSCOL"/>
+ <property name="databaseType">
+ <util:constant static-field="java.sql.Types.TIMESTAMP"/>
+ </property>
+ <property name="javaName" value="tscol"/>
+ <property name="javaType" value="java.sql.Timestamp"/>
+ </bean>
+ <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
+ <property name="databaseName" value="ARRCOL"/>
+ <property name="databaseType">
+ <util:constant static-field="java.sql.Types.VARBINARY"/>
+ </property>
+ <property name="javaName" value="arrcol"/>
+ <property name="javaType" value="java.lang.Object"/>
+ </bean>
+ </list>
+ </property>
+ <property name="queryFields">
+ <map>
+ <entry key="pk" value="int"/>
+ <entry key="boolcol" value="java.lang.Boolean"/>
+ <entry key="bytecol" value="java.lang.Byte"/>
+ <entry key="shortcol" value="java.lang.Short"/>
+ <entry key="intcol" value="java.lang.Integer"/>
+ <entry key="longcol" value="java.lang.Long"/>
+ <entry key="floatcol" value="java.lang.Float"/>
+ <entry key="doublecol" value="java.lang.Double"/>
+ <entry key="doublecol2" value="java.lang.Double"/>
+ <entry key="bigdecimalcol" value="java.math.BigDecimal"/>
+ <entry key="strcol" value="java.lang.String"/>
+ <entry key="datecol" value="java.sql.Date"/>
+ <entry key="timecol" value="java.sql.Time"/>
+ <entry key="tscol" value="java.sql.Timestamp"/>
+ <entry key="arrcol" value="java.lang.Object"/>
+ </map>
+ </property>
+ <property name="ascendingFields">
+ <map>
+ <entry key="pk" value="int"/>
+ </map>
+ </property>
+ </bean>
+ <bean class="org.apache.ignite.cache.CacheTypeMetadata">
+ <property name="databaseSchema" value="PUBLIC"/>
+ <property name="databaseTable" value="PRIMITIVES"/>
+ <property name="keyType" value="org.apache.ignite.schema.test.model.PrimitivesKey"/>
+ <property name="valueType" value="org.apache.ignite.schema.test.model.Primitives"/>
+ <property name="keyFields">
+ <list>
+ <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
+ <property name="databaseName" value="PK"/>
+ <property name="databaseType">
+ <util:constant static-field="java.sql.Types.INTEGER"/>
+ </property>
+ <property name="javaName" value="pk"/>
+ <property name="javaType" value="int"/>
+ </bean>
+ </list>
+ </property>
+ <property name="valueFields">
+ <list>
+ <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
+ <property name="databaseName" value="PK"/>
+ <property name="databaseType">
+ <util:constant static-field="java.sql.Types.INTEGER"/>
+ </property>
+ <property name="javaName" value="pk"/>
+ <property name="javaType" value="int"/>
+ </bean>
+ <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
+ <property name="databaseName" value="BOOLCOL"/>
+ <property name="databaseType">
+ <util:constant static-field="java.sql.Types.BOOLEAN"/>
+ </property>
+ <property name="javaName" value="boolcol"/>
+ <property name="javaType" value="boolean"/>
+ </bean>
+ <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
+ <property name="databaseName" value="BYTECOL"/>
+ <property name="databaseType">
+ <util:constant static-field="java.sql.Types.TINYINT"/>
+ </property>
+ <property name="javaName" value="bytecol"/>
+ <property name="javaType" value="byte"/>
+ </bean>
+ <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
+ <property name="databaseName" value="SHORTCOL"/>
+ <property name="databaseType">
+ <util:constant static-field="java.sql.Types.SMALLINT"/>
+ </property>
+ <property name="javaName" value="shortcol"/>
+ <property name="javaType" value="short"/>
+ </bean>
+ <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
+ <property name="databaseName" value="INTCOL"/>
+ <property name="databaseType">
+ <util:constant static-field="java.sql.Types.INTEGER"/>
+ </property>
+ <property name="javaName" value="intcol"/>
+ <property name="javaType" value="int"/>
+ </bean>
+ <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
+ <property name="databaseName" value="LONGCOL"/>
+ <property name="databaseType">
+ <util:constant static-field="java.sql.Types.BIGINT"/>
+ </property>
+ <property name="javaName" value="longcol"/>
+ <property name="javaType" value="long"/>
+ </bean>
+ <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
+ <property name="databaseName" value="FLOATCOL"/>
+ <property name="databaseType">
+ <util:constant static-field="java.sql.Types.REAL"/>
+ </property>
+ <property name="javaName" value="floatcol"/>
+ <property name="javaType" value="float"/>
+ </bean>
+ <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
+ <property name="databaseName" value="DOUBLECOL"/>
+ <property name="databaseType">
+ <util:constant static-field="java.sql.Types.DOUBLE"/>
+ </property>
+ <property name="javaName" value="doublecol"/>
+ <property name="javaType" value="double"/>
+ </bean>
+ <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
+ <property name="databaseName" value="DOUBLECOL2"/>
+ <property name="databaseType">
+ <util:constant static-field="java.sql.Types.DOUBLE"/>
+ </property>
+ <property name="javaName" value="doublecol2"/>
+ <property name="javaType" value="double"/>
+ </bean>
+ <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
+ <property name="databaseName" value="BIGDECIMALCOL"/>
+ <property name="databaseType">
+ <util:constant static-field="java.sql.Types.DECIMAL"/>
+ </property>
+ <property name="javaName" value="bigdecimalcol"/>
+ <property name="javaType" value="java.math.BigDecimal"/>
+ </bean>
+ <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
+ <property name="databaseName" value="STRCOL"/>
+ <property name="databaseType">
+ <util:constant static-field="java.sql.Types.VARCHAR"/>
+ </property>
+ <property name="javaName" value="strcol"/>
+ <property name="javaType" value="java.lang.String"/>
+ </bean>
+ <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
+ <property name="databaseName" value="DATECOL"/>
+ <property name="databaseType">
+ <util:constant static-field="java.sql.Types.DATE"/>
+ </property>
+ <property name="javaName" value="datecol"/>
+ <property name="javaType" value="java.sql.Date"/>
+ </bean>
+ <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
+ <property name="databaseName" value="TIMECOL"/>
+ <property name="databaseType">
+ <util:constant static-field="java.sql.Types.TIME"/>
+ </property>
+ <property name="javaName" value="timecol"/>
+ <property name="javaType" value="java.sql.Time"/>
+ </bean>
+ <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
+ <property name="databaseName" value="TSCOL"/>
+ <property name="databaseType">
+ <util:constant static-field="java.sql.Types.TIMESTAMP"/>
+ </property>
+ <property name="javaName" value="tscol"/>
+ <property name="javaType" value="java.sql.Timestamp"/>
+ </bean>
+ <bean class="org.apache.ignite.cache.CacheTypeFieldMetadata">
+ <property name="databaseName" value="ARRCOL"/>
+ <property name="databaseType">
+ <util:constant static-field="java.sql.Types.VARBINARY"/>
+ </property>
+ <property name="javaName" value="arrcol"/>
+ <property name="javaType" value="java.lang.Object"/>
+ </bean>
+ </list>
+ </property>
+ <property name="queryFields">
+ <map>
+ <entry key="pk" value="int"/>
+ <entry key="boolcol" value="boolean"/>
+ <entry key="bytecol" value="byte"/>
+ <entry key="shortcol" value="short"/>
+ <entry key="intcol" value="int"/>
+ <entry key="longcol" value="long"/>
+ <entry key="floatcol" value="float"/>
+ <entry key="doublecol" value="double"/>
+ <entry key="doublecol2" value="double"/>
+ <entry key="bigdecimalcol" value="java.math.BigDecimal"/>
+ <entry key="strcol" value="java.lang.String"/>
+ <entry key="datecol" value="java.sql.Date"/>
+ <entry key="timecol" value="java.sql.Time"/>
+ <entry key="tscol" value="java.sql.Timestamp"/>
+ <entry key="arrcol" value="java.lang.Object"/>
+ </map>
+ </property>
+ <property name="ascendingFields">
+ <map>
+ <entry key="pk" value="int"/>
+ </map>
+ </property>
+ </bean>
+</beans>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import-ui/src/test/java/org/apache/ignite/schema/test/parser/DbMetadataParserTest.java
----------------------------------------------------------------------
diff --git a/modules/schema-import-ui/src/test/java/org/apache/ignite/schema/test/parser/DbMetadataParserTest.java b/modules/schema-import-ui/src/test/java/org/apache/ignite/schema/test/parser/DbMetadataParserTest.java
new file mode 100644
index 0000000..9fc12e7
--- /dev/null
+++ b/modules/schema-import-ui/src/test/java/org/apache/ignite/schema/test/parser/DbMetadataParserTest.java
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.ignite.schema.test.parser;
+
+import org.apache.ignite.schema.model.*;
+import org.apache.ignite.schema.test.*;
+
+import java.math.*;
+import java.sql.Date;
+import java.sql.*;
+import java.util.*;
+
+/**
+ * Tests for metadata parsing.
+ */
+public class DbMetadataParserTest extends AbstractSchemaImportTest {
+ /**
+ * Check that field is correspond to expected.
+ *
+ * @param field Field descriptor.
+ * @param name Expected field name.
+ * @param primitive Expected field primitive type.
+ * @param cls Expected field type.
+ */
+ private void checkField(PojoField field, String name, boolean primitive, Class<?> cls) {
+ assertEquals("Name of field should be " + name, name, field.javaName());
+
+ assertEquals("Type of field should be " + cls.getName(), cls.getName(), field.javaTypeName());
+
+ assertEquals("Field primitive should be " + primitive, primitive, field.primitive());
+ }
+
+ /**
+ * Check that type is correspond to expected.
+ *
+ * @param type Type descriptor.
+ */
+ private void checkType(PojoDescriptor type) {
+ assertFalse("Type key class name should be defined", type.keyClassName().isEmpty());
+
+ assertFalse("Type value class name should be defined", type.valueClassName().isEmpty());
+
+ Collection<PojoField> keyFields = type.keyFields();
+
+ assertEquals("Key type should have 1 field", 1, keyFields.size());
+
+ checkField(keyFields.iterator().next(), "pk", true, int.class);
+
+ List<PojoField> fields = type.fields();
+
+ assertEquals("Value type should have 15 fields", 15, fields.size());
+
+ Iterator<PojoField> fieldsIt = fields.iterator();
+
+ checkField(fieldsIt.next(), "pk", true, int.class);
+
+ if ("Objects".equals(type.valueClassName())) {
+ checkField(fieldsIt.next(), "boolcol", false, Boolean.class);
+ checkField(fieldsIt.next(), "bytecol", false, Byte.class);
+ checkField(fieldsIt.next(), "shortcol", false, Short.class);
+ checkField(fieldsIt.next(), "intcol", false, Integer.class);
+ checkField(fieldsIt.next(), "longcol", false, Long.class);
+ checkField(fieldsIt.next(), "floatcol", false, Float.class);
+ checkField(fieldsIt.next(), "doublecol", false, Double.class);
+ checkField(fieldsIt.next(), "doublecol2", false, Double.class);
+ }
+ else {
+ checkField(fieldsIt.next(), "boolcol", true, boolean.class);
+ checkField(fieldsIt.next(), "bytecol", true, byte.class);
+ checkField(fieldsIt.next(), "shortcol", true, short.class);
+ checkField(fieldsIt.next(), "intcol", true, int.class);
+ checkField(fieldsIt.next(), "longcol", true, long.class);
+ checkField(fieldsIt.next(), "floatcol", true, float.class);
+ checkField(fieldsIt.next(), "doublecol", true, double.class);
+ checkField(fieldsIt.next(), "doublecol2", true, double.class);
+ }
+
+ checkField(fieldsIt.next(), "bigdecimalcol", false, BigDecimal.class);
+ checkField(fieldsIt.next(), "strcol", false, String.class);
+ checkField(fieldsIt.next(), "datecol", false, Date.class);
+ checkField(fieldsIt.next(), "timecol", false, Time.class);
+ checkField(fieldsIt.next(), "tscol", false, Timestamp.class);
+ checkField(fieldsIt.next(), "arrcol", false, Object.class);
+ }
+
+ /**
+ * Test that metadata generated correctly.
+ */
+ public void testCheckMetadata() {
+ assertEquals("Metadata should contain 3 element", 3, pojos.size());
+
+ Iterator<PojoDescriptor> it = pojos.iterator();
+
+ PojoDescriptor schema = it.next();
+
+ assertTrue("First element is schema description. Its class name should be empty",
+ schema.valueClassName().isEmpty());
+
+ checkType(it.next());
+
+ checkType(it.next());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import-ui/src/test/java/org/apache/ignite/schema/test/testsuites/IgniteSchemaImportTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/schema-import-ui/src/test/java/org/apache/ignite/schema/test/testsuites/IgniteSchemaImportTestSuite.java b/modules/schema-import-ui/src/test/java/org/apache/ignite/schema/test/testsuites/IgniteSchemaImportTestSuite.java
new file mode 100644
index 0000000..571264e
--- /dev/null
+++ b/modules/schema-import-ui/src/test/java/org/apache/ignite/schema/test/testsuites/IgniteSchemaImportTestSuite.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.ignite.schema.test.testsuites;
+
+import junit.framework.*;
+import org.apache.ignite.schema.test.generator.*;
+import org.apache.ignite.schema.test.parser.*;
+
+/**
+ * Ignite Schema Import Utility Tests.
+ */
+public class IgniteSchemaImportTestSuite {
+ /**
+ * @return Test suite.
+ * @throws Exception Thrown in case of the failure.
+ */
+ public static TestSuite suite() throws Exception {
+ TestSuite suite = new TestSuite("Ignite Apache Schema Import Utility Test Suite");
+
+ suite.addTestSuite(CodeGeneratorTest.class);
+ suite.addTestSuite(XmlGeneratorTest.class);
+ suite.addTestSuite(DbMetadataParserTest.class);
+
+ return suite;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import/pom.xml
----------------------------------------------------------------------
diff --git a/modules/schema-import/pom.xml b/modules/schema-import/pom.xml
index 7364e1e..9eb7971 100644
--- a/modules/schema-import/pom.xml
+++ b/modules/schema-import/pom.xml
@@ -66,39 +66,5 @@
</excludes>
</testResource>
</testResources>
-
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <configuration>
- <archive>
- <manifest>
- <mainClass>org.apache.ignite.schema.ui.SchemaImportApp</mainClass>
- </manifest>
- </archive>
- </configuration>
- </plugin>
- </plugins>
</build>
-
- <profiles>
- <profile>
- <id>schema-import</id>
- <activation>
- <file>
- <exists>${java.home}/lib/jfxrt.jar</exists>
- </file>
- </activation>
- <dependencies>
- <dependency>
- <groupId>javafx</groupId>
- <artifactId>jfxrt</artifactId>
- <version>${java.version}</version>
- <scope>system</scope>
- <systemPath>${java.home}/lib/jfxrt.jar</systemPath>
- </dependency>
- </dependencies>
- </profile>
- </profiles>
</project>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import/src/main/java/media/data_connection_48x48.png
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/media/data_connection_48x48.png b/modules/schema-import/src/main/java/media/data_connection_48x48.png
deleted file mode 100644
index 475f219..0000000
Binary files a/modules/schema-import/src/main/java/media/data_connection_48x48.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import/src/main/java/media/error_48x48.png
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/media/error_48x48.png b/modules/schema-import/src/main/java/media/error_48x48.png
deleted file mode 100644
index e341b8a..0000000
Binary files a/modules/schema-import/src/main/java/media/error_48x48.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import/src/main/java/media/ignite_128x128.png
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/media/ignite_128x128.png b/modules/schema-import/src/main/java/media/ignite_128x128.png
deleted file mode 100644
index d99a83c..0000000
Binary files a/modules/schema-import/src/main/java/media/ignite_128x128.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import/src/main/java/media/ignite_16x16.png
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/media/ignite_16x16.png b/modules/schema-import/src/main/java/media/ignite_16x16.png
deleted file mode 100644
index 3e07d33..0000000
Binary files a/modules/schema-import/src/main/java/media/ignite_16x16.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import/src/main/java/media/ignite_24x24.png
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/media/ignite_24x24.png b/modules/schema-import/src/main/java/media/ignite_24x24.png
deleted file mode 100644
index 8da5c97..0000000
Binary files a/modules/schema-import/src/main/java/media/ignite_24x24.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import/src/main/java/media/ignite_32x32.png
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/media/ignite_32x32.png b/modules/schema-import/src/main/java/media/ignite_32x32.png
deleted file mode 100644
index c6c6819..0000000
Binary files a/modules/schema-import/src/main/java/media/ignite_32x32.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import/src/main/java/media/ignite_48x48.png
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/media/ignite_48x48.png b/modules/schema-import/src/main/java/media/ignite_48x48.png
deleted file mode 100644
index 5b684cc..0000000
Binary files a/modules/schema-import/src/main/java/media/ignite_48x48.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import/src/main/java/media/ignite_64x64.png
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/media/ignite_64x64.png b/modules/schema-import/src/main/java/media/ignite_64x64.png
deleted file mode 100644
index c1d348b..0000000
Binary files a/modules/schema-import/src/main/java/media/ignite_64x64.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import/src/main/java/media/information_48x48.png
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/media/information_48x48.png b/modules/schema-import/src/main/java/media/information_48x48.png
deleted file mode 100644
index 8712a1b..0000000
Binary files a/modules/schema-import/src/main/java/media/information_48x48.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import/src/main/java/media/question_48x48.png
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/media/question_48x48.png b/modules/schema-import/src/main/java/media/question_48x48.png
deleted file mode 100644
index 84683f9..0000000
Binary files a/modules/schema-import/src/main/java/media/question_48x48.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import/src/main/java/media/sign_warning_48x48.png
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/media/sign_warning_48x48.png b/modules/schema-import/src/main/java/media/sign_warning_48x48.png
deleted file mode 100644
index 5e7cccd..0000000
Binary files a/modules/schema-import/src/main/java/media/sign_warning_48x48.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import/src/main/java/media/style.css
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/media/style.css b/modules/schema-import/src/main/java/media/style.css
deleted file mode 100644
index 6eee5f9..0000000
--- a/modules/schema-import/src/main/java/media/style.css
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-
-.root {
- -fx-background-color: eeeeee;
-}
-
-.button {
- -fx-font-size: 14;
- -fx-focus-color: gray;
-}
-
-.label {
- -fx-font-size: 14;
-}
-
-.check-box {
- -fx-font-size: 14;
- -fx-focus-color: gray;
-}
-
-.combo-box-base {
- -fx-font-size: 14;
- -fx-focus-color: gray;
-}
-
-.combo-box-popup .list-view {
- -fx-font-size : 14;
-}
-
-.text-area {
- -fx-font-size: 14;
- -fx-background-color: transparent, transparent, transparent;
-}
-
-.text-area .scroll-pane {
- -fx-background-color: transparent;
-}
-
-.text-area .scroll-pane .viewport{
- -fx-background-color: transparent;
-}
-
-.text-area .scroll-pane .content{
- -fx-background-color: transparent;
-}
-
-.text-area .scroll-bar:vertical:disabled {
- -fx-opacity: 0;
-}
-
-.text-field {
- -fx-font-size: 14;
- -fx-background-color: -fx-text-box-border, -fx-control-inner-background, -fx-control-inner-background;
-}
-
-.text-field:focused {
- -fx-background-color: -fx-text-box-border, -fx-control-inner-background, -fx-control-inner-background;
-}
-
-.table-view {
- -fx-focus-color: gray;
- -fx-font-size: 14;
-}
-
-.table-view .table-row-cell:selected {
- -fx-background-color: -fx-table-cell-border-color, -fx-cell-hover-color;
- -fx-background-insets: 0, 0 0 1 0;
-}
-
-.table-view:focused .table-row-cell:selected {
- -fx-background-color: -fx-focus-color, -fx-cell-focus-inner-border, -fx-selection-bar;
-}
-
-.table-row-cell:empty {
- -fx-background-color: white;
-}
-
-.table-row-cell:empty .table-cell {
- -fx-border-width: 0px;
-}
-
-.tooltip {
- -fx-font-size: 14;
- -fx-background-radius: 0 0 0 0;
-}
-
-.page-corner {
- -fx-shape: " ";
-}
-
-.progress-indicator {
- -fx-progress-color: gray
-}
-
-.split-pane {
- -fx-background-color: -fx-box-border, eeeeee;
-}
-
-.titled-pane {
- -fx-font-size: 14;
-}
-
-.titled-pane:focused {
- -fx-text-fill: -fx-text-base-color;
-}
-
-.titled-pane:focused > .title {
- -fx-color: eeeeee;
-}
-
-.titled-pane:focused > .title > .arrow-button .arrow {
- -fx-background-color: black;
-}
-
-#banner {
- -fx-font-size: 20px;
- -fx-font-weight: bold;
- -fx-background-color: white
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import/src/main/java/media/text_tree_48x48.png
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/media/text_tree_48x48.png b/modules/schema-import/src/main/java/media/text_tree_48x48.png
deleted file mode 100644
index 6ca9e65..0000000
Binary files a/modules/schema-import/src/main/java/media/text_tree_48x48.png and /dev/null differ
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/CodeGenerator.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/CodeGenerator.java b/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/CodeGenerator.java
index b92d84b..66b45cc 100644
--- a/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/CodeGenerator.java
+++ b/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/CodeGenerator.java
@@ -18,14 +18,13 @@
package org.apache.ignite.schema.generator;
import org.apache.ignite.schema.model.*;
-import org.apache.ignite.schema.ui.*;
import java.io.*;
import java.text.*;
import java.util.*;
import java.util.regex.*;
-import static org.apache.ignite.schema.ui.MessageBox.Result.*;
+import static org.apache.ignite.schema.generator.ConfirmOverride.Result.*;
/**
* Code generator of POJOs for key and value classes and configuration snippet.
@@ -259,7 +258,7 @@ public class CodeGenerator {
* @throws IOException If failed to write generated code into file.
*/
private static void generateCode(PojoDescriptor pojo, boolean key, String pkg, File pkgFolder,
- boolean constructor, boolean includeKeys, ConfirmCallable askOverwrite) throws IOException {
+ boolean constructor, boolean includeKeys, ConfirmOverride askOverwrite) throws IOException {
String type = key ? pojo.keyClassName() : pojo.valueClassName();
File out = new File(pkgFolder, type + ".java");
@@ -268,12 +267,12 @@ public class CodeGenerator {
checkValidJavaIdentifier(type, false, "Type", type);
if (out.exists()) {
- MessageBox.Result choice = askOverwrite.confirm(out.getName());
+ ConfirmOverride.Result choice = askOverwrite.confirm(out.getName());
if (CANCEL == choice)
throw new IllegalStateException("POJO generation was canceled!");
- if (NO == choice || NO_TO_ALL == choice)
+ if (NO == choice)
return;
}
@@ -510,7 +509,7 @@ public class CodeGenerator {
* @throws IOException If failed to write generated code into file.
*/
public static void pojos(PojoDescriptor pojo, String outFolder, String pkg, boolean constructor,
- boolean includeKeys, ConfirmCallable askOverwrite) throws IOException {
+ boolean includeKeys, ConfirmOverride askOverwrite) throws IOException {
File pkgFolder = new File(outFolder, pkg.replace('.', File.separatorChar));
if (!pkgFolder.exists() && !pkgFolder.mkdirs())
@@ -582,18 +581,18 @@ public class CodeGenerator {
* @throws IOException If generation failed.
*/
public static void snippet(Collection<PojoDescriptor> pojos, String pkg, boolean includeKeys,
- String outFolder, ConfirmCallable askOverwrite) throws IOException {
+ String outFolder, ConfirmOverride askOverwrite) throws IOException {
File pkgFolder = new File(outFolder, pkg.replace('.', File.separatorChar));
File cacheCfg = new File(pkgFolder, "CacheConfig.java");
if (cacheCfg.exists()) {
- MessageBox.Result choice = askOverwrite.confirm(cacheCfg.getName());
+ ConfirmOverride.Result choice = askOverwrite.confirm(cacheCfg.getName());
if (CANCEL == choice)
throw new IllegalStateException("Java snippet generation was canceled!");
- if (NO == choice || NO_TO_ALL == choice)
+ if (NO == choice)
return;
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/ConfirmOverride.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/ConfirmOverride.java b/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/ConfirmOverride.java
new file mode 100644
index 0000000..5e56a0f
--- /dev/null
+++ b/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/ConfirmOverride.java
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.ignite.schema.generator;
+
+/**
+ *
+ */
+public interface ConfirmOverride {
+ /**
+ * @param msg Message.
+ */
+ public Result confirm(String msg);
+
+ /**
+ *
+ */
+ enum Result {
+ /** */
+ OVERRIDE,
+
+ /** */
+ CANCEL,
+
+ /** */
+ NO
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/XmlGenerator.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/XmlGenerator.java b/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/XmlGenerator.java
index 6ab04dd..48513db 100644
--- a/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/XmlGenerator.java
+++ b/modules/schema-import/src/main/java/org/apache/ignite/schema/generator/XmlGenerator.java
@@ -20,7 +20,6 @@ package org.apache.ignite.schema.generator;
import org.apache.ignite.cache.*;
import org.apache.ignite.lang.*;
import org.apache.ignite.schema.model.*;
-import org.apache.ignite.schema.ui.*;
import org.w3c.dom.*;
import javax.xml.parsers.*;
@@ -32,8 +31,6 @@ import java.nio.file.*;
import java.text.*;
import java.util.*;
-import static org.apache.ignite.schema.ui.MessageBox.Result.*;
-
/**
* Generator of XML files for type metadata.
*/
@@ -263,7 +260,7 @@ public class XmlGenerator {
* @param askOverwrite Callback to ask user to confirm file overwrite.
*/
public static void generate(String pkg, PojoDescriptor pojo, boolean includeKeys, File out,
- ConfirmCallable askOverwrite) {
+ ConfirmOverride askOverwrite) {
generate(pkg, Collections.singleton(pojo), includeKeys, out, askOverwrite);
}
@@ -276,7 +273,7 @@ public class XmlGenerator {
* @param askOverwrite Callback to ask user to confirm file overwrite.
*/
public static void generate(String pkg, Collection<PojoDescriptor> pojos, boolean includeKeys, File out,
- ConfirmCallable askOverwrite) {
+ ConfirmOverride askOverwrite) {
File outFolder = out.getParentFile();
@@ -288,12 +285,12 @@ public class XmlGenerator {
try {
if (out.exists()) {
- MessageBox.Result choice = askOverwrite.confirm(out.getName());
+ ConfirmOverride.Result choice = askOverwrite.confirm(out.getName());
- if (CANCEL == choice)
+ if (ConfirmOverride.Result.CANCEL == choice)
throw new IllegalStateException("XML generation was canceled!");
- if (NO == choice || NO_TO_ALL == choice)
+ if (ConfirmOverride.Result.NO == choice)
return;
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import/src/main/java/org/apache/ignite/schema/model/PojoDescriptor.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/model/PojoDescriptor.java b/modules/schema-import/src/main/java/org/apache/ignite/schema/model/PojoDescriptor.java
index 5e1da06..1c5d059 100644
--- a/modules/schema-import/src/main/java/org/apache/ignite/schema/model/PojoDescriptor.java
+++ b/modules/schema-import/src/main/java/org/apache/ignite/schema/model/PojoDescriptor.java
@@ -17,10 +17,8 @@
package org.apache.ignite.schema.model;
-import javafx.beans.property.*;
-import javafx.beans.value.*;
-import javafx.collections.*;
import org.apache.ignite.schema.parser.*;
+import org.apache.ignite.schema.utils.*;
import java.math.*;
import java.util.*;
@@ -35,19 +33,19 @@ public class PojoDescriptor {
private final DbTable tbl;
/** Selected property. */
- private final BooleanProperty useProp;
+ private final Property<Boolean> useProp;
/** Previous name for key class. */
private final String keyClsNamePrev;
/** Key class name to show on screen. */
- private final StringProperty keyClsNameProp;
+ private final Property<String> keyClsNameProp;
/** Previous name for value class. */
private final String valClsNamePrev;
/** Value class name to show on screen. */
- private final StringProperty valClsNameProp;
+ private final Property<String> valClsNameProp;
/** Parent item (schema name). */
private final PojoDescriptor parent;
@@ -56,13 +54,13 @@ public class PojoDescriptor {
private Collection<PojoDescriptor> children = Collections.emptyList();
/** Indeterminate state of parent. */
- private final BooleanProperty indeterminateProp = new SimpleBooleanProperty(false);
+ private final Property<Boolean> indeterminateProp = new Property<>(false);
/** Full database name: schema + table. */
private final String fullDbName;
/** Java class fields. */
- private final ObservableList<PojoField> fields;
+ private final List<PojoField> fields;
/** Fields map for quick access. */
private final Map<String, PojoField> fieldsMap;
@@ -81,10 +79,10 @@ public class PojoDescriptor {
fullDbName = tbl.schema() + "." + tbl.table();
valClsNamePrev = toJavaClassName(tbl.table());
- valClsNameProp = new SimpleStringProperty(valClsNamePrev);
+ valClsNameProp = new Property<>(valClsNamePrev);
keyClsNamePrev = valClsNamePrev.isEmpty() ? "" : valClsNamePrev + "Key";
- keyClsNameProp = new SimpleStringProperty(keyClsNamePrev);
+ keyClsNameProp = new Property<>(keyClsNamePrev);
Collection<DbColumn> cols = tbl.columns();
@@ -106,19 +104,19 @@ public class PojoDescriptor {
fieldsMap.put(colName, fld);
}
- fields = FXCollections.observableList(flds);
+ fields = flds;
boolean isTbl = parent != null;
boolean hasKeys = !isTbl || !keyFields().isEmpty();
- useProp = new SimpleBooleanProperty(hasKeys);
+ useProp = new Property<>(hasKeys);
if (isTbl && !hasKeys && !parent.indeterminateProp.get())
parent.indeterminateProp.set(true);
useProp.addListener(new ChangeListener<Boolean>() {
- @Override public void changed(ObservableValue<? extends Boolean> val, Boolean oldVal, Boolean newVal) {
+ @Override public void changed(Property<? extends Boolean> val, Boolean oldVal, Boolean newVal) {
for (PojoDescriptor child : children)
child.useProp.set(newVal);
@@ -169,14 +167,14 @@ public class PojoDescriptor {
/**
* @return Boolean property support for {@code use} property.
*/
- public BooleanProperty useProperty() {
+ public Property<Boolean> useProperty() {
return useProp;
}
/**
* @return Boolean property support for parent {@code indeterminate} property.
*/
- public BooleanProperty indeterminate() {
+ public Property<Boolean> indeterminate() {
return indeterminateProp;
}
@@ -336,14 +334,14 @@ public class PojoDescriptor {
/**
* @return Key class name property.
*/
- public StringProperty keyClassNameProperty() {
+ public Property<String> keyClassNameProperty() {
return keyClsNameProp;
}
/**
* @return Value class name property.
*/
- public StringProperty valueClassNameProperty() {
+ public Property<String> valueClassNameProperty() {
return valClsNameProp;
}
@@ -409,7 +407,7 @@ public class PojoDescriptor {
/**
* @return Java class fields.
*/
- public ObservableList<PojoField> fields() {
+ public List<PojoField> fields() {
return fields;
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import/src/main/java/org/apache/ignite/schema/model/PojoField.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/model/PojoField.java b/modules/schema-import/src/main/java/org/apache/ignite/schema/model/PojoField.java
index 88e4008..48b520f 100644
--- a/modules/schema-import/src/main/java/org/apache/ignite/schema/model/PojoField.java
+++ b/modules/schema-import/src/main/java/org/apache/ignite/schema/model/PojoField.java
@@ -17,9 +17,7 @@
package org.apache.ignite.schema.model;
-import javafx.beans.property.*;
-import javafx.beans.value.*;
-import javafx.collections.*;
+import org.apache.ignite.schema.utils.*;
import java.math.*;
import java.util.*;
@@ -31,31 +29,31 @@ import static java.sql.Types.*;
*/
public class PojoField {
/** If this field should be used for code generation. */
- private final BooleanProperty useProp;
+ private final Property<Boolean> useProp;
/** If this field belongs to primary key. */
- private final BooleanProperty keyProp;
+ private final Property<Boolean> keyProp;
/** If this field is an affinity key. */
- private final BooleanProperty akProp;
+ private final Property<Boolean> akProp;
/** If this field initially belongs to primary key. */
private final boolean keyPrev;
/** Field name in database. */
- private final StringProperty dbNameProp;
+ private final Property<String> dbNameProp;
/** Field type in database. */
- private final StringProperty dbTypeNameProp;
+ private final Property<String> dbTypeNameProp;
/** Field name in POJO. */
- private final StringProperty javaNameProp;
+ private final Property<String> javaNameProp;
/** Initial field name in POJO. */
private final String javaNamePrev;
/** Field type in POJO. */
- private final StringProperty javaTypeNameProp;
+ private final Property<String> javaTypeNameProp;
/** Initial field type in POJO. */
private final String javaTypeNamePrev;
@@ -64,7 +62,7 @@ public class PojoField {
private final boolean nullable;
/** List of possible java type conversions. */
- private final ObservableList<String> conversions;
+ private final List<String> conversions;
/** Field owner. */
private PojoDescriptor owner;
@@ -83,10 +81,10 @@ public class PojoField {
}
/** Null number conversions. */
- private static final ObservableList<String> NULL_NUM_CONVERSIONS = FXCollections.observableArrayList();
+ private static final List<String> NULL_NUM_CONVERSIONS = new ArrayList<>();
/** Not null number conversions. */
- private static final ObservableList<String> NOT_NULL_NUM_CONVERSIONS = FXCollections.observableArrayList();
+ private static final List<String> NOT_NULL_NUM_CONVERSIONS = new ArrayList<>();
/** Primitive types. */
private static final List<String> PRIMITIVES = classNames(boolean.class, byte.class, short.class,
@@ -109,7 +107,7 @@ public class PojoField {
* @param dflt Default.
* @return List of possible type conversions.
*/
- private static ObservableList<String> conversions(int dbType, boolean nullable, String dflt) {
+ private static List<String> conversions(int dbType, boolean nullable, String dflt) {
switch (dbType) {
case TINYINT:
case SMALLINT:
@@ -121,7 +119,7 @@ public class PojoField {
return nullable ? NULL_NUM_CONVERSIONS : NOT_NULL_NUM_CONVERSIONS;
default:
- return FXCollections.singletonObservableList(dflt);
+ return Collections.singletonList(dflt);
}
}
@@ -134,32 +132,32 @@ public class PojoField {
* @param nullable {@code true} if {@code NULL} allowed for field in database.
*/
public PojoField(String dbName, int dbType, String javaName, String javaTypeName, boolean key, boolean nullable) {
- dbNameProp = new SimpleStringProperty(dbName);
+ dbNameProp = new Property<>(dbName);
- dbTypeNameProp = new SimpleStringProperty(jdbcTypeName(dbType));
+ dbTypeNameProp = new Property<>(jdbcTypeName(dbType));
javaNamePrev = javaName;
- javaNameProp = new SimpleStringProperty(javaNamePrev);
+ javaNameProp = new Property<>(javaNamePrev);
javaTypeNamePrev = javaTypeName;
- javaTypeNameProp = new SimpleStringProperty(javaTypeNamePrev);
+ javaTypeNameProp = new Property<>(javaTypeNamePrev);
- useProp = new SimpleBooleanProperty(true);
+ useProp = new Property<>(true);
keyPrev = key;
- keyProp = new SimpleBooleanProperty(keyPrev);
+ keyProp = new Property<>(keyPrev);
this.nullable = nullable;
- akProp = new SimpleBooleanProperty(false);
+ akProp = new Property<>(false);
conversions = conversions(dbType, nullable, javaNamePrev);
keyProp.addListener(new ChangeListener<Boolean>() {
- @Override public void changed(ObservableValue<? extends Boolean> val, Boolean oldVal, Boolean newVal) {
+ @Override public void changed(Property<? extends Boolean> val, Boolean oldVal, Boolean newVal) {
if (newVal) {
if (!use())
useProp.set(true);
@@ -170,7 +168,7 @@ public class PojoField {
});
akProp.addListener(new ChangeListener<Boolean>() {
- @Override public void changed(ObservableValue<? extends Boolean> val, Boolean oldVal, Boolean newVal) {
+ @Override public void changed(Property<? extends Boolean> val, Boolean oldVal, Boolean newVal) {
if (newVal && owner != null) {
keyProperty().set(true);
@@ -352,7 +350,7 @@ public class PojoField {
/**
* @return List of possible java type conversions.
*/
- public ObservableList<String> conversions() {
+ public List<String> conversions() {
return conversions;
}
@@ -373,49 +371,49 @@ public class PojoField {
/**
* @return Boolean property support for {@code use} property.
*/
- public BooleanProperty useProperty() {
+ public Property<Boolean> useProperty() {
return useProp;
}
/**
* @return Boolean property support for {@code key} property.
*/
- public BooleanProperty keyProperty() {
+ public Property<Boolean> keyProperty() {
return keyProp;
}
/**
* @return Boolean property support for {@code affinityKey} property.
*/
- public BooleanProperty affinityKeyProperty() {
+ public Property<Boolean> affinityKeyProperty() {
return akProp;
}
/**
* @return String property support for {@code javaName} property.
*/
- public StringProperty javaNameProperty() {
+ public Property<String> javaNameProperty() {
return javaNameProp;
}
/**
* @return String property support for {@code javaTypeName} property.
*/
- public StringProperty javaTypeNameProperty() {
+ public Property<String> javaTypeNameProperty() {
return javaTypeNameProp;
}
/**
* @return String property support for {@code dbName} property.
*/
- public StringProperty dbNameProperty() {
+ public Property<String> dbNameProperty() {
return dbNameProp;
}
/**
* @return String property support for {@code dbName} property.
*/
- public StringProperty dbTypeNameProperty() {
+ public Property<String> dbTypeNameProperty() {
return dbTypeNameProp;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/DatabaseMetadataParser.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/DatabaseMetadataParser.java b/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/DatabaseMetadataParser.java
index 696ca62..1c2eedb 100644
--- a/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/DatabaseMetadataParser.java
+++ b/modules/schema-import/src/main/java/org/apache/ignite/schema/parser/DatabaseMetadataParser.java
@@ -17,7 +17,6 @@
package org.apache.ignite.schema.parser;
-import javafx.collections.*;
import org.apache.ignite.schema.model.*;
import org.apache.ignite.schema.parser.dialect.*;
@@ -40,7 +39,7 @@ public class DatabaseMetadataParser {
* @return Collection of POJO descriptors.
* @throws SQLException If parsing failed.
*/
- public static ObservableList<PojoDescriptor> parse(Connection conn, boolean tblsOnly) throws SQLException {
+ public static List<PojoDescriptor> parse(Connection conn, boolean tblsOnly) throws SQLException {
DatabaseMetadataDialect dialect;
try {
@@ -103,6 +102,6 @@ public class DatabaseMetadataParser {
}
});
- return FXCollections.observableList(res);
+ return res;
}
}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/ConfirmCallable.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/ConfirmCallable.java b/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/ConfirmCallable.java
deleted file mode 100644
index 8321d96..0000000
--- a/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/ConfirmCallable.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.apache.ignite.schema.ui;
-
-import javafx.application.*;
-import javafx.stage.*;
-
-import java.util.concurrent.*;
-
-import static org.apache.ignite.schema.ui.MessageBox.Result.*;
-
-/**
- * Callable to ask user for confirmation from non EDT thread.
- */
-public class ConfirmCallable implements Callable<MessageBox.Result> {
- /** Owner window. */
- private final Stage owner;
-
- /** Message template. */
- private final String template;
-
- /** Message to show in confirmation dialog. */
- private String msg;
-
- /** User choice. */
- private MessageBox.Result choice = NO;
-
- /**
- * @param owner Owner window.
- * @param template Message template.
- */
- public ConfirmCallable(Stage owner, String template) {
- this.owner = owner;
- this.template = template;
- }
-
- /** {@inheritDoc} */
- @Override public MessageBox.Result call() throws Exception {
- choice = MessageBox.applyToAllChoiceDialog(owner, String.format(template, msg));
-
- return choice;
- }
-
- /**
- * Execute confirmation in EDT thread.
- *
- * @return Confirm result.
- */
- public MessageBox.Result confirm(String msg) {
- this.msg = msg;
-
- if (choice == YES_TO_ALL || choice == NO_TO_ALL)
- return choice;
-
- FutureTask<MessageBox.Result> fut = new FutureTask<>(this);
-
- Platform.runLater(fut);
-
- try {
- return fut.get();
- }
- catch (Exception ignored) {
- return NO;
- }
- }
-}
[4/7] incubator-ignite git commit: IGNITE-1155 Extract
ignite-schema-import-ui module.
Posted by se...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/Controls.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/Controls.java b/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/Controls.java
deleted file mode 100644
index 6c4d6bd..0000000
--- a/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/Controls.java
+++ /dev/null
@@ -1,643 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.apache.ignite.schema.ui;
-
-import com.sun.javafx.scene.control.skin.*;
-import javafx.application.*;
-import javafx.beans.value.*;
-import javafx.collections.*;
-import javafx.event.*;
-import javafx.geometry.*;
-import javafx.scene.*;
-import javafx.scene.control.*;
-import javafx.scene.control.cell.*;
-import javafx.scene.image.*;
-import javafx.scene.input.*;
-import javafx.scene.layout.*;
-import javafx.scene.text.*;
-import javafx.util.*;
-import javafx.util.converter.*;
-
-/**
- * Utility class to create controls.
- */
-public class Controls {
- /** */
- public static final Insets DFLT_PADDING = new Insets(10, 10, 10, 10);
-
- /**
- * Create scene with predefined style.
- *
- * @param root The root node of the scene graph.
- * @return New {@code Scene} instance.
- */
- public static Scene scene(Parent root) {
- Scene scene = new Scene(root);
-
- scene.getStylesheets().add("media/style.css");
-
- return scene;
- }
-
- /**
- * Create grid pane with default padding.
- *
- * @param top Top padding
- * @param right Right padding.
- * @param bottom Bottom padding.
- * @param left Left padding.
- * @return New {@code GridPaneEx} instance.
- */
- public static GridPaneEx paneEx(double top, double right, double bottom, double left) {
- GridPaneEx paneEx = new GridPaneEx();
-
- paneEx.setPadding(new Insets(top, right, bottom, left));
-
- return paneEx;
- }
-
- /**
- * Create new {@code HBox} with default padding.
- *
- * @param spacing Amount of horizontal space between each child.
- * @param dfltPadding If {@code true} than set default padding for pane.
- * @return New {@code HBox} instance.
- */
- public static HBox hBox(int spacing, boolean dfltPadding) {
- HBox hb = new HBox(spacing);
-
- if (dfltPadding)
- hb.setPadding(DFLT_PADDING);
-
- return hb;
- }
-
- /**
- * Create new {@code HBox} with default padding and add controls.
- *
- * @param spacing Amount of horizontal space between each child.
- * @param dfltPadding If {@code true} than set default padding for pane.
- * @param controls Controls to add.
- * @return New {@code HBox} instance.
- */
- public static HBox hBox(int spacing, boolean dfltPadding, Node... controls) {
- HBox hb = hBox(spacing, dfltPadding);
-
- hb.getChildren().addAll(controls);
-
- return hb;
- }
-
- /**
- * Create new {@code VBox} with default padding.
- *
- * @param spacing Amount of horizontal space between each child.
- * @return New {@code VBox} instance.
- */
- public static VBox vBox(int spacing) {
- VBox vb = new VBox(spacing);
-
- vb.setPadding(DFLT_PADDING);
-
- return vb;
- }
-
- /**
- * Create new {@code VBox} with default padding and add controls.
- *
- * @param spacing Amount of horizontal space between each child.
- * @param controls Controls to add.
- * @return New {@code VBox} instance.
- */
- public static VBox vBox(int spacing, Node... controls) {
- VBox vb = vBox(spacing);
-
- vb.getChildren().addAll(controls);
-
- return vb;
- }
-
- /**
- * Create stack pane.
- *
- * @param controls Controls to add.
- * @return New {@code StackPane} instance.
- */
- public static StackPane stackPane(Node... controls) {
- StackPane sp = new StackPane();
-
- sp.getChildren().addAll(controls);
-
- return sp;
- }
-
- /**
- * Create border pane.
- *
- * @param top Optional top control.
- * @param center Optional center control.
- * @param bottom Optional bottom control.
- * @param left Optional left control.
- * @param right Optional right control.
- * @return New {@code BorderPane} instance.
- */
- public static BorderPane borderPane(Node top, Node center, Node bottom, Node left, Node right) {
- BorderPane bp = new BorderPane();
-
- bp.setTop(top);
- bp.setCenter(center);
- bp.setBottom(bottom);
- bp.setLeft(left);
- bp.setRight(right);
-
- return bp;
- }
-
- /**
- * Sets control tooltip if needed.
- *
- * @param ctrl Target control.
- * @param tip Tooltip text.
- * @return Control itself for method chaining.
- */
- public static <T extends Control> T tooltip(T ctrl, String tip) {
- if (!tip.isEmpty())
- ctrl.setTooltip(new Tooltip(tip));
-
- return ctrl;
- }
-
- /**
- * Create label.
- *
- * @param text Label text.
- * @return New {@code Label} instance.
- */
- public static Label label(String text) {
- return new Label(text);
- }
-
- /**
- * Create button with text only.
- *
- * @param text Button text.
- * @param tip Tooltip text.
- * @param onAct Button action.
- * @return New {@code Button} instance.
- */
- public static Button button(String text, String tip, EventHandler<ActionEvent> onAct) {
- Button btn = new Button(text);
-
- btn.setOnAction(onAct);
-
- tooltip(btn, tip);
-
- return btn;
- }
-
- /**
- * Create button with icon only.
- *
- * @param icon Button icon.
- * @param tip Tooltip text.
- * @param onAct Button action.
- * @return New {@code Button} instance.
- */
- public static Button button(ImageView icon, String tip, EventHandler<ActionEvent> onAct) {
- Button btn = new Button();
-
- btn.setGraphic(icon);
- btn.setOnAction(onAct);
-
- tooltip(btn, tip);
-
- return btn;
- }
-
- /**
- * Create pane with buttons.
- *
- * @param alignment Alignment of buttons.
- * @param dfltPadding If {@code true} than set default padding for pane.
- * @param btns Buttons that will be added to pane.
- * @return New {@code HBox} instance with buttons.
- */
- public static Pane buttonsPane(Pos alignment, boolean dfltPadding, Button... btns) {
- HBox hb = hBox(10, dfltPadding, btns);
-
- hb.setAlignment(alignment);
-
- return hb;
- }
-
- /**
- * Create checkbox.
- *
- * @param text Checkbox text.
- * @param tip Tooltip tex.
- * @param sel Checkbox selected state.
- * @return New {@code Checkbox} instance.
- */
- public static CheckBox checkBox(String text, String tip, boolean sel) {
- CheckBox ch = new CheckBox(text);
-
- ch.setSelected(sel);
-
- tooltip(ch, tip);
-
- return ch;
- }
-
- /**
- * Create text field.
- *
- * @param tip Tooltip text.
- * @return New {@code TextField} instance.
- */
- public static TextField textField(String tip) {
- TextField tf = new TextField();
-
- tooltip(tf, tip);
-
- return tf;
- }
-
- /**
- * Create static text.
- *
- * @param text Text to show.
- * @param wrap Text wrapping width.
- * @return New {@code Text} instance.
- */
- public static Text text(String text, int wrap) {
- Text t = new Text(text);
-
- t.setFont(new Font(14));
-
- if (wrap > 0)
- t.setWrappingWidth(wrap);
-
- return t;
- }
-
- /**
- * Create password field.
- *
- * @param tip Tooltip text.
- * @return New {@code PasswordField} instance.
- */
- public static PasswordField passwordField(String tip) {
- PasswordField pf = new PasswordField();
-
- tooltip(pf, tip);
-
- return pf;
- }
-
- /**
- * Create combo box.
- *
- * @param tip Tooltip text.
- * @param items Combo box items.
- * @return New {@code ComboBox} instance.
- */
- public static <T> ComboBox<T> comboBox(String tip, T... items) {
- ComboBox<T> cb = new ComboBox<>(FXCollections.observableArrayList(items));
-
- cb.setMaxWidth(Double.MAX_VALUE);
- cb.getSelectionModel().select(0);
-
- tooltip(cb, tip);
-
- return cb;
- }
-
- /**
- * Create split pane for provided nodes.
- *
- * @param node1 First node.
- * @param node2 Second node.
- * @param pos Initial divider position.
- * @return New {@code SplitPane} instance.
- */
- public static SplitPane splitPane(Node node1, Node node2, double pos) {
- SplitPane sp = new SplitPane();
-
- sp.setOrientation(Orientation.VERTICAL);
- sp.getItems().addAll(node1, node2);
- sp.setDividerPosition(0, pos);
-
- return sp;
- }
-
- /**
- * Create titled pane.
- *
- * @param title Title.
- * @param node Node.
- * @return New {@code TitledPane} instance.
- */
- public static TitledPane titledPane(String title, Node node) {
- TitledPane tp = new TitledPane(title, node);
-
- tp.setExpanded(false);
-
- return tp;
- }
-
- /**
- * Create table column.
- *
- * @param colName Column name to display.
- * @param propName Property name column is bound to.
- * @param tip Column tooltip text.
- * @param minWidth The minimum width column is permitted to be resized to.
- * @param maxWidth The maximum width column is permitted to be resized to.
- * @param editable {@code true} if column is editable.
- * @return New {@code TableColumn} instance.
- */
- private static <S, T> TableColumn<S, T> tableColumn(String colName, String propName, String tip,
- int minWidth, int maxWidth, boolean editable) {
- TableColumn<S, T> col = new TableColumn<>();
-
- col.setGraphic(tooltip(new Label(colName), tip));
-
- col.setSortable(false);
-
- if (minWidth > 0)
- col.setMinWidth(minWidth);
-
- if (maxWidth > 0)
- col.setMaxWidth(maxWidth);
-
- col.setCellValueFactory(new PropertyValueFactory<S, T>(propName));
-
- col.setEditable(editable);
-
- return col;
- }
-
- /**
- * Create table column.
- *
- * @param colName Column name to display.
- * @param propName Property name column is bound to.
- * @param tip Column tooltip text.
- * @return New {@code TableColumn} instance.
- */
- public static <S, T> TableColumn<S, T> tableColumn(String colName, String propName, String tip) {
- return tableColumn(colName, propName, tip, 100, 0, false);
- }
-
- /**
- * Create table column.
- *
- * @param colName Column name to display.
- * @param propName Property name column is bound to.
- * @param tip Column tooltip text.
- * @param cellFactory Custom cell factory.
- * @return New {@code TableColumn} instance.
- */
- public static <S, T> TableColumn<S, T> customColumn(String colName, String propName, String tip,
- Callback<TableColumn<S, T>, TableCell<S, T>> cellFactory) {
- TableColumn<S, T> col = tableColumn(colName, propName, tip, 100, 0, true);
-
- col.setCellFactory(cellFactory);
-
- return col;
- }
-
- /**
- * Create editable boolean table column.
- *
- * @param colName Column name to display.
- * @param propName Property name column is bound to.
- * @param tip Column tooltip text.
- * @return New {@code TableColumn} instance.
- */
- public static <S> TableColumn<S, Boolean> booleanColumn(String colName, String propName, String tip) {
- TableColumn<S, Boolean> col = tableColumn(colName, propName, tip, 50, 50, true);
-
- col.setCellFactory(CheckBoxTableCellEx.<S>cellFactory());
-
- return col;
-
- }
-
- /**
- * Create editable text table column.
- *
- * @param colName Column name to display.
- * @param propName Property name column is bound to.
- * @param tip Column tooltip text.
- * @return New {@code TableColumn} instance.
- */
- public static <S> TableColumn<S, String> textColumn(String colName, String propName, String tip,
- TextColumnValidator<S> validator) {
- TableColumn<S, String> col = tableColumn(colName, propName, tip, 100, 0, true);
-
- col.setCellFactory(TextFieldTableCellEx.cellFactory(validator));
-
- return col;
- }
-
- /**
- * Create table view.
- *
- * @param placeholder Text to show if table model is empty.
- * @param cols Columns to add.
- * @return New {@code TableView} instance.
- */
- public static <S> TableView<S> tableView(String placeholder, TableColumn<S, ?>... cols) {
- TableView<S> tbl = new TableView<>();
-
- tbl.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
- tbl.setEditable(true);
- tbl.setMinHeight(70);
- tbl.setPlaceholder(text(placeholder, 0));
-
- tbl.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
-
- tbl.getColumns().addAll(cols);
-
- return tbl;
- }
-
- /**
- * Create progress indicator.
- *
- * @param sz Indicator diameter.
- * @return New {@code ProgressIndicator} instance.
- */
- public static ProgressIndicator progressIndicator(int sz) {
- ProgressIndicator pi = new ProgressIndicator();
-
- pi.setMaxWidth(sz);
- pi.setMaxHeight(sz);
-
- return pi;
- }
-
- /**
- * Create image view.
- *
- * @param imgFileName Image filename.
- * @return New {@code ImageView} instance.
- */
- public static ImageView imageView(String imgFileName, int sz) {
- return new ImageView(image(imgFileName, sz));
- }
-
- /**
- * Gets image by its filename.
- *
- * @param imgFileName Image filename.
- * @return Loaded image.
- */
- public static Image image(String imgFileName, int sz) {
- return new Image(Controls.class.getClassLoader()
- .getResourceAsStream(String.format("media/%1$s_%2$dx%2$d.png", imgFileName, sz)));
- }
-
- /**
- * Customized checkbox.
- */
- private static class CheckBoxTableCellEx<S> extends CheckBoxTableCell<S, Boolean> {
- /** Creates a ComboBox cell factory for use in TableColumn controls. */
- public static <S> Callback<TableColumn<S, Boolean>, TableCell<S, Boolean>> cellFactory() {
- return new Callback<TableColumn<S, Boolean>, TableCell<S, Boolean>>() {
- @Override public TableCell<S, Boolean> call(TableColumn<S, Boolean> col) {
- return new CheckBoxTableCellEx<>();
- }
- };
- }
-
- /**
- * Default constructor.
- */
- private CheckBoxTableCellEx() {
- setAlignment(Pos.CENTER);
- }
- }
-
- /**
- * Special table text field cell that commit its content on focus lost.
- */
- private static class TextFieldTableCellEx<S> extends TextFieldTableCell<S, String> {
- /** */
- private final TextColumnValidator<S> validator;
- /** */
- private String curTxt = "";
-
- /** Row value. */
- private S rowVal;
-
- /** Create cell factory. */
- public static <S> Callback<TableColumn<S, String>, TableCell<S, String>>
- cellFactory(final TextColumnValidator<S> validator) {
- return new Callback<TableColumn<S, String>, TableCell<S, String>>() {
- @Override public TableCell<S, String> call(TableColumn<S, String> col) {
- return new TextFieldTableCellEx<>(validator);
- }
- };
- }
-
- /**
- * Text field cell constructor.
- *
- * @param validator Input text validator.
- */
- private TextFieldTableCellEx(TextColumnValidator<S> validator) {
- super(new DefaultStringConverter());
-
- this.validator = validator;
- }
-
- /** {@inheritDoc} */
- @Override public void startEdit() {
- String item = getItem();
-
- if (item == null || item.isEmpty())
- return;
-
- super.startEdit();
-
- rowVal = getTableView().getSelectionModel().getSelectedItem();
-
- Node g = getGraphic();
-
- if (g != null) {
- final TextField tf = (TextField)g;
-
- curTxt = tf.getText();
-
- tf.textProperty().addListener(new ChangeListener<String>() {
- @Override public void changed(ObservableValue<? extends String> val, String oldVal, String newVal) {
- curTxt = newVal;
- }
- });
-
- tf.setOnKeyPressed(new EventHandler<KeyEvent>() {
- @Override public void handle(KeyEvent evt) {
- if (KeyCode.ENTER == evt.getCode() || KeyCode.ESCAPE == evt.getCode())
- cancelEdit();
- }
- });
-
- tf.setOnKeyReleased(new EventHandler<KeyEvent>() {
- @Override public void handle(KeyEvent evt) {
- // No-op to overwrite JavaFX implementation.
- }
- });
-
- // Special hack for editable TextFieldTableCell.
- // Cancel edit when focus lost from text field, but do not cancel if focus lost to VirtualFlow.
- tf.focusedProperty().addListener(new ChangeListener<Boolean>() {
- @Override public void changed(ObservableValue<? extends Boolean> val, Boolean oldVal, Boolean newVal) {
- Node fo = getScene().getFocusOwner();
-
- if (!newVal) {
- if (fo instanceof VirtualFlow) {
- if (fo.getParent().getParent() != getTableView())
- cancelEdit();
- }
- else
- cancelEdit();
- }
- }
- });
-
- Platform.runLater(new Runnable() {
- @Override public void run() {
- tf.requestFocus();
- }
- });
- }
- }
-
- /** {@inheritDoc} */
- @Override public void cancelEdit() {
- boolean editing = isEditing();
-
- super.cancelEdit();
-
- if (editing && validator.valid(rowVal, curTxt))
- updateItem(curTxt, false);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/GridPaneEx.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/GridPaneEx.java b/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/GridPaneEx.java
deleted file mode 100644
index be1aae9..0000000
--- a/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/GridPaneEx.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.apache.ignite.schema.ui;
-
-import javafx.geometry.*;
-import javafx.scene.*;
-import javafx.scene.control.*;
-import javafx.scene.layout.*;
-
-/**
- * Utility extension of {@code GridPane}.
- */
-public class GridPaneEx extends GridPane {
- /** Current column. */
- private int col;
-
- /** Current row. */
- private int row;
-
- /**
- * Create pane.
- */
- public GridPaneEx() {
- setAlignment(Pos.TOP_LEFT);
- setHgap(5);
- setVgap(10);
- }
-
- /**
- * Add default column.
- */
- public void addColumn() {
- getColumnConstraints().add(new ColumnConstraints());
- }
-
- /**
- * Add column with constraints and horizontal grow priority for the column.
- *
- * @param min Column minimum size.
- * @param pref Column preferred size.
- * @param max Column max size.
- * @param hgrow Column horizontal grow priority.
- */
- public void addColumn(double min, double pref, double max, Priority hgrow) {
- ColumnConstraints cc = new ColumnConstraints(min, pref, max);
-
- cc.setHgrow(hgrow);
-
- getColumnConstraints().add(cc);
- }
-
- /**
- * Add default row.
- */
- public void addRow() {
- getRowConstraints().add(new RowConstraints());
- }
-
- /**
- * Add default rows.
- *
- * @param n Number of rows to add.
- */
- public void addRows(int n) {
- for (int i = 0; i < n; i++)
- addRow();
- }
-
- /**
- * Add row with constraints and vertical grow priority for the row.
- *
- * @param min Row minimum size.
- * @param pref Row preferred size.
- * @param max Row max size.
- * @param vgrow Row vertical grow priority.
- */
- public void addRow(double min, double pref, double max, Priority vgrow) {
- RowConstraints rc = new RowConstraints(min, pref, max);
-
- rc.setVgrow(vgrow);
-
- getRowConstraints().add(rc);
- }
-
- /**
- * Wrap to next row.
- */
- public void wrap() {
- col = 0;
-
- row++;
- }
-
- /**
- * Skip columns.
- *
- * @param span How many columns should be skipped.
- */
- public void skip(int span) {
- add(new Label(""), span);
- }
-
- /**
- * Move to next column.
- */
- private void nextCol(int span) {
- col += span;
-
- if (col >= getColumnConstraints().size())
- wrap();
- }
-
- /**
- * Add control to grid pane.
- *
- * @param ctrl Control to add.
- * @param span How many columns control should take.
- * @return Added control.
- */
- public <T extends Node> T add(T ctrl, int span) {
- add(ctrl, col, row, span, 1);
-
- nextCol(span);
-
- return ctrl;
- }
-
- /**
- * Add control to grid pane.
- *
- * @param ctrl Control to add.
- * @return Added control.
- */
- public <T extends Node> T add(T ctrl) {
- return add(ctrl, 1);
- }
-
- /**
- * Add control with label.
- *
- * @param text Label text.
- * @param ctrl Control to add.
- * @param span How many columns control should take.
- * @return Added control.
- */
- public <T extends Node> T addLabeled(String text, T ctrl, int span) {
- add(new Label(text));
-
- return add(ctrl, span);
- }
-
- /**
- * Add control with label.
- *
- * @param text Label text.
- * @param ctrl Control to add.
- * @return Added control.
- */
- public <T extends Node> T addLabeled(String text, T ctrl) {
- return addLabeled(text, ctrl, 1);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/MessageBox.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/MessageBox.java b/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/MessageBox.java
deleted file mode 100644
index 7daf69f..0000000
--- a/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/MessageBox.java
+++ /dev/null
@@ -1,261 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.apache.ignite.schema.ui;
-
-import javafx.beans.value.*;
-import javafx.event.*;
-import javafx.geometry.*;
-import javafx.scene.control.*;
-import javafx.scene.layout.*;
-import javafx.stage.*;
-
-import java.util.logging.*;
-
-import static org.apache.ignite.schema.ui.Controls.*;
-
-/**
- * Message box functionality.
- */
-public class MessageBox extends ModalDialog {
- /** Logger. */
- private static final Logger log = Logger.getLogger(MessageBox.class.getName());
-
- /** Message box type. */
- private enum MessageType {
- /** Information. */
- INFO,
- /** Warning. */
- WARN,
- /** Error. */
- ERROR,
- /** Confirm. */
- CONFIRM,
- /** Confirm with cancel option. */
- CANCELLABLE_CONFIRM
- }
-
- /** Message box type. */
- public enum Result {
- /** Return value if YES is chosen. */
- YES,
- /** Return value if YES_TO_ALL is chosen. */
- YES_TO_ALL,
- /** Return value if NO is chosen. */
- NO,
- /** Return value if NO_TO_ALL is chosen. */
- NO_TO_ALL,
- /** Return value if CANCEL is chosen. */
- CANCEL
- }
-
- /** Dialog result. */
- private Result res = Result.CANCEL;
-
- /**
- * Create message box.
- *
- * @param owner Owner window.
- * @param type Message box type.
- * @param msg Message to show.
- * @param applyToAll {@code true} if "Apply to all" check box should be displayed.
- */
- private MessageBox(Stage owner, MessageType type, String msg, final boolean applyToAll) {
- super(owner, 480, 180);
-
- String title;
- String iconFile;
-
- switch (type) {
- case WARN:
- title = "Warning";
- iconFile = "sign_warning";
- break;
-
- case ERROR:
- title = "Error";
- iconFile = "error";
- break;
-
- case CONFIRM:
- case CANCELLABLE_CONFIRM:
- title = "Confirmation";
- iconFile = "question";
- break;
-
- default:
- title = "Information";
- iconFile = "information";
- break;
- }
-
- setTitle(title);
- initStyle(StageStyle.UTILITY);
- initModality(Modality.APPLICATION_MODAL);
- initOwner(owner);
- setResizable(false);
-
- GridPaneEx contentPnl = paneEx(10, 10, 0, 10);
-
- contentPnl.addColumn();
- contentPnl.addColumn(100, 100, Double.MAX_VALUE, Priority.ALWAYS);
-
- contentPnl.add(hBox(0, true, imageView(iconFile, 48)));
-
- final TextArea ta = new TextArea(msg);
- ta.setEditable(false);
- ta.setWrapText(true);
- ta.setFocusTraversable(false);
-
- contentPnl.add(ta);
-
- // Workaround for vertical scrollbar.
- if (msg.length() < 100 && msg.split("\r\n|\r|\n").length < 4)
- showingProperty().addListener(new ChangeListener<Boolean>() {
- @Override public void changed(ObservableValue<? extends Boolean> val, Boolean oldVal, Boolean newVal) {
- if (newVal) {
- ScrollBar scrollBar = (ScrollBar)ta.lookup(".scroll-bar:vertical");
-
- if (scrollBar != null)
- scrollBar.setDisable(true);
- }
- }
- });
-
- final CheckBox applyToAllCh = checkBox("Apply to all", "", false);
-
- if (applyToAll) {
- contentPnl.skip(1);
- contentPnl.add(applyToAllCh);
- }
-
- HBox btns = hBox(10, true);
- btns.setAlignment(Pos.CENTER);
-
- if (MessageType.CONFIRM == type || MessageType.CANCELLABLE_CONFIRM == type) {
- res = Result.NO;
-
- btns.getChildren().addAll(
- button("Yes", "Approve the request", new EventHandler<ActionEvent>() {
- @Override public void handle(ActionEvent e) {
- res = applyToAll && applyToAllCh.isSelected() ? Result.YES_TO_ALL : Result.YES;
-
- close();
- }
- }),
- button("No", "Reject the request", new EventHandler<ActionEvent>() {
- @Override public void handle(ActionEvent e) {
- res = applyToAll && applyToAllCh.isSelected() ? Result.NO_TO_ALL : Result.NO;
-
- close();
- }
- }));
-
- if (MessageType.CANCELLABLE_CONFIRM == type)
- btns.getChildren().addAll(
- button("Cancel", "Cancel the request", new EventHandler<ActionEvent>() {
- @Override public void handle(ActionEvent e) {
- res = Result.CANCEL;
-
- close();
- }
- }));
- }
- else
- btns.getChildren().add(button("OK", "Close dialog", new EventHandler<ActionEvent>() {
- @Override public void handle(ActionEvent e) {
- close();
- }
- }));
-
- setScene(scene(borderPane(null, contentPnl, btns, null, null)));
- }
-
- /**
- * Show message in modal dialog.
- *
- * @param owner Owner window.
- * @param type Message box type.
- * @param msg Message to show.
- * @param applyToAll {@code true} if "Apply to all" check box should be displayed.
- * @return Option selected by the user.
- */
- private static Result showDialog(Stage owner, MessageType type, String msg, boolean applyToAll) {
- MessageBox dlg = new MessageBox(owner, type, msg, applyToAll);
-
- dlg.showModal();
-
- return dlg.res;
- }
-
- /**
- * Show confirmation dialog.
- *
- * @param owner Owner window.
- * @param msg Message to show.
- * @return {@code true} If user confirm.
- */
- public static boolean confirmDialog(Stage owner, String msg) {
- return showDialog(owner, MessageType.CONFIRM, msg, false) == Result.YES;
- }
-
- /**
- * Show confirmation dialog.
- *
- * @param owner Owner window.
- * @param msg Message to show.
- * @return User confirmation result.
- */
- public static Result applyToAllChoiceDialog(Stage owner, String msg) {
- return showDialog(owner, MessageType.CANCELLABLE_CONFIRM, msg, true);
- }
-
- /**
- * Show information dialog.
- *
- * @param owner Owner window.
- * @param msg Message to show.
- */
- public static void informationDialog(Stage owner, String msg) {
- showDialog(owner, MessageType.INFO, msg, false);
- }
-
- /**
- * Show warning dialog.
- *
- * @param owner Owner window.
- * @param msg Message to show.
- */
- public static void warningDialog(Stage owner, String msg) {
- showDialog(owner, MessageType.WARN, msg, false);
- }
-
- /**
- * Show error dialog.
- *
- * @param owner Owner window.
- * @param msg Error message to show.
- * @param e Optional exception to show.
- */
- public static void errorDialog(Stage owner, String msg, Throwable e) {
- log.log(Level.SEVERE, msg, e);
-
- String exMsg = e != null ? (e.getMessage() != null ? e.getMessage() : e.getClass().getName()) : null;
-
- showDialog(owner, MessageType.ERROR, exMsg != null ? msg + "\n" + exMsg : msg, false);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/ModalDialog.java
----------------------------------------------------------------------
diff --git a/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/ModalDialog.java b/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/ModalDialog.java
deleted file mode 100644
index 6d0acb7..0000000
--- a/modules/schema-import/src/main/java/org/apache/ignite/schema/ui/ModalDialog.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.apache.ignite.schema.ui;
-
-import javafx.stage.*;
-
-/**
- * Abstract base modal dialog.
- */
-public abstract class ModalDialog extends Stage {
- /** Owner window. */
- protected final Stage owner;
-
- /**
- * @param owner Owner window.
- * @param width Window width.
- * @param height Window height.
- */
- protected ModalDialog(Stage owner, int width, int height) {
- this.owner = owner;
-
- this.setWidth(width);
- this.setHeight(height);
- }
-
- /**
- * Show modal dialog.
- */
- protected void showModal() {
- setX(owner.getX() + owner.getWidth() / 2 - getWidth() / 2);
- setY(owner.getY() + owner.getHeight() / 2 - getHeight() / 2);
-
- showAndWait();
- }
-}
[7/7] incubator-ignite git commit: IGNITE-1155 Extract
ignite-schema-import-ui module.
Posted by se...@apache.org.
IGNITE-1155 Extract ignite-schema-import-ui module.
Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/e8d71b55
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/e8d71b55
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/e8d71b55
Branch: refs/heads/ignite-1155
Commit: e8d71b5523f8898d7a67a07f1b311c6f4cb19186
Parents: d5925e6
Author: sevdokimov <se...@gridgain.com>
Authored: Mon Jul 27 20:26:19 2015 +0300
Committer: sevdokimov <se...@gridgain.com>
Committed: Mon Jul 27 20:26:19 2015 +0300
----------------------------------------------------------------------
modules/schema-import-ui/pom.xml | 110 ++
.../main/java/media/data_connection_48x48.png | Bin 0 -> 4443 bytes
.../src/main/java/media/error_48x48.png | Bin 0 -> 4349 bytes
.../src/main/java/media/ignite_128x128.png | Bin 0 -> 4917 bytes
.../src/main/java/media/ignite_16x16.png | Bin 0 -> 608 bytes
.../src/main/java/media/ignite_24x24.png | Bin 0 -> 930 bytes
.../src/main/java/media/ignite_32x32.png | Bin 0 -> 1203 bytes
.../src/main/java/media/ignite_48x48.png | Bin 0 -> 1868 bytes
.../src/main/java/media/ignite_64x64.png | Bin 0 -> 2453 bytes
.../src/main/java/media/information_48x48.png | Bin 0 -> 4102 bytes
.../src/main/java/media/question_48x48.png | Bin 0 -> 3857 bytes
.../src/main/java/media/sign_warning_48x48.png | Bin 0 -> 2988 bytes
.../src/main/java/media/style.css | 134 ++
.../src/main/java/media/text_tree_48x48.png | Bin 0 -> 2567 bytes
.../ignite/schema/ui/ConfirmCallable.java | 103 +
.../org/apache/ignite/schema/ui/Controls.java | 692 +++++++
.../org/apache/ignite/schema/ui/GridPaneEx.java | 177 ++
.../apache/ignite/schema/ui/JavaFxUtils.java | 122 ++
.../org/apache/ignite/schema/ui/MessageBox.java | 261 +++
.../apache/ignite/schema/ui/ModalDialog.java | 50 +
.../ignite/schema/ui/SchemaImportApp.java | 1768 ++++++++++++++++++
.../ignite/schema/ui/TextColumnValidator.java | 32 +
.../schema/test/AbstractSchemaImportTest.java | 132 ++
.../test/generator/CodeGeneratorTest.java | 70 +
.../schema/test/generator/XmlGeneratorTest.java | 50 +
.../apache/ignite/schema/test/model/Objects.txt | 502 +++++
.../ignite/schema/test/model/ObjectsKey.txt | 96 +
.../ignite/schema/test/model/Primitives.txt | 506 +++++
.../ignite/schema/test/model/PrimitivesKey.txt | 96 +
.../schema/test/model/ignite-type-metadata.xml | 362 ++++
.../test/parser/DbMetadataParserTest.java | 118 ++
.../testsuites/IgniteSchemaImportTestSuite.java | 41 +
modules/schema-import/pom.xml | 34 -
.../main/java/media/data_connection_48x48.png | Bin 4443 -> 0 bytes
.../src/main/java/media/error_48x48.png | Bin 4349 -> 0 bytes
.../src/main/java/media/ignite_128x128.png | Bin 4917 -> 0 bytes
.../src/main/java/media/ignite_16x16.png | Bin 608 -> 0 bytes
.../src/main/java/media/ignite_24x24.png | Bin 930 -> 0 bytes
.../src/main/java/media/ignite_32x32.png | Bin 1203 -> 0 bytes
.../src/main/java/media/ignite_48x48.png | Bin 1868 -> 0 bytes
.../src/main/java/media/ignite_64x64.png | Bin 2453 -> 0 bytes
.../src/main/java/media/information_48x48.png | Bin 4102 -> 0 bytes
.../src/main/java/media/question_48x48.png | Bin 3857 -> 0 bytes
.../src/main/java/media/sign_warning_48x48.png | Bin 2988 -> 0 bytes
.../schema-import/src/main/java/media/style.css | 134 --
.../src/main/java/media/text_tree_48x48.png | Bin 2567 -> 0 bytes
.../ignite/schema/generator/CodeGenerator.java | 17 +-
.../schema/generator/ConfirmOverride.java | 42 +
.../ignite/schema/generator/XmlGenerator.java | 13 +-
.../ignite/schema/model/PojoDescriptor.java | 34 +-
.../apache/ignite/schema/model/PojoField.java | 62 +-
.../schema/parser/DatabaseMetadataParser.java | 5 +-
.../ignite/schema/ui/ConfirmCallable.java | 81 -
.../org/apache/ignite/schema/ui/Controls.java | 643 -------
.../org/apache/ignite/schema/ui/GridPaneEx.java | 177 --
.../org/apache/ignite/schema/ui/MessageBox.java | 261 ---
.../apache/ignite/schema/ui/ModalDialog.java | 50 -
.../ignite/schema/ui/SchemaImportApp.java | 1764 -----------------
.../ignite/schema/ui/TextColumnValidator.java | 32 -
.../ignite/schema/utils/ChangeListener.java | 30 +
.../apache/ignite/schema/utils/Property.java | 84 +
.../schema/test/AbstractSchemaImportTest.java | 134 --
.../test/generator/CodeGeneratorTest.java | 70 -
.../schema/test/generator/XmlGeneratorTest.java | 50 -
.../apache/ignite/schema/test/model/Objects.txt | 502 -----
.../ignite/schema/test/model/ObjectsKey.txt | 96 -
.../ignite/schema/test/model/Primitives.txt | 506 -----
.../ignite/schema/test/model/PrimitivesKey.txt | 96 -
.../schema/test/model/ignite-type-metadata.xml | 362 ----
.../test/parser/DbMetadataParserTest.java | 118 --
.../testsuites/IgniteSchemaImportTestSuite.java | 41 -
71 files changed, 5639 insertions(+), 5221 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import-ui/pom.xml
----------------------------------------------------------------------
diff --git a/modules/schema-import-ui/pom.xml b/modules/schema-import-ui/pom.xml
new file mode 100644
index 0000000..c56d050
--- /dev/null
+++ b/modules/schema-import-ui/pom.xml
@@ -0,0 +1,110 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You 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.
+-->
+
+<!--
+ POM file.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-parent</artifactId>
+ <version>1</version>
+ <relativePath>../../parent</relativePath>
+ </parent>
+
+ <artifactId>ignite-schema-import-ui</artifactId>
+ <version>1.4.1-SNAPSHOT</version>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.ignite</groupId>
+ <artifactId>ignite-schema-import</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.h2database</groupId>
+ <artifactId>h2</artifactId>
+ <version>1.3.175</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/java</directory>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </resource>
+ </resources>
+
+ <testResources>
+ <testResource>
+ <directory>src/test/java</directory>
+ <excludes>
+ <exclude>**/*.java</exclude>
+ </excludes>
+ </testResource>
+ </testResources>
+
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifest>
+ <mainClass>org.apache.ignite.schema.ui.SchemaImportApp</mainClass>
+ </manifest>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <profiles>
+ <profile>
+ <id>schema-import</id>
+ <activation>
+ <file>
+ <exists>${java.home}/lib/jfxrt.jar</exists>
+ </file>
+ </activation>
+ <dependencies>
+ <dependency>
+ <groupId>javafx</groupId>
+ <artifactId>jfxrt</artifactId>
+ <version>${java.version}</version>
+ <scope>system</scope>
+ <systemPath>${java.home}/lib/jfxrt.jar</systemPath>
+ </dependency>
+ </dependencies>
+ </profile>
+ </profiles>
+</project>
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import-ui/src/main/java/media/data_connection_48x48.png
----------------------------------------------------------------------
diff --git a/modules/schema-import-ui/src/main/java/media/data_connection_48x48.png b/modules/schema-import-ui/src/main/java/media/data_connection_48x48.png
new file mode 100644
index 0000000..475f219
Binary files /dev/null and b/modules/schema-import-ui/src/main/java/media/data_connection_48x48.png differ
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import-ui/src/main/java/media/error_48x48.png
----------------------------------------------------------------------
diff --git a/modules/schema-import-ui/src/main/java/media/error_48x48.png b/modules/schema-import-ui/src/main/java/media/error_48x48.png
new file mode 100644
index 0000000..e341b8a
Binary files /dev/null and b/modules/schema-import-ui/src/main/java/media/error_48x48.png differ
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import-ui/src/main/java/media/ignite_128x128.png
----------------------------------------------------------------------
diff --git a/modules/schema-import-ui/src/main/java/media/ignite_128x128.png b/modules/schema-import-ui/src/main/java/media/ignite_128x128.png
new file mode 100644
index 0000000..d99a83c
Binary files /dev/null and b/modules/schema-import-ui/src/main/java/media/ignite_128x128.png differ
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import-ui/src/main/java/media/ignite_16x16.png
----------------------------------------------------------------------
diff --git a/modules/schema-import-ui/src/main/java/media/ignite_16x16.png b/modules/schema-import-ui/src/main/java/media/ignite_16x16.png
new file mode 100644
index 0000000..3e07d33
Binary files /dev/null and b/modules/schema-import-ui/src/main/java/media/ignite_16x16.png differ
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import-ui/src/main/java/media/ignite_24x24.png
----------------------------------------------------------------------
diff --git a/modules/schema-import-ui/src/main/java/media/ignite_24x24.png b/modules/schema-import-ui/src/main/java/media/ignite_24x24.png
new file mode 100644
index 0000000..8da5c97
Binary files /dev/null and b/modules/schema-import-ui/src/main/java/media/ignite_24x24.png differ
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import-ui/src/main/java/media/ignite_32x32.png
----------------------------------------------------------------------
diff --git a/modules/schema-import-ui/src/main/java/media/ignite_32x32.png b/modules/schema-import-ui/src/main/java/media/ignite_32x32.png
new file mode 100644
index 0000000..c6c6819
Binary files /dev/null and b/modules/schema-import-ui/src/main/java/media/ignite_32x32.png differ
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import-ui/src/main/java/media/ignite_48x48.png
----------------------------------------------------------------------
diff --git a/modules/schema-import-ui/src/main/java/media/ignite_48x48.png b/modules/schema-import-ui/src/main/java/media/ignite_48x48.png
new file mode 100644
index 0000000..5b684cc
Binary files /dev/null and b/modules/schema-import-ui/src/main/java/media/ignite_48x48.png differ
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import-ui/src/main/java/media/ignite_64x64.png
----------------------------------------------------------------------
diff --git a/modules/schema-import-ui/src/main/java/media/ignite_64x64.png b/modules/schema-import-ui/src/main/java/media/ignite_64x64.png
new file mode 100644
index 0000000..c1d348b
Binary files /dev/null and b/modules/schema-import-ui/src/main/java/media/ignite_64x64.png differ
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import-ui/src/main/java/media/information_48x48.png
----------------------------------------------------------------------
diff --git a/modules/schema-import-ui/src/main/java/media/information_48x48.png b/modules/schema-import-ui/src/main/java/media/information_48x48.png
new file mode 100644
index 0000000..8712a1b
Binary files /dev/null and b/modules/schema-import-ui/src/main/java/media/information_48x48.png differ
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import-ui/src/main/java/media/question_48x48.png
----------------------------------------------------------------------
diff --git a/modules/schema-import-ui/src/main/java/media/question_48x48.png b/modules/schema-import-ui/src/main/java/media/question_48x48.png
new file mode 100644
index 0000000..84683f9
Binary files /dev/null and b/modules/schema-import-ui/src/main/java/media/question_48x48.png differ
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import-ui/src/main/java/media/sign_warning_48x48.png
----------------------------------------------------------------------
diff --git a/modules/schema-import-ui/src/main/java/media/sign_warning_48x48.png b/modules/schema-import-ui/src/main/java/media/sign_warning_48x48.png
new file mode 100644
index 0000000..5e7cccd
Binary files /dev/null and b/modules/schema-import-ui/src/main/java/media/sign_warning_48x48.png differ
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import-ui/src/main/java/media/style.css
----------------------------------------------------------------------
diff --git a/modules/schema-import-ui/src/main/java/media/style.css b/modules/schema-import-ui/src/main/java/media/style.css
new file mode 100644
index 0000000..6eee5f9
--- /dev/null
+++ b/modules/schema-import-ui/src/main/java/media/style.css
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+
+.root {
+ -fx-background-color: eeeeee;
+}
+
+.button {
+ -fx-font-size: 14;
+ -fx-focus-color: gray;
+}
+
+.label {
+ -fx-font-size: 14;
+}
+
+.check-box {
+ -fx-font-size: 14;
+ -fx-focus-color: gray;
+}
+
+.combo-box-base {
+ -fx-font-size: 14;
+ -fx-focus-color: gray;
+}
+
+.combo-box-popup .list-view {
+ -fx-font-size : 14;
+}
+
+.text-area {
+ -fx-font-size: 14;
+ -fx-background-color: transparent, transparent, transparent;
+}
+
+.text-area .scroll-pane {
+ -fx-background-color: transparent;
+}
+
+.text-area .scroll-pane .viewport{
+ -fx-background-color: transparent;
+}
+
+.text-area .scroll-pane .content{
+ -fx-background-color: transparent;
+}
+
+.text-area .scroll-bar:vertical:disabled {
+ -fx-opacity: 0;
+}
+
+.text-field {
+ -fx-font-size: 14;
+ -fx-background-color: -fx-text-box-border, -fx-control-inner-background, -fx-control-inner-background;
+}
+
+.text-field:focused {
+ -fx-background-color: -fx-text-box-border, -fx-control-inner-background, -fx-control-inner-background;
+}
+
+.table-view {
+ -fx-focus-color: gray;
+ -fx-font-size: 14;
+}
+
+.table-view .table-row-cell:selected {
+ -fx-background-color: -fx-table-cell-border-color, -fx-cell-hover-color;
+ -fx-background-insets: 0, 0 0 1 0;
+}
+
+.table-view:focused .table-row-cell:selected {
+ -fx-background-color: -fx-focus-color, -fx-cell-focus-inner-border, -fx-selection-bar;
+}
+
+.table-row-cell:empty {
+ -fx-background-color: white;
+}
+
+.table-row-cell:empty .table-cell {
+ -fx-border-width: 0px;
+}
+
+.tooltip {
+ -fx-font-size: 14;
+ -fx-background-radius: 0 0 0 0;
+}
+
+.page-corner {
+ -fx-shape: " ";
+}
+
+.progress-indicator {
+ -fx-progress-color: gray
+}
+
+.split-pane {
+ -fx-background-color: -fx-box-border, eeeeee;
+}
+
+.titled-pane {
+ -fx-font-size: 14;
+}
+
+.titled-pane:focused {
+ -fx-text-fill: -fx-text-base-color;
+}
+
+.titled-pane:focused > .title {
+ -fx-color: eeeeee;
+}
+
+.titled-pane:focused > .title > .arrow-button .arrow {
+ -fx-background-color: black;
+}
+
+#banner {
+ -fx-font-size: 20px;
+ -fx-font-weight: bold;
+ -fx-background-color: white
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import-ui/src/main/java/media/text_tree_48x48.png
----------------------------------------------------------------------
diff --git a/modules/schema-import-ui/src/main/java/media/text_tree_48x48.png b/modules/schema-import-ui/src/main/java/media/text_tree_48x48.png
new file mode 100644
index 0000000..6ca9e65
Binary files /dev/null and b/modules/schema-import-ui/src/main/java/media/text_tree_48x48.png differ
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import-ui/src/main/java/org/apache/ignite/schema/ui/ConfirmCallable.java
----------------------------------------------------------------------
diff --git a/modules/schema-import-ui/src/main/java/org/apache/ignite/schema/ui/ConfirmCallable.java b/modules/schema-import-ui/src/main/java/org/apache/ignite/schema/ui/ConfirmCallable.java
new file mode 100644
index 0000000..92340d0
--- /dev/null
+++ b/modules/schema-import-ui/src/main/java/org/apache/ignite/schema/ui/ConfirmCallable.java
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.ignite.schema.ui;
+
+import javafx.application.*;
+import javafx.stage.*;
+import org.apache.ignite.schema.generator.*;
+
+import java.util.concurrent.*;
+
+import static org.apache.ignite.schema.ui.MessageBox.Result.*;
+
+/**
+ * Callable to ask user for confirmation from non EDT thread.
+ */
+public class ConfirmCallable implements Callable<MessageBox.Result>, ConfirmOverride {
+ /** Owner window. */
+ private final Stage owner;
+
+ /** Message template. */
+ private final String template;
+
+ /** Message to show in confirmation dialog. */
+ private String msg;
+
+ /** User choice. */
+ private MessageBox.Result choice = NO;
+
+ /**
+ * @param owner Owner window.
+ * @param template Message template.
+ */
+ public ConfirmCallable(Stage owner, String template) {
+ this.owner = owner;
+ this.template = template;
+ }
+
+ /** {@inheritDoc} */
+ @Override public MessageBox.Result call() throws Exception {
+ choice = MessageBox.applyToAllChoiceDialog(owner, String.format(template, msg));
+
+ return choice;
+ }
+
+ /**
+ * Execute confirmation in EDT thread.
+ *
+ * @return Confirm result.
+ */
+ public ConfirmOverride.Result confirm(String msg) {
+ this.msg = msg;
+
+ if (choice == YES_TO_ALL)
+ return Result.OVERRIDE;
+
+ if (choice == NO_TO_ALL)
+ return Result.NO;
+
+ FutureTask<MessageBox.Result> fut = new FutureTask<>(this);
+
+ Platform.runLater(fut);
+
+ MessageBox.Result res;
+
+ try {
+ res = fut.get();
+ }
+ catch (Exception ignored) {
+ return Result.NO;
+ }
+
+ switch (res) {
+ case CANCEL:
+ return Result.CANCEL;
+
+ case NO:
+ case NO_TO_ALL:
+ return Result.NO;
+
+ case YES:
+ case YES_TO_ALL:
+ return Result.OVERRIDE;
+
+ default:
+ throw new RuntimeException("Unknown result: " + res);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import-ui/src/main/java/org/apache/ignite/schema/ui/Controls.java
----------------------------------------------------------------------
diff --git a/modules/schema-import-ui/src/main/java/org/apache/ignite/schema/ui/Controls.java b/modules/schema-import-ui/src/main/java/org/apache/ignite/schema/ui/Controls.java
new file mode 100644
index 0000000..075a84b
--- /dev/null
+++ b/modules/schema-import-ui/src/main/java/org/apache/ignite/schema/ui/Controls.java
@@ -0,0 +1,692 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.ignite.schema.ui;
+
+import com.sun.javafx.scene.control.skin.*;
+import javafx.application.*;
+import javafx.beans.value.ChangeListener;
+import javafx.beans.value.*;
+import javafx.collections.*;
+import javafx.event.*;
+import javafx.geometry.*;
+import javafx.scene.*;
+import javafx.scene.control.*;
+import javafx.scene.control.cell.*;
+import javafx.scene.image.*;
+import javafx.scene.input.*;
+import javafx.scene.layout.*;
+import javafx.scene.text.*;
+import javafx.util.*;
+import javafx.util.converter.*;
+import org.apache.ignite.schema.utils.*;
+
+import java.lang.reflect.*;
+
+/**
+ * Utility class to create controls.
+ */
+public class Controls {
+ /** */
+ public static final Insets DFLT_PADDING = new Insets(10, 10, 10, 10);
+
+ /**
+ * Create scene with predefined style.
+ *
+ * @param root The root node of the scene graph.
+ * @return New {@code Scene} instance.
+ */
+ public static Scene scene(Parent root) {
+ Scene scene = new Scene(root);
+
+ scene.getStylesheets().add("media/style.css");
+
+ return scene;
+ }
+
+ /**
+ * Create grid pane with default padding.
+ *
+ * @param top Top padding
+ * @param right Right padding.
+ * @param bottom Bottom padding.
+ * @param left Left padding.
+ * @return New {@code GridPaneEx} instance.
+ */
+ public static GridPaneEx paneEx(double top, double right, double bottom, double left) {
+ GridPaneEx paneEx = new GridPaneEx();
+
+ paneEx.setPadding(new Insets(top, right, bottom, left));
+
+ return paneEx;
+ }
+
+ /**
+ * Create new {@code HBox} with default padding.
+ *
+ * @param spacing Amount of horizontal space between each child.
+ * @param dfltPadding If {@code true} than set default padding for pane.
+ * @return New {@code HBox} instance.
+ */
+ public static HBox hBox(int spacing, boolean dfltPadding) {
+ HBox hb = new HBox(spacing);
+
+ if (dfltPadding)
+ hb.setPadding(DFLT_PADDING);
+
+ return hb;
+ }
+
+ /**
+ * Create new {@code HBox} with default padding and add controls.
+ *
+ * @param spacing Amount of horizontal space between each child.
+ * @param dfltPadding If {@code true} than set default padding for pane.
+ * @param controls Controls to add.
+ * @return New {@code HBox} instance.
+ */
+ public static HBox hBox(int spacing, boolean dfltPadding, Node... controls) {
+ HBox hb = hBox(spacing, dfltPadding);
+
+ hb.getChildren().addAll(controls);
+
+ return hb;
+ }
+
+ /**
+ * Create new {@code VBox} with default padding.
+ *
+ * @param spacing Amount of horizontal space between each child.
+ * @return New {@code VBox} instance.
+ */
+ public static VBox vBox(int spacing) {
+ VBox vb = new VBox(spacing);
+
+ vb.setPadding(DFLT_PADDING);
+
+ return vb;
+ }
+
+ /**
+ * Create new {@code VBox} with default padding and add controls.
+ *
+ * @param spacing Amount of horizontal space between each child.
+ * @param controls Controls to add.
+ * @return New {@code VBox} instance.
+ */
+ public static VBox vBox(int spacing, Node... controls) {
+ VBox vb = vBox(spacing);
+
+ vb.getChildren().addAll(controls);
+
+ return vb;
+ }
+
+ /**
+ * Create stack pane.
+ *
+ * @param controls Controls to add.
+ * @return New {@code StackPane} instance.
+ */
+ public static StackPane stackPane(Node... controls) {
+ StackPane sp = new StackPane();
+
+ sp.getChildren().addAll(controls);
+
+ return sp;
+ }
+
+ /**
+ * Create border pane.
+ *
+ * @param top Optional top control.
+ * @param center Optional center control.
+ * @param bottom Optional bottom control.
+ * @param left Optional left control.
+ * @param right Optional right control.
+ * @return New {@code BorderPane} instance.
+ */
+ public static BorderPane borderPane(Node top, Node center, Node bottom, Node left, Node right) {
+ BorderPane bp = new BorderPane();
+
+ bp.setTop(top);
+ bp.setCenter(center);
+ bp.setBottom(bottom);
+ bp.setLeft(left);
+ bp.setRight(right);
+
+ return bp;
+ }
+
+ /**
+ * Sets control tooltip if needed.
+ *
+ * @param ctrl Target control.
+ * @param tip Tooltip text.
+ * @return Control itself for method chaining.
+ */
+ public static <T extends Control> T tooltip(T ctrl, String tip) {
+ if (!tip.isEmpty())
+ ctrl.setTooltip(new Tooltip(tip));
+
+ return ctrl;
+ }
+
+ /**
+ * Create label.
+ *
+ * @param text Label text.
+ * @return New {@code Label} instance.
+ */
+ public static Label label(String text) {
+ return new Label(text);
+ }
+
+ /**
+ * Create button with text only.
+ *
+ * @param text Button text.
+ * @param tip Tooltip text.
+ * @param onAct Button action.
+ * @return New {@code Button} instance.
+ */
+ public static Button button(String text, String tip, EventHandler<ActionEvent> onAct) {
+ Button btn = new Button(text);
+
+ btn.setOnAction(onAct);
+
+ tooltip(btn, tip);
+
+ return btn;
+ }
+
+ /**
+ * Create button with icon only.
+ *
+ * @param icon Button icon.
+ * @param tip Tooltip text.
+ * @param onAct Button action.
+ * @return New {@code Button} instance.
+ */
+ public static Button button(ImageView icon, String tip, EventHandler<ActionEvent> onAct) {
+ Button btn = new Button();
+
+ btn.setGraphic(icon);
+ btn.setOnAction(onAct);
+
+ tooltip(btn, tip);
+
+ return btn;
+ }
+
+ /**
+ * Create pane with buttons.
+ *
+ * @param alignment Alignment of buttons.
+ * @param dfltPadding If {@code true} than set default padding for pane.
+ * @param btns Buttons that will be added to pane.
+ * @return New {@code HBox} instance with buttons.
+ */
+ public static Pane buttonsPane(Pos alignment, boolean dfltPadding, Button... btns) {
+ HBox hb = hBox(10, dfltPadding, btns);
+
+ hb.setAlignment(alignment);
+
+ return hb;
+ }
+
+ /**
+ * Create checkbox.
+ *
+ * @param text Checkbox text.
+ * @param tip Tooltip tex.
+ * @param sel Checkbox selected state.
+ * @return New {@code Checkbox} instance.
+ */
+ public static CheckBox checkBox(String text, String tip, boolean sel) {
+ CheckBox ch = new CheckBox(text);
+
+ ch.setSelected(sel);
+
+ tooltip(ch, tip);
+
+ return ch;
+ }
+
+ /**
+ * Create text field.
+ *
+ * @param tip Tooltip text.
+ * @return New {@code TextField} instance.
+ */
+ public static TextField textField(String tip) {
+ TextField tf = new TextField();
+
+ tooltip(tf, tip);
+
+ return tf;
+ }
+
+ /**
+ * Create static text.
+ *
+ * @param text Text to show.
+ * @param wrap Text wrapping width.
+ * @return New {@code Text} instance.
+ */
+ public static Text text(String text, int wrap) {
+ Text t = new Text(text);
+
+ t.setFont(new Font(14));
+
+ if (wrap > 0)
+ t.setWrappingWidth(wrap);
+
+ return t;
+ }
+
+ /**
+ * Create password field.
+ *
+ * @param tip Tooltip text.
+ * @return New {@code PasswordField} instance.
+ */
+ public static PasswordField passwordField(String tip) {
+ PasswordField pf = new PasswordField();
+
+ tooltip(pf, tip);
+
+ return pf;
+ }
+
+ /**
+ * Create combo box.
+ *
+ * @param tip Tooltip text.
+ * @param items Combo box items.
+ * @return New {@code ComboBox} instance.
+ */
+ public static <T> ComboBox<T> comboBox(String tip, T... items) {
+ ComboBox<T> cb = new ComboBox<>(FXCollections.observableArrayList(items));
+
+ cb.setMaxWidth(Double.MAX_VALUE);
+ cb.getSelectionModel().select(0);
+
+ tooltip(cb, tip);
+
+ return cb;
+ }
+
+ /**
+ * Create split pane for provided nodes.
+ *
+ * @param node1 First node.
+ * @param node2 Second node.
+ * @param pos Initial divider position.
+ * @return New {@code SplitPane} instance.
+ */
+ public static SplitPane splitPane(Node node1, Node node2, double pos) {
+ SplitPane sp = new SplitPane();
+
+ sp.setOrientation(Orientation.VERTICAL);
+ sp.getItems().addAll(node1, node2);
+ sp.setDividerPosition(0, pos);
+
+ return sp;
+ }
+
+ /**
+ * Create titled pane.
+ *
+ * @param title Title.
+ * @param node Node.
+ * @return New {@code TitledPane} instance.
+ */
+ public static TitledPane titledPane(String title, Node node) {
+ TitledPane tp = new TitledPane(title, node);
+
+ tp.setExpanded(false);
+
+ return tp;
+ }
+
+ /**
+ * Create table column.
+ *
+ * @param colName Column name to display.
+ * @param propName Property name column is bound to.
+ * @param tip Column tooltip text.
+ * @param minWidth The minimum width column is permitted to be resized to.
+ * @param maxWidth The maximum width column is permitted to be resized to.
+ * @param editable {@code true} if column is editable.
+ * @return New {@code TableColumn} instance.
+ */
+ private static <S, T> TableColumn<S, T> tableColumn(String colName, String propName, String tip,
+ int minWidth, int maxWidth, boolean editable) {
+ TableColumn<S, T> col = new TableColumn<>();
+
+ col.setGraphic(tooltip(new Label(colName), tip));
+
+ col.setSortable(false);
+
+ if (minWidth > 0)
+ col.setMinWidth(minWidth);
+
+ if (maxWidth > 0)
+ col.setMaxWidth(maxWidth);
+
+ col.setCellValueFactory(new MyPropertyValueFactory<S, T>(propName));
+
+ col.setEditable(editable);
+
+ return col;
+ }
+
+ /** */
+ private static class MyPropertyValueFactory<S, T> implements Callback<TableColumn.CellDataFeatures<S, T>,
+ ObservableValue<T>> {
+ /** */
+ private final String name;
+
+ /**
+ * @param name Name.
+ */
+ public MyPropertyValueFactory(String name) {
+ this.name = name;
+ }
+
+ /** {@inheritDoc} */
+ @Override public ObservableValue<T> call(TableColumn.CellDataFeatures<S, T> features) {
+ Object val = features.getValue();
+
+ if (val == null)
+ return null;
+
+ Property prop;
+
+ try {
+ Method getter = val.getClass().getMethod(name + "Property");
+
+ getter.setAccessible(true);
+
+ prop = (Property)getter.invoke(val);
+
+ Type type = ((ParameterizedType)getter.getGenericReturnType()).getActualTypeArguments()[0];
+
+ if (type == Boolean.class)
+ return (ObservableValue<T>)JavaFxUtils.booleanProperty(prop);
+
+ if (type == String.class)
+ return (ObservableValue<T>)JavaFxUtils.stringProperty(prop);
+
+ throw new RuntimeException("Unknown field type: " + type);
+ }
+ catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+
+ /**
+ * Create table column.
+ *
+ * @param colName Column name to display.
+ * @param propName Property name column is bound to.
+ * @param tip Column tooltip text.
+ * @return New {@code TableColumn} instance.
+ */
+ public static <S, T> TableColumn<S, T> tableColumn(String colName, String propName, String tip) {
+ return tableColumn(colName, propName, tip, 100, 0, false);
+ }
+
+ /**
+ * Create table column.
+ *
+ * @param colName Column name to display.
+ * @param propName Property name column is bound to.
+ * @param tip Column tooltip text.
+ * @param cellFactory Custom cell factory.
+ * @return New {@code TableColumn} instance.
+ */
+ public static <S, T> TableColumn<S, T> customColumn(String colName, String propName, String tip,
+ Callback<TableColumn<S, T>, TableCell<S, T>> cellFactory) {
+ TableColumn<S, T> col = tableColumn(colName, propName, tip, 100, 0, true);
+
+ col.setCellFactory(cellFactory);
+
+ return col;
+ }
+
+ /**
+ * Create editable boolean table column.
+ *
+ * @param colName Column name to display.
+ * @param propName Property name column is bound to.
+ * @param tip Column tooltip text.
+ * @return New {@code TableColumn} instance.
+ */
+ public static <S> TableColumn<S, Boolean> booleanColumn(String colName, String propName, String tip) {
+ TableColumn<S, Boolean> col = tableColumn(colName, propName, tip, 50, 50, true);
+
+ col.setCellFactory(CheckBoxTableCellEx.<S>cellFactory());
+
+ return col;
+
+ }
+
+ /**
+ * Create editable text table column.
+ *
+ * @param colName Column name to display.
+ * @param propName Property name column is bound to.
+ * @param tip Column tooltip text.
+ * @return New {@code TableColumn} instance.
+ */
+ public static <S> TableColumn<S, String> textColumn(String colName, String propName, String tip,
+ TextColumnValidator<S> validator) {
+ TableColumn<S, String> col = tableColumn(colName, propName, tip, 100, 0, true);
+
+ col.setCellFactory(TextFieldTableCellEx.cellFactory(validator));
+
+ return col;
+ }
+
+ /**
+ * Create table view.
+ *
+ * @param placeholder Text to show if table model is empty.
+ * @param cols Columns to add.
+ * @return New {@code TableView} instance.
+ */
+ public static <S> TableView<S> tableView(String placeholder, TableColumn<S, ?>... cols) {
+ TableView<S> tbl = new TableView<>();
+
+ tbl.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
+ tbl.setEditable(true);
+ tbl.setMinHeight(70);
+ tbl.setPlaceholder(text(placeholder, 0));
+
+ tbl.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
+
+ tbl.getColumns().addAll(cols);
+
+ return tbl;
+ }
+
+ /**
+ * Create progress indicator.
+ *
+ * @param sz Indicator diameter.
+ * @return New {@code ProgressIndicator} instance.
+ */
+ public static ProgressIndicator progressIndicator(int sz) {
+ ProgressIndicator pi = new ProgressIndicator();
+
+ pi.setMaxWidth(sz);
+ pi.setMaxHeight(sz);
+
+ return pi;
+ }
+
+ /**
+ * Create image view.
+ *
+ * @param imgFileName Image filename.
+ * @return New {@code ImageView} instance.
+ */
+ public static ImageView imageView(String imgFileName, int sz) {
+ return new ImageView(image(imgFileName, sz));
+ }
+
+ /**
+ * Gets image by its filename.
+ *
+ * @param imgFileName Image filename.
+ * @return Loaded image.
+ */
+ public static Image image(String imgFileName, int sz) {
+ return new Image(Controls.class.getClassLoader()
+ .getResourceAsStream(String.format("media/%1$s_%2$dx%2$d.png", imgFileName, sz)));
+ }
+
+ /**
+ * Customized checkbox.
+ */
+ private static class CheckBoxTableCellEx<S> extends CheckBoxTableCell<S, Boolean> {
+ /** Creates a ComboBox cell factory for use in TableColumn controls. */
+ public static <S> Callback<TableColumn<S, Boolean>, TableCell<S, Boolean>> cellFactory() {
+ return new Callback<TableColumn<S, Boolean>, TableCell<S, Boolean>>() {
+ @Override public TableCell<S, Boolean> call(TableColumn<S, Boolean> col) {
+ return new CheckBoxTableCellEx<>();
+ }
+ };
+ }
+
+ /**
+ * Default constructor.
+ */
+ private CheckBoxTableCellEx() {
+ setAlignment(Pos.CENTER);
+ }
+ }
+
+ /**
+ * Special table text field cell that commit its content on focus lost.
+ */
+ private static class TextFieldTableCellEx<S> extends TextFieldTableCell<S, String> {
+ /** */
+ private final TextColumnValidator<S> validator;
+ /** */
+ private String curTxt = "";
+
+ /** Row value. */
+ private S rowVal;
+
+ /** Create cell factory. */
+ public static <S> Callback<TableColumn<S, String>, TableCell<S, String>>
+ cellFactory(final TextColumnValidator<S> validator) {
+ return new Callback<TableColumn<S, String>, TableCell<S, String>>() {
+ @Override public TableCell<S, String> call(TableColumn<S, String> col) {
+ return new TextFieldTableCellEx<>(validator);
+ }
+ };
+ }
+
+ /**
+ * Text field cell constructor.
+ *
+ * @param validator Input text validator.
+ */
+ private TextFieldTableCellEx(TextColumnValidator<S> validator) {
+ super(new DefaultStringConverter());
+
+ this.validator = validator;
+ }
+
+ /** {@inheritDoc} */
+ @Override public void startEdit() {
+ String item = getItem();
+
+ if (item == null || item.isEmpty())
+ return;
+
+ super.startEdit();
+
+ rowVal = getTableView().getSelectionModel().getSelectedItem();
+
+ Node g = getGraphic();
+
+ if (g != null) {
+ final TextField tf = (TextField)g;
+
+ curTxt = tf.getText();
+
+ tf.textProperty().addListener(new ChangeListener<String>() {
+ @Override public void changed(ObservableValue<? extends String> val, String oldVal, String newVal) {
+ curTxt = newVal;
+ }
+ });
+
+ tf.setOnKeyPressed(new EventHandler<KeyEvent>() {
+ @Override public void handle(KeyEvent evt) {
+ if (KeyCode.ENTER == evt.getCode() || KeyCode.ESCAPE == evt.getCode())
+ cancelEdit();
+ }
+ });
+
+ tf.setOnKeyReleased(new EventHandler<KeyEvent>() {
+ @Override public void handle(KeyEvent evt) {
+ // No-op to overwrite JavaFX implementation.
+ }
+ });
+
+ // Special hack for editable TextFieldTableCell.
+ // Cancel edit when focus lost from text field, but do not cancel if focus lost to VirtualFlow.
+ tf.focusedProperty().addListener(new ChangeListener<Boolean>() {
+ @Override public void changed(ObservableValue<? extends Boolean> val, Boolean oldVal, Boolean newVal) {
+ Node fo = getScene().getFocusOwner();
+
+ if (!newVal) {
+ if (fo instanceof VirtualFlow) {
+ if (fo.getParent().getParent() != getTableView())
+ cancelEdit();
+ }
+ else
+ cancelEdit();
+ }
+ }
+ });
+
+ Platform.runLater(new Runnable() {
+ @Override public void run() {
+ tf.requestFocus();
+ }
+ });
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void cancelEdit() {
+ boolean editing = isEditing();
+
+ super.cancelEdit();
+
+ if (editing && validator.valid(rowVal, curTxt))
+ updateItem(curTxt, false);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import-ui/src/main/java/org/apache/ignite/schema/ui/GridPaneEx.java
----------------------------------------------------------------------
diff --git a/modules/schema-import-ui/src/main/java/org/apache/ignite/schema/ui/GridPaneEx.java b/modules/schema-import-ui/src/main/java/org/apache/ignite/schema/ui/GridPaneEx.java
new file mode 100644
index 0000000..be1aae9
--- /dev/null
+++ b/modules/schema-import-ui/src/main/java/org/apache/ignite/schema/ui/GridPaneEx.java
@@ -0,0 +1,177 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.ignite.schema.ui;
+
+import javafx.geometry.*;
+import javafx.scene.*;
+import javafx.scene.control.*;
+import javafx.scene.layout.*;
+
+/**
+ * Utility extension of {@code GridPane}.
+ */
+public class GridPaneEx extends GridPane {
+ /** Current column. */
+ private int col;
+
+ /** Current row. */
+ private int row;
+
+ /**
+ * Create pane.
+ */
+ public GridPaneEx() {
+ setAlignment(Pos.TOP_LEFT);
+ setHgap(5);
+ setVgap(10);
+ }
+
+ /**
+ * Add default column.
+ */
+ public void addColumn() {
+ getColumnConstraints().add(new ColumnConstraints());
+ }
+
+ /**
+ * Add column with constraints and horizontal grow priority for the column.
+ *
+ * @param min Column minimum size.
+ * @param pref Column preferred size.
+ * @param max Column max size.
+ * @param hgrow Column horizontal grow priority.
+ */
+ public void addColumn(double min, double pref, double max, Priority hgrow) {
+ ColumnConstraints cc = new ColumnConstraints(min, pref, max);
+
+ cc.setHgrow(hgrow);
+
+ getColumnConstraints().add(cc);
+ }
+
+ /**
+ * Add default row.
+ */
+ public void addRow() {
+ getRowConstraints().add(new RowConstraints());
+ }
+
+ /**
+ * Add default rows.
+ *
+ * @param n Number of rows to add.
+ */
+ public void addRows(int n) {
+ for (int i = 0; i < n; i++)
+ addRow();
+ }
+
+ /**
+ * Add row with constraints and vertical grow priority for the row.
+ *
+ * @param min Row minimum size.
+ * @param pref Row preferred size.
+ * @param max Row max size.
+ * @param vgrow Row vertical grow priority.
+ */
+ public void addRow(double min, double pref, double max, Priority vgrow) {
+ RowConstraints rc = new RowConstraints(min, pref, max);
+
+ rc.setVgrow(vgrow);
+
+ getRowConstraints().add(rc);
+ }
+
+ /**
+ * Wrap to next row.
+ */
+ public void wrap() {
+ col = 0;
+
+ row++;
+ }
+
+ /**
+ * Skip columns.
+ *
+ * @param span How many columns should be skipped.
+ */
+ public void skip(int span) {
+ add(new Label(""), span);
+ }
+
+ /**
+ * Move to next column.
+ */
+ private void nextCol(int span) {
+ col += span;
+
+ if (col >= getColumnConstraints().size())
+ wrap();
+ }
+
+ /**
+ * Add control to grid pane.
+ *
+ * @param ctrl Control to add.
+ * @param span How many columns control should take.
+ * @return Added control.
+ */
+ public <T extends Node> T add(T ctrl, int span) {
+ add(ctrl, col, row, span, 1);
+
+ nextCol(span);
+
+ return ctrl;
+ }
+
+ /**
+ * Add control to grid pane.
+ *
+ * @param ctrl Control to add.
+ * @return Added control.
+ */
+ public <T extends Node> T add(T ctrl) {
+ return add(ctrl, 1);
+ }
+
+ /**
+ * Add control with label.
+ *
+ * @param text Label text.
+ * @param ctrl Control to add.
+ * @param span How many columns control should take.
+ * @return Added control.
+ */
+ public <T extends Node> T addLabeled(String text, T ctrl, int span) {
+ add(new Label(text));
+
+ return add(ctrl, span);
+ }
+
+ /**
+ * Add control with label.
+ *
+ * @param text Label text.
+ * @param ctrl Control to add.
+ * @return Added control.
+ */
+ public <T extends Node> T addLabeled(String text, T ctrl) {
+ return addLabeled(text, ctrl, 1);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import-ui/src/main/java/org/apache/ignite/schema/ui/JavaFxUtils.java
----------------------------------------------------------------------
diff --git a/modules/schema-import-ui/src/main/java/org/apache/ignite/schema/ui/JavaFxUtils.java b/modules/schema-import-ui/src/main/java/org/apache/ignite/schema/ui/JavaFxUtils.java
new file mode 100644
index 0000000..579b649
--- /dev/null
+++ b/modules/schema-import-ui/src/main/java/org/apache/ignite/schema/ui/JavaFxUtils.java
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.ignite.schema.ui;
+
+import javafx.beans.property.*;
+import javafx.beans.value.*;
+
+/**
+ *
+ */
+public class JavaFxUtils {
+ /**
+ * @param prop Property.
+ */
+ public static BooleanProperty booleanProperty(org.apache.ignite.schema.utils.Property<Boolean> prop) {
+ BooleanProperty res = (BooleanProperty)prop.fxProperty();
+
+ if (res == null) {
+ res = new SimpleBooleanProperty(prop.get());
+
+ new Bridge<>(res, prop);
+
+ prop.fxProperty(res);
+ }
+
+ return res;
+ }
+
+ /**
+ * @param prop Property.
+ */
+ public static StringProperty stringProperty(org.apache.ignite.schema.utils.Property<String> prop) {
+ StringProperty res = (StringProperty)prop.fxProperty();
+
+ if (res == null) {
+ res = new SimpleStringProperty(prop.get());
+
+ new Bridge<>(res, prop);
+
+ prop.fxProperty(res);
+ }
+
+ return res;
+ }
+
+ /**
+ *
+ * @param <T>
+ */
+ private static class Bridge<T> implements org.apache.ignite.schema.utils.ChangeListener<T>, ChangeListener<T> {
+ /** */
+ private final Property<T> fxProp;
+
+ /** */
+ private final org.apache.ignite.schema.utils.Property<T> igniteProp;
+
+ /**
+ * @param fxProp Fx property.
+ * @param igniteProp Ignite property.
+ */
+ public Bridge(Property<T> fxProp, org.apache.ignite.schema.utils.Property<T> igniteProp) {
+ this.fxProp = fxProp;
+ this.igniteProp = igniteProp;
+
+ fxProp.addListener(this);
+ igniteProp.addListener(this);
+ }
+
+ /** */
+ private boolean notificationInProgress;
+
+ /** {@inheritDoc} */
+ @Override public void changed(org.apache.ignite.schema.utils.Property<? extends T> prop, T oldVal, T newVal) {
+ if (notificationInProgress)
+ return;
+
+ notificationInProgress = true;
+
+ try {
+ assert prop == igniteProp;
+
+ fxProp.setValue(newVal);
+ }
+ finally {
+ notificationInProgress = false;
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override public void changed(ObservableValue<? extends T> prop, T oldVal, T newVal) {
+ if (notificationInProgress)
+ return;
+
+ notificationInProgress = true;
+
+ try {
+ assert prop == fxProp;
+
+ igniteProp.set(newVal);
+ }
+ finally {
+ notificationInProgress = false;
+ }
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import-ui/src/main/java/org/apache/ignite/schema/ui/MessageBox.java
----------------------------------------------------------------------
diff --git a/modules/schema-import-ui/src/main/java/org/apache/ignite/schema/ui/MessageBox.java b/modules/schema-import-ui/src/main/java/org/apache/ignite/schema/ui/MessageBox.java
new file mode 100644
index 0000000..7daf69f
--- /dev/null
+++ b/modules/schema-import-ui/src/main/java/org/apache/ignite/schema/ui/MessageBox.java
@@ -0,0 +1,261 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.ignite.schema.ui;
+
+import javafx.beans.value.*;
+import javafx.event.*;
+import javafx.geometry.*;
+import javafx.scene.control.*;
+import javafx.scene.layout.*;
+import javafx.stage.*;
+
+import java.util.logging.*;
+
+import static org.apache.ignite.schema.ui.Controls.*;
+
+/**
+ * Message box functionality.
+ */
+public class MessageBox extends ModalDialog {
+ /** Logger. */
+ private static final Logger log = Logger.getLogger(MessageBox.class.getName());
+
+ /** Message box type. */
+ private enum MessageType {
+ /** Information. */
+ INFO,
+ /** Warning. */
+ WARN,
+ /** Error. */
+ ERROR,
+ /** Confirm. */
+ CONFIRM,
+ /** Confirm with cancel option. */
+ CANCELLABLE_CONFIRM
+ }
+
+ /** Message box type. */
+ public enum Result {
+ /** Return value if YES is chosen. */
+ YES,
+ /** Return value if YES_TO_ALL is chosen. */
+ YES_TO_ALL,
+ /** Return value if NO is chosen. */
+ NO,
+ /** Return value if NO_TO_ALL is chosen. */
+ NO_TO_ALL,
+ /** Return value if CANCEL is chosen. */
+ CANCEL
+ }
+
+ /** Dialog result. */
+ private Result res = Result.CANCEL;
+
+ /**
+ * Create message box.
+ *
+ * @param owner Owner window.
+ * @param type Message box type.
+ * @param msg Message to show.
+ * @param applyToAll {@code true} if "Apply to all" check box should be displayed.
+ */
+ private MessageBox(Stage owner, MessageType type, String msg, final boolean applyToAll) {
+ super(owner, 480, 180);
+
+ String title;
+ String iconFile;
+
+ switch (type) {
+ case WARN:
+ title = "Warning";
+ iconFile = "sign_warning";
+ break;
+
+ case ERROR:
+ title = "Error";
+ iconFile = "error";
+ break;
+
+ case CONFIRM:
+ case CANCELLABLE_CONFIRM:
+ title = "Confirmation";
+ iconFile = "question";
+ break;
+
+ default:
+ title = "Information";
+ iconFile = "information";
+ break;
+ }
+
+ setTitle(title);
+ initStyle(StageStyle.UTILITY);
+ initModality(Modality.APPLICATION_MODAL);
+ initOwner(owner);
+ setResizable(false);
+
+ GridPaneEx contentPnl = paneEx(10, 10, 0, 10);
+
+ contentPnl.addColumn();
+ contentPnl.addColumn(100, 100, Double.MAX_VALUE, Priority.ALWAYS);
+
+ contentPnl.add(hBox(0, true, imageView(iconFile, 48)));
+
+ final TextArea ta = new TextArea(msg);
+ ta.setEditable(false);
+ ta.setWrapText(true);
+ ta.setFocusTraversable(false);
+
+ contentPnl.add(ta);
+
+ // Workaround for vertical scrollbar.
+ if (msg.length() < 100 && msg.split("\r\n|\r|\n").length < 4)
+ showingProperty().addListener(new ChangeListener<Boolean>() {
+ @Override public void changed(ObservableValue<? extends Boolean> val, Boolean oldVal, Boolean newVal) {
+ if (newVal) {
+ ScrollBar scrollBar = (ScrollBar)ta.lookup(".scroll-bar:vertical");
+
+ if (scrollBar != null)
+ scrollBar.setDisable(true);
+ }
+ }
+ });
+
+ final CheckBox applyToAllCh = checkBox("Apply to all", "", false);
+
+ if (applyToAll) {
+ contentPnl.skip(1);
+ contentPnl.add(applyToAllCh);
+ }
+
+ HBox btns = hBox(10, true);
+ btns.setAlignment(Pos.CENTER);
+
+ if (MessageType.CONFIRM == type || MessageType.CANCELLABLE_CONFIRM == type) {
+ res = Result.NO;
+
+ btns.getChildren().addAll(
+ button("Yes", "Approve the request", new EventHandler<ActionEvent>() {
+ @Override public void handle(ActionEvent e) {
+ res = applyToAll && applyToAllCh.isSelected() ? Result.YES_TO_ALL : Result.YES;
+
+ close();
+ }
+ }),
+ button("No", "Reject the request", new EventHandler<ActionEvent>() {
+ @Override public void handle(ActionEvent e) {
+ res = applyToAll && applyToAllCh.isSelected() ? Result.NO_TO_ALL : Result.NO;
+
+ close();
+ }
+ }));
+
+ if (MessageType.CANCELLABLE_CONFIRM == type)
+ btns.getChildren().addAll(
+ button("Cancel", "Cancel the request", new EventHandler<ActionEvent>() {
+ @Override public void handle(ActionEvent e) {
+ res = Result.CANCEL;
+
+ close();
+ }
+ }));
+ }
+ else
+ btns.getChildren().add(button("OK", "Close dialog", new EventHandler<ActionEvent>() {
+ @Override public void handle(ActionEvent e) {
+ close();
+ }
+ }));
+
+ setScene(scene(borderPane(null, contentPnl, btns, null, null)));
+ }
+
+ /**
+ * Show message in modal dialog.
+ *
+ * @param owner Owner window.
+ * @param type Message box type.
+ * @param msg Message to show.
+ * @param applyToAll {@code true} if "Apply to all" check box should be displayed.
+ * @return Option selected by the user.
+ */
+ private static Result showDialog(Stage owner, MessageType type, String msg, boolean applyToAll) {
+ MessageBox dlg = new MessageBox(owner, type, msg, applyToAll);
+
+ dlg.showModal();
+
+ return dlg.res;
+ }
+
+ /**
+ * Show confirmation dialog.
+ *
+ * @param owner Owner window.
+ * @param msg Message to show.
+ * @return {@code true} If user confirm.
+ */
+ public static boolean confirmDialog(Stage owner, String msg) {
+ return showDialog(owner, MessageType.CONFIRM, msg, false) == Result.YES;
+ }
+
+ /**
+ * Show confirmation dialog.
+ *
+ * @param owner Owner window.
+ * @param msg Message to show.
+ * @return User confirmation result.
+ */
+ public static Result applyToAllChoiceDialog(Stage owner, String msg) {
+ return showDialog(owner, MessageType.CANCELLABLE_CONFIRM, msg, true);
+ }
+
+ /**
+ * Show information dialog.
+ *
+ * @param owner Owner window.
+ * @param msg Message to show.
+ */
+ public static void informationDialog(Stage owner, String msg) {
+ showDialog(owner, MessageType.INFO, msg, false);
+ }
+
+ /**
+ * Show warning dialog.
+ *
+ * @param owner Owner window.
+ * @param msg Message to show.
+ */
+ public static void warningDialog(Stage owner, String msg) {
+ showDialog(owner, MessageType.WARN, msg, false);
+ }
+
+ /**
+ * Show error dialog.
+ *
+ * @param owner Owner window.
+ * @param msg Error message to show.
+ * @param e Optional exception to show.
+ */
+ public static void errorDialog(Stage owner, String msg, Throwable e) {
+ log.log(Level.SEVERE, msg, e);
+
+ String exMsg = e != null ? (e.getMessage() != null ? e.getMessage() : e.getClass().getName()) : null;
+
+ showDialog(owner, MessageType.ERROR, exMsg != null ? msg + "\n" + exMsg : msg, false);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/e8d71b55/modules/schema-import-ui/src/main/java/org/apache/ignite/schema/ui/ModalDialog.java
----------------------------------------------------------------------
diff --git a/modules/schema-import-ui/src/main/java/org/apache/ignite/schema/ui/ModalDialog.java b/modules/schema-import-ui/src/main/java/org/apache/ignite/schema/ui/ModalDialog.java
new file mode 100644
index 0000000..6d0acb7
--- /dev/null
+++ b/modules/schema-import-ui/src/main/java/org/apache/ignite/schema/ui/ModalDialog.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.apache.ignite.schema.ui;
+
+import javafx.stage.*;
+
+/**
+ * Abstract base modal dialog.
+ */
+public abstract class ModalDialog extends Stage {
+ /** Owner window. */
+ protected final Stage owner;
+
+ /**
+ * @param owner Owner window.
+ * @param width Window width.
+ * @param height Window height.
+ */
+ protected ModalDialog(Stage owner, int width, int height) {
+ this.owner = owner;
+
+ this.setWidth(width);
+ this.setHeight(height);
+ }
+
+ /**
+ * Show modal dialog.
+ */
+ protected void showModal() {
+ setX(owner.getX() + owner.getWidth() / 2 - getWidth() / 2);
+ setY(owner.getY() + owner.getHeight() / 2 - getHeight() / 2);
+
+ showAndWait();
+ }
+}