Search in sources :

Example 71 with ILaunchConfiguration

use of org.eclipse.debug.core.ILaunchConfiguration in project jbosstools-hibernate by jbosstools.

the class DeleteProjectParticipant method createChange.

@Override
public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
    ILaunchConfiguration[] configs = HibernateRefactoringUtil.getAffectedLaunchConfigurations(javaProject);
    List<Change> changes = new ArrayList<Change>();
    for (int i = 0; i < configs.length; i++) {
        changes.add(new ConsoleConfigurationDeleteJavaProjectChange(configs[i]));
    }
    return HibernateRefactoringUtil.createChangesFromList(changes, getName());
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ArrayList(java.util.ArrayList) ConsoleConfigurationDeleteJavaProjectChange(org.hibernate.eclipse.launch.core.refactoring.ConsoleConfigurationDeleteJavaProjectChange) ConsoleConfigurationDeleteJavaProjectChange(org.hibernate.eclipse.launch.core.refactoring.ConsoleConfigurationDeleteJavaProjectChange) Change(org.eclipse.ltk.core.refactoring.Change)

Example 72 with ILaunchConfiguration

use of org.eclipse.debug.core.ILaunchConfiguration in project jbosstools-hibernate by jbosstools.

the class HibernateConsolePlugin method listenForConfigurations.

private void listenForConfigurations() {
    final ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
    kcl = new KnownConfigurationsAdapter() {

        /**
         * @param root
         * @param forUpdate - shows whether physical removal necessary
         */
        public void configurationRemoved(ConsoleConfiguration root, boolean forUpdate) {
            if (!forUpdate) {
                try {
                    removeConfiguration(root.getName());
                } catch (CoreException e) {
                    logErrorMessage(HibernateConsoleMessages.HibernateConsolePlugin_could_not_delete_launch_config_for + root.getName(), e);
                }
            }
        }
    };
    KnownConfigurations.getInstance().addConsoleConfigurationListener(kcl);
    icl = new ILaunchConfigurationListener() {

        boolean isConsoleConfiguration(ILaunchConfiguration configuration) {
            try {
                return configuration.getType().getIdentifier().equals(ICodeGenerationLaunchConstants.CONSOLE_CONFIGURATION_LAUNCH_TYPE_ID);
            } catch (CoreException e) {
            // HibernateConsolePlugin.getDefault().log( e );
            // ignore since it occurs on delete
            }
            return false;
        }

        public void launchConfigurationRemoved(ILaunchConfiguration configuration) {
            ConsoleConfiguration cfg = KnownConfigurations.getInstance().find(configuration.getName());
            if (cfg != null) {
                // file system removal have been made already.
                KnownConfigurations.getInstance().removeConfiguration(cfg, true);
            }
        }

        public void launchConfigurationChanged(ILaunchConfiguration configuration) {
            if (configuration.isWorkingCopy() || isTemporary(configuration)) {
                return;
            }
            if (isConsoleConfiguration(configuration)) {
                KnownConfigurations instance = KnownConfigurations.getInstance();
                ConsoleConfiguration oldcfg = instance.find(configuration.getName());
                if (oldcfg != null) {
                    // reset it no matter what.
                    oldcfg.reset();
                } else {
                    // A new one!
                    ConsoleConfigurationPreferences adapter = buildConfigurationPreferences(configuration);
                    instance.addConfiguration(new ConsoleConfiguration(adapter), true);
                }
            }
        }

        private ConsoleConfigurationPreferences buildConfigurationPreferences(ILaunchConfiguration configuration) {
            return new EclipseLaunchConsoleConfigurationPreferences(configuration);
        }

        public void launchConfigurationAdded(ILaunchConfiguration configuration) {
            if (isConsoleConfiguration(configuration)) {
                ILaunchConfiguration movedFrom = launchManager.getMovedFrom(configuration);
                if (movedFrom != null && isConsoleConfiguration(movedFrom)) {
                    KnownConfigurations instance = KnownConfigurations.getInstance();
                    ConsoleConfiguration oldcfg = instance.find(movedFrom.getName());
                    if (oldcfg != null) {
                        // call this before we remove old configuration
                        refactor(movedFrom, configuration);
                        // reset it no matter what.
                        oldcfg.reset();
                        instance.removeConfiguration(oldcfg, false);
                    }
                }
                KnownConfigurations instance = KnownConfigurations.getInstance();
                ConsoleConfigurationPreferences adapter = buildConfigurationPreferences(configuration);
                boolean temporary = isTemporary(configuration);
                if (!temporary) {
                    instance.addConfiguration(new ConsoleConfiguration(adapter), true);
                }
            }
        }

        private void refactor(ILaunchConfiguration oldConfiguration, ILaunchConfiguration newConfiguration) {
            if (!oldConfiguration.getName().equals(newConfiguration.getName())) {
                // only rename of console configuration refactoring is supported.
                ConsoleConfigurationRenameProcessor proc = new ConsoleConfigurationRenameProcessor(oldConfiguration, newConfiguration.getName());
                // Refactor for rename
                PerformRefactoringOperation refOperation = new PerformRefactoringOperation(new ProcessorBasedRefactoring(proc), CheckConditionsOperation.ALL_CONDITIONS);
                try {
                    ResourcesPlugin.getWorkspace().run(refOperation, null);
                } catch (OperationCanceledException oce) {
                    throw new OperationCanceledException();
                } catch (CoreException ce) {
                    HibernateConsolePlugin.openError(new Shell(), HibernateConsoleMessages.EditConsoleConfiguration_rename_refactoring_error_totle, ce.getLocalizedMessage(), ce, HibernateConsolePlugin.PERFORM_SYNC_EXEC);
                }
            }
        }

        private boolean isTemporary(ILaunchConfiguration configuration) {
            boolean temporary = true;
            try {
                temporary = configuration.getAttribute(AddConfigurationAction.TEMPORARY_CONFIG_FLAG, false);
            } catch (CoreException e) {
                HibernateConsolePlugin.getDefault().showError(getShell(), HibernateConsoleMessages.HibernateConsolePlugin_problem_to_get_flag, e);
            }
            return temporary;
        }
    };
    launchManager.addLaunchConfigurationListener(icl);
}
Also used : KnownConfigurationsAdapter(org.hibernate.console.KnownConfigurationsAdapter) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ConsoleConfiguration(org.hibernate.console.ConsoleConfiguration) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) ConsoleConfigurationRenameProcessor(org.hibernate.eclipse.launch.core.refactoring.ConsoleConfigurationRenameProcessor) ILaunchManager(org.eclipse.debug.core.ILaunchManager) PerformRefactoringOperation(org.eclipse.ltk.core.refactoring.PerformRefactoringOperation) ProcessorBasedRefactoring(org.eclipse.ltk.core.refactoring.participants.ProcessorBasedRefactoring) ILaunchConfigurationListener(org.eclipse.debug.core.ILaunchConfigurationListener) Shell(org.eclipse.swt.widgets.Shell) CoreException(org.eclipse.core.runtime.CoreException) ConsoleConfigurationPreferences(org.hibernate.console.preferences.ConsoleConfigurationPreferences) KnownConfigurations(org.hibernate.console.KnownConfigurations)

Example 73 with ILaunchConfiguration

use of org.eclipse.debug.core.ILaunchConfiguration in project jbosstools-hibernate by jbosstools.

the class EditConsoleConfiguration method edit.

private void edit(final ConsoleConfiguration config) {
    IWorkbenchWindow win = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    try {
        ILaunchConfiguration launchConfiguration = LaunchHelper.findHibernateLaunchConfig(config.getName());
        if (launchConfiguration != null) {
            // $NON-NLS-1$
            DebugUITools.openLaunchConfigurationPropertiesDialog(win.getShell(), launchConfiguration, "org.eclipse.debug.ui.launchGroup.run");
            return;
        }
        String out = NLS.bind(HibernateConsoleMessages.EditConsoleConfiguration_could_not_find_launch_cfg, config.getName());
        HibernateConsolePlugin.getDefault().showError(win.getShell(), out, new IllegalStateException(HibernateConsoleMessages.EditConsoleConfiguration_no_launch_cfg_matched + config.getName()));
    } catch (CoreException ce) {
        HibernateConsolePlugin.getDefault().showError(win.getShell(), HibernateConsoleMessages.EditConsoleConfiguration_problem_adding_console_cfg, ce);
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) CoreException(org.eclipse.core.runtime.CoreException)

Example 74 with ILaunchConfiguration

use of org.eclipse.debug.core.ILaunchConfiguration in project jbosstools-hibernate by jbosstools.

the class ExportAntCodeGenWizardPage method setControlCombo.

protected void setControlCombo(Control newControl) {
    consoleConfigurationName = new ComboDialogField(SWT.READ_ONLY);
    consoleConfigurationName.setLabelText(HibernateConsoleMessages.ExportAntCodeGenWizardPage_hibernate_code_generation_configurations);
    ILaunchConfiguration[] launchCfgs;
    try {
        launchCfgs = LaunchHelper.findFilteredCodeGenerationConfigsSorted();
    } catch (CoreException e) {
        launchCfgs = new ILaunchConfiguration[0];
    }
    String[] names = new String[launchCfgs.length];
    for (int i = 0; i < launchCfgs.length; i++) {
        ILaunchConfiguration launchCfg = launchCfgs[i];
        names[i] = launchCfg.getName();
    }
    consoleConfigurationName.setItems(names);
    IDialogFieldListener fieldlistener = new IDialogFieldListener() {

        public void dialogFieldChanged(DialogField field) {
            setPageComplete(validatePage());
        }
    };
    consoleConfigurationName.setDialogFieldListener(fieldlistener);
    consoleConfigurationName.doFillIntoGrid((Composite) newControl, 2);
}
Also used : IDialogFieldListener(org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) CoreException(org.eclipse.core.runtime.CoreException) ComboDialogField(org.eclipse.jdt.internal.ui.wizards.dialogfields.ComboDialogField) ComboDialogField(org.eclipse.jdt.internal.ui.wizards.dialogfields.ComboDialogField) DialogField(org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField)

Example 75 with ILaunchConfiguration

use of org.eclipse.debug.core.ILaunchConfiguration in project jbosstools-hibernate by jbosstools.

the class AddConfigurationAction method makeTemporaryLaunchConfigurationsPermanent.

public static void makeTemporaryLaunchConfigurationsPermanent() throws CoreException {
    List<ILaunchConfiguration> listTempConfigs = getTemporaryLaunchConfigurations();
    ILaunchConfigurationWorkingCopy wc;
    for (int i = 0; i < listTempConfigs.size(); i++) {
        wc = listTempConfigs.get(i).getWorkingCopy();
        // Must be set to null since it should never be in the actual saved configuration!
        wc.setAttribute(TEMPORARY_CONFIG_FLAG, (String) null);
        wc.doSave();
    }
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)

Aggregations

ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)275 CoreException (org.eclipse.core.runtime.CoreException)100 ILaunchConfigurationWorkingCopy (org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)79 Test (org.junit.Test)72 ILaunchConfigurationType (org.eclipse.debug.core.ILaunchConfigurationType)51 ILaunchManager (org.eclipse.debug.core.ILaunchManager)41 ArrayList (java.util.ArrayList)37 ILaunch (org.eclipse.debug.core.ILaunch)37 IPath (org.eclipse.core.runtime.IPath)20 IProject (org.eclipse.core.resources.IProject)19 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)17 IStatus (org.eclipse.core.runtime.IStatus)16 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)16 IEditorPart (org.eclipse.ui.IEditorPart)15 IProcess (org.eclipse.debug.core.model.IProcess)14 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)14 IFile (org.eclipse.core.resources.IFile)13 Status (org.eclipse.core.runtime.Status)13 CachegrindViewPart (org.eclipse.linuxtools.internal.valgrind.cachegrind.CachegrindViewPart)13 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)11