Plugin bug hotfix

master
skylarmt 9 years ago
parent caaeb72e7b
commit 52fc1b1521

@ -250,10 +250,11 @@ public class InstallPlugin extends javax.swing.JInternalFrame {
return; return;
} }
try { try {
String fsep = System.getProperty("file.separator");
Files.copy(f, Files.copy(f,
new File( new File(
System.getProperty("user.home") System.getProperty("user.home")
+ "\\.symat\\plugins\\" + fsep + ".symat" + fsep + "plugins" + fsep
+ f.getName())); + f.getName()));
Main.maingui.reloadRibbon(); Main.maingui.reloadRibbon();
JOptionPane.showInternalMessageDialog(this, JOptionPane.showInternalMessageDialog(this,
@ -263,7 +264,15 @@ public class InstallPlugin extends javax.swing.JInternalFrame {
} catch (IOException ex) { } catch (IOException ex) {
Debug.stacktrace(ex); Debug.stacktrace(ex);
JOptionPane.showInternalMessageDialog(this, 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", "Error",
JOptionPane.ERROR_MESSAGE); JOptionPane.ERROR_MESSAGE);
} catch (Exception ex) { } catch (Exception ex) {

@ -115,7 +115,7 @@ public class Main extends JRibbonFrame {
/** /**
* Version number, for updates and //needs in scripts * 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 * Base URL for building API calls
*/ */
@ -289,7 +289,8 @@ public class Main extends JRibbonFrame {
pluginband.setResizePolicies((List) Arrays.asList( pluginband.setResizePolicies((List) Arrays.asList(
new CoreRibbonResizePolicies.Mirror(pluginband.getControlPanel()))); new CoreRibbonResizePolicies.Mirror(pluginband.getControlPanel())));
pluginband.addCommandButton(installpluginbtn, RibbonElementPriority.TOP); 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(); dir.mkdirs();
File[] files = dir.listFiles(new FilenameFilter() { File[] files = dir.listFiles(new FilenameFilter() {
@Override @Override
@ -304,18 +305,21 @@ public class Main extends JRibbonFrame {
galleryVisibleButtonCounts.put(RibbonElementPriority.TOP, 2); galleryVisibleButtonCounts.put(RibbonElementPriority.TOP, 2);
List<StringValuePair<List<JCommandToggleButton>>> appGalleryButtons = new ArrayList<>(); List<StringValuePair<List<JCommandToggleButton>>> appGalleryButtons = new ArrayList<>();
List<JCommandToggleButton> appGalleryButtonsList = new ArrayList<>(); List<JCommandToggleButton> appGalleryButtonsList = new ArrayList<>();
for (File pl : files) { if (files != null) {
try { for (File pl : files) {
LoadPlugin lp = new LoadPlugin(pl); LoadPlugin lp;
appGalleryButtonsList.add(lp.getGalleryBtn()); try {
} catch (Exception ex) { lp = new LoadPlugin(pl);
Debug.stacktrace(ex); appGalleryButtonsList.add(lp.getGalleryBtn());
System.err.println("Error loading plugin: "+ex.getMessage()); } catch (Exception ex) {
Debug.stacktrace(ex);
System.err.println("Error loading plugin " + pl.getName() + ": " + ex.getMessage());
}
} }
} }
appGalleryButtons.add(new StringValuePair<List<JCommandToggleButton>>("Plugins", appGalleryButtons.add(new StringValuePair<>("Plugins",
appGalleryButtonsList)); appGalleryButtonsList));
pluginband.addRibbonGallery("Plugins", appGalleryButtons, pluginband.addRibbonGallery("Plugins", appGalleryButtons,
galleryVisibleButtonCounts, 5, 3, galleryVisibleButtonCounts, 5, 3,
RibbonElementPriority.TOP); RibbonElementPriority.TOP);
@ -343,7 +347,13 @@ public class Main extends JRibbonFrame {
JRibbonBand collabband = new JRibbonBand("Team", null); JRibbonBand collabband = new JRibbonBand("Team", null);
//JRibbonBand getpluginband = new JRibbonBand("Install", 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() { shellbtn.addActionListener(new ActionListener() {
@Override @Override

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

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

Loading…
Cancel
Save