Hexise's Blog

          業(yè)精于勤荒于嬉 行成于思?xì)в陔S
          posts - 13, comments - 12, trackbacks - 0, articles - 0
            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

          2006年12月29日

          一、軟件準(zhǔn)備:
                 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.運(yùn)行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.啟動(dòng)Sametime歡迎界面,http://domain/stcenter.nsf,登錄至管理頁面,如果無法登錄,可能是域名解析問題,將域名與ip的對(duì)應(yīng)關(guān)系添加到windows/system32/drivers/etc/host文件中
                  3.如果歡迎界面沒有用戶注冊(cè)選項(xiàng),需管理員開啟該功能。
                  
                  在管理頁面中選擇Domino目錄->Domino,勾選

          posted @ 2007-09-04 17:23 Hexise 閱讀(1393) | 評(píng)論 (0)編輯 收藏

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

          CellEditor定義了某個(gè)列被編輯時(shí)顯示的外觀,它可以是文本框、下拉列表框或單選框,也可以自己定義。

          通常使用的CellEditor的子類就是:CheckboxCellEditor、ComboBoxCellEditor和TextCellEditor。
          CellEditor一般用數(shù)組來保存,如果某個(gè)列不需要編輯,則可將該列的CellEditor設(shè)為null。
          當(dāng)CellEditor的數(shù)組定義完后,即可利用setCellEditors(CellEditor[] editors)方法將該數(shù)組設(shè)置到對(duì)應(yīng)的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,避免了設(shè)置value時(shí)造成的空指針異常。

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

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


          CellEditor負(fù)責(zé)外觀,它對(duì)要編輯的模型信息一無所知。所以jface中引入了ICellModifier接口,將model與CellEditor聯(lián)系在一起。為了確定在CellModifier中的列,需要定義columnProperties的String[]數(shù)組,用以區(qū)分不同列對(duì)應(yīng)的不同屬性。使用setColumnProperties(String[] columnProperties)設(shè)置該屬性集。

          ICellModifier定義了三個(gè)接口方法:

          public boolean canModify(Object element, String property);
          該方法判斷何時(shí)該列可以被編輯。其中element是對(duì)應(yīng)的model。返回true表示此時(shí)該列可以被編輯。

          public Object getValue(Object element, String property);
          該方法一般在activateCellEditor()時(shí)調(diào)用,用于設(shè)定CellEditor的初始值。其中element是對(duì)應(yīng)的model。

          此處雖然可以返回Object類型的引用,但是使用時(shí)需小心,特定的CellEditor僅接受特定類型的Value。比如:
          TextCellEditor對(duì)應(yīng)String類型的Value;
          ComboBoxCellEditor對(duì)應(yīng)Integer類型的Value;
          CheckBoxCellEditor對(duì)應(yīng)Boolean類型的Value;
          若返回了不適合的Value對(duì)象,則會(huì)拋出AssertionFailedException。

          public void modify(Object element, String property, Object value);
          該方法執(zhí)行保存修改。一般在saveEditorValue之類的方法中調(diào)用。此處的element不再是model,而是Item類型的引用。取用對(duì)應(yīng)的模型,需要使用((Item) element).getData()方法。一般此處的value值,也就是當(dāng)前CellEditor的Value值,使用CellEditor.getValue()得到。另外,在執(zhí)行完更改后,需要刷新對(duì)應(yīng)的TableViewer或TreeViewer,使做出的更新可見。

          org.eclipse.debug.internal.ui.elements.adapters.DefaultVariableCellModifier是ICellModifier的一個(gè)完整實(shí)現(xiàn):

          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 閱讀(6394) | 評(píng)論 (4)編輯 收藏

          GEF編輯器是構(gòu)架在Draw2D的FigureCanvas上的,而FigureCanvas是swt中Canvas的子類.

          當(dāng)?shù)玫紽igureCanvas之后,就可以得到GEF編輯器的區(qū)域和GEF編輯器內(nèi)部畫布的大小:

          編輯器區(qū)域大小:FigureCanvas.getBounds();
          這是運(yùn)用了FigureCanvas是Canvas子類的特點(diǎn),調(diào)用SWT的Canvas的getBounds()方法,即調(diào)用Control的getBounds()方法.

          畫布大小:FigureCanvas.getContents.getBounds();
          這是運(yùn)用了IFigure的getBounds()方法, 這兩個(gè)區(qū)域矩形不可混淆.

          若要觸發(fā)GEF編輯器的滾動(dòng)條操作,僅需調(diào)用FigureCanvas的scrollToX(int hOffset)和scrollToY(int vOffset)即可.

          獲取FigureCanvas的方法也比較簡(jiǎn)單.通過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 閱讀(2600) | 評(píng)論 (2)編輯 收藏

          這個(gè)函數(shù)用法經(jīng)常忘..
          (String[])ArrayList.toArray(new String[0]);

          posted @ 2006-12-29 13:12 Hexise 閱讀(2669) | 評(píng)論 (0)編輯 收藏

               摘要: 樹節(jié)點(diǎn)定義: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 閱讀(4431) | 評(píng)論 (2)編輯 收藏

          經(jīng)常性的,自己設(shè)計(jì)的對(duì)話框無法改變大小,沒有最大化最小化按鈕,等等.在哪里設(shè)置這些屬性呢?

          JFace的Dialog繼承于Window類,該類中有一方法,設(shè)置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的構(gòu)造函數(shù)中調(diào)用該方法,即可更改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 閱讀(1657) | 評(píng)論 (0)編輯 收藏

          通過圖像的相對(duì)路徑創(chuàng)建org.eclipse.swt.graphics.Image,我通常使用下面兩種途徑:

          1.使用Image(Device device, InputStream stream)構(gòu)造函數(shù),示例代碼如下, path為圖像相對(duì)路徑:

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

          2.使用ImageDescriptor的createImage()方法,示例代碼如下,path為圖像相對(duì)路徑:

          ?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 閱讀(1336) | 評(píng)論 (0)編輯 收藏

          轉(zhuǎn)換成相對(duì)坐標(biāo),要運(yùn)用translateToRelative(Point point)方法.

          例如,在Eclipse Editor視圖中加入Figure,需要計(jì)算出相對(duì)于HostFigure的坐標(biāo),才能正確將figure放在鼠標(biāo)點(diǎn)擊的位置.可以如下這樣做:

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

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

          如此獲得的location就是相對(duì)于HostFigure的坐標(biāo).




          能夠獲得當(dāng)前光標(biāo)絕對(duì)坐標(biāo)的方法是:

          Display.getDefault().getCursorLocation()

          posted @ 2006-12-29 12:26 Hexise 閱讀(1137) | 評(píng)論 (0)編輯 收藏

          最近項(xiàng)目中出現(xiàn)了一個(gè)bug,提示是Resource can not sync with file system.是文件系統(tǒng)不同步的問題,需要手動(dòng)刷新一下資源管理器.

          刷新資源管理器調(diào)用方法:

          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

          我的調(diào)用方法是:

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

          posted @ 2006-12-29 12:19 Hexise 閱讀(1596) | 評(píng)論 (0)編輯 收藏

          可以使用GC類的getAdvanceWidth(char ch)獲取當(dāng)前字符所占的像素寬度.

          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

          可以如下面的程序使用該函數(shù):

          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是目標(biāo)字符串,font是你要設(shè)給字符串的字體對(duì)象:

          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 閱讀(2309) | 評(píng)論 (0)編輯 收藏

          可以擴(kuò)展屬于自己的property view嗎?換句話說,能否再擴(kuò)展出一個(gè)property view出來,并對(duì)它進(jìn)行定制?

          答案是可以的.

          如果你所寫的Property View類繼承自PropertySheet,那么它就是擴(kuò)展出的新property view. 你同樣可以對(duì)其進(jìn)行定制,不會(huì)干擾到原有的property的正常顯示.

          例如,你可以讓你的property view 不監(jiān)聽某個(gè)XYZView中的事件,只需要覆蓋掉isImportant方法就可以了.

          import ?org.eclipse.ui.IWorkbenchPart;
          import ?org.eclipse.ui.views.properties.PropertySheet;

          public ? class ?PropertyView? extends ?PropertySheet? {

          ??
          protected ? boolean ?isImportant(IWorkbenchPart?part)? {
          ????????
          return ?part? != ? this ? && ? ! (part? instanceof ?XYZView);
          ????}

          }

          posted @ 2006-12-29 11:14 Hexise 閱讀(522) | 評(píng)論 (0)編輯 收藏

               摘要: 類似于Java Swing 中的JDateChooser,SWT里有沒有相類似的日期選擇控件呢? 目前有幾種方式提供SWT的時(shí)間控件: 1.eclipse 3.3自帶的org.eclipse.swt.widgets.DateTime控件.?? eclipse 3.3版本增加了對(duì)日期選擇控件的支持,下面是官方提供的示例代碼: import ?o...  閱讀全文

          posted @ 2006-12-29 11:11 Hexise 閱讀(9848) | 評(píng)論 (3)編輯 收藏

          如同編程人員找到了優(yōu)秀的IDE一樣,我找到了我想要的Blog.
          2006年12月29日,Blog遷移至blogjava.

          posted @ 2006-12-29 11:09 Hexise 閱讀(275) | 評(píng)論 (1)編輯 收藏

          主站蜘蛛池模板: 宣威市| 沾益县| 湖南省| 榆树市| 锦州市| 东乡族自治县| 商丘市| 手游| 营口市| 山东省| 南澳县| 淳化县| 洞头县| 荥阳市| 灵宝市| 鲁山县| 大余县| 邹城市| 洞口县| 扶绥县| 汝阳县| 琼海市| 资兴市| 台州市| 潞城市| 宝鸡市| 西华县| 沙田区| 云龙县| 德化县| 绥江县| 宜阳县| 荃湾区| 聊城市| 城固县| 乌恰县| 永泰县| 山阳县| 广平县| 绥芬河市| 灵武市|