extends AbstractPrompter
implements Prompter
{
-
- /**
- * Create dialog for user interaction
- *
- * @param question message for dialog
- * @param optionNames option names for dialog
- * @param defaultOptionIndex initial selection for option
- *
- * @return {@link Dialog} for user selection
- */
- protected
- Dialog
- createDialog(
- final String question,
- final String[] optionNames,
- final int defaultOptionIndex
- )
- {
- return new MessageDialog(
- getActiveShell(),
- "Question",
- null,
- question,
- MessageDialog.QUESTION,
- optionNames,
- defaultOptionIndex
- )
- {
- protected void buttonPressed( int buttonId )
- {
- setReturnCode( buttonId );
- close();
- }
- };
- }
+
+ /**
+ * Create dialog for user interaction
+ *
+ * @param question message for dialog
+ * @param optionNames option names for dialog
+ * @param defaultOptionIndex initial selection for option
+ *
+ * @return {@link Dialog} for user selection
+ */
+ protected
+ Dialog
+ createDialog(
+ final String question,
+ final String[] optionNames,
+ final int defaultOptionIndex
+ )
+ {
+ return new MessageDialog(
+ getActiveShell(),
+ "Question",
+ null,
+ question,
+ MessageDialog.QUESTION,
+ optionNames,
+ defaultOptionIndex
+ )
+ {
+ protected void buttonPressed( int buttonId )
+ {
+ setReturnCode( buttonId );
+ close();
+ }
+ };
+ }
- /* (non-Javadoc)
- * @see org.tizen.common.core.command.Prompter#interact(java.lang.String, org.tizen.common.core.command.prompter.Option[])
- */
- @Override
- public
- Option
- interact(
- final String question,
- final Option... options
- )
- {
- final HashSet<Option> reducedOptions = new LinkedHashSet<Option>();
- Option defaultOption = null;
- final ArrayList<String> optionNames = new ArrayList<String>();
- for ( final Option option : options )
- {
- if ( reducedOptions.contains( option ) )
- {
- throw new IllegalArgumentException(
- "Question can't have duplicated choice(s) :" + option
- );
- }
- optionNames.add( option.getName() );
- reducedOptions.add( option );
- if ( option.isDefault() )
- {
- if ( null != defaultOption )
- {
- throw new IllegalArgumentException(
- "Question must have only one default choice"
- );
- }
-
- defaultOption = option;
- }
- }
- final int defaultIndex = optionNames.indexOf( defaultOption.getName() );
-
- return exec( new SWTRunner<Option>()
+ /* (non-Javadoc)
+ * @see org.tizen.common.core.command.Prompter#interact(java.lang.String, org.tizen.common.core.command.prompter.Option[])
+ */
+ @Override
+ public
+ Option
+ interact(
+ final String question,
+ final Option... options
+ )
+ {
+ final HashSet<Option> reducedOptions = new LinkedHashSet<Option>();
+ Option defaultOption = null;
+ final ArrayList<String> optionNames = new ArrayList<String>();
+ for ( final Option option : options )
{
- /* (non-Javadoc)
- * @see org.tizen.common.util.SWTRunner#process()
- */
- public Option process() {
- final Dialog dialog = createDialog( question, optionNames.toArray( new String[0] ), defaultIndex );
- dialog.open();
- return options[dialog.getReturnCode()];
- }
- } );
- }
+ if ( reducedOptions.contains( option ) )
+ {
+ throw new IllegalArgumentException(
+ "Question can't have duplicated choice(s) :" + option
+ );
+ }
+ optionNames.add( option.getName() );
+ reducedOptions.add( option );
+ if ( option.isDefault() )
+ {
+ if ( null != defaultOption )
+ {
+ throw new IllegalArgumentException(
+ "Question must have only one default choice"
+ );
+ }
+
+ defaultOption = option;
+ }
+ }
+ final int defaultIndex = ( defaultOption != null ) ? optionNames.indexOf( defaultOption.getName() ) : 0;
+
+ return exec( new SWTRunner<Option>()
+ {
+ /* (non-Javadoc)
+ * @see org.tizen.common.util.SWTRunner#process()
+ */
+ public Option process() {
+ final Dialog dialog = createDialog( question, optionNames.toArray( new String[0] ), defaultIndex );
+ dialog.open();
+ return options[dialog.getReturnCode()];
+ }
+ } );
+ }
- /* (non-Javadoc)
- * @see org.tizen.common.core.command.Prompter#notify(java.lang.String, java.lang.Object[])
- */
- @Override
- public void
- notify(
- final String message
- )
- {
- asyncExec( new Runnable() {
-
- /* (non-Javadoc)
- * @see java.lang.Runnable#run()
- */
- @Override
- public void run() {
- NotifierDialog.notify( "Notify", message, NotificationType.INFO );
- }
- } );
- }
+ /* (non-Javadoc)
+ * @see org.tizen.common.core.command.Prompter#notify(java.lang.String, java.lang.Object[])
+ */
+ @Override
+ public void
+ notify(
+ final String message
+ )
+ {
+ asyncExec( new Runnable() {
+
+ /* (non-Javadoc)
+ * @see java.lang.Runnable#run()
+ */
+ @Override
+ public void run() {
+ NotifierDialog.notify( "Notify", message, NotificationType.INFO );
+ }
+ } );
+ }
- /* (non-Javadoc)
- * @see org.tizen.common.core.command.Prompter#cancel()
- */
- @Override
- public void cancel() {
- }
+ /* (non-Javadoc)
+ * @see org.tizen.common.core.command.Prompter#cancel()
+ */
+ @Override
+ public void cancel() {
+ }
- /* (non-Javadoc)
- * @see org.tizen.common.core.command.Prompter#password(java.lang.String)
- */
- @Override
- public
- Object password(
- final String message
- )
- {
- return exec( new SWTRunner<char[]>()
+ /* (non-Javadoc)
+ * @see org.tizen.common.core.command.Prompter#password(java.lang.String)
+ */
+ @Override
+ public
+ Object password(
+ final String message
+ )
+ {
+ return exec( new SWTRunner<char[]>()
{
- /* (non-Javadoc)
- * @see java.lang.Runnable#run()
- */
- @Override
- public char[] process()
- {
- final PasswordInputDialog dialog =
- new PasswordInputDialog( "Password Input Dialog", message );
-
- dialog.open();
-
- if ( IDialogConstants.OK_ID != dialog.getReturnCode() )
- {
- return null;
- }
-
- return trim( dialog.getValue() ).toCharArray();
- }
- } );
-
-
-
- }
+ /* (non-Javadoc)
+ * @see java.lang.Runnable#run()
+ */
+ @Override
+ public char[] process()
+ {
+ final PasswordInputDialog dialog =
+ new PasswordInputDialog( "Password Input Dialog", message );
+
+ dialog.open();
+
+ if ( IDialogConstants.OK_ID != dialog.getReturnCode() )
+ {
+ return null;
+ }
+
+ return trim( dialog.getValue() ).toCharArray();
+ }
+ } );
+
+
+
+ }
- /* (non-Javadoc)
- * @see org.tizen.common.core.command.Prompter#error(java.lang.String, java.lang.Object[])
- */
- @Override
- public
- void
- error(
- final String message
- )
- {
- syncExec( new Runnable() {
-
- /* (non-Javadoc)
- * @see java.lang.Runnable#run()
- */
- @Override
- public void run() {
- MessageDialog.openError( getActiveShell(), "Error", message );
- }
- } );
-
- }
+ /* (non-Javadoc)
+ * @see org.tizen.common.core.command.Prompter#error(java.lang.String, java.lang.Object[])
+ */
+ @Override
+ public
+ void
+ error(
+ final String message
+ )
+ {
+ syncExec( new Runnable() {
+
+ /* (non-Javadoc)
+ * @see java.lang.Runnable#run()
+ */
+ @Override
+ public void run() {
+ MessageDialog.openError( getActiveShell(), "Error", message );
+ }
+ } );
+
+ }
/* (non-Javadoc)
* @see org.tizen.common.core.command.Prompter#batch(java.util.Collection)