Package lighthouse.protocol

Examples of lighthouse.protocol.Project


    private void updateForProject() {
        pieChart.getData().clear();
        pledgesList.getItems().clear();

        final Project p = project.get();

        projectTitle.setText(p.getTitle());
        goalAmountLabel.setText(String.format(goalAmountFormatStr, p.getGoalAmount().toPlainString()));

        description.getChildren().setAll(new Text(project.get().getMemo()));

        noPledgesLabel.visibleProperty().bind(isEmpty(pledgesList.getItems()));

        // Load and set up the cover image.
        Image img = new Image(p.getCoverImage().newInput());
        if (img.getException() != null)
            Throwables.propagate(img.getException());
        BackgroundSize cover = new BackgroundSize(BackgroundSize.AUTO, BackgroundSize.AUTO, false, false, false, true);
        BackgroundImage bimg = new BackgroundImage(img, BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT,
                BackgroundPosition.DEFAULT, cover);
        coverImage.setBackground(new Background(bimg));

        // Configure the pie chart.
        emptySlice = new PieChart.Data("", 0);

        if (bindings != null)
            bindings.unbind();
        bindings = new UIBindings();

        // This must be done after the binding because otherwise it has no node in the scene graph yet.
        emptySlice.getNode().setVisible(false);

        checkForMyPledge(p);

        editButton.setVisible(Main.wallet.isProjectMine(p));

        if (p.getPaymentURL() != null) {
            Platform.runLater(() -> {
                Main.instance.scene.getAccelerators().put(KeyCombination.keyCombination("Shortcut+R"), () -> Main.backend.refreshProjectStatusFromServer(p));
            });
        }
    }
View Full Code Here


            onBackClickedProperty.get().handle(event);
    }

    @FXML
    private void actionClicked(ActionEvent event) {
        final Project p = project.get();
        switch (mode) {
            case OPEN_FOR_PLEDGES:
                makePledge(p);
                break;
            case PLEDGED:
View Full Code Here

        // Work around ConcurrentModificationException error.
        Platform.runLater(() -> {
            final LHProtos.ProjectDetails detailsProto = model.getDetailsProto().build();
            log.info("Saving: {}", detailsProto.getExtraDetails().getTitle());
            try {
                Project project;
                if (!detailsProto.hasPaymentUrl()) {
                    // Request directory first then save, so the animations are right.
                    DirectoryChooser chooser = new DirectoryChooser();
                    chooser.setTitle("Select a directory to store the project and pledges");
                    platformFiddleChooser(chooser);
                    File dir = chooser.showDialog(Main.instance.mainStage);
                    if (dir == null)
                        return;
                    final Path dirPath = dir.toPath();
                    project = model.getProject();
                    // Make sure we don't try and run too many animations simultaneously.
                    final Project fp = project;
                    overlayUI.runAfterFade(ev -> {
                        saveAndWatchDirectory(fp, dirPath);
                    });
                    overlayUI.done();
                } else {
View Full Code Here

        log.info("REQ: {} {}", method, path);
        if (!path.startsWith(LHUtils.HTTP_PATH_PREFIX + LHUtils.HTTP_PROJECT_PATH)) {
            sendError(httpExchange, HTTP_NOT_FOUND);
            return;
        }
        Project project = backend.getProjectFromURL(httpExchange.getRequestURI());
        if (project == null) {
            log.warn("Project URL did not match any known project", httpExchange.getRequestURI());
            sendError(httpExchange, HTTP_NOT_FOUND);
            return;
        }
View Full Code Here

        writeProjectToDisk();
        assertEquals(0, projects.size());
        gate.waitAndRun();
        // Is now loaded from disk.
        assertEquals(1, projects.size());
        final Project project1 = projects.iterator().next();
        assertEquals("Foo", project1.getTitle());

        // Let's watch out for pledges from the server.
        ObservableSet<LHProtos.Pledge> pledges = backend.mirrorOpenPledges(project1, gate);

        // HTTP request was made to server to learn about existing pledges.
View Full Code Here

    }

    private static void showProject(String filename) {
        try (InputStream stream = Files.newInputStream(Paths.get(filename))) {
            LHProtos.Project proto = LHProtos.Project.parseFrom(stream);
            Project project = new Project(proto);
            System.out.println(project);
        } catch (IOException e) {
            System.err.println(format("Could not open project file %s: %s", filename, e.getMessage()));
        } catch (PaymentProtocolException e) {
            e.printStackTrace();
View Full Code Here

    }

    public ProjectModel(LHProtos.ProjectDetails.Builder liveProto) {
        this.proto = liveProto;
        final LHProtos.Project.Builder wrapper = LHProtos.Project.newBuilder().setSerializedPaymentDetails(liveProto.build().toByteString());
        Project project = unchecked(() -> new Project(wrapper.build()));
        title.set(project.getTitle());
        memo.set(project.getMemo());
        goalAmount.set(project.getGoalAmount().value);
        minPledgeAmount.set(recalculateMinPledgeAmount(goalAmount.longValue()));

        if (liveProto.hasPaymentUrl()) {
            String host = LHUtils.validateServerPath(liveProto.getPaymentUrl(), project.getID());
            if (host == null)
                throw new IllegalArgumentException("Server path not valid for Lighthouse protocol: " + liveProto.getPaymentUrl());
            serverName.set(host);
        }

        // Connect the properties.
        title.addListener(o -> proto.getExtraDetailsBuilder().setTitle(title.get()));
        memo.addListener(o -> proto.setMemo(memo.get()));
        // Just adjust the first output. GUI doesn't handle multioutput contracts right now (they're useless anyway).
        goalAmount.addListener(o -> {
            long value = goalAmount.longValue();
            minPledgeAmount.set(recalculateMinPledgeAmount(value));
            proto.getOutputsBuilder(0).setAmount(value);
        });

        minPledgeAmount.addListener(o -> proto.getExtraDetailsBuilder().setMinPledgeSize(minPledgeAmountProperty().get()));

        serverName.addListener(o -> {
            final String name = serverName.get();
            if (name.isEmpty())
                proto.clearPaymentUrl();
            else
                proto.setPaymentUrl(LHUtils.makeServerPath(name, LHUtils.titleToUrlString(title.get())));
        });

        Address addr = project.getOutputs().get(0).getAddressFromP2PKHScript(project.getParams());
        if (addr == null)
            throw new IllegalArgumentException("Output type is not a pay to address: " + project.getOutputs().get(0));
        address.set(addr.toString());
        address.addListener(o -> {
            try {
                Address addr2 = new Address(project.getParams(), address.get());
                proto.getOutputsBuilder(0).setScript(ByteString.copyFrom(ScriptBuilder.createOutputScript(addr2).getProgram()));
            } catch (AddressFormatException e) {
                // Ignored: wait for the user to make it valid.
            }
        });
View Full Code Here

        proto.setSerializedPaymentDetails(getDetailsProto().build().toByteString());
        return proto;
    }

    public Project getProject() {
        return unchecked(() -> new Project(getProto().build()));
    }
View Full Code Here

                TransactionInput spentBy = entry.getKey().getSpentBy();
                if (spentBy != null && tx.equals(spentBy.getParentTransaction())) {
                    if (!revokeInProgress.contains(tx)) {
                        log.info("Saw spend of our pledge that we didn't revoke ... ");
                        LHProtos.Pledge pledge = entry.getValue();
                        Project project = projects.inverse().get(pledge);
                        checkNotNull(project);
                        if (compareOutputsStructurally(tx, project)) {
                            log.info("... by a tx matching the project's outputs: claimed!");
                            for (ListenerRegistration<OnClaimHandler> handler : onClaimedHandlers) {
                                handler.executor.execute(() -> handler.listener.onClaim(pledge, tx));
View Full Code Here

        // Project files are only auto loaded from the app directory. If the user downloads a serverless project to their
        // Downloads folder, imports it, then downloads a second project, we don't want it to automatically appear.
        if (isProject && path.getParent().equals(AppDirectory.dir())) {
            if (isDelete) {
                log.info("Project file deleted/modified: {}", path);
                Project project = projectsByPath.get(path);
                if (project != null) {
                    if (kind == StandardWatchEventKinds.ENTRY_MODIFY) {
                        log.info("Project file modified, reloading ...");
                        this.tryLoadProject(path, projects.indexOf(project));
                    } else {
                        projects.remove(project);
                        projectsByPath.remove(path);
                        synchronized (this) {
                            projectsById.remove(project.getID());
                        }
                    }
                }
            } else if (isCreate) {
                log.info("New project found: {}", path);
                this.tryLoadProject(path);
            }
        } else if (isPledge) {
            if (isDelete) {
                LHProtos.Pledge pledge = pledgesByPath.get(path);
                if (pledge != null) {
                    log.info("Pledge file deleted/modified: {}", path);
                    synchronized (this) {
                        Project project = projectsById.get(pledge.getProjectId());
                        ObservableSet<LHProtos.Pledge> projectPledges = this.getPledgesFor(project);
                        checkNotNull(projectPledges)// Project should be in both sets or neither.
                        projectPledges.remove(pledge);
                    }
                    pledgesByPath.remove(path);
View Full Code Here

TOP

Related Classes of lighthouse.protocol.Project

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.