@Override public void initializeFrom(ILaunchConfiguration configuration) { boolean append= true; try { append = configuration.getAttribute(ILaunchManager.ATTR_APPEND_ENVIRONMENT_VARIABLES, true); } catch (CoreException e) { DebugUIPlugin.log(e.getStatus()); } if (append) { appendEnvironment.setSelection(true); replaceEnvironment.setSelection(false); } else { replaceEnvironment.setSelection(true); appendEnvironment.setSelection(false); } updateEnvironment(configuration); updateAppendReplace(); }
/** * Adds a new environment variable to the table. */ protected void handleEnvAddButtonSelected() { MultipleInputDialog dialog = new MultipleInputDialog(getShell(), LaunchConfigurationsMessages.EnvironmentTab_22); dialog.addTextField(NAME_LABEL, null, false); dialog.addVariablesField(VALUE_LABEL, null, true); if (dialog.open() != Window.OK) { return; } String name = dialog.getStringValue(NAME_LABEL); String value = dialog.getStringValue(VALUE_LABEL); if (name != null && value != null && name.length() > 0 && value.length() >0) { addVariable(new EnvironmentVariable(name.trim(), value.trim())); updateAppendReplace(); } }
/** * Removes the selected environment variable from the table. */ private void handleEnvRemoveButtonSelected() { IStructuredSelection sel = environmentTable.getStructuredSelection(); try { environmentTable.getControl().setRedraw(false); for (Iterator<?> i = sel.iterator(); i.hasNext();) { EnvironmentVariable var = (EnvironmentVariable) i.next(); environmentTable.remove(var); } } finally { environmentTable.getControl().setRedraw(true); } updateAppendReplace(); updateLaunchConfigurationDialog(); }
/** * Displays a dialog that allows user to select native environment variables * to add to the table. */ private void handleEnvSelectButtonSelected() { //get Environment Variables from the OS Map<String, EnvironmentVariable> envVariables = getNativeEnvironment(); //get Environment Variables from the table TableItem[] items = environmentTable.getTable().getItems(); for (int i = 0; i < items.length; i++) { EnvironmentVariable var = (EnvironmentVariable) items[i].getData(); envVariables.remove(var.getName()); } NativeEnvironmentSelectionDialog dialog = new NativeEnvironmentSelectionDialog(getShell(), envVariables); dialog.setTitle(LaunchConfigurationsMessages.EnvironmentTab_20); int button = dialog.open(); if (button == Window.OK) { Object[] selected = dialog.getResult(); for (int i = 0; i < selected.length; i++) { environmentTable.add(selected[i]); } } updateAppendReplace(); updateLaunchConfigurationDialog(); }