Skip to content

Instantly share code, notes, and snippets.

View pvlasov's full-sized avatar

Pavel Vlasov pvlasov

View GitHub Profile
@pvlasov
pvlasov / YamlResource.java
Created January 7, 2019 16:16
Demonstrates how to create an EMF resource loading/storing (configuration) model from/to YAML files. It can be used for creating configuration editors for Spring applications, e.g. microservices.
// --- Resource ---
public class YamlResourceImpl extends ResourceImpl {
private Map<String, Object> data;
public YamlResourceImpl(URI uri) {
super(uri);
}
@SuppressWarnings("unchecked")
@pvlasov
pvlasov / CollectConcreteSubclasses.java
Created January 6, 2019 11:37
Collecting and instantiating concrete subclasses of a specified base class. Can be used to collect children for a reference in emf-based editor
/**
* Iterates over registered ecore packages. Collects and instantiates concrete subclasses.
* @return
*/
public static List<MyType> collectMyTypes() {
List<MyType> ret = new ArrayList<>();
IExtensionRegistry registry = RegistryFactory.getRegistry();
if (registry != null) {
IConfigurationElement[] configElems = registry.getConfigurationElementsFor("org.eclipse.emf.ecore.generated_package");
for (IConfigurationElement elem : configElems) {
@pvlasov
pvlasov / mirror-oxygen.bat
Created January 26, 2018 17:00
Mirroring of Eclipse repos
eclipsec.exe -application org.eclipse.equinox.p2.metadata.repository.mirrorApplication -source http://download.eclipse.org/releases/oxygen -destination C:\oxygen-repository
eclipsec.exe -application org.eclipse.equinox.p2.artifact.repository.mirrorApplication -source http://download.eclipse.org/releases/oxygen -destination C:\oxygen-repository
@pvlasov
pvlasov / cdo-emf-model-annotations.md
Last active October 1, 2017 02:57
CDO EMF model annotations
$(function(){
$("<element selector>").contextmenu(function(e) {
var jsTree = $('<jstree selector>').jstree();
var obj = jsTree.get_node(<node id>);
jsTree.show_contextmenu(obj, e.pageX, e.pageY, e);
return false;
});
});
@pvlasov
pvlasov / JavaCallGraphToGexf.java
Created May 10, 2017 17:20
Call graph visualization with Gephi
/*
Dependencies:
- Java Call Graph - https://github.com/gousiosg/java-callgraph.
- Gexf4j - https://github.com/francesco-ficarola/gexf4j (download all dependencies with mvn dependency:copy-dependencies)
*/
import java.io.BufferedReader;
import java.io.File;
@pvlasov
pvlasov / mantisbt_ntlm.md
Last active March 2, 2018 23:27
Setting MantisBT behind Apache with NTML

This is a hack. Unfortunately I could not find a description of how to put MantisBT behind Apache with NTLM auth.

Set authentication to BASIC_AUTH in config/config_inc.php:

$g_login_method           = BASIC_AUTH;

core/authentication_api.php - comment out lines 289-291 to disable password check:

@pvlasov
pvlasov / SetPasswordAction.java
Created March 29, 2017 21:28
Action for initial model editor to set user password
// For action bar contributor integration see https://github.com/Nasdanika/ledger/blob/19c84bcb07d83b07ffa13761d4df352ef422f223/org.nasdanika.ledger.editor/src/org/nasdanika/ledger/presentation/LedgerActionBarContributor.java
import java.util.ArrayList;
import java.util.Iterator;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.transaction.RecordingCommand;
@pvlasov
pvlasov / ModelSessionInitializer.java
Created March 29, 2017 19:08
Loading of initial model to a new resource in a session initializer
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.common.id.CDOIDUtil;
import org.eclipse.emf.cdo.common.model.CDOPackageRegistry;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.session.CDOSession;