Skip to content

Commit

Permalink
multiple file addition
Browse files Browse the repository at this point in the history
  • Loading branch information
turiaso committed Jun 11, 2018
1 parent 9f8b07b commit 6038543
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 14 deletions.
1 change: 1 addition & 0 deletions tools/resourcemanager/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Changelog
3. Change color index
4. Switch two colors index
5. Add Program icon
6. Multiple file addition

#0.3.1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class CreateBackgroundDialog extends JDialog{
private JTextField backgroundPathText = new JTextField();
private JFileChooser backgroundPath = new JFileChooser(System.getProperty("user.home"));
private JButton acceptButon = new JButton("Ok");
private File[] selectedFiles = null;
private static final long serialVersionUID = 1L;

public CreateBackgroundDialog(ResourceManagerFrame parent, SGDKElement parentNode) {
Expand Down Expand Up @@ -73,6 +74,7 @@ public boolean accept(File f) {
}
});
backgroundPath.setAcceptAllFileFilterUsed(false);
backgroundPath.setMultiSelectionEnabled(true);

setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
Expand Down Expand Up @@ -102,7 +104,14 @@ public boolean accept(File f) {
public void mouseClicked(MouseEvent e){
int returnVal = backgroundPath.showDialog(parent, "New Background");
if (returnVal == JFileChooser.APPROVE_OPTION) {
backgroundPathText.setText(backgroundPath.getSelectedFile().getAbsolutePath());
selectedFiles = backgroundPath.getSelectedFiles();
String[] values = new String[selectedFiles.length];
int i = 0;
for(File f : selectedFiles) {
values[i] = f.getAbsolutePath();
i++;
}
backgroundPathText.setText(StringUtils.join(values, ","));
}
}
});
Expand Down Expand Up @@ -132,10 +141,13 @@ public void actionPerformed(ActionEvent e) {
}

if (validForm) {
SGDKBackground background = SGDKEntityFactory.createSGDKBackground(backgroundPathText.getText(), (SGDKFolder)parentNode);
if(background != null) {
parent.getProjectExplorer().getProjectExplorerTree().addElement(background, parentNode);
for(File f : selectedFiles) {
SGDKBackground background = SGDKEntityFactory.createSGDKBackground(f.getAbsolutePath(), (SGDKFolder)parentNode);
if(background != null) {
parent.getProjectExplorer().getProjectExplorerTree().addElement(background, parentNode);
}
}

clean();
parent.setEnabled(true);
setVisible(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class CreateEnvironmentDialog extends JDialog{

private JTextField environmentSoundPathText = new JTextField();
private JFileChooser environmentSoundPath = new JFileChooser(System.getProperty("user.home"));
private File[] selectedFiles = null;
private JButton acceptButon = new JButton("Ok");
private static final long serialVersionUID = 1L;

Expand Down Expand Up @@ -69,6 +70,7 @@ public boolean accept(File f) {
}
});
environmentSoundPath.setAcceptAllFileFilterUsed(false);
environmentSoundPath.setMultiSelectionEnabled(true);

setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
Expand Down Expand Up @@ -98,7 +100,14 @@ public boolean accept(File f) {
public void mouseClicked(MouseEvent e){
int returnVal = environmentSoundPath.showDialog(parent, "New Environment Sound");
if (returnVal == JFileChooser.APPROVE_OPTION) {
environmentSoundPathText.setText(environmentSoundPath.getSelectedFile().getAbsolutePath());
selectedFiles = environmentSoundPath.getSelectedFiles();
String[] values = new String[selectedFiles.length];
int i = 0;
for(File f : selectedFiles) {
values[i] = f.getAbsolutePath();
i++;
}
environmentSoundPathText.setText(StringUtils.join(values, ","));
}
}
});
Expand Down Expand Up @@ -128,8 +137,10 @@ public void actionPerformed(ActionEvent e) {
}

if (validForm) {
SGDKEnvironmentSound environmentSound = SGDKEntityFactory.createSGDKEnvironmentSound(environmentSoundPathText.getText(), (SGDKFolder)parentNode);
parent.getProjectExplorer().getProjectExplorerTree().addElement(environmentSound, parentNode);
for(File f : selectedFiles) {
SGDKEnvironmentSound environmentSound = SGDKEntityFactory.createSGDKEnvironmentSound(f.getAbsolutePath(), (SGDKFolder)parentNode);
parent.getProjectExplorer().getProjectExplorerTree().addElement(environmentSound, parentNode);
}
clean();
parent.setEnabled(true);
setVisible(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class CreateSFXDialog extends JDialog{

private JTextField fxSoundPathText = new JTextField();
private JFileChooser fxSoundPath = new JFileChooser(System.getProperty("user.home"));
private File[] selectedFiles = null;
private JButton acceptButon = new JButton("Ok");
private static final long serialVersionUID = 1L;

Expand Down Expand Up @@ -69,6 +70,7 @@ public boolean accept(File f) {
}
});
fxSoundPath.setAcceptAllFileFilterUsed(false);
fxSoundPath.setMultiSelectionEnabled(true);

setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
Expand Down Expand Up @@ -98,7 +100,14 @@ public boolean accept(File f) {
public void mouseClicked(MouseEvent e){
int returnVal = fxSoundPath.showDialog(parent, "New FX Sound");
if (returnVal == JFileChooser.APPROVE_OPTION) {
fxSoundPathText.setText(fxSoundPath.getSelectedFile().getAbsolutePath());
selectedFiles = fxSoundPath.getSelectedFiles();
String[] values = new String[selectedFiles.length];
int i = 0;
for(File f : selectedFiles) {
values[i] = f.getAbsolutePath();
i++;
}
fxSoundPathText.setText(StringUtils.join(values, ","));
}
}
});
Expand Down Expand Up @@ -128,8 +137,10 @@ public void actionPerformed(ActionEvent e) {
}

if (validForm) {
SGDKFXSound fxSound = SGDKEntityFactory.createSGDKFXSound(fxSoundPathText.getText(), (SGDKFolder)parentNode);
parent.getProjectExplorer().getProjectExplorerTree().addElement(fxSound,parentNode);
for(File f : selectedFiles) {
SGDKFXSound fxSound = SGDKEntityFactory.createSGDKFXSound(f.getAbsolutePath(), (SGDKFolder)parentNode);
parent.getProjectExplorer().getProjectExplorerTree().addElement(fxSound,parentNode);
}
clean();
parent.setEnabled(true);
setVisible(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class CreateSpriteDialog extends JDialog{

private JTextField spritePathText = new JTextField();
private JFileChooser spritePath = new JFileChooser(System.getProperty("user.home"));
private File[] selectedFiles = null;
private JButton acceptButon = new JButton("Ok");
private static final long serialVersionUID = 1L;

Expand Down Expand Up @@ -72,6 +73,7 @@ public boolean accept(File f) {
}
});
spritePath.setAcceptAllFileFilterUsed(false);
spritePath.setMultiSelectionEnabled(true);

setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
Expand Down Expand Up @@ -101,7 +103,14 @@ public boolean accept(File f) {
public void mouseClicked(MouseEvent e){
int returnVal = spritePath.showDialog(parent, "New Sprite");
if (returnVal == JFileChooser.APPROVE_OPTION) {
spritePathText.setText(spritePath.getSelectedFile().getAbsolutePath());
selectedFiles = spritePath.getSelectedFiles();
String[] values = new String[selectedFiles.length];
int i = 0;
for(File f : selectedFiles) {
values[i] = f.getAbsolutePath();
i++;
}
spritePathText.setText(StringUtils.join(values, ","));
}
}
});
Expand Down Expand Up @@ -131,9 +140,11 @@ public void actionPerformed(ActionEvent e) {
}

if (validForm) {
SGDKSprite sprite = SGDKEntityFactory.createSGDKSprite(spritePathText.getText(), (SGDKFolder)parentNode);
if(sprite != null) {
parent.getProjectExplorer().getProjectExplorerTree().addElement(sprite, parentNode);
for(File f : selectedFiles) {
SGDKSprite sprite = SGDKEntityFactory.createSGDKSprite(f.getAbsolutePath(), (SGDKFolder)parentNode);
if(sprite != null) {
parent.getProjectExplorer().getProjectExplorerTree().addElement(sprite, parentNode);
}
}
clean();
parent.setEnabled(true);
Expand Down

0 comments on commit 6038543

Please sign in to comment.