Docker Beta on OSX with NetBeans 8.2 workaround

The next release of NetBeans (8.2) has a cool new build-in support for Docker.

Get latest NetBeans development build here.

nb_dev
docker_beta

But since I switched to native Docker integration on my Mac the connection broke as now Docker communicates via socket instead of docker-machine URL:

unix:///var/tmp/docker.sock

NetBeans would like to get a valid http or https URL, thus this URI scheme is currently not supported:

nb_docker1

But with help of socat (e.g. via brew install socat) you can create a TCP port (e.g. 9090) listening on localhost attached to the Docker socket to establish a bidirectional connection:

socat tcp-listen:9090,fork UNIX:///var/run/docker.sock

socat

Now we are talking

nb_docker2

nb_docker3

nb_docker4

nb_docker5

nb_docker6

Links

http://wiki.netbeans.org/Docker

https://blogs.oracle.com/geertjan/entry/docker_hub_in_netbeans_ide

http://bits.netbeans.org/download/trunk/nightly/latest/

http://www.dest-unreach.org/socat/

dockerw – A simple Docker command wrapper for the rest of us

help

I am regularly working on Docker images and have to play with different settings. Thus I periodically find myself in the “build, run, clean-up, change something, re-build, run, …” rat race.

dockerw is a little tool for working with Docker images and containers. And it aims to help you (and me ;-)) to build and (locally) run Docker images while it hides all the command line pain.

Note: dockerw targets only ‘latest’ tagged images (does not impact /touch implicit tagged images)!

Usage

./dockerw [ build | run | stop | clean | status | env | help ]

Targets

Command Description
build builds the Docker image
run runs a Docker container in foreground based on the image
stop stops all running container based on the image and removes them
clean stop and then removes ALL (latest) images/artifacts<
status shows the status if the Docker image
env list current environment variables
help display help

“build”
build1[…]
build2

“run”
run

“clean”
clean

Installation

  1. Clone dockerw from GitHub.
  2. Create a dockerw directory ahead your Docker working dir and copy the dockerw.sh script to that location.
  3. Copy/create a script named “dockerw"located into the working directory of a your Docker image.

If you are using default values only: the dockerw script just calls the dockerw.sh:

#!/bin/bash
# call dockerw.sh, passing arguments and using env variables
. ../dockerw/dockerw.sh

You can overule the default environment like this:

#!/bin/bash
# env
BASE_NAME="my_container_context"
CONTAINER_NAME="my_container"
DOCKER_RUN_ARGS="-ti -p 1883:1883 -p 8883:8883"

# call dockerw.sh, passing arguments and using env variables
. ../dockerw/dockerw.sh

tree

Conventions

The CONTAINER_NAME is the parent working directory base name.
The default base name (BASE_NAME_DEFAULT) and default docker run arguments (DOCKER_RUN_ARGS_DEFAULT) can be changed in dockerw/dockerw.sh.
The image name (IMAGE_NAME) is build like this: BASE_NAME_DEFAULT/CONTAINER_NAME (e.g. jerady/ubuntu).

Environment Variables

the name of the docker image”${`BASE_NAME`}/${`CONTAINER_NAME`}”jerady/mosquitto

Name Description Default Example
BASE_NAME the base name of the Docker container jerady jerady
CONTAINER_NAME the name of the Docker container $(`basename 'pwd'`) mosquitto
IMAGE_NAME the name of the Docker image ${BASE_NAME}/${CONTAINER_NAME} jerady/mosquitto
DOCKER_RUN_ARGS the arguments to run the container -ti -ti
DOCKER_RUN the docker run command to be called by ./dockerw run docker run ${DOCKER_RUN_ARGS} --name ${CONTAINER_NAME} ${IMAGE_NAME} docker run -ti --name mosquitto jerady/mosquitto

I added two example Docker images/projects to show how the custom dockerw script can be implemented, e.g. this simple script for mosquitto:

#!/bin/bash

# env variables
DOCKER_RUN_ARGS="-ti -p 1883:1883 -p 8883:8883"

. ../dockerw/dockerw.sh

leads to these implicit values:
env

GitHub

dockerw project on GitHub

 

FontAwesomeFX 8.11 is here!

Just uploaded FontAwesomeFX 8.11 to Bintray.

Now included:
FontAweseme 4.6.1 with 23 additional icons

and a new kid on the block:

525icons

525icons Font coming with (…surprise!) 525 icons on board.
Due to naming conventions and restrictions 525icons related stuff is called “icons525” in FontAwesomeFX, e.g. de.jensd.fx.glyphs.icons525.Icons525.

FontAwesomeFX 8.11

compile ‘de.jensd:fontawesomefx-fontawesome:4.6.1-2’
compile ‘de.jensd:fontawesomefx-materialdesignfont:1.4.57-2’
compile ‘de.jensd:fontawesomefx-materialicons:2.1-2’
compile ‘de.jensd:fontawesomefx-octicons:3.3.0-2’
compile ‘de.jensd:fontawesomefx-weathericons:2.0-2’
compile ‘de.jensd:fontawesomefx-icons525:2.0-2’

They all depend on

compile ‘de.jensd:fontawesomefx-commons:8.11’

Optional

compile ‘de.jensd:fontawesomefx-controls:8.11’

Demo apps

Did you know there is a little test app included in each font artifact?

de.jensd.fx.glyphs.fontawesome.demo.FontAwesomeIconsDemoApp
de.jensd.fx.glyphs.materialdesignicons.demo.MaterialDesignIconsDemoApp
de.jensd.fx.glyphs.materialicons.demo.MaterialIconsDemoApp
de.jensd.fx.glyphs.octicons.demo.OctIconsDemoApp
de.jensd.fx.glyphs.weathericons.demo.WeatherIconsDemoApp
de.jensd.fx.glyphs.icons525.demo.Icons525DemoApp

525icons2

Here you can find the bintray package.

Sources are here at Bitbucket

Report issues here

Button of Choice: Use ToggleButtons as RadioButtons

For MQTT.fx I wanted to use ToggleButtons to e.g. choose the de
coding of a MQTT Message or the QoS Level:

decode

qos

 

I found out that in context of a ToggleGroup ToggleButtons behave different than RadioButtons in terms of selection/deselection: unlike RadioButtons ToggleButtons can still be set to unselected state.

 

A RadioButton extends ToggleButton and overrides fire() (which is invoked when a user gesture indicates that an event for this ButtonBase should occur aka “Button was clicked”):
RadioButton:

@Override public void fire() {
  // we don't toggle from selected to not selected if part of a group
  if (getToggleGroup() == null || !isSelected()) {
    super.fire();
  }
}

ToggleButton:

@Override public void fire() {
  setSelected(!isSelected());
  fireEvent(new ActionEvent());
}

In a ToogleGroup ToggleButtons should behave like RadioButtons, so IMHO this is a bug worth a pull request for ToggleButton 😉

One way to handle this is for sure to create a custom extension of ToggleButton implementing fire() in respect to the RadioButton.
But I like more to add behavior to existing controls.
This is my tweak to modify default behavior by adding filters to all ToogleButtons of a ToggleGroup consuming unwanted MouseEvents:

public class JavaFXUtil {

    private static JavaFXUtil me;

    private JavaFXUtil() {
    }

    public static JavaFXUtil get() {
        if (me == null) {
            me = new JavaFXUtil();
        }
        return me;
    }

    public EventHandler<MouseEvent> consumeMouseEventfilter = (MouseEvent mouseEvent) -> {
        if (((Toggle) mouseEvent.getSource()).isSelected()) {
            mouseEvent.consume();
        }
    };

    public void addAlwaysOneSelectedSupport(final ToggleGroup toggleGroup) {
        toggleGroup.getToggles().addListener((Change<? extends Toggle> c) -> {
            while (c.next()) {
                for (final Toggle addedToggle : c.getAddedSubList()) {
                    addConsumeMouseEventfilter(addedToggle);
                }
            }
        });
        toggleGroup.getToggles().forEach(t -> {
            addConsumeMouseEventfilter(t);
        });
    }

    private void addConsumeMouseEventfilter(Toggle toggle) {
        ((ToggleButton) toggle).addEventFilter(MouseEvent.MOUSE_PRESSED, consumeMouseEventfilter);
        ((ToggleButton) toggle).addEventFilter(MouseEvent.MOUSE_RELEASED, consumeMouseEventfilter);
        ((ToggleButton) toggle).addEventFilter(MouseEvent.MOUSE_CLICKED, consumeMouseEventfilter);
    }

}
public class ButtonDemoController {
    @FXML
    private ToggleGroup g2;

    @FXML
    private ToggleGroup g3;

    public void initialize() {
        JavaFXUtil.get().addAlwaysOneSelectedSupport(g2);
        JavaFXUtil.get().addAlwaysOneSelectedSupport(g3);
    }

}

buttonofchoice

Example code at GitHub.

FontAwesomeFX 8.10: The artefacts act

Recently I created a demo an wanted to use just one FontAwesome icon and I notices that I need to add the whole ~600KB package for that. Clearly the package size is driven by the all the contained True Type Font files:

de.jensd:fontawesomefx-fontawesomefx:8.9 571 KB

So I thought about split the full package into separated artifacts per icon font: smaller footprint and easier to update (also the package versioning reflects the icon font version)

Coming with FontAwesomeFX 8.10

de.jensd:fontawesomefx-fontawesome:4.5.0 115.7 KB
de.jensd:fontawesomefx-materialdesignfont:1.4.57 246.4 KB
de.jensd:fontawesomefx-materialicons:2.1 92.2 KB
de.jensd:fontawesomefx-octicons:3.3.0 29.9 KB
de.jensd:fontawesomefx-weathericons:2.0 2.0 KB

PLUS:

de.jensd:fontawesomefx-common:8.10 13.4 KB

and optional:

de.jensd:fontawesomefx-controls:8.10 3.4 KB

Usage

E.g. to use WeatherIcons in your app you just have to add

repositories {
 jcenter()
}

dependencies {
 compile 'de.jensd:fontawesomefx-weathericons:2.0'
}

to your build.gradle and you are done with 16KB (font-pack + common) additional footprint.

wathericonsdemo

You can run contained demo by calling: de.jensd.fx.glyphs.weathericons.demo.WeatherIconsDemoApp

Please give it a try and feed me back if it works!

Next steps are:

  • rename it from FontAwesomeFX to e.g. IconsFX (in respect to the other supportet icon fonts) and
  • focus on Java9 and JigSaw….

Here you can find the new bintray package.

Sources are here at Bitbucket

Report issues here

New release: MQTT.fx 1.1.0

It is about 4 month since the last MQTT.fx release (1.0.0 in last December) as I was quite busy as of my current project. Anyway I found some (night-) time to work on bug fixes and new features and I am happy to release now MQTT.fx 1.1.0!

You can download latest binaries/installers at mqttfx.org.

[UPDATE]
I have updated the native/bundles installers for OSX & Windows now powered by install4j_large

Please Report bugs and feature requests  via the issue tracker.

Release Notes Version 1.1.0

  • [New] MQTT.fx now has a new fancy icon: Many thanks to Gerrit Grunwald (@hansolo_)!
  • [New] All new “Subscribe” tab:
    • New rendering of subscribed topics.
    • New rendering of receivied messages.
    • Support for “autoscroll”: Always scroll down to latest recevied message and show the details.
    • Message Payload can now be shown as plain text, hex (fomatted) and Base64.
    • Payload can now be saved as raw (binary), plain text, hex (fomatted) and Base64 encoded.
    • Issue #75: Added an option to ‘mute’ topics for temporary ‘no-show’ received messages (per topic)
    • Added experimental support for dumping messages payload.
  • [New] Issue #70: Support for import/export of ConnectionProfiles
  • [New] Issue #71: Support for import/export of Clipboard Messages (publish messages)
  • [New] Issue #76: Support for import/export of Topics (respectively for publish and subscribe)
  • [New] Extended Scripting API: publish() and subscribe() now also supports “QoS” and “Retained”
  • [New] Option to clear Messages Clipboard
  • [New] Option to clear/keep Messages Buffer on unsubscribe
  • [New] Several style and rendering improvements
  • [New] Bundled with JRE 1.8.0_74
  • [Fixed] Issues with global application logging

 

MQTT.fx now has a new fancy icon

MQTTfx_icon_256

Kudos and many thanks to Gerrit Grunwald (@hansolo_) for creating and sharing!

A lot of new stuff on the “Subscribe” tab

mqttfx110_subscribe_screen

mqttfx110_subscribe_tab

  • Support for “autoscroll“:
    Always scroll down to latest recevied message and show the details at the bottom.

mqttfx110_subscribe_autoscroll

  • New rendering of subscribed topics

mqttfx110_subscribe_topics

  • Added an option to ‘mute’ topics for temporary ‘no-show’ received messages (per topic)
  • Added *** experimental *** support for dumping messages payload.
    • Message payload is written in a file per message names by recevied time.
  • All new rendering of receivied messages view

mqttfx110_subscribe_message

  • Message Payload can now be shown as plain text, hex (fomatted) and base64

mqttfx110_subscribe_saveas

  • Payload can now be saved as raw (binary), plain text, hex (fomatted) and base64 encoded
  • Support for import/export of ConnectionProfiles

mqttfx110_import_connectionprofile

  • Support for import/export of Topics (respectively for publish and subscribe) and Clipboard Messages

mqttfx110_import_topics

  • Extended Scripting API: publish() and subscribe() now also supports “QoS” and “Retained”
public void publish(String topic, String messageBody) 
public void publish(String topic, String messageBody, int qos)
public void publish(String topic, String messageBody, int qos, boolean retained)
public void subscribe(String topicFilter)
public void subscribe(String topicFilter, int qos)
public void unsubscribe(String topicFilter)
  • Option to clear Messages Clipboard

mqttfx110_publish_clearclipboard

  • Option to clear/keep Messages Buffer on unsubscribe (by now buffer is cleared on unsubscribe)
  • mqttfx110_settings_clear_bufferSeveral style and rendering improvements
  • Fixed issues with global application logging
  • Now bundled with JRE 1.8.0_74

mqttfx110_about

Ordering via SortedList (and Properties Extractor)

Quite a while ago (almost 1,5 years 😱) I wrote a post about the JavaFX way to get ListViews and TableViews instantly updated on model data change: using Properties Extractor pattern.

TableColumns have a build-in support for sorting the data per column: just double-click the column header (. But how to order ListViews or get the table content get ordered by certain predicate instantly on data changes?

To sort elements the ObervableList has a sort(Comparator<? super E> c) method to sort the list according to the order induced by the specified Comparator (each time it is called).
Note: If the specified comparator is null then all elements in this list must implement the Comparable interface and the elements’ natural ordering should be used.

I have extended the demo app in terms of sorting:
GET THE APP HERE.
GET THE CODE HERE.
extractor_demo_main

SortedList and FilteredList

SortedList and FilteredList are very interesting and useful wrapper for OberservableLists to keep the content sorted and/or filtered (will add filtering soon).

SortedList: Wraps an ObservableList and sorts it’s content. All changes in the ObservableList are propagated immediately to the SortedList.

FilteredList: Wraps an ObservableList and filters it’s content using the provided Predicate. All changes in the ObservableList are propagated immediately to the FilteredList.

You can create a SortedList by creating it “manually”:

personSortedList = new SortedList(model.getPersonFXBeans());

or let the ObservableList do it for you:

personSortedList = model.getPersonFXBeans().sorted();

“Readonly TableView” and “ListView” are sharing the same SortedList wrapper:

readOnlyListView.setItems(personSortedList);
readOnlyTableView.setItems(personSortedList);

Sorting

extractor_demo_comparators

The “Sorting” ComboBox contains the available comparators for the SortedList:

personComparators = FXCollections.observableArrayList(new FirstNameComparator(),
                new LastNameComparator(),
                new DateOfBirthComparator(),
                new AgeComparator(),
                new DaysToNextBirthdayComparator(),
                new NextBirthdayComparator()
);
personOrderByComboBox.setItems(personComparators);
@FXML
public void onSortByComparator() {
  personSortedList.setComparator(personOrderByComboBox.getSelectionModel().getSelectedItem());
}

Also there is a toggle for the sort direction:

@FXML
public void onChangeSortDirection() {
  personSortedList.setComparator(personSortedList.getComparator().reversed());
}

The “Editable TableView” is still “self-sufficient” in terms of sorting.

All three views are sharing the same data model (model.getPersonFXBeans()) and editing the content is instantly notified by them (via property extractor).

If you play with the app by changing the data: note also the sorting take effect. 

One more thing

If you bind the comparatorProperty() of SortedList to the TableView, the sorting the content is triggered by the build-in ordering options ig TableView (via column header):

personSortedList.comparatorProperty().bind(editableTableView.comparatorProperty());

Note that other ways to trigger the SortedList e.g. by setCompartor() will fail then with exception as comparatorProperty is already bound.

MQTT driven NeoPixels

Here are some clips I recorded during last weeks when playing with NeoPixels driven by MQTT messages:

Many thanks to Gerrit Grunwald for sharing his ColorSelector control I used in this demo: