Exemple #1
0
  /**
   * Opens an {@link Dialogs}
   *
   * @param title - The title (if null it will be "Error")
   * @param body - The message (if null it will be e.getLocalizedMessage() )
   * @param e - A Throwable
   */
  public static void errorMsgb(String title, String body, Throwable e) {
    Plugin plugin = ResourcesPlugin.getPlugin();
    if (title == null) {
      title = "Error";
    }

    if (body == null) {
      body = e.getLocalizedMessage();
    }

    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    e.printStackTrace(pw);

    final String trace = sw.toString(); // stack trace as a string

    // Temp holder of child statuses
    List<Status> childStatuses = new ArrayList<>();

    // Split output by OS-independend new-line
    for (String line : trace.split(System.getProperty("line.separator"))) {
      // build & add status
      childStatuses.add(new Status(IStatus.ERROR, plugin.getBundle().getSymbolicName(), line));
    }

    MultiStatus ms =
        new MultiStatus(
            plugin.getBundle().getSymbolicName(),
            IStatus.ERROR,
            childStatuses.toArray(new Status[] {}), // convert to array of statuses
            e.getLocalizedMessage(),
            e);
    ErrorDialog.openError(
        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), title, body, ms);
  }
 private Path findFileInPlugin(Plugin plugin, String file)
     throws MalformedURLException, IOException {
   // Plugin p = Platform.getPlugin(plugin);
   URL pluginURL = plugin.getBundle().getEntry("/");
   URL jarURL = new URL(pluginURL, file);
   URL localJarURL = FileLocator.toFileURL(jarURL); // Platform.asLocalURL(jarURL);
   return new Path(localJarURL.getPath());
 }
Exemple #3
0
  public void start() throws CoreException {
    final String version = getFeatureVersionImpl();

    ErlLogger.debug("Starting CORE " + Thread.currentThread());
    String dev = "(" + EncodingUtils.getEncoding() + ") ";
    if (SystemConfiguration.getInstance().isDeveloper()) {
      dev += " developer version ***";
    }
    if (SystemConfiguration.getInstance().isTest()) {
      dev += " test ***";
    }
    final String versionBanner = "*** starting Erlide v" + version + " *** " + dev;
    logger.log(Level.INFO, versionBanner);
    featureVersion = version;

    workspace.addSaveParticipant(plugin.getBundle().getSymbolicName(), getSaveParticipant());

    ErlangDebugOptionsManager.getDefault().start();
    ErlLogger.debug("Started CORE");
  }
Exemple #4
0
 public StatusExt(int severity, Plugin plugin, String message, Throwable exception) {
   super(severity, plugin.getBundle().getSymbolicName(), message, exception);
   this.plugin = plugin;
 }
Exemple #5
0
 Bundle getBundle() {
   return plugin.getBundle();
 }
Exemple #6
0
 public static <T> T getService(Class<T> service) {
   BundleContext context = plugin.getBundle().getBundleContext();
   ServiceReference<T> ref = context.getServiceReference(service);
   return ref != null ? context.getService(ref) : null;
 }
Exemple #7
0
 public static String getId() {
   return plugin.getBundle().getSymbolicName();
 }
Exemple #8
0
 public static BundleContext getContext() {
   return plugin.getBundle().getBundleContext();
 }