changelog.java

来自「Semantic Web Ontology Editor」· Java 代码 · 共 2,028 行 · 第 1/5 页

JAVA
2,028
字号
		for (Iterator changeIter = changeSet.iterator(); changeIter.hasNext();) {
			SwoopChange swc = (SwoopChange) changeIter.next();
			
			// control adding to changeTreeTable based on checkbox selection
			// of "Show Changes" and "Show Checkpoints"
			if (swc.isCheckpointRelated && !showChkPts.isSelected()) continue;
			if (!swc.isCheckpointRelated && !showChanges.isSelected()) continue;
			
			TreeTableNode changeNode = new TreeTableNode(swc);
			rootNode.addChild(changeNode);
		}
		
		// expand all tree nodes
		for (int row=0; row<changeSet.size(); row++)
			changeTree.expandRow(row);
		changeTree.updateUI();
		
		// need to refresh UI
		this.refreshUI();
	}
	
	private void refreshUI() {
		topPanel.add(threadTableScroll, "Center");		
		bottomPanel.add(htmlPanel, "Center");
		topPanel.updateUI();
		bottomPanel.updateUI();
	}

	/**
	 * Return some ontology change related information depending on 
	 * parameter passed to it 
	 * @param change - ontology change
	 * @param function - either:
	 * 			CHANGE_DESCRIPTION : NL description of change
	 * 			CHANGE_RDFXML : Serialization of change in RDF/XML
	 * 			CHANGE_INVERSE : Inverse Ontology Change 
	 *          CHANGE_ALIGN : Align an Ontology Change with an existing SwoopModel Ontology Object
	 * @param ChangeRenderer - used to callback for serializing change (cyclic - needs to be changed)
	 * @param uris - set of URIs which are subjects of the change
	 * @return
	 */
	public Object getChangeInformation(OntologyChange change, int function, OntologyChangeRenderer changeRenderer, List uris, OWLOntology alignOnt) {
		String changeDesc = "";
		
		if (change instanceof RevertCheckpointChange) {
			
			RevertCheckpointChange revertChk = (RevertCheckpointChange) change;
			String desc = revertChk.getDescription();
			String changeStr = "["+revertChk.getTimeStamp()+"]<br>";
			changeStr += desc;
			SaveCheckpointChange chkpt = revertChk.getCheckpointChange();
			int chkPtScope = chkpt.getScope();
			OWLOntology chkPtOnt = swoopModel.getOntology(chkpt.getOntologyURI());
			OWLEntity chkPtEntity = swoopModel.getEntity(chkPtOnt, chkpt.getEntityURI(), false);
			OWLNamedObject currObj = swoopModel.selectedOWLObject;
			if (chkPtOnt==null || currObj==null || (scope == ENTITY_SCOPE && chkPtEntity==null)) return changeDesc;
			switch (function) {
				case CHANGE_DESCRIPTION :
					changeDesc += changeStr;
					break;
			
				case CHANGE_RDFXML :				
					break;
					
				case CHANGE_INVERSE :
					break;
			}			
		}
		else
		if (change instanceof SaveCheckpointChange) {
			SaveCheckpointChange saveChk = (SaveCheckpointChange) change;
			String desc = saveChk.getDescription();
			String location = saveChk.getLocationURL();
			int chkPtScope = saveChk.getScope();
			String title = "";
			switch (chkPtScope) {
				case 1: 
					title = "Entity" + "&nbsp;<a href=\""+saveChk.getEntityURI()+"\">"+swoopModel.shortForm(saveChk.getEntityURI())+"</a>&nbsp;";
					uris.add(saveChk.getEntityURI());
					break;
				case 2:
					title = "Ontology" + "&nbsp;<a href=\""+saveChk.getOntologyURI()+"\">"+swoopModel.shortForm(saveChk.getOntologyURI())+"</a>&nbsp;";
					uris.add(saveChk.getOntologyURI());
					break;
				case 3: 
					title = "Workspace"; 
					uris.addAll(saveChk.workspaceURIs());
					break;
			}
			String timeStamp = saveChk.getTimeStamp();
			
			switch (function) {
			
			case CHANGE_DESCRIPTION :
				String changeStr = "<u>[[[ CHECKPOINT ]]]</u><br>";
				changeStr += "Saved "+title+" Checkpoint";
				changeStr += "<br><b>Description:</b>&nbsp;" + desc;
				if (!location.equals("")) changeStr += "<br><b>Location:</b>&nbsp;" + location;
				changeStr += this.addLinks(change);
				changeDesc += changeStr;
				return changeDesc;
				
			case CHANGE_RDFXML :				
				break;
				
			case CHANGE_INVERSE :
				break;
			}
		}
		else
		if (change instanceof SetFunctional) {
			SetFunctional sf = (SetFunctional) change;
			OWLOntology ont = sf.getOntology();
			OWLProperty prop = sf.getProperty();
			String isFunc = sf.isFunctional()? "true": "false";
			
			switch (function) {
				
			case CHANGE_DESCRIPTION : 
				isFunc = "Functional: " + isFunc;
				changeDesc += renderChange(
						"SET ATTRIBUTE",
						change,														
						"Ontology:", ont,
						"Property:", prop,
						"Attribute", isFunc,
						uris
						);
				return changeDesc;
				
			case CHANGE_RDFXML :
				List argList = new ArrayList();
				argList.add(ont);
				argList.add(prop);
				argList.add(String.valueOf(isFunc));
				return changeRenderer.addtoOWLAPIOntology("SetFunctional", argList);
				
			case CHANGE_INVERSE :
				return new SetFunctional(ont, prop, !sf.isFunctional(), null);
			
			case CHANGE_ALIGN :
				// align a change with an existing ontology from swoopModel
				try {
					return new SetFunctional(alignOnt, (OWLProperty) swoopModel.getEntity(alignOnt, prop.getURI(), true), sf.isFunctional(), null);
				}
				catch (OWLException ex) {
					ex.printStackTrace();
				}
			}	
		}
		else
		if (change instanceof SetInverseFunctional) {
			SetInverseFunctional sf = (SetInverseFunctional) change;
			OWLOntology ont = sf.getOntology();
			OWLProperty prop = sf.getProperty();
			String isIFunc = sf.isInverseFunctional()? "true": "false";
			
			switch (function) {
			
			case CHANGE_DESCRIPTION :
				isIFunc = "InverseFunctional: " + isIFunc;
				changeDesc += renderChange(
						"SET ATTRIBUTE",
						change,
						"Ontology:", ont,
						"Property:", prop,
						"Attribute", isIFunc,
						uris
						);
				return changeDesc;
			
			case CHANGE_RDFXML :
				List argList = new ArrayList();
				argList.add(ont);
				argList.add(prop);
				argList.add(String.valueOf(isIFunc));
				return changeRenderer.addtoOWLAPIOntology("SetInverseFunctional", argList);
				
			case CHANGE_INVERSE :
				return new SetInverseFunctional(ont, (OWLObjectProperty) prop, !sf.isInverseFunctional(), null);
			
			case CHANGE_ALIGN :
				// align a change with an existing ontology from swoopModel
				try {
					return new SetInverseFunctional(alignOnt, (OWLObjectProperty) swoopModel.getEntity(alignOnt, prop.getURI(), true), sf.isInverseFunctional(), null);
				}
				catch (OWLException ex) {
					ex.printStackTrace();
				}
			}
		}
		else
		if (change instanceof SetTransitive) {
			SetTransitive sf = (SetTransitive) change;
			OWLOntology ont = sf.getOntology();
			OWLProperty prop = sf.getProperty();
			String isTran = sf.isTransitive()? "true": "false";
			
			switch (function) {
			
			case CHANGE_DESCRIPTION :
				isTran = "Transitive: " + isTran;
				changeDesc += renderChange(
						"SET ATTRIBUTE",
						change,
						"Ontology:", ont,
						"Property:", prop,
						"Attribute", isTran,
						uris
						);
				return changeDesc;
			
			case CHANGE_RDFXML :
				List argList = new ArrayList();
				argList.add(ont);
				argList.add(prop);
				argList.add(String.valueOf(isTran));
				return changeRenderer.addtoOWLAPIOntology("SetTransitive", argList);
			
			case CHANGE_INVERSE :
				return new SetTransitive(ont, (OWLObjectProperty) prop, !sf.isTransitive(), null);
			
			case CHANGE_ALIGN :
				// align a change with an existing ontology from swoopModel
				try {
					return new SetFunctional(alignOnt, (OWLObjectProperty) swoopModel.getEntity(alignOnt, prop.getURI(), true), sf.isTransitive(), null);
				}
				catch (OWLException ex) {
					ex.printStackTrace();
				}
			}
		}
		else
		if (change instanceof SetSymmetric) {
			SetSymmetric sf = (SetSymmetric) change;
			OWLOntology ont = sf.getOntology();
			OWLProperty prop = sf.getProperty();
			String isSymm = sf.isSymmetric()? "true": "false";
			
			switch (function) {
			
			case CHANGE_DESCRIPTION :
				isSymm = "Symmetric: " + isSymm;
				changeDesc += renderChange(
						"SET ATTRIBUTE",
						change,
						"Ontology:", ont,
						"Property:", prop,
						"Attribute", isSymm,
						uris
						);
				return changeDesc;
				
			case CHANGE_RDFXML :
				List argList = new ArrayList();
				argList.add(ont);
				argList.add(prop);
				argList.add(String.valueOf(isSymm));
				return changeRenderer.addtoOWLAPIOntology("SetSymmetric", argList);
				 
			case CHANGE_INVERSE :
				return new SetSymmetric(ont, (OWLObjectProperty) prop, !sf.isSymmetric(), null);
			
			case CHANGE_ALIGN :
				// align a change with an existing ontology from swoopModel
				try {
					return new SetFunctional(alignOnt, (OWLObjectProperty) swoopModel.getEntity(alignOnt, prop.getURI(), true), sf.isSymmetric(), null);
				}
				catch (OWLException ex) {
					ex.printStackTrace();
				}
			}
		}
		else
		if (change instanceof AddAnnotationInstance) {
			AddAnnotationInstance aoi = (AddAnnotationInstance) change;
			OWLOntology ont = aoi.getOntology();
			OWLObject obj = aoi.getSubject();
			OWLAnnotationProperty prop = aoi.getProperty();
			Object content = aoi.getContent();
			
			switch (function) {
			
			case CHANGE_DESCRIPTION :
				try {
						// add uri of ontology to URI list
						uris.add(change.getOntology().getURI());
					} catch (OWLException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				
				changeDesc += renderChange(
						"ADD ANNOTATION",
						change,
						"OWL Object:", obj,
						"Annotation Property:", prop,
						"Content", content,
						uris
						);
				return changeDesc;
			
			case CHANGE_RDFXML :
				break;
			
			case CHANGE_INVERSE :
				return new RemoveAnnotationInstance(ont, obj, prop, aoi.getContent(), null);
			
			case CHANGE_ALIGN :
				// align a change with an existing ontology from swoopModel
				try {
					OWLObject eobj = null;
					if (obj instanceof OWLOntology) eobj = swoopModel.getOntology(((OWLOntology) obj).getURI());
					else if (obj instanceof OWLEntity) obj = swoopModel.getEntity(alignOnt, ((OWLEntity) obj).getURI(), true);
					return new AddAnnotationInstance(alignOnt, eobj, prop, aoi.getContent(), null);
				}
				catch (OWLException ex) {
					ex.printStackTrace();
				}
			}
		}
		else
		if (change instanceof RemoveAnnotationInstance) {
			RemoveAnnotationInstance aoi = (RemoveAnnotationInstance) change;
			OWLOntology ont = aoi.getOntology();
			OWLObject obj = aoi.getSubject();
			OWLAnnotationProperty prop = aoi.getProperty();
			Object content = aoi.getContent();
			
			switch (function) {
			
			case CHANGE_DESCRIPTION :
				try {
						// add uri of ontology to URI list
						uris.add(change.getOntology().getURI());
					} catch (OWLException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				
				changeDesc += renderChange(
						"REMOVE ANNOTATION",
						change,
						"OWL Object:", obj,
						"Annotation Property:", prop,
						"Content", content,
						uris
						);
				return changeDesc;
				
			case CHANGE_RDFXML :
				break;
				
			case CHANGE_INVERSE :
				return new AddAnnotationInstance(ont, obj, prop, aoi.getContent(), null);
			
			case CHANGE_ALIGN :
				// align a change with an existing ontology from swoopModel
				try {
					OWLObject eobj = null;
					if (obj instanceof OWLOntology) eobj = swoopModel.getOntology(((OWLOntology) obj).getURI());
					else if (obj instanceof OWLEntity) obj = swoopModel.getEntity(alignOnt, ((OWLEntity) obj).getURI(), true);
					return new RemoveAnnotationInstance(alignOnt, eobj, prop, aoi.getContent(), null);
				}
				catch (OWLException ex) {
					ex.printStackTrace();
				}
			}
		}
		else
		if (change instanceof AddImport) {
			
			AddImport add = (AddImport) change;
			OWLOntology ont = add.getOntology();
			OWLOntology impOnt = add.getImportOntology();
			
			switch (function) {
			
			case CHANGE_DESCRIPTION :			
				changeDesc += renderChange(
						"ADD IMPORT",
						change,
						"", null,
						"Ontology:", ont,
						"Imported Ontology:", impOnt,
						uris
						);
				return changeDesc;
				
			case CHANGE_RDFXML :
				List argList = new ArrayList();
				argList.add(ont);
				argList.add(impOnt);
				return changeRenderer.addtoOWLAPIOntology("AddImport", argList);
				
			case CHANGE_INVERSE :
				return new RemoveImport(ont, impOnt, null);
			
			case CHANGE_ALIGN :
				// align a change with an existing ontology from swoopModel
				try {
					OWLOntology eimpOnt = swoopModel.getOntology(impOnt.getURI());
					return new AddImport(alignOnt, eimpOnt, null);
				}
				catch (OWLException ex) {
					ex.printStackTrace();

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?