Java Code Examples for org.openide.DialogDisplayer

The following are top voted examples for showing how to use org.openide.DialogDisplayer. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: incubator-netbeans   File: ConnectUsingDriverAction.java   View source code 6 votes vote down vote up
@Override
protected boolean retrieveSchemas(SchemaPanel schemaPanel, DatabaseConnection dbcon, String defaultSchema) {
    fireConnectionStep(NbBundle.getMessage (ConnectUsingDriverAction.class, "ConnectionProgress_Schemas")); // NOI18N
    List<String> schemas = new ArrayList<String>();
    try {
        DatabaseMetaData dbMetaData = dbcon.getJDBCConnection().getMetaData();
        if (dbMetaData.supportsSchemasInTableDefinitions()) {
            ResultSet rs = dbMetaData.getSchemas();
            if (rs != null) {
                while (rs.next()) {
                    schemas.add(rs.getString(1).trim());
                }
            }
        }
    } catch (SQLException exc) {
        String message = NbBundle.getMessage(ConnectUsingDriverAction.class, "ERR_UnableObtainSchemas", exc.getMessage()); // NOI18N
        DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(message, NotifyDescriptor.ERROR_MESSAGE));
    }
    return schemaPanel.setSchemas(schemas, defaultSchema);
}
 
Example 2
Project: incubator-netbeans   File: InsertI18nStringAction.java   View source code 6 votes vote down vote up
/**
 * Basically I18nPanel wrapped by Ok, Cancel and Help buttons shown.
 * Handles OK button.
 */
private void showModalPanel() throws IOException {
    DialogDescriptor dd = new DialogDescriptor(
        createPanel(),
        Util.getString("CTL_InsertI18nDialogTitle"),
        true,
        NotifyDescriptor.OK_CANCEL_OPTION,
        NotifyDescriptor.OK_OPTION,
        DialogDescriptor.DEFAULT_ALIGN,
        new HelpCtx(InsertI18nStringAction.class),
        null
    );
    Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
    dialog.setVisible(true);
    if (dd.getValue() == NotifyDescriptor.OK_OPTION) {
        insertI18nString();
    }
}
 
Example 3
Project: incubator-netbeans   File: JFXPackagingPanel.java   View source code 6 votes vote down vote up
private void buttonManifestActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonManifestActionPerformed
    List<Map<String, String>> props = configs.getDefaultManifestEntriesTransparent();
    JFXProjectProperties.PropertiesTableModel appManifestEntriesTableModel = 
            new JFXProjectProperties.PropertiesTableModel(props, null, JFXProjectConfigurations.APP_MANIFEST_SUFFIXES, appManifestEntriesColumnNames);
    JFXApplicationMultiPropertyPanel panel = new JFXApplicationMultiPropertyPanel(appManifestEntriesTableModel);
    panel.setTableTitle(NbBundle.getMessage(JFXPackagingPanel.class, "LBL_ApplicationCustomManifestEntries.tablelabel")); // NOI18N
    panel.setRemark(NbBundle.getMessage(JFXPackagingPanel.class, "LBL_ApplicationCustomManifestEntries.remark")); // NOI18N
    DialogDescriptor dialogDesc = new DialogDescriptor(panel, NbBundle.getMessage(JFXPackagingPanel.class, "TITLE_ApplicationCustomManifestEntries"), true, null); //NOI18N
    panel.registerListeners();
    panel.setDialogDescriptor(dialogDesc);
    //panel.setColumnRenderer();
    Dialog dialog = DialogDisplayer.getDefault().createDialog(dialogDesc);
    dialog.setVisible(true);
    if (dialogDesc.getValue() == DialogDescriptor.OK_OPTION) {
        appManifestEntriesTableModel.removeEmptyRows();
        configs.setDefaultManifestEntriesTransparent(props);
        updateManifestMessage();
    }
    panel.unregisterListeners();
    dialog.dispose();
}
 
Example 4
Project: incubator-netbeans   File: LibrariesCustomizer.java   View source code 6 votes vote down vote up
@Messages({
    "ERR_InvalidName=The library name is not valid.",
    "# {0} - library name", "ERR_ExistingName=Library {0} already exists."
})
private void nameChanged () {
    Node[] nodes = this.getExplorerManager().getSelectedNodes();
    if (nodes.length == 1) {
        final LibraryImplementation lib = nodes[0].getLookup().lookup(LibraryImplementation.class);
        if (lib == null) {
            return;
        }
        final String newName = this.libraryName.getText();
        if (newName.equals(LibrariesSupport.getLocalizedName(lib))) {
            return;
        }
        if (newName.length () == 0) {
            DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(ERR_InvalidName(), NotifyDescriptor.ERROR_MESSAGE));
        } else if (isExistingDisplayName(model, newName, model.getArea(lib))) {
            DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(ERR_ExistingName(newName), NotifyDescriptor.ERROR_MESSAGE));
        } else {
            LibrariesSupport.setDisplayName(lib, newName);
        }
    }
}
 
Example 5
Project: incubator-netbeans   File: MergeRevision.java   View source code 6 votes vote down vote up
boolean show() {
    okButton = new JButton(NbBundle.getMessage(MergeRevision.class, "LBL_MergeRevision.OKButton.text")); //NOI18N
    org.openide.awt.Mnemonics.setLocalizedText(okButton, okButton.getText());
    dd = new DialogDescriptor(panel, NbBundle.getMessage(MergeRevision.class, "LBL_MergeRevision.title"), true,  //NOI18N
            new Object[] { okButton, DialogDescriptor.CANCEL_OPTION }, okButton, DialogDescriptor.DEFAULT_ALIGN,
            new HelpCtx("org.netbeans.modules.git.ui.merge.MergeRevision"), null); //NOI18N
    enableRevisionPanel();
    revisionPicker.addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange (PropertyChangeEvent evt) {
            if (evt.getPropertyName() == RevisionDialogController.PROP_VALID) {
                setValid(Boolean.TRUE.equals(evt.getNewValue()));
            }
        }
    });
    Dialog d = DialogDisplayer.getDefault().createDialog(dd);
    d.setVisible(true);
    return okButton == dd.getValue();
}
 
Example 6
Project: incubator-netbeans   File: FontEditor.java   View source code 6 votes vote down vote up
static private String [] getFonts () {
    if (fonts == null) {
        try {
            fonts = GraphicsEnvironment.getLocalGraphicsEnvironment ().getAvailableFontFamilyNames();
        } catch (RuntimeException e) {
            fonts = new String[0]; //NOI18N
            if (org.openide.util.Utilities.isMac()) {
                String msg = NbBundle.getMessage(FontEditor.class, "MSG_AppleBug"); //NOI18N
                DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(msg));
            } else {
                throw e;
            }
        }
    }
    return fonts;
}
 
Example 7
Project: incubator-netbeans   File: ShortcutPopupPanel.java   View source code 6 votes vote down vote up
private boolean overrideAll(Collection<ShortcutAction> actions) {
    JPanel innerPane = new JPanel();
    StringBuffer display = new StringBuffer();
    for(ShortcutAction sc : actions) {
        display.append(" '" + sc.getDisplayName() + "'<br>"); //NOI18N
    }

    innerPane.add(new JLabel(NbBundle.getMessage(KeymapViewModel.class, "Override_All", display))); //NOI18N
    DialogDescriptor descriptor = new DialogDescriptor(
            innerPane,
            NbBundle.getMessage(KeymapViewModel.class, "Conflicting_Shortcut_Dialog"), //NOI18N
            true,
            DialogDescriptor.YES_NO_OPTION,
            null,
            null);
    DialogDisplayer.getDefault().notify(descriptor);

    if (descriptor.getValue().equals(DialogDescriptor.YES_OPTION))
        return true;
    else return false;
}
 
Example 8
Project: incubator-netbeans   File: AddJavaFXPropertyCodeGenerator.java   View source code 6 votes vote down vote up
@Override
public void invoke() {
    Object o = component.getDocument().getProperty(Document.StreamDescriptionProperty);
    if (o instanceof DataObject) {
        DataObject d = (DataObject) o;
        JButton ok = new JButton(LBL_ButtonOK());
        FileObject primaryFile = d.getPrimaryFile();
        TypeElement element = handle.resolve(javac);
        TreePath path = javac.getTrees().getPath(element);
        Scope scope = javac.getTrees().getScope(path);
        final AddPropertyPanel addPropertyPanel = new AddPropertyPanel(javac, scope, existingFields, ok);
        DialogDescriptor dd = new DialogDescriptor(addPropertyPanel, CAP_AddProperty(), true, new Object[] {ok, LBL_ButtonCancel()}, ok, DialogDescriptor.DEFAULT_ALIGN, null, null);
        if (DialogDisplayer.getDefault().notify(dd) == ok) {
            perform(primaryFile, component, addPropertyPanel.getAddPropertyConfig(), scope);
        }
    }
}
 
Example 9
Project: incubator-netbeans   File: SQLStatementExecutor.java   View source code 6 votes vote down vote up
protected void commitOrRollback(String cmdName) {
    if (!error && commit(conn)) {
        long executionTime = System.currentTimeMillis() - startTime;
        String execTimeStr = SQLExecutionHelper.millisecondsToSeconds(executionTime);
        String infoMsg = cmdName + " " + NbBundle.getMessage(SQLStatementExecutor.class, "MSG_execution_success", execTimeStr);
        dataView.setInfoStatusText(infoMsg);
        executeOnSucess(); // delegate 
    } else {
        rollback(conn);
        reinstateToolbar();

        String msg = cmdName + " " + NbBundle.getMessage(SQLStatementExecutor.class, "MSG_failed");
        if (ex == null) {
            errorMsg = msg + " " + errorMsg;
        } else {
            errorMsg = msg;
        }

        ex = new DBException(errorMsg, ex);
        dataView.setErrorStatusText(conn, null, ex);

        NotifyDescriptor nd = new NotifyDescriptor.Message(ex.getMessage(), NotifyDescriptor.ERROR_MESSAGE);
        DialogDisplayer.getDefault().notify(nd);
    }
}
 
Example 10
Project: incubator-netbeans   File: CustomizerSources.java   View source code 6 votes vote down vote up
private void handleEncodingChange () {
        Charset enc = (Charset) encoding.getSelectedItem();
        String encName;
        if (enc != null) {
            encName = enc.name();
        }
        else {
            encName = originalEncoding;
        }
        if (!notified && encName!=null && !encName.equals(originalEncoding)) {
            DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(
                    NbBundle.getMessage(CustomizerSources.class,"MSG_EncodingWarning"), NotifyDescriptor.WARNING_MESSAGE));
            notified=true;
        }
        this.uiProperties.putAdditionalProperty(ProjectProperties.SOURCE_ENCODING, encName);
}
 
Example 11
Project: incubator-netbeans   File: ProgressPanel.java   View source code 6 votes vote down vote up
public void open(JComponent progressComponent, String title) {
    holder.add(progressComponent, BorderLayout.CENTER);
    try {
        DialogDescriptor dd = new DialogDescriptor(
            this,
            title,
            true,
            new Object[0],
            DialogDescriptor.NO_OPTION,
            DialogDescriptor.DEFAULT_ALIGN,
            null,
            null
            );
        dialog = DialogDisplayer.getDefault().createDialog(dd);
        dialog.setVisible(true);
    } finally {
        if (dialog != null) {
            dialog.dispose();
        }
    }
    
}
 
Example 12
Project: incubator-netbeans   File: ConfigurationsPanel.java   View source code 6 votes vote down vote up
private void btnEditActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEditActionPerformed
    ModelHandle2.Configuration conf = (ModelHandle2.Configuration) lstConfigurations.getSelectedValue();
    if (conf != null) {
        NewConfigurationPanel pnl = new NewConfigurationPanel();
        pnl.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(ConfigurationsPanel.class, "ACSD_Edit_Config"));
        pnl.setConfigurationId(conf.getId());
        pnl.setProfiles(conf.getActivatedProfiles());
        pnl.setProperties(ActionMappings.createPropertiesList(conf.getProperties()));
        pnl.setShared(conf.isShared());
        DialogDescriptor dd = new DialogDescriptor(pnl, NbBundle.getMessage(ConfigurationsPanel.class, "TIT_Edit_Config"));
        Object ret = DialogDisplayer.getDefault().notify(dd);
        if (ret == DialogDescriptor.OK_OPTION) {
            conf.setShared(pnl.isShared());
            conf.setActivatedProfiles(pnl.getProfiles());
            conf.setProperties(ActionMappings.convertStringToActionProperties(pnl.getProperties()));
            handle.markConfigurationsAsModified();
            createListModel();
            lstConfigurations.setSelectedValue(conf, true);
        }
    }
}
 
Example 13
Project: incubator-netbeans   File: AddBreakpointAction.java   View source code 6 votes vote down vote up
/** Constructs managed dialog instance using TopManager.createDialog
* and returnrs it */
private Dialog createDialog () {
    ResourceBundle bundle = NbBundle.getBundle (AddBreakpointAction.class);

    panel = new AddBreakpointPanel ();
    // create dialog descriptor, create & return the dialog
    descriptor = new DialogDescriptor (
        panel,
        bundle.getString ("CTL_Breakpoint_Title"), // NOI18N
        true,
        this
    );
    descriptor.setOptions (new JButton[] {
        bOk = new JButton (bundle.getString ("CTL_Ok")), // NOI18N
        bCancel = new JButton (bundle.getString ("CTL_Cancel")) // NOI18N
    });
    bOk.getAccessibleContext ().setAccessibleDescription (bundle.getString ("ACSD_CTL_Ok")); // NOI18N
    bCancel.getAccessibleContext ().setAccessibleDescription (bundle.getString ("ACSD_CTL_Cancel")); // NOI18N
    descriptor.setClosingOptions (new Object [0]);
    notificationSupport = descriptor.createNotificationLineSupport();
    Dialog d = DialogDisplayer.getDefault ().createDialog (descriptor);
    d.pack ();
    return d;
}
 
Example 14
Project: incubator-netbeans   File: CustomizerCompile.java   View source code 6 votes vote down vote up
private void addProcessorButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addProcessorButtonActionPerformed
    final AddAnnotationProcessor panel = new AddAnnotationProcessor();
    final DialogDescriptor desc = new DialogDescriptor(panel, NbBundle.getMessage (CustomizerCompile.class, "LBL_AddAnnotationProcessor_Title")); //NOI18N
    desc.setValid(false);
    panel.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            String fqn = panel.getProcessorFQN();
            desc.setValid(fqn.length() > 0);
        }
    });
    Dialog dlg = DialogDisplayer.getDefault().createDialog(desc);
    dlg.setVisible (true);
    if (desc.getValue() == DialogDescriptor.OK_OPTION) {
        ((DefaultListModel)annotationProcessorsList.getModel()).addElement(panel.getProcessorFQN());
    }
    dlg.dispose();
}
 
Example 15
Project: incubator-netbeans   File: ImportStep.java   View source code 6 votes vote down vote up
/**
 * Checks if the target folder already exists in the repository.
 * If it does exist, user will be asked to confirm the import into the existing folder.
 * @param client
 * @param repositoryFileUrl
 * @return true if the target does not exist or user wishes to import anyway.
 */
private boolean importIntoExisting(SvnClient client, SVNUrl repositoryFileUrl) {
    try {
        ISVNInfo info = client.getInfo(repositoryFileUrl);
        if (info != null) {
            // target folder exists, ask user for confirmation
            final boolean flags[] = {true};
            NotifyDescriptor nd = new NotifyDescriptor(NbBundle.getMessage(ImportStep.class, "MSG_ImportIntoExisting", SvnUtils.decodeToString(repositoryFileUrl)), //NOI18N
                    NbBundle.getMessage(ImportStep.class, "CTL_TargetFolderExists"), NotifyDescriptor.YES_NO_CANCEL_OPTION, //NOI18N
                    NotifyDescriptor.QUESTION_MESSAGE, null, NotifyDescriptor.YES_OPTION);
            if (DialogDisplayer.getDefault().notify(nd) != NotifyDescriptor.YES_OPTION) {
                flags[0] = false;
            }
            return flags[0];
        }
    } catch (SVNClientException ex) {
        // ignore
    }
    return true;
}
 
Example 16
Project: incubator-netbeans   File: ActionProviderSupport.java   View source code 6 votes vote down vote up
@NbBundle.Messages({
    "CTL_BrokenPlatform_Close=Close",
    "AD_BrokenPlatform_Close=N/A",
    "# {0} - project name", "TEXT_BrokenPlatform=<html><p><strong>The project {0} has a broken platform reference.</strong></p><br><p> You have to fix the broken reference and invoke the action again.</p>",
    "MSG_BrokenPlatform_Title=Broken Platform Reference"
})
static void showPlatformWarning (@NonNull final Project project) {
    final JButton closeOption = new JButton(CTL_BrokenPlatform_Close());
    closeOption.getAccessibleContext().setAccessibleDescription(AD_BrokenPlatform_Close());
    final String projectDisplayName = ProjectUtils.getInformation(project).getDisplayName();
    final DialogDescriptor dd = new DialogDescriptor(
        TEXT_BrokenPlatform(projectDisplayName),
        MSG_BrokenPlatform_Title(),
        true,
        new Object[] {closeOption},
        closeOption,
        DialogDescriptor.DEFAULT_ALIGN,
        null,
        null);
    dd.setMessageType(DialogDescriptor.WARNING_MESSAGE);
    final Dialog dlg = DialogDisplayer.getDefault().createDialog(dd);
    dlg.setVisible(true);
}
 
Example 17
Project: incubator-netbeans   File: ImportConfirmationPanel.java   View source code 6 votes vote down vote up
/** Opens confirmation dialog. */
void showConfirmation() {
    DialogDescriptor dd = new DialogDescriptor(
            this,
            NbBundle.getMessage(ImportConfirmationPanel.class, "ImportConfirmationPanel.title"),
            true,
            DialogDescriptor.YES_NO_OPTION,
            DialogDescriptor.YES_OPTION,
            null);
    dd.setMessageType(DialogDescriptor.WARNING_MESSAGE);
    DialogDisplayer.getDefault().createDialog(dd).setVisible(true);
    if (DialogDescriptor.OK_OPTION.equals(dd.getValue())) {
        confirmed = true;
    } else {
        confirmed = false;
    }
}
 
Example 18
Project: incubator-netbeans   File: NbInputHandler.java   View source code 6 votes vote down vote up
public void handleInput(InputRequest request) throws BuildException {
    interestingOutputCallback.run();

    // #30196 - for one Ant script containing several <input> tasks there will be created
    // just one instance of the NbInputHandler. So it is necessary to cleanup the instance
    // used by the previous <input> task first.
    combo = null;
    input = null;

    JPanel panel = createPanel(request);
    DialogDescriptor dlg = new DialogDescriptor(panel,
    NbBundle.getMessage(NbInputHandler.class, "TITLE_input_handler")); //NOI18N
    do {
        DialogDisplayer.getDefault().createDialog(dlg).setVisible(true);
        if (dlg.getValue() != NotifyDescriptor.OK_OPTION) {
            throw new BuildException(NbBundle.getMessage(NbInputHandler.class, "MSG_input_aborted")); //NOI18N
        }
        String value;
        if (combo != null) {
            value = (String) combo.getSelectedItem();
        } else {
            value = input.getText();
        }
        request.setInput(value);
    } while (!request.isInputValid());
}
 
Example 19
Project: incubator-netbeans   File: UnitTestLibrariesNode.java   View source code 6 votes vote down vote up
@Messages({"# {0} - module display name", "CTL_EditModuleDependencyTitle=Edit \"{0}\" Dependency"})
public @Override void actionPerformed(ActionEvent ev) {
    final EditTestDependencyPanel editTestPanel = new EditTestDependencyPanel(testDep);
    DialogDescriptor descriptor = new DialogDescriptor(editTestPanel,
            CTL_EditModuleDependencyTitle(testDep.getModule().getLocalizedName()));
    descriptor.setHelpCtx(new HelpCtx("org.netbeans.modules.apisupport.project.ui.customizer.EditTestDependencyPanel"));
    Dialog d = DialogDisplayer.getDefault().createDialog(descriptor);
    d.setVisible(true);
    if (descriptor.getValue().equals(DialogDescriptor.OK_OPTION)) {
        TestModuleDependency editedDep = editTestPanel.getEditedDependency();
        try {
            ProjectXMLManager pxm = new ProjectXMLManager(project);
            pxm.removeTestDependency(testType, testDep.getModule().getCodeNameBase());
            pxm.addTestDependency(testType, editedDep);
            ProjectManager.getDefault().saveProject(project);
            
            
        } catch (IOException e) {
            Exceptions.attachMessage(e, "Cannot store dependency: " + editedDep); // NOI18N
            Exceptions.printStackTrace(e);
        }
        
        
    }
    d.dispose();
}
 
Example 20
Project: incubator-netbeans   File: CustomizerCompile.java   View source code 6 votes vote down vote up
private void addOptionButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addOptionButtonActionPerformed
    final AddProcessorOption panel = new AddProcessorOption();
    final DialogDescriptor desc = new DialogDescriptor(panel, NbBundle.getMessage (CustomizerCompile.class, "LBL_AddProcessorOption_Title")); //NOI18N
    desc.setValid(false);
    panel.addChangeListener(new ChangeListener() {
        @Override
        public void stateChanged(ChangeEvent e) {
            String key = panel.getOptionKey();
            for(String s : key.split("\\.", -1)) { //NOI18N
                if (!SourceVersion.isIdentifier(s)) {
                    desc.setValid(false);
                    return;
                }
            }
            desc.setValid(true);
        }
    });
    Dialog dlg = DialogDisplayer.getDefault().createDialog(desc);
    dlg.setVisible (true);
    if (desc.getValue() == DialogDescriptor.OK_OPTION) {
        ((DefaultTableModel)processorOptionsTable.getModel()).addRow(new String[] {panel.getOptionKey(), panel.getOptionValue()});
    }
    dlg.dispose();
}
 
Example 21
Project: incubator-netbeans   File: CustomizerLibraries.java   View source code 6 votes vote down vote up
@Messages("CTL_EditModuleDependencyTitle=Edit Module Dependency")
private void editModuleDependency(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editModuleDependency
    ModuleDependency origDep = getDepListModel().getDependency(
            dependencyList.getSelectedIndex());
    EditDependencyPanel editPanel = new EditDependencyPanel(
            origDep, getProperties().getActivePlatform());
    DialogDescriptor descriptor = new DialogDescriptor(editPanel,
            CTL_EditModuleDependencyTitle());
    descriptor.setHelpCtx(new HelpCtx("org.netbeans.modules.apisupport.project.ui.customizer.EditDependencyPanel"));
    Dialog d = DialogDisplayer.getDefault().createDialog(descriptor);
    d.setVisible(true);
    if (descriptor.getValue().equals(DialogDescriptor.OK_OPTION)) {
        getDepListModel().editDependency(origDep, editPanel.getEditedDependency());
    }
    d.dispose();
    dependencyList.requestFocusInWindow();
}
 
Example 22
Project: incubator-netbeans   File: AbstractMavenExecutor.java   View source code 6 votes vote down vote up
@Messages("TIT_Run_maven=Run Maven")
@Override public void actionPerformed(ActionEvent e) {
    BeanRunConfig newConfig = new BeanRunConfig(config);
    if (debug) {
        RunGoalsPanel pnl = new RunGoalsPanel();
        DialogDescriptor dd = new DialogDescriptor(pnl, TIT_Run_maven());
        pnl.readConfig(config);
        Object retValue = DialogDisplayer.getDefault().notify(dd);
        if (retValue == DialogDescriptor.OK_OPTION) {
            pnl.applyValues(newConfig);
    } else {
            return;
    }
    }
    actionStatesAtStart();
    InputOutput inputOutput = getInputOutput();
    try {
        inputOutput.getOut().reset();
    } catch (IOException ex) {
        ex.printStackTrace();
    }
    MavenCommandLineExecutor.executeMaven(newConfig, inputOutput, tabContext);
//TODO the waiting on tasks won't work..
}
 
Example 23
Project: incubator-netbeans   File: PullWizard.java   View source code 6 votes vote down vote up
boolean show () {
    wizardIterator = new PanelsIterator();
    wizardDescriptor = new WizardDescriptor(wizardIterator);        
    wizardDescriptor.setTitleFormat(new MessageFormat("{0}")); // NOI18N
    wizardDescriptor.setTitle(org.openide.util.NbBundle.getMessage(PullWizard.class, "LBL_PullWizard.title")); // NOI18N
    Dialog dialog = DialogDisplayer.getDefault().createDialog(wizardDescriptor);
    setErrorMessage(wizardIterator.selectUriStep.getErrorMessage());
    dialog.setVisible(true);
    dialog.toFront();
    Object value = wizardDescriptor.getValue();
    boolean finnished = value == WizardDescriptor.FINISH_OPTION;
    if (!finnished) {
        // wizard wasn't properly finnished ...
        if (value == WizardDescriptor.CLOSED_OPTION || value == WizardDescriptor.CANCEL_OPTION ) {
            // wizard was closed or canceled -> reset all steps & kill all running tasks
            wizardIterator.selectUriStep.cancelBackgroundTasks();
        }            
    }
    return finnished;
}
 
Example 24
Project: incubator-netbeans   File: BranchSelector.java   View source code 6 votes vote down vote up
public boolean showDialog (JButton okButton, String title, String branchListDescription) {
    this.okButton = okButton;
    org.openide.awt.Mnemonics.setLocalizedText(panel.jLabel1, branchListDescription);
    DialogDescriptor dialogDescriptor = new DialogDescriptor(panel, title, true, new Object[] {okButton, cancelButton}, 
            okButton, DialogDescriptor.DEFAULT_ALIGN, new HelpCtx(this.getClass()), null);
    
    dialogDescriptor.setValid(false);
    
    Dialog dialog = DialogDisplayer.getDefault().createDialog(dialogDescriptor);     
    dialog.getAccessibleContext().setAccessibleDescription(title);
    loadRevisions();
    dialog.setVisible(true);
    HgProgressSupport supp = loadingSupport;
    if (supp != null) {
        supp.cancel();
    }
    boolean ret = dialogDescriptor.getValue() == okButton;
    return ret;
}
 
Example 25
Project: incubator-netbeans   File: PDFOpenSupport.java   View source code 6 votes vote down vote up
/**
 * Opens a dialog to specify command for opening PDF files.
 *
 * If OK button is clicked and specified command is invalid, the dialog
 * appears again.
 */
private void askForCustomCommand(File f) {
    SetCommandForm scf = new SetCommandForm(getCustomCommand());
    DialogDescriptor desc = new DialogDescriptor(scf,
            NbBundle.getMessage(
            PDFOpenSupport.class, "SetCommandDialog.title"));       //NOI18N

    Object result = DialogDisplayer.getDefault().notify(desc);

    if (result == DialogDescriptor.OK_OPTION) {
        String command = scf.getCommand();
        try {
            storeCustomCommand(command);
            try {
                openWithCustomCommand(command, f);
            } catch (Exception e) {
                askForCustomCommand(f);
            }
        } catch (IOException ex) {
            Exceptions.printStackTrace(ex);
        }
    }
}
 
Example 26
Project: incubator-netbeans   File: ModuleActions.java   View source code 6 votes vote down vote up
/**
 * Checks if a given command can be run at the moment from the perspective of the test userdir lock file.
 * Cf. #63652, #72397, #141069, #207530.
 * @param command as in {@link ActionProvider}
 * @param lock from {@link NbModuleProject#getTestUserDirLockFile} or {@link SuiteProject#getTestUserDirLockFile}
 * @return true if the command is unrelated, there is no lock file, or the lock file is stale and can be safely deleted;
 *         false (after showing a warning dialog) if the command must not proceed
 */
@Messages({
    "ERR_module_already_running=The application is already running within the test user directory. You must shut it down before trying to run it again.",
    "ERR_ModuleIsBeingRun=Cannot copy/move/rename/delete a module or suite while the application is running; shut it down first."
})
static boolean canRunNoLock(String command, File lock) {
    if (command.equals(ActionProvider.COMMAND_RUN) ||
            command.equals(ActionProvider.COMMAND_DEBUG) ||
            command.equals(ActionProvider.COMMAND_PROFILE)) {
        if (isLocked(lock)) {
            DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(ERR_module_already_running()));
            return false;
        }
    } else if (ActionProvider.COMMAND_DELETE.equals(command) ||
            ActionProvider.COMMAND_RENAME.equals(command) ||
            ActionProvider.COMMAND_MOVE.equals(command) ||
            ActionProvider.COMMAND_COPY.equals(command)) {
        if (isLocked(lock)) {
            DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(ERR_ModuleIsBeingRun()));
            return false;
        }
    }
    return true;
}
 
Example 27
Project: incubator-netbeans   File: SelectConnectionPanel.java   View source code 6 votes vote down vote up
public static DatabaseConnection selectConnection(boolean passwordRequired) {
    DatabaseConnection resConn = null;
    SelectConnectionPanel panel = new SelectConnectionPanel(passwordRequired);
    DialogDescriptor desc = new DialogDescriptor(panel, NbBundle.getMessage(SelectConnectionPanel.class, "MSG_SelectConnection"));
    desc.createNotificationLineSupport();
    panel.initialize(desc);
    Dialog dialog = DialogDisplayer.getDefault().createDialog(desc);
    dialog.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(SelectConnectionPanel.class, "ACSD_SelectConnection"));
    dialog.setVisible(true);
    dialog.dispose();

    if (desc.getValue() == DialogDescriptor.OK_OPTION) {
        return panel.dbconn;
    }

    // If the user cancels, keep the selection they started with, rather than setting it to null
    return resConn;
}
 
Example 28
Project: incubator-netbeans   File: Reset.java   View source code 6 votes vote down vote up
boolean show () {
    panel.rbSoft.addActionListener(this);
    panel.rbMixed.addActionListener(this);
    panel.rbHard.addActionListener(this);
    
    okButton = new JButton(NbBundle.getMessage(Reset.class, "LBL_Reset.OKButton.text")); //NOI18N
    org.openide.awt.Mnemonics.setLocalizedText(okButton, okButton.getText());
    dd = new DialogDescriptor(panel, NbBundle.getMessage(Reset.class, "LBL_Reset.title"), true,  //NOI18N
            new Object[] { okButton, DialogDescriptor.CANCEL_OPTION }, okButton, DialogDescriptor.DEFAULT_ALIGN, new HelpCtx(Reset.class), null);
    revisionPicker.addPropertyChangeListener(new PropertyChangeListener() {
        @Override
        public void propertyChange (PropertyChangeEvent evt) {
            if (evt.getPropertyName() == RevisionDialogController.PROP_VALID) {
                setRevisionValid(Boolean.TRUE.equals(evt.getNewValue()));
            }
        }
    });
    Dialog d = DialogDisplayer.getDefault().createDialog(dd);
    validate();
    d.setVisible(true);
    return okButton == dd.getValue();
}
 
Example 29
Project: incubator-netbeans   File: CredentialsCallback.java   View source code 6 votes vote down vote up
@Override
public String askQuestion (String uri, String prompt) {
    String retval = null;
    if (prompt.toLowerCase().startsWith("password:")) { //NOI18N
        char[] pwd = getPassword(uri, prompt);
        if (pwd != null) {
            retval = new String(pwd);
            Arrays.fill(pwd, (char) 0);
        }
    } else {
        NotifyDescriptor.InputLine desc = new NotifyDescriptor.InputLine(prompt, 
                NbBundle.getMessage(CredentialsCallback.class, "LBL_CredentialsCallback.question.title", uri) //NOI18N
        );
        Object dlgResult = DialogDisplayer.getDefault().notify(desc);
        retval = NotifyDescriptor.OK_OPTION == dlgResult ? desc.getInputText() : null;
    }
    return retval;
}
 
Example 30
Project: incubator-netbeans   File: DashboardUtils.java   View source code 5 votes vote down vote up
public static void quickSearchTask(RepositoryImpl repositoryImpl) {
    JButton open = new JButton(NbBundle.getMessage(DashboardTopComponent.class, "OPTION_Open"));
    open.setEnabled(false);
    JButton cancel = new JButton(NbBundle.getMessage(DashboardTopComponent.class, "OPTION_Cancel"));

    QuickSearchPanel quickSearchPanel = new QuickSearchPanel(repositoryImpl);
    NotifyDescriptor quickSearchDialog = new NotifyDescriptor(
            quickSearchPanel,
            NbBundle.getMessage(DashboardTopComponent.class, "LBL_QuickTitle", repositoryImpl.getDisplayName()), //NOI18N
            NotifyDescriptor.OK_CANCEL_OPTION,
            NotifyDescriptor.PLAIN_MESSAGE,
            new Object[]{open, cancel},
            open);
    quickSearchDialog.setValid(false);
    QuickSearchListener quickSearchListener = new QuickSearchListener(quickSearchPanel, open);
    quickSearchPanel.addQuickSearchListener(quickSearchListener);
    Object result = DialogDisplayer.getDefault().notify(quickSearchDialog);
    if (result == open) {
        IssueImpl issueImpl = quickSearchPanel.getSelectedTask();
        IssueAction.openIssue(issueImpl.getRepositoryImpl(), issueImpl.getID());
        Category selectedCategory = quickSearchPanel.getSelectedCategory();
        if (selectedCategory != null) {
            DashboardViewer.getInstance().addTaskToCategory(selectedCategory, new TaskNode(issueImpl, null));
        }
    }
    quickSearchPanel.removeQuickSearchListener(quickSearchListener);
}
 
Example 31
Project: incubator-netbeans   File: TreeTableView152857Test.java   View source code 5 votes vote down vote up
@RandomlyFails // NB-Core-Build #7155: row 1 vs. count 1 with UI [email protected] (from view.getTableValueAt(1))
public void testSetChildren() throws InterruptedException {
    TestNode root = new TestNode(Children.LEAF, "root");
    TreeNode ta = Visualizer.findVisualizer(root);
    view = new TTV(root);
    DialogDescriptor dd = new DialogDescriptor(view, "", false, null);
    Dialog d = DialogDisplayer.getDefault().createDialog(dd);
    makeVisible(d);
    assertEquals(0, ta.getChildCount());

    view.sort(0, false);
    root.doSetChildren(new StringKeys("0", "1", "2"));
    Thread.sleep(1000);
    assertEquals(3, ta.getChildCount());
    assertEquals("2", view.getTableValueAt(1));
    assertEquals("1", view.getTableValueAt(2));
    assertEquals("0", view.getTableValueAt(3));

    view.sort(0, true);
    root.doSetChildren(new StringKeys("5", "6"));
    Thread.sleep(1000);
    assertEquals(2, ta.getChildCount());
    assertEquals("5", view.getTableValueAt(1));
    assertEquals("6", view.getTableValueAt(2));

    root.doSetChildren(Children.LEAF);
    Thread.sleep(1000);
    assertEquals(0, ta.getChildCount());
}
 
Example 32
Project: incubator-netbeans   File: EditableDiffView.java   View source code 5 votes vote down vote up
private Document getSourceDocument(StreamSource ss) {
    Document sdoc = null;
    FileObject fo = ss.getLookup().lookup(FileObject.class);
    if (fo != null) {
        try {
            DataObject dao = DataObject.find(fo);
            if (dao.getPrimaryFile() == fo) {
                EditorCookie ec = dao.getCookie(EditorCookie.class);
                if (ec != null) {
                    try {
                        sdoc = ec.openDocument();
                    } catch (UserQuestionException ex) {
                        boolean open = !Boolean.TRUE.equals(skipFile);
                        if (skipFile == null) {
                            NotifyDescriptor.Confirmation desc = new NotifyDescriptor.Confirmation(ex.getLocalizedMessage(),
                                NbBundle.getMessage(EditableDiffView.class, "EditableDiffView.ConfirmOpenningTitle"), NotifyDescriptor.Confirmation.OK_CANCEL_OPTION); //NOI18N
                            open = DialogDisplayer.getDefault().notify(desc).equals(NotifyDescriptor.OK_OPTION);
                        }
                        if (open) {
                            LOG.log(Level.INFO, "User acepted UQE: {0}", fo.getPath()); //NOI18N
                            ex.confirmed();
                            sdoc = ec.openDocument();
                        } else {
                            sdoc = null;
                            this.skipFile = true;
                        }
                    }
                }
            }
        } catch (Exception e) {
            // fallback to other means of obtaining the source
        }
    } else {
        sdoc = ss.getLookup().lookup(Document.class);
    }
    return sdoc;
}
 
Example 33
Project: incubator-netbeans   File: MissingModuleProblemsProvider.java   View source code 5 votes vote down vote up
private static void showError(@NonNull final String message) {
    SwingUtilities.invokeLater(() -> {
        DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(
                message,
                NotifyDescriptor.Message.ERROR_MESSAGE));
    });
}
 
Example 34
Project: incubator-netbeans   File: BrowseFolders.java   View source code 5 votes vote down vote up
public static FileObject showDialog(SourceGroup[] folders) {

        BrowseFolders bf = new BrowseFolders(folders);

        JButton options[] = new JButton[]{
            new JButton(NbBundle.getMessage(BrowseFolders.class, "LBL_SelectFile")),
            new JButton(NbBundle.getMessage(BrowseFolders.class, "LBL_Cancel"))
        };

        OptionsListener optionsListener = new OptionsListener(bf);

        options[ 0].setActionCommand(OptionsListener.COMMAND_SELECT);
        options[ 0].addActionListener(optionsListener);
        options[ 0].getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(BrowseFolders.class, "ACSD_SelectFile"));
        options[ 1].setActionCommand(OptionsListener.COMMAND_CANCEL);
        options[ 1].addActionListener(optionsListener);
        options[ 1].getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(BrowseFolders.class, "ACSD_Cancel"));

        DialogDescriptor dialogDescriptor = new DialogDescriptor(
                bf, // innerPane
                NbBundle.getMessage(BrowseFolders.class, "LBL_BrowseFiles"), // displayName
                true, // modal
                options, // options
                options[ 0], // initial value
                DialogDescriptor.BOTTOM_ALIGN, // options align
                null, // helpCtx
                null);                                 // listener 

        dialogDescriptor.setClosingOptions(new Object[]{options[ 0], options[ 1]});

        Dialog dialog = DialogDisplayer.getDefault().createDialog(dialogDescriptor);
        dialog.setVisible(true);

        return optionsListener.getResult();

    }
 
Example 35
Project: incubator-netbeans   File: ProfilingPointsDisplayer.java   View source code 5 votes vote down vote up
public static void displayProfilingPoints(Lookup.Provider project, ProfilingSettings settings) {
    ProfilingPointsDisplayer ppd = getDefault();
    ppd.setupDisplay(project, settings);

    final DialogDescriptor dd = new DialogDescriptor(ppd,
                                                     Bundle.ProfilingPointsDisplayer_PpActiveMsg(settings.getSettingsName()), 
                                                     true,
                                                     new Object[] { DialogDescriptor.OK_OPTION }, DialogDescriptor.OK_OPTION,
                                                     0, null, null);
    final Dialog d = DialogDisplayer.getDefault().createDialog(dd);
    d.pack();
    d.setVisible(true);

    ppd.cleanup();
}
 
Example 36
Project: incubator-netbeans   File: ProjectAssociationAction.java   View source code 5 votes vote down vote up
@Messages({
    "ProjectAssociationAction.open_some_projects=Open some projects to choose from.",
    "ProjectAssociationAction.title_select_project=Select Project",
    "ProjectAssociationAction.could_not_associate=Failed to record a Hudson job association.",
    "ProjectAssociationAction.could_not_dissociate=Failed to find the Hudson job association to be removed."
})
@Override public void actionPerformed(ActionEvent e) {
    if (alreadyAssociatedProject == null) {
        SortedSet<Project> projects = new TreeSet<Project>(ProjectRenderer.comparator());
        projects.addAll(Arrays.asList(OpenProjects.getDefault().getOpenProjects()));
        if (projects.isEmpty()) {
            DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(Bundle.ProjectAssociationAction_open_some_projects(), NotifyDescriptor.INFORMATION_MESSAGE));
            return;
        }
        JComboBox box = new JComboBox(new DefaultComboBoxModel(projects.toArray(new Project[projects.size()])));
        box.setRenderer(new ProjectRenderer());
        if (DialogDisplayer.getDefault().notify(new NotifyDescriptor(box, Bundle.ProjectAssociationAction_title_select_project(), NotifyDescriptor.OK_CANCEL_OPTION, NotifyDescriptor.PLAIN_MESSAGE, null, null)) != NotifyDescriptor.OK_OPTION) {
            return;
        }
        if (!ProjectHudsonProvider.getDefault().recordAssociation((Project) box.getSelectedItem(), assoc)) {
            DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(Bundle.ProjectAssociationAction_could_not_associate(), NotifyDescriptor.WARNING_MESSAGE));
        }
    } else {
        if (!ProjectHudsonProvider.getDefault().recordAssociation(alreadyAssociatedProject, null)) {
            DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(Bundle.ProjectAssociationAction_could_not_dissociate(), NotifyDescriptor.WARNING_MESSAGE));
        }
    }
}
 
Example 37
Project: incubator-netbeans   File: ExternalExecutionUserWarningImpl.java   View source code 5 votes vote down vote up
@Override
public void displayError(final String error, final String optionsPath) {
    EventQueue.invokeLater(new Runnable() {
        @Override
        public void run() {
            DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(error, NotifyDescriptor.ERROR_MESSAGE));
            if (optionsPath != null) {
                OptionsDisplayer.getDefault().open(optionsPath);
            }
        }
    });
}
 
Example 38
Project: incubator-netbeans   File: ImportAction.java   View source code 5 votes vote down vote up
private boolean isCacheReady() {
    final DialogDescriptor dd = 
            new DialogDescriptor(
                    NbBundle.getMessage(ImportAction.class,"MSG_CacheNotReady"), // NOI18N
                    NbBundle.getMessage(ImportAction.class,"MSG_InitRunning"),   // NOI18N
                    true, 
                    new Object[]{
                        NbBundle.getMessage(ImportAction.class,"LBL_CancelAction")}, // NOI18N
                        null, 0, null, null);
    final Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
    final FileStatusCache cache = Subversion.getInstance().getStatusCache();
    if(!cache.ready()) {
        RequestProcessor.getDefault().post(new Runnable() {
            @Override
            public void run() {
                while(!cache.ready()) {
                    try {
                        Thread.sleep(300);
                    } catch (InterruptedException ex) {
                        break;
                    }
                }
                dialog.setVisible(false);
            }
        });
        dialog.setVisible(!cache.ready());
        return cache.ready();
    }
    return true;
}
 
Example 39
Project: incubator-netbeans   File: ClassMethodSelector.java   View source code 5 votes vote down vote up
public static List<SourceClassInfo> selectClasses(ProfilerSession session) {
    // TODO: wait for finished scan
    
    UI ui = UI.forSession(session, false);

    HelpCtx helpCtx = new HelpCtx("SelectClassDialog.HelpCtx"); // NOI18N
    DialogDescriptor dd = new DialogDescriptor(ui, Bundle.ClassMethodSelector_selectClass(), true,
                                               new Object[] { ui.getOKButton(), DialogDescriptor.CANCEL_OPTION },
                                               ui.getOKButton(), DialogDescriptor.BOTTOM_ALIGN, helpCtx, null);
    Dialog d = DialogDisplayer.getDefault().createDialog(dd);
    d.setVisible(true);
    
    return dd.getValue() == ui.getOKButton() ? ui.selectedClasses() : Collections.EMPTY_LIST;
}
 
Example 40
Project: incubator-netbeans   File: RecentProjectsPanel.java   View source code 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e) {
    Runnable r = new Runnable() {
        @Override
        public void run() {
            URL url = project.getURL();
            Project prj = null;

            FileObject dir = URLMapper.findFileObject( url );
            if ( dir != null && dir.isFolder() ) {
                try {
                    prj = ProjectManager.getDefault().findProject( dir );
                }
                catch ( IOException ioEx ) {
                    // Ignore invalid folders
                }
            }

            if ( prj != null ) {
                OpenProjects.getDefault().open( new Project[] { prj }, false, true );
            } else {
                String msg = BundleSupport.getMessage("ERR_InvalidProject", project.getDisplayName()); //NOI18N
                NotifyDescriptor nd = new NotifyDescriptor.Message( msg );
                DialogDisplayer.getDefault().notify( nd );
                startBuildingContent();
            }
        }
    };
    ProgressUtils.runOffEventDispatchThread( r, BundleSupport.getLabel("OPEN_RECENT_PROJECT"), new AtomicBoolean(false), false );
}