Search in sources :

Example 1 with SearchPattern

use of org.eclipse.titan.log.viewer.search.SearchPattern in project titan.EclipsePlug-ins by eclipse.

the class LogSearchPage method writeConfiguration.

private void writeConfiguration() {
    IDialogSettings settings = getDialogSettings();
    int historySize = Math.min(previousSearchPatterns.size(), HISTORY_SIZE);
    settings.put("historySize", historySize);
    for (int i = 0; i < historySize; ++i) {
        IDialogSettings histSettings = settings.addNewSection("history" + i);
        SearchPattern pattern = previousSearchPatterns.get(i);
        pattern.store(histSettings);
    }
}
Also used : IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) SearchPattern(org.eclipse.titan.log.viewer.search.SearchPattern)

Example 2 with SearchPattern

use of org.eclipse.titan.log.viewer.search.SearchPattern in project titan.EclipsePlug-ins by eclipse.

the class LogSearchPage method getPattern.

private SearchPattern getPattern() {
    String string = this.searchString.getText();
    SearchPattern match = findInPrevious(string);
    if (match != null) {
        previousSearchPatterns.remove(match);
    }
    Map<String, Boolean> events = new TreeMap<String, Boolean>();
    for (int i = 0; i < searchFor.length - ALL_NONE_BUTTONS; ++i) {
        events.put(searchFor[i].getData().toString(), searchFor[i].getSelection());
    }
    Map<Field, Boolean> limitToMap = new HashMap<Field, Boolean>();
    for (Button aLimitTo : limitTo) {
        limitToMap.put(Field.valueOf(aLimitTo.getData().toString()), aLimitTo.getSelection());
    }
    match = new SearchPattern(string, caseSensitive.getSelection(), regularExpression.getSelection(), events, limitToMap, getContainer().getSelectedScope(), getContainer().getSelectedWorkingSets());
    previousSearchPatterns.add(0, match);
    return match;
}
Also used : Field(org.eclipse.titan.log.viewer.models.FilterPattern.Field) HashMap(java.util.HashMap) Button(org.eclipse.swt.widgets.Button) SearchPattern(org.eclipse.titan.log.viewer.search.SearchPattern) TreeMap(java.util.TreeMap)

Example 3 with SearchPattern

use of org.eclipse.titan.log.viewer.search.SearchPattern in project titan.EclipsePlug-ins by eclipse.

the class LogSearchPage method handlePatternSelected.

private void handlePatternSelected() {
    int selectionIndex = searchString.getSelectionIndex();
    if (selectionIndex < 0 || selectionIndex >= previousSearchPatterns.size()) {
        return;
    }
    SearchPattern pattern = previousSearchPatterns.get(selectionIndex);
    SortedMap<String, Boolean> events = pattern.getEvents();
    for (int i = 0; i < searchFor.length - ALL_NONE_BUTTONS; ++i) {
        searchFor[i].setSelection(events.get(searchFor[i].getData().toString()));
    }
    Map<Field, Boolean> limitToMap = pattern.getLimitTo();
    for (Button button : limitTo) {
        button.setSelection(limitToMap.get(button.getData()));
    }
    searchString.setText(pattern.getSearchString());
    caseSensitive.setSelection(pattern.isCaseSensitive());
    regularExpression.setSelection(pattern.isRegularExpression());
    if (pattern.getWorkingSets() != null) {
        getContainer().setSelectedWorkingSets(pattern.getWorkingSets());
    } else {
        getContainer().setSelectedScope(pattern.getScope());
    }
}
Also used : Field(org.eclipse.titan.log.viewer.models.FilterPattern.Field) Button(org.eclipse.swt.widgets.Button) SearchPattern(org.eclipse.titan.log.viewer.search.SearchPattern)

Example 4 with SearchPattern

use of org.eclipse.titan.log.viewer.search.SearchPattern in project titan.EclipsePlug-ins by eclipse.

the class LogSearchPage method readConfiguration.

private void readConfiguration() {
    IDialogSettings settings = getDialogSettings();
    int historySize;
    try {
        historySize = settings.getInt("historySize");
    } catch (NumberFormatException e) {
        historySize = HISTORY_SIZE;
    }
    try {
        for (int i = 0; i < historySize; ++i) {
            IDialogSettings histSettings = settings.getSection("history" + i);
            if (histSettings != null) {
                SearchPattern data = SearchPattern.create(histSettings);
                if (data != null) {
                    previousSearchPatterns.add(data);
                }
            }
        }
    } catch (NumberFormatException e) {
        ErrorReporter.logExceptionStackTrace(e);
        TitanLogExceptionHandler.handleException(new TechnicalException(Messages.getString("Could not read the configuration of the page. Reason: ") + e.getMessage()));
    }
}
Also used : TechnicalException(org.eclipse.titan.log.viewer.exceptions.TechnicalException) IDialogSettings(org.eclipse.jface.dialogs.IDialogSettings) SearchPattern(org.eclipse.titan.log.viewer.search.SearchPattern)

Aggregations

SearchPattern (org.eclipse.titan.log.viewer.search.SearchPattern)4 IDialogSettings (org.eclipse.jface.dialogs.IDialogSettings)2 Button (org.eclipse.swt.widgets.Button)2 Field (org.eclipse.titan.log.viewer.models.FilterPattern.Field)2 HashMap (java.util.HashMap)1 TreeMap (java.util.TreeMap)1 TechnicalException (org.eclipse.titan.log.viewer.exceptions.TechnicalException)1