当前位置: 首页>>代码示例>>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;未经允许,请勿转载。