Hexise's Blog

业精于勤荒于嬉 行成于思毁于随
posts - 13, comments - 12, trackbacks - 0, articles - 0
  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

2007年9月4日

一、软件准备:
       IBM Lotus Domino Server 7.0.2 ;
       IBM Lotus Notes Designer and Admin Client 7.0.2 ;
       IBM Lotus Sametime Server 7.5.1 ;
       IBM Lotus Sametime Connect 7.5.1 ;

二、安装顺序:
        Domino Server->Sametime Server->Notes Admin Client->Sametime Client

三、Domino Server安装:
        1.按照提示安装Domino Server,选择Domino Enterprise Server
        2.运行Server Setup Program
        3.选择Set up the first server or a new Domino domain.
        4.填写Server name和Server title,Organization Name和Organization Certifier password
        5.填写管理员的名称和密码,一定要记录该用户名和密码
        6.选中Domino Server提供的Http Services
        7.不必选中LDAP Service

四、Sametime Server安装:
        1.按照提示安装Sametime Server,如果需要激活80端口,选中Enable HTTP tunneling。
        2.启动Sametime欢迎界面,http://domain/stcenter.nsf,登录至管理页面,如果无法登录,可能是域名解析问题,将域名与ip的对应关系添加到windows/system32/drivers/etc/host文件中
        3.如果欢迎界面没有用户注册选项,需管理员开启该功能。
        
        在管理页面中选择Domino目录->Domino,勾选

posted @ 2007-09-04 17:23 Hexise 阅读(1372) | 评论 (0)编辑 收藏

2007年1月4日

向已有的TreeViewer和TableViewer上添加编辑功能,可以使用CellEditor和CellModifier。

CellEditor定义了某个列被编辑时显示的外观,它可以是文本框、下拉列表框或单选框,也可以自己定义。

通常使用的CellEditor的子类就是:CheckboxCellEditor、ComboBoxCellEditor和TextCellEditor。
CellEditor一般用数组来保存,如果某个列不需要编辑,则可将该列的CellEditor设为null。
当CellEditor的数组定义完后,即可利用setCellEditors(CellEditor[] editors)方法将该数组设置到对应的TreeViewer或TableViewer中去。例如:

    CellEditor[] cellEditors  =   new  CellEditor[ 5 ];
    cellEditors[
0 =   new  TextCellEditor(tableViewer.getTable());
    cellEditors[
1 =   null ;
    cellEditors[
2 =   new  ComboBoxCellEditor(tableViewer.getTable(),  new  String[]{ " first " " second " " third " " forth " });
    cellEditors[
3 =   new  CheckboxCellEditor(tableViewer.getTable());
    cellEditors[
4 =   new  CustomizedTextCellEditor(tableViewer.getTable());
    tableViewer.setCellEditors(cellEditors);

其中CustomizedTextCellEditor是自定义的CellEditor,避免了设置value时造成的空指针异常。

protected class CustomizedTextCellEditor extends TextCellEditor{
    
public CustomizedTextCellEditor(Composite parent){
        
super(parent);
    }

    
protected void doSetValue(Object value) {
        
if(value == null)
            
return;
        
super.doSetValue(value);
    }
        
}


CellEditor负责外观,它对要编辑的模型信息一无所知。所以jface中引入了ICellModifier接口,将model与CellEditor联系在一起。为了确定在CellModifier中的列,需要定义columnProperties的String[]数组,用以区分不同列对应的不同属性。使用setColumnProperties(String[] columnProperties)设置该属性集。

ICellModifier定义了三个接口方法:

public boolean canModify(Object element, String property);
该方法判断何时该列可以被编辑。其中element是对应的model。返回true表示此时该列可以被编辑。

public Object getValue(Object element, String property);
该方法一般在activateCellEditor()时调用,用于设定CellEditor的初始值。其中element是对应的model。

此处虽然可以返回Object类型的引用,但是使用时需小心,特定的CellEditor仅接受特定类型的Value。比如:
TextCellEditor对应String类型的Value;
ComboBoxCellEditor对应Integer类型的Value;
CheckBoxCellEditor对应Boolean类型的Value;
若返回了不适合的Value对象,则会抛出AssertionFailedException。

public void modify(Object element, String property, Object value);
该方法执行保存修改。一般在saveEditorValue之类的方法中调用。此处的element不再是model,而是Item类型的引用。取用对应的模型,需要使用((Item) element).getData()方法。一般此处的value值,也就是当前CellEditor的Value值,使用CellEditor.getValue()得到。另外,在执行完更改后,需要刷新对应的TableViewer或TreeViewer,使做出的更新可见。

org.eclipse.debug.internal.ui.elements.adapters.DefaultVariableCellModifier是ICellModifier的一个完整实现:

import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IVariable;
import org.eclipse.debug.internal.ui.DebugUIPlugin;
import org.eclipse.debug.internal.ui.DefaultLabelProvider;
import org.eclipse.debug.internal.ui.VariableValueEditorManager;
import org.eclipse.debug.ui.actions.IVariableValueEditor;
import org.eclipse.jface.viewers.ICellModifier;

/**
 * 
@since 3.2
 *
 
*/

public class DefaultVariableCellModifier implements ICellModifier {
    
    
/* (non-Javadoc)
     * @see org.eclipse.jface.viewers.ICellModifier#canModify(java.lang.Object, java.lang.String)
     
*/

    
public boolean canModify(Object element, String property) {
        
if (VariableColumnPresentation.COLUMN_VARIABLE_VALUE.equals(property)) {
            
if (element instanceof IVariable) {
                
return ((IVariable) element).supportsValueModification();
            }

        }

        
return false;
    }


    
/* (non-Javadoc)
     * @see org.eclipse.jface.viewers.ICellModifier#getValue(java.lang.Object, java.lang.String)
     
*/

    
public Object getValue(Object element, String property) {
        
if (VariableColumnPresentation.COLUMN_VARIABLE_VALUE.equals(property)) {
            
if (element instanceof IVariable) {
                IVariable variable 
= (IVariable) element;
                
try {
                    
return DefaultLabelProvider.escapeSpecialChars(variable.getValue().getValueString());
                }
 catch (DebugException e) {
                    DebugUIPlugin.log(e);
                }

            }

        }

        
return null;
    }


    
/* (non-Javadoc)
     * @see org.eclipse.jface.viewers.ICellModifier#modify(java.lang.Object, java.lang.String, java.lang.Object)
     
*/

    
public void modify(Object element, String property, Object value) {
        Object oldValue 
= getValue(element, property);
        
if (!value.equals(oldValue)) {
            
if (VariableColumnPresentation.COLUMN_VARIABLE_VALUE.equals(property)) {
                
if (element instanceof IVariable) {
                    IVariable variable 
= (IVariable) element;
                    IVariableValueEditor editor 
= VariableValueEditorManager.getDefault().getVariableValueEditor(variable.getModelIdentifier());
                    
if (value instanceof String) {
                        value 
= DefaultLabelProvider.encodeEsacpedChars((String)value);
                    }

                    
if (editor != null{
                        
if  (editor.saveVariable(variable, (String) value, DebugUIPlugin.getShell())) {
                            
return;
                        }

                    }

                    
try {
                        variable.setValue((String) value);
                    }
 catch (DebugException e) {
                        DebugUIPlugin.errorDialog(DebugUIPlugin.getShell(), Messages.VariableColumnPresentation_4, Messages.VariableColumnPresentation_5, e.getStatus());
                    }

                }

            }

        }

    }


}

posted @ 2007-01-04 15:29 Hexise 阅读(6343) | 评论 (4)编辑 收藏

2006年12月29日

GEF编辑器是构架在Draw2D的FigureCanvas上的,而FigureCanvas是swt中Canvas的子类.

当得到FigureCanvas之后,就可以得到GEF编辑器的区域和GEF编辑器内部画布的大小:

编辑器区域大小:FigureCanvas.getBounds();
这是运用了FigureCanvas是Canvas子类的特点,调用SWT的Canvas的getBounds()方法,即调用Control的getBounds()方法.

画布大小:FigureCanvas.getContents.getBounds();
这是运用了IFigure的getBounds()方法, 这两个区域矩形不可混淆.

若要触发GEF编辑器的滚动条操作,仅需调用FigureCanvas的scrollToX(int hOffset)和scrollToY(int vOffset)即可.

获取FigureCanvas的方法也比较简单.通过EditPart.getViewer()获得EditPartViewer,一般情况下EditPartViewer的Control就是FigureCanvas.

列出代码如下:

FigureCanvas canvas  =  (FigureCanvas)EditPart.getViewer().getControl();
canvas.scrollToX(
500 );
canvas.scrollToY(
600 );
System.out.println(canvas.getBounds());
System.out.println(canvas.getContents().getBounds());

posted @ 2006-12-29 13:16 Hexise 阅读(2557) | 评论 (2)编辑 收藏

这个函数用法经常忘..
(String[])ArrayList.toArray(new String[0]);

posted @ 2006-12-29 13:12 Hexise 阅读(2645) | 评论 (0)编辑 收藏

     摘要: 树节点定义:class TreeNode {    public TreeNode left;    public TreeNode right;    public int value;    public TreeNode(TreeNode left, TreeNode right, int value) {        this.left = left;        this.right...  阅读全文

posted @ 2006-12-29 13:01 Hexise 阅读(4410) | 评论 (2)编辑 收藏

经常性的,自己设计的对话框无法改变大小,没有最大化最小化按钮,等等.在哪里设置这些属性呢?

JFace的Dialog继承于Window类,该类中有一方法,设置Shell的样式.

setShellStyle

protected void setShellStyle(int newShellStyle)
Sets the shell style bits. This method has no effect after the shell is created.

The shell style bits are used by the framework method createShell when creating this window's shell.

Parameters:
newShellStyle - the new shell style bits


在Dialog的构造函数中调用该方法,即可更改Dialog的样式.下为一例:

import  org.eclipse.jface.dialogs.Dialog;
import  org.eclipse.swt.SWT;
import  org.eclipse.swt.browser.Browser;
import  org.eclipse.swt.layout.GridData;
import  org.eclipse.swt.widgets.Composite;
import  org.eclipse.swt.widgets.Control;
import  org.eclipse.swt.widgets.Shell;

public   class  BrowserDialog  extends  Dialog  {

    
private  String url;

    
public  BrowserDialog(Shell parent, String url)  {
        
super (parent);
        setShellStyle(getShellStyle() 
|  SWT.RESIZE  |  SWT.MAX);
        
this .url  =  url;
    }


    
protected  Control createContents(Composite parent)  {
        Browser browser 
=   new  Browser(parent, SWT.NONE);
        browser.setUrl(url);
        GridData gd 
=   new  GridData(GridData.FILL_BOTH);
        gd.minimumWidth 
=   600 ;
        gd.minimumHeight 
=   400 ;
        browser.setLayoutData(gd);
        
return  browser;
    }

}

import  org.eclipse.swt.SWT;
import  org.eclipse.swt.widgets.Display;
import  org.eclipse.swt.widgets.Shell;

public   class  TestDialog  {

    
public   static   void  main(String[] args)  {

        
final  Shell shell  =   new  Shell(SWT.DIALOG_TRIM  |  SWT.RESIZE  |  SWT.MIN  |  SWT.MAX);
        
final  Display display  =  shell.getDisplay();

        String path 
=   " C:/Temp/log.html " ;
        BrowserDialog dlg 
=   new  BrowserDialog(shell, path);
        dlg.open();

        
while  ( ! shell.isDisposed())  {
            
if  ( ! display.readAndDispatch())  {
                display.sleep();
            }

        }


    }

}

posted @ 2006-12-29 12:53 Hexise 阅读(1622) | 评论 (0)编辑 收藏

通过图像的相对路径创建org.eclipse.swt.graphics.Image,我通常使用下面两种途径:

1.使用Image(Device device, InputStream stream)构造函数,示例代码如下, path为图像相对路径:

private Image getImage(String path){
  
return new Image(Display.getCurrent(), getClass().getResourceAsStream(path));
}

2.使用ImageDescriptor的createImage()方法,示例代码如下,path为图像相对路径:

 private Image getImage(String path){
  URL url 
= null;
  
try{
   url 
= new URL(Activator.getDefault().getDescriptor().getInstallURL(), path);
  }
catch(MalformedURLException e){
   e.printStackTrace();
  }

  ImageDescriptor imageDescriptor 
= ImageDescriptor.createFromURL(url);
  
return imageDescriptor.createImage();
 }

或者:

private Image getImage(String path){
   ImageDescriptor desc 
= AbstractUIPlugin.imageDescriptorFromPlugin(ID, path);
   
return desc.createImage();
}

posted @ 2006-12-29 12:43 Hexise 阅读(1307) | 评论 (0)编辑 收藏

转换成相对坐标,要运用translateToRelative(Point point)方法.

例如,在Eclipse Editor视图中加入Figure,需要计算出相对于HostFigure的坐标,才能正确将figure放在鼠标点击的位置.可以如下这样做:

在getCreateCommand(CreateRequest request)方法中,加入如下语句:

Point location = request.getLocation().getCopy();
getHostFigure().translateToRelative(location);

如此获得的location就是相对于HostFigure的坐标.




能够获得当前光标绝对坐标的方法是:

Display.getDefault().getCursorLocation()

posted @ 2006-12-29 12:26 Hexise 阅读(1108) | 评论 (0)编辑 收藏

最近项目中出现了一个bug,提示是Resource can not sync with file system.是文件系统不同步的问题,需要手动刷新一下资源管理器.

刷新资源管理器调用方法:

RefreshLocal

public void refreshLocal(int depth, IProgressMonitor monitor)
                  throws CoreException

Refreshes the resource hierarchy from this resource and its children (to the specified depth) relative to the local file system. Creations, deletions, and changes detected in the local file system will be reflected in the workspace's resource tree. This resource need not exist or be local.
This method may discover changes to resources; any such changes will be reported in a subsequent resource change event.

If a new file or directory is discovered in the local file system at or below the location of this resource, any parent folders required to contain the new resource in the workspace will also be created automatically as required.

This method is long-running; progress and cancellation are provided by the given progress monitor.


Parameters:
depth - valid values are DEPTH_ZERO, DEPTH_ONE, or DEPTH_INFINITE
monitor - a progress monitor, or null if progress reporting is not desired
Throws:
CoreException - if this method fails. Reasons include:
Resource changes are disallowed during certain types of resource change event notification. See IResourceChangeEvent for more details.
OperationCanceledException - if the operation is canceled. Cancelation can occur even if no progress monitor is provided.
See Also:
DEPTH_ZERO, DEPTH_ONE, DEPTH_INFINITE, IResourceRuleFactory.refreshRule(IResource)

该方法位于org.eclipse.core.resources.IResource

我的调用方法是:

ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, monitor);

posted @ 2006-12-29 12:19 Hexise 阅读(1572) | 评论 (0)编辑 收藏

可以使用GC类的getAdvanceWidth(char ch)获取当前字符所占的像素宽度.

getAdvanceWidth

          public int getAdvanceWidth(char ch)

Returns the advance width of the specified character in the font which is currently selected into the receiver.

The advance width is defined as the horizontal distance the cursor should move after printing the character in the selected font.

Parameters:
ch - the character to measure
Returns:
the distance in the x direction to move past the character before painting the next
Throws:
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

可以如下面的程序使用该函数:

public static int getStringWidth(String string, Control control) {

   
int width = 0;
    GC gc 
= new GC(control);
    
for (int i = 0; i < string.length(); i++{
        
char c = string.charAt(i);
        width 
+= gc.getAdvanceWidth(c);
    }


    gc.dispose();
    
return width;
}

或者更通用的,其中string是目标字符串,font是你要设给字符串的字体对象:

public static int getStringWidth(String string, Font font){
    
int width = 0;
    Shell shell 
= new Shell();
    Label label 
= new Label(shell, SWT.NONE);
    label.setFont(font);
    GC gc 
= new GC(label);
    
for(int i=0;i<string.length();i++){
          
char c = string.charAt(i);
          width 
+= gc.getAdvanceWidth(c);
    }

    gc.dispose();
    shell.dispose();
    
return width;
}

posted @ 2006-12-29 11:21 Hexise 阅读(2261) | 评论 (0)编辑 收藏