GXT Fieldset Checkbox toggle - gxt

I am using sencha gxt 3.x, the Fieldset comes with default toggleButton, instead of button I want to display checkbox.
The older version of gxt 2.x has fieldSet.setCheckboxToggle(true) which was removed in 3.x, is there a workaround solution to toggle fieldset with checkbox?
Thanks

public class CheckedFieldSet extends FieldSet {
HBoxLayoutContainer bar = new HBoxLayoutContainer();
CheckBox state = new CheckBox();
#Override
protected void onAfterFirstAttach() {
super.onAfterFirstAttach();
bar.add(getCollapseButton());
bar.add(state);
if (isCollapsible()) {
state.addChangeHandler(new ChangeHandler() {
#Override
public void onChange(ChangeEvent event) {
if (state.getValue()) {
ComponentHelper.doAttach(asWidget());
} else {
ComponentHelper.doDetach(asWidget());
}
}
});
ComponentHelper.doAttach(state);
getAppearance().getToolElement(getElement()).appendChild(bar.getElement());
}
}
public HandlerRegistration addChangeHandler(ChangeHandler handler){
return state.addChangeHandler(handler);
}
public void setActive(boolean state){
this.state.setValue(state, true, true);
}
}

Related

Xamarin iOS: How to hide seek bar in AvPlayer?

I'm building an app in xamarin ios using AvPlayer. How can I hide the seek bar ?
_playerViewController = new CustomAVPlayerViewController();
_player = new AVPlayer();
_playerViewController.Player = _player;
SetNativeControl(_playerViewController.View);
public class CustomAVPlayerViewController: AVPlayerViewController
{
public override void ViewDidAppear(bool animated)
{
base.ViewDidAppear(animated);
}
}
If you don't want to show the controls or want to highly customize the appearance, I recommend you to use AVPlayerLayer:
public class CustomPlayerRenderer : ViewRenderer<CustomPlayer, UIView>
{
AVPlayer _player;
AVPlayerLayer _playerLayer;
protected override void OnElementChanged(ElementChangedEventArgs<CustomPlayer1> e)
{
base.OnElementChanged(e);
if (Control == null)
{
_player = new AVPlayer(new NSUrl(NSBundle.MainBundle.PathForResource("sample.mp4", null), false));
_playerLayer = AVPlayerLayer.FromPlayer(_player);
UIView view = new UIView();
view.Layer.AddSublayer(_playerLayer);
SetNativeControl(view);
//_player.Play();
// Add custom controls as you want on this view
}
}
public override void Draw(CGRect rect)
{
base.Draw(rect);
_playerLayer.Frame = rect;
}
}

Add action on ObservableList item in javafx

I am using javafx to make a ListView in which add Observable List which contains buttons.
I want to add action on each buttons in this lists.Any help...
ObservableList videoLists = null;
if (listView.getSelectionModel().getSelectedItem().equals("class 8")) {
classTitleID.setText("class 8 video lists");
File physicsFolder = new File("D:\\videos\\physics");
File[] listOfFiles = physicsFolder.listFiles();
videoLists = FXCollections.observableArrayList();
for (File file : listOfFiles) {
if (file.isFile()) {
videoLists.add(new Button(file.getName()));
physicsListview.setItems(videoLists);
}
}
}
simply do
for (File file : listOfFiles) {
if (file.isFile()) {
Button button = new Button(file.getName());
button.setOnAction(new EventHandler<ActionEvent>() {
#Override
public void handle(ActionEvent actionEvent) {
//your action
}
});
videoLists.add(button);
physicsListview.setItems(videoLists);
}
}
It's generally a bad idea to have Node subclasses as the data type in ListViews (or TableViews, ComboBoxes, etc): it breaks MVC. Make your ListView a ListView<File> and use a cellFactory to show the button in the ListView cells. You can set the action handler there.
ListView<File> physicsListview = new ListView<>();
ObservableList<File> videoLists = FCollections.observableArrayList();
//...
for (File file : listOfFiles) {
if (file.isFile()) {
videoLists.add(file);
}
}
physicsListview.setItems(videoLists);
physicsListview.setCellFactory(new Callback<ListView<File>, ListCell<File>>() {
#Override
public ListCell<File> call(ListView<File>()) {
final Button button = new Button();
return new ListCell<File>() {
#Override
public void updateItem(final File item, boolean empty) {
super.updateItem(item, empty);
if (empty) {
setGraphic(null);
} else {
button.setText(item.getName());
button.setOnAction(new EventHandler<ActionEvent>() {
#Override
public void handle(ActionEvent event) {
// handle action.
// You can access the File object item here if needed
}
});
setGraphic(button);
}
}
};
});
});

Cannot properly set visible component

I'm trying to implement Menu with select box which sets to display or not component. I have this checkbox:
final CheckMenuItem toolbarSubMenuNavigation = new CheckMenuItem("Navigation");
toolbarSubMenuNavigation.setOnAction(new EventHandler<ActionEvent>()
{
#Override
public void handle(ActionEvent e)
{
DataTabs.renderTab = toolbarSubMenuNavigation.isSelected();
// call here the getter setter and send boolean flag
System.out.println("subsystem1 #1 Enabled!");
}
});
And I have this tabpane which I want to render only if I have selected the checkbox:
public static boolean renderTab;
public DataTabs()
{
}
public boolean isRenderTab()
{
return renderTab;
}
public void setRenderTab(boolean renderTab)
{
this.renderTab = renderTab;
}
// below this code
tabPane.setVisible(renderTab);
When I run the code it's not working. I also tested this:
DataTabs tabs = new DataTabs(); // instantiate first
tabs.setRenderTab(toolbarSubMenuNavigation.isSelected());
public static boolean renderTab;
TabPane tabPane = new TabPane();
public DataTabs()
{
}
public boolean isRenderTab()
{
return renderTab;
}
public void setRenderTab(boolean renderTab)
{
tabPane.setVisible(renderTab);
}
But again there is no result when I run the code and I check or uncheck the checkbox.
This is the complete source code:
http://pastebin.com/tkj4Fby1
Maybe I need to add listener or something else which I'm missing?
EDIT
Test 3
I also tested this code:
final CheckMenuItem toolbarSubMenuNavigation = new CheckMenuItem("Navigation");
toolbarSubMenuNavigation.setOnAction(new EventHandler<ActionEvent>()
{
#Override
public void handle(ActionEvent e)
{
DataTabs.toolbarSubMenuNavigation = toolbarSubMenuNavigation;
// call here the getter setter and send boolean flag
System.out.println("subsystem1 #1 Enabled!");
}
});
// class with tabs
public static CheckMenuItem toolbarSubMenuNavigation;
public static CheckMenuItem getToolbarSubMenuNavigation()
{
return toolbarSubMenuNavigation;
}
public static void setToolbarSubMenuNavigation(CheckMenuItem toolbarSubMenuNavigation)
{
DataTabs.toolbarSubMenuNavigation = toolbarSubMenuNavigation;
}
// below
abPane.visibleProperty().bind(toolbarSubMenuNavigation.selectedProperty());
I get NPE when I run the code.
You can easely tell to your tab to be visible when you check the box in one line
yourTab.visibleProperty().bind(yourCheckBox.selectedProperty());
And just with this line your tabpane will be visible only when it's checked

How to make checkbox or combobox readonly in JavaFX

How to make checkbox/combobox readonly in javaFX but not disabled.
I tried consuming onAction event but it didn't work.
checkBox.setOnAction(new EventHandler<ActionEvent>() {
#Override
public void handle(ActionEvent event) {
event.consume();
}
});
Consuming all events like in code below works but I don't think it's a good solution:
checkBox.addEventFilter(KeyEvent.ANY, new EventHandler<KeyEvent>() {
#Override
public void handle(KeyEvent event) {
event.consume();
}
});
checkBox.addEventFilter(MouseEvent.ANY, new EventHandler<MouseEvent>() {
#Override
public void handle(MouseEventevent) {
event.consume();
}
});
You can set the check box to disabled but set the the look of it using CSS. If you are using the default style you can make the check box look 'normal' by setting full opacity.
checkbox.setStyle("-fx-opacity: 1");
It is probably a similar deal with the combo box.
You can override method CheckBox#arm() with an empty one:
CheckBox cb = new CheckBox("hi") {
#Override
public void arm() {
// intentionally do nothing
}
};
If you do not want to overwrite the CheckBok class, you can use the selectedProperty.
CheckBox cb = new CheckBox("hi");
cb.selectedProperty().addListener(new NCL());
class NCL implements ChangeListener<Boolean> {
#Override
public void changed(ObservableValue<? extends Boolean> ov, Boolean old_val, Boolean new_val) {
cb.setSelected(false);
}
}

LWUIT 1.4 - Why doesn't the virtual keyboard appear after first show during textfield edit?

I want to show the virtual keyboard when the user is editing the textfield. I take this approach :
public class ChpModif extends TextField {
public ChpModif(int maxChars, FocusListener focusListener, DataChangedListener dataChangeListener, VirtualKeyboard vkb)
{
super();
setReplaceMenu(false);
if (maxChars != -1)
setMaxSize(maxChars);
addFocusListener(focusListener);
addDataChangeListener(dataChangeListener);
if (vkb != null)
VirtualKeyboard.bindVirtualKeyboard(this, vkb);
}
protected Command installCommands(Command clear, Command t9)
{
return null;
}
}
public class ModifierFicheClient extends Ecran implements ActionListener, DataChangedListener, FocusListener
{
private VirtualKeyboard vkNombre = new VirtualKeyboard();
private String textFieldStatus, listBoxStatus;
private ListBox genretxt;
private boolean modifFromUpdate;
private ChpModif nomtxt,prenomtxt,cintxt,adressetxt/*,genretxt*/,lieutxt,professiontxt,courieltxt,teltxt,datenaisstxt;
private Component cursorItem;
...
public ModifierFicheClient(SmartPhoneBanking controller,String prosp_id,int recordStoreID,Form prevForm)
{
super("");
vkNombre.setInputModeOrder(new String[]{VirtualKeyboard.NUMBERS_SYMBOLS_MODE});
...
modifFromUpdate = false;
cintxt = new ChpModif(12, this, this, vkNombre);
...
}
public void dataChanged(int type, int index) {
textFieldStatus = "CHANGED";
if (!modifFromUpdate)
{
try
{
if (type == DataChangedListener.ADDED || type == DataChangedListener.CHANGED || type == DataChangedListener.REMOVED)
{
if (Display.getInstance().isVirtualKeyboardShowingSupported())
{
if (!Display.getInstance().isVirtualKeyboardShowing())
cursorItem.pointerReleased(cursorItem.getAbsoluteX(), cursorItem.getAbsoluteY());
}
}
}
catch (ClassCastException cce)
{}
}
}
public void focusGained(Component chp) {
cursorItem = chp;
}
public void focusLost(Component arg0) {
}
protected void onShowCompleted()
{
...
update();
}
public void update()
{
modifFromUpdate = true;
cintxt.setText(fichesignalitique.elementAt(0).toString());
...
modifFromUpdate = false;
}
...
}
The problem is that at the first time when I edit the textfield then the virtualkeyboard is shown ; then I click the Ok button of the virtualkeyboard , and then I edit again the textfield. But in this time the virtualkeyboard is not shown !
So how to make the virtualkeyboard shown everytime I edit the textfield ?
Its entirely possible that this is a 1.4 bug that was fixed in 1.5 since I can't see it right now. The VKB was brand new in 1.4 .

Resources