Plugin bug hotfix

master
skylarmt 9 years ago
parent caaeb72e7b
commit 52fc1b1521

@ -250,10 +250,11 @@ public class InstallPlugin extends javax.swing.JInternalFrame {
return;
}
try {
String fsep = System.getProperty("file.separator");
Files.copy(f,
new File(
System.getProperty("user.home")
+ "\\.symat\\plugins\\"
+ fsep + ".symat" + fsep + "plugins" + fsep
+ f.getName()));
Main.maingui.reloadRibbon();
JOptionPane.showInternalMessageDialog(this,
@ -263,7 +264,15 @@ public class InstallPlugin extends javax.swing.JInternalFrame {
} catch (IOException ex) {
Debug.stacktrace(ex);
JOptionPane.showInternalMessageDialog(this,
"Error: could not copy plugin file: " + ex.getMessage(),
"Error: could not install plugin file: " + ex.getMessage(),
"Error",
JOptionPane.ERROR_MESSAGE);
} catch (IllegalArgumentException ex) {
Debug.stacktrace(ex);
JOptionPane.showInternalMessageDialog(this,
"Error: could not install plugin file."
+ "\nIs a plugin with the same name already "
+ "installed?\n(" + ex.getMessage() + ")",
"Error",
JOptionPane.ERROR_MESSAGE);
} catch (Exception ex) {

@ -115,7 +115,7 @@ public class Main extends JRibbonFrame {
/**
* Version number, for updates and //needs in scripts
*/
public static final double APP_CODE = 19;
public static final double APP_CODE = 20;
/**
* Base URL for building API calls
*/
@ -289,7 +289,8 @@ public class Main extends JRibbonFrame {
pluginband.setResizePolicies((List) Arrays.asList(
new CoreRibbonResizePolicies.Mirror(pluginband.getControlPanel())));
pluginband.addCommandButton(installpluginbtn, RibbonElementPriority.TOP);
File dir = new File(System.getProperty("user.home") + "\\.symat\\plugins");
String fsep = System.getProperty("file.separator");
File dir = new File(System.getProperty("user.home") + fsep + ".symat" + fsep + "plugins");
dir.mkdirs();
File[] files = dir.listFiles(new FilenameFilter() {
@Override
@ -304,18 +305,21 @@ public class Main extends JRibbonFrame {
galleryVisibleButtonCounts.put(RibbonElementPriority.TOP, 2);
List<StringValuePair<List<JCommandToggleButton>>> appGalleryButtons = new ArrayList<>();
List<JCommandToggleButton> appGalleryButtonsList = new ArrayList<>();
for (File pl : files) {
try {
LoadPlugin lp = new LoadPlugin(pl);
appGalleryButtonsList.add(lp.getGalleryBtn());
} catch (Exception ex) {
Debug.stacktrace(ex);
System.err.println("Error loading plugin: "+ex.getMessage());
if (files != null) {
for (File pl : files) {
LoadPlugin lp;
try {
lp = new LoadPlugin(pl);
appGalleryButtonsList.add(lp.getGalleryBtn());
} catch (Exception ex) {
Debug.stacktrace(ex);
System.err.println("Error loading plugin " + pl.getName() + ": " + ex.getMessage());
}
}
}
appGalleryButtons.add(new StringValuePair<List<JCommandToggleButton>>("Plugins",
appGalleryButtonsList));
appGalleryButtons.add(new StringValuePair<>("Plugins",
appGalleryButtonsList));
pluginband.addRibbonGallery("Plugins", appGalleryButtons,
galleryVisibleButtonCounts, 5, 3,
RibbonElementPriority.TOP);
@ -343,7 +347,13 @@ public class Main extends JRibbonFrame {
JRibbonBand collabband = new JRibbonBand("Team", null);
//JRibbonBand getpluginband = new JRibbonBand("Install", null);
loadPlugins();
try {
loadPlugins();
} catch (Exception ex) {
JOptionPane.showMessageDialog(this,
"An error occurred while loading plugins: "
+ ex.getMessage());
}
shellbtn.addActionListener(new ActionListener() {
@Override

@ -48,8 +48,6 @@ package net.apocalypselabs.symat;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
@ -375,8 +373,6 @@ public class PackagePlugin extends javax.swing.JInternalFrame {
p.setIcon(icon);
if (p.getTitle().equals("")
|| p.getAuthor().equals("")
|| p.getLongTitle().equals("")
|| p.getDesc().equals("")
|| p.getPackage().equals("")
|| p.getVersion().equals("")
|| p.getScript().equals("")

@ -55,6 +55,7 @@ import java.io.IOException;
import java.io.ObjectInputStream;
import net.apocalypselabs.symat.CodeRunner;
import net.apocalypselabs.symat.Debug;
import net.apocalypselabs.symat.Main;
import org.pushingpixels.flamingo.api.common.JCommandButton;
import org.pushingpixels.flamingo.api.common.JCommandToggleButton;
import org.pushingpixels.flamingo.api.common.RichTooltip;
@ -82,15 +83,22 @@ public class LoadPlugin {
}
private ResizableIcon getRibbonIcon() {
return ImageWrapperResizableIcon.getIcon(
p.getIcon().getImage(),
new Dimension(100, 76));
try {
ResizableIcon ico = ImageWrapperResizableIcon.getIcon(
p.getIcon().getImage(),
new Dimension(100, 76));
return ico;
} catch (Exception ex) {
return Main.getRibbonIcon("plugin");
}
}
public JCommandButton getRibbonBtn() {
JCommandButton b = new JCommandButton(p.getTitle(), getRibbonIcon());
b.setActionRichTooltip(new RichTooltip(p.getLongTitle(),
p.getDesc()));
JCommandButton b = new JCommandButton((p.getTitle().equals("") ? "Untitled" : p.getTitle()), getRibbonIcon());
if (!p.getLongTitle().equals("")) {
b.setActionRichTooltip(new RichTooltip(p.getLongTitle(),
(p.getDesc().equals("") ? " " : p.getDesc())));
}
b.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
@ -102,9 +110,11 @@ public class LoadPlugin {
}
public JCommandToggleButton getGalleryBtn() {
JCommandToggleButton b = new JCommandToggleButton(p.getTitle(), getRibbonIcon());
b.setActionRichTooltip(new RichTooltip(p.getLongTitle(),
p.getDesc()));
JCommandToggleButton b = new JCommandToggleButton((p.getTitle().equals("") ? "Untitled" : p.getTitle()), getRibbonIcon());
if (!p.getLongTitle().equals("")) {
b.setActionRichTooltip(new RichTooltip(p.getLongTitle(),
(p.getDesc().equals("") ? " " : p.getDesc())));
}
b.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {

Loading…
Cancel
Save