forked from Kunagi/ilarkesto
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
38 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
/* | ||
* Copyright 2011 Witoslaw Koczewsi <[email protected]>, Artjom Kochtchi | ||
* | ||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public | ||
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) | ||
* any later version. | ||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero | ||
* General Public License as published by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the | ||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License | ||
* for more details. | ||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public | ||
* License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with this program. If not, see | ||
* <http://www.gnu.org/licenses/>. | ||
*/ | ||
package ilarkesto.gwt.client; | ||
|
||
import ilarkesto.core.base.ToHtmlSupport; | ||
import ilarkesto.core.logging.Log; | ||
|
||
import java.util.LinkedHashMap; | ||
import java.util.Map; | ||
|
||
import com.google.gwt.event.dom.client.ChangeEvent; | ||
import com.google.gwt.event.dom.client.ChangeHandler; | ||
import com.google.gwt.user.client.ui.FocusListener; | ||
import com.google.gwt.user.client.ui.HTML; | ||
import com.google.gwt.user.client.ui.ListBox; | ||
import com.google.gwt.user.client.ui.Widget; | ||
|
@@ -41,11 +41,17 @@ protected final Widget onViewerInitialization() { | |
protected final Widget onEditorInitialization() { | ||
editor = new ListBox(); | ||
editor.addChangeHandler(new EditorChangeListener()); | ||
editor.addFocusListener(new EditorFocusListener()); | ||
editor.addKeyDownHandler(new CancelKeyHandler()); | ||
editor.setVisibleItemCount(7); | ||
return editor; | ||
} | ||
|
||
@Override | ||
protected void onEditorUpdate() { | ||
Log.DEBUG("----------> ADropdownViewEditWidget.updateEditor()"); | ||
editor.setFocus(true); | ||
} | ||
|
||
public final void setOptions(String... options) { | ||
Map<String, String> optionsAsKeyLabelMap = new LinkedHashMap<String, String>(); | ||
for (String option : options) { | ||
|
@@ -100,14 +106,4 @@ public void onChange(ChangeEvent event) { | |
|
||
} | ||
|
||
private class EditorFocusListener implements FocusListener { | ||
|
||
public void onFocus(Widget sender) {} | ||
|
||
public void onLostFocus(Widget sender) { | ||
submitEditor(); | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
/* | ||
* Copyright 2011 Witoslaw Koczewsi <[email protected]>, Artjom Kochtchi | ||
* | ||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public | ||
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) | ||
* any later version. | ||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero | ||
* General Public License as published by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the | ||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License | ||
* for more details. | ||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public | ||
* License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with this program. If not, see | ||
* <http://www.gnu.org/licenses/>. | ||
|
@@ -21,6 +21,7 @@ | |
import java.util.List; | ||
import java.util.Map; | ||
|
||
import com.google.gwt.event.dom.client.KeyDownHandler; | ||
import com.google.gwt.user.client.ui.CheckBox; | ||
import com.google.gwt.user.client.ui.FlexTable; | ||
import com.google.gwt.user.client.ui.FocusListener; | ||
|
@@ -103,4 +104,14 @@ public void addFocusListener(FocusListener focusListener) { | |
panel.addFocusListener(focusListener); | ||
} | ||
|
||
public void addKeyDownHandler(KeyDownHandler handler) { | ||
initialize(); | ||
panel.addKeyDownHandler(handler); | ||
} | ||
|
||
public void setFocus(boolean focus) { | ||
initialize(); | ||
panel.setFocus(focus); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
/* | ||
* Copyright 2011 Witoslaw Koczewsi <[email protected]>, Artjom Kochtchi | ||
* | ||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public | ||
* License as published by the Free Software Foundation, either version 3 of the License, or (at your option) | ||
* any later version. | ||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero | ||
* General Public License as published by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the | ||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License | ||
* for more details. | ||
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public | ||
* License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with this program. If not, see | ||
* <http://www.gnu.org/licenses/>. | ||
|
@@ -41,6 +41,7 @@ protected void onViewerUpdate() { | |
|
||
@Override | ||
protected void onEditorUpdate() { | ||
|
||
options = model.getOptions(); | ||
Map<String, String> optionsMap = new LinkedHashMap<String, String>(); | ||
int index = 0; | ||
|
@@ -49,14 +50,14 @@ protected void onEditorUpdate() { | |
index++; | ||
} | ||
setOptions(optionsMap); | ||
super.onEditorUpdate(); | ||
} | ||
|
||
@Override | ||
protected void onEditorSubmit() { | ||
String selected = getSelectedOption(); | ||
int index = Integer.parseInt(selected); | ||
model.changeValue(options.get(index)); | ||
// TODO catch exceptions | ||
} | ||
|
||
@Override | ||
|