@Override public void setVisible(boolean visible) { if (visible) { // Need to filter repository list based on currently selected repository // Will also keep track of which filter is applied, so we don't create // additional content providers unnecessarily. GuvWizardModel model = ((IGuvnorWizard) super.getWizard()).getModel(); String currentSelection = model.getRepLocation(); // Not supposed to use this page without setting the target repository in the model assert (currentSelection != null); // If we had a repository selection before that is different from the current selection if (previousSelection != null && !currentSelection.equals(previousSelection)) { handleRepositoryCreation(); RepositoryContentProvider cp = new RepositoryContentProvider(); cp.setRepositorySelection(currentSelection); viewer.setContentProvider(cp); viewer.setInput(viewer); previousSelection = currentSelection; } else { // If we didn't have a repository selection before (first time this page is loaded) if (previousSelection == null) { handleRepositoryCreation(); RepositoryContentProvider cp = new RepositoryContentProvider(); cp.setRepositorySelection(currentSelection); viewer.setContentProvider(cp); viewer.setInput(viewer); previousSelection = currentSelection; } } } super.setVisible(visible); }
private void updateModel() { GuvWizardModel model = ((IGuvnorWizard) super.getWizard()).getModel(); String selected = null; if (repLocations.getSelection().length > 0) { selected = repLocations.getSelection()[0]; } if (selected != null) { model.setRepLocation(repLocations.getSelection()[0]); } }
private void handleRepositoryCreation() { // First we'll see if the repository already exists GuvWizardModel model = ((IGuvnorWizard) super.getWizard()).getModel(); if (model.shouldCreateNewRep() && model.getRepLocation() != null) { GuvnorRepository theRep = Activator.getLocationManager().findRepository(model.getRepLocation()); if (theRep != null) { // The repository already exists, nothing to do return; } try { WizardUtils.createGuvnorRepository(model); } catch (Exception e) { super.setErrorMessage(e.getMessage()); Activator.getDefault().displayError(IStatus.ERROR, e.getMessage(), e, true); } } }
@SuppressWarnings("unchecked") private void updateModel() { IStructuredSelection selection = (IStructuredSelection) viewer.getSelection(); if (!selection.isEmpty()) { List<String> resources = new ArrayList<String>(); List<TreeObject> nodes = selection.toList(); for (TreeObject o : nodes) { if (o.getNodeType() == TreeObject.Type.RESOURCE) { resources.add(o.getFullPath()); } } GuvWizardModel model = ((IGuvnorWizard) super.getWizard()).getModel(); if (resources.size() > 0) { model.setResources(resources); } else { model.setResources(null); } } super.getWizard().getContainer().updateButtons(); }
@Override public boolean canFlipToNextPage() { GuvWizardModel model = ((IGuvnorWizard) super.getWizard()).getModel(); return model.getResources() != null && model.getResources().size() > 0; }