Skip to content

Commit

Permalink
masesgroup#137: aligned manually made Listeners; MouseInputAdapter do…
Browse files Browse the repository at this point in the history
…es not have generated C# counterpart
  • Loading branch information
masesdevelopers committed Jun 20, 2023
1 parent 84ba50d commit e1a7c18
Show file tree
Hide file tree
Showing 45 changed files with 176 additions and 593 deletions.
16 changes: 4 additions & 12 deletions src/net/JNet/Developed/Java/Lang/Thread.cs
Original file line number Diff line number Diff line change
Expand Up @@ -274,27 +274,19 @@ public class UncaughtExceptionHandler : JVMBridgeListener
/// </summary>
public override string BridgeClassName => "org.mases.jnet.lang.JNetUncaughtExceptionHandler";

readonly Action<Thread, JVMBridgeException> executionFunction = null;
/// <summary>
/// The <see cref="Action{Thread, JVMBridgeException}"/> to be executed
/// </summary>
public virtual Action<Thread, JVMBridgeException> OnUncaughtException { get { return executionFunction; } }
public virtual Action<Thread, JVMBridgeException> OnUncaughtException { get; set; }
/// <summary>
/// Initialize a new instance of <see cref="UncaughtExceptionHandler"/>
/// </summary>
/// <param name="action">The <see cref="Action{Thread, JVMBridgeException}"/> to be executed</param>
/// <param name="attachEventHandler">Set to false to disable attach of <see cref="EventHandler"/> and set an own one</param>
public UncaughtExceptionHandler(Action<Thread, JVMBridgeException> action = null, bool attachEventHandler = true)
public UncaughtExceptionHandler()
{
if (action != null) executionFunction = action;
else executionFunction = UncaughtException;
if (attachEventHandler)
{
AddEventHandler("uncaughtException", new EventHandler<CLRListenerEventArgs<CLREventData<Thread>>>(EventHandler));
}
AddEventHandler("uncaughtException", new EventHandler<CLRListenerEventArgs<CLREventData<Thread>>>(UncaughtExceptionEventHandler)); OnUncaughtException = UncaughtException;
}

void EventHandler(object sender, CLRListenerEventArgs<CLREventData<Thread>> data)
void UncaughtExceptionEventHandler(object sender, CLRListenerEventArgs<CLREventData<Thread>> data)
{
OnUncaughtException(data.EventData.TypedEventData, JVMBridgeException.New(data.EventData.ExtraData.Get(0) as MASES.JCOBridge.C2JBridge.JVMInterop.IJavaObject));
}
Expand Down
17 changes: 4 additions & 13 deletions src/net/JNet/Developed/Java/Util/Function/BiConsumer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,19 @@ public abstract class BiConsumer : JVMBridgeListener
/// <typeparam name="U">The data associated to the event</typeparam>
public class BiConsumer<T, U> : BiConsumer, IBiConsumer<T, U>
{
Action<T, U> executionFunction = null;
/// <summary>
/// The <see cref="Action{T, U}"/> to be executed
/// </summary>
public virtual Action<T, U> OnAccept { get { return executionFunction; } }
public virtual Action<T, U> OnAccept { get; set; }
/// <summary>
/// Initialize a new instance of <see cref="BiConsumer{T, U}"/>
/// </summary>
/// <param name="action">The <see cref="Action{T, U}"/> to be executed</param>
/// <param name="attachEventHandler">Set to <see langword="false" /> to disable invocation of <see cref="JVMBridgeListener.AddEventHandler(string, System.EventHandler)"/>: the call can be done in the derived class</param>
public BiConsumer(Action<T, U> action = null, bool attachEventHandler = true)
public BiConsumer()
{
if (action != null) executionFunction = action;
else executionFunction = Accept;

if (attachEventHandler)
{
AddEventHandler("accept", new EventHandler<CLRListenerEventArgs<CLREventData<T>>>(EventHandler));
}
AddEventHandler("accept", new EventHandler<CLRListenerEventArgs<CLREventData<T>>>(AcceptEventHandler)); OnAccept = Accept;
}

void EventHandler(object sender, CLRListenerEventArgs<CLREventData<T>> data)
void AcceptEventHandler(object sender, CLRListenerEventArgs<CLREventData<T>> data)
{
OnAccept(data.EventData.TypedEventData, data.EventData.To<U>(0));
}
Expand Down
17 changes: 4 additions & 13 deletions src/net/JNet/Developed/Java/Util/Function/BiFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,28 +57,19 @@ public abstract class BiFunction : JVMBridgeListener
/// <typeparam name="TReturn">The return data type associated to the event</typeparam>
public class BiFunction<T, U, TReturn> : BiFunction, IBiFunction<T, U, TReturn>
{
Func<T, U, TReturn> executionFunction = null;
/// <summary>
/// The <see cref="Func{T, U, TReturn}"/> to be executed
/// </summary>
public virtual Func<T, U, TReturn> OnApply { get { return executionFunction; } }
public virtual Func<T, U, TReturn> OnApply { get; set; }
/// <summary>
/// Initialize a new instance of <see cref="BiFunction{T, U, TReturn}"/>
/// </summary>
/// <param name="func">The <see cref="Func{T, U, TReturn}"/> to be executed</param>
/// <param name="attachEventHandler">Set to <see langword="false" /> to disable invocation of <see cref="JVMBridgeListener.AddEventHandler(string, System.EventHandler)"/>: the call can be done in the derived class</param>
public BiFunction(Func<T, U, TReturn> func = null, bool attachEventHandler = true)
public BiFunction()
{
if (func != null) executionFunction = func;
else executionFunction = Apply;

if (attachEventHandler)
{
AddEventHandler("apply", new EventHandler<CLRListenerEventArgs<CLREventData<T>>>(EventHandler));
}
AddEventHandler("apply", new EventHandler<CLRListenerEventArgs<CLREventData<T>>>(ApplyEventHandler)); OnApply = Apply;
}

void EventHandler(object sender, CLRListenerEventArgs<CLREventData<T>> data)
void ApplyEventHandler(object sender, CLRListenerEventArgs<CLREventData<T>> data)
{
var retVal = OnApply(data.EventData.TypedEventData, data.EventData.To<U>(0));
data.SetReturnValue(retVal);
Expand Down
17 changes: 4 additions & 13 deletions src/net/JNet/Developed/Java/Util/Function/BiPredicate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,28 +55,19 @@ public abstract class BiPredicate : JVMBridgeListener
/// <typeparam name="U">The data associated to the event</typeparam>
public class BiPredicate<T, U> : BiPredicate, IBiPredicate<T, U>
{
Func<T, U, bool> executionFunction = null;
/// <summary>
/// The <see cref="Func{T, U, Boolean}"/> to be executed
/// </summary>
public virtual Func<T, U, bool> OnTest { get { return executionFunction; } }
public virtual Func<T, U, bool> OnTest { get; set; }
/// <summary>
/// Initialize a new instance of <see cref="BiPredicate{T, U}"/>
/// </summary>
/// <param name="func">The <see cref="Func{T, U, Boolean}"/> to be executed</param>
/// <param name="attachEventHandler">Set to <see langword="false" /> to disable invocation of <see cref="JVMBridgeListener.AddEventHandler(string, System.EventHandler)"/>: the call can be done in the derived class</param>
public BiPredicate(Func<T, U, bool> func = null, bool attachEventHandler = true)
public BiPredicate()
{
if (func != null) executionFunction = func;
else executionFunction = Test;

if (attachEventHandler)
{
AddEventHandler("test", new EventHandler<CLRListenerEventArgs<CLREventData<T>>>(EventHandler));
}
AddEventHandler("test", new EventHandler<CLRListenerEventArgs<CLREventData<T>>>(TestEventHandler)); OnTest = Test;
}

void EventHandler(object sender, CLRListenerEventArgs<CLREventData<T>> data)
void TestEventHandler(object sender, CLRListenerEventArgs<CLREventData<T>> data)
{
var retVal = OnTest(data.EventData.TypedEventData, data.EventData.To<U>(0));
data.SetReturnValue(retVal);
Expand Down
17 changes: 4 additions & 13 deletions src/net/JNet/Developed/Java/Util/Function/BinaryOperator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,28 +53,19 @@ public abstract class BinaryOperator : JVMBridgeListener
/// <typeparam name="T">The data type associated to the event</typeparam>
public class BinaryOperator<T> : BinaryOperator, IBinaryOperator<T>
{
Func<T, T, T> executionFunction = null;
/// <summary>
/// The <see cref="Func{TObject, TReturn}"/> to be executed
/// </summary>
public virtual Func<T, T, T> OnApply { get { return executionFunction; } }
public virtual Func<T, T, T> OnApply { get; set; }
/// <summary>
/// Initialize a new instance of <see cref="BinaryOperator{T}"/>
/// </summary>
/// <param name="func">The <see cref="Func{T,T,T}"/> to be executed</param>
/// <param name="attachEventHandler">Set to <see langword="false" /> to disable invocation of <see cref="JVMBridgeListener.AddEventHandler(string, System.EventHandler)"/>: the call can be done in the derived class</param>
public BinaryOperator(Func<T, T, T> func = null, bool attachEventHandler = true)
public BinaryOperator()
{
if (func != null) executionFunction = func;
else executionFunction = Apply;

if (attachEventHandler)
{
AddEventHandler("apply", new EventHandler<CLRListenerEventArgs<CLREventData<T>>>(EventHandler));
}
AddEventHandler("apply", new EventHandler<CLRListenerEventArgs<CLREventData<T>>>(ApplyEventHandler)); OnApply = Apply;
}

void EventHandler(object sender, CLRListenerEventArgs<CLREventData<T>> data)
void ApplyEventHandler(object sender, CLRListenerEventArgs<CLREventData<T>> data)
{
var retVal = OnApply(data.EventData.TypedEventData, data.EventData.To<T>(0));
data.SetReturnValue(retVal);
Expand Down
17 changes: 4 additions & 13 deletions src/net/JNet/Developed/Java/Util/Function/BooleanSupplier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,28 +43,19 @@ public class BooleanSupplier : JVMBridgeListener, IBooleanSupplier
/// </summary>
public override string BridgeClassName => "org.mases.jnet.util.function.JNetBooleanSupplier";

Func<bool> executionFunction = null;
/// <summary>
/// The <see cref="Func{Boolean}"/> to be executed
/// </summary>
public virtual Func<bool> OnGetAsBoolean { get { return executionFunction; } }
public virtual Func<bool> OnGetAsBoolean { get; set; }
/// <summary>
/// Initialize a new instance of <see cref="BooleanSupplier"/>
/// </summary>
/// <param name="func">The <see cref="Func{Boolean}"/> to be executed</param>
/// <param name="attachEventHandler">Set to <see langword="false" /> to disable invocation of <see cref="JVMBridgeListener.AddEventHandler(string, System.EventHandler)"/>: the call can be done in the derived class</param>
public BooleanSupplier(Func<bool> func = null, bool attachEventHandler = true)
public BooleanSupplier()
{
if (func != null) executionFunction = func;
else executionFunction = GetAsBoolean;

if (attachEventHandler)
{
AddEventHandler("getAsBoolean", new EventHandler<CLRListenerEventArgs<CLREventData>>(EventHandler));
}
AddEventHandler("getAsBoolean", new EventHandler<CLRListenerEventArgs<CLREventData>>(GetAsBooleanEventHandler)); OnGetAsBoolean = GetAsBoolean;
}

void EventHandler(object sender, CLRListenerEventArgs<CLREventData> data)
void GetAsBooleanEventHandler(object sender, CLRListenerEventArgs<CLREventData> data)
{
var retVal = OnGetAsBoolean();
data.SetReturnValue(retVal);
Expand Down
17 changes: 4 additions & 13 deletions src/net/JNet/Developed/Java/Util/Function/Consumer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,28 +51,19 @@ public abstract class Consumer : JVMBridgeListener
/// <typeparam name="TObject">The data type associated to the event</typeparam>
public class Consumer<TObject> : Consumer, IConsumer<TObject>
{
Action<TObject> executionFunction = null;
/// <summary>
/// The <see cref="Action{TObject}"/> to be executed
/// </summary>
public virtual Action<TObject> OnAccept { get { return executionFunction; } }
public virtual Action<TObject> OnAccept { get; set; }
/// <summary>
/// Initialize a new instance of <see cref="Consumer{TObject}"/>
/// </summary>
/// <param name="action">The <see cref="Action{TObject}"/> to be executed</param>
/// <param name="attachEventHandler">Set to <see langword="false" /> to disable invocation of <see cref="JVMBridgeListener.AddEventHandler(string, System.EventHandler)"/>: the call can be done in the derived class</param>
public Consumer(Action<TObject> action = null, bool attachEventHandler = true)
public Consumer()
{
if (action != null) executionFunction = action;
else executionFunction = Accept;

if (attachEventHandler)
{
AddEventHandler("accept", new EventHandler<CLRListenerEventArgs<CLREventData<TObject>>>(EventHandler));
}
AddEventHandler("accept", new EventHandler<CLRListenerEventArgs<CLREventData<TObject>>>(AcceptEventHandler)); OnAccept = Accept;
}

void EventHandler(object sender, CLRListenerEventArgs<CLREventData<TObject>> data)
void AcceptEventHandler(object sender, CLRListenerEventArgs<CLREventData<TObject>> data)
{
OnAccept(data.EventData.TypedEventData);
}
Expand Down
17 changes: 4 additions & 13 deletions src/net/JNet/Developed/Java/Util/Function/DoubleBinaryOperator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,28 +45,19 @@ public class DoubleBinaryOperator : JVMBridgeListener, IDoubleBinaryOperator
/// </summary>
public override string BridgeClassName => "org.mases.jnet.util.function.JNetDoubleBinaryOperator";

Func<double, double, double> executionFunction = null;
/// <summary>
/// The <see cref="Func{Double, Double, Double}"/> to be executed
/// </summary>
public virtual Func<double, double, double> OnApplyAsDouble { get { return executionFunction; } }
public virtual Func<double, double, double> OnApplyAsDouble { get; set; }
/// <summary>
/// Initialize a new instance of <see cref="DoubleBinaryOperator"/>
/// </summary>
/// <param name="func">The <see cref="Func{Double, Double, Double}"/> to be executed</param>
/// <param name="attachEventHandler">Set to <see langword="false" /> to disable invocation of <see cref="JVMBridgeListener.AddEventHandler(string, System.EventHandler)"/>: the call can be done in the derived class</param>
public DoubleBinaryOperator(Func<double, double, double> func = null, bool attachEventHandler = true)
public DoubleBinaryOperator()
{
if (func != null) executionFunction = func;
else executionFunction = ApplyAsDouble;

if (attachEventHandler)
{
AddEventHandler("applyAsDouble", new EventHandler<CLRListenerEventArgs<CLREventData<double>>>(EventHandler));
}
AddEventHandler("applyAsDouble", new EventHandler<CLRListenerEventArgs<CLREventData<double>>>(ApplyAsDoubleEventHandler)); OnApplyAsDouble = ApplyAsDouble;
}

void EventHandler(object sender, CLRListenerEventArgs<CLREventData<double>> data)
void ApplyAsDoubleEventHandler(object sender, CLRListenerEventArgs<CLREventData<double>> data)
{
var retVal = OnApplyAsDouble(data.EventData.TypedEventData, data.EventData.To<double>(0));
data.SetReturnValue(retVal);
Expand Down
17 changes: 4 additions & 13 deletions src/net/JNet/Developed/Java/Util/Function/DoubleConsumer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,28 +43,19 @@ public class DoubleConsumer : JVMBridgeListener, IDoubleConsumer
/// </summary>
public override string BridgeClassName => "org.mases.jnet.util.function.JNetDoubleConsumer";

Action<double> executionFunction = null;
/// <summary>
/// The <see cref="Action{Double}"/> to be executed
/// </summary>
public virtual Action<double> OnAccept { get { return executionFunction; } }
public virtual Action<double> OnAccept { get; set; }
/// <summary>
/// Initialize a new instance of <see cref="DoubleConsumer"/>
/// </summary>
/// <param name="action">The <see cref="Action{Double}"/> to be executed</param>
/// <param name="attachEventHandler">Set to <see langword="false" /> to disable invocation of <see cref="JVMBridgeListener.AddEventHandler(string, System.EventHandler)"/>: the call can be done in the derived class</param>
public DoubleConsumer(Action<double> action = null, bool attachEventHandler = true)
public DoubleConsumer()
{
if (action != null) executionFunction = action;
else executionFunction = Accept;

if (attachEventHandler)
{
AddEventHandler("accept", new EventHandler<CLRListenerEventArgs<CLREventData<double>>>(EventHandler));
}
AddEventHandler("accept", new EventHandler<CLRListenerEventArgs<CLREventData<double>>>(AcceptEventHandler)); OnAccept = Accept;
}

void EventHandler(object sender, CLRListenerEventArgs<CLREventData<double>> data)
void AcceptEventHandler(object sender, CLRListenerEventArgs<CLREventData<double>> data)
{
OnAccept(data.EventData.TypedEventData);
}
Expand Down
15 changes: 3 additions & 12 deletions src/net/JNet/Developed/Java/Util/Function/DoubleFunction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,28 +52,19 @@ public abstract class DoubleFunction : JVMBridgeListener
/// <typeparam name="TReturn">The return data type associated to the event</typeparam>
public class DoubleFunction<TReturn> : DoubleFunction, IDoubleFunction<TReturn>
{
Func<double, TReturn> executionFunction = null;
/// <summary>
/// The <see cref="Func{Double, TReturn}"/> to be executed
/// </summary>
public virtual Func<double, TReturn> OnApply { get { return executionFunction; } }
public virtual Func<double, TReturn> OnApply { get; set; }
/// <summary>
/// Initialize a new instance of <see cref="DoubleFunction{TReturn}"/>
/// </summary>
/// <param name="func">The <see cref="Func{TObject, TReturn}"/> to be executed</param>
/// <param name="attachEventHandler">Set to <see langword="false" /> to disable invocation of <see cref="JVMBridgeListener.AddEventHandler(string, System.EventHandler)"/>: the call can be done in the derived class</param>
public DoubleFunction(Func<double, TReturn> func = null, bool attachEventHandler = true)
{
if (func != null) executionFunction = func;
else executionFunction = Apply;

if (attachEventHandler)
{
AddEventHandler("apply", new EventHandler<CLRListenerEventArgs<CLREventData<double>>>(EventHandler));
}
AddEventHandler("apply", new EventHandler<CLRListenerEventArgs<CLREventData<double>>>(ApplyEventHandler)); OnApply = Apply;
}

void EventHandler(object sender, CLRListenerEventArgs<CLREventData<double>> data)
void ApplyEventHandler(object sender, CLRListenerEventArgs<CLREventData<double>> data)
{
var retVal = OnApply(data.EventData.TypedEventData);
data.SetReturnValue(retVal);
Expand Down
Loading

0 comments on commit e1a7c18

Please sign in to comment.