/** * Returns the identifier of the launch group this action is associated * with. * * @return the identifier of the launch group this action is associated * with */ protected String getLaunchGroupIdentifier() { return fLaunchGroup.getIdentifier(); } }
public Object[] getElements(Object inputElement) { ILaunchGroup[] groups = DebugUITools.getLaunchGroups(); List possibleGroups = new ArrayList(); ILaunchConfiguration configuration = (ILaunchConfiguration) inputElement; for (int i = 0; i < groups.length; i++) { ILaunchGroup extension = groups[i]; LaunchHistory history = getLaunchConfigurationManager().getLaunchHistory( extension.getIdentifier()); if (history != null && history.accepts(configuration)) { possibleGroups.add(extension); } } return possibleGroups.toArray(); }
@Override public Object[] getElements(Object inputElement) { ILaunchGroup[] groups = DebugUITools.getLaunchGroups(); List<ILaunchGroup> possibleGroups = new ArrayList<>(); ILaunchConfiguration configuration = (ILaunchConfiguration)inputElement; for (int i = 0; i < groups.length; i++) { ILaunchGroup extension = groups[i]; LaunchHistory history = getLaunchConfigurationManager().getLaunchHistory(extension.getIdentifier()); if (history != null && history.accepts(configuration)) { possibleGroups.add(extension); } } return possibleGroups.toArray(); }
@Override public Object[] getElements(Object inputElement) { ILaunchGroup[] groups = DebugUITools.getLaunchGroups(); List<ILaunchGroup> possibleGroups = new ArrayList<>(); ILaunchConfiguration configuration = (ILaunchConfiguration)inputElement; for (int i = 0; i < groups.length; i++) { ILaunchGroup extension = groups[i]; LaunchHistory history = getLaunchConfigurationManager().getLaunchHistory(extension.getIdentifier()); if (history != null && history.accepts(configuration)) { possibleGroups.add(extension); } } return possibleGroups.toArray(); }
/** * This method checks if the specified <code>ILaunchConfiguration</code> is a favorite in this * history's launch group. * * @param configuration * @return true if the configuration is a favorite in this history's launch group, false otherwise * @throws CoreException * * @since 3.4 */ protected boolean isFavorite(ILaunchConfiguration configuration) throws CoreException { String groupId = getLaunchGroup().getIdentifier(); List<String> favoriteGroups = configuration.getAttribute(IDebugUIConstants.ATTR_FAVORITE_GROUPS, (List<String>) null); if (favoriteGroups == null) { // check deprecated attributes for backwards compatibility if (groupId.equals(IDebugUIConstants.ID_DEBUG_LAUNCH_GROUP)) { return configuration.getAttribute(IDebugUIConstants.ATTR_DEBUG_FAVORITE, false); } else if (groupId.equals(IDebugUIConstants.ID_RUN_LAUNCH_GROUP)) { return configuration.getAttribute(IDebugUIConstants.ATTR_RUN_FAVORITE, false); } } else if (favoriteGroups.contains(getLaunchGroup().getIdentifier())) { return true; } return false; }
boolean previewConfiguration(ILaunchConfiguration configuration, ILaunchRequest request) { String groupId = getLaunchConfigurationGroup(configuration, request).getIdentifier(); return DebugUITools.openLaunchConfigurationPropertiesDialog(getShell(), configuration, groupId) == Window.OK; }
/** * Returns the history listing as XML * @return the history listing as XML * @throws CoreException if an exception occurs * @throws ParserConfigurationException if there is a problem creating the XML for the launch history */ protected String getHistoryAsXML() throws CoreException, ParserConfigurationException { Document doc = DebugUIPlugin.getDocument(); Element historyRootElement = doc.createElement(IConfigurationElementConstants.LAUNCH_HISTORY); doc.appendChild(historyRootElement); for (LaunchHistory history : fLaunchHistories.values()) { Element groupElement = doc.createElement(IConfigurationElementConstants.LAUNCH_GROUP); groupElement.setAttribute(IConfigurationElementConstants.ID, history.getLaunchGroup().getIdentifier()); historyRootElement.appendChild(groupElement); Element historyElement = doc.createElement(IConfigurationElementConstants.MRU_HISTORY); groupElement.appendChild(historyElement); createEntry(doc, historyElement, history.getCompleteLaunchHistory()); Element favs = doc.createElement(IConfigurationElementConstants.FAVORITES); groupElement.appendChild(favs); createEntry(doc, favs, history.getFavorites()); history.setSaved(true); } return DebugPlugin.serializeDocument(doc); }
/** * Restore launch history */ private synchronized void loadLaunchHistories() { if (fLaunchHistories == null) { fRestoring = true; ILaunchGroup[] groups = getLaunchGroups(); fLaunchHistories = new HashMap<>(groups.length); ILaunchGroup extension = null; for (int i = 0; i < groups.length; i++) { extension = groups[i]; if (extension.isPublic()) { fLaunchHistories.put(extension.getIdentifier(), new LaunchHistory(extension)); } } restoreLaunchHistory(); fRestoring = false; } }
private static synchronized void initializeModes() { if (modes != null) { return; } modes = new LinkedHashMap<>(); modes.put(GroupLaunchElement.MODE_INHERIT, new InheritModeGroup()); Set<ILaunchGroup> sortedGroups = new TreeSet<>((a, b) -> { return a.getLabel().compareTo(b.getLabel()); }); LaunchConfigurationManager mgr = DebugUIPlugin.getDefault().getLaunchConfigurationManager(); sortedGroups.addAll(Arrays.asList(mgr.getLaunchGroups())); for (ILaunchGroup launchGroup : sortedGroups) { LaunchHistory history = mgr.getLaunchHistory(launchGroup.getIdentifier()); if (history == null) { // mode currently not supported. continue; } String modeName = launchGroup.getMode(); if (!modes.containsKey(modeName)) { modes.put(modeName, launchGroup); } } }
/** * Sets the given launch to be the most recent launch in the launch * history (for applicable histories). * <p> * @param launch the launch to prepend to its associated histories * @since 3.3 */ public void setRecentLaunch(ILaunch launch) { ILaunchGroup[] groups = DebugUITools.getLaunchGroups(); int size = groups.length; for (int i = 0; i < size; i++) { String id = groups[i].getIdentifier(); LaunchHistory history = getLaunchHistory(id); if (history != null) { history.launchAdded(launch); } } }
/** * Returns the label for the last launched configuration or and empty string if there was no last launch. * @param group the {@link ILaunchGroup} to get the label for * @return the name of the last launched configuration, altered with '(running)' if needed, or the empty * string if there is no last launch. */ protected String getlastLaunchedLabel(ILaunchGroup group) { ILaunchConfiguration config = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getFilteredLastLaunch(group.getIdentifier()); if(config != null) { return appendLaunched(config); } return EMPTY_STRING; }
/** * @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus, java.lang.Object) */ @Override public Object handleStatus(IStatus status, Object source) throws CoreException { if(source instanceof Object[]) { Object[] infos = (Object[]) source; if(infos.length == 2) { final ILaunchConfiguration config = (ILaunchConfiguration) infos[0]; final String mode = (String) infos[1]; final Shell shell = DebugUIPlugin.getShell(); Runnable runnable = () -> { ILaunchGroup group = DebugUITools.getLaunchGroup(config, mode); if (group != null) { DebugUITools.openLaunchConfigurationDialog(shell, config, group.getIdentifier(), null); } }; DebugUIPlugin.getStandardDisplay().asyncExec(runnable); } } return Status.OK_STATUS; } }
private static void handleInvocationTargetException(InvocationTargetException e, ILaunchConfiguration configuration, String mode) { Throwable targetException = e.getTargetException(); Throwable t = e; if (targetException instanceof CoreException) { t = targetException; } if (t instanceof CoreException) { CoreException ce = (CoreException)t; IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(ce.getStatus()); if (handler != null) { ILaunchGroup group = DebugUITools.getLaunchGroup(configuration, mode); if (group != null) { DebugUITools.openLaunchConfigurationDialogOnGroup(DebugUIPlugin.getShell(), new StructuredSelection(configuration), group.getIdentifier(), ce.getStatus()); return; } } if ((ce.getStatus().getSeverity() & (IStatus.ERROR | IStatus.WARNING)) == 0) { // If the exception is a CoreException with a status other // than ERROR or WARNING, don't open an error dialog. return; } } DebugUIPlugin.errorDialog(DebugUIPlugin.getShell(), DebugUIMessages.DebugUITools_Error_1, DebugUIMessages.DebugUITools_Exception_occurred_during_launch_2, t); // }
/** * @see org.eclipse.jface.action.IAction#run() */ @Override public void run() { ILaunchGroup group = DebugUITools.getLaunchGroup(getLaunchConfiguration(), getMode()); if (group != null) { if(isTerminated()) { DebugUITools.openLaunchConfigurationDialog( DebugUIPlugin.getShell(), getLaunchConfiguration(), group.getIdentifier(), null); } else { DebugUIPlugin.openLaunchConfigurationEditDialog( DebugUIPlugin.getShell(), getLaunchConfiguration(), group.getIdentifier(), null, false); } } }
/** * This method launches the last configuration that was launched, if any. * * @param group the launch group to launch with * @param isShift is Shift pressed (use <code>false</code> if no support for * Shift) * @return true if there was a last launch and it was launched, false * otherwise */ protected boolean launchLast(ILaunchGroup group, boolean isShift) { ILaunchConfiguration config = null; if(group != null) { config = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getFilteredLastLaunch(group.getIdentifier()); if(config != null) { launch(config, group.getMode(), isShift); return true; } } return false; }
private static void generateErrorDialog(final String title, final String message, final ILaunchConfiguration launchConfig, final String mode) { getDisplay().syncExec(() -> { Shell parentShell = getActiveShell(); MessageDialog dialog = new MessageDialog(parentShell, title, null, message, MessageDialog.ERROR, 1, PDEUIMessages.LauncherUtils_edit, PDEUIMessages.LauncherUtils_cancelLaunch); int res = dialog.open(); if (res == 0) { IStructuredSelection selection = new StructuredSelection(launchConfig); ILaunchGroup group = DebugUITools.getLaunchGroup(launchConfig, mode); String groupIdentifier = group == null ? IDebugUIConstants.ID_RUN_LAUNCH_GROUP : group.getIdentifier(); IStatus status = new Status(IStatus.OK, PDELaunchingPlugin.getPluginId(), LauncherUtils.SELECT_WORKSPACE_FIELD, "", null); //$NON-NLS-1$ DebugUITools.openLaunchConfigurationDialogOnGroup(parentShell, selection, groupIdentifier, status); } }); }
/** * @see org.eclipse.jface.action.IAction#run() */ @Override public void run() { final CoreException[] ex = new CoreException[1]; BusyIndicator.showWhile(DebugUIPlugin.getStandardDisplay(), () -> { try { List<String> list = getLaunchConfiguration().getAttribute(IDebugUIConstants.ATTR_FAVORITE_GROUPS, (List<String>) null); if (list == null) { list = new ArrayList<>(); } list.add(getGroup().getIdentifier()); ILaunchConfigurationWorkingCopy copy = getLaunchConfiguration().getWorkingCopy(); copy.setAttribute(IDebugUIConstants.ATTR_FAVORITE_GROUPS, list); copy.doSave(); setEnabled(false); } catch (CoreException e) { ex[0] = e; } }); if (ex[0] != null) { DebugUIPlugin.errorDialog(DebugUIPlugin.getShell(), ActionMessages.AddToFavoritesAction_2, ActionMessages.AddToFavoritesAction_3, ex[0].getStatus()); // } }
public void run() { DebugPlugin.getDefault().getLaunchManager().addLaunchListener(new SPLaunchListener(config)); if (identifier.getType() == ProcIdentifier.TYPE_TRIGGER) { ILaunchGroup group = DebugUITools.getLaunchGroup(config, spmode); String groupId = group == null ? "" : group.getIdentifier(); //$NON-NLS-1$ DebugUITools.openLaunchConfigurationDialog(getShell(), config, groupId, null); return; } DebugUITools.launch(config, spmode); } });
/** * Removes the specified <code>ILaunchConfiguration</code> from the launch histories associated * with the specified listing of <code>ILaunchGroup</code>s. * @param config the configuration to remove from the histories from the given launch groups * @param groups the launch groups whose histories the given configuration should be removed from * * @since 3.4 */ private void removeFromLaunchHistories(ILaunchConfiguration config, ILaunchGroup[] groups) { LaunchHistory history = null; for(int i = 0; i < groups.length; i++) { history = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchHistory(groups[i].getIdentifier()); if(history != null) { history.removeFromHistory(fConfiguration); } else { DebugUIPlugin.logErrorMessage(MessageFormat.format("Unable to remove configuration [{0}] from launch history. The launch history for mode [{1}] does not exist.", new Object[] { config.getName(), groups[i].getMode() })); //$NON-NLS-1$ } } }
@Override public void runWithEvent(Event event) { if ((event.stateMask & SWT.MOD1) > 0) { try { ILaunchGroup group = DebugUIPlugin.getDefault().getLaunchConfigurationManager().getLaunchGroup(fConfig.getType(), fMode); if(group != null) { DebugUITools.openLaunchConfigurationDialogOnGroup(DebugUIPlugin.getShell(), new StructuredSelection(fConfig), group.getIdentifier()); } else { runInternal(((event.stateMask & SWT.SHIFT) > 0) ? true : false); } } catch(CoreException ce) {} } else { runInternal(((event.stateMask & SWT.SHIFT) > 0) ? true : false); } }