Search in sources :

Example 41 with ConsoleConfiguration

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

the class HibernatePropertyPage method addSecondSection.

private void addSecondSection(Composite parent) {
    // Label for owner field
    Label ownerLabel = new Label(parent, SWT.NONE);
    ownerLabel.setText(HibernateConsoleMessages.HibernatePropertyPage_default_hibernate_console_config);
    Composite settingsPart = createDefaultComposite(parent, 2);
    selectedConfiguration = new Combo(settingsPart, SWT.DROP_DOWN | SWT.READ_ONLY);
    GridData gd = new GridData();
    gd.widthHint = convertWidthInCharsToPixels(50);
    selectedConfiguration.setLayoutData(gd);
    selectedConfiguration.add(NONE);
    // Populate owner text field
    ConsoleConfiguration[] configurations = LaunchHelper.findFilteredSortedConsoleConfigs();
    for (int i = 0; i < configurations.length; i++) {
        ConsoleConfiguration configuration = configurations[i];
        selectedConfiguration.add(configuration.getName());
    }
    details = new Link(settingsPart, SWT.NONE);
    details.setText(HibernateConsoleMessages.HibernatePropertyPage_details);
    details.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            ConsoleConfiguration config = KnownConfigurations.getInstance().find(selectedConfiguration.getText());
            if (config != null) {
                new EditConsoleConfiguration(config).run();
            }
        }
    });
    selectedConfiguration.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            details.setEnabled(selectedConfiguration.getSelectionIndex() != 0);
        }
    });
    Composite settingsPart2 = createDefaultComposite(parent, 2);
    enableNamingStrategy = new Button(settingsPart2, SWT.CHECK);
    enableNamingStrategy.setText(HibernateConsoleMessages.HibernatePropertyPage_use_naming_strategy);
    enableNamingStrategy.setSelection(initNamingStrategy);
    settings = new Control[] { ownerLabel, selectedConfiguration, details, enableNamingStrategy };
}
Also used : EditConsoleConfiguration(org.hibernate.eclipse.console.actions.EditConsoleConfiguration) ConsoleConfiguration(org.hibernate.console.ConsoleConfiguration) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) EditConsoleConfiguration(org.hibernate.eclipse.console.actions.EditConsoleConfiguration) Combo(org.eclipse.swt.widgets.Combo) Link(org.eclipse.swt.widgets.Link)

Example 42 with ConsoleConfiguration

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

the class OpenQueryEditorAction method doRun.

protected boolean doRun(TreePath[] paths) {
    boolean showed = false;
    for (int i = 0; i < paths.length; i++) {
        TreePath path = paths[i];
        ConsoleConfiguration config = (ConsoleConfiguration) path.getSegment(0);
        try {
            openQueryEditor(config, generateQuery(path));
            showed = true;
        } catch (Exception he) {
            HibernateConsolePlugin.getDefault().showError(null, HibernateConsoleMessages.OpenQueryEditorAction_exception_open_hql_editor, he);
        }
    }
    return showed;
}
Also used : ConsoleConfiguration(org.hibernate.console.ConsoleConfiguration) TreePath(org.eclipse.jface.viewers.TreePath)

Example 43 with ConsoleConfiguration

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

the class OpenSourceAction method run.

public void run() {
    IStructuredSelection sel = getStructuredSelection();
    if (!(sel instanceof TreeSelection)) {
        return;
    }
    TreePath[] paths = ((TreeSelection) sel).getPaths();
    for (int i = 0; i < paths.length; i++) {
        TreePath path = paths[i];
        Object lastSegment = path.getLastSegment();
        IPersistentClass persClass = getPersistentClass(lastSegment);
        ConsoleConfiguration consoleConfig = (ConsoleConfiguration) (path.getSegment(0));
        String fullyQualifiedName = null;
        if (lastSegment instanceof IProperty) {
            Object prevSegment = path.getParentPath().getLastSegment();
            if (prevSegment instanceof IProperty && ((IProperty) prevSegment).isComposite()) {
                fullyQualifiedName = ((IValue) ((IProperty) prevSegment).getValue()).getComponentClassName();
            }
        }
        if (fullyQualifiedName == null && persClass != null) {
            fullyQualifiedName = persClass.getClassName();
        }
        try {
            run(consoleConfig, lastSegment, fullyQualifiedName);
        } catch (JavaModelException e) {
            HibernateConsolePlugin.getDefault().logErrorMessage(HibernateConsoleMessages.OpenSourceAction_cannot_find_source_file, e);
        } catch (PartInitException e) {
            HibernateConsolePlugin.getDefault().logErrorMessage(HibernateConsoleMessages.OpenSourceAction_cannot_open_source_file, e);
        } catch (FileNotFoundException e) {
            HibernateConsolePlugin.getDefault().logErrorMessage(HibernateConsoleMessages.OpenSourceAction_cannot_find_source_file, e);
        }
    }
}
Also used : JavaModelException(org.eclipse.jdt.core.JavaModelException) ConsoleConfiguration(org.hibernate.console.ConsoleConfiguration) FileNotFoundException(java.io.FileNotFoundException) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IPersistentClass(org.jboss.tools.hibernate.runtime.spi.IPersistentClass) TreePath(org.eclipse.jface.viewers.TreePath) IProperty(org.jboss.tools.hibernate.runtime.spi.IProperty) TreeSelection(org.eclipse.jface.viewers.TreeSelection) PartInitException(org.eclipse.ui.PartInitException)

Example 44 with ConsoleConfiguration

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

the class CloseConfigAction method doCloseConfig.

protected void doCloseConfig() {
    for (Iterator<?> i = getSelectedNonResources().iterator(); i.hasNext(); ) {
        Object node = i.next();
        if (!(node instanceof ConsoleConfiguration)) {
            continue;
        }
        ConsoleConfiguration config = (ConsoleConfiguration) node;
        ((MTreeViewer) viewer).clearChildren(config);
        config.reset();
        viewer.refresh(node);
    }
}
Also used : ConsoleConfiguration(org.hibernate.console.ConsoleConfiguration) MTreeViewer(org.hibernate.eclipse.console.viewers.xpl.MTreeViewer)

Example 45 with ConsoleConfiguration

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

the class ConsoleConfigReadyUseBaseAction method clearCache.

@SuppressWarnings("rawtypes")
protected void clearCache() {
    final IStructuredSelection selection = getStructuredSelection();
    HashSet<ConsoleConfiguration> vecMonitorConsoleConfigsTmp = cloneMonitorConsoleConfigs();
    for (ConsoleConfiguration consoleConfig : vecMonitorConsoleConfigsTmp) {
        consoleConfig.removeConsoleConfigurationListener(this);
    }
    vecMonitorConsoleConfigsTmp.clear();
    for (Iterator i = selection.iterator(); i.hasNext(); ) {
        Object obj = i.next();
        if (obj instanceof ConsoleConfiguration) {
            ConsoleConfiguration consoleConfig = (ConsoleConfiguration) obj;
            vecMonitorConsoleConfigsTmp.add(consoleConfig);
            consoleConfig.addConsoleConfigurationListener(this);
        }
    }
    vecMonitorConsoleConfigs = vecMonitorConsoleConfigsTmp;
    super.clearCache();
}
Also used : ConsoleConfiguration(org.hibernate.console.ConsoleConfiguration) Iterator(java.util.Iterator) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

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