Update socket and swt dependency on gclc last stable
This commit is contained in:
parent
38322d4fed
commit
df159e4ca6
@ -87,7 +87,7 @@ of Emmanuel Bigeon. -->
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>fr.bigeon</groupId>
|
<groupId>fr.bigeon</groupId>
|
||||||
<artifactId>gclc</artifactId>
|
<artifactId>gclc</artifactId>
|
||||||
<version>1.1.1</version>
|
<version>1.1.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>fr.bigeon</groupId>
|
<groupId>fr.bigeon</groupId>
|
||||||
|
@ -50,7 +50,7 @@ import java.util.logging.Level;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import fr.bigeon.gclc.ConsoleApplication;
|
import fr.bigeon.gclc.ConsoleApplication;
|
||||||
import fr.bigeon.gclc.ConsoleManager;
|
import fr.bigeon.gclc.manager.ConsoleManager;
|
||||||
import fr.bigeon.smu.StringEncoder;
|
import fr.bigeon.smu.StringEncoder;
|
||||||
|
|
||||||
/** This is a socket communicating console consoleManager
|
/** This is a socket communicating console consoleManager
|
||||||
|
@ -44,7 +44,7 @@ import java.io.PrintWriter;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import fr.bigeon.gclc.ConsoleManager;
|
import fr.bigeon.gclc.manager.ConsoleManager;
|
||||||
import fr.bigeon.smu.StringEncoder;
|
import fr.bigeon.smu.StringEncoder;
|
||||||
|
|
||||||
/** The console manager for socket communication
|
/** The console manager for socket communication
|
||||||
@ -154,5 +154,11 @@ public class ThreadedServerConsoleManager implements ConsoleManager {
|
|||||||
return prompt;
|
return prompt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see fr.bigeon.gclc.manager.ConsoleManager#close() */
|
||||||
|
@Override
|
||||||
|
public void close() throws IOException {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -38,21 +38,89 @@
|
|||||||
*/
|
*/
|
||||||
package fr.bigeon.gclc.socket;
|
package fr.bigeon.gclc.socket;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import fr.bigeon.gclc.ConsoleApplication;
|
import fr.bigeon.gclc.ConsoleApplication;
|
||||||
import fr.bigeon.gclc.ConsoleManager;
|
import fr.bigeon.gclc.manager.ConsoleManager;
|
||||||
import fr.bigeon.gclc.system.SystemConsoleManager;
|
import fr.bigeon.gclc.manager.SystemConsoleManager;
|
||||||
|
|
||||||
/** Test class for {@link ConsoleRunnable}
|
/** Test class for {@link ConsoleRunnable}
|
||||||
*
|
*
|
||||||
* @author Emmanuel Bigeon */
|
* @author Emmanuel Bigeon */
|
||||||
@SuppressWarnings({"static-method", "unused"})
|
@SuppressWarnings({"static-method", "unused", "javadoc"})
|
||||||
public class ConsoleRunnableTest {
|
public class ConsoleRunnableTest {
|
||||||
|
|
||||||
/**
|
/** <p>
|
||||||
* Test method for {@link fr.bigeon.gclc.socket.ConsoleRunnable#ConsoleRunnable(fr.bigeon.gclc.ConsoleApplication, java.lang.Object)}.
|
* TODO
|
||||||
*/
|
*
|
||||||
|
* @author Emmanuel Bigeon */
|
||||||
|
private static final class ConsoleManagerTestImplementation
|
||||||
|
implements ConsoleManager {
|
||||||
|
int i = 0;
|
||||||
|
String[] cmds;
|
||||||
|
|
||||||
|
/** @param cmds */
|
||||||
|
public ConsoleManagerTestImplementation(String[] cmds) {
|
||||||
|
super();
|
||||||
|
this.cmds = cmds;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPrompt(String prompt) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPrompt() {
|
||||||
|
// Not used in test
|
||||||
|
return ""; //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String prompt() {
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (InterruptedException e) { // NOSONAR
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
if (i == cmds.length) {
|
||||||
|
i = 0;
|
||||||
|
}
|
||||||
|
return cmds[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String prompt(String message) {
|
||||||
|
return prompt();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void println(String message) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void println() {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void print(String text) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void close() throws IOException {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Test method for
|
||||||
|
* {@link fr.bigeon.gclc.socket.ConsoleRunnable#ConsoleRunnable(fr.bigeon.gclc.ConsoleApplication, java.lang.Object)}
|
||||||
|
* . */
|
||||||
@Test
|
@Test
|
||||||
public void testConsoleRunnable() {
|
public void testConsoleRunnable() {
|
||||||
Object lock = new Object();
|
Object lock = new Object();
|
||||||
@ -62,56 +130,13 @@ public class ConsoleRunnableTest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Test method for {@link fr.bigeon.gclc.socket.ConsoleRunnable#run()}. */
|
||||||
* Test method for {@link fr.bigeon.gclc.socket.ConsoleRunnable#run()}.
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
public void testRunFlow() {
|
public void testRunFlow() {
|
||||||
Object lock = new Object();
|
Object lock = new Object();
|
||||||
ConsoleApplication app = new ConsoleTestApplication(
|
ConsoleApplication app = new ConsoleTestApplication(
|
||||||
new ConsoleManager() {
|
new ConsoleManagerTestImplementation(
|
||||||
|
new String[] {"test", ConsoleTestApplication.EXIT}));
|
||||||
@Override
|
|
||||||
public void setPrompt(String prompt) {
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPrompt() {
|
|
||||||
// Not used in test
|
|
||||||
return ""; //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String prompt() {
|
|
||||||
try {
|
|
||||||
Thread.sleep(1000);
|
|
||||||
} catch (InterruptedException e) { // NOSONAR
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
return "mock"; //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String prompt(String message) {
|
|
||||||
return prompt();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void println(String message) {
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void println() {
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void print(String text) {
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
});
|
|
||||||
ConsoleRunnable runnable = new ConsoleRunnable(app, lock);
|
ConsoleRunnable runnable = new ConsoleRunnable(app, lock);
|
||||||
|
|
||||||
Thread th = new Thread(runnable);
|
Thread th = new Thread(runnable);
|
||||||
@ -120,55 +145,13 @@ public class ConsoleRunnableTest {
|
|||||||
runnable.stop();
|
runnable.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/** Test method for {@link fr.bigeon.gclc.socket.ConsoleRunnable#stop()}. */
|
||||||
* Test method for {@link fr.bigeon.gclc.socket.ConsoleRunnable#stop()}.
|
|
||||||
*/
|
|
||||||
@Test
|
@Test
|
||||||
public void testStop() {
|
public void testStop() {
|
||||||
Object lock = new Object();
|
Object lock = new Object();
|
||||||
ConsoleApplication app = new ConsoleTestApplication(
|
ConsoleApplication app = new ConsoleTestApplication(
|
||||||
new ConsoleManager() {
|
new ConsoleManagerTestImplementation(
|
||||||
|
new String[] {"test", ConsoleTestApplication.EXIT}));
|
||||||
@Override
|
|
||||||
public void setPrompt(String prompt) {
|
|
||||||
throw new RuntimeException("Not implemented yet"); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPrompt() {
|
|
||||||
throw new RuntimeException("Not implemented yet"); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String prompt() {
|
|
||||||
try {
|
|
||||||
Thread.sleep(1000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return "mock"; //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String prompt(String message) {
|
|
||||||
throw new RuntimeException("Not implemented yet"); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void println(String message) {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void println() {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void print(String text) {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
});
|
|
||||||
ConsoleRunnable runnable = new ConsoleRunnable(app, lock);
|
ConsoleRunnable runnable = new ConsoleRunnable(app, lock);
|
||||||
runnable.stop();
|
runnable.stop();
|
||||||
Thread th = new Thread(runnable);
|
Thread th = new Thread(runnable);
|
||||||
@ -182,48 +165,8 @@ public class ConsoleRunnableTest {
|
|||||||
public void testRun() {
|
public void testRun() {
|
||||||
Object lock = new Object();
|
Object lock = new Object();
|
||||||
ConsoleApplication app = new ConsoleTestApplication(
|
ConsoleApplication app = new ConsoleTestApplication(
|
||||||
new ConsoleManager() {
|
new ConsoleManagerTestImplementation(
|
||||||
|
new String[] {"test", ConsoleTestApplication.EXIT}));
|
||||||
@Override
|
|
||||||
public void setPrompt(String prompt) {
|
|
||||||
throw new RuntimeException("Not implemented yet"); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getPrompt() {
|
|
||||||
throw new RuntimeException("Not implemented yet"); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String prompt() {
|
|
||||||
try {
|
|
||||||
Thread.sleep(1000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return "exit"; //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String prompt(String message) {
|
|
||||||
throw new RuntimeException("Not implemented yet"); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void println(String message) {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void println() {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void print(String text) {
|
|
||||||
//
|
|
||||||
}
|
|
||||||
});
|
|
||||||
ConsoleRunnable runnable = new ConsoleRunnable(app, lock);
|
ConsoleRunnable runnable = new ConsoleRunnable(app, lock);
|
||||||
runnable.run();
|
runnable.run();
|
||||||
}
|
}
|
||||||
|
@ -35,9 +35,11 @@
|
|||||||
package fr.bigeon.gclc.socket;
|
package fr.bigeon.gclc.socket;
|
||||||
|
|
||||||
import fr.bigeon.gclc.ConsoleApplication;
|
import fr.bigeon.gclc.ConsoleApplication;
|
||||||
import fr.bigeon.gclc.ConsoleManager;
|
|
||||||
import fr.bigeon.gclc.command.Command;
|
import fr.bigeon.gclc.command.Command;
|
||||||
|
import fr.bigeon.gclc.command.ICommand;
|
||||||
import fr.bigeon.gclc.exception.InvalidCommandName;
|
import fr.bigeon.gclc.exception.InvalidCommandName;
|
||||||
|
import fr.bigeon.gclc.manager.ConsoleManager;
|
||||||
|
import fr.bigeon.gclc.prompt.CLIPrompterMessages;
|
||||||
|
|
||||||
/** A test-purpose application
|
/** A test-purpose application
|
||||||
*
|
*
|
||||||
@ -50,11 +52,11 @@ public class ConsoleTestApplication extends ConsoleApplication {
|
|||||||
/** @param manager the manager */
|
/** @param manager the manager */
|
||||||
@SuppressWarnings("nls")
|
@SuppressWarnings("nls")
|
||||||
public ConsoleTestApplication(final ConsoleManager manager) {
|
public ConsoleTestApplication(final ConsoleManager manager) {
|
||||||
super(manager, EXIT,
|
super(manager, "Welcome to the test application. Type help or test.",
|
||||||
"Welcome to the test application. Type help or test.",
|
|
||||||
"See you");
|
"See you");
|
||||||
addHelpCommand("help");
|
|
||||||
try {
|
try {
|
||||||
|
add(new ExitCommand(EXIT, this));
|
||||||
|
addHelpCommand("help");
|
||||||
add(new Command("test") {
|
add(new Command("test") {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -71,4 +73,55 @@ public class ConsoleTestApplication extends ConsoleApplication {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** <p>
|
||||||
|
* A command to exit a {@link ConsoleApplication}.
|
||||||
|
*
|
||||||
|
* @author Emmanuel BIGEON */
|
||||||
|
class ExitCommand implements ICommand {
|
||||||
|
/** The exit command manual message key */
|
||||||
|
private static final String EXIT_MAN = "exit.man"; //$NON-NLS-1$
|
||||||
|
/** The tip of the exit command */
|
||||||
|
private static final String EXIT_TIP = "exit.tip"; //$NON-NLS-1$
|
||||||
|
/** The application that will be exited when this command runs */
|
||||||
|
private final ConsoleApplication app;
|
||||||
|
/** The exit command name */
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
/** @param name the name of the command
|
||||||
|
* @param app the application to exit */
|
||||||
|
public ExitCommand(String name, ConsoleApplication app) {
|
||||||
|
this.name = name;
|
||||||
|
this.app = app;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The actions to take before exiting */
|
||||||
|
public void beforeExit() {
|
||||||
|
// Do nothing by default
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void execute(String... args) {
|
||||||
|
beforeExit();
|
||||||
|
app.exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see fr.bigeon.gclc.command.ICommand#getCommandName() */
|
||||||
|
@Override
|
||||||
|
public String getCommandName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void help(ConsoleManager helpManager, String... args) {
|
||||||
|
helpManager.println(
|
||||||
|
CLIPrompterMessages.getString(EXIT_MAN, (Object[]) args));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String tip() {
|
||||||
|
return CLIPrompterMessages.getString(EXIT_TIP);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>fr.bigeon</groupId>
|
<groupId>fr.bigeon</groupId>
|
||||||
<artifactId>gclc</artifactId>
|
<artifactId>gclc</artifactId>
|
||||||
<version>1.1.1</version>
|
<version>1.1.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.swt.gtk.linux</groupId>
|
<groupId>org.eclipse.swt.gtk.linux</groupId>
|
||||||
|
@ -38,6 +38,8 @@
|
|||||||
*/
|
*/
|
||||||
package fr.bigeon.gclc.swt;
|
package fr.bigeon.gclc.swt;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.events.FocusAdapter;
|
import org.eclipse.swt.events.FocusAdapter;
|
||||||
import org.eclipse.swt.events.FocusEvent;
|
import org.eclipse.swt.events.FocusEvent;
|
||||||
@ -53,7 +55,7 @@ import org.eclipse.swt.widgets.Text;
|
|||||||
import fr.bigeon.collections.ArrayRibbon;
|
import fr.bigeon.collections.ArrayRibbon;
|
||||||
import fr.bigeon.collections.Ribbon;
|
import fr.bigeon.collections.Ribbon;
|
||||||
import fr.bigeon.gclc.ConsoleApplication;
|
import fr.bigeon.gclc.ConsoleApplication;
|
||||||
import fr.bigeon.gclc.ConsoleManager;
|
import fr.bigeon.gclc.manager.ConsoleManager;
|
||||||
|
|
||||||
/** A SWT component to connect to gclc {@link ConsoleApplication}
|
/** A SWT component to connect to gclc {@link ConsoleApplication}
|
||||||
* <p>
|
* <p>
|
||||||
@ -320,4 +322,12 @@ public class SWTConsole extends Composite implements ConsoleManager {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see fr.bigeon.gclc.manager.ConsoleManager#close() */
|
||||||
|
@Override
|
||||||
|
public void close() throws IOException {
|
||||||
|
consoleInput.setEnabled(false);
|
||||||
|
consoleOutput.setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ import org.eclipse.swt.layout.FillLayout;
|
|||||||
import org.eclipse.swt.widgets.Display;
|
import org.eclipse.swt.widgets.Display;
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
|
||||||
import fr.bigeon.gclc.ConsoleManager;
|
import fr.bigeon.gclc.manager.ConsoleManager;
|
||||||
|
|
||||||
/** A shell containing a {@link SWTConsole}
|
/** A shell containing a {@link SWTConsole}
|
||||||
* <p>
|
* <p>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user