connect to patreon added

This commit is contained in:
Bane Stojkovic
2025-04-09 19:43:05 +02:00
parent bf80f65690
commit 17e8e11731
4 changed files with 85 additions and 7 deletions
@@ -74,6 +74,7 @@ public class CloudPlugIn implements IPlugIn {
private UploadAction uploadAction;
private ChangePasswordAction changePasswordAction;
private ManageProjectsAction manageProjectsAction;
private ConnectPatreonAction connectPatreonAction;
private CloudBrowserFrame cloudBrowser;
@@ -83,6 +84,12 @@ public class CloudPlugIn implements IPlugIn {
this.swingUI = swingUI;
this.thumbnailPresenter = new Presenter(new DummyView(), InMemoryConfigurationManager.getInstance());
this.thumbnailGenerator = new ThumbnailGenerator(thumbnailPresenter);
}
@Override
public void connect(IPlugInPort plugInPort) {
this.plugInPort = plugInPort;
this.cloudService = plugInPort.getCloudService();
// Initialize actions
this.libraryAction = new LibraryAction(this);
@@ -93,6 +100,7 @@ public class CloudPlugIn implements IPlugIn {
this.uploadAction = new UploadAction(this);
this.changePasswordAction = new ChangePasswordAction(this);
this.manageProjectsAction = new ManageProjectsAction(this);
this.connectPatreonAction = new ConnectPatreonAction(plugInPort, swingUI);
swingUI.injectMenuAction(getLibraryAction(), ONLINE_TITLE);
swingUI.injectMenuAction(null, ONLINE_TITLE);
@@ -104,6 +112,7 @@ public class CloudPlugIn implements IPlugIn {
swingUI.injectMenuAction(null, ONLINE_TITLE);
swingUI.injectMenuAction(getManageAccountAction(), ONLINE_TITLE);
swingUI.injectMenuAction(getChangePasswordAction(), ONLINE_TITLE);
swingUI.injectMenuAction(getConnectPatreonAction(), ONLINE_TITLE);
swingUI.injectMenuAction(getLogOutAction(), ONLINE_TITLE);
// default state
@@ -114,12 +123,6 @@ public class CloudPlugIn implements IPlugIn {
getLogOutAction().setEnabled(false);
}
@Override
public void connect(IPlugInPort plugInPort) {
this.plugInPort = plugInPort;
this.cloudService = plugInPort.getCloudService();
}
public CloudBrowserFrame getCloudBrowser() {
if (cloudBrowser == null) {
cloudBrowser = new CloudBrowserFrame(swingUI, plugInPort);
@@ -151,6 +154,10 @@ public class CloudPlugIn implements IPlugIn {
return manageAccountAction;
}
public ConnectPatreonAction getConnectPatreonAction() {
return connectPatreonAction;
}
public UploadAction getUploadAction() {
return uploadAction;
}
@@ -0,0 +1,70 @@
/*
DIY Layout Creator (DIYLC).
Copyright (c) 2009-2018 held jointly by the individual authors.
This file is part of DIYLC.
DIYLC is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
DIYLC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DIYLC. If not, see <http://www.gnu.org/licenses/>.
*/
package org.diylc.swing.plugins.cloud.actions;
import org.apache.log4j.Logger;
import org.diylc.common.IPlugInPort;
import org.diylc.common.ITask;
import org.diylc.core.IView;
import org.diylc.plugins.cloud.service.CloudException;
import org.diylc.swing.ISwingUI;
import org.diylc.swing.gui.DialogFactory;
import org.diylc.swing.plugins.cloud.CloudPlugIn;
import org.diylc.swing.plugins.cloud.view.UserEditDialog;
import org.diylc.swingframework.ButtonDialog;
import org.diylc.utils.IconLoader;
import javax.swing.*;
import java.awt.event.ActionEvent;
public class ConnectPatreonAction extends AbstractAction {
private static final long serialVersionUID = 1L;
private static final Logger LOG = Logger.getLogger(ConnectPatreonAction.class);
private final IPlugInPort plugInPort;
private final ISwingUI swingUI;
public ConnectPatreonAction(IPlugInPort plugInPort, ISwingUI swingUI) {
super();
this.plugInPort = plugInPort;
this.swingUI = swingUI;
putValue(AbstractAction.NAME, "Connect to Patreon");
putValue(AbstractAction.SMALL_ICON, IconLoader.Patreon.getIcon());
}
@Override
public void actionPerformed(ActionEvent e) {
if (!plugInPort.getCloudService().isLoggedIn()) {
swingUI.showMessage("You must be logged in to DIYLC Cloud account in order to connect with Patreon account.", "Error",
ISwingUI.ERROR_MESSAGE);
return;
}
String username = plugInPort.getCloudService().getCurrentUsername();
String url = "http://diy-fever.com/diylc/api/v1/ai/patreon_login.php?username=" + username;
try {
java.awt.Desktop.getDesktop().browse(new java.net.URI(url));
} catch (Exception ex) {
LOG.error("Failed to open Patreon connection page", ex);
swingUI.showMessage("Failed to open Patreon connection page. Please visit " + url + " manually.", "Error",
ISwingUI.ERROR_MESSAGE);
}
}
}
@@ -71,7 +71,8 @@ public enum IconLoader {
SnapToComponents("snap_to_components.png"), SnapToNone("snap_to_none.png"), TraceProximity("trace_proximity.png"),
ComponentLarge("component_large.png"), ImportNetlist("import_netlist.png"), SplashIC("splash_ic.png"),
ComponentPreferences("component_preferences.png"), ComponentReplace("component_replace.png"), Barcode("barcode.png"),
DocumentGerber("document_gerber.png"), DocumentX2("document_x2.png"), Export("export.png"), Multimeter("multimeter.png");
DocumentGerber("document_gerber.png"), DocumentX2("document_x2.png"), Export("export.png"), Multimeter("multimeter.png"),
Patreon("patreon.png");
protected String name;
Binary file not shown.

After

Width:  |  Height:  |  Size: 828 B