Fill data for combobox, adjust sizes

This commit is contained in:
Marcin Michałek committed 2015-06-16 17:53:01 +02:00
1 parent 752ba245a9
commit b10b495fa6
4 files changed
+215 -36

No files matched your search

@@ -0,0 +1,10 @@
package com.svn.utils.mirror.gui.enums;
/**
* SvnMirror
* Created by Marcin on 2015-06-16.
*/
public enum RepositoryType {
LOCAL,
REMOTE
}
@@ -1,10 +1,18 @@
<?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.main.MainWindow">
<grid id="27dc6" binding="rootPanel" layout-manager="FormLayout">
<rowspec value="center:d:noGrow"/>
<rowspec value="center:max(d;4px):noGrow"/>
<rowspec value="top:4dlu:noGrow"/>
<rowspec value="center:max(d;4px):noGrow"/>
<colspec value="fill:d:grow"/>
<rowspec value="top:4dlu:noGrow"/>
<rowspec value="center:max(d;4px):noGrow"/>
<rowspec value="top:4dlu:noGrow"/>
<rowspec value="center:max(d;4px):noGrow"/>
<rowspec value="top:4dlu:noGrow"/>
<rowspec value="center:d:grow"/>
<rowspec value="top:4dlu:noGrow"/>
<rowspec value="center:d:grow"/>
<colspec value="fill:363px:grow"/>
<colspec value="left:4dlu:noGrow"/>
<colspec value="fill:d:noGrow"/>
<constraints>
@@ -13,35 +21,125 @@
<properties/>
<border type="none"/>
<children>
<component id="4f73b" class="javax.swing.JTextPane" binding="logTextPane">
<component id="ddc3e" class="javax.swing.JTextField" binding="sourcePathTextField">
<constraints>
<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>
<properties/>
</component>
<component id="ada03" class="javax.swing.JButton" binding="createRepoButton">
<constraints>
<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="ddc3e" class="javax.swing.JTextField" binding="nameTextField" default-binding="true">
<constraints>
<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">
<grid row="4" column="0" 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>
<text value="name"/>
<text value="Source repository path"/>
</properties>
</component>
<component id="703e0" class="javax.swing.JTextField" binding="destinationRepositoryPathTextField" default-binding="true">
<constraints>
<grid row="6" column="0" 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>
<text value="Destination repository path"/>
</properties>
</component>
<scrollpane id="b8f99">
<constraints>
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<forms defaultalign-horz="false" defaultalign-vert="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="4f73b" class="javax.swing.JTextPane" binding="logTextPane">
<constraints/>
<properties>
<text value="logs"/>
</properties>
</component>
</children>
</scrollpane>
<component id="3fbfa" class="javax.swing.JComboBox" binding="repositoryType">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
<forms/>
</constraints>
<properties/>
</component>
<grid id="c9d20" binding="rootServerLoginPanel" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<forms/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="f3976" class="javax.swing.JTextField" binding="loginTextFields">
<constraints>
<grid row="0" column="0" 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>
</constraints>
<properties>
<text value="SVN user login"/>
</properties>
</component>
<component id="ae73" class="javax.swing.JPasswordField" binding="passwordField">
<constraints>
<grid row="0" column="1" 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>
</constraints>
<properties>
<text value="password"/>
</properties>
</component>
</children>
</grid>
<scrollpane id="19c4a">
<constraints>
<grid row="10" column="0" row-span="1" col-span="1" vsize-policy="7" hsize-policy="7" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<forms defaultalign-horz="false" defaultalign-vert="false"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<component id="88417" class="javax.swing.JEditorPane" binding="detailsPane">
<constraints/>
<properties>
<text value="details"/>
</properties>
</component>
</children>
</scrollpane>
<component id="ada03" class="javax.swing.JButton" binding="mirrorButton">
<constraints>
<grid row="6" 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="Mirror"/>
</properties>
</component>
<component id="2d020" class="javax.swing.JLabel">
<constraints>
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<forms/>
</constraints>
<properties>
<text value="Synchronization:"/>
</properties>
</component>
<grid id="7dd0b" binding="synchroStatusPanel" layout-manager="CardLayout" hgap="0" vgap="0">
<constraints>
<grid row="2" column="2" row-span="3" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<forms defaultalign-vert="false"/>
</constraints>
<properties/>
<border type="none"/>
<children/>
</grid>
</children>
</grid>
</form>
@@ -3,7 +3,11 @@ package com.svn.utils.mirror.gui.main;
import com.svn.utils.mirror.app.CreateRepoInt;
import com.svn.utils.mirror.app.Mirror;
import com.svn.utils.mirror.gui.enums.RepoAction;
import com.svn.utils.mirror.gui.enums.RepositoryType;
import com.svn.utils.mirror.gui.enums.SynchronizationStatus;
import com.svn.utils.mirror.gui.logger.StatusLogger;
import com.svn.utils.mirror.gui.model.RepositoryModel;
import com.svn.utils.mirror.gui.view.SynchronizationStatusComponent;
import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNURL;
@@ -11,6 +15,8 @@ import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
/**
* SvnMirror
@@ -18,35 +24,76 @@ import java.awt.event.ActionListener;
*/
public class MainWindow extends JFrame implements CreateRepoInt {
private JPanel rootPanel;
private JButton createRepoButton;
private JButton mirrorButton;
private JTextPane logTextPane;
private JTextField nameTextField;
private JTextField sourcePathTextField;
private JTextField destinationRepositoryPathTextField;
private JComboBox repositoryType;
private JTextField loginTextFields;
private JPasswordField passwordField;
private JPanel rootServerLoginPanel;
private JEditorPane detailsPane;
private JPanel synchroStatusPanel;
private StatusLogger statusLogger;
private RepoAction repoAction;
private SynchronizationStatusComponent synchronizationStatusComponent;
public MainWindow(String title, RepoAction repoAction) throws HeadlessException {
super(title);
statusLogger = new StatusLogger(logTextPane);
this.repoAction = repoAction;
initAndShowMainWindow();
initializeView();
initializeFormBasedOnRepoAction();
addListeners();
}
private void addListeners() {
createRepoButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Mirror.createRepo(nameTextField.getText(), MainWindow.this);
}
});
}
private void initAndShowMainWindow() {
private void initializeView() {
setExtendedState(JFrame.MAXIMIZED_BOTH);
setContentPane(rootPanel);
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
pack();
setVisible(true);
synchronizationStatusComponent = new SynchronizationStatusComponent();
synchronizationStatusComponent.setSynchronizationStatus(SynchronizationStatus.WAITING_FOR_FEEDBACK);
synchroStatusPanel.add(synchronizationStatusComponent);
DefaultComboBoxModel<RepositoryModel> repositoryTypeComboBoxModel = new DefaultComboBoxModel<>();
repositoryTypeComboBoxModel.addElement(new RepositoryModel(RepositoryType.REMOTE));
repositoryTypeComboBoxModel.addElement(new RepositoryModel(RepositoryType.LOCAL));
repositoryType.setModel(repositoryTypeComboBoxModel);
}
private void initializeFormBasedOnRepoAction() {
// @TODO hide & show GUI parts
switch (repoAction) {
case CONNECT_TO_EXISTING_REPO_MIRROR:
break;
case CREATE_NEW_REPO_MIRROR:
break;
}
setVisible(true);
}
private void addListeners() {
mirrorButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
Mirror.createRepo(sourcePathTextField.getText(), MainWindow.this);
}
});
repositoryType.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
if (((RepositoryModel) e.getItem()).getRepositoryType() == RepositoryType.LOCAL) {
rootServerLoginPanel.setVisible(false);
} else {
rootServerLoginPanel.setVisible(true);
}
}
}
});
}
@Override
@@ -0,0 +1,24 @@
package com.svn.utils.mirror.gui.model;
import com.svn.utils.mirror.gui.enums.RepositoryType;
/**
* SvnMirror
* Created by Marcin on 2015-06-16.
*/
public class RepositoryModel {
private RepositoryType repositoryType;
public RepositoryModel(RepositoryType repositoryType) {
this.repositoryType = repositoryType;
}
public RepositoryType getRepositoryType() {
return repositoryType;
}
@Override
public String toString() {
return repositoryType.toString();
}
}