Java tutorial
/* * 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.mahasen.client.gui; import org.apache.http.NameValuePair; import org.mahasen.authentication.ClientLogin; import org.mahasen.authentication.ClientLoginData; import org.mahasen.client.*; import org.mahasen.configuration.ClientConfiguration; import org.mahasen.exception.MahasenClientException; import javax.swing.*; import java.io.File; import java.io.IOException; import java.lang.Exception; import java.net.URISyntaxException; import java.rmi.RemoteException; import java.util.ArrayList; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; public class MahasenClient extends javax.swing.JFrame { JFileChooser uploadFC = new JFileChooser(); JFileChooser downloadFC = new JFileChooser(); File file; ClientLoginData clientLoginData; ClientConfiguration clientConfiguration = ClientConfiguration.getInstance(); // Property property; Property updateProperty; Property uploadProperty; MultipleSearch multipleSearch; String downloadRepo = null; /** Creates new form MahasenClient */ /** * @param loginData */ public MahasenClient(ClientLoginData loginData) { initComponents(); downloadFC.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); userNameLabel.setText(loginData.getUserName()); this.clientLoginData = loginData; propertryBasedPanel.setVisible(true); tagBasedPanel.setVisible(false); rangeBasedPanel.setVisible(false); customPropertyPanel1.setVisible(false); customPropertyPanel2.setVisible(false); SearchResult.setVisible(false); SearchResult.setEditable(false); List<NameValuePair> updatePropertyList = new ArrayList<NameValuePair>(); updateProperty = new Property(updatePropertyList); List<NameValuePair> uploadPropertyList = new ArrayList<NameValuePair>(); uploadProperty = new Property(uploadPropertyList); } /** * This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { jPanel1 = new javax.swing.JPanel(); clientTabbedPane = new javax.swing.JTabbedPane(); uploadPanel = new javax.swing.JPanel(); uploadFileChooserButton = new javax.swing.JButton(); jLabel2 = new javax.swing.JLabel(); uploadTagsTextField = new javax.swing.JTextField(); jLabel3 = new javax.swing.JLabel(); uploadButton = new javax.swing.JButton(); jLabel16 = new javax.swing.JLabel(); javax.swing.JButton uploadAddPropertiesButton = new javax.swing.JButton(); jLabel20 = new javax.swing.JLabel(); folderStructureText = new javax.swing.JTextField(); downloadPanel = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); downloadTextField = new javax.swing.JTextField(); downloadButton = new javax.swing.JButton(); jLabel19 = new javax.swing.JLabel(); downloadRepoChooseButton = new javax.swing.JButton(); chosenDirectroyLabel = new javax.swing.JLabel(); deletePanel = new javax.swing.JPanel(); jLabel4 = new javax.swing.JLabel(); deleteTextField = new javax.swing.JTextField(); deleteButton = new javax.swing.JButton(); searchPanel = new javax.swing.JPanel(); searchButton = new javax.swing.JButton(); jLabel8 = new javax.swing.JLabel(); rangeBasedPanel = new javax.swing.JPanel(); jLabel5 = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); jLabel7 = new javax.swing.JLabel(); initialValueTextField = new javax.swing.JTextField(); lastValueTextField = new javax.swing.JTextField(); jComboBox3 = new javax.swing.JComboBox(); customPropertyPanel2 = new javax.swing.JPanel(); jLabel11 = new javax.swing.JLabel(); customPropertyTextField2 = new javax.swing.JTextField(); propertryBasedPanel = new javax.swing.JPanel(); jLabel10 = new javax.swing.JLabel(); propertyValueTextField = new javax.swing.JTextField(); jLabel12 = new javax.swing.JLabel(); jComboBox2 = new javax.swing.JComboBox(); customPropertyPanel1 = new javax.swing.JPanel(); jLabel13 = new javax.swing.JLabel(); customPropertyTextField1 = new javax.swing.JTextField(); jComboBox1 = new javax.swing.JComboBox(); jLabel14 = new javax.swing.JLabel(); jScrollPane1 = new javax.swing.JScrollPane(); SearchResult = new javax.swing.JTextArea(); tagBasedPanel = new javax.swing.JPanel(); jLabel15 = new javax.swing.JLabel(); tagTextField = new javax.swing.JTextField(); advancedSearchButton = new javax.swing.JButton(); updatePanel = new javax.swing.JPanel(); updateButton = new javax.swing.JButton(); updateAddNewPropertyButton = new javax.swing.JButton(); updateTagsTextField = new javax.swing.JTextField(); jLabel9 = new javax.swing.JLabel(); jLabel17 = new javax.swing.JLabel(); updateFileNameTextField = new javax.swing.JTextField(); jLabel18 = new javax.swing.JLabel(); logoutButton = new javax.swing.JButton(); cancelButton = new javax.swing.JButton(); loggedInAsLabel = new javax.swing.JLabel(); userNameLabel = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Mahasen Client"); uploadFileChooserButton.setText("Choose a File :"); uploadFileChooserButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { uploadFileChooserButtonActionPerformed(evt); } }); jLabel2.setText("Tags :"); jLabel3.setText("(enter tags seperated by commas \",\")"); uploadButton.setText("Upload"); uploadButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { uploadButtonActionPerformed(evt); } }); uploadAddPropertiesButton.setText("Add Properties"); // NOI18N uploadAddPropertiesButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { uploadAddPropertiesButtonaddPropertiesButtonActionPerformed(evt); } }); jLabel20.setText("Folder Structure:"); javax.swing.GroupLayout uploadPanelLayout = new javax.swing.GroupLayout(uploadPanel); uploadPanel.setLayout(uploadPanelLayout); uploadPanelLayout.setHorizontalGroup(uploadPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(uploadPanelLayout.createSequentialGroup().addContainerGap() .addGroup(uploadPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(uploadFileChooserButton) .addGroup(uploadPanelLayout.createSequentialGroup().addGap(8, 8, 8) .addGroup(uploadPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel20).addComponent(jLabel2)))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 37, Short.MAX_VALUE) .addGroup(uploadPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(folderStructureText) .addComponent(jLabel16, javax.swing.GroupLayout.DEFAULT_SIZE, 252, Short.MAX_VALUE) .addComponent(uploadTagsTextField, javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(60, 60, 60)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, uploadPanelLayout.createSequentialGroup() .addGap(167, 167, 167) .addGroup(uploadPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(uploadButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 143, Short.MAX_VALUE) .addComponent(uploadAddPropertiesButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 143, Short.MAX_VALUE)) .addGap(165, 165, 165))); uploadPanelLayout.setVerticalGroup(uploadPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(uploadPanelLayout.createSequentialGroup().addGap(74, 74, 74) .addGroup(uploadPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(uploadFileChooserButton).addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(58, 58, 58) .addGroup(uploadPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2).addComponent(uploadTagsTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(jLabel3) .addGap(22, 22, 22) .addGroup(uploadPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(folderStructureText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel20)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 48, Short.MAX_VALUE) .addComponent(uploadAddPropertiesButton).addGap(18, 18, 18).addComponent(uploadButton) .addGap(60, 60, 60))); clientTabbedPane.addTab("Upload", uploadPanel); jLabel1.setText("Name of the File :"); downloadTextField.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { downloadTextFieldActionPerformed(evt); } }); downloadButton.setText("Download"); downloadButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { downloadButtonActionPerformed(evt); } }); jLabel19.setText("Download Repo :"); downloadRepoChooseButton.setText("Choose Directory :"); downloadRepoChooseButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { downloadRepoChooseButtonActionPerformed(evt); } }); chosenDirectroyLabel.setText("No Directory Chosen."); javax.swing.GroupLayout downloadPanelLayout = new javax.swing.GroupLayout(downloadPanel); downloadPanel.setLayout(downloadPanelLayout); downloadPanelLayout.setHorizontalGroup(downloadPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(downloadPanelLayout.createSequentialGroup().addGroup(downloadPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(downloadPanelLayout.createSequentialGroup().addGap(21, 21, 21) .addGroup(downloadPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel1).addComponent(jLabel19)) .addGap(18, 18, 18) .addGroup(downloadPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(downloadPanelLayout.createSequentialGroup().addGap(16, 16, 16) .addComponent(chosenDirectroyLabel)) .addComponent(downloadRepoChooseButton).addComponent(downloadTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 295, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGroup(downloadPanelLayout.createSequentialGroup().addGap(158, 158, 158).addComponent( downloadButton, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(31, Short.MAX_VALUE))); downloadPanelLayout .setVerticalGroup(downloadPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(downloadPanelLayout.createSequentialGroup().addGap(132, 132, 132) .addGroup(downloadPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1) .addComponent(downloadTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(19, 19, 19) .addGroup(downloadPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel19).addComponent(downloadRepoChooseButton)) .addGap(7, 7, 7).addComponent(chosenDirectroyLabel).addGap(37, 37, 37) .addComponent(downloadButton).addContainerGap(149, Short.MAX_VALUE))); clientTabbedPane.addTab("Download", downloadPanel); jLabel4.setText("Name of the FIle :"); deleteButton.setText("Delete"); deleteButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { deleteButtonActionPerformed(evt); } }); javax.swing.GroupLayout deletePanelLayout = new javax.swing.GroupLayout(deletePanel); deletePanel.setLayout(deletePanelLayout); deletePanelLayout.setHorizontalGroup(deletePanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(deletePanelLayout.createSequentialGroup() .addGroup(deletePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(deletePanelLayout.createSequentialGroup().addGap(23, 23, 23) .addComponent(jLabel4).addGap(18, 18, 18).addComponent(deleteTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 294, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(deletePanelLayout.createSequentialGroup().addGap(165, 165, 165) .addComponent(deleteButton, javax.swing.GroupLayout.PREFERRED_SIZE, 139, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(30, Short.MAX_VALUE))); deletePanelLayout.setVerticalGroup(deletePanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(deletePanelLayout.createSequentialGroup().addGap(133, 133, 133) .addGroup(deletePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(deleteTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel4)) .addGap(101, 101, 101).addComponent(deleteButton).addContainerGap(152, Short.MAX_VALUE))); clientTabbedPane.addTab("Delete", deletePanel); searchButton.setText("Search"); searchButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { searchButtonActionPerformed(evt); } }); jLabel8.setText("Search results :"); rangeBasedPanel.setName("Panel1"); // NOI18N jLabel5.setText("Property Name"); jLabel6.setText("Initial Value"); jLabel7.setText("Last Value"); initialValueTextField.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { initialValueTextFieldActionPerformed(evt); } }); jComboBox3.setModel(new javax.swing.DefaultComboBoxModel( new String[] { "File Name", "File Size", "Uploaded Date", "Custom Property" })); jComboBox3.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jComboBox3ActionPerformed(evt); } }); jLabel11.setText("Custom Property Name"); customPropertyTextField2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { customPropertyTextField2ActionPerformed(evt); } }); javax.swing.GroupLayout customPropertyPanel2Layout = new javax.swing.GroupLayout(customPropertyPanel2); customPropertyPanel2.setLayout(customPropertyPanel2Layout); customPropertyPanel2Layout.setHorizontalGroup(customPropertyPanel2Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(customPropertyPanel2Layout.createSequentialGroup().addGap(20, 20, 20) .addComponent(jLabel11) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 37, Short.MAX_VALUE) .addComponent(customPropertyTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 247, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(31, 31, 31))); customPropertyPanel2Layout.setVerticalGroup(customPropertyPanel2Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(customPropertyPanel2Layout.createSequentialGroup().addContainerGap(18, Short.MAX_VALUE) .addGroup(customPropertyPanel2Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel11).addComponent(customPropertyTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))); javax.swing.GroupLayout rangeBasedPanelLayout = new javax.swing.GroupLayout(rangeBasedPanel); rangeBasedPanel.setLayout(rangeBasedPanelLayout); rangeBasedPanelLayout.setHorizontalGroup(rangeBasedPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(rangeBasedPanelLayout.createSequentialGroup().addGap(21, 21, 21).addComponent(jLabel5) .addGap(86, 86, 86).addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, 246, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(customPropertyPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(rangeBasedPanelLayout.createSequentialGroup().addGap(18, 18, 18).addComponent(jLabel6) .addGap(110, 110, 110).addComponent(initialValueTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 245, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(rangeBasedPanelLayout.createSequentialGroup().addGap(18, 18, 18).addComponent(jLabel7) .addGap(117, 117, 117).addComponent(lastValueTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 245, javax.swing.GroupLayout.PREFERRED_SIZE))); rangeBasedPanelLayout.setVerticalGroup( rangeBasedPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(rangeBasedPanelLayout.createSequentialGroup().addGap(10, 10, 10) .addGroup(rangeBasedPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(rangeBasedPanelLayout.createSequentialGroup().addGap(7, 7, 7) .addComponent(jLabel5)) .addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(8, 8, 8) .addComponent(customPropertyPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(14, 14, 14) .addGroup(rangeBasedPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(rangeBasedPanelLayout.createSequentialGroup().addGap(9, 9, 9) .addComponent(jLabel6)) .addComponent(initialValueTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(15, 15, 15) .addGroup(rangeBasedPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(rangeBasedPanelLayout.createSequentialGroup().addGap(6, 6, 6) .addComponent(jLabel7)) .addComponent(lastValueTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))); propertryBasedPanel.setName("propertryBasedPanel"); // NOI18N jLabel10.setText("Property Value"); propertyValueTextField.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { propertyValueTextFieldActionPerformed(evt); } }); propertyValueTextField.addKeyListener(new java.awt.event.KeyAdapter() { public void keyTyped(java.awt.event.KeyEvent evt) { searchKeyTped(evt); } }); jLabel12.setText("Property Name"); jComboBox2.setModel(new javax.swing.DefaultComboBoxModel( new String[] { "File Name", "File Size", "Uploaded Date", "Folder Structure", "Custom Property" })); jComboBox2.setMinimumSize(new java.awt.Dimension(166, 25)); jComboBox2.setOpaque(false); jComboBox2.setPreferredSize(new java.awt.Dimension(166, 25)); jComboBox2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jComboBox2ActionPerformed(evt); } }); jLabel13.setText("Custom Property Name"); customPropertyTextField1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { customPropertyTextField1ActionPerformed(evt); } }); javax.swing.GroupLayout customPropertyPanel1Layout = new javax.swing.GroupLayout(customPropertyPanel1); customPropertyPanel1.setLayout(customPropertyPanel1Layout); customPropertyPanel1Layout.setHorizontalGroup(customPropertyPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, customPropertyPanel1Layout .createSequentialGroup().addContainerGap() .addComponent(jLabel13, javax.swing.GroupLayout.DEFAULT_SIZE, 158, Short.MAX_VALUE) .addGap(18, 18, 18).addComponent(customPropertyTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 242, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(25, 25, 25))); customPropertyPanel1Layout.setVerticalGroup(customPropertyPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(customPropertyPanel1Layout.createSequentialGroup().addContainerGap() .addGroup(customPropertyPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(customPropertyTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel13)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); javax.swing.GroupLayout propertryBasedPanelLayout = new javax.swing.GroupLayout(propertryBasedPanel); propertryBasedPanel.setLayout(propertryBasedPanelLayout); propertryBasedPanelLayout.setHorizontalGroup(propertryBasedPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(propertryBasedPanelLayout.createSequentialGroup().addGroup(propertryBasedPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, propertryBasedPanelLayout .createSequentialGroup().addContainerGap() .addGroup(propertryBasedPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(propertryBasedPanelLayout.createSequentialGroup() .addGap(12, 12, 12) .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 75, Short.MAX_VALUE) .addComponent(propertyValueTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 244, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(24, 24, 24)) .addComponent(customPropertyPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addGroup(propertryBasedPanelLayout.createSequentialGroup().addGap(25, 25, 25) .addComponent(jLabel12) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 80, Short.MAX_VALUE) .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, 246, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(23, 23, 23))) .addContainerGap())); propertryBasedPanelLayout.setVerticalGroup(propertryBasedPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(propertryBasedPanelLayout.createSequentialGroup().addGap(20, 20, 20) .addGroup(propertryBasedPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel12)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(customPropertyPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(7, 7, 7) .addGroup(propertryBasedPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(propertyValueTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel10)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); jComboBox1.setModel(new javax.swing.DefaultComboBoxModel( new String[] { "Property Search", "Range Based Search", "Tag Search" })); jComboBox1.setInheritsPopupMenu(true); jComboBox1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jComboBox1ActionPerformed(evt); } }); jLabel14.setText("Search Type"); SearchResult.setColumns(20); SearchResult.setRows(5); jScrollPane1.setViewportView(SearchResult); tagBasedPanel.setName("Panel1"); // NOI18N jLabel15.setText("Tags to search :"); tagTextField.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { tagTextFieldActionPerformed(evt); } }); javax.swing.GroupLayout tagBasedPanelLayout = new javax.swing.GroupLayout(tagBasedPanel); tagBasedPanel.setLayout(tagBasedPanelLayout); tagBasedPanelLayout.setHorizontalGroup(tagBasedPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, tagBasedPanelLayout.createSequentialGroup() .addGap(20, 20, 20) .addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 54, Short.MAX_VALUE) .addComponent(tagTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 248, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap())); tagBasedPanelLayout.setVerticalGroup( tagBasedPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup( javax.swing.GroupLayout.Alignment.TRAILING, tagBasedPanelLayout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(tagBasedPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(tagTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel15)) .addContainerGap())); advancedSearchButton.setText("Advanced Search"); advancedSearchButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { advancedSearchButtonActionPerformed(evt); } }); javax.swing.GroupLayout searchPanelLayout = new javax.swing.GroupLayout(searchPanel); searchPanel.setLayout(searchPanelLayout); searchPanelLayout.setHorizontalGroup(searchPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(searchPanelLayout.createSequentialGroup().addGroup(searchPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(searchPanelLayout.createSequentialGroup().addContainerGap().addComponent( tagBasedPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(searchPanelLayout.createSequentialGroup().addGap(54, 54, 54) .addGroup(searchPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 403, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGroup(searchPanelLayout.createSequentialGroup().addGap(34, 34, 34) .addGroup(searchPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(advancedSearchButton) .addGroup(searchPanelLayout.createSequentialGroup() .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 144, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(32, 32, 32).addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 246, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addGroup(searchPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, searchPanelLayout.createSequentialGroup().addContainerGap().addComponent( propertryBasedPanel, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, searchPanelLayout.createSequentialGroup().addGap(12, 12, 12).addComponent( rangeBasedPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, searchPanelLayout.createSequentialGroup() .addContainerGap(187, Short.MAX_VALUE).addComponent(searchButton, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(184, 184, 184))); searchPanelLayout.setVerticalGroup(searchPanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(searchPanelLayout.createSequentialGroup().addGap(16, 16, 16) .addComponent(advancedSearchButton) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(searchPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(searchPanelLayout.createSequentialGroup().addGap(5, 5, 5).addComponent( jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGap(7, 7, 7) .addComponent(propertryBasedPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(rangeBasedPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(tagBasedPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(26, 26, 26).addComponent(searchButton).addGap(11, 11, 11).addComponent(jLabel8) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); clientTabbedPane.addTab("Search", searchPanel); updateButton.setText("Update"); updateButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { updateButtonActionPerformed(evt); } }); updateAddNewPropertyButton.setText("Add New Property"); updateAddNewPropertyButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { updateAddNewPropertyButtonActionPerformed(evt); } }); jLabel9.setText("Tags :"); jLabel17.setText("(enter tags seperated by commas \",\")"); jLabel18.setText("FileName :"); javax.swing.GroupLayout updatePanelLayout = new javax.swing.GroupLayout(updatePanel); updatePanel.setLayout(updatePanelLayout); updatePanelLayout.setHorizontalGroup(updatePanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(updatePanelLayout.createSequentialGroup().addGroup(updatePanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(updatePanelLayout.createSequentialGroup().addGap(42, 42, 42) .addGroup(updatePanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel17) .addGroup(updatePanelLayout.createSequentialGroup() .addGroup(updatePanelLayout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel9).addComponent(jLabel18)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(updatePanelLayout .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(updateAddNewPropertyButton) .addComponent(updateTagsTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 298, Short.MAX_VALUE) .addComponent(updateFileNameTextField))))) .addGroup(updatePanelLayout.createSequentialGroup().addGap(173, 173, 173).addComponent( updateButton, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap(58, Short.MAX_VALUE))); updatePanelLayout.setVerticalGroup(updatePanelLayout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(updatePanelLayout.createSequentialGroup().addGap(55, 55, 55) .addGroup(updatePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(updateFileNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel18)) .addGap(18, 18, 18).addComponent(updateAddNewPropertyButton).addGap(18, 18, 18) .addGroup(updatePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel9).addComponent(updateTagsTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18).addComponent(jLabel17).addGap(89, 89, 89).addComponent(updateButton) .addContainerGap(121, Short.MAX_VALUE))); clientTabbedPane.addTab("Update", updatePanel); logoutButton.setText("Logout"); logoutButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { logoutButtonActionPerformed(evt); } }); cancelButton.setText("Cancel"); cancelButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { cancelButtonActionPerformed(evt); } }); loggedInAsLabel.setText("Logged in as :"); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addGap(6, 6, 6) .addComponent(loggedInAsLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 105, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(userNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(29, 29, 29) .addComponent(logoutButton, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(39, 39, 39) .addComponent(cancelButton, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(45, 45, 45)) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(clientTabbedPane, javax.swing.GroupLayout.PREFERRED_SIZE, 491, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(clientTabbedPane, javax.swing.GroupLayout.PREFERRED_SIZE, 485, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(cancelButton).addComponent(logoutButton)) .addGroup(jPanel1Layout.createSequentialGroup().addGap(2, 2, 2) .addGroup(jPanel1Layout .createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(loggedInAsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(userNameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 15, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addContainerGap(47, Short.MAX_VALUE))); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup().addContainerGap() .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))); java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); setBounds((screenSize.width - 515) / 2, (screenSize.height - 590) / 2, 515, 590); }// </editor-fold>//GEN-END:initComponents private void uploadFileChooserButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_uploadFileChooserButtonActionPerformed // TODO add your handling code here: //Create a file choosercomponent. int returnVal = uploadFC.showOpenDialog(MahasenClient.this); if (returnVal == JFileChooser.APPROVE_OPTION) { jLabel16.setText(""); file = uploadFC.getSelectedFile(); jLabel16.setText(file.getName()); } }//GEN-LAST:event_uploadFileChooserButtonActionPerformed private void uploadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_uploadButtonActionPerformed // TODO add your handling code here: if (file == null || !file.exists()) { JOptionPane.showMessageDialog(this, " Please select a file to uploaed "); return; } Upload upload = new Upload(clientLoginData); List<NameValuePair> addedProperties = null; if (uploadProperty != null) { addedProperties = uploadProperty.getAddedProperties(); } try { if (file != null && file.exists()) { String tags = uploadTagsTextField.getText(); String folderStructure = folderStructureText.getText(); upload.upload(file, tags, folderStructure, addedProperties); JOptionPane.showMessageDialog(this, file.getName() + " was " + "Successfully uploaded "); } } catch (IOException ex) { JOptionPane.showMessageDialog(this, "Error Occured while Uploading", "Upload Error", JOptionPane.ERROR_MESSAGE); } catch (MahasenClientException e) { JOptionPane.showMessageDialog(this, e.getMessage(), "Upload Error", JOptionPane.ERROR_MESSAGE); } catch (URISyntaxException e) { JOptionPane.showMessageDialog(this, "Error while parsing URL", "Upload Error", JOptionPane.ERROR_MESSAGE); } finally { List<NameValuePair> uploadPropertyList = new ArrayList<NameValuePair>(); uploadProperty = new Property(uploadPropertyList); } }//GEN-LAST:event_uploadButtonActionPerformed private void downloadTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_downloadTextFieldActionPerformed // TODO add your handling code here: }//GEN-LAST:event_downloadTextFieldActionPerformed private void downloadButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_downloadButtonActionPerformed Download fileDownload = new Download(clientLoginData); String fileName = downloadTextField.getText(); if (fileName != null && !fileName.equals("")) { if (downloadRepo != null) { try { fileDownload.download(fileName); File downlodedFile = new File(clientConfiguration.getDownloadRepo() + "/" + fileName); if (downlodedFile.exists()) { JOptionPane.showMessageDialog(this, fileName + " was Successfully " + "Downloaded. "); } else { JOptionPane.showMessageDialog(this, "No file was downloaded", "Download Error", JOptionPane.ERROR_MESSAGE); } } catch (IOException ex) { JOptionPane.showMessageDialog(this, "Error Occured while Downloading", "Download Error", JOptionPane.ERROR_MESSAGE); } catch (MahasenClientException e) { JOptionPane.showMessageDialog(this, e.getMessage(), "Download Error", JOptionPane.ERROR_MESSAGE); } catch (URISyntaxException e) { JOptionPane.showMessageDialog(this, "Error while parsing URL", "Download Error", JOptionPane.ERROR_MESSAGE); } } else { JOptionPane.showMessageDialog(this, "Please choose a download directory"); int returnVal = downloadFC.showOpenDialog(MahasenClient.this); if (returnVal == JFileChooser.APPROVE_OPTION) { downloadRepo = downloadFC.getSelectedFile().getPath(); if (downloadRepo == null) { return; } chosenDirectroyLabel.setText(downloadRepo); clientConfiguration.setDownloadRepo(downloadRepo); } try { fileDownload.download(fileName); File downlodedFile = new File(clientConfiguration.getDownloadRepo() + "/" + fileName); if (downlodedFile.exists()) { JOptionPane.showMessageDialog(this, fileName + " was Successfully " + "Downloaded. "); } else { JOptionPane.showMessageDialog(this, "No file was downloaded", "Download Error", JOptionPane.ERROR_MESSAGE); } } catch (IOException ex) { JOptionPane.showMessageDialog(this, "Error Occured while Downloading", "Download Error", JOptionPane.ERROR_MESSAGE); } catch (MahasenClientException e) { JOptionPane.showMessageDialog(this, e.getMessage(), "Download Error", JOptionPane.ERROR_MESSAGE); } catch (URISyntaxException e) { JOptionPane.showMessageDialog(this, "Error while parsing URL", "Download Error", JOptionPane.ERROR_MESSAGE); } } } else { JOptionPane.showMessageDialog(this, "Please enter a file name to download"); return; } }//GEN-LAST:event_downloadButtonActionPerformed private void deleteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteButtonActionPerformed Delete delete = new Delete(clientLoginData); String fileName = deleteTextField.getText(); if (fileName != null && !fileName.equals("")) { try { delete.delete(fileName); JOptionPane.showMessageDialog(this, fileName + " was Successfully Deleted "); // TODO add your handling code here: } catch (IOException ex) { JOptionPane.showMessageDialog(this, "Error Occured while Deleting", "Delete Error", JOptionPane.ERROR_MESSAGE); } catch (MahasenClientException e) { JOptionPane.showMessageDialog(this, e.getMessage(), "Delete Error", JOptionPane.ERROR_MESSAGE); } catch (URISyntaxException e) { JOptionPane.showMessageDialog(this, "Error while parsing URL", "Delete Error", JOptionPane.ERROR_MESSAGE); } } else { JOptionPane.showMessageDialog(this, "Please enter a file name to delete"); } // TODO add your handling code here: }//GEN-LAST:event_deleteButtonActionPerformed private void searchButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchButtonActionPerformed try { // TODO add your handling code here: Search search = new Search(clientLoginData); SearchResult.setText(""); String propertyName = null; String propertyValue = null; if (jComboBox1.getSelectedIndex() == 0) { if (jComboBox2.getSelectedIndex() == 0) { propertyName = "fileName"; propertyValue = propertyValueTextField.getText(); } else if (jComboBox2.getSelectedIndex() == 1) { propertyName = "fileSize(MB)"; propertyValue = propertyValueTextField.getText(); if (propertyValue.contains(".")) { propertyValue = propertyValue.substring(0, propertyValue.indexOf(".")); } try { int value = Integer.valueOf(propertyValue); } catch (Exception e) { JOptionPane.showMessageDialog(this, "Invalid argument", "Wrong argument", JOptionPane.ERROR_MESSAGE); return; } } else if (jComboBox2.getSelectedIndex() == 2) { propertyName = "uploadedDate"; propertyValue = propertyValueTextField.getText().replace(".", ""); try { int value = Integer.valueOf(propertyValue); } catch (Exception e) { JOptionPane.showMessageDialog(this, "Invalid argument", "Wrong argument", JOptionPane.ERROR_MESSAGE); return; } } else if (jComboBox2.getSelectedIndex() == 3) { propertyName = "folderStructure"; propertyValue = propertyValueTextField.getText(); } else if (jComboBox2.getSelectedIndex() == 4) { propertyName = customPropertyTextField1.getText(); propertyValue = propertyValueTextField.getText(); } if (propertyName != null && propertyValue != null && !propertyName.equals("") && !propertyValue.equals("")) { String result = search.search(propertyName, propertyValue); if (result.equals("")) { JOptionPane.showMessageDialog(this, "No result found"); SearchResult.setText("No result found"); } else { SearchResult.setText(result.replace(", ", "\n")); SearchResult.setVisible(true); } } else { JOptionPane.showMessageDialog(this, "Search Queries are Empty"); } } else if (jComboBox1.getSelectedIndex() == 1) { String initialValue = null; String lastValue = null; if (jComboBox3.getSelectedIndex() == 0) { propertyName = "fileName"; initialValue = initialValueTextField.getText(); lastValue = lastValueTextField.getText(); } else if (jComboBox3.getSelectedIndex() == 1) { propertyName = "fileSize(MB)"; initialValue = initialValueTextField.getText(); if (initialValue.contains(".")) { initialValue = initialValue.substring(0, initialValue.indexOf(".")); } try { int value = Integer.valueOf(initialValue); } catch (Exception e) { JOptionPane.showMessageDialog(this, "Invalid argument", "Wrong argument", JOptionPane.ERROR_MESSAGE); return; } lastValue = lastValueTextField.getText(); if (lastValue.contains(".")) { lastValue = lastValue.substring(0, lastValue.indexOf(".")); } try { int value = Integer.valueOf(lastValue); } catch (Exception e) { JOptionPane.showMessageDialog(this, "Invalid argument", "Wrong argument", JOptionPane.ERROR_MESSAGE); return; } if (Integer.valueOf(initialValue) > Integer.valueOf(lastValue)) { JOptionPane.showMessageDialog(this, "Initial value should be smaller than the last value"); initialValueTextField.setText(""); lastValueTextField.setText(""); return; } } else if (jComboBox3.getSelectedIndex() == 2) { propertyName = "uploadedDate"; initialValue = initialValueTextField.getText().replace(".", ""); try { int value = Integer.valueOf(initialValue); } catch (Exception e) { JOptionPane.showMessageDialog(this, "Invalid argument", "Wrong argument", JOptionPane.ERROR_MESSAGE); return; } lastValue = lastValueTextField.getText().replace(".", ""); try { int value = Integer.valueOf(lastValue); } catch (Exception e) { JOptionPane.showMessageDialog(this, "Invalid argument", "Wrong argument", JOptionPane.ERROR_MESSAGE); return; } if (Integer.valueOf(initialValue) > Integer.valueOf(lastValue)) { JOptionPane.showMessageDialog(this, "Initial value should be smaller than the last value"); initialValueTextField.setText(""); lastValueTextField.setText(""); return; } } else { customPropertyPanel2.setVisible(true); propertyName = customPropertyTextField2.getText(); initialValue = initialValueTextField.getText(); lastValue = lastValueTextField.getText(); } if (propertyName != null && initialValue != null && lastValue != null && !propertyName.equals("") && !initialValue.equals("") && !lastValue.equals("")) { String result = search.rangeSearch(propertyName, initialValue, lastValue); if (result.equals("")) { JOptionPane.showMessageDialog(this, "No result found"); SearchResult.setText("No result found"); } else { SearchResult.setText(result.replace(", ", "\n")); SearchResult.setVisible(true); } } else { JOptionPane.showMessageDialog(this, "Search Queries are Empty"); } } else { String tag = tagTextField.getText(); if (tag != null && !tag.equals("")) { String result = search.tagSearch(tag); if (result.equals("")) { JOptionPane.showMessageDialog(this, "No result found"); SearchResult.setText("No result found"); } else { SearchResult.setText(result.replace(", ", "\n")); SearchResult.setVisible(true); } } else { JOptionPane.showMessageDialog(this, "Search Queries are Empty"); } } } catch (IOException ex) { JOptionPane.showMessageDialog(this, "Error Occured In network while " + "Searching. Please Try again", "Search Error", JOptionPane.ERROR_MESSAGE); } catch (AuthenticationExceptionException e) { JOptionPane.showMessageDialog(this, "Error Occured In Authenticating " + "Searching. Please Try again", "Search Error", JOptionPane.ERROR_MESSAGE); } catch (URISyntaxException e) { JOptionPane.showMessageDialog(this, "Error Occured parsing URL", "Search Error", JOptionPane.ERROR_MESSAGE); } catch (MahasenClientException e) { JOptionPane.showMessageDialog(this, e.getMessage(), "Search Error", JOptionPane.ERROR_MESSAGE); SearchResult.setText("No result found"); } // TODO add your handling code here: }//GEN-LAST:event_searchButtonActionPerformed private void initialValueTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_initialValueTextFieldActionPerformed // TODO add your handling code here: }//GEN-LAST:event_initialValueTextFieldActionPerformed private void jComboBox3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox3ActionPerformed if (jComboBox3.getSelectedIndex() == 3) { customPropertyPanel2.setVisible(true); } else { customPropertyPanel2.setVisible(false); } // TODO add your handling code here: }//GEN-LAST:event_jComboBox3ActionPerformed private void customPropertyTextField2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_customPropertyTextField2ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_customPropertyTextField2ActionPerformed private void propertyValueTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_propertyValueTextFieldActionPerformed }//GEN-LAST:event_propertyValueTextFieldActionPerformed private void jComboBox2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox2ActionPerformed if (jComboBox2.getSelectedIndex() == 4) { customPropertyPanel1.setVisible(true); } else { customPropertyPanel1.setVisible(false); } // TODO add your handling code here: }//GEN-LAST:event_jComboBox2ActionPerformed private void customPropertyTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_customPropertyTextField1ActionPerformed // TODO add your handling code here: }//GEN-LAST:event_customPropertyTextField1ActionPerformed private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed if (jComboBox1.getSelectedIndex() == 0) { SearchResult.setText(""); propertryBasedPanel.setVisible(true); //customPropertyPanel1.setVisible(false); tagBasedPanel.setVisible(false); rangeBasedPanel.setVisible(false); } else if (jComboBox1.getSelectedIndex() == 2) { SearchResult.setText(""); propertryBasedPanel.setVisible(false); tagBasedPanel.setVisible(true); rangeBasedPanel.setVisible(false); } else if (jComboBox1.getSelectedIndex() == 1) { SearchResult.setText(""); propertryBasedPanel.setVisible(false); tagBasedPanel.setVisible(false); rangeBasedPanel.setVisible(true); //customPropertyPanel2.setVisible(false); } // TODO add your handling code here: }//GEN-LAST:event_jComboBox1ActionPerformed private void tagTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tagTextFieldActionPerformed // TODO add your handling code here: }//GEN-LAST:event_tagTextFieldActionPerformed private void logoutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_logoutButtonActionPerformed String hostAndPort = clientConfiguration.getHost() + ":" + clientConfiguration.getPort(); ClientLogin clientLogin = new ClientLogin(); Boolean isLogged = false; System.setProperty("javax.net.ssl.trustStore", clientConfiguration.getTrustStorePath()); System.setProperty("javax.net.ssl.trustStorePassword", "wso2carbon"); System.setProperty("javax.net.ssl.trustStoreType", "JKS"); try { ClientLoginData loginData = clientLogin.remoteLogOut(hostAndPort); isLogged = loginData.isLoggedIn(); if (!isLogged) { this.dispose(); new Login().setVisible(true); } // TODO add your handling code here: } catch (AuthenticationExceptionException ex) { Logger.getLogger(Login.class.getName()).log(Level.SEVERE, null, ex); } catch (RemoteException ex) { Logger.getLogger(Login.class.getName()).log(Level.SEVERE, null, ex); } // TODO add your handling code here: }//GEN-LAST:event_logoutButtonActionPerformed private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed this.dispose(); // TODO add your handling code here: }//GEN-LAST:event_cancelButtonActionPerformed private void updateAddNewPropertyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_updateAddNewPropertyButtonActionPerformed // Hashtable<String, String> properties = new Hashtable<String, String>(); //List<NameValuePair> propeties = new ArrayList<NameValuePair>(); //updateProperty = new Property(propeties); updateProperty.setVisible(true); // TODO add your handling code here: }//GEN-LAST:event_updateAddNewPropertyButtonActionPerformed private void updateButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_updateButtonActionPerformed List<NameValuePair> addedProperties = null; UpdateMetadata update = new UpdateMetadata(clientLoginData); String updateTags = updateTagsTextField.getText(); String fileToUpdate = updateFileNameTextField.getText(); if (fileToUpdate == null | fileToUpdate.equals("")) { JOptionPane.showMessageDialog(this, "Please enter a file to update"); return; } if (addedProperties == null && updateTags == null) { JOptionPane.showMessageDialog(this, "Please add properties or tags to update"); return; } if (updateProperty != null) { addedProperties = updateProperty.getAddedProperties(); if (!addedProperties.isEmpty()) { update.setAddedProperties(addedProperties); } } if (addedProperties != null && updateTags == null) { if (addedProperties.isEmpty()) { JOptionPane.showMessageDialog(this, "Please add properties or tags to update"); return; } if (addedProperties != null && updateTags.equals("")) { if (addedProperties.isEmpty()) { JOptionPane.showMessageDialog(this, "Please add properties or tags to update"); return; } } } if (updateTags != null && addedProperties == null) { if (updateTags.equals("")) { JOptionPane.showMessageDialog(this, "Please add properties or tags to update"); return; } } /*if (property != null) { addedProperties = property.getAddedProperties(); if (!addedProperties.isEmpty()) { update.setAddedProperties(addedProperties); } } if (addedProperties == null && (updateTags == null | updateTags.isEmpty())) { JOptionPane.showMessageDialog(this, "Please add properties or tags to update"); return; }*/ if (updateTags != null && addedProperties == null) { if (updateTags.isEmpty()) { JOptionPane.showMessageDialog(this, "Please add properties or tags to update"); return; } } try { if (fileToUpdate != null && !fileToUpdate.equals("")) { update.updateMetadata(fileToUpdate, updateTags); JOptionPane.showMessageDialog(this, fileToUpdate + " was updated successfully"); } else { JOptionPane.showMessageDialog(this, "", "Update Error", JOptionPane.ERROR_MESSAGE); } } catch (IOException ex) { JOptionPane.showMessageDialog(this, "Error Occured In network while " + "Updating. Please Try again", "Update Error", JOptionPane.ERROR_MESSAGE); } catch (AuthenticationExceptionException e) { JOptionPane.showMessageDialog(this, "Error Occured In Authenticating " + "Updating. Please Try again", "Update Error", JOptionPane.ERROR_MESSAGE); } catch (URISyntaxException e) { JOptionPane.showMessageDialog(this, "Error Occured while parsing the URL", "Update Error", JOptionPane.ERROR_MESSAGE); } catch (MahasenClientException e) { JOptionPane.showMessageDialog(this, e.getMessage(), "Update Error", JOptionPane.ERROR_MESSAGE); SearchResult.setText("File not found"); } finally { List<NameValuePair> updatePropertyList = new ArrayList<NameValuePair>(); updateProperty = new Property(updatePropertyList); } // TODO add your handling code here: }//GEN-LAST:event_updateButtonActionPerformed private void uploadAddPropertiesButtonaddPropertiesButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_uploadAddPropertiesButtonaddPropertiesButtonActionPerformed // Hashtable<String, String> properties = new Hashtable<String, String>(); //List<NameValuePair> propeties = new ArrayList<NameValuePair>(); //uploadProperty = new Property(propeties); uploadProperty.setVisible(true); // TODO add your handling code here: }//GEN-LAST:event_uploadAddPropertiesButtonaddPropertiesButtonActionPerformed private void advancedSearchButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_advancedSearchButtonActionPerformed // Hashtable<String, String> searchQueries = new Hashtable<String, String>(); multipleSearch = new MultipleSearch(clientLoginData); multipleSearch.setVisible(true); // TODO add your handling code here: }//GEN-LAST:event_advancedSearchButtonActionPerformed private void searchKeyTped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_searchKeyTped }//GEN-LAST:event_searchKeyTped private void downloadRepoChooseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_downloadRepoChooseButtonActionPerformed int returnVal = downloadFC.showOpenDialog(MahasenClient.this); if (returnVal == JFileChooser.APPROVE_OPTION) { downloadRepo = downloadFC.getSelectedFile().getPath(); chosenDirectroyLabel.setText(downloadRepo); clientConfiguration.setDownloadRepo(downloadRepo); } // TODO add your handling code here: }//GEN-LAST:event_downloadRepoChooseButtonActionPerformed /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new MahasenClient(new ClientLoginData()).setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JTextArea SearchResult; private javax.swing.JButton advancedSearchButton; private javax.swing.JButton cancelButton; private javax.swing.JLabel chosenDirectroyLabel; private javax.swing.JTabbedPane clientTabbedPane; private javax.swing.JPanel customPropertyPanel1; private javax.swing.JPanel customPropertyPanel2; private javax.swing.JTextField customPropertyTextField1; private javax.swing.JTextField customPropertyTextField2; private javax.swing.JButton deleteButton; private javax.swing.JPanel deletePanel; private javax.swing.JTextField deleteTextField; private javax.swing.JButton downloadButton; private javax.swing.JPanel downloadPanel; private javax.swing.JButton downloadRepoChooseButton; private javax.swing.JTextField downloadTextField; private javax.swing.JTextField folderStructureText; private javax.swing.JTextField initialValueTextField; private javax.swing.JComboBox jComboBox1; private javax.swing.JComboBox jComboBox2; private javax.swing.JComboBox jComboBox3; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel10; private javax.swing.JLabel jLabel11; private javax.swing.JLabel jLabel12; private javax.swing.JLabel jLabel13; private javax.swing.JLabel jLabel14; private javax.swing.JLabel jLabel15; private javax.swing.JLabel jLabel16; private javax.swing.JLabel jLabel17; private javax.swing.JLabel jLabel18; private javax.swing.JLabel jLabel19; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel20; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; private javax.swing.JLabel jLabel8; private javax.swing.JLabel jLabel9; private javax.swing.JPanel jPanel1; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTextField lastValueTextField; private javax.swing.JLabel loggedInAsLabel; private javax.swing.JButton logoutButton; private javax.swing.JPanel propertryBasedPanel; private javax.swing.JTextField propertyValueTextField; private javax.swing.JPanel rangeBasedPanel; private javax.swing.JButton searchButton; private javax.swing.JPanel searchPanel; private javax.swing.JPanel tagBasedPanel; private javax.swing.JTextField tagTextField; private javax.swing.JButton updateAddNewPropertyButton; private javax.swing.JButton updateButton; private javax.swing.JTextField updateFileNameTextField; private javax.swing.JPanel updatePanel; private javax.swing.JTextField updateTagsTextField; private javax.swing.JButton uploadButton; private javax.swing.JButton uploadFileChooserButton; private javax.swing.JPanel uploadPanel; private javax.swing.JTextField uploadTagsTextField; private javax.swing.JLabel userNameLabel; // End of variables declaration//GEN-END:variables }