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

@@ -0,0 +1,73 @@
<?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

@@ -0,0 +1,3 @@
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

@@ -0,0 +1,8 @@
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

@@ -0,0 +1,97 @@
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

@@ -0,0 +1,13 @@
<?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

@@ -6,9 +6,6 @@

package netz;


import java.io.IOException;
import java.net.MalformedURLException;
import javax.swing.JFrame;
import javax.swing.WindowConstants;
import netz.controller.ReceiveAdapter;
@@ -66,6 +63,7 @@ public class Start
JOptionPane.showMessageDialog(null, ex.toString());
}
new Start();
new Start();

}
}

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

@@ -9,8 +9,6 @@ package netz.controller;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.logging.Logger;
import ohmlogger.OhmLogger;
import netz.model.ChatModel;
@@ -52,11 +50,7 @@ public class CommandConnect implements ActionListener
synchronized (this){
try {
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) {
lg.severe(ex.toString());
}
@@ -68,10 +62,8 @@ public class CommandConnect implements ActionListener
synchronized (this){
try {
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) {
lg.severe(ex.toString());
}

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

@@ -48,6 +48,7 @@ public class ReceiveAdapter implements Flow.Subscriber<String>
{
view.getLblStatusDialog().setText("Nachricht empfangen");
view.getjTextArea().append("Partner: " + item + "\n");
subscription.request(1);
//System.out.println(item);
}


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

@@ -16,6 +16,7 @@ import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -78,8 +79,6 @@ public class ChatModel implements Runnable
}

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

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

@@ -91,6 +90,41 @@ public class ChatModel implements Runnable
out = new PrintWriter(osr);
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)
{

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

@@ -37,9 +37,6 @@
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="lblType">
<Properties>
<Property name="text" type="java.lang.String" value="Client"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="btnSetClient">
<Properties>
@@ -53,16 +50,6 @@
</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>
<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">
<Properties>
<Property name="text" type="java.lang.String" value="Send"/>
@@ -83,23 +70,41 @@
</Constraint>
</Constraints>
</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>
<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>
</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>
<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>
</SubComponents>
</Container>

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

@@ -114,18 +114,17 @@ public class ChatView extends javax.swing.JFrame
lblType = new javax.swing.JLabel();
btnSetClient = new javax.swing.JButton();
btnSetServer = new javax.swing.JButton();
txtField = new javax.swing.JTextField();
btnSend = new javax.swing.JButton();
lblStatusDialog = new javax.swing.JLabel();
jPanel2 = new javax.swing.JPanel();
jScrollPane1 = new javax.swing.JScrollPane();
jTextArea = new javax.swing.JTextArea();
txtField = new javax.swing.JTextField();

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

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

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

btnSetClient.setText("Client");
@@ -136,26 +135,32 @@ public class ChatView extends javax.swing.JFrame

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");
getContentPane().add(btnSend, java.awt.BorderLayout.LINE_END);

lblStatusDialog.setText("\"\"");
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.setRows(5);
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();
}// </editor-fold>//GEN-END:initComponents
@@ -222,6 +227,7 @@ public class ChatView extends javax.swing.JFrame
private javax.swing.JButton btnSetClient;
private javax.swing.JButton btnSetServer;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea jTextArea;
private javax.swing.JLabel lblStatusDialog;

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

@@ -1,26 +0,0 @@
/*
* 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

@@ -1,54 +0,0 @@
/*
* 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

@@ -1,4 +0,0 @@
#Level
LOG_LEVEL=INFO
#Log-Datei
LOG_DATEI=../logOHM.txt

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

@@ -1,4 +0,0 @@
#Level
LOG_LEVEL=ALL
#Log-Datei
LOG_DATEI=

Loading…
Cancel
Save