Search in sources :

Example 1 with EffectsLibrary

use of blue.ui.core.mixer.EffectsLibrary in project blue by kunstmusik.

the class EffectsPopup method reinitialize.

private void reinitialize() {
    this.removeAll();
    effectsMenu.removeAll();
    EffectsLibrary library = EffectsLibrary.getInstance();
    populateMenu(library.getRootEffectCategory(), effectsMenu);
    // this.add(addInsert);
    this.add(addNewEffect);
    this.add(effectsMenu);
    this.addSeparator();
    this.add(addSend);
    this.addSeparator();
    this.add(pushUp);
    this.add(pushDown);
    this.addSeparator();
    this.add(openEditor);
    this.add(editEffect);
    this.add(enableDisableEffect);
    this.addSeparator();
    this.add(cutAction);
    this.add(copyAction);
    this.add(pasteAction);
    this.addSeparator();
    this.add(importToLibrary);
    this.addSeparator();
    this.add(removeItem);
    this.addSeparator();
    this.add(importAction);
    this.add(exportAction);
}
Also used : EffectsLibrary(blue.ui.core.mixer.EffectsLibrary)

Example 2 with EffectsLibrary

use of blue.ui.core.mixer.EffectsLibrary in project blue by kunstmusik.

the class EffectImportPane method importEffect.

private void importEffect() {
    EffectOption effectOption = iTableModel.getInstrumentOption(instrumentTable.getSelectedRow());
    if (effectOption == null) {
        return;
    }
    try {
        Effect effect = BlueShareRemoteCaller.getEffect(effectOption);
        if (effect == null) {
            String error = BlueSystem.getString("blueShare.effect.importError");
            JOptionPane.showMessageDialog(null, error, BlueSystem.getString("message.error"), JOptionPane.ERROR_MESSAGE);
            return;
        }
        // data.getOrchestra().addInstrument(instrument);
        // instrumentTreeModel.reload();
        // InstrumentLibrary instrLib =
        // BlueSystem.getUserInstrumentLibrary();
        EffectsLibrary library = EffectsLibrary.getInstance();
        library.importEffect(effect);
        library.save();
        String message = BlueSystem.getString("blueShare.effect.importSuccess");
        JOptionPane.showMessageDialog(null, message, BlueSystem.getString("common.success"), JOptionPane.PLAIN_MESSAGE);
    } catch (ParseException pe) {
        String error = BlueSystem.getString("blueShare.selectServer.couldNotReadResponse");
        JOptionPane.showMessageDialog(null, error, BlueSystem.getString("message.error"), JOptionPane.ERROR_MESSAGE);
        return;
    } catch (XmlRpcException xre) {
        String error = "Error: " + xre.getLocalizedMessage();
        JOptionPane.showMessageDialog(null, error, BlueSystem.getString("message.error"), JOptionPane.ERROR_MESSAGE);
        return;
    } catch (IOException ioe) {
        String error = "Error: " + ioe.getLocalizedMessage();
        JOptionPane.showMessageDialog(null, error, BlueSystem.getString("message.error"), JOptionPane.ERROR_MESSAGE);
        return;
    }
}
Also used : EffectsLibrary(blue.ui.core.mixer.EffectsLibrary) Effect(blue.mixer.Effect) ParseException(electric.xml.ParseException) IOException(java.io.IOException) XmlRpcException(org.apache.xmlrpc.XmlRpcException)

Example 3 with EffectsLibrary

use of blue.ui.core.mixer.EffectsLibrary in project blue by kunstmusik.

the class EffectTreeDropTarget method drop.

@Override
public void drop(DropTargetDropEvent dtde) {
    Point pt = dtde.getLocation();
    DropTargetContext dtc = dtde.getDropTargetContext();
    JTree tree = (JTree) dtc.getComponent();
    TreePath parentpath = tree.getClosestPathForLocation(pt.x, pt.y);
    Object node = parentpath.getLastPathComponent();
    EffectsLibrary eLibrary = EffectsLibrary.getInstance();
    if (dtde.isDataFlavorSupported(TransferableEffect.EFFECT_CAT_FLAVOR)) {
        if (!(node instanceof EffectCategory)) {
            dtde.rejectDrop();
            return;
        }
        if (dtde.getDropAction() == DnDConstants.ACTION_MOVE) {
            dtde.acceptDrop(dtde.getDropAction());
            Transferable tr = dtde.getTransferable();
            try {
                Object transferNode = tr.getTransferData(TransferableEffect.EFFECT_CAT_FLAVOR);
                EffectCategory effectCategory = (EffectCategory) transferNode;
                EffectCategory parentNode = (EffectCategory) node;
                eLibrary.addCategory(parentNode, effectCategory);
                dtde.dropComplete(true);
            } catch (UnsupportedFlavorException | IOException e) {
                dtde.dropComplete(false);
            }
        } else {
            dtde.rejectDrop();
        }
    } else if (dtde.isDataFlavorSupported(TransferableEffect.EFFECT_FLAVOR)) {
        dtde.acceptDrop(dtde.getDropAction());
        try {
            Transferable tr = dtde.getTransferable();
            Object transferNode = tr.getTransferData(TransferableEffect.EFFECT_FLAVOR);
            Effect effect = (Effect) transferNode;
            effect.clearParameters();
            // iLibrary.removeInstrument(instrument);
            if (node instanceof EffectCategory) {
                EffectCategory parentNode = (EffectCategory) node;
                eLibrary.addEffect(parentNode, effect);
            } else if (node instanceof Effect) {
                EffectCategory parentNode = (EffectCategory) parentpath.getPathComponent(parentpath.getPathCount() - 2);
                int index = ListUtil.indexOfByRef(parentNode.getEffects(), node);
                int closestRow = tree.getClosestRowForLocation(pt.x, pt.y);
                Rectangle bounds = tree.getRowBounds(closestRow);
                if (pt.y > bounds.y + bounds.height) {
                    eLibrary.addEffect(parentNode, effect);
                } else {
                    eLibrary.addEffect(parentNode, index, effect);
                }
            }
            dtde.dropComplete(true);
        } catch (UnsupportedFlavorException | IOException e) {
            dtde.dropComplete(false);
        }
    } else {
        dtde.rejectDrop();
    }
}
Also used : DropTargetContext(java.awt.dnd.DropTargetContext) Transferable(java.awt.datatransfer.Transferable) Rectangle(java.awt.Rectangle) Point(java.awt.Point) EffectCategory(blue.ui.core.mixer.EffectCategory) IOException(java.io.IOException) UnsupportedFlavorException(java.awt.datatransfer.UnsupportedFlavorException) Point(java.awt.Point) JTree(javax.swing.JTree) TreePath(javax.swing.tree.TreePath) EffectsLibrary(blue.ui.core.mixer.EffectsLibrary)

Aggregations

EffectsLibrary (blue.ui.core.mixer.EffectsLibrary)3 IOException (java.io.IOException)2 Effect (blue.mixer.Effect)1 EffectCategory (blue.ui.core.mixer.EffectCategory)1 ParseException (electric.xml.ParseException)1 Point (java.awt.Point)1 Rectangle (java.awt.Rectangle)1 Transferable (java.awt.datatransfer.Transferable)1 UnsupportedFlavorException (java.awt.datatransfer.UnsupportedFlavorException)1 DropTargetContext (java.awt.dnd.DropTargetContext)1 JTree (javax.swing.JTree)1 TreePath (javax.swing.tree.TreePath)1 XmlRpcException (org.apache.xmlrpc.XmlRpcException)1