Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add commandline parameters #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions 5.0.0/ARO.UI/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@
<artifactId>jmf</artifactId>
<version>2.1.1e</version>
</dependency>
<dependency>
<groupId>com.beust</groupId>
<artifactId>jcommander</artifactId>
<version>1.30</version>
</dependency>

</dependencies>

Expand Down
100 changes: 82 additions & 18 deletions 5.0.0/ARO.UI/src/main/java/com/att/aro/ui/view/MainFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@
import com.att.aro.ui.view.video.LiveScreenViewDialog;
import com.att.aro.ui.view.waterfalltab.WaterfallTab;
import com.att.aro.view.images.Images;
import com.beust.jcommander.IParameterValidator;
import com.beust.jcommander.IStringConverter;
import com.beust.jcommander.JCommander;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.ParameterException;

public class MainFrame implements SharedAttributesProcesses {

Expand Down Expand Up @@ -128,16 +133,73 @@ public AROController getController() {
return controller;
}

public static class CommandLineParams {
@Parameter(names = {"--help", "-h", "-?"}, description = "show help", help = true)
private boolean help = false;

@Parameter(names = "--input", converter = FileConverter.class,
validateWith = ValidateInput.class, description = "open report located in directory")
private File input;

@Parameter(names = "--splash", description = "display splashscreen upon startup", arity = 1, hidden = true)
private boolean isSplashRequired = true;

public File getInputDirectory() {
return input;
}

public boolean isSplashRequired() {
return isSplashRequired;
}

public static class ValidateInput implements IParameterValidator {
public void validate(String name, String value)
throws ParameterException {
File input = new File(value);
if (!input.exists()) {
throw new ParameterException("File not found: " + value);
}
}
}

public static class FileConverter implements IStringConverter<File> {
public File convert(String value) {
return new File(value);
}
}
}

/**
* Launch the application.
*/
public static void main(String[] args) {
CommandLineParams cmds = new CommandLineParams();
JCommander commandLineParser = new JCommander(cmds);
try {
commandLineParser.parse(args);
if (cmds.help) {
commandLineParser.usage();
System.exit(0);
} else {
startUI(cmds);
}
} catch (ParameterException ex) {
System.err.println("Error parsing command: " + ex.getMessage());
commandLineParser.usage();
System.exit(1);
}
}

private static void startUI(final CommandLineParams params) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
try {
window = new MainFrame();
window.frmApplicationResourceOptimizer.setVisible(true);

File input = params.getInputDirectory();
if (input != null) {
window.updateTracePath(input);
}
} catch (Exception e) {
e.printStackTrace();
}
Expand All @@ -156,25 +218,27 @@ public void run() {
//fail quietly
}
}
final SplashScreen splash = new SplashScreen();
splash.setVisible(true);
splash.setAlwaysOnTop(true);
new SwingWorker<Object, Object>() {

@Override
protected Object doInBackground() {
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
if (params.isSplashRequired()) {
final SplashScreen splash = new SplashScreen();
splash.setVisible(true);
splash.setAlwaysOnTop(true);
new SwingWorker<Object, Object>() {

@Override
protected Object doInBackground() {
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
}
return null;
}
@Override
protected void done() {
splash.dispose();
}
return null;
}
@Override
protected void done() {
splash.dispose();
}

}.execute();
}.execute();
}
System.out.println("---------------------DONE---------------------");
}
});
Expand Down