@After
 public void restartPlugin() throws BundleException {
   Platform.getBundle(JBossLiveReloadCoreActivator.PLUGIN_ID).stop();
   Platform.getBundle(JBossLiveReloadCoreActivator.PLUGIN_ID).start(Bundle.START_TRANSIENT);
   final JBossLiveReloadCoreActivator restartedPlugin = JBossLiveReloadCoreActivator.getDefault();
   assertThat(restartedPlugin).isNotNull();
 }
예제 #2
0
 private void addSWTJars(List rtes) {
   if (fgSWTEntries == null) {
     fgSWTEntries = new ArrayList();
     Bundle bundle = Platform.getBundle("org.eclipse.swt"); // $NON-NLS-1$
     BundleDescription description =
         Platform.getPlatformAdmin().getState(false).getBundle(bundle.getBundleId());
     BundleDescription[] fragments = description.getFragments();
     for (int i = 0; i < fragments.length; i++) {
       Bundle fragmentBundle = Platform.getBundle(fragments[i].getName());
       URL bundleURL;
       try {
         bundleURL = FileLocator.resolve(fragmentBundle.getEntry("/")); // $NON-NLS-1$
       } catch (IOException e) {
         AntLaunching.log(e);
         continue;
       }
       String urlFileName = bundleURL.getFile();
       if (urlFileName.startsWith("file:")) { // $NON-NLS-1$
         try {
           urlFileName = new URL(urlFileName).getFile();
           if (urlFileName.endsWith("!/")) { // $NON-NLS-1$
             urlFileName = urlFileName.substring(0, urlFileName.length() - 2);
           }
         } catch (MalformedURLException e) {
           AntLaunching.log(e);
           continue;
         }
       }
       IPath fragmentPath = new Path(urlFileName);
       if (fragmentPath.getFileExtension() != null) { // JAR file
         fgSWTEntries.add(JavaRuntime.newArchiveRuntimeClasspathEntry(fragmentPath));
       } else { // folder
         File bundleFolder = fragmentPath.toFile();
         if (!bundleFolder.isDirectory()) {
           continue;
         }
         String[] names =
             bundleFolder.list(
                 new FilenameFilter() {
                   public boolean accept(File dir, String name) {
                     return name.endsWith(".jar"); // $NON-NLS-1$
                   }
                 });
         for (int j = 0; j < names.length; j++) {
           String jarName = names[j];
           fgSWTEntries.add(
               JavaRuntime.newArchiveRuntimeClasspathEntry(fragmentPath.append(jarName)));
         }
       }
     }
   }
   rtes.addAll(fgSWTEntries);
 }
예제 #3
0
 void createPage0() {
   try {
     xmlEditor = new XMLEditor();
     int index = addPage(xmlEditor, getEditorInput());
     setPageText(index, xmlEditor.getTitle() + " (Xml View)");
     IDocument inputDocument =
         xmlEditor.getDocumentProvider().getDocument(xmlEditor.getEditorInput());
     String documentContent = inputDocument.get();
     if (documentContent.isEmpty()) {
       documentContent = "";
       Bundle bundle = Platform.getBundle("reprotool.ide.txtspec");
       URL url = bundle.getResource("schema/default.txtspec.xml");
       try {
         InputStream ir = url.openStream();
         InputStreamReader isr = new InputStreamReader(ir);
         BufferedReader br = new BufferedReader(isr);
         String append;
         if ((documentContent = (br.readLine())) != null) ;
         while ((append = (br.readLine())) != null) documentContent += ("\n" + append);
         br.close();
       } catch (Exception e) {
         System.err.println(e.getMessage() + " " + e.getCause().toString());
       }
       documentContent = documentContent.trim();
       xmlEditor.setDocument(documentContent);
     }
   } catch (PartInitException e) {
     ErrorDialog.openError(
         getSite().getShell(), "Error creating xml text editor", null, e.getStatus());
   }
 }
예제 #4
0
 public static ILog getLog() {
   if (log == null) {
     Bundle bundle = Platform.getBundle(Activator.PLUGIN_ID);
     log = Platform.getLog(bundle);
   }
   return log;
 }
  @Test
  public void testCalculateXlogPFromCML()
      throws BioclipseException, FileNotFoundException, IOException, CoreException {

    ICDKManager cdk = net.bioclipse.cdk.business.Activator.getDefault().getJavaCDKManager();

    Bundle bun = Platform.getBundle(net.bioclipse.cdk.qsar.test.Activator.PLUGIN_ID);
    URL url = FileLocator.find(bun, new Path("src/testFiles/0037.cml"), null);
    String str = FileLocator.toFileURL(url).getFile();

    ICDKMolecule mol = cdk.loadMolecule(new MockIFile(str));

    IDescriptorResult dres1 = qsar.calculate(mol, xlogpID, CDK_REST_SHORTNAME);
    IDescriptorResult dres2 = qsar.calculate(mol, xlogpID, "CDK");

    assertNotNull(dres1);
    assertNull(dres1.getErrorMessage(), dres1.getErrorMessage());
    assertEquals(xlogpID, dres1.getDescriptor().getOntologyid());
    assertNotNull(dres2);
    assertNull(dres2.getErrorMessage(), dres1.getErrorMessage());
    assertEquals(xlogpID, dres2.getDescriptor().getOntologyid());

    assertEquals(
        "CDK and CDK REST gives different labels", dres2.getLabels()[0], dres1.getLabels()[0]);
    assertEquals(
        "CDK and CDK REST gives different values", dres2.getValues()[0], dres1.getValues()[0]);
  }
 @SuppressWarnings("unchecked")
 public MediaConfigurationScreenManager() {
   super();
   configurationScreens = new HashMap<String, Map<String, ConfigurationScreenRecord>>();
   IConfigurationElement[] screenExtensions =
       Platform.getExtensionRegistry()
           .getConfigurationElementsFor(mediaConfigurationScreenExtensionId);
   for (int i = 0; i < screenExtensions.length; i++) {
     ConfigurationScreenRecord csr = new ConfigurationScreenRecord();
     csr.primitiveTypeId = screenExtensions[i].getAttribute("primitive-id");
     csr.interactionType = screenExtensions[i].getAttribute("interaction-type");
     String className = screenExtensions[i].getAttribute("class");
     Bundle contributor = Platform.getBundle(screenExtensions[i].getContributor().getName());
     try {
       csr.screenClass = (Class<MediaConfigurationScreen>) contributor.loadClass(className);
     } catch (ClassNotFoundException e) {
       e.printStackTrace();
       continue;
     }
     Map<String, ConfigurationScreenRecord> byInteraction =
         configurationScreens.get(csr.primitiveTypeId);
     if (byInteraction == null) {
       byInteraction = new HashMap<String, ConfigurationScreenRecord>();
       configurationScreens.put(csr.primitiveTypeId, byInteraction);
     }
     byInteraction.put(csr.interactionType, csr);
   }
 }
예제 #7
0
 @Override
 public synchronized File getSourceWorkspaceDirectory() {
   if (sourceWorkspaceDirectory != null) {
     return sourceWorkspaceDirectory;
   }
   final Bundle bundle = Platform.getBundle(bundleName);
   if (bundle == null) {
     throw new IllegalStateException(
         NLS.bind("Bundle \"{0}\" with test data not found", bundleName));
   }
   final URL bundleURL = bundle.getEntry("/");
   final File bundleDirectory;
   try {
     bundleDirectory = new File(FileLocator.toFileURL(bundleURL).toURI());
   } catch (URISyntaxException e) {
     throw new IllegalStateException(e);
   } catch (IOException e) {
     throw new IllegalStateException(e);
   }
   final File workspace = new File(bundleDirectory, getLocalWorkspacePath());
   if (!workspace.isDirectory()) {
     throw new IllegalStateException(
         NLS.bind("Source workspace directory {0} doesn't exist", workspace));
   }
   sourceWorkspaceDirectory = workspace;
   return workspace;
 }
  private void updateEntries() throws Exception {
    final List<IClasspathEntry> newEntries = new ArrayList<>();
    for (final String referenceLibrary : SARL_REFERENCE_LIBRARIES) {
      // Retreive the bundle
      final Bundle bundle = Platform.getBundle(referenceLibrary);
      if (bundle == null) {
        throw new NameNotFoundException("No bundle found for: " + referenceLibrary); // $NON-NLS-1$
      }

      final IPath bundlePath = BundleUtil.getBundlePath(bundle);
      final IPath sourceBundlePath = BundleUtil.getSourceBundlePath(bundle, bundlePath);

      IClasspathAttribute[] extraAttributes = null;
      if (referenceLibrary.startsWith("io.sarl")) { // $NON-NLS-1$
        final IPath javadocPath = BundleUtil.getJavadocBundlePath(bundle, bundlePath);
        final IClasspathAttribute attr;
        if (javadocPath == null) {
          attr =
              JavaCore.newClasspathAttribute(
                  IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME, JAVADOC_URL);
        } else {
          attr =
              JavaCore.newClasspathAttribute(
                  IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME,
                  javadocPath.makeAbsolute().toOSString());
        }
        extraAttributes = new IClasspathAttribute[] {attr};
      }

      newEntries.add(
          JavaCore.newLibraryEntry(
              bundlePath, sourceBundlePath, null, new IAccessRule[] {}, extraAttributes, false));
    }
    this.entries = newEntries.toArray(new IClasspathEntry[newEntries.size()]);
  }
 private Class<?> loadClassInBundle(String bundleID, String qualifiedName) {
   Bundle requiredBundle = Platform.getBundle(bundleID);
   if (requiredBundle != null) {
     return loadClassInBundle(requiredBundle, qualifiedName);
   }
   return null;
 }
  protected void perfValidate(String filename, int iterations) throws Exception {
    // read in the file
    InputStream in =
        FileLocator.openStream(
            Platform.getBundle(JSCorePlugin.PLUGIN_ID),
            Path.fromPortableString("performance/" + filename),
            false);
    IFile file = project.createFile(filename, IOUtil.read(in));
    RebuildIndexJob job = new RebuildIndexJob(project.getURI());
    job.run(null);

    // Ok now actually validate the thing, the real work
    for (int i = 0; i < iterations; i++) {
      EditorTestHelper.joinBackgroundActivities();

      BuildContext context = new BuildContext(file);
      // Don't measure reading in string...
      context.getContents();

      startMeasuring();
      validator.buildFile(context, null);
      stopMeasuring();
    }
    commitMeasurements();
    assertPerformance();
  }
  /**
   * Adapted from "ClojureProjectNature", in
   * http://code.google.com/p/clojure-dev/source/browse/src/clojuredev/ClojureProjectNature.java?r=823b1fa724ead0027dbfbf3450eaca5f5d8257b7
   *
   * @param pluginName
   * @param jarName
   * @return
   */
  private File getJarInsidePlugin(String pluginName, String jarName) {
    try {
      Bundle bundle = Platform.getBundle(pluginName);
      File bundlePath = FileLocator.getBundleFile(bundle);
      if (bundlePath.isFile()) {
        // ClojuredevPlugin.logError(pluginName + " plugin should be deployed as a directory");
        // return null;
        throw new RuntimeException(pluginName + " plugin should be deployed as a directory");
      }

      File libEntry = new File(bundlePath, jarName + ".jar");
      if (!libEntry.exists()) {
        // ClojuredevPlugin.logError("Unable to locate " + jarName + " jar in " + pluginName + "
        // plugin");
        // return null;
        throw new RuntimeException(
            "Unable to locate " + jarName + " jar in " + pluginName + " plugin");
      }
      return libEntry;
    } catch (IOException e) {
      throw new RuntimeException("Unable to find " + pluginName + " plugin");
      // ClojuredevPlugin.logError("Unable to find " + pluginName + " plugin");
      // return null;
    }
  }
예제 #12
0
파일: MME.java 프로젝트: gedaofeng/xmind3
 private static Bundle getIDE() {
   if (ideBundle == null && !noIDE) {
     ideBundle = Platform.getBundle("org.eclipse.ui.ide"); // $NON-NLS-1$
     noIDE = (ideBundle == null);
   }
   return ideBundle;
 }
 private static LanguageSupport tryInstantiate(String className) {
   LanguageSupport instance = null;
   if (className != null && className.length() > 0) {
     try {
       int separator = className.indexOf(':');
       Bundle bundle = null;
       if (separator == -1) {
         JavaCore javaCore = JavaCore.getJavaCore();
         if (javaCore == null) {
           Class clazz = Class.forName(className);
           return (LanguageSupport) clazz.newInstance();
         } else {
           bundle = javaCore.getBundle();
         }
       } else {
         String bundleName = className.substring(0, separator);
         className = className.substring(separator + 1);
         bundle = Platform.getBundle(bundleName);
       }
       Class c = bundle.loadClass(className);
       instance = (LanguageSupport) c.newInstance();
     } catch (ClassNotFoundException e) {
       log(e);
     } catch (InstantiationException e) {
       log(e);
     } catch (IllegalAccessException e) {
       log(e);
     } catch (ClassCastException e) {
       log(e);
     }
   }
   return instance;
 }
 /**
  * Creates an extension. If the extension plugin has not been loaded a busy cursor will be
  * activated during the duration of the load.
  *
  * @param element the config element defining the extension
  * @param classAttribute the name of the attribute carrying the class
  * @returns the extension object if successful. If an error occurs when createing executable
  *     extension, the exception is logged, and null returned.
  */
 public static Object createExtension(
     final IConfigurationElement element, final String classAttribute) {
   final Object[] result = new Object[1];
   // If plugin has been loaded create extension.
   // Otherwise, show busy cursor then create extension.
   String pluginId = element.getDeclaringExtension().getNamespace();
   Bundle bundle = Platform.getBundle(pluginId);
   if (bundle.getState() == Bundle.ACTIVE) {
     try {
       result[0] = element.createExecutableExtension(classAttribute);
     } catch (Exception e) {
       // catch and log ANY exception from extension point
       handleCreateExecutableException(result, e);
     }
   } else {
     BusyIndicator.showWhile(
         null,
         new Runnable() {
           public void run() {
             try {
               result[0] = element.createExecutableExtension(classAttribute);
             } catch (Exception e) {
               // catch and log ANY exception from extension point
               handleCreateExecutableException(result, e);
             }
           }
         });
   }
   return result[0];
 }
예제 #15
0
 public URL getLicenseFile() throws IOException {
   final Bundle b = Platform.getBundle(Activator.PLUGIN_ID);
   final URL url =
       FileLocator.toFileURL(
           FileLocator.find(b, new Path("resources/license.txt"), null)); // $NON-NLS-1$
   return url;
 }
  private void printBundleState(String id) {
    Bundle resolverBundle = Platform.getBundle(id);
    if (resolverBundle != null) {
      int state = resolverBundle.getState();
      String stateString;
      switch (state) {
        case Bundle.ACTIVE:
          stateString = "ACTIVE";
          break;
        case Bundle.INSTALLED:
          stateString = "INSTALLED";
          break;
        case Bundle.RESOLVED:
          stateString = "RESOLVED";
          break;
        case Bundle.STOPPING:
          stateString = "STOPPING";
          break;
        case Bundle.UNINSTALLED:
          stateString = "UNINSTALLED";
          break;

        default:
          stateString = "UNKNOWN";
          break;
      }
      System.out.println(id + " state: " + stateString);
    } else {
      System.out.println(id + " is not installed");
    }
  }
예제 #17
0
  public void testCopyFromNonReadableDirectory() throws Exception {
    // We can use source.setReadable(false) when we decide to use java 1.6
    if (!Platform.OS_WIN32.equals(Platform.getOS())) {
      URL resourceURL = Platform.getBundle(BUNDLE_ID).getEntry(RESOURCE_DIR);
      File resourceFolder = ResourceUtil.resourcePathToFile(resourceURL);

      File source = new File(resourceFolder, TEST_DIR);
      File dest = new File(tempDir, "tempdir");

      try {
        Runtime.getRuntime()
            .exec(new String[] {"chmod", "333", source.getAbsolutePath()})
            .waitFor(); //$NON-NLS-1$
        IOUtil.copyDirectory(source, dest);
        assertDirectory(source, dest);
        fail("Expected directories to not match");
      } catch (AssertionError ae) {
        // expected
      } finally {
        FileUtil.deleteRecursively(dest);
        Runtime.getRuntime()
            .exec(new String[] {"chmod", "755", source.getAbsolutePath()})
            .waitFor(); //$NON-NLS-1$
      }
    }
  }
예제 #18
0
  protected void validateState(IEditorInput input) {

    IDocumentProvider provider = getDocumentProvider();
    if (!(provider instanceof IDocumentProviderExtension)) return;

    IDocumentProviderExtension extension = (IDocumentProviderExtension) provider;

    try {

      extension.validateState(input, getSite().getShell());

    } catch (CoreException x) {
      IStatus status = x.getStatus();
      if (status == null || status.getSeverity() != IStatus.CANCEL) {
        Bundle bundle = Platform.getBundle(PlatformUI.PLUGIN_ID);
        ILog log = Platform.getLog(bundle);
        log.log(x.getStatus());

        Shell shell = getSite().getShell();
        String title = "EditorMessages.Editor_error_validateEdit_title";
        String msg = "EditorMessages.Editor_error_validateEdit_message";
        ErrorDialog.openError(shell, title, msg, x.getStatus());
      }
      return;
    }

    if (fSourceViewer != null) fSourceViewer.setEditable(isEditable());
  }
예제 #19
0
 /**
  * Image registry loading. Loads the images by key into the given registry.
  *
  * @param registry image registry to load
  */
 @Override
 protected void initializeImageRegistry(ImageRegistry registry) {
   Bundle bundle = Platform.getBundle(PLUGIN_ID);
   initializeImage(registry, bundle, "icons/obj16/ratio.gif", COMPUTE_IMAGE);
   initializeImage(registry, bundle, "icons/obj16/ratio.gif", NODE_SCRAP_RATIO);
   initializeImage(registry, bundle, "icons/obj16/ratio.gif", NODE_REWORK_RATIO);
   initializeImage(registry, bundle, "icons/obj16/ratio.gif", NODE_MODULARITY);
   initializeImage(registry, bundle, "icons/obj16/ratio.gif", NODE_ADAPTABILITY);
   initializeImage(registry, bundle, "icons/obj16/ratio.gif", NODE_MATURITY);
   initializeImage(registry, bundle, "icons/obj16/ratio.gif", NODE_MAINTAINABILITY);
   initializeImage(registry, bundle, "icons/obj16/ratio.gif", NODE_REWORK_STABILITY);
   initializeImage(registry, bundle, "icons/obj16/ratio.gif", NODE_REWORK_BACKLOG);
   initializeImage(registry, bundle, "icons/obj16/trend.gif", NODE_MODULARITY_TREND);
   initializeImage(registry, bundle, "icons/obj16/trend.gif", NODE_ADAPTABILITY_TREND);
   initializeImage(registry, bundle, "icons/obj16/trend.gif", NODE_MATURITY_TREND);
   initializeImage(registry, bundle, "icons/obj16/spider.png", FORM_IMAGE);
   initializeImage(registry, bundle, "icons/obj16/th_horizontal.gif", HORIZONTAL_IMAGE);
   initializeImage(registry, bundle, "icons/obj16/th_vertical.gif", VERTICAL_IMAGE);
   initializeImage(registry, bundle, "icons/obj16/commit.gif", COMMIT_IMAGE);
   initializeImage(
       registry, bundle, "icons/obj16/critical_changes.gif", NODE_CRITICAL_CHANGE_ORDERS);
   initializeImage(registry, bundle, "icons/obj16/normal_changes.gif", NODE_NORMAL_CHANGE_ORDERS);
   initializeImage(
       registry, bundle, "icons/obj16/improvement_changes.gif", NODE_IMPROVEMENT_CHANGE_ORDERS);
   initializeImage(registry, bundle, "icons/obj16/new_changes.gif", NODE_NEW_CHANGE_ORDERS);
   initializeImage(registry, bundle, "icons/obj16/sigma.gif", NODE_TOTAL_CHANGE_ORDERS);
   initializeImage(registry, bundle, "icons/obj16/artifacts.gif", NODE_TOTAL_SIZE);
   initializeImage(registry, bundle, "icons/obj16/artifacts.gif", NODE_BROKEN_SIZE);
   initializeImage(registry, bundle, "icons/obj16/artifacts.gif", NODE_FIXED_SIZE);
   initializeImage(registry, bundle, "icons/obj16/baselined_lines.gif", NODE_BASELINED_LINES);
   initializeImage(registry, bundle, "icons/obj16/usage.gif", NODE_USAGE_TIME);
   initializeImage(registry, bundle, "icons/obj16/development.gif", NODE_DEVELOPMENT_EFFORT);
   initializeImage(registry, bundle, "icons/obj16/repair.gif", NODE_REPAIR_EFFORT);
 }
 /** readElement() */
 protected void readElement(IConfigurationElement element) {
   if (element.getName().equals(tagName)) {
     String namespace = element.getAttribute(ATT_NAME_SPACE);
     if (namespace != null) {
       Bundle bundle =
           Platform.getBundle(element.getDeclaringExtension().getContributor().getName());
       if (attributeNames.length == 1) {
         String className = element.getAttribute(attributeNames[0]);
         if (className != null) {
           nsKeyedExtensionRegistry.put(namespace, className, bundle);
         }
       } else {
         HashMap map = new HashMap();
         for (int i = 0; i < attributeNames.length; i++) {
           String attributeName = attributeNames[i];
           String className = element.getAttribute(attributeName);
           if (className != null && className.length() > 0) {
             map.put(attributeName, className);
           }
         }
         nsKeyedExtensionRegistry.put(namespace, map, bundle);
       }
     }
   }
 }
예제 #21
0
 /**
  * Initialize the filter descriptor from the specified configuration element.
  *
  * @param descriptor The new descriptor to be initialized.
  * @param configuration The configuration element to initialize the filter.
  * @throws CoreException Thrown during parsing.
  */
 void initFilter(FilterDescriptor descriptor, IConfigurationElement configuration)
     throws CoreException {
   String attribute = configuration.getAttribute("name"); // $NON-NLS-1$
   Assert.isNotNull(attribute);
   descriptor.setName(attribute);
   attribute = configuration.getAttribute("description"); // $NON-NLS-1$
   if (attribute != null) {
     descriptor.setDescription(attribute);
   }
   attribute = configuration.getAttribute("image"); // $NON-NLS-1$
   if (attribute != null) {
     String symbolicName = configuration.getContributor().getName();
     URL resource = Platform.getBundle(symbolicName).getResource(attribute);
     Image image = ImageDescriptor.createFromURL(resource).createImage();
     descriptor.setImage(image);
   }
   attribute = configuration.getAttribute("enabled"); // $NON-NLS-1$
   if (attribute != null) {
     descriptor.setEnabled(Boolean.valueOf(attribute).booleanValue());
   }
   attribute = configuration.getAttribute("class"); // $NON-NLS-1$
   Assert.isNotNull(attribute);
   ViewerFilter filter =
       (ViewerFilter) configuration.createExecutableExtension("class"); // $NON-NLS-1$
   Assert.isNotNull(filter);
   descriptor.setFilter(filter);
   attribute = configuration.getAttribute("visibleInUI"); // $NON-NLS-1$
   if (attribute != null) {
     descriptor.setVisible(Boolean.valueOf(attribute).booleanValue());
   }
 }
 private Bundle locateBundle(String bundleID) {
   final Bundle bundle = Platform.getBundle(bundleID);
   if (bundle == null) {
     throw new RuntimeException("Bundle not found: " + bundleID);
   }
   return bundle;
 }
예제 #23
0
  private void hideMenuCheck() {
    try {
      URL pluginUrl = Platform.getBundle(GrassUiPlugin.PLUGIN_ID).getResource("/");
      String pluginPath = FileLocator.toFileURL(pluginUrl).getPath();
      File pluginFile = new File(pluginPath);
      File installFolder = pluginFile.getParentFile().getParentFile().getParentFile();

      File grassFolderFile = new File(installFolder, "grass");
      if (Platform.getOS().equals(Platform.OS_WIN32)) {
        if (!grassFolderFile.exists() || !grassFolderFile.isDirectory()) {
          IWorkbenchWindow[] wwindows = PlatformUI.getWorkbench().getWorkbenchWindows();
          String actionSetID = "eu.hydrologis.jgrass.ui.grassactionset";

          for (IWorkbenchWindow iWorkbenchWindow : wwindows) {
            IWorkbenchPage activePage = iWorkbenchWindow.getActivePage();
            if (activePage != null) {
              activePage.hideActionSet(actionSetID);
              MenuManager mbManager = ((ApplicationWindow) iWorkbenchWindow).getMenuBarManager();
              for (int i = 0; i < mbManager.getItems().length; i++) {
                IContributionItem item = mbManager.getItems()[i];
                if (item.getId().equals(actionSetID)) {
                  item.setVisible(false);
                }
              }
            }
          }
        }
      }
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
예제 #24
0
파일: CoreUtility.java 프로젝트: zhaog/cdt
 /**
  * Creates an extension. If the extension plugin has not been loaded, a busy cursor will be
  * activated during the duration of the load.
  *
  * @param element the config element defining the extension
  * @param classAttribute the name of the attribute carrying the class
  * @return the extension object
  */
 public static Object createExtension(
     final IConfigurationElement element, final String classAttribute) throws CoreException {
   // If plugin has been loaded, create extension.
   // Otherwise, show busy cursor then create extension.
   String id = element.getContributor().getName();
   Bundle bundle = Platform.getBundle(id);
   if (bundle.getState() == org.osgi.framework.Bundle.ACTIVE) {
     return element.createExecutableExtension(classAttribute);
   }
   final Object[] ret = new Object[1];
   final CoreException[] exc = new CoreException[1];
   BusyIndicator.showWhile(
       null,
       new Runnable() {
         @Override
         public void run() {
           try {
             ret[0] = element.createExecutableExtension(classAttribute);
           } catch (CoreException e) {
             exc[0] = e;
           }
         }
       });
   if (exc[0] != null) throw exc[0];
   return ret[0];
 }
예제 #25
0
  public void deleteServer(Object server) {
    String id = ((Server) server).getName();
    Server serverIns = (Server) server;
    DOMConfigurator config = null;
    try {
      Bundle bundle = Platform.getBundle(Application.PLUGIN_ID);
      URL fileURL = FileLocator.toFileURL(BundleUtility.find(bundle, "configuration/nabee.xml"));

      config = new DOMConfigurator(fileURL.getPath());

      config.deleteConf("monitor/server", id);

      if (serverIns.getConnect().isConnect()) serverIns.getConnect().getProtocol()._close();

    } catch (ParserConfigurationException e) {
      IMessageBox.Error(shell, NBLabel.get(0x008F));
      return;
    } catch (TransformerException e) {
      IMessageBox.Error(shell, NBLabel.get(0x008F));
      return;
    } catch (IOException e) {
      IMessageBox.Error(shell, NBLabel.get(0x008F));
      return;
    } catch (SAXException e) {
      IMessageBox.Error(shell, NBLabel.get(0x008F));
      return;
    } catch (Exception e) {
      IMessageBox.Error(shell, NBLabel.get(0x008F));
      return;
    }

    serverIns.getParent().removeChild(id);
    treeViewer.refresh();
  }
예제 #26
0
  @Before
  public void setup() {
    ILog log = Platform.getLog(Platform.getBundle(Activator.PLUGIN_ID));

    log.log(
        new Status(
            IStatus.ERROR, ERROR_ID_1, ERROR_MESSAGE_1, new NullPointerException(ERROR_STACK_1)));
    log.log(
        new Status(
            IStatus.ERROR, ERROR_ID_2, ERROR_MESSAGE_2, new NullPointerException(ERROR_STACK_2)));

    log.log(new Status(IStatus.OK, OK_ID_1, OK_MESSAGE_1, null));
    log.log(new Status(IStatus.OK, OK_ID_2, OK_MESSAGE_2, new NullPointerException(OK_STACK_2)));

    log.log(
        new Status(
            IStatus.WARNING,
            WARNING_ID_1,
            WARNING_MESSAGE_1,
            new IllegalArgumentException(WARNING_STACK_1)));
    log.log(
        new Status(
            IStatus.WARNING,
            WARNING_ID_2,
            WARNING_MESSAGE_2,
            new NullPointerException(WARNING_STACK_2)));

    log.log(new Status(IStatus.INFO, INFO_ID_1, INFO_MESSAGE_1, null));
    log.log(
        new Status(
            IStatus.INFO, INFO_ID_2, INFO_MESSAGE_2, new NullPointerException(INFO_STACK_2)));
  }
예제 #27
0
 /**
  * Expects the bundle to have a META-INF/MANIFEST.MF set and to exist.
  *
  * @param symbolicName
  * @return
  * @throws IOException
  */
 public static String getBundleJarPath(String symbolicName) throws IOException {
   String MANIFESTPath = "/META-INF/MANIFEST.MF";
   URL pluginManifLoc =
       FileLocator.resolve(
           FileLocator.find(Platform.getBundle(symbolicName), new Path(MANIFESTPath), null));
   return getBundleJarPathInternal(MANIFESTPath, pluginManifLoc);
 }
  public static void checkSanity(int expectMinor) throws BundleException {
    Bundle bundle = CompilerUtils.getActiveGroovyBundle();
    assertNotNull("No active Groovy bundle found", bundle);
    assertEquals(
        "Wrong version for groovy bundle: " + bundle.getVersion(),
        expectMinor,
        bundle.getVersion().getMinor());
    if (bundle.getState() != Bundle.ACTIVE) {
      bundle.start();
    }

    bundle = Platform.getBundle("org.eclipse.jdt.core");
    final String qualifier = bundle.getVersion().getQualifier();
    // TODO: the conditions below should be activated... or test will break on non E_3_6 builds...
    // for now leave like this
    // to be 100% sure sanity checks are really executed!
    //		if (StsTestUtil.isOnBuildSite() && StsTestUtil.ECLIPSE_3_6_OR_LATER) {
    assertTrue(
        "JDT patch not properly installed (org.eclipse.jdt.core version = "
            + bundle.getVersion()
            + ")",
        qualifier.contains("xx") || qualifier.equals("qualifier"));
    //		}
    if (bundle.getState() != Bundle.ACTIVE) {
      bundle.start();
    }
    assertTrue(
        "Groovy language support is not active",
        LanguageSupportFactory.getEventHandler()
            .getClass()
            .getName()
            .endsWith("GroovyEventHandler"));
  }
예제 #29
0
  /**
   * Adds message to log.
   *
   * @param level severity level of the message (OK, INFO, WARNING, ERROR, OK_DEBUG, INFO_DEBUG,
   *     WARNING_DEBUG, ERROR_DEBUG)
   * @param message text to add to the log
   * @param exception exception thrown
   */
  protected static void _log(int level, String message, Throwable exception) {
    if (level == OK_DEBUG
        || level == INFO_DEBUG
        || level == WARNING_DEBUG
        || level == ERROR_DEBUG) {
      if (!isDebugging()) return;
    }

    int severity = IStatus.OK;
    switch (level) {
      case INFO_DEBUG:
      case INFO:
        severity = IStatus.INFO;
        break;
      case WARNING_DEBUG:
      case WARNING:
        severity = IStatus.WARNING;
        break;
      case ERROR_DEBUG:
      case ERROR:
        severity = IStatus.ERROR;
    }
    message = (message != null) ? message : "null"; // $NON-NLS-1$
    Status statusObj = new Status(severity, PLUGIN_ID, severity, message, exception);
    Bundle bundle = Platform.getBundle(PLUGIN_ID);
    if (bundle != null) Platform.getLog(bundle).log(statusObj);
  }
예제 #30
0
 /** Calculates the contents of page 2 when the it is activated. */
 protected void pageChange(int newPageIndex) {
   super.pageChange(newPageIndex);
   if (newPageIndex == 1) {
     IDocument inputDocument =
         xmlEditor.getDocumentProvider().getDocument(xmlEditor.getEditorInput());
     String documentContent = inputDocument.get();
     TSEditor.setDocument(documentContent);
   } else if (newPageIndex == 0) {
     IDocument inputDocument =
         xmlEditor.getDocumentProvider().getDocument(xmlEditor.getEditorInput());
     String documentContent = inputDocument.get();
     if (documentContent.isEmpty()) {
       documentContent = "";
       Bundle bundle = Platform.getBundle("reprotool.ide.txtspec");
       URL url = bundle.getResource("schema/default.txtspec.xml");
       try {
         InputStream ir = url.openStream();
         InputStreamReader isr = new InputStreamReader(ir);
         BufferedReader br = new BufferedReader(isr);
         String append;
         if ((documentContent = (br.readLine())) != null) ;
         while ((append = (br.readLine())) != null) documentContent += ("\n" + append);
         br.close();
       } catch (Exception e) {
         System.err.println(e.getMessage() + " " + e.getCause().toString());
       }
       documentContent = documentContent.trim();
     }
     xmlEditor.setDocument(documentContent);
   }
 }