走过海棠暮

文章 0 评论 0 浏览 24

走过海棠暮 2024-10-31 00:15:28

只需在 onCreate 方法中注册上下文菜单,

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView tv = (TextView)this.findViewById(R.id.textViewId);
registerForContextMenu(this.getTextView());
}

通过添加项目在此处创建上下文菜单

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo)
{
menu.setHeaderTitle("Sample Context Menu");
menu.add(200, 200, 200, "item1");
}

,在此处响应所选项目

 @Override
public boolean onContextItemSelected(MenuItem item)
{
if (item.itemId() = some-menu-item-id)
{
//handle this menu item
return true;
}
… other exception processing
}

只需运行并获取上下文菜单:)

just register for context menu in onCreate method

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TextView tv = (TextView)this.findViewById(R.id.textViewId);
registerForContextMenu(this.getTextView());
}

create ContextMenu here by adding item

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo)
{
menu.setHeaderTitle("Sample Context Menu");
menu.add(200, 200, 200, "item1");
}

respond here for selected item

 @Override
public boolean onContextItemSelected(MenuItem item)
{
if (item.itemId() = some-menu-item-id)
{
//handle this menu item
return true;
}
… other exception processing
}

just run and get your context menu :)

上下文菜单创建

走过海棠暮 2024-10-30 16:52:13

在大多数从头开始的过程中,在写入平面文件之前,即使没有执行任何转换,也会在写入文件之前或写入文件的步骤之前对数据执行一些转换,存在中间 DML,其中包含每列的数据定义,其中大部分是通用定义,您所需要做的就是要求 ab-initio 开发人员向您发送该通用 dml 的副本,然后您可以将此 DML 发送到java 中的映射值。希望这有帮助。

In most ab-inito processes, just before a flat file is written, some transformation is performed on the data, even if there in no transformation performed, before writing to the file, or a step before the step that writes to the file, an intermediate DML is present which contains the data definitions for each columns, most of these are generic definitions, all you need to do is ask the ab-initio developer to send you a copy of that generic dml, and then you can you this DML to map values in java. Hope this helps.

如何将其他语言的数据映射到java

走过海棠暮 2024-10-29 19:48:43

您确定需要 groups_users 表吗?每个用户不是只能属于一个组吗?

如果您只需将组 id 作为外键放入用户表中,您将能够更轻松地完成此操作

    CREATE TABLE IF NOT EXISTS `users` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `email` varchar(64) NOT NULL,
  `password` varchar(64) NOT NULL,
  `enabled` tinyint(1) NOT NULL,
  `created` datetime NOT NULL,
  `modified` datetime NOT NULL,
  `group_id` int(11) NOT NULLL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `email` (`email`)
)

然后您可以将用户是否应该能够

在您的 app_controller 中看到某些信息发送到视图。 php 添加以下内容

function beforeFilter(){
    $this->set('users_role', $this->Auth->user('group_id'));
}

现在您的视图将有一个可访问的变量,该变量将是 $users_role... 然后您可以在视图中执行以下操作。

<?php if($users_role == 1 ): ?>
    //show records available to admins
<?php elseif ($users_role == 2): ?>
    //show records available to logged in users
<?php else : ?>
    //show records for all users
<?php endif; ?>

Are you sure that you need the groups_users table? Wouldn't each user only be able to belong to one group?

You will be able to accomplish this much easier if you just bring the group id into the users table as a foreign key

    CREATE TABLE IF NOT EXISTS `users` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `email` varchar(64) NOT NULL,
  `password` varchar(64) NOT NULL,
  `enabled` tinyint(1) NOT NULL,
  `created` datetime NOT NULL,
  `modified` datetime NOT NULL,
  `group_id` int(11) NOT NULLL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `email` (`email`)
)

Then you can send to the view whether or not the user should be able to see certain information...

in your app_controller.php add the following

function beforeFilter(){
    $this->set('users_role', $this->Auth->user('group_id'));
}

Now you will have a variable accessable by your view which will be $users_role... then you can perform the following in your view.

<?php if($users_role == 1 ): ?>
    //show records available to admins
<?php elseif ($users_role == 2): ?>
    //show records available to logged in users
<?php else : ?>
    //show records for all users
<?php endif; ?>

cakePHP如何获取权限

走过海棠暮 2024-10-29 06:29:18

不,PHP 没有这样的东西。 PHP 中最接近的近似方法是使用单引号字符串作为哈希键 - 只是为了确保其中不会有“插值”。

几个例子:

  • $arr[key] - 在大多数情况下,这与 $arr['key'] 一样工作,但有几个缺点:
    a) 如果确实存在定义的常量(例如,define('key', 'rubbish') - 您将访问$arr['rubish']。所以,这根本不安全。
    b) 它将生成“PHP 通知”消息(除非通知被抑制)

  • $arr[@key] — 就像以前一样,但没有通知。事实上,错误抑制在可维护性方面非常糟糕。

  • $arr["key"] — 绝对有效的方式,除非双引号字符串中有一些特殊符号。例如:"ab\ntc" != 'ab\ntc'"ab$c" != 'ab$c' 等等。但我相信,想到这种情况有点偏执。

  • $arr['key'] — 在我看来,这是最接近 PHP 中的 Ruby 的 arr[:key]

No, PHP does not have anything like this. The most close approximation in PHP would be to use single-quoted strings for your hash keys — just to make sure there would be no "interpolations" in them.

Few examples:

  • $arr[key] — this would work like $arr['key'] in most cases, but has couple of drawbacks:
    a) if there is indeed a defined constant (e.g., define('key', 'rubbish') — you'll access $arr['rubish']. So, it's simply unsafe.
    b) it would produce "PHP Notice" messages (unless notices are suppressed)

  • $arr[@key] — just like before, but without notices. In fact, errors suppressing is very bad in terms of maintainability.

  • $arr["key"] — absolutely valid way, unless you have some special symbols inside the double-quoted string. For example: "ab\ntc" != 'ab\ntc', "ab$c" != 'ab$c' and so on. But its a bit paranoid to think of such cases, I believe.

  • $arr['key'] — this is, to my opinion, the closest to Ruby's arr[:key] as you could get in PHP.

PHP 相当于 Ruby 符号

走过海棠暮 2024-10-29 06:07:30

3 年后我偶然发现了这个问题;)

有趣的事实是 imagemagick 本身存在于 javascript 中。
但 google (page1) 和 github 不知何故找不到它。
Github 失败是因为主项目(有用的 emscripten ports)

UNIX 工具箱.js

仅由模块组成...

这是带有自述文件的主要项目:
github : manuels/unix-toolbox.js

git clone ... --recursive

和特定模块:
github:manuels/unix-toolbox.js-imagemagick

3 years later I stumbled upon this question ;)

The fun fact is that imagemagick itself exists in javascript.
But google (page1) and github somehow do not find it.
Github fails because the main project (useful emscripten ports)

UNIX toolbox.js

just consists of the modules ...

Here is the main project with readme:
github : manuels/unix-toolbox.js

git clone ... --recursive

and the particular module :
github : manuels/unix-toolbox.js-imagemagick

类似于 Imagemagick 的 JavaScript 库(即调整图像和图片的大小,同时最大化图片保真度)?

走过海棠暮 2024-10-29 05:51:16

虽然我不能 100% 确定你的意图,但我认为你的目标是取代
fileLine 中的每个匹配子字符串与 valuesMap 的相应值。
如果是这样,以下代码可能会满足您的目的:

  ...same as your code...

  while ( regex_search( begin, end, what, expression, flags ) ) {
    outLine.insert( outLine.end(), begin, what[0].first );
    outLine += valuesMap[what[0]];
    begin = what[0].second;
  }

  outLine.insert( outLine.end(), begin, end );

希望这会有所帮助

Though I'm not 100% sure about your intent, I presume your goal is replacing
each matched substring in fileLine with the corresponding value of valuesMap.
If so, the following code might meet your purpose:

  ...same as your code...

  while ( regex_search( begin, end, what, expression, flags ) ) {
    outLine.insert( outLine.end(), begin, what[0].first );
    outLine += valuesMap[what[0]];
    begin = what[0].second;
  }

  outLine.insert( outLine.end(), begin, end );

Hope this helps

带 Boost 的 regex_search 和 regex_replace

走过海棠暮 2024-10-29 05:31:18

不,你不能在mapView上打开上下文菜单

我想让onTap事件打开上下文菜单我尝试了大多数方法,但都是徒劳。

如果您愿意,也许您应该使用 Alert.Builder 及其三个按钮来执行操作。或者更好的是有一个定制的警报视图。

registerForContextMenu(mapView);

openContextMenu(mapView);

那不起作用

No you can't open a context menu on mapView

I wanted to have onTap event open context menu I tried most of methods but all in vain.

Maybe you should use Alert.Builder with it's three button to perform actions if you want. or better have a customized alert view.

registerForContextMenu(mapView);

openContextMenu(mapView);

that don't works

是否可以从 Android 中的地图覆盖项打开上下文菜单?

走过海棠暮 2024-10-29 05:08:00
mylist = [line.split()[7] for line in myfile] 

如果始终是第 8 列,则应该有效。

如果 tr 的位置是可变的,你可以这样做

mylist = []
for line in myfile:
    items = line.split()
    mylist.append(items[items.index("tr")+1])
mylist = [line.split()[7] for line in myfile] 

should work if it's always the 8th column.

If the position of tr is variable, you could do

mylist = []
for line in myfile:
    items = line.split()
    mylist.append(items[items.index("tr")+1])

如何根据文本文件中的特定单词过滤特定值并将其存储在列表中?

走过海棠暮 2024-10-28 22:06:40

如果你想进入function2,你必须调用它。事实上,将它放入另一个函数中并不意味着它将被执行,但仍会被声明和定义。你必须显式地调用它

function1()
    {
    statement1;
    statement2;
    function2()
    {
            statement3;
            statement3;
    }
 function2();

} 

,事实上 Std C 不允许这样做。但这仍然取决于您的编译器,因此如果您出于某种目的这样做,请咨询您的编译器,否则只需将 function2 声明从 function1 的块中取出

If you want to enter function2 you have to call it. The fact that you put it inside another function doesn't mean it's going to be executed, but yet declared and defined. You have to explicitly call it

function1()
    {
    statement1;
    statement2;
    function2()
    {
            statement3;
            statement3;
    }
 function2();

} 

And indeed Std C doesn't allow this. But it still depends on your compiler, so if you're doing this on some purpose, check with your compiler otherwise just pull the function2 declaration out of the function1's block

函数内的函数

走过海棠暮 2024-10-28 13:35:19

你应该这样做:

class MyHelper extends Zend_Controller_Action_Helper
{
    const BAR = false;

    public function preDispatch($request)
    {
        $this->ifBarExit(self::BAR);
    }

    public function ifBarExit($barValue)
    {
        if ($barValue) {
            exit('Bar was true!');
        }
    }
}

preDispatch 认为它的第一个变量是 request 对象 - 这就是它在 ZF 内部的连接方式。

但现在有了新功能,您可以做到:

 $helper = Zend_Controller_Action_HelperBroker::getStaticHelper('MyHelper');
 $variable = true;
 $helper->ifBarExit($variable); //won't exit

您不应该为了自己的恶棍计划而弄乱内部方法(即调用它们)。如果你想在助手中注入一些东西,不要直接传递它。添加成员变量和类似 $helper->setImportantThing($thing); 的内容,将其保存到 protected $_thing; 中,然后在方法内 echo $这->_thing;

You should make it like this:

class MyHelper extends Zend_Controller_Action_Helper
{
    const BAR = false;

    public function preDispatch($request)
    {
        $this->ifBarExit(self::BAR);
    }

    public function ifBarExit($barValue)
    {
        if ($barValue) {
            exit('Bar was true!');
        }
    }
}

The preDispatch thinks it's first variable is request object - it's how it'S wired in the ZF's internals.

But now with the new function you can do:

 $helper = Zend_Controller_Action_HelperBroker::getStaticHelper('MyHelper');
 $variable = true;
 $helper->ifBarExit($variable); //won't exit

You shouldn't mess with the internal methods (i.e. call them) for your own vilain plans. If you want to inject something in the helper, don't pass it directly. Add member variable and sth like $helper->setImportantThing($thing); which will save it into protected $_thing; and then inside the method echo $this->_thing;

getStaticHelper(action helper) 获取参数但给出错误

走过海棠暮 2024-10-28 12:12:12

您可以使用 WinMerge 生成一个批处理文件来比较文件、创建列表,然后循环列表并复制文件。

You could have a batch file with WinMerge comparing the files, creating a list and then looping the list and copying files.

将源文件夹和目标文件夹之间的差异复制到第三个文件夹

走过海棠暮 2024-10-28 10:34:25

window.postMessage() 只能来回发送字符串,因此不能发送二进制数据。您只需将标准表单发布到不同的域即可。

window.postMessage() can only send strings back and forth, so you can't send binary data. You could just do a standard form post to a different domain.

window.postMessage(...) 用于跨域文件上传?

走过海棠暮 2024-10-28 04:32:02

事实上它应该改变。我会尝试使用 NSTextField 等其他控件。当它不起作用时,你就做错了

绑定的想法正是你所想的那样。

Actually it should change. I would try it with other controls like NSTextField. When it doesn't work you're doing it wrong

The idea of binding is exactly what you thought it is.

关于 NSUserDefaults 的问题

走过海棠暮 2024-10-28 03:37:08

理想情况下,您的每个测试都将从干净的状态开始,没有任何现有的 Firefox 或 IE 进程在运行。在您的测试tearDown()方法中,您应该关闭/退出浏览器。即使使用这种方法,有时,杂散进程仍然会悄悄出现。如果您在 Windows 上通过 Java RC 运行 Selenium 服务器,将此命令放入测试的 startUp() 方法中可以帮助确保没有浏览器/实例正在运行

Runtime.getRuntime().exec("TASKKILL /F /IM Firefox.exe");
Runtime.getRuntime().exec("TASKKILL /F /IM iexplore.exe");

:当检测到崩溃时,Firefox 将显示一个警告对话框,指示崩溃。您可以通过外部工具(例如 AutoIT)以编程方式与此窗口进行交互,如果需要,它可以自动按此对话框上的“确定”按钮。我发现构建一个在后台不断运行的外部 AutoIT 脚本来处理弹出窗口、崩溃、警告等非常有帮助。

Ideally, each of your tests will be starting from a clean state, with no existing Firefox or IE processes running. In your test tearDown() methods, you should be closing / exiting your browsers. Even with this approach, sometimes, stray processes can still creep in. If you are running your Selenium server on Windows, via Java RC, putting this command in your tests' startUp() method can help ensure no browsers / instances are running:

Runtime.getRuntime().exec("TASKKILL /F /IM Firefox.exe");
Runtime.getRuntime().exec("TASKKILL /F /IM iexplore.exe");

As far as detecting when they crash, Firefox will display an alert dialog indicating a crash. You can programatically interact with this window via external tools, such as AutoIT, which can automatically press the "OK" button on this dialog if you need. I've found that building an external AutoIT script that runs constantly in the background to handle popups, crashes, warnings, etc, is very helpful.

如何处理硒崩溃

走过海棠暮 2024-10-28 03:13:56

我会尝试使用基于相互证书的身份验证的 HTTPS 作为最安全的选择。桌面应用程序可以轮询服务器(=定期询问)并在无响应/无连接/否定响应的情况下退出。

但是,根据您正在开发的应用的类型目标受众,您可以预期大量用户存在连接问题完全没有连接

因此,最终,您可以想出更简单的解决方案,例如在本地测量运行时间而不涉及任何服务器,并获得几乎相同的效果。

I'd give a go to HTTPS with mutual certificate-based authentication as the safest option. The desktop app can poll the server (=ask periodically) and quit in case of no response / no connection / negative reponse.

However, based on the type of app you are developing and the target audience, you can expect an important amount of users to have connectivity problems or have no connectivity at all.

Because of this, at the end of the day, you can come up with a lot simpler solution, like measuring run-time locally without any server involved, and gain pretty much the same effect.

从 Linux 服务器与 C# 桌面应用程序通信的选项?

更多

推荐作者

daid

文章 0 评论 0

我心依旧

文章 0 评论 0

晒暮凉

文章 0 评论 0

微信用户

文章 0 评论 0

DS

文章 0 评论 0

〆凄凉。

文章 0 评论 0

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文