本文整理汇总了Java中org.openide.modules.ModuleInfo.removePropertyChangeListener方法的典型用法代码示例。如果您正苦于以下问题:Java ModuleInfo.removePropertyChangeListener方法的具体用法?Java ModuleInfo.removePropertyChangeListener怎么用?Java ModuleInfo.removePropertyChangeListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openide.modules.ModuleInfo
的用法示例。
在下文中一共展示了ModuleInfo.removePropertyChangeListener方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resultChanged
import org.openide.modules.ModuleInfo; //导入方法依赖的package包/类
public void resultChanged(LookupEvent ev) {
LOG.fine("AntModule got ModuleInfo change");
synchronized (this) {
if (modules != null) {
for (ModuleInfo module : modules) {
module.removePropertyChangeListener(this);
}
modules = null;
}
}
fireChange();
}
示例2: resultChanged
import org.openide.modules.ModuleInfo; //导入方法依赖的package包/类
@Override
public void resultChanged(LookupEvent ev) {
for (ModuleInfo m : result.allInstances()) {
m.removePropertyChangeListener(this);
m.addPropertyChangeListener(this);
}
Map<String,ModuleInfo> tmp = new HashMap<String,ModuleInfo>();
for (ModuleInfo mi : result.allInstances()) {
tmp.put(mi.getCodeNameBase(), mi);
}
infos = tmp;
if (ev != null) {
fireChange();
}
}
示例3: switchModule
import org.openide.modules.ModuleInfo; //导入方法依赖的package包/类
/**
* Enbles <code>enable = true</code> or disables <code>enable = false</code> the module.
*/
public static void switchModule(String codeName, boolean enable) throws Exception {
String statusFile = "Modules/" + codeName.replace('.', '-') + ".xml";
ModuleInfo mi = getModuleInfo(codeName);
/*
FileObject fo = findFileObject(statusFile);
Document document = XMLUtil.parse(new InputSource(fo.getInputStream()), false, false, null, EntityCatalog.getDefault());
//Document document = XMLUtil.parse(new InputSource(data.getPrimaryFile().getInputStream()), false, false, null, EntityCatalog.getDefault());
NodeList list = document.getElementsByTagName("param");
for (int i = 0; i < list.getLength(); i++) {
Element ele = (Element) list.item(i);
if (ele.getAttribute("name").equals("enabled")) {
ele.getFirstChild().setNodeValue(enable ? "true" : "false");
break;
}
}
FileLock lock = fo.lock();
OutputStream os = fo.getOutputStream(lock);
XMLUtil.write(document, os, "UTF-8");
lock.releaseLock();
os.close();
*/
// module is switched
if (mi.isEnabled() == enable) {
return;
}
DataObject data = findDataObject(statusFile);
EditorCookie ec = (EditorCookie) data.getCookie(EditorCookie.class);
StyledDocument doc = ec.openDocument();
// Change parametr enabled
String stag = "<param name=\"enabled\">";
String etag = "</param>";
String enabled = enable ? "true" : "false";
String result;
String str = doc.getText(0,doc.getLength());
int sindex = str.indexOf(stag);
int eindex = str.indexOf(etag, sindex);
if (sindex > -1 && eindex > sindex) {
result = str.substring(0, sindex + stag.length()) + enabled + str.substring(eindex);
//System.err.println(result);
} else {
//throw new IllegalStateException("Invalid format of: " + statusFile + ", missing parametr 'enabled'");
// Probably autoload module
return;
}
// prepare synchronization and register listener
final Waiter waiter = new Waiter();
final PropertyChangeListener pcl = new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals("enabled")) {
waiter.notifyFinished();
}
}
};
mi.addPropertyChangeListener(pcl);
// save document
doc.remove(0,doc.getLength());
doc.insertString(0,result,null);
ec.saveDocument();
// wait for enabled propety change and remove listener
waiter.waitFinished();
mi.removePropertyChangeListener(pcl);
}