Skip to content

Commit

Permalink
Autosave feature using a hardcoded default autosave period and the cu…
Browse files Browse the repository at this point in the history
…rrent focus frame.
  • Loading branch information
adamburkegh committed Nov 27, 2023
1 parent f32b1fc commit 6259467
Show file tree
Hide file tree
Showing 19 changed files with 426 additions and 213 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.awt.Dimension;
import java.awt.Font;
import java.io.File;
import java.time.Duration;
import java.util.Locale;
import java.util.Vector;
import org.woped.config.ApromoreServer;
Expand Down Expand Up @@ -78,6 +79,8 @@ public class DefaultStaticConfiguration implements IGeneralConfiguration {
public static int DEFAULT_BUSINESSDASHBOARD_PORT = 2711;
public static int DEFAULT_BUSINESSDASHBOARD_MAXVALUES = 1000;
public static boolean DEFAULT_BUSINESSDASHBOARD_USEBYDEFAULT = false;
public static final Duration DEFAULT_AUTOSAVE_PERIOD = Duration.ofSeconds(30);

// Booleans for alpha-functions (TEST) later integration in configuration &
// GUI
public static boolean ACTIVATE_NET_ROUTING = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ public IViewController[] findViewController(int type) {
return iwC;
}

@SuppressWarnings("unchecked")
public List<IEditor> getEditorAwareVCs() {
return (List<IEditor>) editorLists.clone();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ public abstract class AbstractViewEvent extends ActionEvent {
public static final int FILE = 6;
public static final int SAVE = 7;
public static final int SAVEAS = 8;
/**
* AUTOSAVE is GUI generated in the sense that the GUI detects the autosave condition after user
* edits.
*/
public static final int AUTOSAVE = 9;

public static final int IMPORTAPRO = 703;
public static final int EXPORTAPRO = 704;
public static final int ERROR = 9;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
package org.woped.core.controller;

import javax.swing.JLabel;
import javax.swing.JProgressBar;

public interface IStatusBar {

public static int TYPE = 2;

public JProgressBar getProgressBar();

public boolean startProgress(String description, int endValue);

public boolean nextStep();

public boolean isRunning();

public JLabel getStatusLabel();
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ public class PetriNetModelProcessor implements Serializable {
private HashMap<String, Vector<String>> resourceMapping = new HashMap<String, Vector<String>>();
private String id = null;
private String name = null;
private ModelProcessorContext modelProcessorContext = null;
private ModelElementContainer elementContainer = null;

/**
Expand All @@ -92,7 +91,6 @@ public PetriNetModelProcessor() {
*/
public PetriNetModelProcessor(String id) {
elementContainer = new ModelElementContainer();
modelProcessorContext = new ModelProcessorContext();

/* First thing for all: creating a ModelElementContainer */
setId(id);
Expand Down Expand Up @@ -334,7 +332,6 @@ public TriggerModel newTrigger(CreationMap map) {
return transition.getToolSpecific().setTrigger(map);
}

// TODO: DOCUMentation
public TransitionResourceModel newTransResource(CreationMap map) {
TransitionModel transition =
(TransitionModel) getElementContainer().getElementById(map.getId());
Expand Down
21 changes: 17 additions & 4 deletions WoPeD-Core/src/main/java/org/woped/core/utilities/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
import java.awt.print.PageFormat;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
import java.time.Clock;
import java.time.Instant;
import java.util.Vector;
import org.woped.core.controller.AbstractGraph;
import org.woped.core.controller.IEditor;
Expand All @@ -40,6 +42,12 @@
*/
public class Utils {

/**
* A common application clock which abstracts from the system clock. Introduced in 3.9.1, and much
* code predating that version does not use it.
*/
private static Clock CLOCK = Clock.systemDefaultZone();

/**
* This method returns the location that should place a component with <code>componentDimension
* </code> in the center of the owner component ( <code>ownerBounds</code>).
Expand Down Expand Up @@ -140,8 +148,6 @@ public static Object[] sortArcsLast(Object[] input) {
}

/**
* TODO: DOCUMENTATION (alexnagy)
*
* @param editor
*/
public static void print(IEditor editor) {
Expand All @@ -156,11 +162,18 @@ public static void print(IEditor editor) {
try {
printJob.print();
} catch (PrinterException e) {
// logger.warn("Could not Print");
// logger.debug("Exception", e);
// Swallow exception
}
}
}
}
}

public static Instant currentInstant() {
return CLOCK.instant();
}

public static void setClock(Clock clock) {
CLOCK = clock;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public WoPeDAction(
if (propertiesPrefix != null) {
putValue(NAME, Messages.getTitle(propertiesPrefix, args));
putValue(SMALL_ICON, Messages.getImageIcon(propertiesPrefix));
putValue(MNEMONIC_KEY, new Integer(Messages.getMnemonic(propertiesPrefix)));
putValue(MNEMONIC_KEY, Messages.getMnemonic(propertiesPrefix));
putValue(ACCELERATOR_KEY, Messages.getShortcut(propertiesPrefix));
putValue(SHORT_DESCRIPTION, Messages.getTitle(propertiesPrefix, args));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ public class EditorPanel extends JPanel {
private org.woped.metrics.sidebar.SideBar metricsSideBar = null;
private NetColorScheme m_understandColoring = null;

private JSplitPane mainPaneWithT2PBar;
private JPanel t2pBar;
private String t2pText;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import java.text.DecimalFormat;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
import java.util.Observable;
import java.util.Observer;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSlider;
Expand All @@ -22,6 +24,9 @@
@SuppressWarnings("serial")
public class EditorStatusBarVC extends JPanel implements Observer {

private static final DateTimeFormatter FORMATTER =
DateTimeFormatter.ofLocalizedTime(FormatStyle.MEDIUM).withZone(ZoneId.systemDefault());

private JLabel m_counterLabel = null;

private JLabel m_saveIcon = null;
Expand All @@ -34,8 +39,11 @@ public class EditorStatusBarVC extends JPanel implements Observer {

private JLabel m_modelingDirection = null;

private final boolean subprocessEditor;

public EditorStatusBarVC(IEditor editor) {
m_editor = (EditorVC) editor;
subprocessEditor = m_editor instanceof SubprocessEditorVC;
JPanel bar = new JPanel();
bar.setLayout(new BorderLayout());
bar.add(getModelingDirection(), BorderLayout.WEST);
Expand Down Expand Up @@ -144,13 +152,11 @@ public void updateStatus() {
.setText(
"Zoom: " + DecimalFormat.getPercentInstance().format(m_editor.getGraph().getScale()));

if (!(m_editor instanceof SubprocessEditorVC)) {
if (!subprocessEditor) {
if (m_editor.isSaved()) {
getSaveIcon().setText(Messages.getString("Button.Saved.Title"));
getSaveIcon().setIcon(Messages.getImageIcon("Button.Saved"));
displaySavedStatus();
} else {
getSaveIcon().setText(Messages.getString("Button.NotSaved.Title"));
getSaveIcon().setIcon(Messages.getImageIcon("Button.NotSaved"));
displayAutosaveStatus();
}
}

Expand Down Expand Up @@ -181,6 +187,27 @@ public void updateStatus() {
}
}

private void displayAutosaveStatus() {
String savedTime = " " + FORMATTER.format(m_editor.getSavedTime());
if (m_editor.isAutosaved()) {
getSaveIcon()
.setText(
Messages.getString("Button.Autosave.Title")
+ savedTime
+ " "
+ m_editor.getAutosavePath());
getSaveIcon().setIcon(Messages.getImageIcon("Button.Saved"));
} else {
getSaveIcon().setText(Messages.getString("Button.NotSaved.Title"));
getSaveIcon().setIcon(Messages.getImageIcon("Button.NotSaved"));
}
}

private void displaySavedStatus() {
getSaveIcon().setText(Messages.getString("Button.Saved.Title"));
getSaveIcon().setIcon(Messages.getImageIcon("Button.Saved"));
}

public void update(Observable arg0, Object arg1) {
updateStatus();
}
Expand All @@ -189,7 +216,6 @@ public void update(Observable arg0, Object arg1) {
class SliderComboListener implements ChangeListener {

JSlider slide;
JComboBox combo;

// JSlider event
public void stateChanged(ChangeEvent ce) {
Expand Down
Loading

0 comments on commit 6259467

Please sign in to comment.