Skip to content

Commit

Permalink
1.10.6 Feature: Edit OnlineRef dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikescher committed Apr 14, 2019
1 parent 693933f commit d187744
Show file tree
Hide file tree
Showing 16 changed files with 295 additions and 18 deletions.
3 changes: 3 additions & 0 deletions res/de/jClipCorn/gui/localization/locale.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1189,6 +1189,9 @@ RandomMovieFrame.btnPlay.text = Play
RandomMovieFrame.btnShuffle.text = Shuffle
RandomMovieFrame.this.title = Random Movie

ReferenceChooserDialog.btnAppend = Append
ReferenceChooserDialog.title = References (Online)

ResourcePreloadMode.Opt0 = No preload
ResourcePreloadMode.Opt1 = Synchronous preloading
ResourcePreloadMode.Opt2 = Asynchronous preloading
Expand Down
3 changes: 3 additions & 0 deletions res/de/jClipCorn/gui/localization/locale_de_DE.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1189,6 +1189,9 @@ RandomMovieFrame.btnPlay.text = Abspielen
RandomMovieFrame.btnShuffle.text = Mischen
RandomMovieFrame.this.title = Filmtrommel

ReferenceChooserDialog.btnAppend = Neu
ReferenceChooserDialog.title = Referenzen (Online)

ResourcePreloadMode.Opt0 = Kein Vorladen
ResourcePreloadMode.Opt1 = Synchrones Vorladen
ResourcePreloadMode.Opt2 = Asynchrones Vorladen
Expand Down
3 changes: 3 additions & 0 deletions res/de/jClipCorn/gui/localization/locale_dl_DL.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1189,6 +1189,9 @@ RandomMovieFrame.btnPlay.text = Play
RandomMovieFrame.btnShuffle.text = Shuffle
RandomMovieFrame.this.title = Filmtrommel

ReferenceChooserDialog.btnAppend = Append
ReferenceChooserDialog.title = Referenzen (Online)

ResourcePreloadMode.Opt0 = No preload
ResourcePreloadMode.Opt1 = Synchronous preloading
ResourcePreloadMode.Opt2 = Asynchronous preloading
Expand Down
3 changes: 3 additions & 0 deletions res/de/jClipCorn/gui/localization/locale_en_US.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1189,6 +1189,9 @@ RandomMovieFrame.btnPlay.text = Play
RandomMovieFrame.btnShuffle.text = Shuffle
RandomMovieFrame.this.title = Random Movie

ReferenceChooserDialog.btnAppend = Append
ReferenceChooserDialog.title = References (Online)

ResourcePreloadMode.Opt0 = No preload
ResourcePreloadMode.Opt1 = Synchronous preloading
ResourcePreloadMode.Opt2 = Asynchronous preloading
Expand Down
Binary file added res/icons/common/bullet_add_16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/icons/common/bullet_arrow_down_16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/icons/common/bullet_arrow_up_16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/icons/common/bullet_delete_16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 1 addition & 3 deletions src/main/de/jClipCorn/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

public class Main {
public final static String TITLE = "jClipCorn"; //$NON-NLS-1$
public final static String VERSION = /*<gradle_version_marker>*/"1.10.5.35"/*</gradle_version_marker>*/; //$NON-NLS-1$
public final static String VERSION = /*<gradle_version_marker>*/"1.10.5.36"/*</gradle_version_marker>*/; //$NON-NLS-1$
public final static String DBVERSION = "12"; //$NON-NLS-1$
public final static String JXMLVER = "2"; //$NON-NLS-1$

Expand Down Expand Up @@ -212,8 +212,6 @@ private static void post_init(String[] args) {
//TODO localsync: also autosave to other dir (== nextcloud) (or directly sync with server??)
// php viewer: view synced data online with webpage(read-only)

//TODO Edit OnlineRef in own dialog with more options (move, sort, insert, ...)

//TODO (optional) add a season ref to an online ref to associate it with a specific season

//TODO re-do PlainTextExporter
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package de.jClipCorn.database.databaseElement.columnTypes;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ public static CCTagList deserialize(String v) throws TagNotFoundException
boolean[] n = new boolean[TAGCOUNT];
for (int i = 0; i < TAGCOUNT; i++) n[i] = false;

for (String str : v.split(";"))
for (String str : v.split(";")) //$NON-NLS-1$
{
if (!Str.isNullOrWhitespace(str)) n[CCSingleTag.find(Integer.parseInt(str)).Index] = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ private void initGUI() {

spnLength = new JSpinner();
spnLength.setModel(new SpinnerNumberModel(0, 0, null, 1));
spnLength.setBounds(93, 405, 212, 20);
spnLength.setBounds(93, 405, 163, 20);
getContentPane().add(spnLength);

label_19 = new JLabel(LocaleBundle.getString("AddMovieFrame.lblLength.text")); //$NON-NLS-1$
Expand All @@ -405,7 +405,7 @@ private void initGUI() {
getContentPane().add(spnAddDate);

label_20 = new JLabel("min."); //$NON-NLS-1$
label_20.setBounds(314, 407, 52, 16);
label_20.setBounds(266, 407, 52, 16);
getContentPane().add(label_20);

label_21 = new JLabel(LocaleBundle.getString("AddMovieFrame.lblEinfgDatum.text")); //$NON-NLS-1$
Expand Down Expand Up @@ -570,19 +570,19 @@ private void initGUI() {
getContentPane().add(edGroups);

btnMediaInfo1 = new JButton(Resources.ICN_MENUBAR_UPDATECODECDATA.get16x16());
btnMediaInfo1.setBounds(386, 375, 22, 22);
btnMediaInfo1.setBounds(314, 376, 22, 22);
btnMediaInfo1.addActionListener(e -> parseCodecMetadata_Lang());
btnMediaInfo1.setToolTipText("MediaInfo"); //$NON-NLS-1$
getContentPane().add(btnMediaInfo1);

btnMediaInfoRaw = new JButton("..."); //$NON-NLS-1$
btnMediaInfoRaw.setBounds(411, 375, 32, 22);
btnMediaInfoRaw.setBounds(339, 376, 32, 22);
btnMediaInfoRaw.addActionListener(e -> showCodecMetadata());
btnMediaInfoRaw.setToolTipText("MediaInfo"); //$NON-NLS-1$
getContentPane().add(btnMediaInfoRaw);

btnMediaInfo2 = new JButton(Resources.ICN_MENUBAR_UPDATECODECDATA.get16x16());
btnMediaInfo2.setBounds(386, 402, 22, 22);
btnMediaInfo2.setBounds(314, 403, 22, 22);
btnMediaInfo2.addActionListener(e -> parseCodecMetadata_Len());
btnMediaInfo2.setToolTipText("MediaInfo"); //$NON-NLS-1$
getContentPane().add(btnMediaInfo2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.awt.BorderLayout;
import java.awt.Insets;
import java.awt.event.InputEvent;
import java.util.ArrayList;
import java.util.List;

Expand Down Expand Up @@ -31,8 +32,13 @@ private void initGUI() {
add(btnAdditional, BorderLayout.EAST);
btnAdditional.addActionListener(e ->
{
ReferenceChooserPopup popup = new ReferenceChooserPopup(_additional, JReferenceChooser.this);
popup.setVisible(true);
if ((e.getModifiers() & InputEvent.CTRL_MASK) == InputEvent.CTRL_MASK) {
ReferenceChooserDialog dialog = new ReferenceChooserDialog(mainChooser.getValue(), _additional, JReferenceChooser.this);
dialog.setVisible(true);
} else {
ReferenceChooserPopup popup = new ReferenceChooserPopup(_additional, JReferenceChooser.this);
popup.setVisible(true);
}
});
btnAdditional.setMargin(new Insets(2, 4, 2, 4));
btnAdditional.setFocusable(false);
Expand Down Expand Up @@ -63,6 +69,11 @@ private void updateUIControls() {
mainChooser.updateUIControls();
btnAdditional.setText("+"+_additional.size()); //$NON-NLS-1$
}

public void setMain(CCSingleOnlineReference a) {
mainChooser.setValue(a);
updateUIControls();
}

public void setAdditional(List<CCSingleOnlineReference> a) {
_additional = CCStreams
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
package de.jClipCorn.gui.guiComponents.referenceChooser;

import java.awt.*;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.List;

import javax.swing.*;
import javax.swing.border.EmptyBorder;

import com.jgoodies.forms.layout.ColumnSpec;
import com.jgoodies.forms.layout.FormLayout;
import com.jgoodies.forms.layout.FormSpecs;
import com.jgoodies.forms.layout.RowSpec;
import de.jClipCorn.database.databaseElement.columnTypes.CCSingleOnlineReference;
import de.jClipCorn.gui.localization.LocaleBundle;
import de.jClipCorn.gui.resources.Resources;
import de.jClipCorn.util.datatypes.Tuple;

public class ReferenceChooserDialog extends JDialog {
private static final long serialVersionUID = -3812579297074052719L;

private final JReferenceChooser parent;
private JSingleReferenceChooser chsrMain;
private List<JSingleSubReferenceChooser> chsrAdd;

private JPanel pnlData;

public ReferenceChooserDialog(CCSingleOnlineReference dataMain, List<CCSingleOnlineReference> dataAdditional, JReferenceChooser parent) {
super();

this.parent = parent;

initGUI();
updateControls(dataMain, dataAdditional);
setSize(380, Math.max(250, 165 + 32*dataAdditional.size()));


setLocationRelativeTo(parent);
}

private void initGUI() {
setTitle(LocaleBundle.getString("ReferenceChooserDialog.title")); //$NON-NLS-1$
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
setIconImage(Resources.IMG_FRAME_ICON.get());
setType(Type.UTILITY);
setMinimumSize(new Dimension(250, 200));
setModal(true);

getContentPane().setLayout(new BorderLayout());

JPanel pnlBase = new JPanel();
{
pnlBase.setBorder(new EmptyBorder(5, 5, 5, 5));
pnlBase.setLayout(new BorderLayout());
getContentPane().add(pnlBase, BorderLayout.CENTER);

JScrollPane pnlScroll = new JScrollPane();
{
pnlBase.add(pnlScroll, BorderLayout.CENTER);

pnlData = new JPanel();
{
pnlData.setLayout(new FormLayout());
pnlScroll.setViewportView(pnlData);
}
}

JPanel pnlOpt = new JPanel();
{
FlowLayout flowLayout;
pnlOpt.setLayout(flowLayout = new FlowLayout());
flowLayout.setAlignment(FlowLayout.RIGHT);
pnlBase.add(pnlOpt, BorderLayout.SOUTH);

JButton btnAppend = new JButton(LocaleBundle.getString("ReferenceChooserDialog.btnAppend")); //$NON-NLS-1$
btnAppend.addActionListener(e -> insertNewRef(chsrAdd.size()));
pnlOpt.add(btnAppend);
}
}

JPanel pnlBottom = new JPanel();
{
FlowLayout flowLayout;
pnlBottom.setLayout(flowLayout = new FlowLayout());
flowLayout.setAlignment(FlowLayout.RIGHT);
getContentPane().add(pnlBottom, BorderLayout.SOUTH);

JButton btnCancel = new JButton(LocaleBundle.getString("UIGeneric.btnCancel.text")); //$NON-NLS-1$
btnCancel.addActionListener(e -> { setVisible(false); dispose(); });
pnlBottom.add(btnCancel);

JButton btnOk = new JButton(LocaleBundle.getString("UIGeneric.btnOK.text")); //$NON-NLS-1$
btnOk.setFont(new Font(btnOk.getFont().getFontName(), Font.BOLD, btnOk.getFont().getSize()));
btnOk.addActionListener(e -> onOK());
pnlBottom.add(btnOk);
}

JRootPane root = getRootPane();
root.registerKeyboardAction(e -> { setVisible(false); dispose(); }, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
}

private void updateControls(CCSingleOnlineReference dataMain, List<CCSingleOnlineReference> dataAdditional) {
pnlData.removeAll();

ArrayList<RowSpec> rspec = new ArrayList<>();
ArrayList<ColumnSpec> cspec = new ArrayList<>();

cspec.add(ColumnSpec.decode("max(15dlu;default):grow")); //$NON-NLS-1$
cspec.add(FormSpecs.RELATED_GAP_COLSPEC);
cspec.add(ColumnSpec.decode("default")); //$NON-NLS-1$
cspec.add(ColumnSpec.decode("default")); //$NON-NLS-1$
cspec.add(ColumnSpec.decode("default")); //$NON-NLS-1$
cspec.add(ColumnSpec.decode("default")); //$NON-NLS-1$

rspec.add(RowSpec.decode("24px")); //$NON-NLS-1$
rspec.add(RowSpec.decode("5dlu")); //$NON-NLS-1$
for (int i = 0; i < dataAdditional.size(); i++) {
rspec.add(FormSpecs.RELATED_GAP_ROWSPEC);
rspec.add(RowSpec.decode("24px")); //$NON-NLS-1$
}
rspec.add(RowSpec.decode("default:grow")); //$NON-NLS-1$

pnlData.setLayout(new FormLayout(cspec.toArray(new ColumnSpec[0]), rspec.toArray(new RowSpec[0])));

chsrMain = new JSingleReferenceChooser();
chsrMain.setValue(dataMain);
pnlData.add(chsrMain, "1, 1, 6, 1, fill, fill"); //$NON-NLS-1$

chsrAdd = new ArrayList<>();

for (int i = 0; i < dataAdditional.size(); i++) {
final int fi = i;

JSingleSubReferenceChooser c = new JSingleSubReferenceChooser();
c.setValue(dataAdditional.get(i));
pnlData.add(c, "1, "+(4 + i*2)+", fill, fill"); //$NON-NLS-1$ //$NON-NLS-2$

JButton btnUp = new JButton(Resources.ICN_GENERIC_BULLET_UP.get());
JButton btnDn = new JButton(Resources.ICN_GENERIC_BULLET_DOWN.get());
JButton btnIn = new JButton(Resources.ICN_GENERIC_BULLET_ADD.get());
JButton btnRm = new JButton(Resources.ICN_GENERIC_BULLET_REM.get());

pnlData.add(btnUp, "3, "+(4 + i*2)+", fill, fill"); //$NON-NLS-1$ //$NON-NLS-2$
pnlData.add(btnDn, "4, "+(4 + i*2)+", fill, fill"); //$NON-NLS-1$ //$NON-NLS-2$
pnlData.add(btnIn, "5, "+(4 + i*2)+", fill, fill"); //$NON-NLS-1$ //$NON-NLS-2$
pnlData.add(btnRm, "6, "+(4 + i*2)+", fill, fill"); //$NON-NLS-1$ //$NON-NLS-2$

btnUp.addActionListener(e -> moveRefUp(fi));
btnDn.addActionListener(e -> moveRefDown(fi));
btnIn.addActionListener(e -> insertNewRef(fi));
btnRm.addActionListener(e -> removeRef(fi));

btnUp.setMargin(new Insets(0, 0, 0, 0));
btnDn.setMargin(new Insets(0, 0, 0, 0));
btnIn.setMargin(new Insets(0, 0, 0, 0));
btnRm.setMargin(new Insets(0, 0, 0, 0));

btnUp.setEnabled(i>0);
btnDn.setEnabled(i<(dataAdditional.size()-1));

chsrAdd.add(c);
}

validate();
pnlData.revalidate();

repaint();
pnlData.repaint();
}

private void onOK() {
Tuple<CCSingleOnlineReference, List<CCSingleOnlineReference>> val = getActual();

List<CCSingleOnlineReference> value = new ArrayList<>();
for (CCSingleOnlineReference soref : val.Item2)
{
if (soref == null) continue;
if (soref.isUnset()) continue;
if (soref.isInvalid()) continue;
value.add(soref);
}

parent.setMain(val.Item1);
parent.setAdditional(value);
dispose();
}

private Tuple<CCSingleOnlineReference, List<CCSingleOnlineReference>> getActual() {
CCSingleOnlineReference m = chsrMain.getValue();

List<CCSingleOnlineReference> l = new ArrayList<>();
for (JSingleSubReferenceChooser c : chsrAdd) l.add(c.getValue());

return Tuple.Create(m, l);
}

private void removeRef(int idx) {
Tuple<CCSingleOnlineReference, List<CCSingleOnlineReference>> d = getActual();
d.Item2.remove(idx);
updateControls(d.Item1, d.Item2);
}

private void insertNewRef(int idx) {
Tuple<CCSingleOnlineReference, List<CCSingleOnlineReference>> d = getActual();
if (idx == d.Item2.size()) d.Item2.add(CCSingleOnlineReference.createNone());
else d.Item2.add(idx+1, CCSingleOnlineReference.createNone());
updateControls(d.Item1, d.Item2);
}

private void moveRefDown(int idx) {
Tuple<CCSingleOnlineReference, List<CCSingleOnlineReference>> d = getActual();
CCSingleOnlineReference r = d.Item2.remove(idx);
d.Item2.add(idx+1, r);
updateControls(d.Item1, d.Item2);
}

private void moveRefUp(int idx) {
Tuple<CCSingleOnlineReference, List<CCSingleOnlineReference>> d = getActual();
CCSingleOnlineReference r = d.Item2.remove(idx);
d.Item2.add(idx-1, r);
updateControls(d.Item1, d.Item2);
}
}
Loading

0 comments on commit d187744

Please sign in to comment.