use of org.openide.DialogDescriptor in project gephi-plugins-bootcamp by gephi.
the class TestAction method actionPerformed.
@Override
public void actionPerformed(ActionEvent e) {
// Do something, display a message
NotifyDescriptor d = new NotifyDescriptor.Message("Hello...now trying to display a dialog", NotifyDescriptor.INFORMATION_MESSAGE);
DialogDisplayer.getDefault().notify(d);
// Do something - for instance display a dialog
// Dialogs API documentation: http://bits.netbeans.org/dev/javadoc/org-openide-dialogs/index.html?overview-summary.html
DialogDescriptor dd = new DialogDescriptor(new JPanel(), "My Dialog", false, null);
DialogDisplayer.getDefault().notify(dd);
}
use of org.openide.DialogDescriptor in project gephi-plugins-bootcamp by gephi.
the class SQLiteDatabaseExporterUI method action.
@Override
public void action() {
// Create exporter
final SQLiteDatabaseExporter exporter = new SQLiteDatabaseExporter();
// Create the settings panel
SQLiteDatabaseSettingsPanel settingPanel = new SQLiteDatabaseSettingsPanel();
settingPanel.setup(exporter);
final DialogDescriptor dd = new DialogDescriptor(settingPanel, "SQLite Database Export");
Object result = DialogDisplayer.getDefault().notify(dd);
if (result == NotifyDescriptor.OK_OPTION) {
// This line will write the file path from the panel to the exporter's <code>setPath()<code> method.
settingPanel.unsetup(true);
// Create a new executor and execute
LongTaskExecutor executor = new LongTaskExecutor(true, "SQLite Exporter");
executor.setDefaultErrorHandler(errorHandler);
executor.execute(exporter, new Runnable() {
@Override
public void run() {
// Get the current workspace and set it to the exporter
Workspace currentWorkspace = Lookup.getDefault().lookup(ProjectController.class).getCurrentWorkspace();
exporter.setWorkspace(currentWorkspace);
// Execute export
cancelled = !exporter.execute();
// If not cancelled, write a status line message
if (!cancelled) {
StatusDisplayer.getDefault().setStatusText("Export to SQLite database completed");
}
}
});
} else {
settingPanel.unsetup(false);
}
}
use of org.openide.DialogDescriptor in project gephi by gephi.
the class DesktopImportControllerUI method importFile.
@Override
public void importFile(FileObject fileObject) {
try {
final FileImporter importer = controller.getFileImporter(FileUtil.toFile(fileObject));
if (importer == null) {
NotifyDescriptor.Message msg = new NotifyDescriptor.Message(NbBundle.getMessage(getClass(), "DesktopImportControllerUI.error_no_matching_file_importer"), NotifyDescriptor.WARNING_MESSAGE);
DialogDisplayer.getDefault().notify(msg);
return;
}
//MRU
MostRecentFiles mostRecentFiles = Lookup.getDefault().lookup(MostRecentFiles.class);
mostRecentFiles.addFile(fileObject.getPath());
ImporterUI ui = controller.getUI(importer);
if (ui != null) {
String title = NbBundle.getMessage(DesktopImportControllerUI.class, "DesktopImportControllerUI.file.ui.dialog.title", ui.getDisplayName());
JPanel panel = ui.getPanel();
FileImporter[] fi = (FileImporter[]) Array.newInstance(importer.getClass(), 1);
fi[0] = importer;
ui.setup(fi);
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.OK_OPTION)) {
ui.unsetup(false);
return;
}
ui.unsetup(true);
}
LongTask task = null;
if (importer instanceof LongTask) {
task = (LongTask) importer;
}
//Execute task
fileObject = getArchivedFile(fileObject);
final String containerSource = fileObject.getNameExt();
final InputStream stream = fileObject.getInputStream();
String taskName = NbBundle.getMessage(DesktopImportControllerUI.class, "DesktopImportControllerUI.taskName", containerSource);
executor.execute(task, new Runnable() {
@Override
public void run() {
try {
Container container = controller.importFile(stream, importer);
if (container != null) {
container.setSource(containerSource);
finishImport(container);
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
}, taskName, errorHandler);
} catch (Exception ex) {
Logger.getLogger("").log(Level.WARNING, "", ex);
}
}
use of org.openide.DialogDescriptor in project gephi by gephi.
the class ProjectControllerUIImpl method projectProperties.
@Override
public void projectProperties() {
Project project = controller.getCurrentProject();
ProjectPropertiesUI ui = Lookup.getDefault().lookup(ProjectPropertiesUI.class);
if (ui != null) {
JPanel panel = ui.getPanel();
ui.setup(project);
DialogDescriptor dd = new DialogDescriptor(panel, NbBundle.getMessage(ProjectControllerUIImpl.class, "ProjectProperties_dialog_title"));
Object result = DialogDisplayer.getDefault().notify(dd);
if (result == NotifyDescriptor.OK_OPTION) {
ui.unsetup(project);
}
}
}
use of org.openide.DialogDescriptor in project gephi by gephi.
the class DataLaboratoryHelper method executeAttributeColumnsManipulator.
/**
* Prepares the dialog UI of a AttributeColumnsManipulator if it has one and executes the manipulator in a separate
* Thread when the dialog is accepted or directly if there is no UI.
* @param m AttributeColumnsManipulator
* @param graphModel Graph model of the table
* @param table Table of the column
* @param column Column to manipulate
*/
public void executeAttributeColumnsManipulator(final AttributeColumnsManipulator m, final GraphModel graphModel, final Table table, final Column column) {
if (m.canManipulateColumn(table, column)) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
final AttributeColumnsManipulatorUI ui = m.getUI(table, column);
// Show a dialog for the manipulator UI if it provides one. If not, execute the manipulator directly:
if (ui != null) {
final JButton okButton = new JButton(NbBundle.getMessage(DataLaboratoryHelper.class, "DataLaboratoryHelper.ui.okButton.text"));
DialogControls dialogControls = new DialogControlsImpl(okButton);
ui.setup(m, graphModel, table, column, dialogControls);
JPanel settingsPanel = ui.getSettingsPanel();
DialogDescriptor dd = new DialogDescriptor(settingsPanel, NbBundle.getMessage(DataLaboratoryHelper.class, "SettingsPanel.title", ui.getDisplayName()), ui.isModal(), new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource().equals(okButton)) {
ui.unSetup();
executeAttributeColumnsManipulatorInOtherThread(m, table, column);
} else {
ui.unSetup();
}
}
});
dd.setOptions(new Object[] { okButton, DialogDescriptor.CANCEL_OPTION });
// All options close
dd.setClosingOptions(null);
Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
dialog.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
ui.unSetup();
}
});
dialog.setVisible(true);
} else {
executeAttributeColumnsManipulatorInOtherThread(m, table, column);
}
}
});
}
}
Aggregations