Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Pull request for issues #42, #69 #105

Closed
wants to merge 1 commit into from

3 participants

@kiran-bhat
  1. Delete of imported theme
  2. Do not reapply theme on clicking ok
unknown 1. Support for deleting imported themes
2. Do not reapply theme on clicking ok
f826fda
@fhd
Owner

Completely missed this pull request, I'm sorry :( Still haven't figured out how to have GitHub notify me about organisation issues/PRs.

If you're still interested in having this merged, could you please change the indentation level to 4 spaces? It's easier if we change this before the actual review.

@paulvi

Still haven't figured out how to have GitHub notify me about organisation issues/PRs

GitHub should be spamming into your email box about every new issue.

@fhd
Owner

GitHub should be spamming into your email box about every new issue.

Yeah I figured that out in the mean time, had to be configured for the organisation.

@paulvi

Hint: use special email for GitHub, it will really get spammed.

@fhd
Owner

Guess the comments won't be addressed, it's been almost two years.

@fhd fhd closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 29, 2012
  1. 1. Support for deleting imported themes

    unknown authored
    2. Do not reapply theme on clicking ok
This page is out of date. Refresh to see the latest.
View
36 com.github.eclipsecolortheme/src/com/github/eclipsecolortheme/ColorTheme.java
@@ -49,4 +49,40 @@ public void setWebsite(String website) {
public void setEntries(Map<String, ColorThemeSetting> entries) {
this.entries = entries;
}
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
+ return result;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (!(obj instanceof ColorTheme)) {
+ return false;
+ }
+ ColorTheme other = (ColorTheme) obj;
+ if (id == null) {
+ if (other.id != null) {
+ return false;
+ }
+ } else if (!id.equals(other.id)) {
+ return false;
+ }
+ return true;
+ }
}
View
53 com.github.eclipsecolortheme/src/com/github/eclipsecolortheme/ColorThemeManager.java
@@ -5,6 +5,7 @@
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
@@ -248,4 +249,56 @@ public ColorTheme saveTheme(String content) {
return null;
}
}
+ /**
+ * Check if given theme is imported
+ * @param themeID
+ * @return
+ */
+ public boolean isImportedTheme(String themeID) {
+ if(themeID!=null) {
+ Map<String,ColorTheme> imported=new HashMap<String, ColorTheme>();
+ readImportedThemes(imported);
+ return imported.containsKey(themeID);
+ }
+ return false;
+ }
+ /**
+ * Delete an imported theme from the preference store
+ * @param theme
+ * @return
+ */
+ public boolean deleteImportedTheme(ColorTheme theme) {
+ IPreferenceStore store=getPreferenceStore();
+ for(int i=1;;i++) {
+ String xml=store.getString("importedColorTheme" + i);
+ if(xml==null||xml.isEmpty()) {
+ break;
+ }
+ try {
+ if(theme.equals(parseTheme(new ByteArrayInputStream(xml.getBytes("UTF-8"))))) {
+ store.setToDefault("importedColorTheme" + i);
+ themes.remove(theme.getName());
+ //left shift all stored themes
+ for(int j=i+1;;j++) {
+ String nextXML=store.getString("importedColorTheme" + j);
+ if(nextXML==null||nextXML.isEmpty()) {
+ break;
+ }
+ store.setValue("importedColorTheme" + (j-1), nextXML);
+ }
+ return true;
+ }
+ } catch (UnsupportedEncodingException e) {
+ e.printStackTrace();
+ } catch (ParserConfigurationException e) {
+ e.printStackTrace();
+ } catch (SAXException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ }
+ return false;
+ }
}
View
22 com.github.eclipsecolortheme/src/com/github/eclipsecolortheme/preferences/ColorThemePreferencePage.java
@@ -55,6 +55,7 @@
private Label authorLabel;
private Link websiteLink;
private Browser browser;
+ private Button deleteThemebutton;
/** Creates a new color theme preference page. */
public ColorThemePreferencePage() {
@@ -107,6 +108,11 @@ protected Control createContents(Composite parent) {
themeSelectionList.addListener(SWT.Selection, new Listener() {
public void handleEvent(Event event) {
+ if(colorThemeManager.isImportedTheme(themeSelectionList.getSelection()[0])) {
+ deleteThemebutton.setEnabled(true);
+ } else {
+ deleteThemebutton.setEnabled(true);
+ }
updateDetails(colorThemeManager.getTheme(
themeSelectionList.getSelection()[0]));
}
@@ -172,6 +178,10 @@ private void updateDetails(ColorTheme theme) {
@Override
public boolean performOk() {
+ String selectedThemeName=themeSelectionList.getSelection()[0];
+ if(selectedThemeName!=null&&selectedThemeName.equals(getPreferenceStore().getString("colorTheme"))) {
+ return true;
+ }
IWorkbenchPage activePage = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow()
.getActivePage();
@@ -204,7 +214,6 @@ public boolean performOk() {
new IEditorReference[editorsToClose.size()]), true);
}
- String selectedThemeName = themeSelectionList.getSelection()[0];
getPreferenceStore().setValue("colorTheme", selectedThemeName);
colorThemeManager.applyTheme(selectedThemeName);
@@ -255,6 +264,17 @@ public void widgetSelected(SelectionEvent event) {
}
}
});
+ deleteThemebutton = new Button(parent, SWT.NONE);
+ deleteThemebutton.setText("&Delete");
+ deleteThemebutton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent event) {
+ colorThemeManager.deleteImportedTheme(colorThemeManager
+ .getTheme(themeSelectionList.getSelection()[0]));
+ reloadThemeSelectionList();
+ }
+ });
+ deleteThemebutton.setEnabled(false);
}
private void reloadThemeSelectionList() {
Something went wrong with that request. Please try again.