Search in sources :

Example 6 with ConsoleConfiguration

use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.

the class NewJavaFilesListener method cleanup.

private void cleanup(Job job) {
    job.removeJobChangeListener(jobChangeListener);
    ConsoleConfiguration configuration = KnownConfigurations.getInstance().find(temporaryConfigurationName);
    if (configuration != null) {
        KnownConfigurations.getInstance().removeConfiguration(configuration, false);
    }
    temporaryConfigurationName = null;
}
Also used : ConsoleConfiguration(org.hibernate.console.ConsoleConfiguration)

Example 7 with ConsoleConfiguration

use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.

the class ElementsFactory method getConfig.

public IConfiguration getConfig() {
    IConfiguration config = null;
    final ConsoleConfiguration consoleConfig = getConsoleConfig();
    if (consoleConfig != null) {
        config = consoleConfig.getConfiguration();
    }
    return config;
}
Also used : ConsoleConfiguration(org.hibernate.console.ConsoleConfiguration) IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration)

Example 8 with ConsoleConfiguration

use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.

the class OrmDiagram method loadState.

@Override
public void loadState(IMemento memento) {
    super.loadState(memento);
    // $NON-NLS-1$ //$NON-NLS-2$
    consoleConfigName = getPrValue(memento, "consoleConfig_name", "");
    @SuppressWarnings("unused") ConsoleConfiguration consoleConfig = getConsoleConfig();
    labelProvider.setConsoleConfigName(consoleConfigName);
    // $NON-NLS-1$
    int size = getPrValue(memento, "entityNames_size", 0);
    roots.clear();
    entityNames.clear();
    for (int i = 0; i < size; i++) {
        roots.add(null);
        // $NON-NLS-1$ //$NON-NLS-2$
        entityNames.add(getPrValue(memento, "entityNames_" + Integer.toString(i), ""));
    }
    // $NON-NLS-1$
    rulersVisibility = getPrValue(memento, "rulersVisibility", false);
    // $NON-NLS-1$
    snapToGeometry = getPrValue(memento, "snapToGeometry", false);
    // $NON-NLS-1$
    gridEnabled = getPrValue(memento, "gridEnabled", false);
    // $NON-NLS-1$
    zoom = getPrValue(memento, "zoom", 1.0);
    // $NON-NLS-1$
    deepIntoSort = getPrValue(memento, "deepIntoSort", false);
    // $NON-NLS-1$
    flagManhattanConnectionRouter = getPrValue(memento, "flagManhattanConnectionRouter", true);
    // $NON-NLS-1$
    connectionsVisibilityAssociation = getPrValue(memento, "connectionsVisibilityAssociation", true);
    // $NON-NLS-1$
    connectionsVisibilityClassMapping = getPrValue(memento, "connectionsVisibilityClassMapping", true);
    // $NON-NLS-1$
    connectionsVisibilityForeignKeyConstraint = getPrValue(memento, "connectionsVisibilityForeignKeyConstraint", true);
    // $NON-NLS-1$
    connectionsVisibilityPropertyMapping = getPrValue(memento, "connectionsVisibilityPropertyMapping", true);
    refreshRootsFromNames();
}
Also used : ConsoleConfiguration(org.hibernate.console.ConsoleConfiguration) Point(org.eclipse.draw2d.geometry.Point)

Example 9 with ConsoleConfiguration

use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.

the class OpenDiagramActionDelegate method run.

public void run(IAction action) {
    ObjectPluginAction objectPluginAction = (ObjectPluginAction) action;
    Map<ConsoleConfiguration, Set<IPersistentClass>> mapCC_PCs = new HashMap<ConsoleConfiguration, Set<IPersistentClass>>();
    TreePath[] paths = ((TreeSelection) objectPluginAction.getSelection()).getPaths();
    for (int i = 0; i < paths.length; i++) {
        final Object firstSegment = paths[i].getFirstSegment();
        if (!(firstSegment instanceof ConsoleConfiguration)) {
            continue;
        }
        final ConsoleConfiguration consoleConfig = (ConsoleConfiguration) (firstSegment);
        Set<IPersistentClass> setPC = mapCC_PCs.get(consoleConfig);
        if (null == setPC) {
            setPC = new HashSet<IPersistentClass>();
            mapCC_PCs.put(consoleConfig, setPC);
        }
        Object last_el = paths[i].getLastSegment();
        if (last_el instanceof IPersistentClass) {
            IPersistentClass persClass = (IPersistentClass) last_el;
            setPC.add(persClass);
        } else if (last_el instanceof IConfiguration) {
            IConfiguration config = (IConfiguration) last_el;
            Iterator<IPersistentClass> it = config.getClassMappings();
            while (it.hasNext()) {
                setPC.add(it.next());
            }
        } else if (last_el instanceof ConsoleConfiguration) {
            IConfiguration config = consoleConfig.getConfiguration();
            if (config == null) {
                try {
                    consoleConfig.build();
                } catch (Exception he) {
                    HibernateConsolePlugin.getDefault().showError(HibernateConsolePlugin.getShell(), DiagramViewerMessages.OpenDiagramActionDelegate_could_not_load_configuration + ' ' + consoleConfig.getName(), he);
                }
                if (consoleConfig.hasConfiguration()) {
                    consoleConfig.buildMappings();
                }
                config = consoleConfig.getConfiguration();
            }
            if (config != null) {
                Iterator<IPersistentClass> it = config.getClassMappings();
                while (it.hasNext()) {
                    setPC.add(it.next());
                }
            }
        }
    }
    for (Iterator<ConsoleConfiguration> it = mapCC_PCs.keySet().iterator(); it.hasNext(); ) {
        ConsoleConfiguration consoleConfiguration = it.next();
        Set<IPersistentClass> setPC = mapCC_PCs.get(consoleConfiguration);
        try {
            openEditor(setPC, consoleConfiguration);
        } catch (PartInitException e) {
            // $NON-NLS-1$
            HibernateConsolePlugin.getDefault().logErrorMessage("Can't open mapping view.", e);
        }
    }
}
Also used : ConsoleConfiguration(org.hibernate.console.ConsoleConfiguration) Set(java.util.Set) HashSet(java.util.HashSet) HashMap(java.util.HashMap) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass) PartInitException(org.eclipse.ui.PartInitException) ObjectPluginAction(org.eclipse.ui.internal.ObjectPluginAction) TreePath(org.eclipse.jface.viewers.TreePath) TreeSelection(org.eclipse.jface.viewers.TreeSelection) Iterator(java.util.Iterator) PartInitException(org.eclipse.ui.PartInitException) IConfiguration(org.jboss.tools.hibernate.runtime.spi.IConfiguration)

Example 10 with ConsoleConfiguration

use of org.hibernate.console.ConsoleConfiguration in project jbosstools-hibernate by jbosstools.

the class OrmLabelProvider method setConsoleConfigName.

public void setConsoleConfigName(String consoleConfigName) {
    if (this.consoleConfigName == consoleConfigName) {
        return;
    }
    this.consoleConfigName = consoleConfigName;
    final ConsoleConfiguration consoleConfig = getConsoleConfig();
    // TODO verify if/how this can be done differently
    if (consoleConfig != null && "4.3".equals(consoleConfig.getHibernateExtension().getHibernateVersion())) {
        getConsoleConfig().execute(new ExecutionContext.Command() {

            @Override
            public Object execute() {
                return getConfig().buildSessionFactory();
            }
        });
    }
}
Also used : ConsoleConfiguration(org.hibernate.console.ConsoleConfiguration) ExecutionContext(org.hibernate.console.execution.ExecutionContext)

Aggregations

ConsoleConfiguration (org.hibernate.console.ConsoleConfiguration)107 IPersistentClass (org.jboss.tools.hibernate.runtime.spi.IPersistentClass)19 IConfiguration (org.jboss.tools.hibernate.runtime.spi.IConfiguration)17 CoreException (org.eclipse.core.runtime.CoreException)16 PartInitException (org.eclipse.ui.PartInitException)13 IProperty (org.jboss.tools.hibernate.runtime.spi.IProperty)12 KnownConfigurations (org.hibernate.console.KnownConfigurations)11 JavaModelException (org.eclipse.jdt.core.JavaModelException)10 TreePath (org.eclipse.jface.viewers.TreePath)10 Test (org.junit.Test)10 File (java.io.File)9 ArrayList (java.util.ArrayList)9 FileNotFoundException (java.io.FileNotFoundException)8 IPath (org.eclipse.core.runtime.IPath)8 TreeSelection (org.eclipse.jface.viewers.TreeSelection)8 IService (org.jboss.tools.hibernate.runtime.spi.IService)8 ITreeSelection (org.eclipse.jface.viewers.ITreeSelection)7 IEditorPart (org.eclipse.ui.IEditorPart)7 ConsoleConfigurationPreferences (org.hibernate.console.preferences.ConsoleConfigurationPreferences)7 GridLayout (org.eclipse.swt.layout.GridLayout)6