Add j goodies, create local repository

This commit is contained in:
Marcin Michałek committed 2015-06-12 15:44:11 +02:00
1 parent 4f18eb6858
commit b60fe9359b
5 files changed
+65 -21

No files matched your search

+2
View File
@@ -10,5 +10,7 @@ repositories {
}
dependencies {
compile 'org.tmatesoft.svnkit:svnkit:1.8.10'
compile 'com.jgoodies:forms:1.2.1'
testCompile group: 'junit', name: 'junit', version: '4.11'
}
@@ -0,0 +1,13 @@
package com.svn.utils.mirror.app;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNURL;
/**
* SvnMirror
* Created by Marcin on 2015-06-12.
*/
public interface CreateRepoInt {
void onRepoCreated(SVNURL svnurl);
void onRepoCreationException(SVNException e);
}
@@ -1,11 +1,20 @@
package com.svn.utils.mirror.app;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.io.SVNRepositoryFactory;
import java.io.File;
/**
* SvnMirror
* Created by Marcin on 2015-06-12.
*/
public class Mirror {
public static boolean createRepo() {
return true;
public static void createRepo(String name, CreateRepoInt createRepoInt) {
try {
createRepoInt.onRepoCreated(SVNRepositoryFactory.createLocalRepository(new File("repos/" + name), true, true));
} catch (SVNException e) {
createRepoInt.onRepoCreationException(e);
}
}
}
@@ -1,38 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.svn.utils.mirror.gui.MainWindow">
<grid id="27dc6" binding="rootPanel" layout-manager="GridLayoutManager" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="15" left="15" bottom="15" right="15"/>
<grid id="27dc6" binding="rootPanel" layout-manager="FormLayout">
<rowspec value="center:d:noGrow"/>
<rowspec value="top:4dlu:noGrow"/>
<rowspec value="center:max(d;4px):noGrow"/>
<colspec value="fill:d:grow"/>
<colspec value="left:4dlu:noGrow"/>
<colspec value="fill:d:noGrow"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<hspacer id="24bb7">
<component id="4f73b" class="javax.swing.JTextPane" binding="logTextPane">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false">
<preferred-size width="150" height="50"/>
</grid>
<forms defaultalign-horz="false" defaultalign-vert="false"/>
</constraints>
</hspacer>
<vspacer id="5dae">
<constraints>
<grid row="2" column="0" row-span="2" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<properties/>
</component>
<component id="ada03" class="javax.swing.JButton" binding="createRepoButton">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="1" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
<text value="Create repo"/>
</properties>
</component>
<component id="4f73b" class="javax.swing.JTextPane" binding="logTextPane">
<component id="ddc3e" class="javax.swing.JTextField" binding="nameTextField" default-binding="true">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="6" anchor="0" fill="3" indent="0" use-parent-layout="false">
<preferred-size width="150" height="50"/>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
<forms defaultalign-horz="false"/>
</constraints>
<properties/>
<properties>
<text value="name"/>
</properties>
</component>
</children>
</grid>
@@ -1,6 +1,9 @@
package com.svn.utils.mirror.gui;
import com.svn.utils.mirror.app.CreateRepoInt;
import com.svn.utils.mirror.app.Mirror;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNURL;
import javax.swing.*;
import javax.swing.text.AttributeSet;
@@ -15,10 +18,11 @@ import java.awt.event.ActionListener;
* SvnMirror
* Created by Marcin on 2015-06-12.
*/
public class MainWindow extends JFrame {
public class MainWindow extends JFrame implements CreateRepoInt {
private JPanel rootPanel;
private JButton createRepoButton;
private JTextPane logTextPane;
private JTextField nameTextField;
public MainWindow(String title) throws HeadlessException {
super(title);
@@ -30,9 +34,7 @@ public class MainWindow extends JFrame {
createRepoButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (Mirror.createRepo()) {
appendToPane(logTextPane, "Repo created!", Color.GREEN);
}
Mirror.createRepo(nameTextField.getText(), MainWindow.this);
}
});
}
@@ -55,4 +57,14 @@ public class MainWindow extends JFrame {
jTextPane.setCharacterAttributes(attributeSet, false);
jTextPane.replaceSelection(message);
}
@Override
public void onRepoCreated(SVNURL svnurl) {
appendToPane(logTextPane, "Repo created: " + svnurl.getPath(), Color.GREEN);
}
@Override
public void onRepoCreationException(SVNException e) {
appendToPane(logTextPane, "Repo created: " + e.getMessage(), Color.GREEN);
}
}