Skip to content
This repository has been archived by the owner on Oct 15, 2021. It is now read-only.

Commit

Permalink
Dirty hack to fix the bug 873148
Browse files Browse the repository at this point in the history
  • Loading branch information
mbastian committed Oct 13, 2011
1 parent 00a4e71 commit d9942ae
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 11 deletions.
2 changes: 1 addition & 1 deletion DesktopBranding/manifest.mf
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ OpenIDE-Module: org.gephi.branding.desktop
OpenIDE-Module-Install: org/gephi/branding/desktop/Installer.class
OpenIDE-Module-Layer: org/gephi/branding/desktop/layer.xml
OpenIDE-Module-Localizing-Bundle: org/gephi/branding/desktop/Bundle.properties
OpenIDE-Module-Specification-Version: 0.8.0.4
OpenIDE-Module-Specification-Version: 0.8.0.5

8 changes: 4 additions & 4 deletions DesktopBranding/nbproject/genfiles.properties
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
build.xml.data.CRC32=485008bd
build.xml.data.CRC32=1f390079
build.xml.script.CRC32=3a13ec7e
build.xml.stylesheet.CRC32=[email protected].1
build.xml.stylesheet.CRC32=[email protected].2
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
nbproject/build-impl.xml.data.CRC32=485008bd
nbproject/build-impl.xml.data.CRC32=1f390079
nbproject/build-impl.xml.script.CRC32=3c0d63a0
nbproject/build-impl.xml.stylesheet.CRC32=[email protected].1
nbproject/build-impl.xml.stylesheet.CRC32=[email protected].2
6 changes: 0 additions & 6 deletions DesktopBranding/nbproject/project.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,6 @@
<specification-version>1.16.1.1</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.modules.autoupdate.services</code-name-base>
<run-dependency>
<specification-version>1.16.1</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.modules.sendopts</code-name-base>
<build-prerequisite/>
Expand Down
53 changes: 53 additions & 0 deletions DesktopBranding/src/org/gephi/branding/desktop/Installer.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,19 @@ Development and Distribution License("CDDL") (collectively, the
*/
package org.gephi.branding.desktop;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import org.gephi.branding.desktop.reporter.ReporterHandler;
import org.gephi.desktop.project.api.ProjectControllerUI;
import org.gephi.project.api.ProjectController;
import org.openide.LifecycleManager;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
import org.openide.modules.ModuleInstall;
import org.openide.util.Lookup;
import org.openide.util.NbBundle;
Expand All @@ -61,6 +68,14 @@ public class Installer extends ModuleInstall {

@Override
public void restored() {
try {
//Fix old preview loading - bug 873148
doDisable("org.gephi.preview");
} catch (Exception ex) {
ex.printStackTrace();
}

//Init
initGephi();

//TopTab
Expand Down Expand Up @@ -108,4 +123,42 @@ public boolean closing() {
Lookup.getDefault().lookup(ProjectController.class).closeCurrentProject();
return true;
}

public void doDisable(String codeName) throws Exception {
FileObject confFileObject = FileUtil.getConfigFile("Modules/" + codeName.replace('.', '-') + ".xml");

if (confFileObject != null && confFileObject.isValid()) {
StringBuilder outputBuilder = new StringBuilder();

String matchOptionsLine = "<param name=\"enabled\">true";

//In
File confFile = FileUtil.toFile(confFileObject);
BufferedReader reader = new BufferedReader(new FileReader(confFile));
String strLine;
boolean matched = false;
while ((strLine = reader.readLine()) != null) {
if (strLine.indexOf(matchOptionsLine) != -1) {
matched = true;
strLine = strLine.replaceAll("<param name=\"enabled\">true</param>", "<param name=\"enabled\">false</param>");
}
outputBuilder.append(strLine);
outputBuilder.append("\n");
}
reader.close();

//Out
FileWriter writer = new FileWriter(confFile);
writer.write(outputBuilder.toString());
writer.close();

if (matched) {
JOptionPane.showMessageDialog(null, "A custom patch to import your 0.8 alpha settings has been applied and Gephi needs to restart now. Sorry for the inconvenience.");

//Restart
LifecycleManager.getDefault().markForRestart();
LifecycleManager.getDefault().exit();
}
}
}
}

0 comments on commit d9942ae

Please sign in to comment.