├── .gitignore
├── .travis.yml
├── CHANGELOG.md
├── LICENSE
├── OSS_Licenses.md
├── README.md
├── images
├── diff.png
├── screenshot-1.png
├── screenshot-2.png
└── visualdiff.png
├── pom.xml
├── src
├── assembly
│ └── zip.xml
├── main
│ ├── java
│ │ └── org
│ │ │ └── pentaho
│ │ │ ├── di
│ │ │ ├── git
│ │ │ │ └── spoon
│ │ │ │ │ ├── DrawDiffOnJobEntryExtensionPoint.java
│ │ │ │ │ ├── DrawDiffOnStepExtensionPoint.java
│ │ │ │ │ ├── GitController.java
│ │ │ │ │ ├── GitPerspective.java
│ │ │ │ │ ├── GitSpoonMenuController.java
│ │ │ │ │ ├── GitSpoonPlugin.java
│ │ │ │ │ ├── PdiDiff.java
│ │ │ │ │ ├── dialog
│ │ │ │ │ ├── CloneRepositoryDialog.java
│ │ │ │ │ ├── DeleteBranchDialog.java
│ │ │ │ │ ├── EditRepositoryDialog.java
│ │ │ │ │ ├── MergeBranchDialog.java
│ │ │ │ │ └── UsernamePasswordDialog.java
│ │ │ │ │ └── model
│ │ │ │ │ ├── GitRepository.java
│ │ │ │ │ ├── IVCS.java
│ │ │ │ │ ├── SVN.java
│ │ │ │ │ ├── UIFile.java
│ │ │ │ │ ├── UIGit.java
│ │ │ │ │ └── VCS.java
│ │ │ ├── repository
│ │ │ │ └── pur
│ │ │ │ │ └── PurObjectRevision.java
│ │ │ └── ui
│ │ │ │ └── repository
│ │ │ │ └── pur
│ │ │ │ └── repositoryexplorer
│ │ │ │ └── model
│ │ │ │ ├── UIRepositoryObjectRevision.java
│ │ │ │ └── UIRepositoryObjectRevisions.java
│ │ │ └── ui
│ │ │ └── xul
│ │ │ └── util
│ │ │ └── XulDialogLambdaCallback.java
│ └── resources
│ │ └── org
│ │ └── pentaho
│ │ └── di
│ │ └── git
│ │ └── spoon
│ │ ├── images
│ │ ├── added.png
│ │ ├── added.svg
│ │ ├── branch.png
│ │ ├── branch.svg
│ │ ├── changed.png
│ │ ├── changed.svg
│ │ ├── pull.png
│ │ ├── pull.svg
│ │ ├── push.png
│ │ ├── push.svg
│ │ ├── removed.png
│ │ ├── removed.svg
│ │ ├── repository.png
│ │ ├── repository.svg
│ │ ├── tag.png
│ │ └── tag.svg
│ │ ├── messages
│ │ ├── messages_en_US.properties
│ │ └── messages_ja_JP.properties
│ │ └── xul
│ │ ├── changed-table.xul
│ │ ├── git_perspective.xul
│ │ ├── git_revision-table.xul
│ │ └── git_spoon_overlays.xul
└── test
│ ├── java
│ └── org
│ │ └── pentaho
│ │ └── di
│ │ └── git
│ │ └── spoon
│ │ ├── GitControllerTest.java
│ │ ├── GitSpoonMenuControllerTest.java
│ │ ├── PdiDiffTest.java
│ │ └── model
│ │ ├── GitRepositoryTest.java
│ │ ├── SVNTest.java
│ │ └── UIGitTest.java
│ └── resources
│ ├── r1.kjb
│ ├── r1.ktr
│ ├── r2.kjb
│ └── r2.ktr
└── version.xml
/.gitignore:
--------------------------------------------------------------------------------
1 | /target/
2 | .classpath
3 | .project
4 | .settings/
5 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | branches:
2 | except:
3 | - nightly
4 | language: java
5 | dist: xenial
6 | jdk: openjdk8
7 | cache:
8 | directories:
9 | - "$HOME/.m2"
10 | before_install:
11 | - sudo apt-get install libsvn-java
12 | before_script:
13 | - export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/jni
14 | before_deploy:
15 | - git config --local user.name "Hiromu Hota"
16 | - git config --local user.email "hiromu.hota@hal.hitachi.com"
17 | - export TRAVIS_TAG=nightly
18 | - git tag $TRAVIS_TAG --force
19 | - git push -f https://${GITHUB_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git $TRAVIS_TAG
20 | deploy:
21 | provider: releases
22 | api_key: $GITHUB_TOKEN
23 | file_glob: true
24 | file: target/pdi-git-plugin-*-jar-with-dependencies.zip
25 | skip_cleanup: true
26 | on:
27 | branch: master
28 | name: nightly
29 | body: Auto-build of $TRAVIS_BRANCH ($TRAVIS_COMMIT) by Travis CI on $(date +'%F %T %Z').
30 | prerelease: true
31 | overwrite: true
32 | tag_name: $TRAVIS_TAG
33 | target_commitish: $TRAVIS_COMMIT
34 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Change Log
2 |
3 | ## 1.1.1 - 2020-04-06
4 | ### Security
5 | - [Git] Update JGit to 5.1.13
6 | - [Git] Update Apache HTTPClient
7 |
8 | ## 1.1.0 - 2019-11-27
9 | ### Added
10 | - [Common][#26] Allow other plugins to open a repository by name
11 | - [Common][#27] Allow other plugins to get a list of defined git repositories
12 | - [Common][#23] Allow variables in directory (currently system properties only)
13 |
14 | ### Security
15 | - [Git] Update JGit to 4.11.9
16 | - [Git] Update Apache HTTPClient
17 |
18 | ## 1.0.2 - 2018-12-19
19 | ### Changed
20 | - [Git] Allow pull,merge,rollback even when untracked files exist but no uncommited change
21 |
22 | ### Fixed
23 | - [Git][#20] Use DiffFormatter, which does not detect renames.
24 | - [Common] Rephrase "Dirty working-tree" message and internationalized it
25 | - [Common][#24] Make the repository settings dialog resizable and remember the last position/size (thanks @mattcasters)
26 |
27 | ## 1.0.1 - 2018-04-04
28 | ### Fixed
29 | - [Git] Prevent from making a commit with no files
30 | - [SVN] Fix null pointer exception when invalid SVN repository selected
31 | - [Common][#18] Abort commit when empty commit message
32 |
33 | ## 1.0.0 - 2017-11-11
34 | ### Added
35 | - [SVN] Subversion support
36 | - [Common] "Rollback to here" command to a context menu that rollbacks the working tree (copy) to a previous commit (revision), but does not make a commit.
37 | - [Common] Staging one of conflicted versions (e.g., mine,rXX,rYY in SVN; ours and theris in Git) accepts that version
38 | - [Common] Visual diff between conflicted versions
39 |
40 | ### Changed
41 | - [Git] No need to unstage to discard changes
42 | - [Git] When Pull results in conflicts, do not reset hard (stay in a conflicted state). When conflicts occur, ours and theirs versions are created in the same directory (e.g., test.ktr -> test.ktr.ours and test.ktr.theirs)
43 | - [Common] Rename "Git Project" to "Project" b/c it now supports SVN
44 |
45 | ### Fixed
46 | - Fix a bug that deleted files cannot be staged for a commit
47 |
48 | ## 0.7.3 - 2017-10-17
49 | ### Fixed
50 | - The layout of CloneRepositoryDialog
51 | - Ignore parse error when typing an url
52 | - A bug that a remote branch cannot be checked-out
53 | - A bug that deleting a branch deletes a tag with the same name
54 |
55 | ## 0.7.2 - 2017-09-28
56 | ### Fixed
57 | - Fix a typo bug that tries to push instead of pull when the cached credential does not get authenticated
58 |
59 | ## 0.7.1 - 2017-09-25
60 | ### Fixed
61 | - Fix the bug that visual diff does not work when WORKINGTREE or HEAD is compared
62 |
63 | ## 0.7.0 - 2017-09-19
64 | ### Added
65 | - Tagging feature
66 | - Menuitems to push specific branch/tag
67 | - A context menuitem "Reset to this commit"
68 |
69 | ### Changed
70 | - To avoid accidental loss of work, abort merge/pull if one or more tabs have unsaved changes
71 | - Do not merge (and pull) when the working tree is dirty
72 |
73 | ## 0.6.1 - 2017-09-05
74 | ### Added
75 | - Ask to add a repository when no repository
76 | - Restore Stage/Unstage menuitems in the context menu
77 | - Show a error msg when trying to open/visualdiff a non-Kettle file
78 |
79 | ### Changed
80 | - Switching to Git perspective does not trigger refresh, added refresh button for that
81 | - Cache one pair of username and password (cleared when Spoon terminates)
82 |
83 | ### Removed
84 | - Do not show texual diff upon selecting a revision
85 |
86 | ## 0.6.0 - 2017-08-30
87 | ### Changed
88 | - Diff can now be between arbitrary two commits
89 | - The two tables for unstaged and staged was merged into one table for changed files
90 | - The list of changed files of past commits can now be shown
91 | - An icon is attached to each changed file, representing ADDED, CHANGED, or REMOVED
92 | - Texual/visual diff of past commits can now be obtained
93 |
94 | ## 0.5.1 - 2017-08-22
95 | ### Added
96 | - Add version.xml and OSS_Licenses.md to the assemply zip
97 |
98 | ### Changed
99 | - Save the repository information to metastore after cloneRepoWithUsernamePassword
100 |
101 | ### Fixed
102 | - Show a confirmation dialog (after adding/deleting a repository)
103 | - Prevent the texual diff from getting garbled (e.g., when Japanese)
104 |
105 | ## 0.5.0 - 2017-08-04
106 | ### Added
107 | - A concept of "Git Repository" is introduced. No longer need to open a Kettle file in order to open the corresponding Git repository.
108 |
109 | ### Changed
110 | - Move **Tools > Git** in the menu to the top toolbar in Git perspective
111 |
112 | ## 0.4.1 - 2017-07-20
113 | ### Fixed
114 | - Fix an issue that visual diff of Kettle files in sub-directories is not shown
115 |
116 | ## 0.4.0 - 2017-07-13
117 | ### Added
118 | - "Discard changes in working tree" to the context menu
119 | - setAccelerator for "Data Integration" menu (CTRL+D)
120 | - Visual diff
121 |
122 | ### Fixed
123 | - Improve messages (e.g., "null" -> empty string)
124 |
125 | ## 0.3.2 - 2017-06-22
126 | ### Fixed
127 | - Use Apache HTTP Client instead of Sun HTTP client. This fixes the communication with a remote repository via HTTP(S) in EE.
128 |
129 | ## 0.3.1 - 2017-06-13
130 | ### Added
131 | - Japanese translation
132 | - Users can clone a remote repository (from the menu Tools > Git)
133 | - Users can checkout a particular commit (thru a context menu on a commit)
134 | - Users can create / delete a branch
135 | - Users can merge a branch into the current one
136 |
137 | ## 0.3.0 - 2017-06-05
138 | ### Added
139 | - Users can switch between branches
140 |
141 | ## 0.2.2 - 2017-06-04
142 | ### Added
143 | - Pull/push with username and password
144 |
145 | ## 0.2.1 - 2017-05-31
146 | ### Changed
147 | - Do not show diff when WIP (work-in-progress) is selected for the sake of performance
148 | - Remove the dependency on pdi-pur-plugin and copy the required classes
149 |
150 | ## 0.2.0 - 2017-05-28
151 |
152 | ### Added
153 | - Show diff
154 | - Support VFS (local)
155 |
156 | ## 0.1.0 - 2017-05-17
157 |
158 | ### Added
159 | - Show directory, branch, remote (origin)
160 | - Show commits
161 | - Show unstaged changes and untracked files
162 | - Show staged changes
163 | - Users can edit the directory
164 | - Users can edit the remote (origin only)
165 | - Users can edit the commit message
166 | - Users can edit the author name
167 | - Users can initialize a git repository when not exists
168 | - Users can stage and unstage files
169 | - Users can commit
170 | - Users can pull
171 | - Users can push
172 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright 2017 Hitachi America, Ltd., R&D.
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/OSS_Licenses.md:
--------------------------------------------------------------------------------
1 | This is the list of OSS that pdi-git-plugin depends upon.
2 |
3 | | Component | Version | Home Page | License In Effect |
4 | |-----------|---------|-----------|-------------------|
5 | | JGit | 5.1.13.202002110435-r | https://eclipse.org/jgit/ | [Eclipse Distribution License - v 1.0](https://www.eclipse.org/org/documents/edl-v10.php) |
6 | | JGit Apache Httpclient Based HTTP Support | 5.1.13.202002110435-r | https://eclipse.org/jgit/ | [Eclipse Distribution License - v 1.0](https://www.eclipse.org/org/documents/edl-v10.php) |
7 | | Apache HttpCore | 4.4.13 | https://hc.apache.org/ | [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0) |
8 | | Apache HttpClient | 4.5.12 | https://hc.apache.org/ | [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0) |
9 | | Apache Subversion JavaHL | 1.9.4 | http://subclipse.tigris.org/wiki/JavaHL | [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0) |
10 | | SVNClientAdapter | 1.9.4-2 | http://subclipse.tigris.org/svnClientAdapter.html | [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0) |
11 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Overview
2 |
3 | This plugin allows you to manage versions of local Kettle files without leaving Spoon.
4 | In addition to Git, Subversion is also supported.
5 |
6 | # How to install
7 |
8 | ## 1. PDI Plugin
9 |
10 | ```
11 | $ cd data-integration/plugins
12 | $ unzip pdi-git-plugin-X.X.X-jar-with-dependencies.zip
13 | ```
14 |
15 | To uninstall, just remove the `pdi-git-plugin` folder.
16 |
17 | ## 2. Native SVN libraries (skip if Subversion is not used)
18 |
19 | ### Windows
20 |
21 | 1. Download SlikSVN from [here](https://sliksvn.com/download/) and install it
22 | 2. Copy `C:\Program Files\SlikSvn\bin\libsvnjavahl-1.dll` to `libswt\win64` (64-bit) or to `libswt\win32` (32-bit)
23 |
24 | ### Mac OS X
25 |
26 | ```
27 | brew install subversion --with-java
28 | sudo ln -s /usr/local/lib/libsvnjavahl-1.dylib $JAVA_HOME/jre/lib/
29 | ```
30 |
31 | or follow instructions in [here](http://subclipse.stage.tigris.org/wiki/JavaHL).
32 |
33 | ### Linux (Debian/Ubuntu)
34 |
35 | ```
36 | $ sudo apt-get install libsvn-java
37 | ```
38 |
39 | Append `/usr/lib/x86_64-linux-gnu/jni/` to `LIBPATH` in `spoon.sh` as follows:
40 |
41 | ```
42 | LIBPATH=$LIBPATH:/usr/lib/x86_64-linux-gnu/jni/
43 | export LIBPATH
44 | ```
45 |
46 | Important: For example in Ubuntu 14.04, the version of libsvn-java will be 1.8.8 by default, but it should be 1.9.X.
47 | Ubuntu 16.04 (Xenial) gives you 1.9.3 by default.
48 | See [here](https://tecadmin.net/install-subversion-1-9-on-ubuntu/) how to install 1.9.X to Ubuntu 14.04.
49 |
50 | # How to use
51 |
52 | The Git plugin is provided as a perspective (See [Using Perspectives](https://help.pentaho.com/Documentation/7.1/0L0/0Y0/020)).
53 | **View > Perspectives > Git** takes you to the Git perspective.
54 |
55 | ## Project
56 |
57 | When you switch to the Git perspective, you will be asked to choose a Project out of a list to open.
58 | To add a Project to the list, go to
59 |
60 | **Project > Add**.
61 |
62 | ### Config
63 |
64 | **Config** allows you to configure the opened Project.
65 | Currently, a remote repository named "origin" can be set.
66 |
67 | ## Commit history
68 |
69 | The commit history is listed in reverse chronological order.
70 | Selecting one of the commits shows a list of changed files in that particular commit.
71 | If there are any changes in the working tree, WORKINGTREE is added to the top of the list, where you can see those changes.
72 | Right-click menu on a commit differs between Git and Subversion.
73 |
74 | ### Git
75 |
76 | - **Checkout**: checkout a previous commit (`git checkout `). **Branch > Checkout** to undo this operation.
77 | - **Rollback**: rollback to a previous commit (`git revert --no-commit HEAD..`). **Discard changes** to undo this operation.
78 | - **Reset**: reset HEAD to a previous commit (`git reset --mixed `).
79 |
80 | ### Subversion
81 |
82 | - **Update**: update to a previous revision (`svn update -r )`. **Update** to undo this operation.
83 | - **Rollback**: rollback to a previous commit (`svn merge -r BASE:`). **Discard changes** to undo this operation.
84 |
85 | Use **Checkout/Update** to see how the contents looked like at that commit with the commit history intact.
86 | Use **Rollback** to rollback all the changes. A new commit can be made to persist the rollback.
87 |
88 | ## Working with files
89 |
90 | If you have changed files but WORKINGTREE is not listed, push **Refresh** to reflect the changes in the Git perspective.
91 | Make sure no commit other than WORKINGTREE is selected in the commit history.
92 | Stage changed files by checking the checkbox on the left side of each file, write a good commit message, change the author name if necessary, and finally Commit.
93 |
94 | ### Diff
95 |
96 | Diff information can be obtained texually and visually.
97 | In order to get the right diff you want to see, it is important to understand the followings:
98 |
99 | - When only one commit is selected, the diff will be between the selected commit and its first parent commit.
100 | - When multiple commits are selected, the diff will be between the newest commit and the oldest commit (out of the selected commits).
101 | - When no commit is selected, it is assumed that WORKINGTREE is selected.
102 |
103 | Examples:
104 |
105 | - Only WORKINGTREE is selected: (1)
106 | - Only 456def is selected: (2)
107 | - WORKINGTREE and 456def are selected: (3)
108 | - 123abc and 789ghi are selected: (4)
109 |
110 | You can also see the diff of a specific changed file by selecting one of them, but special rules applie when WORKINGTREE is selected.
111 |
112 | - If only WORKINGTREE is selected AND the selected file is not staged: (5)
113 | - If only WORKINGTREE is selected AND the selected file is staged: (6)
114 | - If another commit is also selected: the diff will be between WORKINGTREE and that another commit
115 |
116 |
117 |
118 | A texual diff will be displayed in the bottom left corner.
119 | Visual diff can be displayed by right-clicking on a changed file, then choose **Visual diff**.
120 | This opens up two tabs in the Data Integration perspective:
121 | one tab shows the difference you see when looking from one commit to another commit, and the other tab shows the other way around.
122 |
123 | The difference is represented by the small icon superimposed on the top-right corner on the steps/job entries like the image below:
124 |
125 |
126 |
127 | Each icon means as follows:
128 |
129 | - : Added
130 | - : Changed
131 | - : Removed
132 |
133 | Note that even just a x-y location change of step/job entry is recognized as a changed one.
134 |
135 | ### Resolve conflicts
136 |
137 | Conflicts happen when merging on a Git repository or when updating on a Subversion repository, but it is difficult to resolve.
138 | Even a very simple conflict like below could be a problem because Spoon won't open such an ill-formed file and editing a Kettle file in a text editor might fail to conform with the Kettle file format.
139 | Instead of resolving conflicts line-by-line, this plugin allows you to resolve them by accepting one out of conflicted versions.
140 |
141 | ```
142 |
143 | ++<<<<<<< HEAD
144 | + 320
145 | + 32
146 | ++=======
147 | + 416
148 | + 80
149 | ++>>>>>>> d003036e19537739415b7a7c0e6ded6238050189
150 | Y
151 |
152 | ```
153 |
154 | When a Kettle file, say `hoge.ktr`, has conflicts, this plugin creates a file for each version.
155 | For a Git repository, `hoge.ktr.ours` and `hoge.ktr.theirs` are created.
156 | For a Subversion repository, `hoge.ktr.mine`, `hoge.ktr.rXX`, and `hoge.ktr.rYY` are created.
157 | To accept your desired version, **Stage** the corresponding file (e.g., `hoge.ktr.ours`), then make a commit.
158 | To abort, **Discard changes** of the conflicted file (e.g., `hoge.ktr`) and (Git-only) **Reset** to the latest commit.
159 |
160 | ## Remote
161 |
162 | **Pull** and **Push** allows you to sync between the opened, local repository and the remote one.
163 | **Pull** and **Push** are equivalent of `git pull` and `git push`, respectively.
164 | Thus, the remote `origin` is the source of Pull and the target of Push unless configured otherwise.
165 | If an error (e.g., merge conflict) happens, the operation will be just cancelled.
166 |
167 | These commands, however, behave differently depending on how `origin` and branches are configured.
168 | Here is an example `.git/config` (see [here](https://git-scm.com/docs/git-config) for more details):
169 |
170 | ```
171 | [branch "master"]
172 | mergeoptions = --no-ff
173 | [remote "origin"]
174 | url = git@example.com:hiromu/testrepo.git
175 | fetch = +refs/heads/*:refs/remotes/origin/*
176 | pushurl = git@example.com:hiromu/testrepo.git
177 | pushurl = git@example.com:hiromu/testrepo2.git
178 | ```
179 |
180 | With this example config, **Pull** uses the non fast-forward mode instead of the default fast-forward mode when merging into `master`, **Push** pushes the current branch to two remotes.
181 |
182 | ### Subversion
183 |
184 | **Push** is disabled because making a commit always pushes changes to the remote repository.
185 | Instead of **Pull**, **Update** is used because of the Subversion terminology.
186 |
187 | ## Branches
188 |
189 | **Branch** has branch operations: **Checkout** switches between branches, **Create / Delete** can create / delete a branch, **Merge** can merge a branch into the current one, **Push** can push a specific branch.
190 |
191 | Switching to a remote branch, say `origin/feature`, gets you in a detached HEAD state.
192 | Use **Branch > Create** to create a local branch, say `feature`, then you will get out of the state.
193 | Collectively, they are equivalent of `git checkout origin/feature` then `git checkout -b feature`.
194 |
195 | ### Subversion
196 |
197 | The typical repository layout is trunk/branches/tags, but currently this plugin has no assumption on the layout.
198 | Thus, the list of branches includes any directories in the repository.
199 | For example, the list may include `/trunk` and `/tags/tag1`.
200 |
201 | ## Tags
202 |
203 | **Tag** has tagging operations similar to
204 | **Branch** except **Merge** is not available.
205 |
206 | ## FAQ
207 |
208 | ### When pushing, I get an "UnknownHostKey" error
209 |
210 | This happens when connecting to the remote repository via SSH.
211 | Please add the host to `~/.ssh/known_hosts` in "ssh-rsa" format instead of "ecdsa-sha2-nistp256" format.
212 |
213 | ### The remote host has been added, but I still get an "UnknownHostKey" error
214 |
215 | This could happen for example when the remote host is Gerrit.
216 | The remote host will be added by executing `$ ssh -p 29418 hiromu@localhost`
217 |
218 | ```
219 | [localhost]:29418 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBAFgEc3BqPijHvVs5KoXLLoBaYtBlW8c8v+wpHEPpKObAF0lSG2qt764zFUE1eRlb/thq8RdNxHQ8l+i4VLTlR8=
220 | ```
221 |
222 | However, JSch (Java library for SSH and used in the Git plugin) prefers **ssh-rsa** over **ecdsa-sha2-nistp256**. Hence, add the remote host like below.
223 |
224 | ```
225 | [localhost]:29418 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDVoiADWyjer2MRMZYAl1Ws/0zj9VyqMgYQxgNL+xcFGz4cO4AZIaL5L6TlNaU5bOF3WeCFgDLMrMioUoWS/0yLE5Q9mXwE2/5V3fEKDgMfuO+xvEGoh/xZb0GqhCeioG63+clqrXM8DvYfqzMmUg8ksPejEYeQpSrTkg0S5RE9AEB/+qvNnipye7M+9Nutr2lSE+GRhRfFNITCXLIAN6ukoKis+xVZgCMXFSnS41PlhQ/mLNJdA1bMxjm1/58iJsdF44iD+cuM/mFvLoAnXeAbOkkj8jyM136vAvO45M5c+a6Z8k4X7Q/CxsZ2IowWfUshg0jsjerzANUPCaoP9VJX
226 | ```
227 |
228 | ### When behind proxy
229 |
230 | Define *System Properties* (not environment variables) like below in spoon.sh
231 |
232 | ```
233 | OPT="$OPT -Dhttp.proxyHost=localhost -Dhttp.proxyPort=3128 -Dhttps.proxyHost=localhost -Dhttps.proxyPort=3128"
234 | ```
235 |
236 | or in Spoon.bat
237 |
238 | ```
239 | set OPT=%OPT% "-Dhttp.proxyHost=10.0.2.2" "-Dhttp.proxyPort=3128" "-Dhttps.proxyHost=10.0.2.2" "-Dhttps.proxyPort=3128"
240 | ```
241 |
242 | The host and port should be replaced according to your proxy server.
243 |
244 | ### I got "407 Proxy Authentication Required" error
245 |
246 | Proxy Authentication is currently not supported.
247 |
248 | ### When I checkedout a remote branch, say *origin/develop*, I ended up being in a HEAD detached state. How can I create a local branch?
249 |
250 | Please create a branch called *develop*, then you will be out of the HEAD detached state.
251 |
252 | ### Auth fail when using publickey authentication
253 |
254 | When an error happens during clone/pull/push, please check the followings:
255 |
256 | - A private key is placed at `~/.ssh/` and the file name is either `identity`, `id_rsa`, or `id_dsa`.
257 | - The private key was created without a passphrase.
258 | - The corresponding public key is registered at the remote repository.
259 | - As of 0.1.54, JSch only supports DSA, RSA, and ECDSA-256. ECDSA-384 and ECDSA-521 do not work (fixed in 0.1.55) and Ed25519 is not supported.
260 |
261 | # How to compile
262 |
263 | ```
264 | mvn clean package
265 | ```
266 |
267 | You may need to include the directory that has the native SVN libraries like below.
268 |
269 | ```
270 | export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/jni
271 | mvn clean package
272 | ```
273 |
--------------------------------------------------------------------------------
/images/diff.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HiromuHota/pdi-git-plugin/ae96274fbda0c1874f1a393adeba87499a5b272d/images/diff.png
--------------------------------------------------------------------------------
/images/screenshot-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HiromuHota/pdi-git-plugin/ae96274fbda0c1874f1a393adeba87499a5b272d/images/screenshot-1.png
--------------------------------------------------------------------------------
/images/screenshot-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HiromuHota/pdi-git-plugin/ae96274fbda0c1874f1a393adeba87499a5b272d/images/screenshot-2.png
--------------------------------------------------------------------------------
/images/visualdiff.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/HiromuHota/pdi-git-plugin/ae96274fbda0c1874f1a393adeba87499a5b272d/images/visualdiff.png
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 |
5 | pentaho-kettle
6 | pdi-git-plugin
7 | 1.1.2-SNAPSHOT
8 | jar
9 |
10 | pdi-git-plugin
11 | http://maven.apache.org
12 |
13 |
14 |
15 |
16 | maven-compiler-plugin
17 | 3.1
18 |
19 | 1.8
20 | 1.8
21 |
22 |
23 |
24 | maven-assembly-plugin
25 | 2.5.3
26 |
27 | src/assembly/zip.xml
28 |
29 |
30 |
31 | create-archive
32 | package
33 |
34 | single
35 |
36 |
37 |
38 |
39 |
40 | org.jacoco
41 | jacoco-maven-plugin
42 | 0.7.9
43 |
44 | ${basedir}/target/coverage-reports/jacoco-unit.exec
45 | ${basedir}/target/coverage-reports/jacoco-unit.exec
46 |
47 |
48 |
49 | jacoco-initialize
50 |
51 | prepare-agent
52 |
53 |
54 |
55 | jacoco-site
56 | package
57 |
58 | report
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 | pentaho-kettle
69 | kettle-ui-swt
70 | ${dependency.kettle.revision}
71 | provided
72 |
73 |
74 | com.googlecode.json-simple
75 | json-simple
76 | 1.1.1
77 | provided
78 |
79 |
80 | org.eclipse.jgit
81 | org.eclipse.jgit
82 | ${dependency.jgit.revision}
83 |
84 |
85 | org.eclipse.jgit
86 | org.eclipse.jgit.http.apache
87 | ${dependency.jgit.revision}
88 |
89 |
90 | org.tigris.svnclientadapter
91 | adapter-base
92 | 1.9.4-2
93 |
94 |
95 | org.tigris.svnclientadapter
96 | adapter-javahl
97 | 1.9.4-2
98 |
99 |
100 | org.apache.subversion
101 | javahl
102 | 1.9.4
103 |
104 |
105 | org.apache.httpcomponents
106 | httpclient
107 | 4.5.12
108 |
109 |
110 | org.apache.httpcomponents
111 | httpcore
112 | 4.4.13
113 |
114 |
115 | commons-io
116 | commons-io
117 | 2.2
118 | provided
119 |
120 |
121 | junit
122 | junit
123 | 4.13.1
124 | test
125 |
126 |
127 | org.eclipse.jgit
128 | org.eclipse.jgit.junit
129 | ${dependency.jgit.revision}
130 | test
131 |
132 |
133 | org.mockito
134 | mockito-all
135 | 1.9.5
136 | test
137 |
138 |
139 |
140 | 7.1.0.0-12
141 | 7.1.0.0-12
142 | 5.1.13.202002110435-r
143 |
144 |
145 |
146 | Pentaho Public Release Repo
147 | http://nexus.pentaho.org/content/groups/omni
148 |
149 |
150 | bintray-maven
151 | https://dl.bintray.com/subclipse/maven
152 |
153 |
154 |
155 |
--------------------------------------------------------------------------------
/src/assembly/zip.xml:
--------------------------------------------------------------------------------
1 |
5 | jar-with-dependencies
6 |
7 | zip
8 |
9 | false
10 |
11 |
12 | ${basedir}
13 | ${project.name}
14 |
15 | version.xml
16 | OSS_Licenses.md
17 |
18 |
19 |
20 | ${project.build.directory}
21 | ${project.name}
22 |
23 | *.jar
24 | version.xml
25 |
26 |
27 |
28 |
29 |
30 | ${project.name}/lib
31 | false
32 | false
33 | runtime
34 | false
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/src/main/java/org/pentaho/di/git/spoon/DrawDiffOnJobEntryExtensionPoint.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Hitachi America, Ltd., R&D.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.pentaho.di.git.spoon;
18 |
19 | import static org.pentaho.di.git.spoon.PdiDiff.*;
20 |
21 | import org.pentaho.di.core.exception.KettleException;
22 | import org.pentaho.di.core.extension.ExtensionPoint;
23 | import org.pentaho.di.core.extension.ExtensionPointInterface;
24 | import org.pentaho.di.core.gui.BasePainter;
25 | import org.pentaho.di.core.gui.GCInterface;
26 | import org.pentaho.di.core.gui.Point;
27 | import org.pentaho.di.core.logging.LogChannelInterface;
28 | import org.pentaho.di.job.JobMeta;
29 | import org.pentaho.di.job.JobPainter;
30 | import org.pentaho.di.ui.core.ConstUI;
31 | import org.pentaho.di.ui.core.PropsUI;
32 |
33 | @ExtensionPoint(
34 | id = "DrawDiffOnJobEntryExtensionPoint",
35 | description = "Draws a marker on top of a job entry if it has some change",
36 | extensionPointId = "JobPainterEnd" )
37 | public class DrawDiffOnJobEntryExtensionPoint implements ExtensionPointInterface {
38 |
39 | @Override
40 | public void callExtensionPoint( LogChannelInterface log, Object object ) throws KettleException {
41 | if ( !( object instanceof JobPainter ) ) {
42 | return;
43 | }
44 | JobPainter painter = (JobPainter) object;
45 | Point offset = painter.getOffset();
46 | GCInterface gc = painter.getGc();
47 | JobMeta jobMeta = painter.getJobMeta();
48 | jobMeta.getJobCopies().stream().filter( je -> je.getAttribute( ATTR_GIT, ATTR_STATUS ) != null )
49 | .forEach( je -> {
50 | if ( jobMeta.getJobversion() == null ? false : jobMeta.getJobversion().startsWith( "git" ) ) {
51 | String status = je.getAttribute( ATTR_GIT, ATTR_STATUS );
52 | Point n = je.getLocation();
53 | String location = "org/pentaho/di/git/spoon/images/";
54 | if ( status.equals( REMOVED ) ) {
55 | location += "removed.svg";
56 | } else if ( status.equals( CHANGED ) ) {
57 | location += "changed.svg";
58 | } else if ( status.equals( ADDED ) ) {
59 | location += "added.svg";
60 | } else { // Unchanged
61 | return;
62 | }
63 | int iconsize = ConstUI.ICON_SIZE;
64 | try {
65 | iconsize = PropsUI.getInstance().getIconSize();
66 | } catch ( Exception e ) {
67 | // Exception when accessed from Carte
68 | }
69 | gc.drawImage( location, getClass().getClassLoader(), ( n.x + iconsize + offset.x ) - ( BasePainter.MINI_ICON_SIZE / 2 ), n.y + offset.y - ( BasePainter.MINI_ICON_SIZE / 2 ) );
70 | } else {
71 | je.getAttributesMap().remove( ATTR_GIT );
72 | }
73 | } );
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/src/main/java/org/pentaho/di/git/spoon/DrawDiffOnStepExtensionPoint.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Hitachi America, Ltd., R&D.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.pentaho.di.git.spoon;
18 |
19 | import static org.pentaho.di.git.spoon.PdiDiff.*;
20 |
21 | import org.pentaho.di.core.exception.KettleException;
22 | import org.pentaho.di.core.extension.ExtensionPoint;
23 | import org.pentaho.di.core.extension.ExtensionPointInterface;
24 | import org.pentaho.di.core.gui.GCInterface;
25 | import org.pentaho.di.core.gui.Point;
26 | import org.pentaho.di.core.gui.BasePainter;
27 | import org.pentaho.di.core.logging.LogChannelInterface;
28 | import org.pentaho.di.trans.TransMeta;
29 | import org.pentaho.di.trans.TransPainter;
30 | import org.pentaho.di.ui.core.ConstUI;
31 | import org.pentaho.di.ui.core.PropsUI;
32 |
33 | @ExtensionPoint(
34 | id = "DrawDiffOnTransExtensionPoint",
35 | description = "Draws a marker on top of a step if it has some change",
36 | extensionPointId = "TransPainterEnd" )
37 | public class DrawDiffOnStepExtensionPoint implements ExtensionPointInterface {
38 |
39 | @Override
40 | public void callExtensionPoint( LogChannelInterface log, Object object ) throws KettleException {
41 | if ( !( object instanceof TransPainter ) ) {
42 | return;
43 | }
44 | TransPainter painter = (TransPainter) object;
45 | Point offset = painter.getOffset();
46 | GCInterface gc = painter.getGc();
47 | TransMeta transMeta = painter.getTransMeta();
48 | transMeta.getSteps().stream().filter( step -> step.getAttribute( ATTR_GIT, ATTR_STATUS ) != null )
49 | .forEach( step -> {
50 | if ( transMeta.getTransversion() == null ? false : transMeta.getTransversion().startsWith( "git" ) ) {
51 | String status = step.getAttribute( ATTR_GIT, ATTR_STATUS );
52 | Point n = step.getLocation();
53 | String location = "org/pentaho/di/git/spoon/images/";
54 | if ( status.equals( REMOVED ) ) {
55 | location += "removed.svg";
56 | } else if ( status.equals( CHANGED ) ) {
57 | location += "changed.svg";
58 | } else if ( status.equals( ADDED ) ) {
59 | location += "added.svg";
60 | } else { // Unchanged
61 | return;
62 | }
63 | int iconsize = ConstUI.ICON_SIZE;
64 | try {
65 | iconsize = PropsUI.getInstance().getIconSize();
66 | } catch ( Exception e ) {
67 | // Exception when accessed from Carte
68 | }
69 | gc.drawImage( location, getClass().getClassLoader(), ( n.x + iconsize + offset.x ) - ( BasePainter.MINI_ICON_SIZE / 2 ), n.y + offset.y - ( BasePainter.MINI_ICON_SIZE / 2 ) );
70 | } else {
71 | step.getAttributesMap().remove( ATTR_GIT );
72 | }
73 | } );
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/src/main/java/org/pentaho/di/git/spoon/GitPerspective.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2017 Hitachi America, Ltd., R&D.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.pentaho.di.git.spoon;
18 |
19 | import java.io.InputStream;
20 | import java.util.List;
21 | import java.util.Locale;
22 | import java.util.ResourceBundle;
23 | import java.util.stream.Stream;
24 |
25 | import org.eclipse.jface.action.ActionContributionItem;
26 | import org.eclipse.jface.action.MenuManager;
27 | import org.eclipse.swt.SWT;
28 | import org.eclipse.swt.SWTException;
29 | import org.eclipse.swt.widgets.Composite;
30 | import org.pentaho.di.core.EngineMetaInterface;
31 | import org.pentaho.di.i18n.BaseMessages;
32 | import org.pentaho.di.ui.spoon.Spoon;
33 | import org.pentaho.di.ui.spoon.SpoonPerspectiveImageProvider;
34 | import org.pentaho.di.ui.spoon.SpoonPerspectiveListener;
35 | import org.pentaho.di.ui.spoon.XulSpoonResourceBundle;
36 | import org.pentaho.di.ui.xul.KettleXulLoader;
37 | import org.pentaho.metastore.api.exceptions.MetaStoreException;
38 | import org.pentaho.ui.xul.XulDomContainer;
39 | import org.pentaho.ui.xul.XulException;
40 | import org.pentaho.ui.xul.XulOverlay;
41 | import org.pentaho.ui.xul.XulRunner;
42 | import org.pentaho.ui.xul.components.XulConfirmBox;
43 | import org.pentaho.ui.xul.containers.XulMenupopup;
44 | import org.pentaho.ui.xul.containers.XulVbox;
45 | import org.pentaho.ui.xul.impl.XulEventHandler;
46 | import org.pentaho.ui.xul.swt.SwtXulRunner;
47 | import org.pentaho.ui.xul.swt.tags.SwtDeck;
48 | import org.pentaho.ui.xul.util.XulDialogCallback.Status;
49 | import org.pentaho.ui.xul.util.XulDialogLambdaCallback;
50 |
51 | public class GitPerspective implements SpoonPerspectiveImageProvider {
52 |
53 | private static Class> PKG = GitPerspective.class;
54 | private ResourceBundle resourceBundle = new XulSpoonResourceBundle( PKG );
55 |
56 | final String PERSPECTIVE_ID = "010-git"; //$NON-NLS-1$
57 | final String PERSPECTIVE_NAME = "gitPerspective"; //$NON-NLS-1$
58 |
59 | private XulDomContainer container;
60 | private GitController controller;
61 | private GitSpoonMenuController gitSpoonMenuController;
62 | private XulVbox box;
63 |
64 | public GitPerspective() throws XulException {
65 | // Loading Xul Document
66 | KettleXulLoader loader = new KettleXulLoader();
67 | loader.registerClassLoader( getClass().getClassLoader() );
68 | container = loader.loadXul( "org/pentaho/di/git/spoon/xul/git_perspective.xul", resourceBundle );
69 |
70 | // Adding Event Handlers
71 | controller = new GitController();
72 | gitSpoonMenuController = new GitSpoonMenuController();
73 | gitSpoonMenuController.setGitController( controller );
74 | container.addEventHandler( controller );
75 | container.addEventHandler( gitSpoonMenuController );
76 |
77 | final XulRunner runner = new SwtXulRunner();
78 | runner.addContainer( container );
79 | runner.initialize(); //calls any onload events
80 |
81 | /*
82 | * To make compatible with webSpoon
83 | * Create a temporary parent for the UI and then call layout().
84 | * A different parent will be assigned to the UI in SpoonPerspectiveManager.PerspectiveManager.performInit().
85 | */
86 | SwtDeck deck = (SwtDeck) Spoon.getInstance().getXulDomContainer().getDocumentRoot().getElementById( "canvas-deck" );
87 | box = deck.createVBoxCard();
88 | getUI().setParent( (Composite) box.getManagedObject() );
89 | getUI().layout();
90 |
91 | /**
92 | * Hack: setAccelerator 'CTRL(CMD) + D' to "Data Integration" menu
93 | */
94 | int mask = 'D';
95 | if ( System.getProperty( "KETTLE_CONTEXT_PATH" ) == null ) { // Spoon
96 | boolean isMac = System.getProperty( "os.name" ).toLowerCase().indexOf( "mac" ) >= 0;
97 | mask += isMac ? SWT.COMMAND : SWT.CTRL;
98 | } else { // webSpoon
99 | mask += SWT.CTRL;
100 | }
101 | int keyCode = mask;
102 | XulMenupopup menuPopup = (XulMenupopup) Spoon.getInstance().getXulDomContainer().getDocumentRoot().getElementById( "view-perspectives-popup" );
103 | MenuManager menuMgr = (MenuManager) menuPopup.getManagedObject();
104 | Stream.of( menuMgr.getItems() )
105 | .map( menu -> ( (ActionContributionItem) menu ).getAction() )
106 | .filter( action -> action.getText().equals( "Data Integration" ) ).findFirst().ifPresent( action -> {
107 | action.setAccelerator( keyCode );
108 | } );
109 | }
110 |
111 | @Override
112 | public String getId() {
113 | return PERSPECTIVE_ID;
114 | }
115 |
116 | public String getName() {
117 | return PERSPECTIVE_NAME;
118 | }
119 |
120 | @Override
121 | public Composite getUI() {
122 | return (Composite) container.getDocumentRoot().getRootElement().getFirstChild().getManagedObject();
123 | }
124 |
125 | @Override
126 | public String getDisplayName( Locale l ) {
127 | return BaseMessages.getString( PKG, "Git.Perspective.perspectiveName" );
128 | }
129 |
130 | @Override
131 | public InputStream getPerspectiveIcon() {
132 | // TODO Auto-generated method stub
133 | return null;
134 | }
135 |
136 | @Override
137 | public void setActive( boolean active ) {
138 | try { // Dispose the temporary parent
139 | ( (Composite) box.getManagedObject() ).dispose();
140 | } catch ( SWTException e ) {
141 | // To nothing
142 | }
143 | if ( active ) {
144 | if ( !controller.isOpen() ) {
145 | try {
146 | if ( gitSpoonMenuController.isRepoEmpty() ) {
147 | XulConfirmBox confirmBox = (XulConfirmBox) container.getDocumentRoot().createElement( "confirmbox" );
148 | confirmBox.setTitle( "No repository" );
149 | confirmBox.setMessage( "Add a new one?" );
150 | confirmBox.setAcceptLabel( BaseMessages.getString( PKG, "Dialog.Ok" ) );
151 | confirmBox.setCancelLabel( BaseMessages.getString( PKG, "Dialog.Cancel" ) );
152 | confirmBox.addDialogCallback( (XulDialogLambdaCallback