當前位置: 首頁>>代碼示例>>Java>>正文


Java Worker.State方法代碼示例

本文整理匯總了Java中javafx.concurrent.Worker.State方法的典型用法代碼示例。如果您正苦於以下問題:Java Worker.State方法的具體用法?Java Worker.State怎麽用?Java Worker.State使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javafx.concurrent.Worker的用法示例。


在下文中一共展示了Worker.State方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getListener

import javafx.concurrent.Worker; //導入方法依賴的package包/類
private ChangeListener<Worker.State> getListener(final DropboxManager.DropboxAccountLinkListener dropboxAccountLinkListener,
                                                 final DbxWebAuthNoRedirect webAuth, final WebEngine engine, final Stage stage) {
    return (observable, oldValue, newState) -> {
        if (newState == Worker.State.SUCCEEDED) {
            try {
                final String authCode = (String) engine.executeScript("document.getElementById('auth-code').textContent");
                LOGGER.debug("Authorization Code [{}]", authCode);
                DbxAuthFinish authFinish = webAuth.finish(authCode);

                String accessToken = authFinish.accessToken;
                final DbxAuthInfo dbxAuthInfo = new DbxAuthInfo(accessToken, DbxHost.Default);
                DbxAuthInfo.Writer.writeToFile(dbxAuthInfo, accessTokenFile);

                DbxClient client = new DbxClient(dropboxConfig, dbxAuthInfo.accessToken, dbxAuthInfo.host);

                final String displayName = client.getAccountInfo().displayName;
                LOGGER.info("Linked account [{}]", displayName);
                stage.close();
                dropboxAccountLinkListener.accountLinked(AccountInfoFactory.getAccountInfo(client.getAccountInfo()));
            } catch (Exception e) {
                // ignore
            }
        }
    };
}
 
開發者ID:adelolmo,項目名稱:biblio,代碼行數:26,代碼來源:DropboxLinkDialog.java

示例2: doAction

import javafx.concurrent.Worker; //導入方法依賴的package包/類
@Override
public void doAction(ObservableValue<? extends Worker.State> observable, Worker.State oldValue, Worker.State newValue) {
    if (newValue == Worker.State.SUCCEEDED) {
        NodeList nodeList = webEngine.getDocument().getElementsByTagName("code");

        if (nodeList != null) {
            HTMLElementImpl htmlNode = (HTMLElementImpl) nodeList.item(0);

            if (htmlNode != null) {
                String authorizationCode = htmlNode.getInnerText();

                save(new AuthorizationData(authorizationCode));
            }
        }
    }
}
 
開發者ID:yfiton,項目名稱:yfiton,代碼行數:17,代碼來源:TwitterWebEngineListener.java

示例3: changed

import javafx.concurrent.Worker; //導入方法依賴的package包/類
@Override
public void changed(ObservableValue<? extends Worker.State> observable, Worker.State oldValue, Worker.State newValue) {
    if (newValue.equals(Worker.State.SUCCEEDED)) {
        if(webEngine.getDocument().getBaseURI().equals("about:blank")) return;
        //If the page loads, let's take a snapshot of it.
        WritableImage snapshot = new WritableImage((int) screenSize.getWidth(), (int) screenSize.getHeight());
        browser.snapshot(null, snapshot);
        BufferedImage renderedImage = SwingFXUtils.fromFXImage(snapshot, null);
        //Some math to get a little better thumbnail. Starting x is at 1/4 of the totale page. Goes for a width of half of the screen size to attempt and get the 'core' of the content.
        renderedImage = renderedImage.getSubimage((int)(screenSize.getWidth() /4),0,(int)( screenSize.getWidth()  / 2 ),(int) screenSize.getHeight() / 2);
        saveImage(padPath, fileName, renderedImage);
        controller.refreshListView();
        urlStage.close();
        webEngine.load(null);
    }
    else if(newValue.equals(Worker.State.FAILED)){
        //TODO: Send an error message somehow.
        urlStage.close();
    }
}
 
開發者ID:arocketman,項目名稱:URL-pad,代碼行數:21,代碼來源:Snapshotter.java

示例4: changed

import javafx.concurrent.Worker; //導入方法依賴的package包/類
@Override
public void changed(ObservableValue<? extends Worker.State> ov, Worker.State oldState, Worker.State newState) {
    if (newState == Worker.State.SUCCEEDED) {
        Document document = configuration.createDocument(engine);
        configuration.onLoad(document);
        Window window = configuration.createWindow(document);
        DocumentLoadEvent event = new DocumentLoadEvent(window);
        documentListener.onLoad(event);

        if (configuration.getConfiguration().getInterceptor() != null && handler != null) {
            URLConnection connection = handler.getConnection();
            if (handler.getConnection() != null) {
                Map<String, List<String>> headers = connection.getHeaderFields();
                Response response = new Response(window.getLocation(), Collections.unmodifiableMap(new HashMap<>(headers)));
                configuration.getConfiguration().getInterceptor().afterLoad(response);
            }
        }
    }
}
 
開發者ID:webfolderio,項目名稱:ui4j,代碼行數:20,代碼來源:WebKitBrowser.java

示例5: loadSections

import javafx.concurrent.Worker; //導入方法依賴的package包/類
private void loadSections(Runnable nextCall) {
	logger.info("Loading " + bounds.toString());
	boolean includeTitle = (bounds.lowerSection == 0 && bounds.lowerOption == 0);
	String source = project.getTemplate().render(project, includeTitle, bounds, ImageType.REFERENCE);

	WebEngine engine = browser.getEngine();
	engine.loadContent(source);

	if (listener != null) {
		engine.getLoadWorker().stateProperty().removeListener(listener);
	}
	listener = new ChangeListener<Worker.State>() {

		@Override
		public void changed(ObservableValue<? extends Worker.State> observable, Worker.State oldValue,
				Worker.State newValue) {
			if (newValue != Worker.State.SUCCEEDED)
				return;

			try {
				engine.executeScript("document.body.style.overflow = 'hidden'");

				String heightText = engine
						.executeScript("window.getComputedStyle(document.body).getPropertyValue('height')")
						.toString();
				height = Double.valueOf(heightText.replace("px", ""));
				browser.setMinWidth(1280);
				browser.setMaxWidth(browser.getMinWidth());

				nextCall.run();
			} catch (Exception e) {
				logger.error("Error while setting up screenshot browser", e);
				stage.close();
				callback.accept("Error while taking screenshot");
			}
		}
	};
	engine.getLoadWorker().stateProperty().addListener(listener);
}
 
開發者ID:Quantencomputer,項目名稱:cyoastudio,代碼行數:40,代碼來源:HtmlImageExporter.java

示例6: changed

import javafx.concurrent.Worker; //導入方法依賴的package包/類
@Override
public void changed(ObservableValue<? extends Worker.State> ov, Worker.State oldState, Worker.State newState) {
    switch (newState) {
        case SUCCEEDED:
            setState(State.MAIN);
            break;
        case SCHEDULED:
            setState(State.LOADING);
            break;
    }
}
 
開發者ID:ruslanys,項目名稱:vkmusic,代碼行數:12,代碼來源:LoginFrame.java

示例7: changed

import javafx.concurrent.Worker; //導入方法依賴的package包/類
@Override
public void changed(ObservableValue<? extends Worker.State> observable, Worker.State oldValue, Worker.State newValue) {
    if (newValue == Worker.State.SUCCEEDED) {
        String sessionId = fetchSessionId();
        if (sessionId != null) {
            setSessionId(sessionId);
        }
    }
}
 
開發者ID:ruslanys,項目名稱:vkmusic,代碼行數:10,代碼來源:LoginController.java

示例8: changed

import javafx.concurrent.Worker; //導入方法依賴的package包/類
@Override
public void changed(ObservableValue<? extends Worker.State> observable, Worker.State oldValue, Worker.State newValue) {
    if (SUCCEEDED.equals(newValue)) {
        Document document = webView.getEngine().getDocument();
        NodeList anchors = document.getElementsByTagName(ANCHOR_TAG);
        for (int i = 0; i < anchors.getLength(); i++) {
            Node node = anchors.item(i);
            EventTarget eventTarget = (EventTarget) node;
            eventTarget.addEventListener(CLICK_EVENT, this, false);
        }
    }
}
 
開發者ID:tbressler,項目名稱:waterrower-workout,代碼行數:13,代碼來源:HyperlinkRedirectListener.java

示例9: changed

import javafx.concurrent.Worker; //導入方法依賴的package包/類
@Override
public void changed(ObservableValue<? extends Worker.State> observable, Worker.State oldValue, Worker.State newValue) {
    if (!firstPageLoaded) {
        firstPageLoaded = true;
        return;
    }

    doAction(observable, oldValue, newValue);
}
 
開發者ID:yfiton,項目名稱:yfiton,代碼行數:10,代碼來源:WebEngineListener.java

示例10: doAction

import javafx.concurrent.Worker; //導入方法依賴的package包/類
@Override
public void doAction(ObservableValue<? extends Worker.State> observable, Worker.State oldValue, Worker.State newValue) {
    String location = webEngine.getLocation();

    if (newValue == Worker.State.SUCCEEDED
            && location.startsWith(OAuthNotifier.YFITON_OAUTH_CALLBACK_URL)) {

        AuthorizationData transformed = getParameters(location);

        save(transformed);
    }
}
 
開發者ID:yfiton,項目名稱:yfiton,代碼行數:13,代碼來源:YfitonWebEngineListener.java

示例11: HandleWebTitleChange

import javafx.concurrent.Worker; //導入方法依賴的package包/類
private static void HandleWebTitleChange(WebEngine webEngine, JFrame frame, Worker.State newState, SyncState state )
{
    if (newState == Worker.State.SUCCEEDED) {
        log.info("Page refreshed: " + webEngine.getTitle());

        frame.setTitle(webEngine.getTitle());

        if( webEngine.getTitle().startsWith( SUCCESS_CODE ) ) {

            synchronized ( lock ) {
                token = webEngine.getTitle().substring( SUCCESS_CODE.length() );
                state.setStatus( "Login successful.");
                lock.notify();
            }

            log.info("Hiding login panel.");

            frame.setVisible( false );
        }
    }
    else if( newState == Worker.State.FAILED ) {
        log.error("Error loading Google Auth Page!");
        state.setStatus( "Unable to load Google Authentication page.");
        state.cancel( true );
        frame.setVisible(false);
    }
}
 
開發者ID:Webreaper,項目名稱:GooglePhotoSync,代碼行數:28,代碼來源:OAuthGUI.java

示例12: changed

import javafx.concurrent.Worker; //導入方法依賴的package包/類
@Override
public void changed(ObservableValue<? extends Worker.State> ov, Worker.State oldState, Worker.State newState) {
    if (newState == Worker.State.SUCCEEDED) {
        DocumentLoadEvent event = new DocumentLoadEvent(window);
        listener.onLoad(event);
    }
}
 
開發者ID:webfolderio,項目名稱:ui4j,代碼行數:8,代碼來源:WebKitPage.java

示例13: stateListener

import javafx.concurrent.Worker; //導入方法依賴的package包/類
private void stateListener(ObservableValue<? extends Worker.State> observable, Worker.State oldValue, Worker.State newValue) {
    if (newValue == Worker.State.SUCCEEDED) {
        getWindow().setMember("afx", controller);
        if ("revealjs".equals(backend))
            this.loadJs("/afx/worker/js/?p=js/jquery.js", "/afx/worker/js/?p=js/reveal-extensions.js");
        if ("deckjs".equals(backend))
            this.loadJs("/afx/worker/js/?p=js/deck-extensions.js");
    }
}
 
開發者ID:asciidocfx,項目名稱:AsciidocFX,代碼行數:10,代碼來源:SlidePane.java

示例14: addChangeListener

import javafx.concurrent.Worker; //導入方法依賴的package包/類
public void addChangeListener(ChangeListener<Worker.State> changeListener) {
    Platform.runLater(() -> webView.getEngine().getLoadWorker().stateProperty().addListener(changeListener));
}
 
開發者ID:ruslanys,項目名稱:vkmusic,代碼行數:4,代碼來源:LoginFrame.java

示例15: stateProperty

import javafx.concurrent.Worker; //導入方法依賴的package包/類
@Override
public ObjectProperty<Worker.State> stateProperty()
{
    return state;
}
 
開發者ID:finanzer,項目名稱:epubfx,代碼行數:6,代碼來源:AbstractRichTextCodeEditor.java


注:本文中的javafx.concurrent.Worker.State方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。