小编Cub*_*key的帖子

如何最好地在TreeViewer上使用ViewerFilter?

我正在申请ViewerFilter一棵树上的几棵树,但大多是树叶.过滤器确实适用于叶子,使用叶子内的属性.所有树枝都保持不变,以便它们的叶子可以出现.

但是我想过滤掉不包含选定叶子的分支,我可以看到其中没有ViewerFilter允许这样的机制.

这有可能吗?

例如,给定下面的概念树(其中b是分支,a L是叶子)

b0
  b1
    L2
    L4
    L8
  b2
    L1
    L3
    L5
Run Code Online (Sandbox Code Playgroud)

我想申请一个ViewerFilter只选择甚至包含叶子的树叶和树枝.结果树将是......

b0
  b1
    L2
    L4
    L8
Run Code Online (Sandbox Code Playgroud)

..分支b2不显示,因为它不包含选定的子项,但分支b0b1do.

swt eclipse-plugin jface treeviewer

9
推荐指数
1
解决办法
7227
查看次数

Android应用程序在Lollipop上崩溃 - 服务意图必须明确:

我的日志......

05-05 12:02:50.620:E/AndroidRuntime(32319):java.lang.RuntimeException:无法启动活动ComponentInfo {com.xxxxxxxx.apps.xxx/com.xxxxxx.apps.xxx.activities.SplashActivity}:java .lang.IllegalArgumentException:Service Intent必须是显式的:Intent {act = com.android.vending.licensing.ILicensingService}

我在哪里修复我的代码?

package com.xxxxxx.apps.xxx.activities;`

import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.provider.Settings.Secure;
import android.util.Log;
import android.widget.ImageView;
import android.widget.ImageView.ScaleType;

import com.android.vending.licensing.AESObfuscator;
import com.android.vending.licensing.LicenseChecker;
import com.android.vending.licensing.LicenseCheckerCallback;
import com.android.vending.licensing.ServerManagedPolicy;
import com.xxxxxxxx.apps.xxxx.R;
import com.xxxxxx.libs.util.Platform;

public class SplashActivity extends Activity {

    /*[ $if full $ ]*/
    private final class xxxLicenseCheckerCallback implements LicenseCheckerCallback {
        @Override
        public void allow() {
            Log.i(TAG, "License OK");

            licenseResponseHandler.postDelayed(new Runnable() {
                @Override
                public void run() {
                    Intent intent …
Run Code Online (Sandbox Code Playgroud)

java android

9
推荐指数
2
解决办法
3948
查看次数

@timeout(timelimit)装饰器如何工作?

我发现这个装饰器在Stack Overflow上超时了一个函数,我想知道是否有人可以详细解释它是如何工作的,因为代码非常优雅但根本不清楚.用法是@timeout(timelimit).

from functools import wraps
import errno
import os
import signal

class TimeoutError(Exception):
    pass

def timeout(seconds=100, error_message=os.strerror(errno.ETIME)):
    def decorator(func):
        def _handle_timeout(signum, frame):
            raise TimeoutError(error_message)

        def wrapper(*args, **kwargs):
            signal.signal(signal.SIGALRM, _handle_timeout)
            signal.alarm(seconds)
            try:
                result = func(*args, **kwargs)
            finally:
                signal.alarm(0)
            return result

        return wraps(func)(wrapper)

    return decorator
Run Code Online (Sandbox Code Playgroud)

python

9
推荐指数
1
解决办法
821
查看次数

Shell - 如何在Bash中将String转换为Byte数组

我在StackOverflow上发现了许多帖子,这些帖子已经用C++,C#和其他语言覆盖了这个问题,但是没有使用Shell.

使用Bash/Shell,如何将随机String转换为byte array

我试过了:

echo "some string" | xxd -r -p
Run Code Online (Sandbox Code Playgroud)

但它不起作用.

我基本上想要一个字节输出 - 例如 )?e?GV??vY?Ge?#G

arrays bash shell byte

9
推荐指数
2
解决办法
1万
查看次数

Spring sseEmitter,在调用方法发送后不会立即发送事件

我试图用Spring 4(tomcat 7,servlet-api 3.0.1)发送服务器发送的事件.

问题是Events在调用方法发送后我没有发送.它们都是在超时之后同时(具有相同的时间戳)到达客户端SseEmitter,带有EventSource错误事件.然后客户端正在尝试重新连接.知道发生了什么事吗?

我创建了一个简单的服务:

@RequestMapping(value = "subscribe", method = RequestMethod.GET)
public SseEmitter subscribe () throws IOException {
    final SseEmitter emitter = new SseEmitter();
    Executors.newScheduledThreadPool(1).scheduleAtFixedRate(new Runnable() {
        @Override
        public void run() {
            try {
                emitter.send(SseEmitter.event().data("Thread writing: " + Thread.currentThread()).name("ping"));
            } catch (Exception e) {
            }
        }
    } , 1000, 1000, TimeUnit.MILLISECONDS);
    return emitter;
}
Run Code Online (Sandbox Code Playgroud)

使用客户代码:

sse = new EventSource(urlBuilder(base, url));
sse.addEventListener('ping', function (event) {
    dfd.notify(event);
});

sse.addEventListener('message', function(event){
    dfd.notify(event);
});

sse.addEventListener('close', function(event){
    dfd.notify(event); …
Run Code Online (Sandbox Code Playgroud)

java spring spring-mvc server-sent-events

8
推荐指数
1
解决办法
4243
查看次数

在docker-compose.yml中绑定主机端口时,无法将服务扩展到多个容器

微服务在一个容器上运行.我已将该服务绑定到主机端口8082并使用启动此微服务docker-compose.现在我想使用docker-compose scale命令将其缩放到3个容器但是它给了我以下错误 -

错误:for 2无法在网络上创建端点composetest_nginx_2 composetest_default:绑定0.0.0.0:8082失败:端口已经分配

错误:3无法在网络composetest_default上创建端点composetest_nginx_3:绑定0.0.0.0:8082失败:端口已分配

这会是什么解决方案?

networking docker docker-compose

8
推荐指数
2
解决办法
8641
查看次数

Spring应用程序启动错误:源不能为空

我正在关注Spring教程,当我尝试启动spring应用程序时出现以下错误:

2016-01-20 23:18:15.907 INFO 5271 --- [main] osboot.SpringApplication:启动SpringApplication v1.3.1.RELEASE on ...

2016-01-20 23:18:15.911 INFO 5271 --- [main] osboot.SpringApplication:没有活动的配置文件集,回退到默认配置文件:默认

2016-01-20 23:18:15.918 ERROR 5271 --- [main] osboot.SpringApplication:应用程序启动失败java.lang.IllegalArgumentException:org.springframework.util.Assert.notEmpty(Assert.java)中的源不能为空:276)〜[spring-core-4.2.4.RELEASE.jar:4.2.4.RELEASE] org.springframework.boot.SpringApplication.doRun(SpringApplication.java:352)[spring-boot-1.3.1.RELEASE .jar:1.3.1.RELEASE]在org.springframework的org.springframework.boot.SpringApplication.run(SpringApplication.java:305)[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]. boot.SpringApplication.run(SpringApplication.java:1124)[spring-boot-1.3.1.RELEASE.jar:1.3.1.RELEASE] org.springframework.boot.SpringApplication.main(SpringApplication.java:1140)[spring -boot-1.3.1.RELEASE.jar:1.3.1.RELEASE]

什么是"来源不能为空"错误?

我正在为本教程项目使用Eclipse-Maven项目,我已经更新了项目.我也已经清理并重建了但是我仍然遇到了这个错误.

java rest spring

7
推荐指数
4
解决办法
2万
查看次数

在调试模式下使用Retrofit回调时应用程序崩溃

当我尝试调试它时,我的应用程序崩溃,但在运行模式下运行正常.我查看了堆栈跟踪,我知道这是由于回调代码而发生的.

任何想法为什么应用程序只在调试模式崩溃?

这是片段:

public class MoviePosterFragment extends Fragment {

    private void updateMoviePosters(final RecyclerView rv) {
        MovieAPI mMovieAPI = NetworkAPI.createService(MovieAPI.class);
        Callback<movieGeneral> callback = new Callback<movieGeneral>()
        {
            @Override
            public void success(movieGeneral mMovieGeneral, Response response) {
                updateMovieGrid(rv, mMovieGeneral);
                Toast.makeText(getActivity(), "callback success!",
                        Toast.LENGTH_LONG).show();
            }
            @Override
            public void failure(RetrofitError error) {
                int a =0;
                //show error message
                //set adapter to null
                Toast.makeText(getActivity(), "fail!",
                        Toast.LENGTH_LONG).show();
            }
        };
        mMovieAPI.fetchPopMovies(MOST_POPULAR, API_KEY, callback);
    }
}
Run Code Online (Sandbox Code Playgroud)

网络API:

public class NetworkAPI {

    //Volatile keyword ensures that multiple threads handle the     unique/instance …
Run Code Online (Sandbox Code Playgroud)

java android callback android-studio retrofit

7
推荐指数
0
解决办法
638
查看次数

Chart.js Line,负点的不同填充颜色

当点为负时,我需要更改Line Chart.js中的填充颜色(内部区域).

代码简单而基本:

$(document).ready(function(){

  var ctx = $("#myChart").get(0).getContext("2d");

  var data = {
      labels: ["January", "February", "March", "April", "May", "June", "July"],
      datasets: [
          {
              label: "My First dataset",
              //fillColor : "rgba(60,91,87,1)",
              // String - the color to fill the area under the line with if fill is true
              backgroundColor: "rgba(75,192,192,0.4)",
              strokeColor : "rgba(60,91,87,1)",
              pointColor : "rgba(60,91,87,1)",
              pointStrokeColor : "#58606d",
              // The actual data
              data: [65, 59, 80, -81, 56, 55, -40],

              // String - If specified, binds the dataset to a …
Run Code Online (Sandbox Code Playgroud)

javascript background colors dataset chart.js

7
推荐指数
2
解决办法
7180
查看次数

jquery remove()跳回页面顶部

我写了一个带有覆盖的弹出窗口(与通常的图片显示器不同),用户点击该窗口,并且覆盖层覆盖了用于显示的大图片的屏幕.

问题是,当用户点击"关闭"时,我的功能会淡化图片并覆盖,然后将其删除.当我调用该.remove()函数时,浏览器会关注body标签并滚动到页面顶部.

我尝试通过捕获offset.topco-ords并将它们存储在用户点击的元素的属性中,以及弹出窗口关闭时和之后的方法来进行解决.remove()我已经调用了scrollTo()函数,我使用该函数返回正确的滚动位置(由于某种原因,它会过冲并将元素滚动到顶部).

/*creating the popup layer and picture*/
function newsPopup(obj){

    /***PART ZERO - get the timestamp value of this ***/
    var itemID = $(obj).attr('itemID');
    var storyNumber = $(obj).attr('storyNumber');

    /*adding the identifier for later*/
    var offset = $(obj).offset();
    var roundedOff = Math.round(offset.top);
    $(obj).attr('scrollMeBack', roundedOff);

     /*** the script then continues to create an overlay and picture popup
}

/*function to remove popup*/
function overlayRemove(){
    //first fade out the cover and the container
    $("#NEWS_overlay").fadeOut(); …
Run Code Online (Sandbox Code Playgroud)

javascript jquery

6
推荐指数
1
解决办法
4310
查看次数