Example #1
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)));
  }
  /* Initialisierung */
  static {
    IPath actLoc = Activator.getDefault().getStateLocation();
    IPath p = Platform.getLocation();
    IStatus ae =
        new Status(IStatus.INFO, Activator.PLUGIN_ID, "actLoc.toString(): " + actLoc.toString());
    ILOGGER.log(ae);
    ae = new Status(IStatus.INFO, Activator.PLUGIN_ID, "p.toString(): " + p.toString());
    ILOGGER.log(ae);

    // develop in eclipse
    String pdrHome = System.getenv("AE_RAP_HOME");
    if (pdrHome != null) {
      AE_RAP_HOME = pdrHome;
    } else {

      // rap
      AE_RAP_HOME = actLoc.removeLastSegments(8).toOSString();
    }
    ae = new Status(IStatus.INFO, Activator.PLUGIN_ID, "reduced string: " + AE_RAP_HOME);
    ILOGGER.log(ae);
    /** Properties laden. */
    PROPERTIES = new Properties();
    PROPERTIES_FILENAME = AE_RAP_HOME + FS + "RAPConfig" + FS + "config.properties";
    File file = new File(PROPERTIES_FILENAME);
    // try {
    // if (_i) _l.info("Lade: " + file.toURI().toString());
    try {
      PROPERTIES.load(new FileInputStream(file));
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
    PROJECT_IDS = PROPERTIES.getProperty("PROJECT_IDS").split("\\|");
    REPOSITORY_ID = Integer.parseInt(PROPERTIES.getProperty("REPOSITORY_ID"));
    PROJECT_ID = Integer.parseInt(PROPERTIES.getProperty("PROJECT_ID"));
    REPOSITORY_URL = PROPERTIES.getProperty("REPOSITORY_URL");
    if (PROPERTIES.getProperty("USER_IDS_BLACK_LIST") != null) {
      USER_IDS_BLACK_LIST = PROPERTIES.getProperty("USER_IDS_BLACK_LIST").split("\\|");
    } else {
      USER_IDS_BLACK_LIST = null;
    }
    if (PROPERTIES.getProperty("USER_IDS_WHITE_LIST") != null) {
      USER_IDS_WHITE_LIST = PROPERTIES.getProperty("USER_IDS_WHITE_LIST").split("\\|");
    } else {
      USER_IDS_WHITE_LIST = null;
    }
  }
Example #3
0
 private static RSetup loadSetup(
     final String id,
     final Map<String, String> filter,
     final IConfigurationElement[] configurationElements) {
   try {
     for (int i = 0; i < configurationElements.length; i++) {
       final IConfigurationElement element = configurationElements[i];
       if (element.getName().equals(SETUP_ELEMENT_NAME)
           && id.equals(element.getAttribute(ID_ATTRIBUTE_NAME))) {
         final RSetup setup = new RSetup(id);
         if (filter != null && filter.containsKey("$os$")) { // $NON-NLS-1$
           setup.setOS(filter.get("$os$"), filter.get("$arch$")); // $NON-NLS-1$ //$NON-NLS-2$
         } else {
           setup.setOS(Platform.getOS(), Platform.getOSArch());
         }
         setup.setName(element.getAttribute(NAME_ATTRIBUTE_NAME));
         loadSetupBase(id, filter, configurationElements, setup);
         if (setup.getRHome() == null) {
           log(
               IStatus.WARNING,
               "Incomplete R setup: Missing R home for setup '" + id + "', the setup is ignored.",
               element);
           return null;
         }
         loadSetupLibraries(id, filter, configurationElements, setup);
         return setup;
       }
     }
   } catch (final Exception e) {
     LOGGER.log(
         new Status(IStatus.ERROR, PLUGIN_ID, "Error in R setup: Failed to load setup.", e));
   }
   return null;
 }
Example #4
0
 public static boolean getNotAllConvert(IProject project, boolean preference) {
   String org = null;
   String notAllConvert = null;
   try {
     org =
         project.getPersistentProperty(
             new QualifiedName(
                 PropertiesEditorPlugin.PLUGIN_ID, PropertiesProperty.P_ORIGINAL_SETTINGS));
     notAllConvert =
         project.getPersistentProperty(
             new QualifiedName(
                 PropertiesEditorPlugin.PLUGIN_ID, PropertiesProperty.P_NOT_ALL_CONVERT));
   } catch (CoreException e) {
     IStatus status =
         new Status(
             IStatus.ERROR, PropertiesEditorPlugin.PLUGIN_ID, IStatus.OK, e.getMessage(), e);
     ILog log = PropertiesEditorPlugin.getDefault().getLog();
     log.log(status);
     ErrorDialog.openError(
         null,
         Messages.getString("eclipse.propertieseditor.property.error_title"),
         Messages.getString("eclipse.propertieseditor.property.get.settings.error"),
         status); //$NON-NLS-1$ //$NON-NLS-2$
   }
   if (org != null) {
     if (Boolean.valueOf(org).booleanValue()) {
       if (notAllConvert == null || notAllConvert.equals("")) { // $NON-NLS-1$
         return preference;
       } else {
         return Boolean.valueOf(notAllConvert).booleanValue();
       }
     }
   }
   return preference;
 }
Example #5
0
 public static String getCommentChar(IProject project, String preference) {
   String org = null;
   String commentChar = null;
   try {
     org =
         project.getPersistentProperty(
             new QualifiedName(
                 PropertiesEditorPlugin.PLUGIN_ID, PropertiesProperty.P_ORIGINAL_SETTINGS));
     commentChar =
         project.getPersistentProperty(
             new QualifiedName(
                 PropertiesEditorPlugin.PLUGIN_ID, PropertiesProperty.P_COMMENT_CHARACTER));
   } catch (CoreException e) {
     IStatus status =
         new Status(
             IStatus.ERROR, PropertiesEditorPlugin.PLUGIN_ID, IStatus.OK, e.getMessage(), e);
     ILog log = PropertiesEditorPlugin.getDefault().getLog();
     log.log(status);
     ErrorDialog.openError(
         null,
         Messages.getString("eclipse.propertieseditor.property.error_title"),
         Messages.getString("eclipse.propertieseditor.property.get.settings.error"),
         status); //$NON-NLS-1$ //$NON-NLS-2$
   }
   if (org != null) {
     if (Boolean.valueOf(org).booleanValue()) {
       if (commentChar == null || commentChar.equals("")) { // $NON-NLS-1$
         return preference;
       } else {
         return commentChar;
       }
     }
   }
   return preference;
 }
  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());
  }
  private AdvancedIncQueryEngine createEngine() {
    boolean wildcardMode =
        IncQueryGUIPlugin.getDefault()
            .getPreferenceStore()
            .getBoolean(PreferenceConstants.WILDCARD_MODE);
    boolean dynamicEMFMode =
        IncQueryGUIPlugin.getDefault()
            .getPreferenceStore()
            .getBoolean(PreferenceConstants.DYNAMIC_EMF_MODE);

    try {
      AdvancedIncQueryEngine engine =
          AdvancedIncQueryEngine.createUnmanagedEngine(
              key.getNotifier(), wildcardMode, dynamicEMFMode);
      return engine;
    } catch (IncQueryException e) {
      logger.log(
          new Status(
              IStatus.ERROR,
              IncQueryGUIPlugin.PLUGIN_ID,
              "Could not retrieve IncQueryEngine for " + key.getNotifier(),
              e));
      return null;
    }
  }
 /**
  * Use the supplied log to display the current settings.
  *
  * @param log Log to send output to.
  */
 public void show(ILog log) {
   StringBuilder info = new StringBuilder();
   info.append(TextUI.box(TextUI.fmt(Resources.INFO_SETTINGS_HEADING)));
   for (Entry<String, String> kv : settings.entrySet()) {
     info.append(String.format("%-12s = %s\n", kv.getKey(), kv.getValue()));
   }
   log.log(new Status(Status.INFO, Activator.PLUGIN_ID, info.toString()));
 }
  /** @param ex */
  public static void log(final Exception ex) {
    final ILog log = getDefault().getLog();
    final StringWriter stringWriter = new StringWriter();
    ex.printStackTrace(new PrintWriter(stringWriter));
    final String msg = stringWriter.getBuffer().toString();

    final Status status = new Status(4, PLUGIN_ID, 4, msg, null);
    log.log(status);
  }
 public static void log(final IStatus status) {
   final WaLTablePlugin plugin = getDefault();
   if (plugin != null) {
     final ILog log = plugin.getLog();
     if (log != null) {
       log.log(status);
     }
   }
 }
 private void reportMatcherError(String message, Throwable t) {
   if (t != null) {
     contentStatus = new Status(IStatus.ERROR, IncQueryGUIPlugin.PLUGIN_ID, message, t);
   } else {
     contentStatus = new Status(IStatus.ERROR, IncQueryGUIPlugin.PLUGIN_ID, message);
   }
   logger.log(contentStatus);
   getParent().getViewer().refresh(this);
 }
Example #12
0
 private static void log(
     final int severity, final String message, final IConfigurationElement element) {
   final StringBuilder info = new StringBuilder(message);
   if (element != null) {
     info.append(" (contributed by '");
     info.append(element.getContributor().getName());
     info.append("').");
   }
   LOGGER.log(new Status(IStatus.WARNING, PLUGIN_ID, info.toString()));
 }
Example #13
0
 public static void log(String message, Throwable error) {
   ILog log = getLog();
   if (log != null) {
     log.log(
         new Status(
             error == null ? IStatus.INFO : IStatus.ERROR,
             XMindCommandPlugin.PLUGIN_ID,
             message,
             error));
   }
 }
  boolean openPerspective(
      final String perspId,
      final IAdaptable input,
      final IWorkbench workbench,
      final IPreferenceStore store,
      final ILog logger) {
    try {
      // Verify the requested perspective ID
      IPerspectiveRegistry reg = workbench.getPerspectiveRegistry();
      IPerspectiveDescriptor perspective = reg.findPerspectiveWithId(perspId);
      if (perspective == null) {
        logger.log(statusFactory.error("Unable to open perspective: " + perspId));
        return false;
      }

      // Get "Open Behavior" preference.
      String pref = store.getString(IWorkbenchPreferenceConstants.OPEN_NEW_PERSPECTIVE);

      // Implement open behavior.
      if (pref.equals(IWorkbenchPreferenceConstants.OPEN_PERSPECTIVE_WINDOW)) {
        workbench.openWorkbenchWindow(perspId, input);
      } else if (pref.equals(IWorkbenchPreferenceConstants.OPEN_PERSPECTIVE_REPLACE)) {
        IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
        IWorkbenchPage activePage = window.getActivePage();
        if (activePage != null) {
          activePage.setPerspective(perspective);
        } else {
          window.openPage(perspId, input);
        }
      }

      Shell shell = workbench.getActiveWorkbenchWindow().getShell();
      shell.setMinimized(false);
      shell.forceActive();
      logger.log(statusFactory.info("Opened perspective: " + perspId));
      return true;
    } catch (WorkbenchException e) {
      logger.log(statusFactory.error("Error opening perspective: " + e.getMessage(), e));
      return false;
    }
  }
 /**
  * Log message
  *
  * @param severity the severity of the message
  * @param message the message
  * @param e the exception
  */
 private void logMessage(int severity, String message, Throwable e) {
   if (DEBUG) {
     String what = (severity == IStatus.ERROR) ? (e != null ? "Exception" : "Error") : "Warning";
     System.out.println(what + " in Optet plugin: " + message);
     if (e != null) {
       e.printStackTrace();
     }
   }
   IStatus status = createStatus(severity, message, e);
   // Activator.getDefault().getLog().log(status);
   log.log(status);
 }
Example #16
0
  /** Generates an error in the Eclipse error log. Note that most people never look at it! */
  public static void error(
      CompilationUnitDeclaration cud, String message, String bundleName, Throwable error) {
    Bundle bundle = Platform.getBundle(bundleName);
    if (bundle == null) {
      System.err.printf(
          "Can't find bundle %s while trying to report error:\n%s\n", bundleName, message);
      return;
    }

    ILog log = Platform.getLog(bundle);

    log.log(new Status(IStatus.ERROR, bundleName, message, error));
    if (cud != null)
      EclipseAST.addProblemToCompilationResult(cud, false, message + " - See error log.", 0, 0);
  }
Example #17
0
  /**
   * 输入出日志
   *
   * @param message 日志信息
   */
  private void println(String message, int status, Class<?> clazz) {
    if (isDebug) {
      // 获取类信息
      String msg = clazz.toString();
      msg = msg.substring(msg.indexOf(" ") + 1);

      // 打印消息
      if (null != log) {
        log.log(
            new Status(
                status,
                AutoCodePlugin.PLUGIN_ID,
                new StringBuffer("\n").append(msg).append(": ").append(message).toString()));
      } else {
        // 定义零时字符串
        StringBuffer buffer = new StringBuffer();

        // 判断类型
        switch (status) {
          case IStatus.INFO:
            buffer.append("[INFO] ");
            break;
          case IStatus.ERROR:
            buffer.append("[ERROR] ");
            break;
          case IStatus.WARNING:
            buffer.append("[WARNING] ");
            break;
          default:
            buffer.append("[DEBUG] ");
            break;
        }

        // 设置日志格式
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println(
            buffer
                .append(format.format((new Date()).getTime()))
                .append(" ")
                .append(msg)
                .append(": ")
                .append(message)
                .toString());
      }
    }
  }
 private EObject getEObject(IModelObject modelObject) {
   if (modelObject instanceof Description
       || modelObject instanceof OperationFault
       || modelObject instanceof OperationParameter
       || modelObject instanceof ServiceInterface
       || modelObject instanceof ServiceOperation
       || modelObject instanceof ISchema
       || modelObject instanceof IType
       || modelObject instanceof IElement
       || modelObject instanceof IFacet) {
     return modelObject.getComponent();
   }
   logger.log(
       new Status(
           IStatus.WARNING,
           Activator.PLUGIN_ID,
           "EObject not found for " + modelObject)); // $NON-NLS-1$
   return null;
 }
  /**
   * The action has been activated. The argument of the method represents the 'real' action sitting
   * in the workbench UI.
   *
   * @see IWorkbenchWindowActionDelegate#run
   */
  @Override
  public void run(final IAction action) {

    final IEditorPart part =
        PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
    if (!(part instanceof AbstractTextEditor)) {
      return;
    }
    final ITextEditor editor = (ITextEditor) part;
    final IDocumentProvider dp = editor.getDocumentProvider();
    final IDocument doc = dp.getDocument(editor.getEditorInput());
    try {
      impexClient.validateImpex(doc.get(0, doc.getLength()));
    } catch (final BadLocationException e) {

      logger.log(
          new Status(Status.ERROR, Activator.PLUGIN_ID, Status.ERROR, "Bad Location Exception", e));
    }
  }
 /**
  * Add this exception to the collector. If a log was specified in the constructor then the
  * exception will be output to the log. You can retreive exceptions using <code>getStatus</code>.
  *
  * @param exception the exception to collect
  */
 public void handleException(CoreException exception) {
   // log the exception if we have a log
   if (log != null) {
     log.log(new Status(severity, pluginId, 0, message, exception));
   }
   // Record each status individually to flatten the resulting multi-status
   IStatus exceptionStatus = exception.getStatus();
   // Wrap the exception so the stack trace is not lost.
   IStatus status =
       new Status(
           exceptionStatus.getSeverity(),
           exceptionStatus.getPlugin(),
           exceptionStatus.getCode(),
           exceptionStatus.getMessage(),
           exception);
   recordStatus(status);
   IStatus[] children = status.getChildren();
   for (int i = 0; i < children.length; i++) {
     IStatus status2 = children[i];
     recordStatus(status2);
   }
 }
Example #21
0
  @Override
  protected void append(ILoggingEvent logEvent) {
    int severity = 0;
    switch (logEvent.getLevel().levelInt) {
      case Level.ERROR_INT:
        severity = IStatus.ERROR;
        break;
      case Level.WARN_INT:
        severity = IStatus.WARNING;
        break;
      case Level.INFO_INT:
        severity = IStatus.INFO;
        break;
      default:
        return;
    }

    IStatus status =
        new Status(severity, BUNDLE_ID, logEvent.getFormattedMessage(), getThrowable(logEvent));
    ILog eclipseLog = Platform.getLog(getSelfBundle());
    eclipseLog.log(status);
  }
Example #22
0
  /** @since 1.1 */
  @ConfinedToDsfExecutor("fSession#getExecutor")
  public AbstractCLIProcess(ICommandControlService commandControl) throws IOException {
    fSession = commandControl.getSession();
    fCommandControl = commandControl;

    commandControl.addEventListener(this);
    commandControl.addCommandListener(this);

    PipedInputStream miInConsolePipe = null;
    PipedOutputStream miOutConsolePipe = null;
    PipedInputStream miInLogPipe = null;
    PipedOutputStream miOutLogPipe = null;

    try {
      // Using a LargePipedInputStream see https://bugs.eclipse.org/bugs/show_bug.cgi?id=223154
      miOutConsolePipe = new PipedOutputStream();
      miInConsolePipe = new LargePipedInputStream(miOutConsolePipe);
      miOutLogPipe = new PipedOutputStream();
      miInLogPipe = new LargePipedInputStream(miOutLogPipe);
    } catch (IOException e) {
      ILog log = GdbPlugin.getDefault().getLog();
      if (log != null) {
        log.log(
            new Status(
                IStatus.ERROR,
                GdbPlugin.PLUGIN_ID,
                -1,
                "Error when creating log pipes",
                e)); //$NON-NLS-1$
      }
    }
    // Must initialize these outside of the try block because they are final.
    fMIOutConsolePipe = miOutConsolePipe;
    fMIInConsolePipe = miInConsolePipe;
    fMIOutLogPipe = miOutLogPipe;
    fMIInLogPipe = miInLogPipe;
  }
Example #23
0
 public static void log(IStatus status) {
   LOG.log(status);
 }
 public static void log(IStatus status) {
   ILog log = Platform.getLog(context.getBundle());
   if (log != null) log.log(status);
 }
Example #25
0
 public static void log(int status, String message, Throwable throwable) {
   logger.log(new Status(status, message, PLUGIN_ID, throwable));
 }
 /** @param msg */
 public static void log(final String msg) {
   final ILog log = getDefault().getLog();
   final Status status = new Status(4, PLUGIN_ID, 4, msg, null);
   log.log(status);
 }
Example #27
0
 public static void log(IStatus status) {
   ILog log = getLog();
   if (log != null) {
     log.log(status);
   }
 }
 private static void handleTerminationError() {
   Activator plugin = Activator.getDefault();
   ILog log = plugin.getLog();
   String pluginId = plugin.getBundle().getSymbolicName();
   log.log(new Status(IStatus.ERROR, pluginId, "Could not eliminate OSGi launch"));
 }
Example #29
0
 public static void logMessage(String msg, int level, Exception e) {
   if (logInstance != null) logInstance.log(new Status(level, PLUGIN_ID, Status.OK, msg, e));
 }