Skip to content

Commit

Permalink
Added Plug-In Store
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreaAlbanese committed Jun 6, 2021
1 parent 4c7256c commit 8001610
Show file tree
Hide file tree
Showing 30 changed files with 1,485 additions and 6 deletions.
26 changes: 24 additions & 2 deletions Logisim-Fork/.classpath
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path=""/>
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/libs"/>
<classpathentry kind="output" path="bin"/>
<classpathentry including="**/*.java" kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
6 changes: 6 additions & 0 deletions Logisim-Fork/.project
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
6 changes: 6 additions & 0 deletions Logisim-Fork/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary=
org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.APILeak=warning
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
Expand All @@ -18,6 +20,7 @@ org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
Expand Down Expand Up @@ -62,6 +65,7 @@ org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warn
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
Expand Down Expand Up @@ -98,3 +102,5 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
4 changes: 4 additions & 0 deletions Logisim-Fork/.settings/org.eclipse.m2e.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
7 changes: 7 additions & 0 deletions Logisim-Fork/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@
<artifactId>colorpicker</artifactId>
<version>1.3.1</version>
</dependency>

<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.6</version>
</dependency>
</dependencies>

<repositories>
Expand Down
2 changes: 1 addition & 1 deletion Logisim-Fork/src/main/java/com/cburch/logisim/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

public class Main {
// current version
public static final LogisimVersion VERSION = LogisimVersion.get(2, 16, 1, 2, LogisimVersion.getVariantFromFile());
public static final LogisimVersion VERSION = LogisimVersion.get(2, 16, 1, 3, LogisimVersion.getVariantFromFile());
// the version of the file you're using, equals to current version if new file
public static LogisimVersion FILE_VERSION;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import javax.swing.filechooser.FileFilter;

import com.cburch.logisim.Main;
import com.cburch.logisim.plugin.PluginLoader;
import com.cburch.logisim.std.Builtin;
import com.cburch.logisim.tools.Library;
import com.cburch.logisim.util.JFileChoosers;
Expand Down Expand Up @@ -135,6 +136,11 @@ public String getDescriptor(Library lib) {
// helper methods
//
File getFileFor(String name, FileFilter filter) {
//Check if the library is in plugin list
String ret=PluginLoader.check(name);
if(ret!=null) {
name=ret;
}
// Determine the actual file name.
File file = new File(name);
if (!file.isAbsolute()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
import javax.swing.JMenu;
import javax.swing.JMenuItem;

import com.cburch.logisim.gui.plugin.PluginFrame;
import com.cburch.logisim.plugin.PluginLoader;
import com.cburch.logisim.plugin.PluginUtils;
import com.cburch.logisim.proj.Project;

class MenuProject extends Menu {
Expand All @@ -18,7 +21,9 @@ private class MyListener implements ActionListener {
public void actionPerformed(ActionEvent event) {
Object src = event.getSource();
Project proj = menubar.getProject();
if (src == loadBuiltin) {
if (src == plugin) {
PluginFrame.showPlugin();
}else if (src == loadBuiltin) {
ProjectLibraryActions.doLoadBuiltinLibrary(proj);
} else if (src == loadLogisim) {
ProjectLibraryActions.LoadLogisimLibraryFromChooser(proj);
Expand All @@ -29,6 +34,10 @@ public void actionPerformed(ActionEvent event) {
} else if (src == options) {
JFrame frame = proj.getOptionsFrame(true);
frame.setVisible(true);

}else if(src instanceof JMenuItem){
String text = ((JMenuItem) src).getText();
PluginLoader.add(text,proj);
}
}
}
Expand All @@ -42,6 +51,9 @@ public void actionPerformed(ActionEvent event) {
private MyListener myListener = new MyListener();

private MenuItemImpl addCircuit = new MenuItemImpl(this, LogisimMenuBar.ADD_CIRCUIT);
private JMenuItem plugin = new JMenuItem();
private JMenu loadInternaPlugin = new JMenu();
private JMenuItem[] array = PluginUtils.makeArray();
private JMenu loadLibrary = new JMenu();
private JMenuItem loadBuiltin = new JMenuItem();
private JMenuItem loadLogisim = new JMenuItem();
Expand All @@ -64,6 +76,7 @@ public void actionPerformed(ActionEvent event) {
this.menubar = menubar;

menubar.registerItem(LogisimMenuBar.ADD_CIRCUIT, addCircuit);
plugin.addActionListener(myListener);
loadBuiltin.addActionListener(myListener);
loadLogisim.addActionListener(myListener);
loadJar.addActionListener(myListener);
Expand All @@ -80,12 +93,20 @@ public void actionPerformed(ActionEvent event) {
menubar.registerItem(LogisimMenuBar.ANALYZE_CIRCUIT, analyze);
menubar.registerItem(LogisimMenuBar.CIRCUIT_STATS, stats);
options.addActionListener(myListener);


if (array!=null) {
for (int i = 0; i < array.length; i++) {
loadInternaPlugin.add(array[i]);
array[i].addActionListener(myListener);
}
}
loadLibrary.add(loadBuiltin);
loadLibrary.add(loadLogisim);
loadLibrary.add(loadJar);

add(addCircuit);
add(plugin);
add(loadInternaPlugin);
add(loadLibrary);
add(unload);
addSeparator();
Expand All @@ -106,6 +127,7 @@ public void actionPerformed(ActionEvent event) {
add(options);

boolean known = menubar.getProject() != null;
loadInternaPlugin.setEnabled(known&&array!=null);
loadLibrary.setEnabled(known);
loadBuiltin.setEnabled(known);
loadLogisim.setEnabled(known);
Expand All @@ -127,6 +149,8 @@ void computeEnabled() {
public void localeChanged() {
setText(Strings.get("projectMenu"));
addCircuit.setText(Strings.get("projectAddCircuitItem"));
plugin.setText(Strings.get("projectPluginItem"));
loadInternaPlugin.setText(Strings.get("projectLoadInternalPlugin"));
loadLibrary.setText(Strings.get("projectLoadLibraryItem"));
loadBuiltin.setText(Strings.get("projectLoadBuiltinItem"));
loadLogisim.setText(Strings.get("projectLoadLogisimItem"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.cburch.logisim.analyze.gui.AnalyzerManager;
import com.cburch.logisim.file.LibraryEvent;
import com.cburch.logisim.file.LibraryListener;
import com.cburch.logisim.gui.plugin.PluginFrame;
import com.cburch.logisim.gui.prefs.PreferencesFrame;
import com.cburch.logisim.proj.Project;
import com.cburch.logisim.proj.ProjectEvent;
Expand Down Expand Up @@ -90,6 +91,7 @@ public static void initialize() {
initialized = true;
AnalyzerManager.initialize();
PreferencesFrame.initializeManager();
PluginFrame.initializeManager();
Projects.addPropertyChangeListener(Projects.projectListProperty, myListener);
computeListeners();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/PluginFrame.class
/PluginFrame$MyListener.class
/PluginFrame$WindowMenuManager.class
/Strings.class
/IntlOptions$RestrictedLabel.class
/IntlOptions.class
/OptionsPanel.class
/PrefBoolean.class
/PrefOptionList.class
/PrefOption.class
/ForkOptions$MyListener.class
/ForkOptions.class
/IntlOptions$1.class
/PluginOptions$MyListener.class
/PluginOptions.class
/StoreOptions$1.class
/StoreOptions.class
/P.class
/Installed$1.class
/Installed.class
/InstalledOptions$1.class
/InstalledOptions.class
/InstalledOptions$MyListener.class
/MyListener.class
/StoreOptions$MyListener.class
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/* Copyright (c) 2010, Carl Burch. License information is located in the
* com.cburch.logisim.Main source code and at www.cburch.com/logisim/. */

package com.cburch.logisim.gui.plugin;



import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Vector;


import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

import com.cburch.logisim.plugin.Json;
import com.cburch.logisim.plugin.PluginUtils;

class InstalledOptions extends OptionsPanel {
private static final long serialVersionUID = -6484141255871285744L;
private class MyListener implements ActionListener {
@Override
public void actionPerformed(ActionEvent event) {
Object src = event.getSource();
if (src == pluginDeleteButton) {
int[] selectedRows = table.getSelectedRows();
for (int i = selectedRows.length-1; i >=0; i--) {
int row = selectedRows[i];
String pluginName =table.getValueAt(row, 0).toString()+"-"+table.getValueAt(row, 1)+"."+table.getValueAt(row, 2);
PluginUtils.deleteFile(pluginName);
((DefaultTableModel)table.getModel()).removeRow(row);
}
PluginUtils.requestRestart();
}
else if (src == pluginUpdateButton) {
int[] selectedRows = table.getSelectedRows();
boolean isUpdated=false;
for (int i = selectedRows.length-1; i >=0; i--) {
int row = selectedRows[i];
String pluginName =table.getValueAt(row, 0).toString()+"-"+table.getValueAt(row, 1)+"."+table.getValueAt(row, 2);
if (Json.searchUpdatedVersion(pluginName)) {
isUpdated=(true);
}
if (isUpdated) {
PluginUtils.requestRestart();
}
}
}
}
}
private MyListener myListener = new MyListener();

private JButton pluginDeleteButton = new JButton(Strings.get("pluginDeleteButton"));
private JButton pluginUpdateButton = new JButton(Strings.get("pluginUpdateButton"));

JTable table;
public InstalledOptions(PluginFrame frame) {
super(frame);
pluginDeleteButton.addActionListener(myListener);
pluginUpdateButton.addActionListener(myListener);
Vector<Vector<String>> rec = PluginUtils.getInstallTable();
Vector<String> columnNames = new Vector<String>();
columnNames.addElement(Strings.get("tableName"));
columnNames.addElement(Strings.get("tableVersion"));
columnNames.addElement(Strings.get("tableType"));
table = new JTable(rec, columnNames){
private static final long serialVersionUID = -9199865726557261219L;
public boolean isCellEditable(int row, int column) {
return false;
}
};
;

JPanel panel = new JPanel();
if(table.getRowCount()==0) {
pluginDeleteButton.setEnabled(false);
pluginUpdateButton.setEnabled(false);
}
panel.add(pluginDeleteButton);
panel.add(pluginUpdateButton);
table.setFont(new Font("Arial", Font.CENTER_BASELINE, 15));
table.setRowHeight(25);
JScrollPane scrollPane=new JScrollPane(table);
Dimension d = new Dimension(400,200);
scrollPane.setPreferredSize(d);
table.getColumnModel().getColumn(0).setPreferredWidth(300);
add(panel);
add(scrollPane);
}


@Override
public String getHelpText() {
return null;
}

@Override
public String getTitle() {
return Strings.get("installedTitle");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* Copyright (c) 2010, Carl Burch. License information is located in the
* com.cburch.logisim.Main source code and at www.cburch.com/logisim/. */

package com.cburch.logisim.gui.plugin;

import java.awt.LayoutManager;

import javax.swing.JPanel;

abstract class OptionsPanel extends JPanel {
/**
*
*/
private static final long serialVersionUID = -2637847947425197542L;
private PluginFrame optionsFrame;

public OptionsPanel(PluginFrame frame) {
super();
this.optionsFrame = frame;
}

public OptionsPanel(PluginFrame frame, LayoutManager manager) {
super(manager);
this.optionsFrame = frame;
}

public abstract String getHelpText();

PluginFrame getPreferencesFrame() {
return optionsFrame;
}

public abstract String getTitle();
}
Loading

0 comments on commit 8001610

Please sign in to comment.