Skip to content

Commit

Permalink
Merge pull request #9 from salimkanoun/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
salimkanoun authored Jun 14, 2018
2 parents f6e2bf9 + 3cad9bf commit f70da94
Show file tree
Hide file tree
Showing 19 changed files with 2,985 additions and 16 deletions.
24 changes: 24 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>Boundless</id>
<name>Boundless Repository</name>
<url>http://repo.boundlessgeo.com/main/</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>




</repositories>
<groupId>Orthanc_Tools</groupId>
Expand Down Expand Up @@ -112,6 +124,18 @@
<artifactId>mysql-connector-java</artifactId>
<version>5.1.14</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>

<dependency>
<groupId>net.sf.packtag</groupId>
<artifactId>packtag-core</artifactId>
<version>3.8</version>
</dependency>


</dependencies>

Expand Down
111 changes: 111 additions & 0 deletions src/org/petctviewer/orthanc/Jsonsettings/Connection_Dialog.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
package org.petctviewer.orthanc.Jsonsettings;
import java.awt.EventQueue;

import javax.swing.JDialog;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTextField;
import java.awt.GridLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

@SuppressWarnings("serial")
public class Connection_Dialog extends JDialog {
private JTextField txtHttpipport;
private JTextField textField_Login;
private JTextField textField_Password;
private String address;
private String login;
private String password;

/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Connection_Dialog dialog = new Connection_Dialog();
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
dialog.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}

/**
* Create the dialog.
*/
public Connection_Dialog() {
setBounds(100, 100, 450, 300);
setModal(true);
JPanel panel = new JPanel();
getContentPane().add(panel, BorderLayout.SOUTH);

JButton btnOk = new JButton("OK");
btnOk.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
address=txtHttpipport.getText();
login=textField_Login.getText();
password=textField_Password.getText();
dispose();
}
});
panel.add(btnOk);

JPanel panel_1 = new JPanel();
getContentPane().add(panel_1, BorderLayout.CENTER);
panel_1.setLayout(new GridLayout(0, 1, 0, 0));

JLabel lblServerAdres = new JLabel("Server address");
panel_1.add(lblServerAdres);

txtHttpipport = new JTextField();
txtHttpipport.setText("http://localhost:8042");
panel_1.add(txtHttpipport);
txtHttpipport.setColumns(10);

JLabel label_4 = new JLabel("");
panel_1.add(label_4);

JLabel lblLogin = new JLabel("Login");
panel_1.add(lblLogin);

textField_Login = new JTextField();
panel_1.add(textField_Login);
textField_Login.setColumns(10);

JLabel label = new JLabel("");
panel_1.add(label);

JLabel lblPassword = new JLabel("Password");
panel_1.add(lblPassword);

textField_Password = new JTextField();
panel_1.add(textField_Password);
textField_Password.setColumns(10);

JLabel label_3 = new JLabel("");
panel_1.add(label_3);

JPanel panel_2 = new JPanel();
getContentPane().add(panel_2, BorderLayout.NORTH);

JLabel lblEnterCorrectSettings = new JLabel("Enter correct settings and retry connection");
panel_2.add(lblEnterCorrectSettings);

}
protected String getAddress(){
return address;
}
protected String getLogin(){
return login;
}
protected String getPassword(){
return password;
}
}
157 changes: 157 additions & 0 deletions src/org/petctviewer/orthanc/Jsonsettings/Content_Dialog.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
package org.petctviewer.orthanc.Jsonsettings;
/**
Copyright (C) 2017 KANOUN Salim
This
program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public v.3 License as published by
the Free Software Foundation;
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

import org.json.simple.JSONArray;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

@SuppressWarnings("serial")
public class Content_Dialog extends JDialog {

private final JPanel contentPanel = new JPanel();
private JTable table;
private DefaultTableModel model;

/**
* Launch the application.
*/
public static void main(String[] args) {
try {
Content_Dialog dialog = new Content_Dialog(new Json_Settings());
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
dialog.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}

/**
* Create the dialog.
*/
public Content_Dialog(Json_Settings settings) {
setModal(true);
setBounds(100, 100, 450, 300);
getContentPane().setLayout(new BorderLayout());
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
getContentPane().add(contentPanel, BorderLayout.CENTER);

{
table = new JTable();
table.setModel(new DefaultTableModel(new String[] {"Name", "Number", "MIME"},0));
table.putClientProperty("terminateEditOnFocusLost", true);
model = (DefaultTableModel) table.getModel();
if (settings.contentType.size()>0){
String[] contentType=new String[settings.contentType.size()];
settings.contentType.keySet().toArray(contentType);
for (int i=0 ; i<contentType.length;i++){
model.addRow(new Object[]{"Name", "0", "MIME"});
JSONArray content=settings.contentType.get(contentType[i]);
table.setValueAt(contentType[i], i, 0);
table.setValueAt(Integer.valueOf(content.get(0).toString()), i, 1);
table.setValueAt(content.get(1).toString(), i, 2);
}
}
model = (DefaultTableModel) table.getModel();
}
contentPanel.setLayout(new BorderLayout(0, 0));
{
JScrollPane scrollPane = new JScrollPane();
scrollPane.setViewportView(table);
contentPanel.add(scrollPane);
}
{
JPanel buttonPane = new JPanel();
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
getContentPane().add(buttonPane, BorderLayout.SOUTH);
{
JButton btnAdd = new JButton("Add");
btnAdd.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
model.addRow(new Object[]{"Name", "0", "MIME"});

}
});
{
JButton btnInfo = new JButton("Info");
btnInfo.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String message="Dictionary of symbolic names for the user-defined types of attached files. \n"
+ "Each entry must map an unique string to an unique number between 1024 and 65535. \n"
+ "Optionally, a second argument can provided to specify a MIME content type for the attachment.";
JOptionPane.showMessageDialog(null,message);

}
});
buttonPane.add(btnInfo);
}
buttonPane.add(btnAdd);
}
{
JButton btnRemove = new JButton("Remove");
btnRemove.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (table.getSelectedRow()!=-1){
model.removeRow(table.getSelectedRow());
}
}
});
buttonPane.add(btnRemove);
}
{
JButton okButton = new JButton("OK");
okButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//On vide les ancienne content
settings.contentType.clear();
for (int i=0; i<table.getRowCount(); i++){
settings.addContentType(table.getValueAt(i, 0).toString(), Integer.valueOf(table.getValueAt(i, 1).toString()), table.getValueAt(i, 2).toString());
}
//update du texte
//SettingsGUI.ContentType_Counter.setText(String.valueOf(IndexOrthanc.contentType.size()));
dispose();
}
});
okButton.setActionCommand("OK");
buttonPane.add(okButton);
getRootPane().setDefaultButton(okButton);
}
{
JButton cancelButton = new JButton("Cancel");
cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
dispose();
}
});
cancelButton.setActionCommand("Cancel");
buttonPane.add(cancelButton);
}
}
}

}
Loading

0 comments on commit f70da94

Please sign in to comment.