Skip to content

Commit

Permalink
Core/lib manager: asking confirmation before deleting unmanaged library
Browse files Browse the repository at this point in the history
  • Loading branch information
Federico Fissore committed Mar 27, 2015
1 parent 103f2e4 commit 603dd3c
Showing 1 changed file with 13 additions and 0 deletions.
Expand Up @@ -36,6 +36,7 @@
import cc.arduino.ui.InstallerTableCell;
import cc.arduino.utils.Progress;

import javax.swing.*;
import java.awt.*;
import java.util.Collection;

Expand All @@ -44,6 +45,8 @@
@SuppressWarnings("serial")
public class LibraryManagerUI extends InstallerJDialog {

private LibrariesIndexer indexer;

@Override
protected FilteredAbstractTableModel createContribModel() {
return new LibrariesIndexTableModel();
Expand Down Expand Up @@ -82,6 +85,7 @@ public LibraryManagerUI(Frame parent) {
}

public void setIndexer(LibrariesIndexer indexer) {
this.indexer = indexer;
getContribModel().removeTableModelListener(tableModelListener);
categoryChooser.removeActionListener(categoryChooserActionListener);

Expand Down Expand Up @@ -181,6 +185,15 @@ public void run() {
}

public void onRemovePressed(final ContributedLibrary lib) {
boolean managedByIndex = indexer.getIndex().getLibraries().contains(lib);

if (!managedByIndex) {
int chosenOption = JOptionPane.showConfirmDialog(getParent(), _("This library is not listed on Library Manager. You won't be able to resinstall it from here.\nAre you sure you want to delete it?"), _("Please confirm library deletion"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
if (chosenOption != JOptionPane.YES_OPTION) {
return;
}
}

clearErrorMessage();
installerThread = new Thread(new Runnable() {
@Override
Expand Down

0 comments on commit 603dd3c

Please sign in to comment.