Skip to content

Commit

Permalink
Merge pull request #311 from cbeust/feautre/154_favorite_static_import
Browse files Browse the repository at this point in the history
Add Eclipse Favorites - for static import of org.testng.Assert.*
  • Loading branch information
missedone authored Jan 31, 2017
2 parents 04cfadd + f99a645 commit f60bc7a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Supported Metrics:
* feature #300: testng eclipse plugin results view should allow the user to copy the test data that is displayed for test iterations
* fixed #279: java.lang.SecurityException: class "org.osgi.framework.BundleException"'s signer information does not match signer information of other classes in the same package
* feature #102: Template XML file should should offer workspace-related location
* feature #152: add more templates for quickly adding new method for 'setup' and 'teardown'
* feature #154: Add Eclipse Favorites - for static import of 'org.testng.Assert.*'

## 6.10

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
package org.testng.eclipse.ui.preferences;

import java.io.IOException;
import java.util.Arrays;
import java.util.LinkedHashSet;
import java.util.Set;

import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.jdt.ui.PreferenceConstants;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.ui.preferences.ScopedPreferenceStore;
import org.testng.eclipse.TestNGPlugin;
import org.testng.eclipse.TestNGPluginConstants;

import com.google.common.base.Joiner;

/**
* Class used to initialize default preference values.
*/
Expand All @@ -29,6 +38,26 @@ public void initializeDefaultPreferences() {
true);
store.setDefault(TestNGPluginConstants.S_VIEW_TITLE_SHOW_CASE_NAME,
true);

initializeFavoriteStatic();
}

private void initializeFavoriteStatic() {
IPreferenceStore jdtPrefStore = PreferenceConstants.getPreferenceStore();

Set<String> favorites = new LinkedHashSet<>();
String existingFavorites = jdtPrefStore.getString(PreferenceConstants.CODEASSIST_FAVORITE_STATIC_MEMBERS);
if (!existingFavorites.isEmpty()) {
favorites.addAll(Arrays.asList(existingFavorites.split(";")));
}

favorites.add("org.testng.Assert.*");

jdtPrefStore.setValue(PreferenceConstants.CODEASSIST_FAVORITE_STATIC_MEMBERS,
Joiner.on(";").join(favorites));
try {
((ScopedPreferenceStore) jdtPrefStore).save();
} catch (IOException e) {
}
}
}

0 comments on commit f60bc7a

Please sign in to comment.