Browse Source

Merge origin/master

Conflicts:
	src/wuerfelthreads/Start.java
	src/wuerfelthreads/view/WuerfelView.form
	src/wuerfelthreads/view/WuerfelView.java
master
BakeOrDie 3 years ago
parent
commit
1585766b5a

+ 73
- 0
ChatProg/build.xml View File

<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="ChatProg" default="default" basedir=".">
<description>Builds, tests, and runs the project ChatProg.</description>
<import file="nbproject/build-impl.xml"/>
<!--
There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. They are:
-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file
-pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests
-pre-compile-test-single: called before javac compilation of single JUnit test
-post-compile-test-single: called after javac compilation of single JUunit test
-pre-jar: called before JAR building
-post-jar: called after JAR building
-post-clean: called after cleaning build products
(Targets beginning with '-' are not intended to be called on their own.)
Example of inserting an obfuscator after compilation could look like this:
<target name="-post-compile">
<obfuscate>
<fileset dir="${build.classes.dir}"/>
</obfuscate>
</target>
For list of available properties check the imported
nbproject/build-impl.xml file.
Another way to customize the build is by overriding existing main targets.
The targets of interest are:
-init-macrodef-javac: defines macro for javac compilation
-init-macrodef-junit: defines macro for junit execution
-init-macrodef-debug: defines macro for class debugging
-init-macrodef-java: defines macro for class execution
-do-jar: JAR building
run: execution of project
-javadoc-build: Javadoc generation
test-report: JUnit report generation
An example of overriding the target for project execution could look like this:
<target name="run" depends="ChatProg-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>
Notice that the overridden target depends on the jar target and not only on
the compile target as the regular run target does. Again, for a list of available
properties which you can use, check the target you are overriding in the
nbproject/build-impl.xml file.
-->
</project>

+ 3
- 0
ChatProg/manifest.mf View File

Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build

+ 1756
- 0
ChatProg/nbproject/build-impl.xml
File diff suppressed because it is too large
View File


+ 8
- 0
ChatProg/nbproject/genfiles.properties View File

build.xml.data.CRC32=b5658c92
build.xml.script.CRC32=8f33d0e4
build.xml.stylesheet.CRC32=f85dc8f2@1.96.0.48
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=b5658c92
nbproject/build-impl.xml.script.CRC32=24347752
nbproject/build-impl.xml.stylesheet.CRC32=f89f7d21@1.96.0.48

+ 97
- 0
ChatProg/nbproject/project.properties View File

annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false
annotation.processing.processor.options=
annotation.processing.processors.list=
annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java,**/*.form
# This directory is removed when the project is cleaned:
build.dir=build
build.generated.dir=${build.dir}/generated
build.generated.sources.dir=${build.dir}/generated-sources
# Only compile against the classpath explicitly listed here:
build.sysclasspath=ignore
build.test.classes.dir=${build.dir}/test/classes
build.test.results.dir=${build.dir}/test/results
# Uncomment to specify the preferred debugger connection transport:
#debug.transport=dt_socket
debug.classpath=\
${run.classpath}
debug.modulepath=\
${run.modulepath}
debug.test.classpath=\
${run.test.classpath}
debug.test.modulepath=\
${run.test.modulepath}
# Files in build.classes.dir which should be excluded from distribution jar
dist.archive.excludes=
# This directory is removed when the project is cleaned:
dist.dir=dist
dist.jar=${dist.dir}/ChatProg.jar
dist.javadoc.dir=${dist.dir}/javadoc
dist.jlink.dir=${dist.dir}/jlink
dist.jlink.output=${dist.jlink.dir}/ChatProg
excludes=
file.reference.chat_prog-src=../src
includes=**
jar.compress=false
javac.classpath=\
${libs.absolutelayout.classpath}:\
${libs.OhmLogger.classpath}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
javac.external.vm=true
javac.modulepath=
javac.processormodulepath=
javac.processorpath=\
${javac.classpath}
javac.source=15
javac.target=15
javac.test.classpath=\
${javac.classpath}:\
${build.classes.dir}
javac.test.modulepath=\
${javac.modulepath}
javac.test.processorpath=\
${javac.test.classpath}
javadoc.additionalparam=
javadoc.author=false
javadoc.encoding=${source.encoding}
javadoc.html5=false
javadoc.noindex=false
javadoc.nonavbar=false
javadoc.notree=false
javadoc.private=false
javadoc.splitindex=true
javadoc.use=true
javadoc.version=false
javadoc.windowtitle=
# The jlink additional root modules to resolve
jlink.additionalmodules=
# The jlink additional command line parameters
jlink.additionalparam=
jlink.launcher=true
jlink.launcher.name=ChatProg
main.class=netz.Start
manifest.file=manifest.mf
meta.inf.dir=${src.dir}/META-INF
mkdist.disabled=false
platform.active=default_platform
run.classpath=\
${javac.classpath}:\
${build.classes.dir}
# Space-separated list of JVM arguments used when running the project.
# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
# To set system properties for unit tests define test-sys-prop.name=value:
run.jvmargs=
run.modulepath=\
${javac.modulepath}
run.test.classpath=\
${javac.test.classpath}:\
${build.test.classes.dir}
run.test.modulepath=\
${javac.test.modulepath}
source.encoding=UTF-8
src.dir=${file.reference.chat_prog-src}

+ 13
- 0
ChatProg/nbproject/project.xml View File

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.java.j2seproject</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
<name>ChatProg</name>
<source-roots>
<root id="src.dir"/>
</source-roots>
<test-roots/>
</data>
</configuration>
</project>

+ 1
- 3
src/netz/Start.java View File



package netz; package netz;



import java.io.IOException;
import java.net.MalformedURLException;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.WindowConstants; import javax.swing.WindowConstants;
import netz.controller.ReceiveAdapter; import netz.controller.ReceiveAdapter;
JOptionPane.showMessageDialog(null, ex.toString()); JOptionPane.showMessageDialog(null, ex.toString());
} }
new Start(); new Start();
new Start();


} }
} }

+ 3
- 11
src/netz/controller/CommandConnect.java View File

import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.io.IOException; import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.logging.Logger; import java.util.logging.Logger;
import ohmlogger.OhmLogger; import ohmlogger.OhmLogger;
import netz.model.ChatModel; import netz.model.ChatModel;
synchronized (this){ synchronized (this){
try { try {
view.getLblType().setText("Server"); view.getLblType().setText("Server");
ServerSocket sSocket = new ServerSocket(PORT);
lg.info("Server: Warte auf Verbindung ...");
Socket s = sSocket.accept(); // Achtung: blockiert!
lg.info("Server: Verbindung akzeptiert");
model.setSocket(s);
model.setServer(PORT);
} catch (IOException ex) { } catch (IOException ex) {
lg.severe(ex.toString()); lg.severe(ex.toString());
} }
synchronized (this){ synchronized (this){
try { try {
view.getLblType().setText("Client"); view.getLblType().setText("Client");
lg.info("Client: verbinde ...");
Socket s = new Socket(IP_ADRESSE, PORT); // Achtung: blockiert!
lg.info("Client: Verbindung hergestellt");
model.setSocket(s);
model.setClient(PORT, IP_ADRESSE);
} catch (IOException ex) { } catch (IOException ex) {
lg.severe(ex.toString()); lg.severe(ex.toString());
} }

+ 1
- 0
src/netz/controller/ReceiveAdapter.java View File

{ {
view.getLblStatusDialog().setText("Nachricht empfangen"); view.getLblStatusDialog().setText("Nachricht empfangen");
view.getjTextArea().append("Partner: " + item + "\n"); view.getjTextArea().append("Partner: " + item + "\n");
subscription.request(1);
//System.out.println(item); //System.out.println(item);
} }



+ 36
- 2
src/netz/model/ChatModel.java View File

import java.io.OutputStream; import java.io.OutputStream;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket; import java.net.Socket;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
} }


public void setSocket(Socket s) throws IOException { public void setSocket(Socket s) throws IOException {
this.socket = s;

InputStream iStream = s.getInputStream(); InputStream iStream = s.getInputStream();
OutputStream oStream = s.getOutputStream(); OutputStream oStream = s.getOutputStream();


out = new PrintWriter(osr); out = new PrintWriter(osr);
start(); start();
} }
public void setClient(int PORT, String IP_ADRESSE) throws IOException
{
Thread connectThread = new Thread(new Runnable() {
@Override
public void run() {
try {
lg.info("Client: verbinde ...");
Socket s = new Socket(IP_ADRESSE, PORT); // Achtung: blockiert!
lg.info("Client: Verbindung hergestellt");
setSocket(s);
} catch (Exception e) {
e.printStackTrace();
}
}
});
connectThread.start();
}
public void setServer(int PORT) throws IOException
{
Thread connectThread = new Thread(new Runnable() {
@Override
public void run() {
try {
ServerSocket sSocket = new ServerSocket(PORT);
lg.info("Server: Warte auf Verbindung ...");
Socket s = sSocket.accept(); // Achtung: blockiert!
lg.info("Server: Verbindung akzeptiert");
setSocket(s);
} catch (Exception e) {
e.printStackTrace();
}
}
});
connectThread.start();
}


public void sendMessage(String msg) public void sendMessage(String msg)
{ {

+ 29
- 24
src/netz/view/ChatView.form View File

</Layout> </Layout>
<SubComponents> <SubComponents>
<Component class="javax.swing.JLabel" name="lblType"> <Component class="javax.swing.JLabel" name="lblType">
<Properties>
<Property name="text" type="java.lang.String" value="Client"/>
</Properties>
</Component> </Component>
<Component class="javax.swing.JButton" name="btnSetClient"> <Component class="javax.swing.JButton" name="btnSetClient">
<Properties> <Properties>
</Component> </Component>
</SubComponents> </SubComponents>
</Container> </Container>
<Component class="javax.swing.JTextField" name="txtField">
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="txtFieldActionPerformed"/>
</Events>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Center"/>
</Constraint>
</Constraints>
</Component>
<Component class="javax.swing.JButton" name="btnSend"> <Component class="javax.swing.JButton" name="btnSend">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Send"/> <Property name="text" type="java.lang.String" value="Send"/>
</Constraint> </Constraint>
</Constraints> </Constraints>
</Component> </Component>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Container class="javax.swing.JPanel" name="jPanel2">
<Constraints> <Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription"> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Before"/>
<BorderConstraints direction="Center"/>
</Constraint> </Constraint>
</Constraints> </Constraints>


<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridLayout">
<Property name="columns" type="int" value="1"/>
<Property name="rows" type="int" value="2"/>
</Layout>
<SubComponents> <SubComponents>
<Component class="javax.swing.JTextArea" name="jTextArea">
<Properties>
<Property name="columns" type="int" value="20"/>
<Property name="rows" type="int" value="5"/>
</Properties>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>

<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTextArea" name="jTextArea">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="cc" green="cc" red="cc" type="rgb"/>
</Property>
<Property name="columns" type="int" value="20"/>
<Property name="rows" type="int" value="5"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JTextField" name="txtField">
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="txtFieldActionPerformed"/>
</Events>
</Component> </Component>
</SubComponents> </SubComponents>
</Container> </Container>

+ 19
- 13
src/netz/view/ChatView.java View File

lblType = new javax.swing.JLabel(); lblType = new javax.swing.JLabel();
btnSetClient = new javax.swing.JButton(); btnSetClient = new javax.swing.JButton();
btnSetServer = new javax.swing.JButton(); btnSetServer = new javax.swing.JButton();
txtField = new javax.swing.JTextField();
btnSend = new javax.swing.JButton(); btnSend = new javax.swing.JButton();
lblStatusDialog = new javax.swing.JLabel(); lblStatusDialog = new javax.swing.JLabel();
jPanel2 = new javax.swing.JPanel();
jScrollPane1 = new javax.swing.JScrollPane(); jScrollPane1 = new javax.swing.JScrollPane();
jTextArea = new javax.swing.JTextArea(); jTextArea = new javax.swing.JTextArea();
txtField = new javax.swing.JTextField();


setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("ChatTool"); setTitle("ChatTool");


jPanel1.setLayout(new java.awt.GridLayout(1, 0)); jPanel1.setLayout(new java.awt.GridLayout(1, 0));

lblType.setText("Client");
jPanel1.add(lblType); jPanel1.add(lblType);


btnSetClient.setText("Client"); btnSetClient.setText("Client");


getContentPane().add(jPanel1, java.awt.BorderLayout.PAGE_START); getContentPane().add(jPanel1, java.awt.BorderLayout.PAGE_START);


txtField.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
txtFieldActionPerformed(evt);
}
});
getContentPane().add(txtField, java.awt.BorderLayout.CENTER);

btnSend.setText("Send"); btnSend.setText("Send");
getContentPane().add(btnSend, java.awt.BorderLayout.LINE_END); getContentPane().add(btnSend, java.awt.BorderLayout.LINE_END);


lblStatusDialog.setText("\"\""); lblStatusDialog.setText("\"\"");
getContentPane().add(lblStatusDialog, java.awt.BorderLayout.PAGE_END); getContentPane().add(lblStatusDialog, java.awt.BorderLayout.PAGE_END);


jPanel2.setLayout(new java.awt.GridLayout(2, 1));

jTextArea.setEditable(false);
jTextArea.setBackground(new java.awt.Color(204, 204, 204));
jTextArea.setColumns(20); jTextArea.setColumns(20);
jTextArea.setRows(5); jTextArea.setRows(5);
jScrollPane1.setViewportView(jTextArea); jScrollPane1.setViewportView(jTextArea);


getContentPane().add(jScrollPane1, java.awt.BorderLayout.LINE_START);
jPanel2.add(jScrollPane1);

txtField.addActionListener(new java.awt.event.ActionListener()
{
public void actionPerformed(java.awt.event.ActionEvent evt)
{
txtFieldActionPerformed(evt);
}
});
jPanel2.add(txtField);

getContentPane().add(jPanel2, java.awt.BorderLayout.CENTER);


pack(); pack();
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
private javax.swing.JButton btnSetClient; private javax.swing.JButton btnSetClient;
private javax.swing.JButton btnSetServer; private javax.swing.JButton btnSetServer;
private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea jTextArea; private javax.swing.JTextArea jTextArea;
private javax.swing.JLabel lblStatusDialog; private javax.swing.JLabel lblStatusDialog;

+ 0
- 26
src/ohmlogger/MyFormatter.java View File

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/

package ohmlogger;

import java.util.Date;
import java.util.logging.Formatter;
import java.util.logging.LogRecord;

/**
*
* @author chris
*/
public class MyFormatter extends Formatter {
@Override
public String format(LogRecord lr) {
String date = String.format("%1$tb %1$td, %1$tY %1$tl:%1$tM:%1$tS %1$Tp", new Date(lr.getMillis()));
String s = ("| ")+lr.getMillis()+(" | ")+date+(" | ")+lr.getLevel().toString()+(" | ")+lr.getSourceClassName()+(" | ")+lr.getMessage()+(" | ")+"\n";
return s;
}
}

+ 0
- 54
src/ohmlogger/OhmLogger.java View File

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ohmlogger;


import java.io.File;
import java.io.IOException;
import java.util.logging.*;



/**
*
* @author chris, hd
*/
public class OhmLogger
{
public OhmLogger()
{
}
private static Logger lg = null;
public static Logger getLogger()
{
if (lg == null)
{
lg = Logger.getLogger("OhmLogger");
initLogger();
}
return lg;
}
private static void initLogger()
{
try{
String datei = System.getProperty("java.io.tmpdir") + File.separator + "log.txt";
FileHandler fh = new FileHandler(datei);
fh.setFormatter(new MyFormatter());
ConsoleHandler ch = new ConsoleHandler();
lg.addHandler(fh);
ch.setFormatter(new MyFormatter());
lg.setUseParentHandlers(false);
lg.addHandler(ch);
lg.setLevel(Level.ALL);
}
catch(IOException ioex)
{
System.err.println(ioex);
}
}
}

+ 0
- 4
src/ohmlogger/OhmLogger.properties View File

#Level
LOG_LEVEL=INFO
#Log-Datei
LOG_DATEI=../logOHM.txt

+ 0
- 4
src/ohmlogger/logger.properties View File

#Level
LOG_LEVEL=ALL
#Log-Datei
LOG_DATEI=

Loading…
Cancel
Save