org.openide.DialogDisplayer Java Examples

The following examples show how to use org.openide.DialogDisplayer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ModelInfoAction.java    From opensim-gui with Apache License 2.0 6 votes vote down vote up
public void performAction() {
    ModelInfoJPanel infoPanel=new ModelInfoJPanel();
    Node[] selected = ExplorerTopComponent.findInstance().getExplorerManager().getSelectedNodes();
    // Action shouldn't be available otherwise'
    OneModelNode modelNode = (OneModelNode) selected[0];
    Model mdl = modelNode.getModel();
    infoPanel.setModelName(mdl.getName());
    infoPanel.setModelFile(mdl.getInputFileName());
    infoPanel.setDynamicsEngineName(mdl.getSimbodyEngine().getConcreteClassName());
    infoPanel.setAuthors(
            mdl.getCredits());
    infoPanel.setReferences(mdl.getPublications());
    DialogDescriptor dlg = new DialogDescriptor(infoPanel, "Model Info.");
    dlg.setOptions(new Object[]{new JButton("Close")});
    dlg.setClosingOptions(null);
    DialogDisplayer.getDefault().notify(dlg);
}
 
Example #2
Source File: ProjectConfig.java    From tikione-jacocoverage with MIT License 6 votes vote down vote up
/**
 * Load project's configuration.
 *
 * @throws IOException if cannot load configuration.
 */
@SuppressWarnings("unchecked")
public void load()
        throws IOException {
    getInternalPref().clear();
    getPkgclssExclude().clear();
    prjCfgFile.getParentFile().mkdirs();
    if (prjCfgFile.exists()) {
        try {
            getInternalPref().putAll((Map<Object, Object>) mapper.readValue(prjCfgFile, Map.class).get(JSON_GENERAL));
            getPkgclssExclude().addAll((Collection<? extends String>) mapper.readValue(prjCfgFile, Map.class).get(JSON_PKGFILTER));
        } catch (IOException ex) {
            LOGGER.log(Level.INFO, "Project's JaCoCoverage configuration file format is outdated or invalid. Reset cause:", ex);
            String msg = "The project's JaCoCoverage configuration file format is outdated or invalid.\n"
                    + "The configuration file has been reset to support new format.";
            DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(msg, NotifyDescriptor.WARNING_MESSAGE));
        }
    }
}
 
Example #3
Source File: ManagePluginsAction.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void actionPerformed(ActionEvent arg0) {
    GrailsPluginsPanel panel = new GrailsPluginsPanel(project);
    javax.swing.JButton close =
        new javax.swing.JButton(NbBundle.getMessage(ManagePluginsAction.class, "CTL_Close"));
    close.getAccessibleContext()
         .setAccessibleDescription(NbBundle.getMessage(ManagePluginsAction.class, "CTL_Close"));

    DialogDescriptor descriptor =
        new DialogDescriptor(panel, NbBundle.getMessage(ManagePluginsAction.class, "CTL_PluginTitle"),
            true, new Object[] { close }, close, DialogDescriptor.DEFAULT_ALIGN,
            new HelpCtx(GrailsPluginsPanel.class), null); // NOI18N
    Dialog dlg = null;

    try {
        dlg = DialogDisplayer.getDefault().createDialog(descriptor);
        dlg.setVisible(true);
    } finally {
        try {
            if (dlg != null) {
                dlg.dispose();
            }
        } finally {
            panel.dispose();
        }
    }
}
 
Example #4
Source File: GLInfo.java    From constellation with Apache License 2.0 6 votes vote down vote up
/**
 * Generate a user dialogue box to alert the user that the hardware/graphics
 * drivers they are using are incompatible with CONSTELLATION
 *
 * @param drawable - a GLAutoDrawable object currently being displayed on
 * the screen. This may be null in the event of the method being called from
 * a GLException exception handler.
 */
public static void respondToIncompatibleHardwareOrGL(final GLAutoDrawable drawable) {
    final String basicInfo = drawable == null ? "Not available" : (new GLInfo(drawable.getGL())).getBasicInfo();
    final String errorMessage
            = BrandingUtilities.APPLICATION_NAME + " requires a minimum of "
            + "OpenGL version " + MINIMUM_OPEN_GL_VERSION + "\n\n"
            + "This PC has an incompatible graphics card.\n"
            + "Please contact CONSTELLATION support, or use a different PC.\n\n"
            + "This PC's details:\n\n" + basicInfo;

    new Thread(() -> {
        final InfoTextPanel itp = new InfoTextPanel(errorMessage);
        final NotifyDescriptor d = new NotifyDescriptor.Message(itp, NotifyDescriptor.ERROR_MESSAGE);
        DialogDisplayer.getDefault().notify(d);
    }).start();
}
 
Example #5
Source File: DialogDisplayer50960Test.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testRedundantActionPerformed () {
    JButton b1 = new JButton ("Do");
    JButton b2 = new JButton ("Don't");
    ActionListener listener = new ActionListener () {
        public void actionPerformed (ActionEvent event) {
            assertFalse ("actionPerformed() only once.", performed);
            performed = true;
        }
    };
    DialogDescriptor dd = new DialogDescriptor (
                        "...",
                        "My Dialog",
                        true,
                        new JButton[] {b1, b2},
                        b2,
                        DialogDescriptor.DEFAULT_ALIGN,
                        null,
                        null
                    );
    dd.setButtonListener (listener);
    Dialog dlg = DialogDisplayer.getDefault ().createDialog (dd);
    b1.doClick ();
    assertTrue ("Button b1 invoked.", performed);
}
 
Example #6
Source File: NbUtils.java    From netbeans-mmd-plugin with Apache License 2.0 6 votes vote down vote up
@Nullable
public static FileEditPanel.DataContainer editFilePath (@Nullable Component parentComponent, @Nonnull final String title, @Nullable final File projectFolder, @Nullable final FileEditPanel.DataContainer data) {
  final FileEditPanel filePathEditor = new FileEditPanel(projectFolder, data);

  filePathEditor.doLayout();
  filePathEditor.setPreferredSize(new Dimension(450, filePathEditor.getPreferredSize().height));

  final NotifyDescriptor desc = new NotifyDescriptor.Confirmation(filePathEditor, title, NotifyDescriptor.OK_CANCEL_OPTION, NotifyDescriptor.PLAIN_MESSAGE);
  FileEditPanel.DataContainer result = null;
  if (DialogDisplayer.getDefault().notify(desc) == NotifyDescriptor.OK_OPTION) {
    result = filePathEditor.getData();
    if (!result.isValid()) {
      NbUtils.msgError(parentComponent, String.format(java.util.ResourceBundle.getBundle("com/igormaznitsa/nbmindmap/i18n/Bundle").getString("MMDGraphEditor.editFileLinkForTopic.errorCantFindFile"), result.getFilePathWithLine()));
      result = null;
    }
  }
  return result;
}
 
Example #7
Source File: AbstractOutputPane.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@NbBundle.Messages({
    "MSG_TooMuchTextSelected=Selecting large parts of text can cause "
            + "Out-Of-Memory errors. Do you want to continue?"
})
public void selectAll() {
    unlockScroll();
    getCaret().setVisible(true);
    int start = 0;
    int end = getLength();
    if (end - start > 20000000 && !copyingOfLargeParts) { // 40 MB
        NotifyDescriptor nd = new NotifyDescriptor.Confirmation(
                Bundle.MSG_TooMuchTextSelected(),
                NotifyDescriptor.YES_NO_OPTION);
        Object result = DialogDisplayer.getDefault().notify(nd);
        if (result == NotifyDescriptor.YES_OPTION) {
            copyingOfLargeParts = true;
        } else {
            return;
        }
    }
    textView.setSelectionStart(start);
    textView.setSelectionEnd(end);
}
 
Example #8
Source File: Browser.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private boolean show() {
    final DialogDescriptor dialogDescriptor =
            new DialogDescriptor(getBrowserPanel(), NbBundle.getMessage(Browser.class, "CTL_Browser_BrowseFolders_Title")); // NOI18N
    dialogDescriptor.setModal(true);
    dialogDescriptor.setHelpCtx(new HelpCtx(helpID));
    dialogDescriptor.setValid(false);

    addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if( ExplorerManager.PROP_SELECTED_NODES.equals(evt.getPropertyName()) ) {
                Node[] nodes = getSelectedNodes();
                if (nodes != null && nodes.length > 0) {
                    selectedNodes = nodes;
                    dialogDescriptor.setValid(nodes.length > 0);
                }
            }
        }
    });

    Dialog dialog = DialogDisplayer.getDefault().createDialog(dialogDescriptor);
    dialog.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(Browser.class, "CTL_Browser_BrowseFolders_Title")); // NOI18N
    dialog.setVisible(true);

    return DialogDescriptor.OK_OPTION.equals(dialogDescriptor.getValue());
}
 
Example #9
Source File: TableViewTopComponent.java    From constellation with Apache License 2.0 6 votes vote down vote up
private void createSelectColumnDialog() {
    final ColumnSelectPanel panel = new ColumnSelectPanel(dataTable);
    final JButton cancelButton = new JButton("Cancel");
    final JButton okButton = new JButton("OK");
    final DialogDescriptor dd = new DialogDescriptor(panel, "Select Column...", true, new Object[]{
        okButton, cancelButton
    }, "OK", DialogDescriptor.DEFAULT_ALIGN, null, (final ActionEvent e) -> {
        if (e.getActionCommand().equals("OK")) {
            try {
                panel.okButtonActionPerformed(e);
            } catch (Exception ex) {
                Exceptions.printStackTrace(ex);
            }
        }
    });
    dd.setClosingOptions(new JButton[]{
        cancelButton, okButton
    });
    Dialog d;
    d = DialogDisplayer.getDefault().createDialog(dd);
    d.pack();
    d.setPreferredSize(new Dimension(200, 350));
    d.setMinimumSize(new Dimension(350, 450));
    d.setVisible(true);
}
 
Example #10
Source File: ImportFromJdbcAction.java    From constellation with Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(final ActionEvent e) {
    final Graph graph = context.getGraph();

    final WizardDescriptor.Panel<WizardDescriptor>[] panels = new WizardDescriptor.Panel[]{new ConnectionPanelController(graph), new TablesPanelController(), new MappingPanelController(graph, false)};
    final String[] steps = new String[panels.length];
    int i = 0;
    for (final WizardDescriptor.Panel<WizardDescriptor> panel : panels) {
        final JComponent jc = (JComponent) panel.getComponent();
        steps[i] = jc.getName();
        jc.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, i);
        jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DISPLAYED, true);
        jc.putClientProperty(WizardDescriptor.PROP_CONTENT_DATA, steps);
        jc.putClientProperty(WizardDescriptor.PROP_AUTO_WIZARD_STYLE, true);
        jc.putClientProperty(WizardDescriptor.PROP_CONTENT_NUMBERED, true);
        i++;
    }
    final WizardDescriptorData wd = new WizardDescriptorData(panels);
    wd.setTitleFormat(new MessageFormat("{0}"));
    wd.setTitle(Bundle.MSG_ImportFromJdbc());
    final Object result = DialogDisplayer.getDefault().notify(wd);
    if (result == DialogDescriptor.OK_OPTION) {
        final ImportFromJdbcPlugin exporter = new ImportFromJdbcPlugin(wd.data);
        PluginExecution.withPlugin(exporter).executeLater(graph);
    }
}
 
Example #11
Source File: RunTargetsAction.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {
    String title = NbBundle.getMessage(RunTargetsAction.class, "TITLE_run_advanced");
    AdvancedActionPanel panel = new AdvancedActionPanel(project, allTargets);
    DialogDescriptor dd = new DialogDescriptor(panel, title);
    dd.setOptionType(NotifyDescriptor.OK_CANCEL_OPTION);
    JButton run = new JButton(NbBundle.getMessage(RunTargetsAction.class, "LBL_run_advanced_run"));
    run.setDefaultCapable(true);
    JButton cancel = new JButton(NbBundle.getMessage(RunTargetsAction.class, "LBL_run_advanced_cancel"));
    dd.setOptions(new Object[] {run, cancel});
    dd.setModal(true);
    Object result = DialogDisplayer.getDefault().notify(dd);
    if (result.equals(run)) {
        try {
            panel.run();
        } catch (IOException x) {
            AntModule.err.notify(x);
        }
    }
}
 
Example #12
Source File: ProjectTemplateLoader.java    From NBANDROID-V2 with Apache License 2.0 6 votes vote down vote up
@Override
public void instantiate(File from, File to) throws TemplateProcessingException {
    if ("build.gradle".equals(to.getName()) && buildGradleLocation == null) {
        buildGradleLocation = to;
    }
    String process = process(templatePath + from.getPath(), parameters);
    if (process == null) {
        NotifyDescriptor nd = new NotifyDescriptor.Message("Unable to instantiate template " + from.getPath(), NotifyDescriptor.ERROR_MESSAGE);
        DialogDisplayer.getDefault().notifyLater(nd);
    } else {
        try {
            FileUtils.writeToFile(to, process);
        } catch (IOException ex) {
            Exceptions.printStackTrace(ex);
        }
    }
}
 
Example #13
Source File: ExportToJdbcPlugin.java    From constellation with Apache License 2.0 6 votes vote down vote up
private static void notifyException(final Exception ex) {
    final ByteArrayOutputStream sb = new ByteArrayOutputStream();
    final PrintWriter w = new PrintWriter(sb);
    w.printf("Unexpected JDBC export exception: %s%n%n", ex.getMessage());
    w.printf("Stack trace:%n%n");
    ex.printStackTrace(w);
    w.flush();
    SwingUtilities.invokeLater(() -> {
        String message;
        try {
            message = sb.toString(StandardCharsets.UTF_8.name());
        } catch (UnsupportedEncodingException ex1) {
            LOGGER.severe(ex1.getLocalizedMessage());
            message = sb.toString();
        }
        final InfoTextPanel itp = new InfoTextPanel(message);
        final NotifyDescriptor d = new NotifyDescriptor.Message(itp, NotifyDescriptor.ERROR_MESSAGE);
        DialogDisplayer.getDefault().notify(d);
    });
}
 
Example #14
Source File: TreeTableView152857Test.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void testRemoveNodeInTTV () throws InterruptedException {
    StringKeys children = new StringKeys (true);
    children.doSetKeys (new String [] {"1", "3", "2"});
    Node root = new TestNode (children, "root");
    view = new TTV (root);
    TreeNode ta = Visualizer.findVisualizer(root);

    DialogDescriptor dd = new DialogDescriptor (view, "", false, null);
    Dialog d = DialogDisplayer.getDefault ().createDialog (dd);
    makeVisible(d);
    ((StringKeys) root.getChildren ()).doSetKeys (new String [] {"1", "2"});
    Thread.sleep (1000);

    assertEquals ("Node on 0nd position is '1'", "1", ta.getChildAt (0).toString ());
    assertEquals ("Node on 1st position is '2'", "2", ta.getChildAt (1).toString ());

    d.setVisible (false);
}
 
Example #15
Source File: MemoryAction.java    From constellation with Apache License 2.0 6 votes vote down vote up
@Override
    public void actionPerformed(ActionEvent e) {
        final long freemem = Runtime.getRuntime().freeMemory();
        final long totalmem = Runtime.getRuntime().totalMemory();
        final long maxmem = Runtime.getRuntime().maxMemory();

        final StringBuilder b = new StringBuilder();
        b.append(String.format("Free memory: %,d%n", freemem));
        b.append(String.format("Total memory: %,d%n", totalmem));
        b.append(String.format("Maximum memory: %,d%n", maxmem));

//        // test
//        for (MemoryPoolMXBean memoryPoolMXBeans : ManagementFactory.getMemoryPoolMXBeans()) {
//            b.append(memoryPoolMXBeans.getName());
//            b.append(memoryPoolMXBeans.getUsage());
//            b.append("\n");
//        }
        final NotifyDescriptor nd = new NotifyDescriptor.Message(b.toString(), NotifyDescriptor.INFORMATION_MESSAGE);
        DialogDisplayer.getDefault().notify(nd);
    }
 
Example #16
Source File: JaxWsServiceCreator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void createServiceFromWsdl() throws IOException {

    //initProjectInfo(project);

    final ProgressHandle handle = ProgressHandleFactory.createHandle(NbBundle.getMessage(JaxWsServiceCreator.class, "TXT_WebServiceGeneration")); //NOI18N

    Runnable r = new Runnable() {

        @Override
        public void run() {
            try {
                handle.start(100);
                generateWsFromWsdl15(handle);
            } catch (IOException e) {
                //finish progress bar
                handle.finish();
                String message = e.getLocalizedMessage();
                if (message != null) {
                    ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
                    NotifyDescriptor nd = new NotifyDescriptor.Message(message, NotifyDescriptor.ERROR_MESSAGE);
                    DialogDisplayer.getDefault().notify(nd);
                } else {
                    ErrorManager.getDefault().notify(ErrorManager.EXCEPTION, e);
                }
            }
        }
    };
    RequestProcessor.getDefault().post(r);
}
 
Example #17
Source File: SelectRootsPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void addURL(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addURL
    final NotifyDescriptor.InputLine nd = new NotifyDescriptor.InputLine(
        NbBundle.getMessage(SelectRootsPanel.class,"TXT_RemoteJavadoc"),
        NbBundle.getMessage(SelectRootsPanel.class,"TXT_RemoteJavadoc_Title"),
        NotifyDescriptor.OK_CANCEL_OPTION,
        NotifyDescriptor.PLAIN_MESSAGE);
    if (DialogDisplayer.getDefault().notify(nd) == NotifyDescriptor.OK_OPTION) {
        final String inputText = nd.getInputText();
        final DefaultListModel<URI> lm = (DefaultListModel<URI>) sources.getModel();
        final Set<URI> contained = new HashSet<>(Collections.list(lm.elements()));
        int index = sources.getSelectedIndex();
        index = index < 0 ? lm.getSize() : index + 1;
        try {
            URI uri = new URI(inputText);
            if (!contained.contains(uri)) {
                lm.add(index, uri);
                select(Collections.<Integer>singleton(index));
                index++;
            }
        } catch (URISyntaxException ex) {
            DialogDisplayer.getDefault().notify(
                new NotifyDescriptor.Message(
                    NbBundle.getMessage(SelectRootsPanel.class, "TXT_InvalidRoot", inputText),
                    NotifyDescriptor.ERROR_MESSAGE));
        }
    }
}
 
Example #18
Source File: CodeCustomizer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void show() {
    JavaCodeGenerator codeGen = (JavaCodeGenerator) FormEditor.getCodeGenerator(formModel);
    codeGen.regenerateCode(); // to have fresh code for code completion

    DialogDescriptor dd = new DialogDescriptor(codeView,
            NbBundle.getMessage(CodeCustomizer.class, "TITLE_CodeCustomizer"), // NOI18N
            true, DialogDescriptor.OK_CANCEL_OPTION, null, null);
    dd.setHelpCtx(new HelpCtx("gui.codecustomizer")); // NOI18N
    Object res = DialogDisplayer.getDefault().notify(dd);
    if (DialogDescriptor.OK_OPTION.equals(res)) {
        retreiveCurrentData();
        storeChanges();
    }
}
 
Example #19
Source File: NoSelectedServerWarning.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static String selectServerDialog(J2eeModule.Type[] moduleTypes, Profile j2eeProfile, String title, String description) {
    NoSelectedServerWarning panel = new NoSelectedServerWarning(moduleTypes, j2eeProfile);
    Object[] options = new Object[] {
        DialogDescriptor.OK_OPTION,
        DialogDescriptor.CANCEL_OPTION
    };
    final DialogDescriptor desc = new DialogDescriptor(panel, title, true, options,
            DialogDescriptor.OK_OPTION, DialogDescriptor.DEFAULT_ALIGN, null, null);
    desc.setMessageType(DialogDescriptor.WARNING_MESSAGE);
    Dialog dlg = null;
    try {
        dlg = DialogDisplayer.getDefault().createDialog(desc);
        dlg.getAccessibleContext().setAccessibleDescription(description);
        panel.addPropertyChangeListener(new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent evt) {
                if (evt.getPropertyName().equals(NoSelectedServerWarning.OK_ENABLED)) {
                    Object newvalue = evt.getNewValue();
                    if ((newvalue != null) && (newvalue instanceof Boolean)) {
                        desc.setValid(((Boolean)newvalue).booleanValue());
                    }
                }
            }
        }
        );
        desc.setValid(panel.getSelectedInstance() != null);
        panel.setSize(panel.getPreferredSize());
        dlg.pack();
        dlg.setVisible(true);
    } finally {
        if (dlg != null) {
            dlg.dispose();
        }
    }
    return desc.getValue() == DialogDescriptor.OK_OPTION
            ? panel.getSelectedInstance()
            : null;
}
 
Example #20
Source File: KeystoreSelector.java    From NBANDROID-V2 with Apache License 2.0 5 votes vote down vote up
private void changeAliasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_changeAliasActionPerformed
    // TODO add your handling code here:
    try {
        File f = new File(path.getText());
        if (f.exists()) {
            KeyStore ks = KeyStore.getInstance("jks");
            ks.load(new FileInputStream(f), keystorePassword.getPassword());
            EditKeyStore editKeyStore = new EditKeyStore(ks, alias.getText());
            DialogDescriptor dd = new DialogDescriptor(editKeyStore, "Choose Key", true, null);
            editKeyStore.setDescriptor(dd);
            Object notify = DialogDisplayer.getDefault().notify(dd);
            if (DialogDescriptor.OK_OPTION.equals(notify)) {
                if (editKeyStore.isNewKey()) {
                    ApkUtils.DN dn = editKeyStore.getNewDN();
                    boolean addNewKey = ApkUtils.addNewKey(ks, f, keystorePassword.getPassword(), dn);
                    if (!addNewKey) {
                        NotifyDescriptor nd = new NotifyDescriptor.Message("Unable to save new alias to key store!", NotifyDescriptor.ERROR_MESSAGE);
                        DialogDisplayer.getDefault().notifyLater(nd);
                    } else {
                        alias.setText(dn.getAlias());
                        keyPassword.setText(new String(dn.getPassword()));
                    }
                    keyPressed(null);
                } else {
                    alias.setText(editKeyStore.getAliasName());
                    keyPassword.setText("");
                }
                keyReleased(null);
            }
        }
    } catch (Exception ex) {
    }

}
 
Example #21
Source File: AddGroupAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
protected void performAction(Node[] nodes) {
    String defaultName = NbBundle.getMessage(AddGroupAction.class, "NEW_GROUP");  // NOI18N
    NotifyDescriptor.InputLine dlg = new NotifyDescriptor.InputLine(
            NbBundle.getMessage(AddGroupAction.class, "CTL_GroupLabel"), // NOI18N
            NbBundle.getMessage(AddGroupAction.class, "CTL_GroupTitle")); // NOI18N
    dlg.setInputText(defaultName);
    
    if (NotifyDescriptor.OK_OPTION.equals(DialogDisplayer.getDefault().notify(dlg))) {
        try {
            String newName = dlg.getInputText().trim();
            if (newName == null || newName.length() == 0) {
                newName = defaultName;
            }
            SaasGroup parent = nodes[0].getLookup().lookup(SaasGroup.class);
            
            try {
                SaasServicesModel.getInstance().createGroup(parent, newName);   
            } catch (Exception ex) {
                NotifyDescriptor.Message msg = new NotifyDescriptor.Message(ex.getMessage());
                DialogDisplayer.getDefault().notify(msg);
            }
        } catch (IllegalArgumentException e) {
            Exceptions.printStackTrace(e);
        }
    }
}
 
Example #22
Source File: BranchPicker.java    From netbeans with Apache License 2.0 5 votes vote down vote up
boolean openDialog () {
    final JButton okButton = new JButton();
    Mnemonics.setLocalizedText(okButton, NbBundle.getMessage(BranchPicker.class, "LBL_BranchPicker.okButton.text")); //NOI18N
    DialogDescriptor dd = new DialogDescriptor(panel, NbBundle.getMessage(BranchPicker.class, "LBL_BranchPicker.title"), //NOI18N
            true, new Object[] { okButton, DialogDescriptor.CANCEL_OPTION }, okButton, DialogDescriptor.DEFAULT_ALIGN, new HelpCtx(BranchPicker.class), null);
    okButton.setEnabled(false);
    Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
    ListSelectionListener list = new ListSelectionListener() {
        @Override
        public void valueChanged (ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                String selected = (String) panel.lstBranches.getSelectedValue();
                selectedPath = null;
                if (!FORBIDDEN_SELECTION.contains(selected)) {
                    selectedPath = selected;
                }
                okButton.setEnabled(selectedPath != null);
            }
        }
    };
    panel.lstBranches.addListSelectionListener(list);
    initializeItems();
    dialog.setVisible(true);
    SvnProgressSupport supp = loadingSupport;
    if (supp != null) {
        supp.cancel();
    }
    panel.lstBranches.removeListSelectionListener(list);
    return dd.getValue() == okButton;
}
 
Example #23
Source File: DateTimeRangePanel.java    From constellation with Apache License 2.0 5 votes vote down vote up
private void calendarButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_calendarButton1ActionPerformed
    final Date date = this.getFirstDate();
    DateChooserPanel dc = new DateChooserPanel(date);
    final DialogDescriptor dialog = new DialogDescriptor(dc, "Select Date", true, null);
    Integer result = (Integer) DialogDisplayer.getDefault().notify(dialog);
    if (result == 0) {
        spnDateTime1.setValue(dc.getSelectedDate());
    }
}
 
Example #24
Source File: OQLQueryCustomizer.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
public static boolean saveQuery(final String query,
                                final OQLSupport.OQLTreeModel treeModel,
                                final JTree tree) {
    JButton okButton = new JButton();
    Mnemonics.setLocalizedText(okButton, Bundle.OQLQueryCustomizer_OkButtonText());

    CustomizerPanel customizer = new CustomizerPanel(okButton,  treeModel);
    final DialogDescriptor dd = new DialogDescriptor(customizer,
                                        Bundle.OQLQueryCustomizer_SaveQueryCaption(), true,
                                        new Object[] { okButton,
                                        DialogDescriptor.CANCEL_OPTION },
                                        okButton, 0, HELP_CTX_SAVE_QUERY, null);
    final Dialog d = DialogDisplayer.getDefault().createDialog(dd);
    d.pack();
    d.setVisible(true);

    if (dd.getValue() == okButton) {
        OQLSupport.OQLQueryNode node;
        if (customizer.isNewQuery()) {
            OQLSupport.Query q = new OQLSupport.Query(query,
                                    customizer.getQueryName(),
                                    customizer.getQueryDescription());
            node = new OQLSupport.OQLQueryNode(q);
            treeModel.customCategory().add(node);
            treeModel.nodeStructureChanged(treeModel.customCategory());
        } else {
            node = (OQLSupport.OQLQueryNode)customizer.getSelectedValue();
            node.getUserObject().setScript(query);
            treeModel.nodeChanged(node);
        }
        tree.setSelectionPath(new TreePath(treeModel.getPathToRoot(node)));
        return true;
    } else {
        return false;
    }
}
 
Example #25
Source File: CreateLabDialog.java    From opensim-gui with Apache License 2.0 5 votes vote down vote up
private void addButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addButton1ActionPerformed
       AddOutputTextPanel createOutputPanel = new AddOutputTextPanel();
       DialogDescriptor dlg = new DialogDescriptor(createOutputPanel,"Add Output");
       dlg.setClosingOptions(null);
       dlg.setModal(true);
       DialogDisplayer.getDefault().createDialog(dlg).setVisible(true);
       Object userInput = dlg.getValue();
       if (((Integer)userInput).compareTo((Integer)DialogDescriptor.OK_OPTION)==0){
           ((LabOutputsNode)lab.getObject(Lab.OUTPUTS)).addOutput(createOutputPanel.getOutputDescription());
           outputListModel.addElement(createOutputPanel.getOutputDescription());
       }
// TODO add your handling code here:
    }
 
Example #26
Source File: SQLHistoryPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void deleteAllSQL() {
    NotifyDescriptor d = new NotifyDescriptor.Confirmation(
            NbBundle.getMessage(SQLHistoryPanel.class, "DESC_DeleteAll"),
            NbBundle.getMessage(SQLHistoryPanel.class, "LBL_DeleteAll"),
            NotifyDescriptor.YES_NO_OPTION);
    if (DialogDisplayer.getDefault().notify(d) == NotifyDescriptor.YES_OPTION) {
        SQLHistoryManager shm = SQLHistoryManager.getInstance();
        SQLHistory history = shm.getSQLHistory();
        history.clear();
        shm.save();
        htm.refresh();
    }
}
 
Example #27
Source File: MinifyKeyAction.java    From minifierbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {
    MinifyProperty minifyProperty = MinifyProperty.getInstance();
    DataObject dob = TopComponent.getRegistry().getActivated().getLookup().lookup(DataObject.class);

    if (dob != null && minifyProperty.isEnableShortKeyAction()) {
        FileObject fileObject = dob.getPrimaryFile();//       p = FileOwnerQuery.getOwner(fo);
        boolean allowAction = true;

        if (minifyProperty.isEnableShortKeyActionConfirmBox()) {
            NotifyDescriptor.Confirmation nd
                    = new NotifyDescriptor.Confirmation(
                            "Are you sure to minify " + fileObject.getNameExt() + " ?",
                            "Minify " + fileObject.getNameExt(),
                            NotifyDescriptor.YES_NO_OPTION);
            nd.setOptions(new Object[]{
                NotifyDescriptor.YES_OPTION,
                NotifyDescriptor.NO_OPTION});
            if (DialogDisplayer.getDefault().notify(nd).equals(NotifyDescriptor.NO_OPTION)) {
                allowAction = false;
            }
        }
        if (allowAction) {
            if (fileObject.isFolder()) {
                targetAction = new Minify(dob);
            } else {
                if (fileObject.getExt().equalsIgnoreCase("js")) {
                    targetAction = new JSMinify(dob);
                } else if (fileObject.getExt().equalsIgnoreCase("css")) {
                    targetAction = new CSSMinify(dob);
                } else if (fileObject.getExt().equalsIgnoreCase("html") || fileObject.getExt().equalsIgnoreCase("htm")) {
                    targetAction = new HTMLMinify(dob);
                }
            }
            targetAction.actionPerformed(e);
        }
    }
}
 
Example #28
Source File: JavaScopeBuilder.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Open a modal dialog to specify a new Scope.
 * 
 * @param title - the title of the dialog
 * @param scope - the scope to use to preselect parts
 * @return a new Scope or null if the dialog was canceled
 */
public static Scope open(String title, final Scope scope) {
    final CustomScopePanel panel = new CustomScopePanel();
    final AtomicBoolean successful = new AtomicBoolean();

    DialogDescriptor dialogDescriptor = new DialogDescriptor(
            panel,
            title,
            true, // modal
            new Object[]{DialogDescriptor.OK_OPTION, DialogDescriptor.CANCEL_OPTION},
            DialogDescriptor.CANCEL_OPTION,
            DialogDescriptor.DEFAULT_ALIGN,
            HelpCtx.DEFAULT_HELP,
            new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (e.getSource() == DialogDescriptor.OK_OPTION) {
                successful.set(true);
            }
        }
    });

    dialogDescriptor.setClosingOptions(new Object[]{DialogDescriptor.OK_OPTION, DialogDescriptor.CANCEL_OPTION});

    new Thread(new Runnable() {

        @Override
        public void run() {
            panel.initialize(scope);
        }
    }).start();
    
    DialogDisplayer.getDefault().createDialog(dialogDescriptor).setVisible(true);
    
    if(successful.get()) {
        return panel.getCustomScope();
    }
    return null;
}
 
Example #29
Source File: CatalogAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public @Override void actionPerformed(ActionEvent e) {
    
    Dialog dialog = dialogWRef.get ();

    if (dialog == null || ! dialog.isShowing ()) {

        final CatalogPanel cp = new CatalogPanel ();
        JButton closeButton = new JButton ();
        Mnemonics.setLocalizedText (closeButton,NbBundle.getMessage (CatalogAction.class, "BTN_CatalogPanel_CloseButton")); // NOI18N
        JButton openInEditor = new JButton ();
        openInEditor.setEnabled (false);
        OpenInEditorListener l = new OpenInEditorListener (cp, openInEditor);
        openInEditor.addActionListener (l);
        cp.getExplorerManager ().addPropertyChangeListener (l);
        Mnemonics.setLocalizedText (openInEditor,NbBundle.getMessage (CatalogAction.class, "BTN_CatalogPanel_OpenInEditorButton")); // NOI18N
        DialogDescriptor dd = new DialogDescriptor (cp,NbBundle.getMessage (CatalogAction.class, "LBL_CatalogPanel_Title"),  // NOI18N
                                false, // modal
                                new Object [] { openInEditor, closeButton },
                                closeButton,
                                DialogDescriptor.DEFAULT_ALIGN,
                                null,
                                null);
        dd.setClosingOptions (null);
        // set helpctx to null again, DialogDescriptor replaces null with HelpCtx.DEFAULT_HELP
        dd.setHelpCtx (null);
        
        dialog = DialogDisplayer.getDefault ().createDialog (dd);
        dialog.setVisible (true);
        dialogWRef = new WeakReference<Dialog> (dialog);
        
    } else {
        dialog.toFront ();
    }
    
}
 
Example #30
Source File: GotoOppositeAction.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void handleResult(LocationResult opposite) {
    FileObject fileObject = opposite.getFileObject();
    if (fileObject != null) {
        NbDocument.openDocument(fileObject, opposite.getOffset(), Line.ShowOpenType.OPEN, Line.ShowVisibilityType.FOCUS);
    } else if (opposite.getErrorMessage() != null) {
        String msg = opposite.getErrorMessage();
        NotifyDescriptor descr = new NotifyDescriptor.Message(msg, 
                NotifyDescriptor.INFORMATION_MESSAGE);
        DialogDisplayer.getDefault().notify(descr);
    }
}