Search in sources :

Example 6 with ExporterFactory

use of org.hibernate.eclipse.console.model.impl.ExporterFactory in project jbosstools-hibernate by jbosstools.

the class ExporterSettingsTab method createControl.

/**
 * @see IDialogPage#createControl(Composite)
 */
public void createControl(Composite parent) {
    selectedExporters = new HashSet<ExporterFactory>();
    deletedExporterIds = new HashSet<String>();
    final ScrolledComposite sc = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
    sc.setExpandHorizontal(true);
    sc.setExpandVertical(true);
    Composite container = new Composite(sc, SWT.NONE);
    sc.setContent(container);
    GridData controlData = new GridData(GridData.FILL_BOTH);
    container.setLayoutData(controlData);
    GridLayout layout = new GridLayout();
    layout.marginHeight = 5;
    layout.marginWidth = 5;
    layout.verticalSpacing = 1;
    container.setLayout(layout);
    createGeneralSettings(container);
    createExporterTable(container);
    createExporterProperties(container);
    sc.setMinSize(container.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    dialogChanged();
    setControl(sc);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) UpDownListComposite(org.hibernate.eclipse.console.wizards.UpDownListComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ExporterFactory(org.hibernate.eclipse.console.model.impl.ExporterFactory) GridData(org.eclipse.swt.layout.GridData) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite)

Example 7 with ExporterFactory

use of org.hibernate.eclipse.console.model.impl.ExporterFactory in project jbosstools-hibernate by jbosstools.

the class ExporterSettingsTab method createOldExporterTable.

// currently unused functionality
@SuppressWarnings("unused")
private void createOldExporterTable(Composite parent) {
    Composite exporterOptions = createComposite(parent, HibernateConsoleMessages.ExporterSettingsTab_exporters);
    GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd.minimumHeight = 100;
    exporterOptions.setLayoutData(gd);
    exporterOptions.setLayout(new GridLayout(2, false));
    Table table = new Table(exporterOptions, SWT.CHECK | SWT.BORDER | SWT.V_SCROLL);
    // setExporterTable(new CheckboxTableViewer( table ));
    getExporterTable().setContentProvider(new ExporterContentProvider());
    getExporterTable().setLabelProvider(new ExporterLabelProvider());
    // exporterTable.getControl().setLayoutData(
    // new GridData( SWT.FILL, SWT.FILL, true, true ) );
    // $NON-NLS-1$
    getExporterTable().setColumnProperties(new String[] { "", HibernateConsoleMessages.ExporterSettingsTab_description });
    getExporterTable().addCheckStateListener(new ICheckStateListener() {

        public void checkStateChanged(CheckStateChangedEvent event) {
            ExporterFactory factory = (ExporterFactory) event.getElement();
            if (!event.getChecked() && selectedExporters.contains(factory)) {
                selectedExporters.remove(factory);
            } else if (event.getChecked() && !selectedExporters.contains(factory)) {
                selectedExporters.add(factory);
            }
            dialogChanged();
        }
    });
    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd.verticalSpan = 2;
    gd.horizontalSpan = 1;
    table.setLayoutData(gd);
    selectAll = new Button(exporterOptions, SWT.PUSH);
    selectAll.setText(HibernateConsoleMessages.ExporterSettingsTab_select_all);
    selectAll.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            getExporterTable().setAllChecked(true);
            dialogChanged();
        }
    });
    gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
    gd.horizontalIndent = 5;
    selectAll.setLayoutData(gd);
    deselectAll = new Button(exporterOptions, SWT.PUSH);
    deselectAll.setText(HibernateConsoleMessages.ExporterSettingsTab_deselect_all);
    deselectAll.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            getExporterTable().setAllChecked(false);
            dialogChanged();
        }
    });
    gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_BEGINNING);
    gd.horizontalIndent = 5;
    deselectAll.setLayoutData(gd);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) UpDownListComposite(org.hibernate.eclipse.console.wizards.UpDownListComposite) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) ExporterFactory(org.hibernate.eclipse.console.model.impl.ExporterFactory) Button(org.eclipse.swt.widgets.Button) ICheckStateListener(org.eclipse.jface.viewers.ICheckStateListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) CheckStateChangedEvent(org.eclipse.jface.viewers.CheckStateChangedEvent)

Example 8 with ExporterFactory

use of org.hibernate.eclipse.console.model.impl.ExporterFactory in project jbosstools-hibernate by jbosstools.

the class CodeGenXMLFactory method createRoot.

@SuppressWarnings("unchecked")
protected Element createRoot() {
    ExporterAttributes attributes = null;
    try {
        attributes = new ExporterAttributes(lc);
    } catch (CoreException e) {
    // ignore
    }
    if (attributes == null) {
        return null;
    }
    Properties props = new Properties();
    if (attributes.isReverseEngineer()) {
        props.setProperty(ConfigurationXMLStrings.ISREVENG, Boolean.toString(attributes.isReverseEngineer()));
        props.setProperty(ConfigurationXMLStrings.PACKAGENAME, attributes.getPackageName());
        props.setProperty(ConfigurationXMLStrings.PREFERBASICCOMPOSITEIDS, Boolean.toString(attributes.isPreferBasicCompositeIds()));
        props.setProperty(ConfigurationXMLStrings.DETECTMANYTOMANY, Boolean.toString(attributes.detectManyToMany()));
        props.setProperty(ConfigurationXMLStrings.DETECTONTTOONE, Boolean.toString(attributes.detectOneToOne()));
        props.setProperty(ConfigurationXMLStrings.DETECTOPTIMISTICLOCK, Boolean.toString(attributes.detectOptimisticLock()));
        props.setProperty(ConfigurationXMLStrings.REVERSESTRATEGY, attributes.getRevengStrategy());
        String revEngFile = getResLocation(attributes.getRevengSettings());
        props.setProperty(ConfigurationXMLStrings.REVENGFILE, revEngFile);
    }
    // 
    final IPath pathPlace2Generate = isEmpty(place2Generate) ? null : new Path(getResLocation(place2Generate));
    final IPath pathWorkspacePath = isEmpty(workspacePath) ? null : new Path(getResLocation(workspacePath));
    // 
    String consoleConfigName = attributes.getConsoleConfigurationName();
    ConsoleConfigurationPreferences consoleConfigPrefs = getConsoleConfigPreferences(consoleConfigName);
    final ConfigurationXMLFactory configurationXMLFactory = new ConfigurationXMLFactory(consoleConfigPrefs, props);
    configurationXMLFactory.setPlace2Generate(pathPlace2Generate);
    configurationXMLFactory.setWorkspacePath(pathWorkspacePath);
    Element rootConsoleConfig = configurationXMLFactory.createRoot();
    // 
    // $NON-NLS-1$
    String defaultTargetName = "hibernateAntCodeGeneration";
    Element el, root = DocumentFactory.getInstance().createElement(CodeGenerationStrings.PROJECT);
    // $NON-NLS-1$
    root.addAttribute(CodeGenerationStrings.NAME, "CodeGen");
    root.addAttribute(CodeGenerationStrings.DEFAULT, defaultTargetName);
    // 
    if (!isEmpty(place2Generate)) {
        el = root.addElement(CodeGenerationStrings.PROPERTY);
        el.addAttribute(CodeGenerationStrings.NAME, varCurrentDir);
        el.addAttribute(CodeGenerationStrings.LOCATION, getPlace2GenerateUID());
    }
    if (!isEmpty(workspacePath)) {
        el = root.addElement(CodeGenerationStrings.PROPERTY);
        el.addAttribute(CodeGenerationStrings.NAME, varWorkspaceDir);
        el.addAttribute(CodeGenerationStrings.LOCATION, getWorkspacePathUID());
    }
    // 
    String location = getResLocation(attributes.getOutputPath());
    location = ConfigurationXMLFactory.makePathRelative(location, pathPlace2Generate, pathWorkspacePath);
    el = root.addElement(CodeGenerationStrings.PROPERTY);
    el.addAttribute(CodeGenerationStrings.NAME, varBuildDir);
    el.addAttribute(CodeGenerationStrings.LOCATION, location);
    // 
    String hibernatePropFile = null;
    String generateHibernatePropeties = null;
    String connProfileName = consoleConfigPrefs == null ? null : consoleConfigPrefs.getConnectionProfileName();
    IConnectionProfile profile = getConnectionProfile(connProfileName);
    boolean bPropFile = profile != null;
    // update property with fake tm
    Properties propsTmp = null;
    String[] versions = ServiceLookup.getVersions();
    String maxVersion = versions[versions.length - 1];
    String hibernateVersion = consoleConfigPrefs == null ? maxVersion : consoleConfigPrefs.getHibernateVersion();
    IService service = ServiceLookup.findService(hibernateVersion);
    IEnvironment environment = service.getEnvironment();
    if (consoleConfigPrefs != null && consoleConfigPrefs.getPropertyFile() != null) {
        propsTmp = consoleConfigPrefs.getProperties();
        String tmStrategy = propsTmp.getProperty(environment.getTransactionManagerStrategy());
        if (tmStrategy != null && StringHelper.isEmpty(tmStrategy)) {
            propsTmp.setProperty(environment.getTransactionManagerStrategy(), ConfigurationFactory.FAKE_TM_LOOKUP);
            bPropFile = true;
        }
    }
    if (bPropFile) {
        Set<String> specialProps = new TreeSet<String>();
        specialProps.add(environment.getDriver());
        specialProps.add(environment.getURL());
        specialProps.add(environment.getUser());
        specialProps.add(environment.getPass());
        specialProps.add(environment.getDialect());
        // 
        if (propsTmp == null) {
            propsTmp = new Properties();
        }
        StringBuilder propFileContent = new StringBuilder();
        String driverClass = getDriverClass(connProfileName);
        if (profile != null) {
            final Properties cpProperties = profile.getProperties(profile.getProviderId());
            // 
            String url = cpProperties.getProperty(IJDBCDriverDefinitionConstants.URL_PROP_ID);
            // 
            String user = cpProperties.getProperty(IJDBCDriverDefinitionConstants.USERNAME_PROP_ID);
            // 
            String pass = cpProperties.getProperty(IJDBCDriverDefinitionConstants.PASSWORD_PROP_ID);
            // 
            String dialectName = consoleConfigPrefs.getDialectName();
            // 
            propsTmp.setProperty(environment.getDriver(), driverClass);
            propsTmp.setProperty(environment.getURL(), url);
            propsTmp.setProperty(environment.getUser(), user);
            propsTmp.setProperty(environment.getPass(), pass);
            if (StringHelper.isNotEmpty(dialectName)) {
                propsTmp.setProperty(environment.getDialect(), dialectName);
            }
        }
        // output keys in sort order
        Object[] keys = propsTmp.keySet().toArray();
        Arrays.sort(keys);
        // 
        if (externalPropFile) {
            for (Object obj : keys) {
                addIntoPropFileContent(propFileContent, obj.toString(), propsTmp.getProperty(obj.toString()));
            }
        } else {
            for (Object obj : keys) {
                if (specialProps.contains(obj)) {
                    el = root.addElement(CodeGenerationStrings.PROPERTY);
                    el.addAttribute(CodeGenerationStrings.NAME, obj.toString());
                    el.addAttribute(CodeGenerationStrings.VALUE, propsTmp.getProperty(obj.toString()));
                    addIntoPropFileContent(propFileContent, obj.toString());
                } else {
                    addIntoPropFileContent(propFileContent, obj.toString(), propsTmp.getProperty(obj.toString()));
                }
            }
        }
        if (externalPropFile) {
            hibernatePropFile = externalPropFileName;
        } else {
            // $NON-NLS-1$
            hibernatePropFile = "hibernatePropFile";
            el = root.addElement(CodeGenerationStrings.PROPERTY);
            el.addAttribute(CodeGenerationStrings.NAME, hibernatePropFile);
            // $NON-NLS-1$
            el.addAttribute(CodeGenerationStrings.VALUE, "${java.io.tmpdir}${ant.project.name}-hibernate.properties");
            // 
            // $NON-NLS-1$
            generateHibernatePropeties = "generateHibernatePropeties";
            Element target = root.addElement(CodeGenerationStrings.TARGET);
            target.addAttribute(CodeGenerationStrings.NAME, generateHibernatePropeties);
            // 
            hibernatePropFile = getVar(hibernatePropFile);
            Element echo = target.addElement(CodeGenerationStrings.ECHO);
            echo.addAttribute(CodeGenerationStrings.FILE, hibernatePropFile);
            echo.addText(getPropFileContentStubUID());
        }
        propFileContentPreSave = propFileContent.toString().trim();
    }
    // all jars from libraries should be here
    // $NON-NLS-1$
    String toolslibID = "toolslib";
    Element toolslib = root.addElement(CodeGenerationStrings.PATH);
    toolslib.addAttribute(CodeGenerationStrings.ID, toolslibID);
    final URL[] customClassPathURLs = PreferencesClassPathUtils.getCustomClassPathURLs(consoleConfigPrefs);
    for (int i = 0; i < customClassPathURLs.length; i++) {
        if (customClassPathURLs[i] == null) {
            continue;
        }
        // what is right here: CodeGenerationStrings.PATH or CodeGenerationStrings.PATHELEMENT?
        // http://www.redhat.com/docs/en-US/JBoss_Developer_Studio/en/hibernatetools/html/ant.html
        // use CodeGenerationStrings.PATH - so may be error in documentation?
        Element pathItem = toolslib.addElement(CodeGenerationStrings.PATH);
        // Element pathItem = toolslib.addElement(CodeGenerationStrings.PATHELEMENT);
        String strPathItem = customClassPathURLs[i].getPath();
        try {
            strPathItem = (new java.io.File(customClassPathURLs[i].toURI())).getPath();
        } catch (URISyntaxException e) {
        // ignore
        }
        strPathItem = new Path(strPathItem).toString();
        strPathItem = ConfigurationXMLFactory.makePathRelative(strPathItem, pathPlace2Generate, pathWorkspacePath);
        pathItem.addAttribute(CodeGenerationStrings.LOCATION, strPathItem);
    }
    // 
    Element target = root.addElement(CodeGenerationStrings.TARGET);
    target.addAttribute(CodeGenerationStrings.NAME, defaultTargetName);
    if (!isEmpty(generateHibernatePropeties)) {
        target.addAttribute(CodeGenerationStrings.DEPENDS, generateHibernatePropeties);
    }
    // 
    Element taskdef = target.addElement(CodeGenerationStrings.TASKDEF);
    taskdef.addAttribute(CodeGenerationStrings.NAME, CodeGenerationStrings.HIBERNATETOOL);
    // $NON-NLS-1$
    taskdef.addAttribute(CodeGenerationStrings.CLASSNAME, "org.hibernate.tool.ant.HibernateToolTask");
    taskdef.addAttribute(CodeGenerationStrings.CLASSPATHREF, toolslibID);
    // 
    Element hibernatetool = target.addElement(CodeGenerationStrings.HIBERNATETOOL);
    hibernatetool.addAttribute(CodeGenerationStrings.DESTDIR, getVar(varBuildDir));
    if (attributes.isUseOwnTemplates()) {
        String templatePath = getResLocation(attributes.getTemplatePath());
        hibernatetool.addAttribute(CodeGenerationStrings.TEMPLATEPATH, templatePath);
    }
    if (rootConsoleConfig != null) {
        if (StringHelper.isNotEmpty(hibernatePropFile)) {
            rootConsoleConfig.addAttribute(ConfigurationXMLStrings.PROPERTYFILE, hibernatePropFile);
        }
        // add hibernate console configuration
        hibernatetool.content().add(rootConsoleConfig);
    }
    // 
    // the path there are user classes
    Element classpath = hibernatetool.addElement(CodeGenerationStrings.CLASSPATH);
    Element path = classpath.addElement(CodeGenerationStrings.PATH);
    path.addAttribute(CodeGenerationStrings.LOCATION, getVar(varBuildDir));
    // 
    Map<String, Map<String, AttributeDescription>> exportersDescr = ExportersXMLAttributeDescription.getExportersDescription();
    Map<String, Set<String>> exportersSetSubTags = ExportersXMLAttributeDescription.getExportersSetSubTags();
    // 
    Properties globalProps = new Properties();
    // obligatory global properties
    // $NON-NLS-1$
    globalProps.put(CodeGenerationStrings.EJB3, "" + attributes.isEJB3Enabled());
    // $NON-NLS-1$
    globalProps.put(CodeGenerationStrings.JDK5, "" + attributes.isJDK5Enabled());
    List<ExporterFactory> exporterFactories = attributes.getExporterFactories();
    for (Iterator<ExporterFactory> iter = exporterFactories.iterator(); iter.hasNext(); ) {
        ExporterFactory ef = iter.next();
        if (!ef.isEnabled(lc)) {
            continue;
        }
        // Map<String, ExporterProperty> defExpProps = ef.getDefaultExporterProperties();
        // String expId = ef.getId();
        String expDefId = ef.getExporterDefinitionId();
        String expName = ef.getExporterTag();
        // mapping: guiName -> AttributeDescription
        Map<String, AttributeDescription> attributesDescrGui = exportersDescr.get(expName);
        if (attributesDescrGui == null) {
            attributesDescrGui = new TreeMap<String, AttributeDescription>();
        }
        // mapping: guiName -> set of sub tags
        Set<String> setSubTags = exportersSetSubTags.get(expName);
        if (setSubTags == null) {
            setSubTags = new TreeSet<String>();
        }
        // construct new mapping: name -> AttributeDescription
        Map<String, AttributeDescription> attributesDescrAnt = new TreeMap<String, AttributeDescription>();
        for (AttributeDescription ad : attributesDescrGui.values()) {
            attributesDescrAnt.put(ad.name, ad);
        }
        // 
        Element exporter = hibernatetool.addElement(expName);
        Properties expProps = new Properties();
        expProps.putAll(globalProps);
        expProps.putAll(ef.getProperties());
        // 
        Properties extractGUISpecial = new Properties();
        try {
            ExporterFactory.extractExporterProperties(expDefId, expProps, extractGUISpecial);
        } catch (CoreException e) {
        // ignore
        }
        // convert gui special properties names into Ant names
        for (Map.Entry<Object, Object> propEntry : extractGUISpecial.entrySet()) {
            Object key = propEntry.getKey();
            Object val = propEntry.getValue();
            AttributeDescription ad = attributesDescrGui.get(key);
            if (ad == null) {
                expProps.put(key, val);
                continue;
            }
            expProps.put(ad.name, val);
        }
        // to add attributes and properties in alphabetic order
        Map<String, Object> expPropsSorted = new TreeMap<String, Object>();
        for (Map.Entry<Object, Object> propEntry : expProps.entrySet()) {
            Object key = propEntry.getKey();
            Object val = propEntry.getValue();
            expPropsSorted.put(key.toString(), val);
        }
        // list2Remove - list to collect properties which put into attributes,
        // all other properties be ordinal property definition
        List<Object> list2Remove = new ArrayList<Object>();
        for (Map.Entry<String, Object> propEntry : expPropsSorted.entrySet()) {
            Object key = propEntry.getKey();
            Object val = propEntry.getValue();
            AttributeDescription ad = attributesDescrAnt.get(key);
            if (ad == null) {
                continue;
            }
            list2Remove.add(key);
            if (val == null || 0 == val.toString().compareTo(ad.defaultValue)) {
                continue;
            }
            String processedVal = processPropertyValue(val);
            if (setSubTags.contains(ad.guiName)) {
                Element subTag = exporter.addElement(ad.name);
                subTag.addText(processedVal);
            } else {
                exporter.addAttribute(ad.name, processedVal);
            }
        }
        for (Object obj : list2Remove) {
            expProps.remove(obj);
            expPropsSorted.remove(obj);
        }
        for (Map.Entry<String, Object> propEntry : expPropsSorted.entrySet()) {
            Object key = propEntry.getKey();
            Object val = propEntry.getValue();
            String processedVal = processPropertyValue(val);
            Element property = exporter.addElement(CodeGenerationStrings.PROPERTY);
            property.addAttribute(CodeGenerationStrings.KEY, key.toString());
            property.addAttribute(CodeGenerationStrings.VALUE, processedVal);
        }
    }
    return root;
}
Also used : TreeSet(java.util.TreeSet) Set(java.util.Set) Element(org.dom4j.Element) ArrayList(java.util.ArrayList) URISyntaxException(java.net.URISyntaxException) Properties(java.util.Properties) URL(java.net.URL) TreeSet(java.util.TreeSet) IConnectionProfile(org.eclipse.datatools.connectivity.IConnectionProfile) IService(org.jboss.tools.hibernate.runtime.spi.IService) IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IPath(org.eclipse.core.runtime.IPath) TreeMap(java.util.TreeMap) AttributeDescription(org.hibernate.eclipse.launch.ExportersXMLAttributeDescription.AttributeDescription) CoreException(org.eclipse.core.runtime.CoreException) ConsoleConfigurationPreferences(org.hibernate.console.preferences.ConsoleConfigurationPreferences) ExporterFactory(org.hibernate.eclipse.console.model.impl.ExporterFactory) IEnvironment(org.jboss.tools.hibernate.runtime.spi.IEnvironment) ConfigurationXMLFactory(org.hibernate.console.ConfigurationXMLFactory) Map(java.util.Map) TreeMap(java.util.TreeMap)

Example 9 with ExporterFactory

use of org.hibernate.eclipse.console.model.impl.ExporterFactory in project jbosstools-hibernate by jbosstools.

the class CodeGenerationLaunchDelegate method preLaunchCheck.

public boolean preLaunchCheck(ILaunchConfiguration configuration, String mode, IProgressMonitor monitor) throws CoreException {
    ExporterAttributes attributes = new ExporterAttributes(configuration);
    String configName = attributes.getConsoleConfigurationName();
    if (StringHelper.isEmpty(configName)) {
        abort(HibernateConsoleMessages.CodeGenerationLaunchDelegate_console_configuration_name_is_empty_in + configuration.getName(), null, ICodeGenerationLaunchConstants.ERR_UNSPECIFIED_CONSOLE_CONFIGURATION);
    }
    if (KnownConfigurations.getInstance().find(configName) == null) {
        String out = NLS.bind(HibernateConsoleMessages.CodeGenerationLaunchDelegate_console_configuration_not_found_in, configName, configuration.getName());
        abort(out, null, ICodeGenerationLaunchConstants.ERR_CONSOLE_CONFIGURATION_NOTFOUND);
    }
    if (StringHelper.isEmpty(attributes.getOutputPath())) {
        abort(HibernateConsoleMessages.CodeGenerationLaunchDelegate_output_has_to_be_specified_in + configuration.getName(), null, ICodeGenerationLaunchConstants.ERR_OUTPUT_PATH_NOTFOUND);
    }
    List<ExporterFactory> exporterFactories = attributes.getExporterFactories();
    for (Iterator<ExporterFactory> iter = exporterFactories.iterator(); iter.hasNext(); ) {
        ExporterFactory exFactory = iter.next();
        if (exFactory.isEnabled(configuration) && exFactory.getExporterDefinitionId().equals("org.hibernate.tools.query")) {
            // $NON-NLS-1$
            if (!exFactory.getProperties().containsKey("query_string")) {
                // $NON-NLS-1$
                // $NON-NLS-1$
                abort("Query property should be explicitly set for Query Exporter", null, ICodeGenerationLaunchConstants.ERR_OUTPUT_PATH_NOTFOUND);
            }
        }
    }
    return super.preLaunchCheck(configuration, mode, monitor);
}
Also used : ExporterFactory(org.hibernate.eclipse.console.model.impl.ExporterFactory)

Example 10 with ExporterFactory

use of org.hibernate.eclipse.console.model.impl.ExporterFactory in project jbosstools-hibernate by jbosstools.

the class ExporterSettingsTab method initializeFrom.

public void initializeFrom(ILaunchConfiguration configuration) {
    try {
        ExporterAttributes attributes = new ExporterAttributes(configuration);
        selectedExporters.clear();
        enableEJB3annotations.setSelection(attributes.isEJB3Enabled());
        enableJDK5.setSelection(attributes.isJDK5Enabled());
        List<ExporterFactory> exporterFactories = attributes.getExporterFactories();
        observableFactoryList = new ObservableFactoryList(exporterFactories);
        getExporterTable().setInput(observableFactoryList);
        for (ExporterFactory exporterFactory : exporterFactories) {
            if (exporterFactory.isEnabled()) {
                getExporterTable().setChecked(exporterFactory, true);
                selectedExporters.add(exporterFactory);
            } else {
                getExporterTable().setChecked(exporterFactory, false);
            }
        }
        refreshPropertySheet();
        dialogChanged();
    } catch (CoreException ce) {
        HibernateConsolePlugin.getDefault().logErrorMessage(HibernateConsoleMessages.ExporterSettingsTab_problem_when_reading_hibernate_tools_launch_configuration, ce);
    }
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) ExporterFactory(org.hibernate.eclipse.console.model.impl.ExporterFactory)

Aggregations

ExporterFactory (org.hibernate.eclipse.console.model.impl.ExporterFactory)16 ArrayList (java.util.ArrayList)4 CoreException (org.eclipse.core.runtime.CoreException)4 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 SelectionEvent (org.eclipse.swt.events.SelectionEvent)4 GridData (org.eclipse.swt.layout.GridData)4 UpDownListComposite (org.hibernate.eclipse.console.wizards.UpDownListComposite)4 HashMap (java.util.HashMap)3 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 Composite (org.eclipse.swt.widgets.Composite)3 HashSet (java.util.HashSet)2 Iterator (java.util.Iterator)2 Map (java.util.Map)2 Properties (java.util.Properties)2 IPath (org.eclipse.core.runtime.IPath)2 CheckStateChangedEvent (org.eclipse.jface.viewers.CheckStateChangedEvent)2 ICheckStateListener (org.eclipse.jface.viewers.ICheckStateListener)2 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)2 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)2