private Map getNativeEnvironment() { IEnvironment environment = fDialog.getEnvironment(); IExecutionEnvironment execEnvironment = (IExecutionEnvironment) environment.getAdapter(IExecutionEnvironment.class); Map stringVars = execEnvironment.getEnvironmentVariables(true); HashMap vars = new HashMap(); for (Iterator i = stringVars.keySet().iterator(); i.hasNext(); ) { String key = (String) i.next(); String value = (String) stringVars.get(key); vars.put(key, new EnvironmentVariable(key, value)); } return vars; }
protected EnvironmentVariable[] addExisted() { // get Environment Variables from the Environment Map envVariables = getNativeEnvironment(); if (envVariables.size() == 0) { MessageBox box = new MessageBox(fDialog.getShell(), SWT.ICON_ERROR); box.setMessage( MessageFormat.format( InterpretersMessages .AbstractInterpreterEnvironmentVariablesBlock_couldNotRetrieveEnvironmentVariablesFrom, new Object[] {fDialog.getEnvironment().getName()})); box.setText( InterpretersMessages .AbstractInterpreterEnvironmentVariablesBlock_failedToRetrieveEnvironment); box.open(); return null; } // get Environment Variables from the table EnvironmentVariable[] items = fEnvironmentVariablesContentProvider.getVariables(); for (int i = 0; i < items.length; i++) { EnvironmentVariable var = (EnvironmentVariable) items[i]; envVariables.remove(var.getName()); } ListSelectionDialog dialog = new ListSelectionDialog( fDialog.getShell(), envVariables, createSelectionDialogContentProvider(), createSelectionDialogLabelProvider(), LaunchConfigurationsMessages.EnvironmentTab_19); dialog.setTitle(LaunchConfigurationsMessages.EnvironmentTab_20); int button = dialog.open(); if (button == Window.OK) { Object[] selected = dialog.getResult(); EnvironmentVariable[] vars = new EnvironmentVariable[selected.length]; for (int i = 0; i < vars.length; i++) { vars[i] = (EnvironmentVariable) selected[i]; } return vars; } return null; }