mirror of
https://github.com/tonikelope/megabasterd.git
synced 2025-05-29 04:50:14 +02:00
4.3
-File splitter
This commit is contained in:
parent
853afb93a8
commit
d5eb9e80ed
@ -13,10 +13,10 @@ import java.awt.Color;
|
||||
public final class AboutDialog extends javax.swing.JDialog {
|
||||
|
||||
private static final String MEGA_URL = "https://mega.nz/#F!lYsRWaQB!uVhntmyKcVECRaOxAbcL4A";
|
||||
private static final String TONIKELOPE_URL = "http://toni.world";
|
||||
private static final String TONIKELOPE_URL = "https://github.com/tonikelope/";
|
||||
private static final String MEGACRYPTER_URL = "https://tonikelope.github.io/megacrypter/";
|
||||
private static final String SPAIN_URL = "https://en.wikipedia.org/wiki/Spain";
|
||||
private static final String MEGABASTERD_GITHUB_URL = "https://github.com/tonikelope/megabasterd";
|
||||
private static final String MEGABASTERD_GITHUB_URL = "https://github.com/tonikelope/megabasterd/";
|
||||
|
||||
public AboutDialog(MainPanelView parent, boolean modal) {
|
||||
|
||||
|
176
src/main/java/com/tonikelope/megabasterd/FileSplitterDialog.form
Normal file
176
src/main/java/com/tonikelope/megabasterd/FileSplitterDialog.form
Normal file
@ -0,0 +1,176 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="2"/>
|
||||
<Property name="title" type="java.lang.String" value="File Splitter"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="file_button" alignment="0" max="32767" attributes="0"/>
|
||||
<Component id="file_name_label" alignment="0" max="32767" attributes="0"/>
|
||||
<Component id="output_button" alignment="0" pref="976" max="32767" attributes="0"/>
|
||||
<Component id="file_size_label" alignment="0" max="32767" attributes="0"/>
|
||||
<Component id="output_folder_label" alignment="0" max="32767" attributes="0"/>
|
||||
<Component id="jProgressBar2" alignment="0" max="32767" attributes="0"/>
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="split_size_label" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="split_size_text" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="split_button" alignment="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="file_button" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="9" max="-2" attributes="0"/>
|
||||
<Component id="file_name_label" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="file_size_label" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Component id="output_button" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="output_folder_label" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="split_size_label" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="split_size_text" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Component id="jProgressBar2" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Component id="split_button" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JButton" name="file_button">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Dialog" size="18" style="0"/>
|
||||
</Property>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/images/icons8-add-file-30.png"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Open file"/>
|
||||
<Property name="doubleBuffered" type="boolean" value="true"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="file_buttonActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="file_name_label">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Dialog" size="18" style="0"/>
|
||||
</Property>
|
||||
<Property name="doubleBuffered" type="boolean" value="true"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="output_button">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Dialog" size="18" style="0"/>
|
||||
</Property>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/images/icons8-add-folder-30.png"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Change output folder"/>
|
||||
<Property name="doubleBuffered" type="boolean" value="true"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="output_buttonActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="file_size_label">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Dialog" size="18" style="0"/>
|
||||
</Property>
|
||||
<Property name="doubleBuffered" type="boolean" value="true"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="output_folder_label">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Dialog" size="18" style="0"/>
|
||||
</Property>
|
||||
<Property name="doubleBuffered" type="boolean" value="true"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="split_size_label">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Dialog" size="18" style="0"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Split size (MBs):"/>
|
||||
<Property name="doubleBuffered" type="boolean" value="true"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JTextField" name="split_size_text">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Dialog" size="18" style="0"/>
|
||||
</Property>
|
||||
<Property name="doubleBuffered" type="boolean" value="true"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JProgressBar" name="jProgressBar2">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Dialog" size="18" style="0"/>
|
||||
</Property>
|
||||
<Property name="doubleBuffered" type="boolean" value="true"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="split_button">
|
||||
<Properties>
|
||||
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||
<Color blue="ff" green="cc" red="66" type="rgb"/>
|
||||
</Property>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Dialog" size="24" style="1"/>
|
||||
</Property>
|
||||
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||
<Color blue="ff" green="ff" red="ff" type="rgb"/>
|
||||
</Property>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/images/icons8-cut-30.png"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="SPLIT FILE"/>
|
||||
<Property name="doubleBuffered" type="boolean" value="true"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="split_buttonActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
372
src/main/java/com/tonikelope/megabasterd/FileSplitterDialog.java
Normal file
372
src/main/java/com/tonikelope/megabasterd/FileSplitterDialog.java
Normal file
@ -0,0 +1,372 @@
|
||||
/*
|
||||
* Copyright (C) 2018 tonikelope
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.tonikelope.megabasterd;
|
||||
|
||||
import static com.tonikelope.megabasterd.MainPanel.DEFAULT_FONT;
|
||||
import static com.tonikelope.megabasterd.MainPanel.THREAD_POOL;
|
||||
import static com.tonikelope.megabasterd.MiscTools.swingInvoke;
|
||||
import static com.tonikelope.megabasterd.MiscTools.updateFonts;
|
||||
import java.awt.Dialog;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
import static java.lang.Integer.MAX_VALUE;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.JFileChooser;
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author tonikelope
|
||||
*/
|
||||
public class FileSplitterDialog extends javax.swing.JDialog {
|
||||
|
||||
private final MainPanelView _mainPanelView;
|
||||
private final MainPanel _main_panel;
|
||||
private File _file = null;
|
||||
private File _output_dir = null;
|
||||
private long _progress = 0L;
|
||||
|
||||
/**
|
||||
* Creates new form FileSplitterDialog
|
||||
*/
|
||||
public FileSplitterDialog(MainPanelView parent, boolean modal) {
|
||||
super(parent, modal);
|
||||
_main_panel = parent.getMain_panel();
|
||||
initComponents();
|
||||
updateFonts(this.getRootPane(), DEFAULT_FONT, _main_panel.getZoom_factor());
|
||||
_mainPanelView = parent;
|
||||
}
|
||||
|
||||
private List<Path> _splitFile() throws IOException {
|
||||
|
||||
int mBperSplit = Integer.parseInt(this.split_size_text.getText());
|
||||
|
||||
if (mBperSplit <= 0) {
|
||||
throw new IllegalArgumentException("mBperSplit must be more than zero");
|
||||
}
|
||||
|
||||
List<Path> partFiles = new ArrayList<>();
|
||||
final long sourceSize = Files.size(Paths.get(this._file.getAbsolutePath()));
|
||||
final long bytesPerSplit = 1024L * 1024L * mBperSplit;
|
||||
final long numSplits = sourceSize / bytesPerSplit;
|
||||
final long remainingBytes = sourceSize % bytesPerSplit;
|
||||
int position = 0;
|
||||
int conta_split = 1;
|
||||
|
||||
try (RandomAccessFile sourceFile = new RandomAccessFile(this._file.getAbsolutePath(), "r");
|
||||
FileChannel sourceChannel = sourceFile.getChannel()) {
|
||||
|
||||
for (; position < numSplits; position++, conta_split++) {
|
||||
_writePartToFile(bytesPerSplit, position * bytesPerSplit, sourceChannel, partFiles, conta_split);
|
||||
}
|
||||
|
||||
if (remainingBytes > 0) {
|
||||
_writePartToFile(remainingBytes, position * bytesPerSplit, sourceChannel, partFiles, conta_split);
|
||||
}
|
||||
}
|
||||
return partFiles;
|
||||
}
|
||||
|
||||
private void _writePartToFile(long byteSize, long position, FileChannel sourceChannel, List<Path> partFiles, int conta_split) throws IOException {
|
||||
|
||||
Path fileName = Paths.get(this._output_dir.getAbsolutePath() + "/" + this._file.getName() + ".part" + String.valueOf(conta_split));
|
||||
try (RandomAccessFile toFile = new RandomAccessFile(fileName.toFile(), "rw");
|
||||
FileChannel toChannel = toFile.getChannel()) {
|
||||
sourceChannel.position(position);
|
||||
toChannel.transferFrom(sourceChannel, 0, byteSize);
|
||||
}
|
||||
partFiles.add(fileName);
|
||||
|
||||
this._progress += byteSize;
|
||||
|
||||
swingInvoke(
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
jProgressBar2.setValue((int) Math.ceil((MAX_VALUE / (double) _file.length()) * _progress));
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
file_button = new javax.swing.JButton();
|
||||
file_name_label = new javax.swing.JLabel();
|
||||
output_button = new javax.swing.JButton();
|
||||
file_size_label = new javax.swing.JLabel();
|
||||
output_folder_label = new javax.swing.JLabel();
|
||||
split_size_label = new javax.swing.JLabel();
|
||||
split_size_text = new javax.swing.JTextField();
|
||||
jProgressBar2 = new javax.swing.JProgressBar();
|
||||
split_button = new javax.swing.JButton();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
|
||||
setTitle("File Splitter");
|
||||
|
||||
file_button.setFont(new java.awt.Font("Dialog", 0, 18)); // NOI18N
|
||||
file_button.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/icons8-add-file-30.png"))); // NOI18N
|
||||
file_button.setText("Open file");
|
||||
file_button.setDoubleBuffered(true);
|
||||
file_button.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
file_buttonActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
file_name_label.setFont(new java.awt.Font("Dialog", 0, 18)); // NOI18N
|
||||
file_name_label.setDoubleBuffered(true);
|
||||
|
||||
output_button.setFont(new java.awt.Font("Dialog", 0, 18)); // NOI18N
|
||||
output_button.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/icons8-add-folder-30.png"))); // NOI18N
|
||||
output_button.setText("Change output folder");
|
||||
output_button.setDoubleBuffered(true);
|
||||
output_button.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
output_buttonActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
file_size_label.setFont(new java.awt.Font("Dialog", 0, 18)); // NOI18N
|
||||
file_size_label.setDoubleBuffered(true);
|
||||
|
||||
output_folder_label.setFont(new java.awt.Font("Dialog", 0, 18)); // NOI18N
|
||||
output_folder_label.setDoubleBuffered(true);
|
||||
|
||||
split_size_label.setFont(new java.awt.Font("Dialog", 0, 18)); // NOI18N
|
||||
split_size_label.setText("Split size (MBs):");
|
||||
split_size_label.setDoubleBuffered(true);
|
||||
|
||||
split_size_text.setFont(new java.awt.Font("Dialog", 0, 18)); // NOI18N
|
||||
split_size_text.setDoubleBuffered(true);
|
||||
|
||||
jProgressBar2.setFont(new java.awt.Font("Dialog", 0, 18)); // NOI18N
|
||||
jProgressBar2.setDoubleBuffered(true);
|
||||
|
||||
split_button.setBackground(new java.awt.Color(102, 204, 255));
|
||||
split_button.setFont(new java.awt.Font("Dialog", 1, 24)); // NOI18N
|
||||
split_button.setForeground(new java.awt.Color(255, 255, 255));
|
||||
split_button.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/icons8-cut-30.png"))); // NOI18N
|
||||
split_button.setText("SPLIT FILE");
|
||||
split_button.setDoubleBuffered(true);
|
||||
split_button.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
split_buttonActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(file_button, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(file_name_label, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(output_button, javax.swing.GroupLayout.DEFAULT_SIZE, 976, Short.MAX_VALUE)
|
||||
.addComponent(file_size_label, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(output_folder_label, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(jProgressBar2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(split_size_label)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(split_size_text))
|
||||
.addComponent(split_button, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(file_button)
|
||||
.addGap(9, 9, 9)
|
||||
.addComponent(file_name_label)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(file_size_label)
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(output_button)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(output_folder_label)
|
||||
.addGap(18, 18, 18)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(split_size_label)
|
||||
.addComponent(split_size_text, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(jProgressBar2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(split_button, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void file_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_file_buttonActionPerformed
|
||||
// TODO add your handling code here:
|
||||
|
||||
this.file_button.setText("Opening file...");
|
||||
|
||||
this.file_button.setEnabled(false);
|
||||
|
||||
this.output_button.setEnabled(false);
|
||||
|
||||
this.split_button.setEnabled(false);
|
||||
|
||||
JFileChooser filechooser = new javax.swing.JFileChooser();
|
||||
|
||||
filechooser.setDialogTitle("Add files");
|
||||
|
||||
filechooser.setAcceptAllFileFilterUsed(false);
|
||||
|
||||
if (filechooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION && filechooser.getSelectedFile().canRead()) {
|
||||
|
||||
this._file = filechooser.getSelectedFile();
|
||||
this.file_name_label.setText(this._file.getAbsolutePath());
|
||||
this.file_size_label.setText(MiscTools.formatBytes(this._file.length()));
|
||||
this.output_folder_label.setText(this._file.getParentFile().getAbsolutePath());
|
||||
this.jProgressBar2.setMinimum(0);
|
||||
this.jProgressBar2.setMaximum(MAX_VALUE);
|
||||
this.jProgressBar2.setStringPainted(true);
|
||||
this.jProgressBar2.setValue(0);
|
||||
this._progress = 0L;
|
||||
}
|
||||
|
||||
this.file_button.setText("Open file");
|
||||
|
||||
this.file_button.setEnabled(true);
|
||||
|
||||
this.output_button.setEnabled(true);
|
||||
|
||||
this.split_button.setEnabled(true);
|
||||
|
||||
pack();
|
||||
|
||||
}//GEN-LAST:event_file_buttonActionPerformed
|
||||
|
||||
private void output_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_output_buttonActionPerformed
|
||||
// TODO add your handling code here:
|
||||
|
||||
this.output_button.setText("Changing output folder...");
|
||||
|
||||
this.file_button.setEnabled(false);
|
||||
|
||||
this.output_button.setEnabled(false);
|
||||
|
||||
this.split_button.setEnabled(false);
|
||||
|
||||
JFileChooser filechooser = new javax.swing.JFileChooser();
|
||||
|
||||
filechooser.setDialogTitle("Add directory");
|
||||
|
||||
filechooser.setFileSelectionMode(javax.swing.JFileChooser.DIRECTORIES_ONLY);
|
||||
|
||||
filechooser.setAcceptAllFileFilterUsed(false);
|
||||
|
||||
if (filechooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION && filechooser.getSelectedFile().canRead()) {
|
||||
|
||||
this._output_dir = filechooser.getSelectedFile();
|
||||
|
||||
this.output_folder_label.setText(this._output_dir.getAbsolutePath());
|
||||
}
|
||||
|
||||
this.output_button.setText("Change output folder");
|
||||
|
||||
this.file_button.setEnabled(true);
|
||||
|
||||
this.output_button.setEnabled(true);
|
||||
|
||||
this.split_button.setEnabled(true);
|
||||
|
||||
pack();
|
||||
}//GEN-LAST:event_output_buttonActionPerformed
|
||||
|
||||
private void split_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_split_buttonActionPerformed
|
||||
// TODO add your handling code here:
|
||||
|
||||
if (this._file != null && this._output_dir != null && !this.split_size_text.getText().equals("")) {
|
||||
|
||||
this.split_button.setText("SPLITTING FILE...");
|
||||
|
||||
this.file_button.setEnabled(false);
|
||||
|
||||
this.output_button.setEnabled(false);
|
||||
|
||||
this.split_button.setEnabled(false);
|
||||
|
||||
this.split_size_text.setEnabled(false);
|
||||
|
||||
Dialog tthis = this;
|
||||
|
||||
THREAD_POOL.execute(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
try {
|
||||
_splitFile();
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(FileSplitterDialog.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
|
||||
JOptionPane.showMessageDialog(tthis, "File successfully splitted!");
|
||||
|
||||
split_button.setText("SPLIT FILE");
|
||||
|
||||
file_button.setEnabled(true);
|
||||
|
||||
output_button.setEnabled(true);
|
||||
|
||||
split_button.setEnabled(true);
|
||||
|
||||
split_size_text.setEnabled(true);
|
||||
|
||||
pack();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}//GEN-LAST:event_split_buttonActionPerformed
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton file_button;
|
||||
private javax.swing.JLabel file_name_label;
|
||||
private javax.swing.JLabel file_size_label;
|
||||
private javax.swing.JProgressBar jProgressBar2;
|
||||
private javax.swing.JButton output_button;
|
||||
private javax.swing.JLabel output_folder_label;
|
||||
private javax.swing.JButton split_button;
|
||||
private javax.swing.JLabel split_size_label;
|
||||
private javax.swing.JTextField split_size_text;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
@ -37,7 +37,7 @@ public final class KissVideoStreamServer implements HttpHandler, SecureSingleThr
|
||||
|
||||
public static final int THREAD_START = 0x01;
|
||||
public static final int THREAD_STOP = 0x02;
|
||||
public static final int DEFAULT_WORKERS = 10;
|
||||
public static final int DEFAULT_WORKERS = 8;
|
||||
|
||||
private final MainPanel _main_panel;
|
||||
private final ConcurrentHashMap<String, HashMap<String, Object>> _link_cache;
|
||||
|
@ -48,7 +48,7 @@ import org.apache.http.auth.UsernamePasswordCredentials;
|
||||
*/
|
||||
public final class MainPanel {
|
||||
|
||||
public static final String VERSION = "4.2";
|
||||
public static final String VERSION = "4.3";
|
||||
public static final int THROTTLE_SLICE_SIZE = 16 * 1024;
|
||||
public static final int DEFAULT_BYTE_BUFFER_SIZE = 16 * 1024;
|
||||
public static final int STREAMER_PORT = 1337;
|
||||
|
@ -55,6 +55,20 @@
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="new_stream_menuActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="split_file_menu">
|
||||
<Properties>
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Dialog" size="18" style="0"/>
|
||||
</Property>
|
||||
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor">
|
||||
<Image iconType="3" name="/images/icons8-cut-30.png"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Split file"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="split_file_menuActionPerformed"/>
|
||||
</Events>
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JPopupMenu$Separator" name="jSeparator4">
|
||||
</MenuItem>
|
||||
<MenuItem class="javax.swing.JMenuItem" name="clean_all_down_menu">
|
||||
|
@ -247,6 +247,7 @@ public final class MainPanelView extends javax.swing.JFrame {
|
||||
new_download_menu = new javax.swing.JMenuItem();
|
||||
new_upload_menu = new javax.swing.JMenuItem();
|
||||
new_stream_menu = new javax.swing.JMenuItem();
|
||||
split_file_menu = new javax.swing.JMenuItem();
|
||||
jSeparator4 = new javax.swing.JPopupMenu.Separator();
|
||||
clean_all_down_menu = new javax.swing.JMenuItem();
|
||||
clean_all_up_menu = new javax.swing.JMenuItem();
|
||||
@ -452,6 +453,16 @@ public final class MainPanelView extends javax.swing.JFrame {
|
||||
}
|
||||
});
|
||||
file_menu.add(new_stream_menu);
|
||||
|
||||
split_file_menu.setFont(new java.awt.Font("Dialog", 0, 18)); // NOI18N
|
||||
split_file_menu.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/icons8-cut-30.png"))); // NOI18N
|
||||
split_file_menu.setText("Split file");
|
||||
split_file_menu.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
split_file_menuActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
file_menu.add(split_file_menu);
|
||||
file_menu.add(jSeparator4);
|
||||
|
||||
clean_all_down_menu.setFont(new java.awt.Font("Dialog", 0, 18)); // NOI18N
|
||||
@ -1083,6 +1094,15 @@ public final class MainPanelView extends javax.swing.JFrame {
|
||||
}
|
||||
}//GEN-LAST:event_clean_all_up_menuActionPerformed
|
||||
|
||||
private void split_file_menuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_split_file_menuActionPerformed
|
||||
// TODO add your handling code here:
|
||||
FileSplitterDialog dialog = new FileSplitterDialog(this, true);
|
||||
|
||||
dialog.setLocationRelativeTo(this);
|
||||
|
||||
dialog.setVisible(true);
|
||||
}//GEN-LAST:event_split_file_menuActionPerformed
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JMenuItem about_menu;
|
||||
private javax.swing.JMenuItem clean_all_down_menu;
|
||||
@ -1116,6 +1136,7 @@ public final class MainPanelView extends javax.swing.JFrame {
|
||||
private javax.swing.JButton pause_all_up_button;
|
||||
private javax.swing.JMenuItem settings_menu;
|
||||
private javax.swing.JLabel smart_proxy_status;
|
||||
private javax.swing.JMenuItem split_file_menu;
|
||||
private javax.swing.JLabel status_down_label;
|
||||
private javax.swing.JLabel status_up_label;
|
||||
private javax.swing.JLabel up_remtime_label;
|
||||
|
@ -44,7 +44,7 @@
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jTabbedPane1" max="32767" attributes="0"/>
|
||||
<Component id="jTabbedPane1" pref="536" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="cancel_button" min="-2" max="-2" attributes="0"/>
|
||||
@ -127,7 +127,7 @@
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="downloads_scroll_pane" pref="465" max="32767" attributes="0"/>
|
||||
<Component id="downloads_scroll_pane" pref="471" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
@ -406,7 +406,7 @@
|
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
|
||||
<Font name="Dialog" size="18" style="0"/>
|
||||
</Property>
|
||||
<Property name="text" type="java.lang.String" value="Custom URL:"/>
|
||||
<Property name="text" type="java.lang.String" value="Custom URL (optional):"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JSpinner" name="max_downloads_spinner">
|
||||
@ -637,7 +637,7 @@
|
||||
<Component id="max_up_speed_label" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="max_up_speed_spinner" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace pref="269" max="32767" attributes="0"/>
|
||||
<EmptySpace pref="275" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
@ -796,7 +796,7 @@
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="mega_accounts_scrollpane" pref="118" max="32767" attributes="0"/>
|
||||
<Component id="mega_accounts_scrollpane" pref="121" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="remove_mega_account_button" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
@ -805,7 +805,7 @@
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="elc_accounts_label" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="elc_accounts_scrollpane" pref="118" max="32767" attributes="0"/>
|
||||
<Component id="elc_accounts_scrollpane" pref="121" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="remove_elc_account_button" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
@ -1079,7 +1079,7 @@
|
||||
<Component id="import_settings_button" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="export_settings_button" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace pref="144" max="32767" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
|
@ -671,7 +671,7 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
||||
});
|
||||
|
||||
smart_proxy_url_label.setFont(new java.awt.Font("Dialog", 0, 18)); // NOI18N
|
||||
smart_proxy_url_label.setText("Custom URL:");
|
||||
smart_proxy_url_label.setText("Custom URL (optional):");
|
||||
|
||||
max_downloads_spinner.setFont(new java.awt.Font("Dialog", 0, 18)); // NOI18N
|
||||
max_downloads_spinner.setDoubleBuffered(true);
|
||||
@ -882,7 +882,7 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
||||
downloads_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(downloads_panelLayout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(downloads_scroll_pane, javax.swing.GroupLayout.DEFAULT_SIZE, 465, Short.MAX_VALUE)
|
||||
.addComponent(downloads_scroll_pane, javax.swing.GroupLayout.DEFAULT_SIZE, 471, Short.MAX_VALUE)
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
@ -987,7 +987,7 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
||||
.addGroup(uploads_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(max_up_speed_label)
|
||||
.addComponent(max_up_speed_spinner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addContainerGap(269, Short.MAX_VALUE))
|
||||
.addContainerGap(275, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
jTabbedPane1.addTab("Uploads", new javax.swing.ImageIcon(getClass().getResource("/images/icons8-upload-to-ftp-30.png")), uploads_panel); // NOI18N
|
||||
@ -1166,7 +1166,7 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jLabel1)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(mega_accounts_scrollpane, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE)
|
||||
.addComponent(mega_accounts_scrollpane, javax.swing.GroupLayout.DEFAULT_SIZE, 121, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(accounts_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(remove_mega_account_button)
|
||||
@ -1174,7 +1174,7 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(elc_accounts_label)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(elc_accounts_scrollpane, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE)
|
||||
.addComponent(elc_accounts_scrollpane, javax.swing.GroupLayout.DEFAULT_SIZE, 121, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(accounts_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(remove_elc_account_button)
|
||||
@ -1383,7 +1383,7 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
||||
.addGroup(advanced_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(import_settings_button)
|
||||
.addComponent(export_settings_button))
|
||||
.addContainerGap(144, Short.MAX_VALUE))
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
jTabbedPane1.addTab("Advanced", new javax.swing.ImageIcon(getClass().getResource("/images/icons8-administrative-tools-30.png")), advanced_panel); // NOI18N
|
||||
@ -1411,7 +1411,7 @@ public final class SettingsDialog extends javax.swing.JDialog {
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 530, Short.MAX_VALUE)
|
||||
.addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 536, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(cancel_button)
|
||||
|
BIN
src/main/resources/images/icons8-cut-30.png
Normal file
BIN
src/main/resources/images/icons8-cut-30.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
Loading…
x
Reference in New Issue
Block a user