Example usage for javafx.application Platform runLater

List of usage examples for javafx.application Platform runLater

Introduction

In this page you can find the example usage for javafx.application Platform runLater.

Prototype

public static void runLater(Runnable runnable) 

Source Link

Document

Run the specified Runnable on the JavaFX Application Thread at some unspecified time in the future.

Usage

From source file:gov.va.isaac.sync.view.SyncView.java

private void sync() {
    cancelRequested_ = false;//from   w w w  .  j a v  a2 s. c om
    try {
        UserProfile up = ExtendedAppContext.getCurrentlyLoggedInUserProfile();
        if (syncService_.isRootLocationConfiguredForSCM()) {
            addLine("Setting Remote Address");

            boolean successful = false;
            while (!successful) {
                try {
                    syncService_.relinkRemote(url_, up.getSyncUsername(), up.getSyncPassword());
                    successful = true;
                } catch (AuthenticationException ae) {
                    try {
                        promptUserForCreds(up);
                    } catch (InterruptedException e) {
                        //noop
                    }

                    if (cancelRequested_) {
                        return;
                    }
                } catch (Exception e) {
                    log.error("Sync failure", e);
                    AppContext.getCommonDialogs().showErrorDialog("Sync Error",
                            "Sync error setting up remote address", e.getMessage());
                    return;
                }
            }
        } else {
            //Note, this operation is not expected to be run by real end users - hence, no attempt to gather a new password if necessary.
            //this is mostly for test purposes.  This is typically done during bundle build.
            addLine("Initial Sync Beginning");
            try {
                syncService_.linkAndFetchFromRemote(url_, up.getSyncUsername(), up.getSyncPassword());
                addLine("*****************");
                addLine("INITIAL SYNC PERFORMED - PLEASE RESTART ISAAC AFTER THIS OPERATION COMPLETES!");
            } catch (Exception e) {
                log.error("Sync failure", e);
                AppContext.getCommonDialogs().showErrorDialog("Sync Error",
                        "Sync error performing initial sync", e.getMessage());
                return;
            }
        }

        if (cancelRequested_) {
            addLine("Cancelled");
            return;
        }

        Set<String> changedFiles = new HashSet<>();

        //recover from a previous merge fail state that didn't get resolved for whatever reason
        try {
            Set<String> conflictFiles = syncService_.getFilesInMergeConflict();
            if (conflictFiles.size() > 0) {
                MergeFailure mf = new MergeFailure(conflictFiles, new HashSet<String>());
                changedFiles.addAll(resolveMergeFailure(mf));
            }
        } catch (Exception e) {
            log.error("Sync failure", e);
            AppContext.getCommonDialogs().showErrorDialog("Sync Error",
                    "Error checking for aborted merge conflicts", e.getMessage());
            return;
        }

        if (cancelRequested_) {
            addLine("Cancelled");
            return;
        }
        addLine("Adding new local files");

        try {
            syncService_.addUntrackedFiles();
        } catch (Exception e) {
            log.error("Sync failure", e);
            AppContext.getCommonDialogs().showErrorDialog("Sync Error", "Error adding new files",
                    e.getMessage());
            return;
        }

        if (cancelRequested_) {
            addLine("Cancelled");
            return;
        }
        addLine("Performing remote sync");
        try {
            int modifiedFileCount = syncService_.getLocallyModifiedFileCount();
            addLine(modifiedFileCount + " local modifications to be sent");

            commitMessage_ = null;

            if (modifiedFileCount > 0) {
                CountDownLatch await = new CountDownLatch(1);

                Platform.runLater(() -> {
                    new CommitMessage(root_.getScene().getWindow()).getMessage(result -> {
                        commitMessage_ = result;
                        await.countDown();
                    });
                });

                await.await();

                if (StringUtils.isBlank(commitMessage_)) {
                    addLine("Commit message is required.  Cancelling.");
                    return;
                }
            }

            boolean successful = false;
            while (!successful) {
                try {
                    //If we didn't collect a commit message above, we had no outgoing changes - just sync down
                    if (commitMessage_ == null) {
                        //in theory, it should be impossible to get a merge failure here - but if we do - just run them through the normal 
                        //resolution process.
                        addLine("No local changes - checking for changes on server");
                        changedFiles.addAll(syncService_.updateFromRemote(up.getSyncUsername(),
                                up.getSyncPassword(), MergeFailOption.FAIL));
                        successful = true;
                    } else {
                        //sync down and push back
                        addLine("Sending changes and checking for changes on server");
                        changedFiles
                                .addAll(syncService_.updateCommitAndPush(commitMessage_, up.getSyncUsername(),
                                        up.getSyncPassword(), MergeFailOption.FAIL, (String[]) null));
                        successful = true;
                    }
                } catch (MergeFailure mf) {
                    if (commitMessage_ == null) {
                        //We (somehow) got a merge failure when only doing an update, even though we had no changes to push.
                        //put in a commit message, so on the next loop of the code, we do a push as well, to push the resolution.
                        commitMessage_ = "Merge Failure Resolution";
                    }
                    changedFiles.addAll(resolveMergeFailure(mf));
                } catch (AuthenticationException ae) {
                    promptUserForCreds(up);

                    if (cancelRequested_) {
                        return;
                    }
                }
            }
        } catch (Exception e) {
            log.error("Sync failure", e);
            AppContext.getCommonDialogs().showErrorDialog("Sync Error", "Error adding new files",
                    e.getMessage());
            return;
        }

        //Process the changed files list
        addLine("Processing the changed files (" + changedFiles.size() + ")");
        StringBuilder errorsDuringProcess = new StringBuilder();
        try {
            //TODO OCHRE this doesn't exist yet.
            //AppContext.getService(TerminologyStoreDI.class).suspendChangeNotifications();
            for (String s : changedFiles) {
                log.debug("Post processing {} after change during sync", s);
                File f = new File(syncService_.getRootLocation(), s);
                if (f.getName().equals(UserProfileManager.PREFS_FILE_NAME)
                        && f.getParentFile().getName().equals(ExtendedAppContext.getCurrentlyLoggedInUser())) {
                    addLine("Rereading current user profile");
                    try {
                        AppContext.getService(UserProfileManager.class).rereadProfile();
                    } catch (IOException e) {
                        log.error("Error rereading changed user profile!", e);
                        AppContext.getCommonDialogs()
                                .showErrorDialog("Unexpected error reading updated user profile", e);
                    }
                } else if (f.getName().toLowerCase().endsWith(".eccs")) {
                    try {
                        addLine("Processing changeset " + f.getName());
                        ChangeSetReader csr = new ChangeSetReader();
                        csr.setChangeSetFile(f);
                        Set<ConceptChronicleBI> indexedAnnotationConcepts = new HashSet<>();
                        csr.read(indexedAnnotationConcepts);
                        if (indexedAnnotationConcepts.size() > 0) {
                            log.info("Dan doesn't know what to do with this after change set processing: {}",
                                    indexedAnnotationConcepts);
                        }
                    }

                    catch (Exception e) {
                        log.error("Error processing change set file " + f.getAbsolutePath(), e);
                        errorsDuringProcess.append("Error processing change set file " + f.getName() + "/r");
                    }
                } else {
                    log.info("No processing done for changed file {}", f.getAbsolutePath());
                }
            }
        } finally {
            //TODO OCHRE this doesn't exist yet.
            //            AppContext.getService(TerminologyStoreDI.class).resumeChangeNotifications();
        }
        if (errorsDuringProcess.length() > 0) {
            AppContext.getCommonDialogs().showErrorDialog("Errors processing changesets",
                    "Errors processing changesets:", errorsDuringProcess.toString());
        }
        addLine("Syncronization complete!");
    } finally {
        Platform.runLater(() -> {
            pb_.setProgress(0.0);
            running_.set(false);
        });
    }
}

From source file:org.sleuthkit.autopsy.timeline.ui.AbstractTimelineChart.java

/**
 * Iterate through the list of tick-marks building a two level structure of
 * replacement tick mark labels. (Visually) upper level has most
 * detailed/highest frequency part of date/time (specific label). Second
 * level has rest of date/time grouped by unchanging part (contextual
 * label).//from   w ww .j a  v  a2  s. c  o  m
 *
 * eg:
 *
 * October-October-31_September-01_September-02_September-03
 *
 * becomes:
 *
 * _________30_________31___________01___________02___________03
 *
 * _________October___________|_____________September___________
 *
 */
@ThreadConfined(type = ThreadConfined.ThreadType.JFX)
protected synchronized void layoutDateLabels() {
    //clear old labels
    contextLabelPane.getChildren().clear();
    specificLabelPane.getChildren().clear();
    //since the tickmarks aren't necessarily in value/position order,
    //make a copy of the list sorted by position along axis
    SortedList<Axis.TickMark<X>> tickMarks = getXAxis().getTickMarks()
            .sorted(Comparator.comparing(Axis.TickMark::getPosition));

    if (tickMarks.isEmpty()) {
        /*
         * Since StackedBarChart does some funky animation/background thread
         * stuff, sometimes there are no tick marks even though there is
         * data. Dispatching another call to layoutDateLables() allows that
         * stuff time to run before we check a gain.
         */
        Platform.runLater(this::layoutDateLabels);
    } else {
        //get the spacing between ticks in the underlying axis
        double spacing = getTickSpacing();

        //initialize values from first tick
        TwoPartDateTime dateTime = new TwoPartDateTime(getTickMarkLabel(tickMarks.get(0).getValue()));
        String lastSeenContextLabel = dateTime.context;

        //x-positions (pixels) of the current branch and leaf labels
        double specificLabelX = 0;

        if (dateTime.context.isEmpty()) {
            //if there is only one part to the date (ie only year), just add a label for each tick
            for (Axis.TickMark<X> t : tickMarks) {
                addSpecificLabel(new TwoPartDateTime(getTickMarkLabel(t.getValue())).specifics, spacing,
                        specificLabelX, isTickBold(t.getValue()));
                specificLabelX += spacing; //increment x
            }
        } else {
            //there are two parts so ...
            //initialize additional state
            double contextLabelX = 0;
            double contextLabelWidth = 0;

            for (Axis.TickMark<X> t : tickMarks) {
                //split the label into a TwoPartDateTime
                dateTime = new TwoPartDateTime(getTickMarkLabel(t.getValue()));

                //if we are still in the same context
                if (lastSeenContextLabel.equals(dateTime.context)) {
                    //increment context width
                    contextLabelWidth += spacing;
                } else {// we are on to a new context, so ...
                    addContextLabel(lastSeenContextLabel, contextLabelWidth, contextLabelX);
                    //and then update label, x-pos, and width
                    lastSeenContextLabel = dateTime.context;
                    contextLabelX += contextLabelWidth;
                    contextLabelWidth = spacing;
                }
                //add the specific label (highest frequency part)
                addSpecificLabel(dateTime.specifics, spacing, specificLabelX, isTickBold(t.getValue()));

                //increment specific position
                specificLabelX += spacing;
            }
            //we have reached end so add label for current context
            addContextLabel(lastSeenContextLabel, contextLabelWidth, contextLabelX);
        }
    }
    //request layout since we have modified scene graph structure
    requestParentLayout();
}

From source file:org.sleuthkit.autopsy.imageanalyzer.grouping.GroupManager.java

/**
 * create a group with the given GroupKey and file ids and add it to the
 * analyzed group list./*  w  w w. j  av  a2s .com*/
 *
 * @param groupKey
 * @param filesInGroup
 */
private synchronized <A extends Comparable<A>> void populateAnalyzedGroup(final GroupKey<A> groupKey,
        List<Long> filesInGroup, ReGroupTask<A> task) {

    /* if this is not part of a regroup task or it is but the task is not
     * cancelled...
     *
     * this allows us to stop if a regroup task has been cancelled (e.g. the
     * user picked a different group by attribute, while the current task
     * was still running) */
    if (task == null || (task.isCancelled() == false)) {
        DrawableGroup g = makeGroup(groupKey, filesInGroup);

        final boolean groupSeen = db.isGroupSeen(groupKey);
        Platform.runLater(() -> {
            if (analyzedGroups.contains(g) == false) {
                analyzedGroups.add(g);
            }
            synchronized (unSeenGroups) {
                if (groupSeen == false && unSeenGroups.contains(g) == false) {
                    unSeenGroups.add(g);
                    FXCollections.sort(unSeenGroups, sortBy.getGrpComparator(sortOrder));
                }
            }
        });
    }
}

From source file:org.sleuthkit.autopsy.timeline.ui.detailview.AggregateEventNode.java

/** apply the 'effect' to visually indicate selection
 *
 * @param applied true to apply the selection 'effect', false to remove it
 *//*  w w w .  j a  v a2 s.  c  om*/
void applySelectionEffect(final boolean applied) {
    Platform.runLater(() -> {
        if (applied) {
            setBorder(selectionBorder);
        } else {
            setBorder(null);
        }
    });
}

From source file:pts4.googlemaps.Gmaps.java

public void createStage() {

    GeoPosition Utrecht = new GeoPosition(52.0907370, 5.1214200);
    /*// Create a waypoint painter that takes all the waypoints
     WaypointPainter<Waypoint> waypointPainter = new WaypointPainter<Waypoint>();
     waypointPainter.setWaypoints(waypoints);*/
    // Set the focus
    mapViewer.setZoom(10);//from w w  w  .  j a  va  2 s. co m
    mapViewer.setAddressLocation(Utrecht);

    // Add interactions
    MouseInputListener mia = new PanMouseInputListener(mapViewer);

    mapViewer.addMouseListener(sa);
    mapViewer.addMouseMotionListener(sa);
    mapViewer.setOverlayPainter(sp);
    mapViewer.addMouseListener(mia);
    mapViewer.addMouseMotionListener(mia);
    //mapViewer.addMouseListener(new CenterMapListener(mapViewer));
    mapViewer.addMouseWheelListener(new ZoomMouseWheelListenerCenter(mapViewer));
    mapViewer.addKeyListener(new PanKeyListener(mapViewer));

    mapViewer.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseClicked(MouseEvent me) {

            //Rechter muisknop klik
            if (me.getButton() == MouseEvent.BUTTON3) {
                GeoPosition mousepoint = mapViewer.convertPointToGeoPosition(me.getPoint());
                Double lat1 = mousepoint.getLatitude();
                Double lng1 = mousepoint.getLongitude();
                Double lat2;
                Double lng2;

                for (MyWaypoint u : units) {
                    lat2 = u.getPosition().getLatitude();
                    lng2 = u.getPosition().getLongitude();

                    if (UnitControl.distFrom(lat1.floatValue(), lng1.floatValue(), lat2.floatValue(),
                            lng2.floatValue()) < (mapViewer.getZoom() * mapViewer.getZoom()
                                    * mapViewer.getZoom() * 2)) {
                        Platform.runLater(new Runnable() {

                            @Override
                            public void run() {

                                MessageBox msg = new MessageBox("Send message to unit " + u.getLabel() + "?",
                                        MessageBoxType.YES_NO);
                                msg.showAndWait();

                                if (msg.getMessageBoxResult() == MessageBoxResult.YES) {

                                    try {
                                        if (gui.messageToUnit(u.getLabel()) == false) {
                                            MessageBox msg2 = new MessageBox("Error connecting to unit",
                                                    MessageBoxType.OK_ONLY);
                                            msg2.show();

                                        }
                                    } catch (IOException ex) {
                                        Logger.getLogger(Gmaps.class.getName()).log(Level.SEVERE, null, ex);
                                    }

                                } else {
                                    //msg.close();
                                }
                            }

                        });
                    }
                }

            } else {
                if (createUnit == true) {
                    Color kleur = null;
                    if (type == 1) {
                        kleur = Color.cyan;
                    }
                    if (type == 2) {
                        kleur = Color.YELLOW;
                    }
                    if (type == 3) {
                        kleur = Color.RED;
                    }
                    GeoPosition plek = mapViewer.convertPointToGeoPosition(me.getPoint());
                    Platform.runLater(new Runnable() {
                        @Override
                        public void run() {
                            gui.setUnit(plek.getLongitude(), plek.getLatitude());
                        }
                    });

                    for (MyWaypoint p : orders) {
                        if (p.getLabel().equals(id)) {
                            orders.remove(p);
                        }
                    }
                    orders.add(new MyWaypoint(id, kleur, plek));
                    for (Unit a : EmergencyUnits) {
                        if (a.getName().equals(id)) {
                            GeoPosition plek2 = new GeoPosition(a.getLatidude(), a.getLongitude());
                            ChatMessage chat = new ChatMessage(
                                    gui.getIncidentorder() + "\n" + gui.getUnitDescription(), "Meldkamer", id);
                            server.sendMessage(chat);
                            a.setIncident(incidentstring);
                            new Animation(plek, plek2, id, orders, units, Gmaps.this, waypointPainter3);
                        }
                    }
                    createUnit = false;
                    // Create a waypoint painter that takes all the waypoints
                    waypointPainter3.setWaypoints(orders);
                    waypointPainter3.setRenderer(new FancyWaypointRenderer());
                    draw();
                }

                if (simulation == true) {
                    Color kleur = null;
                    if (type == 1) {
                        kleur = Color.cyan;
                    }
                    if (type == 2) {
                        kleur = Color.YELLOW;
                    }
                    if (type == 3) {
                        kleur = Color.RED;
                    }
                    GeoPosition plek = mapViewer.convertPointToGeoPosition(me.getPoint());
                    Platform.runLater(new Runnable() {
                        @Override
                        public void run() {
                            gui.setUnit(plek.getLongitude(), plek.getLatitude());
                        }
                    });

                    for (MyWaypoint p : orders) {
                        if (p.getLabel().equals(id)) {
                            orders.remove(p);
                        }
                    }
                    orders.add(new MyWaypoint(id, kleur, plek));
                    for (Unit a : EmergencyUnits) {
                        if (a.getName().equals(id)) {
                            GeoPosition plek2 = new GeoPosition(a.getLatidude(), a.getLongitude());
                            ChatMessage chat = new ChatMessage(
                                    gui.getIncidentorder() + "\n" + gui.getUnitDescription(), "Meldkamer", id);
                            server.sendMessage(chat);
                            a.setIncident(incidentstring);
                            Point2D fire = mapViewer.getTileFactory().geoToPixel(plek, mapViewer.getZoom());
                            simulations = new Simulation(plek, plek2, id, orders, units, Gmaps.this,
                                    waypointPainter3);
                            new SimulationAnimation(simulations, plek, plek2, id, orders, units, Gmaps.this,
                                    waypointPainter3);

                        }
                    }
                    createUnit = false;
                    // Create a waypoint painter that takes all the waypoints
                    waypointPainter3.setWaypoints(orders);
                    waypointPainter3.setRenderer(new FancyWaypointRenderer());
                    /*
                     List<Painter<JXMapViewer>> painters = new ArrayList<Painter<JXMapViewer>>();
                     painters.add(simulations);
                     CompoundPainter<JXMapViewer> painter = new CompoundPainter<JXMapViewer>(painters);
                                
                     mapViewer.setOverlayPainter(painter);*/
                    draw();
                    simulation = false;
                }

                if (weather == true) {
                    GeoPosition mousepoint = mapViewer.convertPointToGeoPosition(me.getPoint());
                    Double lat1 = mousepoint.getLatitude();
                    Double lng1 = mousepoint.getLongitude();
                    try {
                        new Weather(lng1, lat1);
                    } catch (IOException ex) {
                        Logger.getLogger(Gmaps.class.getName()).log(Level.SEVERE, null, ex);
                    } catch (JSONException ex) {
                        Logger.getLogger(Gmaps.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            }
        }
    }); // end MouseAdapter

}

From source file:tw.edu.sju.ee.eea.module.iepe.project.window.IepeRealtimeSpectrumElement.java

private void initfx() {
    createChart();//from   w  w  w. j av  a2 s .  co  m
    Platform.runLater(new Runnable() {
        @Override
        public void run() {
            initFX(jFXPanel1);

        }
    });
}

From source file:org.sleuthkit.autopsy.imageanalyzer.gui.GroupPane.java

/**
 * reset the text and icons to represent the currently filtered files
 *///w ww.ja v  a  2 s .  c o m
protected void resetHeaderString() {
    if (grouping.get() == null) {
        Platform.runLater(() -> {
            groupLabel.setText("");
        });
    } else {
        int size = grouping.get().getSize();
        int hashHitCount = grouping.get().getFilesWithHashSetHitsCount();
        String groupName;
        if (grouping.get().groupKey.getAttribute() == DrawableAttribute.TAGS) {
            groupName = ((TagName) grouping.get().groupKey.getValue()).getDisplayName();
        } else {
            groupName = grouping.get().groupKey.getValue().toString();
        }
        final String headerString = StringUtils.defaultIfBlank(groupName, DrawableGroup.UNKNOWN) + " -- "
                + hashHitCount + " hash set hits / " + size + " files";
        Platform.runLater(() -> {
            groupLabel.setText(headerString);
        });
    }
}

From source file:org.sleuthkit.autopsy.imageanalyzer.ImageAnalyzerController.java

private void restartWorker() {
    if (dbWorkerThread != null) {
        dbWorkerThread.cancelAllTasks();
    }//from  ww  w .  j ava  2 s. c  o  m
    dbWorkerThread = new DBWorkerThread();

    getFileUpdateQueueSizeProperty().addListener((Observable o) -> {
        Platform.runLater(this::updateRegroupDisabled);
    });

    Thread th = new Thread(dbWorkerThread);
    th.setDaemon(false); // we want it to go away when it is done
    th.start();
}

From source file:poe.trade.assist.Main.java

private void setupResultPaneBinding(SearchPane searchPane, ResultPane resultPane,
        AutoSearchService autoSearchService) {
    searchPane.searchTable.getSelectionModel().selectedItemProperty().addListener((ob, o, n) -> {
        if (n != null) {
            List<SearchResultItem> list = n.getResultList();
            if (n.getAutoSearch() && list != null) {
                resultPane.setSearch(n);
            } else if (!n.getAutoSearch()) {
                manualTaskRun(n);//from   www .j a v a2s . c o  m
            }
        }
    });
    autoSearchService.setCallback(noOfItemsFound -> {
        //         refreshResultColumn();
        Search search = searchPane.searchTable.getSelectionModel().getSelectedItem();
        if (search != null && search.getResultList() != null && search.getAutoSearch()) {
            Platform.runLater(() -> resultPane.setSearch(search));
        }
        if (noOfItemsFound > 0) {
            String soundPath = resultPane.soundButton.getUserData().toString();
            File file = new File(soundPath);
            if (file.exists()) {
                String url;
                try {
                    url = file.toURI().toURL().toExternalForm();
                    AudioClip sound = new AudioClip(url);
                    sound.play();
                } catch (Exception e) {
                    e.printStackTrace();
                    Dialogs.showError(e);
                }
            }
        }
    });
}

From source file:com.neuronrobotics.bowlerstudio.MainController.java

private void setToLoggedIn(final String name) {
    // new Exception().printStackTrace();
    FxTimer.runLater(Duration.ofMillis(100), () -> {
        logoutGithub.disableProperty().set(false);
        logoutGithub.setText("Log out " + name);
        new Thread() {
            public void run() {

                GitHub github = ScriptingEngine.getGithub();
                while (github == null) {
                    github = ScriptingEngine.getGithub();
                    ThreadUtil.wait(20);
                }// w  ww .  j  a  v  a  2 s.  c om
                try {
                    GHMyself myself = github.getMyself();
                    PagedIterable<GHGist> gists = myself.listGists();
                    Platform.runLater(() -> {
                        myGists.getItems().clear();
                    });
                    ThreadUtil.wait(20);
                    for (GHGist gist : gists) {
                        String desc = gist.getDescription();
                        if (desc == null || desc.length() == 0) {
                            desc = gist.getFiles().keySet().toArray()[0].toString();
                        }
                        Menu tmpGist = new Menu(desc);

                        MenuItem loadWebGist = new MenuItem("Show Web Gist...");
                        loadWebGist.setOnAction(event -> {
                            String webURL = gist.getHtmlUrl();
                            try {
                                BowlerStudio.openUrlInNewTab(new URL(webURL));
                            } catch (MalformedURLException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            }
                        });
                        MenuItem addFile = new MenuItem("Add file to Gist...");
                        addFile.setOnAction(event -> {
                            new Thread() {
                                public void run() {

                                }
                            }.start();
                        });
                        Platform.runLater(() -> {
                            tmpGist.getItems().addAll(addFile, loadWebGist);
                        });
                        EventHandler<Event> loadFiles = new EventHandler<Event>() {
                            @Override
                            public void handle(Event ev) {

                                // for(ScriptingEngine.)
                                new Thread() {
                                    public void run() {
                                        System.out.println("Loading files");
                                        ArrayList<String> listofFiles = ScriptingEngine
                                                .filesInGit(gist.getGitPushUrl(), "master", null);
                                        for (String s : listofFiles) {
                                            MenuItem tmp = new MenuItem(s);
                                            tmp.setOnAction(event -> {
                                                new Thread() {
                                                    public void run() {
                                                        try {
                                                            File fileSelected = ScriptingEngine
                                                                    .fileFromGit(gist.getGitPushUrl(), s);
                                                            BowlerStudio.createFileTab(fileSelected);
                                                        } catch (Exception e) {
                                                            // TODO
                                                            // Auto-generated
                                                            // catch block
                                                            e.printStackTrace();
                                                        }
                                                    }
                                                }.start();

                                            });
                                            Platform.runLater(() -> {
                                                tmpGist.getItems().add(tmp);
                                                tmpGist.setOnShowing(null);

                                            });
                                        }
                                        Platform.runLater(() -> {
                                            tmpGist.hide();
                                            Platform.runLater(() -> {
                                                tmpGist.show();
                                            });
                                        });
                                    }
                                }.start();
                            }
                        };

                        tmpGist.setOnShowing(loadFiles);
                        Platform.runLater(() -> {
                            myGists.getItems().add(tmpGist);
                        });

                    }
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
        }.start();

    });
}