use of org.gephi.io.importer.spi.ImporterWizardUI in project gephi by gephi.
the class WizardVisualPanel1 method reloadDescription.
private void reloadDescription() {
String description = "";
if (emptyList()) {
description = NbBundle.getMessage(WizardPanel1.class, "ImportWizard.description_no_plugin_importers_installed");
} else {
String category = categoryList.getSelectedValue().toString();
String wizard = wizardList.getSelectedValue().toString();
for (ImporterWizardUI wizardUi : Lookup.getDefault().lookupAll(ImporterWizardUI.class)) {
if (category.equals(wizardUi.getCategory()) && wizard.equals(wizardUi.getDisplayName())) {
description = wizardUi.getDescription();
break;
}
}
}
descriptionArea.setText(description);
}
use of org.gephi.io.importer.spi.ImporterWizardUI in project gephi by gephi.
the class WizardVisualPanel1 method reloadSubType.
private ListModel reloadSubType() {
subTypeModel.clear();
if (categoryList.getSelectedValue() == null) {
return subTypeModel;
}
String category = categoryList.getSelectedValue().toString();
for (ImporterWizardUI wizardUi : Lookup.getDefault().lookupAll(ImporterWizardUI.class)) {
if (category.equals(wizardUi.getCategory())) {
subTypeModel.addElement(wizardUi.getDisplayName());
descriptionArea.setText(wizardUi.getDescription());
}
}
return subTypeModel;
}
use of org.gephi.io.importer.spi.ImporterWizardUI in project gephi by gephi.
the class ImportWizard method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
WizardIterator wizardIterator = new WizardIterator();
WizardDescriptor wizardDescriptor = new WizardDescriptor(wizardIterator);
wizardDescriptor.setTitleFormat(new MessageFormat("{0} ({1})"));
wizardDescriptor.setTitle(NbBundle.getMessage(getClass(), "ImportWizard.wizard.title"));
Dialog dialog = DialogDisplayer.getDefault().createDialog(wizardDescriptor);
dialog.setVisible(true);
dialog.toFront();
boolean cancelled = wizardDescriptor.getValue() != WizardDescriptor.FINISH_OPTION;
if (!cancelled) {
ImporterWizardUI wizardUI = wizardIterator.getCurrentWizardUI();
// Get Importer
WizardImporter importer = null;
for (WizardImporterBuilder wizardBuilder : Lookup.getDefault().lookupAll(WizardImporterBuilder.class)) {
WizardImporter im = wizardBuilder.buildImporter();
if (wizardUI.isUIForImporter(im)) {
importer = im;
}
}
if (importer == null) {
NotifyDescriptor.Message msg = new NotifyDescriptor.Message(NbBundle.getMessage(getClass(), "ImportWizard.error_no_matching_importer"), NotifyDescriptor.WARNING_MESSAGE);
DialogDisplayer.getDefault().notify(msg);
return;
}
// Unsetup
wizardIterator.unsetupPanels(importer);
ImportControllerUI importControllerUI = Lookup.getDefault().lookup(ImportControllerUI.class);
importControllerUI.importWizard(importer);
}
}
use of org.gephi.io.importer.spi.ImporterWizardUI in project gephi by gephi.
the class WizardIterator method nextPanel.
@Override
public void nextPanel() {
if (!hasNext()) {
throw new NoSuchElementException();
}
// change panel if the current is the first panel
if (index == 0) {
for (ImporterWizardUI wizardUi : Lookup.getDefault().lookupAll(ImporterWizardUI.class)) {
WizardVisualPanel1 visual1 = ((WizardVisualPanel1) current().getComponent());
if (visual1.getCurrentCategory().equals(wizardUi.getCategory()) && visual1.getCurrentWizard().equals(wizardUi.getDisplayName())) {
WizardDescriptor.Panel[] wizardPanels = wizardUi.getPanels();
WizardDescriptor.Panel tempFirstPanel = panels[0];
panels = new WizardDescriptor.Panel[wizardPanels.length + 1];
panels[0] = tempFirstPanel;
for (int i = 0; i < wizardPanels.length; i++) {
panels[i + 1] = wizardPanels[i];
wizardUi.setup(wizardPanels[i]);
}
currentWizardUI = wizardUi;
}
}
//
repaintLeftComponent();
}
index++;
}
use of org.gephi.io.importer.spi.ImporterWizardUI in project gephi by gephi.
the class DesktopImportControllerUI method importWizard.
@Override
public void importWizard(final WizardImporter importer) {
try {
if (importer == null) {
NotifyDescriptor.Message msg = new NotifyDescriptor.Message(NbBundle.getMessage(DesktopImportControllerUI.class, "DesktopImportControllerUI.error_no_matching_db_importer"), NotifyDescriptor.WARNING_MESSAGE);
DialogDisplayer.getDefault().notify(msg);
return;
}
String containerSource = NbBundle.getMessage(DesktopImportControllerUI.class, "DesktopImportControllerUI.wizardSource", "");
ImporterUI ui = controller.getUI(importer);
if (ui != null) {
String title = NbBundle.getMessage(DesktopImportControllerUI.class, "DesktopImportControllerUI.wizard.ui.dialog.title", ui.getDisplayName());
JPanel panel = ui.getPanel();
ui.setup(new WizardImporter[] { importer });
final DialogDescriptor dd = new DialogDescriptor(panel, title);
if (panel instanceof ValidationPanel) {
ValidationPanel vp = (ValidationPanel) panel;
vp.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
dd.setValid(!((ValidationPanel) e.getSource()).isProblem());
}
});
}
Object result = DialogDisplayer.getDefault().notify(dd);
if (result.equals(NotifyDescriptor.CANCEL_OPTION) || result.equals(NotifyDescriptor.CLOSED_OPTION)) {
ui.unsetup(false);
return;
}
ui.unsetup(true);
containerSource = ui.getDisplayName();
}
ImporterWizardUI wizardUI = controller.getWizardUI(importer);
if (wizardUI != null) {
containerSource = wizardUI.getCategory() + ":" + wizardUI.getDisplayName();
}
LongTask task = null;
if (importer instanceof LongTask) {
task = (LongTask) importer;
}
// Execute task
final String source = containerSource;
String taskName = NbBundle.getMessage(DesktopImportControllerUI.class, "DesktopImportControllerUI.taskName", containerSource);
executor.execute(task, new Runnable() {
@Override
public void run() {
try {
Container container = controller.importWizard(importer);
if (container != null) {
container.setSource(source);
finishImport(container);
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
}, taskName, errorHandler);
} catch (Exception ex) {
Logger.getLogger("").log(Level.WARNING, "", ex);
}
}
Aggregations