This repository has been archived by the owner on Jan 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added functional ConversionTab. Added example to RenamingTab
- Loading branch information
Mitch Talmadge
committed
Jun 27, 2015
1 parent
baa889c
commit 6d73543
Showing
9 changed files
with
362 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
135 changes: 135 additions & 0 deletions
135
src/main/java/me/MitchT/EmojiTools/GUI/Tabs/ConversionTab.form
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="me.MitchT.EmojiTools.GUI.Tabs.ConversionTab"> | ||
<grid id="27dc6" binding="contentPane" layout-manager="BorderLayout" hgap="0" vgap="0"> | ||
<constraints> | ||
<xy x="20" y="20" width="393" height="322"/> | ||
</constraints> | ||
<properties/> | ||
<border type="none"/> | ||
<children> | ||
<grid id="6b665" layout-manager="FormLayout"> | ||
<rowspec value="center:18px:noGrow"/> | ||
<rowspec value="center:max(d;4px):noGrow"/> | ||
<rowspec value="top:4dlu:noGrow"/> | ||
<rowspec value="center:d:grow"/> | ||
<rowspec value="center:d:grow"/> | ||
<colspec value="fill:200px:noGrow"/> | ||
<colspec value="fill:max(d;4px):noGrow"/> | ||
<constraints border-constraint="North"/> | ||
<properties/> | ||
<border type="etched" title="Folder or .png Location"/> | ||
<children> | ||
<component id="4e3f0" class="javax.swing.JTextField" binding="fileNameField"> | ||
<constraints> | ||
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false"> | ||
<preferred-size width="150" height="-1"/> | ||
</grid> | ||
<forms defaultalign-horz="false"/> | ||
</constraints> | ||
<properties> | ||
<columns value="15"/> | ||
<editable value="false"/> | ||
<text value="File Name"/> | ||
</properties> | ||
</component> | ||
<component id="a97f0" class="javax.swing.JButton" binding="browseButton" default-binding="true"> | ||
<constraints> | ||
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/> | ||
<forms/> | ||
</constraints> | ||
<properties> | ||
<text value="&Browse..."/> | ||
</properties> | ||
</component> | ||
<component id="37e5a" class="javax.swing.JLabel"> | ||
<constraints> | ||
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> | ||
<forms/> | ||
</constraints> | ||
<properties> | ||
<text value="Either select a folder of Emoji .png files to"/> | ||
</properties> | ||
</component> | ||
<component id="20527" class="javax.swing.JLabel"> | ||
<constraints> | ||
<grid row="1" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/> | ||
<forms/> | ||
</constraints> | ||
<properties> | ||
<text value="convert, or select a single .png file."/> | ||
</properties> | ||
</component> | ||
</children> | ||
</grid> | ||
<grid id="a64dd" layout-manager="FormLayout"> | ||
<rowspec value="center:d:grow"/> | ||
<colspec value="fill:d:grow"/> | ||
<constraints border-constraint="Center"/> | ||
<properties/> | ||
<border type="etched" title="Options"/> | ||
<children> | ||
<grid id="b1baf" layout-manager="FormLayout"> | ||
<rowspec value="center:25px:noGrow"/> | ||
<rowspec value="center:25px:noGrow"/> | ||
<colspec value="fill:d:noGrow"/> | ||
<constraints> | ||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="1" fill="1" indent="0" use-parent-layout="false"/> | ||
<forms defaultalign-vert="false"/> | ||
</constraints> | ||
<properties/> | ||
<border type="etched" title="Conversion Direction"/> | ||
<children> | ||
<component id="a7672" class="javax.swing.JRadioButton" binding="conversionRadioButton1"> | ||
<constraints> | ||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> | ||
<forms/> | ||
</constraints> | ||
<properties> | ||
<selected value="true"/> | ||
<text value="&CgBI to RGBA (Pincrushed to Normal)"/> | ||
</properties> | ||
</component> | ||
<component id="f32f4" class="javax.swing.JRadioButton" binding="conversionRadioButton2"> | ||
<constraints> | ||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/> | ||
<forms/> | ||
</constraints> | ||
<properties> | ||
<enabled value="false"/> | ||
<text value="&RGBA to CgBI (Normal to Pincrushed) -- WORK IN PROGRESS"/> | ||
</properties> | ||
</component> | ||
</children> | ||
</grid> | ||
</children> | ||
</grid> | ||
<grid id="b6b48" layout-manager="BorderLayout" hgap="0" vgap="0"> | ||
<constraints border-constraint="South"/> | ||
<properties/> | ||
<border type="none"/> | ||
<children> | ||
<component id="5b333" class="javax.swing.JButton" binding="startRenamingButton"> | ||
<constraints border-constraint="Center"/> | ||
<properties> | ||
<enabled value="false"/> | ||
<hideActionText value="false"/> | ||
<text value="Start C&onversion"/> | ||
</properties> | ||
</component> | ||
<component id="40cca" class="javax.swing.JButton" binding="openRootDirectoryButton"> | ||
<constraints border-constraint="West"/> | ||
<properties> | ||
<text value="&Open Root Directory"/> | ||
</properties> | ||
</component> | ||
</children> | ||
</grid> | ||
</children> | ||
</grid> | ||
<buttonGroups> | ||
<group name="conversionDirectionGroup"> | ||
<member id="a7672"/> | ||
<member id="f32f4"/> | ||
</group> | ||
</buttonGroups> | ||
</form> |
102 changes: 102 additions & 0 deletions
102
src/main/java/me/MitchT/EmojiTools/GUI/Tabs/ConversionTab.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
package me.MitchT.EmojiTools.GUI.Tabs; | ||
|
||
import me.MitchT.EmojiTools.Conversion.ConversionManager; | ||
import me.MitchT.EmojiTools.EmojiTools; | ||
import me.MitchT.EmojiTools.GUI.ConversionDialog; | ||
import me.MitchT.EmojiTools.GUI.EmojiToolsGUI; | ||
import me.MitchT.EmojiTools.OperationManager; | ||
|
||
import javax.swing.*; | ||
import javax.swing.filechooser.FileNameExtensionFilter; | ||
import java.awt.*; | ||
import java.awt.event.ActionEvent; | ||
import java.awt.event.ActionListener; | ||
import java.io.File; | ||
import java.io.IOException; | ||
|
||
public class ConversionTab extends OperationTab implements ActionListener { | ||
private final EmojiToolsGUI gui; | ||
private JPanel contentPane; | ||
private JTextField fileNameField; | ||
private JButton browseButton; | ||
private JRadioButton conversionRadioButton1; | ||
private JRadioButton conversionRadioButton2; | ||
private JButton startRenamingButton; | ||
private JButton openRootDirectoryButton; | ||
|
||
private OperationManager currentOperationManager; | ||
private boolean cancelled; | ||
private File conversionFile; | ||
|
||
public ConversionTab(EmojiToolsGUI gui) { | ||
this.gui = gui; | ||
|
||
this.setLayout(new BorderLayout()); | ||
this.add(this.contentPane, BorderLayout.CENTER); | ||
|
||
this.browseButton.addActionListener(this); | ||
|
||
this.conversionRadioButton1.addActionListener(this); | ||
this.conversionRadioButton1.addActionListener(this); | ||
|
||
this.openRootDirectoryButton.addActionListener(this); | ||
this.startRenamingButton.addActionListener(this); | ||
} | ||
|
||
private void startConversion() { | ||
this.cancelled = false; | ||
|
||
ConversionDialog conversionDialog = new ConversionDialog(this, this.gui.getLogo()); | ||
this.currentOperationManager = new ConversionManager(this.conversionFile, this.gui, conversionDialog); | ||
currentOperationManager.start(); | ||
conversionDialog.setVisible(true); | ||
|
||
this.gui.showMessageDialog("Emoji Conversion Complete! All Done! :)"); | ||
} | ||
|
||
@Override | ||
public void stopOperations() { | ||
if (this.currentOperationManager != null) | ||
this.currentOperationManager.stop(); | ||
this.cancelled = true; | ||
} | ||
|
||
private void openFileChooser() { | ||
this.fileNameField.setText("File Name"); | ||
|
||
JFileChooser fileChooser = new JFileChooser(EmojiTools.getRootDirectory()); | ||
FileNameExtensionFilter filter = new FileNameExtensionFilter("Folder or PNG File (*.png)", "png"); | ||
fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); | ||
fileChooser.setFileFilter(filter); | ||
int returnVal = fileChooser.showOpenDialog(this); | ||
if (returnVal == JFileChooser.APPROVE_OPTION) { | ||
this.fileNameField.setText(fileChooser.getSelectedFile().getName()); | ||
this.conversionFile = fileChooser.getSelectedFile(); | ||
} | ||
updateStartButton(); | ||
} | ||
|
||
private void updateStartButton() { | ||
if (!this.fileNameField.getText().equals("File Name")) | ||
this.startRenamingButton.setEnabled(true); | ||
else | ||
this.startRenamingButton.setEnabled(false); | ||
} | ||
|
||
@Override | ||
public void actionPerformed(ActionEvent e) { | ||
if (e.getSource().equals(this.browseButton)) | ||
openFileChooser(); | ||
else if (e.getSource().equals(this.openRootDirectoryButton)) { | ||
Desktop desktop = Desktop.getDesktop(); | ||
try { | ||
desktop.open(EmojiTools.getRootDirectory()); | ||
} catch (IOException e1) { | ||
e1.printStackTrace(); | ||
} | ||
} else if (e.getSource().equals(this.startRenamingButton)) { | ||
startConversion(); | ||
} | ||
updateStartButton(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.