/** * Must be called after createProjectDropDownMenu, since we need to figure out the selected * project. * * @author stolz */ protected void createProductDropDownMenu(TabListener myListener, Composite comp) { Group group = createGroup(comp, "ABS Product", 1, 1, GridData.FILL_HORIZONTAL); productDropDown = new Combo(group, SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY); GridData gridData = new GridData(); gridData.widthHint = 200; productDropDown.setLayoutData(gridData); productDropDown.addListener(SWT.Selection, myListener); }
protected void fillProjectDropDownMenue(String name) { List<String> projectNames = getProjectNames(); int selectedProjectName = 0; projectDropDown.removeAll(); for (int i = 0; i < projectNames.size(); i++) { String projectName = projectNames.get(i); if (projectName.equals(name)) { selectedProjectName = i; } projectDropDown.add(projectName); } projectDropDown.select(selectedProjectName); }
protected IProject getSelectedProject() { final int idx = projectDropDown.getSelectionIndex(); if (idx == -1) return null; String projN = getProjectNames().get(idx); IProject proj = ResourcesPlugin.getWorkspace().getRoot().getProject(projN); return proj; }
protected void createProjectDropDownMenu(TabListener myListener, Composite comp) { Group group = createGroup(comp, "ABS Project", 1, 1, GridData.FILL_HORIZONTAL); projectDropDown = new Combo(group, SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY); GridData gridData = new GridData(); gridData.widthHint = 200; projectDropDown.setLayoutData(gridData); projectDropDown.addListener(SWT.Selection, myListener); /* Refresh products everytime the project is changed */ projectDropDown.addListener( SWT.Selection, new Listener() { @Override public void handleEvent(Event event) { fillProductDropDownMenue(null); updateErrors(); } }); }
/** * Lists all products in the current project's module, incl. a "<base>" product if no particular * product is selected. * * @param preSelected The product that should be preselected, or null for <base>. */ protected void fillProductDropDownMenue(String preSelected) { productDropDown.removeAll(); productDropDown.add("<base>"); IProject proj = getSelectedProject(); if (proj == null) { return; } AbsNature n = UtilityFunctions.getAbsNature(proj); Model m = n.getCompleteModel(); if (m == null) return; Collection<Product> prods = m.getProducts(); if (prods == null) return; int i = 1; /* base comes first */ int selected = 0; for (Product p : prods) { final String name = p.qualifiedName(); productDropDown.add(name); if (name.equals(preSelected)) { selected = i; } i++; } productDropDown.select(selected); }
/** @return the product name, or null if the base product is selected. */ protected String getSelectedProductName() { final int index = productDropDown.getSelectionIndex(); if (index <= 0) /* base is at index 0 */ return null; return productDropDown.getItem(index); }
protected String getSelectedProjectName() { return projectDropDown.getItem(projectDropDown.getSelectionIndex()); }