Skip to content

Commit

Permalink
New metadata panel.
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristian Cotes committed Jun 10, 2014
1 parent 45d8b49 commit fb3a899
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 118 deletions.
2 changes: 1 addition & 1 deletion src/com/stacksync/desktop/config/config-default.xml
Expand Up @@ -9,7 +9,7 @@
<remoteLogs>false</remoteLogs>

<rabbitMQ>
<host />
<host>localhost</host>

<port>5672</port>
<enableSSL>false</enableSSL>
Expand Down
26 changes: 3 additions & 23 deletions src/com/stacksync/desktop/config/profile/BrokerProperties.java
Expand Up @@ -14,32 +14,12 @@
* TODO this class seems a typical legacy code example, but it's necessary to
* load the brokers configuration
*
* @author gguerrero
* @author StackSync Team
*/
public class BrokerProperties implements Configurable {

private static final String port = "5672";
private static final String host = "130.206.36.132";

private Properties properties = new Properties();

public BrokerProperties() {
properties.setProperty(ParameterQueue.USER_NAME, "guest");
properties.setProperty(ParameterQueue.USER_PASS, "guest");

// Set host info of rabbimq (where it is)
properties.setProperty(ParameterQueue.RABBIT_HOST, host);
properties.setProperty(ParameterQueue.RABBIT_PORT, port);
properties.setProperty(ParameterQueue.ENABLE_SSL, "false");

// Set info about where the message will be sent
properties.setProperty(ParameterQueue.RPC_EXCHANGE, "rpc_global_exchange");

// Set info about the queue & the exchange where the ResponseListener
// will listen to.
properties.setProperty(ParameterQueue.RPC_REPLY_QUEUE, "reply_queue");
}

public void setRPCExchange(String rpc_exchange) {
properties.setProperty(ParameterQueue.RPC_EXCHANGE, rpc_exchange);
}
Expand Down Expand Up @@ -102,8 +82,8 @@ public void load(ConfigNode node) throws ConfigException {
setPassword(node.getProperty("password", "guest"));

// Set host info of rabbimq (where it is)
setHost(node.getProperty("host", host));
setPort(node.getInteger("port", 5672));
setHost(node.getProperty("host"));
setPort(node.getInteger("port"));
setEnableSsl(node.getBoolean("enableSSL", false));

setRPCExchange(node.getProperty("rpc_exchange", "rpc_global_exchange"));
Expand Down
38 changes: 11 additions & 27 deletions src/com/stacksync/desktop/gui/wizard/MetadataPanel.form
Expand Up @@ -20,25 +20,22 @@
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="lblTitle" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="lblConnectionTitle" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Component id="lblTitle" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="lblMachineName" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="lblServerIp" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="lblUsername" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="lblPassword" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="lblServerIp" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="lblUsername" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="lblPassword" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
<EmptySpace min="-2" pref="31" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="chkAuthenticated" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="txtServerIp" max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="txtServerIp" min="-2" pref="250" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="lblPort" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="4" max="-2" attributes="0"/>
Expand All @@ -61,9 +58,7 @@
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="lblTitle" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="33" max="-2" attributes="0"/>
<Component id="lblConnectionTitle" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="61" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="lblServerIp" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="txtServerIp" alignment="3" min="-2" max="-2" attributes="0"/>
Expand Down Expand Up @@ -102,21 +97,10 @@
<Font bold="true" component="lblTitle" property="font" relativeSize="true" size="3"/>
</FontInfo>
</Property>
<Property name="text" type="java.lang.String" value="Metadata Server"/>
<Property name="text" type="java.lang.String" value="Connection details"/>
<Property name="name" type="java.lang.String" value="lblTitle" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lblConnectionTitle">
<Properties>
<Property name="font" type="java.awt.Font" noResource="true" editor="org.netbeans.modules.form.editors2.FontEditor">
<FontInfo relative="true">
<Font bold="true" component="lblConnectionTitle" property="font" relativeSize="true" size="0"/>
</FontInfo>
</Property>
<Property name="text" type="java.lang.String" value="Connection Details"/>
<Property name="name" type="java.lang.String" value="lblConnectionTitle" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lblServerIp">
<Properties>
<Property name="text" type="java.lang.String" value="Server Ip:"/>
Expand Down
62 changes: 18 additions & 44 deletions src/com/stacksync/desktop/gui/wizard/MetadataPanel.java
Expand Up @@ -3,7 +3,6 @@
import com.stacksync.desktop.Environment;
import com.stacksync.desktop.config.profile.Profile;
import com.stacksync.desktop.config.profile.BrokerProperties;
import com.stacksync.desktop.connection.plugins.Connection;
import com.stacksync.desktop.gui.error.ErrorMessage;
import com.stacksync.desktop.gui.settings.SettingsPanel;

Expand All @@ -17,12 +16,12 @@ public MetadataPanel(Profile profile) {
initComponents();

/// setting text ///
lblTitle.setText("Metadata Server");
lblConnectionTitle.setText("Connection details:");
lblServerIp.setText("Server Ip:");
lblTitle.setText("Connection details");
lblServerIp.setText("RabbitMQ Ip:");
lblMachineName.setText("Machine Name:");

txtServerIp.setText("");
txtServerIp.setSize(200, 24);
txtMachineName.setText("");

chkAuthenticated.setSelected(false);
Expand All @@ -43,6 +42,8 @@ private void hideFields() {
txtPassword.setVisible(false);
lblPassword.setVisible(false);
lblUsername.setVisible(false);
lblMachineName.setVisible(false);
txtMachineName.setVisible(false);
}

@Override
Expand Down Expand Up @@ -87,27 +88,12 @@ public boolean check() {
}

@Override
public void load() {
// set the connection parameters
Connection conn = profile.getRepository().getConnection();
rabbitConnection.setHost(conn.getHost());
rabbitConnection.setUsername(conn.getUsername());
rabbitConnection.setPassword(conn.getPassword());

txtServerIp.setText(rabbitConnection.getHost());
spnPort.setValue(rabbitConnection.getPort());

chkUseSSL.setSelected(rabbitConnection.enableSsl());

txtUsername.setText(rabbitConnection.getUsername());
txtPassword.setText(rabbitConnection.getPassword());

public void load() {
txtMachineName.setText(env.getDeviceName());
}

@Override
public void save() {
config.setDeviceName(txtMachineName.getText());
public void save() {

rabbitConnection.setHost(txtServerIp.getText());
rabbitConnection.setPort(Integer.parseInt(spnPort.getValue().toString()));
Expand All @@ -123,8 +109,6 @@ public void save() {

rabbitConnection.setUsername(username);
rabbitConnection.setPassword(password);

rabbitConnection.setRPCReply(txtMachineName.getText());
}

/** This method is called from within the constructor to
Expand All @@ -137,7 +121,6 @@ public void save() {
private void initComponents() {

lblTitle = new javax.swing.JLabel();
lblConnectionTitle = new javax.swing.JLabel();
lblServerIp = new javax.swing.JLabel();
txtServerIp = new javax.swing.JTextField();
lblMachineName = new javax.swing.JLabel();
Expand All @@ -152,13 +135,9 @@ private void initComponents() {
chkUseSSL = new javax.swing.JCheckBox();

lblTitle.setFont(lblTitle.getFont().deriveFont(lblTitle.getFont().getStyle() | java.awt.Font.BOLD, lblTitle.getFont().getSize()+3));
lblTitle.setText("Metadata Server");
lblTitle.setText("Connection details");
lblTitle.setName("lblTitle"); // NOI18N

lblConnectionTitle.setFont(lblConnectionTitle.getFont().deriveFont(lblConnectionTitle.getFont().getStyle() | java.awt.Font.BOLD));
lblConnectionTitle.setText("Connection Details");
lblConnectionTitle.setName("lblConnectionTitle"); // NOI18N

lblServerIp.setText("Server Ip:");
lblServerIp.setName("lblServerIp"); // NOI18N

Expand Down Expand Up @@ -213,22 +192,20 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblTitle)
.addComponent(lblConnectionTitle))
.addGap(0, 0, Short.MAX_VALUE))
.addComponent(lblTitle)
.addGap(0, 0, 0))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblMachineName)
.addComponent(lblServerIp)
.addComponent(lblUsername)
.addComponent(lblPassword))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(lblServerIp, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(lblUsername, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(lblPassword, javax.swing.GroupLayout.Alignment.TRAILING))
.addGap(31, 31, 31)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(chkAuthenticated)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createSequentialGroup()
.addComponent(txtServerIp)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(txtServerIp, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblPort)
.addGap(4, 4, 4)
Expand All @@ -244,9 +221,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(lblTitle)
.addGap(33, 33, 33)
.addComponent(lblConnectionTitle)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGap(61, 61, 61)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblServerIp)
.addComponent(txtServerIp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
Expand Down Expand Up @@ -294,7 +269,6 @@ private void chkUseSSLActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIR
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JCheckBox chkAuthenticated;
private javax.swing.JCheckBox chkUseSSL;
private javax.swing.JLabel lblConnectionTitle;
private javax.swing.JLabel lblMachineName;
private javax.swing.JLabel lblPassword;
private javax.swing.JLabel lblPort;
Expand Down
28 changes: 5 additions & 23 deletions src/com/stacksync/desktop/gui/wizard/WizardDialog.java
Expand Up @@ -38,6 +38,7 @@
/**
*
* @author Philipp C. Heckel <philipp.heckel@gmail.com>
* @author StackSync Team
*/
public class WizardDialog extends JDialog {
private static final Config config = Config.getInstance();
Expand All @@ -50,11 +51,8 @@ public class WizardDialog extends JDialog {

private StackSyncServerPanel panelStackSyncServer;
private StackSyncTestPanel panelStackSyncTest;
private ConnectionPanel panelProfileBasic;
private ConnectionsPanel panelProfileBasics;
private MetadataPanel panelMetadataServer;
private EncryptionPanel panelEncryption;
private RepositoryTestPanel panelRepositoryTest;
private FoldersPanel panelFolders;

private Profile profile;
Expand Down Expand Up @@ -92,32 +90,27 @@ private void initWizard() {
// Panels
currentPanelIndex = 0;
panelStackSyncServer = new StackSyncServerPanel(profile);
panelProfileBasic = new ConnectionPanel(profile);
panelProfileBasics = new ConnectionsPanel(profile);
panelMetadataServer = new MetadataPanel(profile);
panelEncryption = new EncryptionPanel(profile);
panelRepositoryTest = new RepositoryTestPanel(profile);
panelFolders = new FoldersPanel(profile);
panelStackSyncTest = new StackSyncTestPanel(profile);

if(Config.getInstance().isExtendedMode()){
panels = new SettingsPanel[] {panelStackSyncServer,
panels = new SettingsPanel[] {panelMetadataServer,
panelStackSyncServer,
//panelProfileBasics,
//panelMetadataServer,
panelStackSyncTest,
panelEncryption,
panelFolders
//panelRepositoryTest
};

} else{
panels = new SettingsPanel[] {panelStackSyncServer,
panels = new SettingsPanel[] {panelMetadataServer,
panelStackSyncServer,
//panelProfileBasic,
//panelMetadataServer,
panelStackSyncTest,
panelEncryption,
panelFolders
//panelRepositoryTest
};

}
Expand Down Expand Up @@ -246,10 +239,6 @@ private void btnBackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST
currentPanelIndex--;
}
}

if(panels[currentPanelIndex].equals(panelMetadataServer) && !config.isExtendedMode()){ //hides the metadata panel
currentPanelIndex--;
}

showCurrentPanel(true);
break;
Expand Down Expand Up @@ -318,13 +307,6 @@ public void actionCompleted(boolean success) {

currentPanelIndex++;
showCurrentPanel(true);

//hides the metadata panel
if(panels[currentPanelIndex].equals(panelMetadataServer) && !config.isExtendedMode()){
panels[currentPanelIndex].save();
currentPanelIndex++;
showCurrentPanel(true);
}

if (!config.isExtendedMode()) {
if (panels[currentPanelIndex].equals(panelEncryption)) {
Expand Down

0 comments on commit fb3a899

Please sign in to comment.