Compound scripts have direct editing disabled - it might damage script initializer to edit it separately.

This commit is contained in:
Jindra Petřík
2023-10-01 18:21:38 +02:00
parent 5846e86a2f
commit d2a32374b0
3 changed files with 18 additions and 0 deletions
@@ -5140,6 +5140,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
abcPanel.setAbc(scriptLeaf.abc);
abcPanel.decompiledTextArea.setScript(scriptLeaf, true);
abcPanel.decompiledTextArea.setNoTrait();
abcPanel.setCompound(true);
}
if (Configuration.displayAs3TraitsListAndConstantsPanel.get()) {
@@ -5156,6 +5157,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
abcPanel.setAbc(scriptLeaf.abc);
abcPanel.decompiledTextArea.setScript(scriptLeaf, true);
abcPanel.decompiledTextArea.setNoTrait();
abcPanel.setCompound(!scriptLeaf.isSimple);
}
if (Configuration.displayAs3TraitsListAndConstantsPanel.get()) {
@@ -203,6 +203,8 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<Scr
private final DebugPanel debugPanel;
private final JLabel experimentalLabel = new JLabel(AppStrings.translate("action.edit.experimental"));
private final JLabel infoNotEditableLabel;
private final JButton editDecompiledButton = new JButton(AppStrings.translate("button.edit.script.decompiled"), View.getIcon("edit16"));
@@ -1065,14 +1067,20 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<Scr
brokenHintPanel.setVisible(false);
infoNotEditableLabel = new JLabel(View.getIcon("information16"));
infoNotEditableLabel.setToolTipText(AppStrings.translate("info.noteditable.compound"));
iconDecPanel.add(panelWithHint, BorderLayout.CENTER);
final JPanel decButtonsPan = new JPanel(new FlowLayout());
decButtonsPan.setBorder(new BevelBorder(BevelBorder.RAISED));
decButtonsPan.add(editDecompiledButton);
decButtonsPan.add(experimentalLabel);
decButtonsPan.add(infoNotEditableLabel);
decButtonsPan.add(saveDecompiledButton);
decButtonsPan.add(cancelDecompiledButton);
infoNotEditableLabel.setVisible(false);
editDecompiledButton.setMargin(new Insets(3, 3, 3, 10));
saveDecompiledButton.setMargin(new Insets(3, 3, 3, 10));
cancelDecompiledButton.setMargin(new Insets(3, 3, 3, 10));
@@ -1993,4 +2001,10 @@ public class ABCPanel extends JPanel implements ItemListener, SearchListener<Scr
public DebugPanel getDebugPanel() {
return debugPanel;
}
public void setCompound(boolean value) {
infoNotEditableLabel.setVisible(value);
experimentalLabel.setVisible(!value);
editDecompiledButton.setEnabled(!value);
}
}
@@ -1150,3 +1150,5 @@ warning.icon = Click to show related warning
button.export = Export
error.font.cannotaddcharacter = ERROR: Cannot add more characters to the font.\r\nSuccessfully added characters: %numchars%.
info.noteditable.compound = The script is compound - has multiple externally visible definitions. The direct editing is not available.