Exemplo n.º 1
0
 @SuppressWarnings("unchecked")
 public static boolean checkResourceSet(ISelection selection, boolean guvnorControlled) {
   boolean res = true;
   try {
     if (!(selection instanceof IStructuredSelection)) {
       return false;
     }
     IStructuredSelection sel = (IStructuredSelection) selection;
     for (Iterator<Object> it = sel.iterator(); it.hasNext(); ) {
       Object oneSelection = it.next();
       if (oneSelection instanceof IFile) {
         if (!(((IFile) oneSelection).getName().indexOf(".") > 0)) {
           res = false;
           break;
         }
         GuvnorMetadataProps props = GuvnorMetadataUtils.getGuvnorMetadata((IFile) oneSelection);
         if ((guvnorControlled && props == null) || (!guvnorControlled && props != null)) {
           res = false;
           break;
         }
       }
     }
   } catch (Exception e) {
     Activator.getDefault().writeLog(IStatus.ERROR, e.getMessage(), e);
     res = false;
   }
   return res;
 }
 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);
     }
   }
 }
 private void addRepositoryList() {
   java.util.List<GuvnorRepository> reps = Activator.getLocationManager().getRepositories();
   for (int i = 0; i < reps.size(); i++) {
     repLocations.add(reps.get(i).getLocation());
   }
   if (repLocations.getItemCount() > 0) {
     repLocations.setSelection(0);
     updateModel();
   }
 }
Exemplo n.º 4
0
  private static ImageDescriptor loadImageDescriptor(String id) {
    String iconPath = "icons/"; // $NON-NLS-1$

    try {
      URL installURL = Activator.getDefault().getBundle().getEntry("/"); // $NON-NLS-1$
      URL url = new URL(installURL, iconPath + id);
      return ImageDescriptor.createFromURL(url);
    } catch (MalformedURLException e) {
      return ImageDescriptor.getMissingImageDescriptor();
    }
  }
 private void initialize() {
   boolean shouldAdd = true;
   invisibleRoot = new TreeParent("", TreeObject.Type.NONE); // $NON-NLS-1$
   List<GuvnorRepository> reps = Activator.getLocationManager().getRepositories();
   for (int i = 0; i < reps.size(); i++) {
     if (repUrl != null) {
       if (repUrl.equals(reps.get(i).getLocation())) {
         shouldAdd = true;
       } else {
         shouldAdd = false;
       }
     } else {
       shouldAdd = true;
     }
     if (shouldAdd) {
       TreeParent p = new TreeParent(reps.get(i).getLocation(), TreeObject.Type.REPOSITORY);
       p.setGuvnorRepository(reps.get(i));
       ResourceProperties props = new ResourceProperties();
       props.setBase(""); // $NON-NLS-1$
       p.setResourceProps(props);
       invisibleRoot.addChild(p);
     }
   }
 }
Exemplo n.º 6
0
 @SuppressWarnings("unchecked")
 public static boolean areFilesDirty(ISelection selection) {
   boolean res = true;
   try {
     if (!(selection instanceof IStructuredSelection)) {
       return false;
     }
     IStructuredSelection sel = (IStructuredSelection) selection;
     for (Iterator<Object> it = sel.iterator(); it.hasNext(); ) {
       Object oneSelection = it.next();
       if (oneSelection instanceof IFile) {
         boolean isCurrent = GuvnorMetadataUtils.isGuvnorResourceCurrent((IFile) oneSelection);
         if (isCurrent) {
           res = false;
           break;
         }
       }
     }
   } catch (Exception e) {
     Activator.getDefault().writeLog(IStatus.ERROR, e.getMessage(), e);
     res = false;
   }
   return res;
 }