- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我需要开发一个 Lotus Notes 插件,将一些 UI 添加到 Lotus Notes 主 UI,并在用户创建和发送电子邮件时执行以下操作:
这在 Lotus Notes 插件中可行吗?
谢谢和问候,纳迪姆·乌拉
最佳答案
package com.ibm.NotesJava.agents;
import lotus.domino.*;
import java.io.File;
import java.io.FileInputStream;
import java.lang.*;
import java.util.*;
import java.awt.*;
import java.awt.List;
import java.awt.event.*;
import java.text.SimpleDateFormat;
public class MyJavaAgent extends AgentBase {
//Main metho which is called by lotus notes
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
// (Your code goes here)
Name n = session.createName(agentContext.getEffectiveUserName());
String st = n.getCommon();
Log log=session.createLog("JAVA_AGENT");
log.openFileLog("JAVA_AGENT.log");
MessageBox mb = new MessageBox();
try{
log.logAction("");
log.logAction("******************************Starting JAVA AGENT ************************");
log.logAction("Hello " + st + "!");
log.logAction("Executing JavaAgentTest with Agent: "+agentContext.getCurrentAgent().getName());
Database db = agentContext.getCurrentDatabase();
//System.out.println("Loading emaildetails.properties file from following location:C:\\Program Files\\Lotus\\Notes\\framework\\emaildetails.properties");
log.logAction("Loading emaildetails.properties file from following location:C:\\Program Files\\Lotus\\Notes\\framework\\emaildetails.properties");
Properties pro = new Properties();
File fil = new File("C:\\Program Files\\Lotus\\Notes\\framework\\emaildetails.properties");
//***********LOGIC*********
DocumentCollection coll=agentContext.getUnprocessedDocuments();
Document doc=coll.getFirstDocument();
//get input from user about the process area
}
}
/************************Library Code ***********************************/
/*
* The MessageBox class allows you to create simple message boxes
* using only the java.awt classes. All you have to do is create an instance
* of a MessageBox and use it to call the doOkCancelDialog or the
* doInputBox methods. You can use a single MessageBox instance to
* create multiple dialogs.
*
* This class has been implemented here as an inner class, but there's
* no reason why it couldn't be a class all by itself. The functionality to
* create buttons and messageboxes has been modularized, so it should
* be easy for you to add your own methods to this class, or make global
* modifications as you desire.
*
* The only really complicated/weird thing I had to do was to write and
* include the MultiLineLabel class, which is included towards the end
* of this class as an inner class. Read the comments associated with
* that class to see what's going on there.
*
* Make sure you import java.awt.* and java.awt.event.*
*
* Julian Robichaux -- http://www.nsftools.com
*/
class MessageBox {
public final int NO_ACTION = -1;
public final int CANCEL_ACTION = 0;
public final int OK_ACTION = 1;
int actionCode = NO_ACTION;
Frame parent;
Dialog msgbox;
MultiLineLabel msglabel; // our custom class, defined later
Panel buttons;
Button ok, cancel;
TextField textbox;
Choice dropdown;
List multilist;
public MessageBox () {
// this is the invisible Frame we'll be using to call all of our Dialogs
parent = new Frame();
}
public void dispose () {
// use this when you're ready to clean up
try { msgbox.dispose(); } catch (Exception e) {}
try { parent.dispose(); } catch (Exception e) {}
}
/*
* This method will create a simple dialog box with a title, a message,
* and Ok/Cancel buttons. It will halt execution of your program until
* one of the buttons is clicked, and it will return either OK_ACTION
* if the Ok button is clicked, or CANCEL_BUTTON if the Cancel
* button is clicked.
*/
public int doOkCancelDialog (String title, String message) {
actionCode = NO_ACTION;
try {
// create the messagebox
msgbox = new Dialog(parent, title, true);
msgbox.setLayout(new BorderLayout());
// create the label
initMsglabel(message);
msgbox.add("North", msglabel);
// create the OK and Cancel buttons
buttons = new Panel();
buttons.setLayout(new FlowLayout());
initOkButton();
buttons.add(ok);
initCancelButton();
buttons.add(cancel);
msgbox.add("South", buttons);
// display everything (the system will wait until a button is pressed
// before returning)
displayMsgbox();
msgbox.dispose(); // just in case the ActionListeners didn't fire...
} catch (Exception e) {
}
return actionCode;
}
/*
* This method will create a dialog box that allows the user to enter
* text into a field. It also has a title, a message, and Ok/Cancel buttons,
* and will halt execution of your program until one of the buttons is
* clicked or the user enters text into the field and presses "Enter".
* If the user clicks the Ok button or enters text and presses "Enter",
* then the text in the field will be returned; otherwise, this method will
* return null (which usually indicates that the user clicked Cancel).
*/
public String doInputBox (String title, String message, String defaultText) {
actionCode = NO_ACTION;
try {
// create the messagebox
msgbox = new Dialog(parent, title, true);
msgbox.setLayout(new BorderLayout());
// create the label
initMsglabel(message);
msgbox.add("North", msglabel);
// create the text field
initTextbox(defaultText);
msgbox.add("Center", textbox);
// create the OK and Cancel buttons
buttons = new Panel();
buttons.setLayout(new FlowLayout());
initOkButton();
buttons.add(ok);
initCancelButton();
buttons.add(cancel);
msgbox.add("South", buttons);
// display everything (the system will wait until a button is pressed
// before returning)
displayMsgbox();
msgbox.dispose(); // just in case the ActionListeners didn't fire...
} catch (Exception e) {
}
if (actionCode == OK_ACTION)
return textbox.getText();
else
return null;
}
/*
* This method will create a dialog box that allows the user to select from
* a dropdown list. It also has a title, a message, and Ok/Cancel buttons,
* and will halt execution of your program until one of the buttons is
* clicked. If the user clicks the Ok button then the text in the field will be
* returned; otherwise, this method will return null (which usually indicates
* that the user clicked Cancel).
*/
public String doDropdownBox (String title, String message, String[] selections) {
actionCode = NO_ACTION;
try {
// create the messagebox
msgbox = new Dialog(parent, title, true);
msgbox.setLayout(new BorderLayout());
// create the label
initMsglabel(message);
msgbox.add("North", msglabel);
// create the dropdown box
initDropdown(selections);
msgbox.add("Center", dropdown);
// create the OK and Cancel buttons
buttons = new Panel();
buttons.setLayout(new FlowLayout());
initOkButton();
buttons.add(ok);
initCancelButton();
buttons.add(cancel);
msgbox.add("South", buttons);
// display everything (the system will wait until a button is pressed
// before returning)
displayMsgbox();
msgbox.dispose(); // just in case the ActionListeners didn't fire...
} catch (Exception e) {
}
if (actionCode == OK_ACTION)
return dropdown.getSelectedItem();
else
return null;
}
/*
* This method will create a dialog box that allows the user to select from
* a list of options (use the allowMultiSelect parameter to indicate whether
* the user can select multiple items from the list [true] or just one [false]).
* It also has a title, a message, and Ok/Cancel buttons, and will halt
* execution of your program until one of the buttons is clicked. If the user
* clicks the Ok button then the text in the field will be returned; otherwise,
* this method will return null (which usually indicates that the user clicked
* Cancel or didn't select anything).
*/
public String[] doMultilistBox (String title, String message, String[] selections, boolean allowMultiSelect) {
actionCode = NO_ACTION;
try {
// create the messagebox
msgbox = new Dialog(parent, title, true);
msgbox.setLayout(new BorderLayout());
// create the label
initMsglabel(message);
msgbox.add("North", msglabel);
// create the multilist field
initMultilist(4, allowMultiSelect, selections);
msgbox.add("Center", multilist);
// create the OK and Cancel buttons
buttons = new Panel();
buttons.setLayout(new FlowLayout());
initOkButton();
buttons.add(ok);
initCancelButton();
buttons.add(cancel);
msgbox.add("South", buttons);
// display everything (the system will wait until a button is pressed
// before returning)
displayMsgbox();
msgbox.dispose(); // just in case the ActionListeners didn't fire...
} catch (Exception e) {
}
if ((actionCode == OK_ACTION) &&
(java.lang.reflect.Array.getLength(multilist.getSelectedItems()) > 0))
return multilist.getSelectedItems();
else
return null;
}
/*
* The private methods below are simply reusable modular functions for
* creating various elements that may appear in a MessageBox dialog.
* They make it easier to write new public methods that create different
* kinds of dialogs, and also allow you to make global changes to all your
* dialog components pretty easily.
*/
private void initMsglabel (String message) {
// the actual message in the MessageBox (using the custom
// MultiLineLabel class, included below)
msglabel = new MultiLineLabel(message);
}
private void initOkButton () {
// the OK button
ok = new Button("OK");
ok.addActionListener( new ActionListener() {
public void actionPerformed(ActionEvent e) {
actionCode = OK_ACTION;
msgbox.dispose();
}
} );
}
private void initCancelButton () {
// the Cancel button
cancel = new Button("Cancel");
cancel.addActionListener( new ActionListener() {
public void actionPerformed(ActionEvent e) {
actionCode = CANCEL_ACTION;
msgbox.dispose();
}
} );
}
private void initTextbox (String defaultText) {
// the field that allows a user to enter text in an InputBox
textbox = new TextField(defaultText, 40);
// the ActionListener here will get called if the user presses "Enter"
textbox.addActionListener( new ActionListener() {
public void actionPerformed(ActionEvent e) {
actionCode = OK_ACTION;
msgbox.dispose();
}
} );
}
private void initDropdown (String[] selections) {
// a dropdown box that allows a user to select from a list of
// multiple items
dropdown = new Choice();
for (int i = 0; i < java.lang.reflect.Array.getLength(selections); i++)
dropdown.add(selections[i]);
}
private void initMultilist (int numOfLines, boolean allowMultiSelect, String[] selections) {
// a multiple selection box that allows a user to select one or
// more items. numOfLines indicates how many lines should be
// visible at a time, allowMultiSelect is a boolean value indicating
// whether or not the user should be allowed to select more than
// one item from the list, and selections is an array of Strings that
// is used to populate the selection box
multilist = new List(numOfLines, allowMultiSelect);
for (int i = 0; i < java.lang.reflect.Array.getLength(selections); i++)
multilist.add(selections[i]);
}
private void displayMsgbox () {
// once all of the components have been added to a dialog,
// use this method to display it
Dimension d = msgbox.getToolkit().getScreenSize();
msgbox.setLocation(d.width/3, d.height/3); // center the dialog (sort of)
msgbox.pack(); // organize all its components
msgbox.setResizable(false); // make sure the user can't resize it
msgbox.toFront(); // give it focus
msgbox.setVisible(true); // and display it
}
/*
* Okay, this is a pain, but java.awt doesn't natively have a Label-type class
* that allows you to display text that's more than one line. So I had to write one
* myself. The class below is a modification of some code from the fantastic
* book, "Java in a Nutshell".
*
* The big change I made was to allow this multi-line label to have a fixed width,
* so the Label wouldn't fly off the screen if you had a big paragraph of text to
* display. The width is specified in "columns", which I defined as the width of
* the letter "X" in whatever font is being used. The text that you add to the label
* is automatically split into chunks that are no longer than the number of columns
* specified (you'll see the code to do this in the parseLabel method).
*
* This sample implementation is an inner class of the MessageBox class, although
* it could also be a separate class all by itself. I made it an inner class to make it
* easier to copy and paste everything from one agent to another.
*
* Julian Robichaux -- http://www.nsftools.com
*/
class MultiLineLabel extends Canvas {
// a custom class that will display a text label at a fixed width across
// multiple lines
// (modification of MultiLineLabel class from "Java in a Nutshell")
String label;
String[] lines;
int rows = 1;
int cols = 40;
int margin = 6;
int rowHeight;
int lineAscent;
int maxWidth;
public MultiLineLabel (String text) {
// create a label with the default width
label = text;
}
public MultiLineLabel (String text, int columns) {
// create a label with the specified number of "columns" (where a column
// is the width of "X" in the font that we're using)
if (columns > 0)
cols = columns;
label = text;
}
protected void measure () {
// get the global values we use in relation to our current font
FontMetrics fm = this.getFontMetrics(this.getFont());
if (fm == null)
return;
rowHeight = fm.getHeight();
lineAscent = fm.getAscent();
maxWidth = fm.stringWidth("X") * cols;
}
private int stringWidth (String text) {
// calculate the width of a String using our current font
FontMetrics fm = this.getFontMetrics(this.getFont());
if (fm == null)
return 0;
return fm.stringWidth(text);
}
public Font getFont () {
// return the font that we're currently using
return super.getFont();
}
public void setFont (Font f) {
// change the font that we're currently using, and redraw the
// label with the new font
super.setFont(f);
repaint();
}
public void addNotify () {
// automatically invoked after our label/Canvas is created but
// before it's displayed (FontMetrics aren't available until
// super.addNotify() has been called)
super.addNotify();
measure();
}
public Dimension getPreferredSize () {
// called by the LayoutManager to find out how big we want to be
if (lines == null)
setText(label);
return new Dimension(maxWidth + (2 * margin), (rows * rowHeight) + (2 * margin));
}
public Dimension getMinimumSize () {
// called by the LayoutManager to find out what our bare minimum
// size requirements are
if (lines == null)
setText(label);
return new Dimension(maxWidth, (rows * rowHeight));
}
public void setText (String text) {
// change the text we're using for this label
label = text;
parseLabel();
}
private void parseLabel () {
// parses the text we want to display in the label, so that the lines[]
// variable contains lines of text that are no wider than maxWidth
String token, word;
StringBuffer msg = new StringBuffer("");
StringBuffer line = new StringBuffer("");
// do an initial measurement, to make sure we have maxWidth
measure();
rows = 0;
// we'll be tokenizing the label String twice, first at every end-of-line
// character ('\n') and then at every space (if the lines are too long),
// in order to generate an StringBuffer of proper length lines, all
// separated by \n
java.util.StringTokenizer st1 = new java.util.StringTokenizer(label, "\n", false);
while (st1.hasMoreTokens()) {
token = st1.nextToken();
if (stringWidth(token) <= maxWidth) {
// if the whole line is shorter than the maxWidth allowed, we can
// just add this line to the buffer and get the next one
rows++;
msg.append(token + "\n");
} else {
// if the line was too long, we'll have to break it up manually by
// tokenizing the line at every space and adding words together
// one by one until we have a line that's greater than maxWidth;
// then we can add that shorter line to the buffer and keep doing
// that until we're out of words
java.util.StringTokenizer st2 = new java.util.StringTokenizer(token, " ", false);
while (st2.hasMoreTokens()) {
word = st2.nextToken();
if ((stringWidth(line.toString()) + stringWidth(word)) > maxWidth) {
rows++;
msg.append(line.toString() + "\n");
line.setLength(0);
line.append(word + " ");
} else {
line.append(word + " ");
}
}
// after we've run out of words, add any remaining text to the buffer, too
if (line.length() > 0) {
rows++;
msg.append(line.toString() + "\n");
}
}
}
// once we're done, split the buffer into the lines[] array
java.util.StringTokenizer st = new java.util.StringTokenizer(msg.toString(), "\n");
lines = new String[rows];
for (int i = 0; i < rows; i++)
lines[i] = st.nextToken();
}
public void paint (Graphics g) {
// draw the actual label to the screen, with space around the edges
// based on the margins we've specified (for some reason, we have to
// call setLabel instead of just parseText here in order to get the size
// right, which is a little redundant, but whatever works...)
int y;
setText(label);
Dimension d = this.getSize();
y = lineAscent + (d.height - (rows * rowHeight)) / 2;
for (int i = 0; i < rows; i++, y += rowHeight)
g.drawString(lines[i], margin, y);
}
}
}// end of the MultiLineLabel class
关于java - Lotus Notes插件拦截外发电子邮件(JAVA),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11015319/
我试图弄清楚如何为聊天气泡制作外 Angular 圆形设计,以获得所需的结果: 我必须使用气泡作为不同背景的组件,没有相同和纯色,但有一些设计元素,所以气泡周围的空间必须是透明的: 我试过将元素添加为
我尝试了 display:table-cell 但它没有用。我怎样才能在div中显示这个词。现在它显示溢出了 div。我在我的网页上使用 CSS2。提前致谢。 Visit W3Schools
我有一个使用 CSS 隐藏在 View (对于移动设备)之外的菜单: #filter-column { position:absolute; left:-400px; } 当用户单击链
我想创建一个这样的问题行 http://imageshack.us/photo/my-images/200/questionh.png/ 此时我的html源是: question label
我要mock a class with Ruby . 如何编写处理样板代码的方法? 以下代码: module Mailgun end module Acani def self.mock_mail
请不要担心循环,但我的问题是关于这些关键字:outer、middle 和 inner。它们不是声明为实例变量,为什么IDE让代码编译?我在谷歌上搜索了一下,这是java标签吗? Java中的某种关键字
我有一个数据框(df),看起来像, Id Name Activity. 1 ABC a;sldkj kkkdk 2 two
Elasticsearch内存中有哪些东西可以使搜索如此快速? 是所有json本身都在内存中,还是仅倒排索引和映射将在内存中24 * 7? 最佳答案 这是一个很好的问题,然后简而言之就是: 不仅仅是数
我正在尝试添加用户在用户界面上选择的值。对于数据库中的特定列,我已经与数据库建立了连接,当我按“保存”时,新的 id 会添加到数据库中,控制台中不会显示任何错误,但我要提交的值不会放入数据库,我怎样才
我不确定这个问题是否应该涉及电子领域,但由于它是关于编程的,所以我在这里问了它。 我正在制作一个数字时钟,使用由移位寄存器供电的 LED,而不是 7 段显示器。无论如何,当使用 CCS 编译代码时,我
我希望用户在 div 中选择文本 (html)。然而,这样做会在浏览器中显示选择背景,也在 div 之外。 我可以用(参见 http://jsfiddle.net/lborgman/aWbgT/)来防
我有以下 Razor View @{ ViewBag.Title = "UserCost"; }
我使用 KineticJS 和 D3.js 制作了以下内容。当用户将鼠标悬停在其中一个点上时,我使用 KineticJS 让我弹出工具提示。但是,由于 Canvas 的边界,工具提示似乎被切断了。有没
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 2 年前。 Improve this qu
我正在使用 primefaces 学习 Java Web 和 jsf。 我的项目当前只有一个index.xhtml 文件,当我访问localhost:8080/appname/时,index.xhtm
我是 ios 新手。 我有一个 View ,其中我使用 Quarts 核心绘制了一个圆圈。 我在该圆圈中放置了一个 UIButton,并赋予了拖放该按钮的功能。 现在我想要限制按钮不能被拖出那个圆圈区
这个问题已经有答案了: How to add two strings as if they were numbers? [duplicate] (20 个回答) How to force JS to
我正在创建简单的文本从右侧滑动到页面的 css 动画。我正在使用 jQuery 通过向元素添加一个类来触发动画。但是起始位置必须在视口(viewport)之外,这会触发底部滚动条出现。如何预防? 这是
我编写了一个简单的代码来评估一段代码并将输出写入文件。这样它减少了我的一些,因为我需要很多很多文件,每一行都包含返回值! 无论如何,我正在使用的代码是: #!/usr/bin/ruby -w def
所以我试图在我的一款游戏中加入一个非常基本的“手电筒”式的东西。 我让它工作的方式是在我的游戏屏幕顶部有一个层,这个层会绘制一个黑色矩形,不透明度约为 80%,在我的游戏场景顶部创建黑暗的外观。 cc
我是一名优秀的程序员,十分优秀!