table.addSelectionListener(new SelectionAdapter() { publicvoid widgetSelected(SelectionEvent e) { // Clean up any previous editor control Control oldEditor = editor.getEditor(); if (oldEditor !=null) oldEditor.dispose(); // Identify the selected row TableItem item = (TableItem)e.item; if (item ==null) return; // The control that will be the editor must be a child of the Table Text newEditor =new Text(table, SWT.NONE); newEditor.setText(item.getText(EDITABLECOLUMN)); newEditor.addModifyListener(new ModifyListener() { publicvoid modifyText(ModifyEvent me) { Text text = (Text)editor.getEditor(); editor.getItem().setText(EDITABLECOLUMN, text.getText()); } }); newEditor.selectAll(); newEditor.setFocus(); editor.setEditor(newEditor, item, EDITABLECOLUMN); } });
]]>GEF中POLICY的位|。。?/title>http://www.aygfsteel.com/hackest/articles/124847.html一条辉一条辉Sun, 17 Jun 2007 14:19:00 GMThttp://www.aygfsteel.com/hackest/articles/124847.htmlhttp://www.aygfsteel.com/hackest/comments/124847.htmlhttp://www.aygfsteel.com/hackest/articles/124847.html#Feedback0http://www.aygfsteel.com/hackest/comments/commentRss/124847.htmlhttp://www.aygfsteel.com/hackest/services/trackbacks/124847.htmlPOLICY有几U类型:NOTEPOLICY,COMPONENTPOLICY,LAYOUTPOLICY;分别对应REQUEST的几U类型,一旦出现REQUEST在EDITPART里面扄应的POLICYQ然后在POLICY中执行COMMAND。当然要lCOMMAND传递一定的参数Q比如MODEL,CONSTRAINT{等 调用POLICY的GETCOMMANDQ)函数Q得到相应的一个或多个COMMANDQ然后分别执行,q样改变了MODEL?br>最后在EDITPART里面d监听?
abstractpublicclass EditPartWithListener extends AbstractGraphicalEditPart implements PropertyChangeListener { publicvoid activate() { super.activate(); // It registers with a model by making self into listeners. ((AbstractModel) getModel()).addPropertyChangeListener(this); } publicvoid deactivate() { super.deactivate(); // It deletes from a model. ((AbstractModel) getModel()).removePropertyChangeListener(this); } }
publicclass HelloEditorPart extends EditPartWithListener { publicvoid propertyChange(PropertyChangeEvent event) { // the model of change shows change of the position information on a model -- do thing or not? if (event.getPropertyName().equals(HelloModel.P_CONSTRAINT)) refreshVisuals(); // A view is updated. } }