use of org.gephi.desktop.preview.api.PreviewUIController in project gephi by gephi.
the class PreviewSettingsTopComponent method setup.
public void setup(PreviewUIModel previewModel) {
propertySheet.setNodes(new Node[] { new PreviewNode(propertySheet) });
PreviewUIController previewUIController = Lookup.getDefault().lookup(PreviewUIController.class);
if (previewModel != null) {
ratioSlider.setValue((int) (previewModel.getVisibilityRatio() * 100));
}
//Presets
if (previewModel == null) {
saveButton.setEnabled(false);
labelPreset.setEnabled(false);
presetComboBox.setEnabled(false);
presetComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "---" }));
} else {
saveButton.setEnabled(true);
labelPreset.setEnabled(true);
presetComboBox.setEnabled(true);
DefaultComboBoxModel comboBoxModel = new DefaultComboBoxModel();
defaultPresetLimit = 0;
for (PreviewPreset preset : previewUIController.getDefaultPresets()) {
comboBoxModel.addElement(preset);
defaultPresetLimit++;
}
PreviewPreset[] userPresets = previewUIController.getUserPresets();
if (userPresets.length > 0) {
comboBoxModel.addElement(NO_SELECTION);
for (PreviewPreset preset : userPresets) {
comboBoxModel.addElement(preset);
}
}
presetComboBox.setSelectedItem(previewModel.getCurrentPreset());
presetComboBox.setModel(comboBoxModel);
}
//Refresh tabs
int tabCount = tabbedPane.getTabCount();
for (int i = 2; i < tabCount; i++) {
//Start at 2, not removing settings and renderer manager tabs
tabbedPane.removeTabAt(i);
}
for (PreviewUI pui : Lookup.getDefault().lookupAll(PreviewUI.class)) {
pui.unsetup();
}
if (previewModel != null) {
PreviewController previewController = Lookup.getDefault().lookup(PreviewController.class);
PreviewModel pModel = previewController.getModel();
//Add new tabs
for (PreviewUI pui : Lookup.getDefault().lookupAll(PreviewUI.class)) {
pui.setup(pModel);
JPanel pluginPanel = pui.getPanel();
if (UIUtils.isAquaLookAndFeel()) {
pluginPanel.setBackground(UIManager.getColor("NbExplorerView.background"));
}
if (pui.getIcon() != null) {
tabbedPane.addTab(pui.getPanelTitle(), pui.getIcon(), pluginPanel);
} else {
tabbedPane.addTab(pui.getPanelTitle(), pluginPanel);
}
}
}
}
use of org.gephi.desktop.preview.api.PreviewUIController in project gephi by gephi.
the class PreviewSettingsTopComponent method saveButtonActionPerformed.
//GEN-LAST:event_refreshButtonActionPerformed
private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {
//GEN-FIRST:event_saveButtonActionPerformed
PreviewUIController previewController = Lookup.getDefault().lookup(PreviewUIController.class);
PreviewPreset preset = previewController.getModel().getCurrentPreset();
boolean saved = false;
if (isDefaultPreset(preset)) {
NotifyDescriptor.InputLine question = new NotifyDescriptor.InputLine(NbBundle.getMessage(PreviewSettingsTopComponent.class, "PreviewSettingsTopComponent.savePreset.input"), NbBundle.getMessage(PreviewSettingsTopComponent.class, "PreviewSettingsTopComponent.savePreset.input.title"));
if (DialogDisplayer.getDefault().notify(question) == NotifyDescriptor.OK_OPTION) {
String input = question.getInputText();
if (input != null && !input.isEmpty()) {
previewController.savePreset(input);
saved = true;
StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(PreviewSettingsTopComponent.class, "PreviewSettingsTopComponent.savePreset.status", input));
}
}
} else {
previewController.savePreset(preset.getName());
saved = true;
StatusDisplayer.getDefault().setStatusText(NbBundle.getMessage(PreviewSettingsTopComponent.class, "PreviewSettingsTopComponent.savePreset.status", preset.getName()));
}
if (saved) {
//refresh combo
DefaultComboBoxModel comboBoxModel = new DefaultComboBoxModel();
defaultPresetLimit = 0;
for (PreviewPreset p : previewController.getDefaultPresets()) {
comboBoxModel.addElement(p);
defaultPresetLimit++;
}
PreviewPreset[] userPresets = previewController.getUserPresets();
if (userPresets.length > 0) {
comboBoxModel.addElement(NO_SELECTION);
for (PreviewPreset p : userPresets) {
comboBoxModel.addElement(p);
}
}
comboBoxModel.setSelectedItem(previewController.getModel().getCurrentPreset());
presetComboBox.setModel(comboBoxModel);
}
}
Aggregations