protected void onSave() { try { int channelInt = Integer.parseInt(channelName.getText()); if (channelInt < 0 || channelInt > 256) { throw new Exception(); } String key = getKey(String.valueOf(channelInt)); raptorPreferenceStore.setValue(key, colorSelector.getColorValue()); boolean channelsHasSelection = false; for (int i = 0; i < channels.getItemCount(); i++) { if (channels.getItem(i).equals(String.valueOf(channelInt))) { channelsHasSelection = true; break; } } if (!channelsHasSelection) { channels.add(String.valueOf(channelInt)); } } catch (Throwable t) { MessageDialog.openInformation( Raptor.getInstance().getWindow().getShell(), local.getString("alert"), local.getString("chatConColP3")); } }
private void editPressed() { setPresentsDefaultValue(false); String value = list.getItem(list.getSelectionIndex()); value = promptForText(local.getString("entNewVal"), value); if (value != null && isTextValid(value)) { list.setItem(list.getSelectionIndex(), value); selectionChanged(); } else { showErrorMessage(local.getString("invalid") + value); } }
/** Notifies that the Add button has been pressed. */ private void addPressed() { setPresentsDefaultValue(false); String value = promptForText(local.getString("entNewVal")); if (value != null && isTextValid(value)) { int index = list.getSelectionIndex(); if (index >= 0) { list.add(value, index + 1); } else { list.add(value, 0); } selectionChanged(); } else { showErrorMessage(local.getString("invalid") + value); } }
/** * Creates the Add, Remove, Up, and Down button in the given button box. * * @param box the box for the buttons */ private void createButtons(Composite box) { addButton = createPushButton(box, "ListEditor.add", null); // $NON-NLS-1$ editButton = createPushButton(box, null, local.getString("edit")); removeButton = createPushButton(box, "ListEditor.remove", null); // $NON-NLS-1$ upButton = createPushButton(box, "ListEditor.up", null); // $NON-NLS-1$ downButton = createPushButton(box, "ListEditor.down", null); // $NON-NLS-1$ }
@Override protected void createFieldEditors() { addField( new ComboFieldEditor( PreferenceKeys.BOARD_USER_MOVE_INPUT_MODE, local.getString("chesBBehP10"), USER_MOVE_INPUT_MODE_ARRAY, getFieldEditorParent())); addField( new ComboFieldEditor( PreferenceKeys.BOARD_CLOCK_SHOW_MILLIS_WHEN_LESS_THAN, local.getString("chesBBehP11"), SHOW_TENTHS_OPTIONS, getFieldEditorParent())); addField( new ComboFieldEditor( PreferenceKeys.BOARD_CLOCK_SHOW_SECONDS_WHEN_LESS_THAN, local.getString("chesBBehP12"), SHOW_SECONDS_OPTIONS, getFieldEditorParent())); addField( new BooleanFieldEditor( PreferenceKeys.BOARD_TRAVERSE_WITH_MOUSE_WHEEL, local.getString("chesBBehP13"), getFieldEditorParent())); addField( new BooleanFieldEditor( PreferenceKeys.BOARD_ALLOW_MOUSE_WHEEL_NAVIGATION_WHEEL_PLAYING, local.getString("chesBBehP14"), getFieldEditorParent())); addField( new BooleanFieldEditor( PreferenceKeys.BOARD_ANNOUNCE_CHECK_WHEN_I_CHECK_OPPONENT, local.getString("chesBBehP15"), getFieldEditorParent())); addField( new BooleanFieldEditor( PreferenceKeys.BOARD_ANNOUNCE_CHECK_WHEN_OPPONENT_CHECKS_ME, local.getString("chesBBehP16"), getFieldEditorParent())); addField( new BooleanFieldEditor( PreferenceKeys.BOARD_IGNORE_OBSERVED_GAMES_IF_PLAYING, local.getString("chesBBehP17"), getFieldEditorParent())); addField( new BooleanFieldEditor( PreferenceKeys.BOARD_TAKEOVER_INACTIVE_GAMES, local.getString("chesBBehP18"), getFieldEditorParent())); addField( new BooleanFieldEditor( PreferenceKeys.BOARD_IS_USING_CROSSHAIRS_CURSOR, local.getString("chesBBehP19"), getFieldEditorParent())); addField( new BooleanFieldEditor( PreferenceKeys.BOARD_PLAY_ABORT_REQUEST_SOUND, local.getString("chesBBehP20"), getFieldEditorParent())); addField( new BooleanFieldEditor( PreferenceKeys.BOARD_PLAY_CHALLENGE_SOUND, local.getString("chesBBehP21"), getFieldEditorParent())); addField( new BooleanFieldEditor( PreferenceKeys.BOARD_PLAY_DRAW_OFFER_SOUND, local.getString("chesBBehP22"), getFieldEditorParent())); addField( new BooleanFieldEditor( PreferenceKeys.BOARD_PLAY_MOVE_SOUND_WHEN_OBSERVING, local.getString("chesBBehP23"), getFieldEditorParent())); addField( new BooleanFieldEditor( PreferenceKeys.BOARD_IS_PLAYING_10_SECOND_COUNTDOWN_SOUNDS, local.getString("chesBBehP24"), getFieldEditorParent())); addField( new BooleanFieldEditor( PreferenceKeys.BOARD_PREMOVE_ENABLED, local.getString("chesBBehP25"), getFieldEditorParent())); addField( new BooleanFieldEditor( PreferenceKeys.BOARD_QUEUED_PREMOVE_ENABLED, local.getString("chesBBehP26"), getFieldEditorParent())); addField( new BooleanFieldEditor( PreferenceKeys.BOARD_IS_SHOW_COORDINATES, local.getString("chesBBehP27"), getFieldEditorParent())); addField( new BooleanFieldEditor( PreferenceKeys.BOARD_IS_SHOWING_PIECE_JAIL, local.getString("chesBBehP28"), getFieldEditorParent())); addField( new BooleanFieldEditor( PreferenceKeys.BOARD_SHOW_PLAYING_GAME_STATS_ON_GAME_END, local.getString("chesBBehP29"), getFieldEditorParent())); addField( new BooleanFieldEditor( PreferenceKeys.BOARD_SPEAK_RESULTS, local.getString("chesBBehP30"), getFieldEditorParent())); addField( new BooleanFieldEditor( PreferenceKeys.BOARD_SPEAK_MOVES_I_MAKE, local.getString("chesBBehP31"), getFieldEditorParent())); addField( new BooleanFieldEditor( PreferenceKeys.BOARD_SPEAK_MOVES_OPP_MAKES, local.getString("chesBBehP32"), getFieldEditorParent())); addField( new BooleanFieldEditor( PreferenceKeys.BOARD_SPEAK_WHEN_OBSERVING, local.getString("chesBBehP33"), getFieldEditorParent())); }
public ChessBoardBehaviorPage() { // Use the "flat" layout super(GRID); setTitle(local.getString("behavior")); setPreferenceStore(Raptor.getInstance().getPreferences()); }
public class ChessBoardBehaviorPage extends FieldEditorPreferencePage { protected static L10n local = L10n.getInstance(); public static final String[][] USER_MOVE_INPUT_MODE_ARRAY = { {local.getString("dragNDrop"), UserMoveInputMode.DragAndDrop.toString()}, {local.getString("clClMove"), UserMoveInputMode.ClickClickMove.toString()} }; public static final String[][] SHOW_SECONDS_OPTIONS = { {local.getString("always"), "" + Integer.MAX_VALUE}, {local.getString("chesBBehP1"), "" + (60 * 60 * 1000 + 1)}, {local.getString("chesBBehP2"), "" + (30 * 60 * 1000 + 1)}, {local.getString("chesBBehP3"), "" + (15 * 60 * 1000 + 1)}, {local.getString("chesBBehP4"), "" + (10 * 60 * 1000 + 1)} }; public static final String[][] SHOW_TENTHS_OPTIONS = { {local.getString("never"), "" + Integer.MIN_VALUE}, {local.getString("chesBBehP5"), "" + (10 * 1000 + 1)}, {local.getString("chesBBehP6"), "" + (60 * 1000 + 1)}, {local.getString("chesBBehP7"), "" + (3 * 60 * 1000 + 1)}, {local.getString("chesBBehP8"), "" + (5 * 60 * 1000 + 1)}, {local.getString("chesBBehP9"), "" + (10 * 60 * 1000 + 1)}, {local.getString("always"), "" + Integer.MAX_VALUE} }; public ChessBoardBehaviorPage() { // Use the "flat" layout super(GRID); setTitle(local.getString("behavior")); setPreferenceStore(Raptor.getInstance().getPreferences()); } @Override protected void createFieldEditors() { addField( new ComboFieldEditor( PreferenceKeys.BOARD_USER_MOVE_INPUT_MODE, local.getString("chesBBehP10"), USER_MOVE_INPUT_MODE_ARRAY, getFieldEditorParent())); addField( new ComboFieldEditor( PreferenceKeys.BOARD_CLOCK_SHOW_MILLIS_WHEN_LESS_THAN, local.getString("chesBBehP11"), SHOW_TENTHS_OPTIONS, getFieldEditorParent())); addField( new ComboFieldEditor( PreferenceKeys.BOARD_CLOCK_SHOW_SECONDS_WHEN_LESS_THAN, local.getString("chesBBehP12"), SHOW_SECONDS_OPTIONS, getFieldEditorParent())); addField( new BooleanFieldEditor( PreferenceKeys.BOARD_TRAVERSE_WITH_MOUSE_WHEEL, local.getString("chesBBehP13"), getFieldEditorParent())); addField( new BooleanFieldEditor( PreferenceKeys.BOARD_ALLOW_MOUSE_WHEEL_NAVIGATION_WHEEL_PLAYING, local.getString("chesBBehP14"), getFieldEditorParent())); addField( new BooleanFieldEditor( PreferenceKeys.BOARD_ANNOUNCE_CHECK_WHEN_I_CHECK_OPPONENT, local.getString("chesBBehP15"), getFieldEditorParent())); addField( new BooleanFieldEditor( PreferenceKeys.BOARD_ANNOUNCE_CHECK_WHEN_OPPONENT_CHECKS_ME, local.getString("chesBBehP16"), getFieldEditorParent())); addField( new BooleanFieldEditor( PreferenceKeys.BOARD_IGNORE_OBSERVED_GAMES_IF_PLAYING, local.getString("chesBBehP17"), getFieldEditorParent())); addField( new BooleanFieldEditor( PreferenceKeys.BOARD_TAKEOVER_INACTIVE_GAMES, local.getString("chesBBehP18"), getFieldEditorParent())); addField( new BooleanFieldEditor( PreferenceKeys.BOARD_IS_USING_CROSSHAIRS_CURSOR, local.getString("chesBBehP19"), getFieldEditorParent())); addField( new BooleanFieldEditor( PreferenceKeys.BOARD_PLAY_ABORT_REQUEST_SOUND, local.getString("chesBBehP20"), getFieldEditorParent())); addField( new BooleanFieldEditor( PreferenceKeys.BOARD_PLAY_CHALLENGE_SOUND, local.getString("chesBBehP21"), getFieldEditorParent())); addField( new BooleanFieldEditor( PreferenceKeys.BOARD_PLAY_DRAW_OFFER_SOUND, local.getString("chesBBehP22"), getFieldEditorParent())); addField( new BooleanFieldEditor( PreferenceKeys.BOARD_PLAY_MOVE_SOUND_WHEN_OBSERVING, local.getString("chesBBehP23"), getFieldEditorParent())); addField( new BooleanFieldEditor( PreferenceKeys.BOARD_IS_PLAYING_10_SECOND_COUNTDOWN_SOUNDS, local.getString("chesBBehP24"), getFieldEditorParent())); addField( new BooleanFieldEditor( PreferenceKeys.BOARD_PREMOVE_ENABLED, local.getString("chesBBehP25"), getFieldEditorParent())); addField( new BooleanFieldEditor( PreferenceKeys.BOARD_QUEUED_PREMOVE_ENABLED, local.getString("chesBBehP26"), getFieldEditorParent())); addField( new BooleanFieldEditor( PreferenceKeys.BOARD_IS_SHOW_COORDINATES, local.getString("chesBBehP27"), getFieldEditorParent())); addField( new BooleanFieldEditor( PreferenceKeys.BOARD_IS_SHOWING_PIECE_JAIL, local.getString("chesBBehP28"), getFieldEditorParent())); addField( new BooleanFieldEditor( PreferenceKeys.BOARD_SHOW_PLAYING_GAME_STATS_ON_GAME_END, local.getString("chesBBehP29"), getFieldEditorParent())); addField( new BooleanFieldEditor( PreferenceKeys.BOARD_SPEAK_RESULTS, local.getString("chesBBehP30"), getFieldEditorParent())); addField( new BooleanFieldEditor( PreferenceKeys.BOARD_SPEAK_MOVES_I_MAKE, local.getString("chesBBehP31"), getFieldEditorParent())); addField( new BooleanFieldEditor( PreferenceKeys.BOARD_SPEAK_MOVES_OPP_MAKES, local.getString("chesBBehP32"), getFieldEditorParent())); addField( new BooleanFieldEditor( PreferenceKeys.BOARD_SPEAK_WHEN_OBSERVING, local.getString("chesBBehP33"), getFieldEditorParent())); } }
@Override protected Control createContents(Composite parent) { parent = new Composite(parent, SWT.NONE); parent.setLayout(new GridLayout(3, false)); Label label = new Label(parent, SWT.NONE); label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1)); label.setText( WordUtils.wrap(local.getString("chatConColP1"), 70) + WordUtils.wrap(local.getString("chatConColP2"), 70)); Label channelNamesLabel = new Label(parent, SWT.NONE); channelNamesLabel.setText(local.getString("channels")); channelNamesLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1)); channels = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY); channels.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1)); channels.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { String selectedChannelName = channels.getItem(channels.getSelectionIndex()); channelName.setText(selectedChannelName); String key = getKey(selectedChannelName); colorSelector.setColorValue(raptorPreferenceStore.getColor(key).getRGB()); } }); Label channelNameLabel = new Label(parent, SWT.NONE); channelNameLabel.setText(local.getString("chanName")); channelNameLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1)); channelName = new Text(parent, SWT.SINGLE | SWT.BORDER); channelName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); colorSelector = new ColorSelector(parent); colorSelector.getButton().setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1)); saveButton = new Button(parent, SWT.PUSH); saveButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 3, 1)); saveButton.setText(local.getString("svAddChCol")); saveButton.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { onSave(); } }); // deleteButton = new Button(parent, SWT.PUSH); // deleteButton.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, // false, 2, 1)); // deleteButton.setText("Delete Channel Color"); // deleteButton.addSelectionListener(new SelectionAdapter() { // @Override // public void widgetSelected(SelectionEvent e) { // try { // int channelInt = Integer.parseInt(channelName.getText()); // String key = getKey("" + channelInt); // channels.remove("" + channelInt); // raptorPreferenceStore.putValue(key, null); // } catch (NumberFormatException nfe) { // MessageDialog // .openInformation(Raptor.getInstance() // .getRaptorWindow().getShell(), "Alert", // "Channel name must be an integer greater than -1 and less than 256."); // } // } // }); updateChannelsCombo(); if (channels.getItemCount() > 0) { channels.select(0); String selectedChannelName = channels.getItem(channels.getSelectionIndex()); channelName.setText(selectedChannelName); String key = getKey(selectedChannelName); colorSelector.setColorValue(raptorPreferenceStore.getColor(key).getRGB()); } return parent; }
public ChatConsoleChannelColorsPage() { // Use the "flat" layout super(); setPreferenceStore(raptorPreferenceStore = Raptor.getInstance().getPreferences()); setTitle(local.getString("chanCol")); }