下面列出了javax.swing.plaf.basic.BasicFileChooserUI#org.openide.DialogDisplayer 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@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);
}
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);
});
}
@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);
}
}
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());
}
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);
}
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);
}
/**
* 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();
}
@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);
}
}
}
@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);
}
}
}
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);
}
@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);
}
@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;
}
/**
* 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));
}
}
}
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();
}
}
}
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);
}
@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);
}
public static void chooseBandsWithSameSize() {
String title = Dialogs.getDialogTitle("Choose bands with same size.");
int optionType = JOptionPane.OK_CANCEL_OPTION;
int messageType = JOptionPane.INFORMATION_MESSAGE;
final StringBuilder msgTextBuilder = new StringBuilder("The functionality you have chosen is not supported for bands of different sizes.<br/>");
JPanel panel = new JPanel(new BorderLayout(4, 4));
final JEditorPane textPane = new JEditorPane("text/html", msgTextBuilder.toString());
setFont(textPane);
textPane.setEditable(false);
textPane.setOpaque(false);
textPane.addHyperlinkListener(e -> {
if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) {
try {
Desktop.getDesktop().browse(e.getURL().toURI());
} catch (IOException | URISyntaxException e1) {
Dialogs.showWarning("Could not open URL: " + e.getDescription());
}
}
});
panel.add(textPane, BorderLayout.CENTER);
final JComboBox<Object> resamplerBox = new JComboBox<>();
NotifyDescriptor d = new NotifyDescriptor(panel, title, optionType, messageType, null, null);
DialogDisplayer.getDefault().notify(d);
}
public static void showDescription(Rule rule, String htmlDescription) {
Class ruleClass = rule.getClass();
URL ruleBase = ruleClass.getResource(ruleClass.getSimpleName() + ".class"); // NOI18N
final DialogDescriptor dd = new DialogDescriptor(new DescriptionDisplayer(ruleBase, htmlDescription),
rule.getDisplayName(), true,
new Object[] { DialogDescriptor.OK_OPTION },
DialogDescriptor.OK_OPTION, DialogDescriptor.BOTTOM_ALIGN, null, null);
final Dialog d = DialogDisplayer.getDefault().createDialog(dd);
d.pack(); // allows correct resizing of textarea in PreferredInstrFilterPanel
d.setVisible(true);
}
/**
* Processing of alert messages from this web-browser pane.
*
* @param message alert message.
*/
private void processAlert(String message) {
if (message.startsWith(PAGE_INSPECTION_PREFIX)) {
message = message.substring(PAGE_INSPECTION_PREFIX.length());
MessageDispatcherImpl dispatcher = getLookup().lookup(MessageDispatcherImpl.class);
if (dispatcher != null) {
dispatcher.dispatchMessage(PageInspector.MESSAGE_DISPATCHER_FEATURE_ID, message);
}
} else {
DialogDisplayer.getDefault().notifyLater( new NotifyDescriptor.Message( message ) );
}
}
/**
* Shows the wizard, having the provided files and target folder pre-selected,
* lets the user configure the source files-target folder, and if confirmed,
* then also copies the files.
* @return the files copied to the project, null if the wizard was canceled
*/
FileObject[] show() {
Dialog dialog = DialogDisplayer.getDefault().createDialog(this);
dialog.setVisible(true);
dialog.dispose();
return getValue() == FINISH_OPTION ? copyFiles() : null;
}
public static void showInformation(final String msg, final String title) {
Runnable info = new Runnable() {
public void run() {
NotifyDescriptor d = new NotifyDescriptor.Message(msg, NotifyDescriptor.INFORMATION_MESSAGE);
d.setTitle(title);
DialogDisplayer.getDefault().notify(d);
}
};
if (SwingUtilities.isEventDispatchThread()) {
info.run();
} else {
SwingUtilities.invokeLater(info);
}
}
public void openSearch(final File repository, final File[] roots, final String contextName) {
String branchName = getActiveBranchName(repository);
if (branchName.equals(GitBranch.NO_BRANCH)) {
NotifyDescriptor nd = new NotifyDescriptor.Message(Bundle.MSG_SearchOutgoingTopComponent_err_noBranch(),
NotifyDescriptor.ERROR_MESSAGE);
DialogDisplayer.getDefault().notify(nd);
return;
}
openSearch(repository, roots, branchName, contextName);
}
public void updateState() {
DeploymentStatus deployStatus = progressObject.getDeploymentStatus();
synchronized (this) {
if (finished || deployStatus == null) {
return;
}
if (deployStatus.isCompleted() || deployStatus.isFailed()) {
finished = true;
}
if (deployStatus.getState() == StateType.COMPLETED) {
CommandType command = deployStatus.getCommand();
if (command == CommandType.START || command == CommandType.STOP) {
StatusDisplayer.getDefault().setStatusText(deployStatus.getMessage());
if (command == CommandType.START) {
isRunning = true;
} else {
isRunning = false;
}
node.setDisplayName(constructDisplayName());
} else if (command == CommandType.UNDEPLOY) {
StatusDisplayer.getDefault().setStatusText(deployStatus.getMessage());
}
} else if (deployStatus.getState() == StateType.FAILED) {
NotifyDescriptor notDesc = new NotifyDescriptor.Message(
deployStatus.getMessage(),
NotifyDescriptor.ERROR_MESSAGE);
DialogDisplayer.getDefault().notify(notDesc);
StatusDisplayer.getDefault().setStatusText(deployStatus.getMessage());
}
}
}
public void addFilterSetting() {
NotifyDescriptor.InputLine l = new NotifyDescriptor.InputLine("Enter a name:", "Filter");
if (DialogDisplayer.getDefault().notify(l) == NotifyDescriptor.OK_OPTION) {
String name = l.getInputText();
FilterSetting toRemove = null;
for (FilterSetting s : filterSettings) {
if (s.getName().equals(name)) {
NotifyDescriptor.Confirmation conf = new NotifyDescriptor.Confirmation("Filter \"" + name + "\" already exists, to you want to overwrite?", "Filter");
if (DialogDisplayer.getDefault().notify(conf) == NotifyDescriptor.YES_OPTION) {
toRemove = s;
break;
} else {
return;
}
}
}
if (toRemove != null) {
filterSettings.remove(toRemove);
}
FilterSetting setting = createFilterSetting(name);
filterSettings.add(setting);
// Sort alphabetically
Collections.sort(filterSettings, new Comparator<FilterSetting>() {
public int compare(FilterSetting o1, FilterSetting o2) {
return o1.getName().compareTo(o2.getName());
}
});
updateComboBox();
}
}
private boolean createNewConfiguration(boolean platformChanged) {
DialogDescriptor d = new DialogDescriptor(new CreateConfigurationPanel(platformChanged), NbBundle.getMessage(JFXRunPanel.class, "JFXConfigurationProvider.input.title")); //NOI18N
if (DialogDisplayer.getDefault().notify(d) != NotifyDescriptor.OK_OPTION) {
return false;
}
String name = ((CreateConfigurationPanel) d.getMessage()).getConfigName();
String config = JFXProjectUtils.makeSafe(name);
if (config.trim().length() == 0) {
//#143764
DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(
NbBundle.getMessage(JFXRunPanel.class, "JFXConfigurationProvider.input.empty", config), // NOI18N
NotifyDescriptor.WARNING_MESSAGE));
return false;
}
if (configs.hasConfig(config)) {
DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message(
NbBundle.getMessage(JFXRunPanel.class, "JFXConfigurationProvider.input.duplicate", config), // NOI18N
NotifyDescriptor.WARNING_MESSAGE));
return false;
}
Map<String, String> m = new HashMap<String, String>();
if (!name.equals(config)) {
m.put("$label", name); // NOI18N
}
configs.addToConfig(config, m);
configs.setActive(config);
configChanged(config);
return true;
}
@NbBundle.Messages({
"LBL_BrokenLinksCustomizer_Close=Close",
"ACSD_BrokenLinksCustomizer_Close=N/A",
"LBL_BrokenLinksCustomizer_Title=Resolve Project Problems - \"{0}\" Project"
})
@Override
public void showCustomizer(@NonNull Project project) {
Parameters.notNull("project", project); //NOI18N
BrokenReferencesModel model = new BrokenReferencesModel(project);
BrokenReferencesCustomizer customizer = new BrokenReferencesCustomizer(model);
JButton close = new JButton (LBL_BrokenLinksCustomizer_Close()); // NOI18N
close.getAccessibleContext ().setAccessibleDescription (ACSD_BrokenLinksCustomizer_Close()); // NOI18N
String projectDisplayName = ProjectUtils.getInformation(project).getDisplayName();
DialogDescriptor dd = new DialogDescriptor(customizer,
LBL_BrokenLinksCustomizer_Title(projectDisplayName), // NOI18N
true, new Object[] {close}, close, DialogDescriptor.DEFAULT_ALIGN, null, null);
customizer.setNotificationLineSupport(dd.createNotificationLineSupport());
Dialog dlg = null;
try {
dlg = DialogDisplayer.getDefault().createDialog(dd);
dlg.setVisible(true);
} finally {
if (dlg != null) {
dlg.dispose();
}
}
}
@NbBundle.Messages({
"# {0} - branch to merge",
"MSG_PullAction_mergeNeeded_text=A merge commit is needed to synchronize current branch with {0}.\n\n"
+ "Do you want to Rebase the current branch onto {0} or Merge it with {0}?",
"LBL_PullAction_mergeNeeded_title=Merge Commit Needed",
"CTL_PullAction_mergeButton_text=&Merge",
"CTL_PullAction_mergeButton_TTtext=Merge the two created heads",
"CTL_PullAction_rebaseButton_text=&Rebase",
"CTL_PullAction_rebaseButton_TTtext=Rebase current branch on top of the fetched branch"
})
private Callable<ActionProgress> askForNextAction () {
JButton btnMerge = new JButton();
Mnemonics.setLocalizedText(btnMerge, Bundle.CTL_PullAction_mergeButton_text());
btnMerge.setToolTipText(Bundle.CTL_PullAction_mergeButton_TTtext());
JButton btnRebase = new JButton();
Mnemonics.setLocalizedText(btnRebase, Bundle.CTL_PullAction_rebaseButton_text());
btnRebase.setToolTipText(Bundle.CTL_PullAction_rebaseButton_TTtext());
Object value = DialogDisplayer.getDefault().notify(new NotifyDescriptor(
Bundle.MSG_PullAction_mergeNeeded_text(branchToMerge),
Bundle.LBL_PullAction_mergeNeeded_title(),
NotifyDescriptor.DEFAULT_OPTION,
NotifyDescriptor.QUESTION_MESSAGE,
new Object[] { btnRebase, btnMerge, NotifyDescriptor.CANCEL_OPTION },
btnRebase));
if (value == btnMerge) {
return new Merge();
} else if (value == btnRebase) {
return new Rebase();
}
return null;
}
static Result selectSnapshot(HeapFragmentWalker heapWalker, boolean compareRetained) {
CompareSnapshotsHelper helper = new CompareSnapshotsHelper(heapWalker, compareRetained);
SelectSecondSnapshotPanel panel = helper.getSecondSnapshotSelector();
panel.populateSnapshotsList();
DialogDescriptor desc = new DialogDescriptor(panel, Bundle.CompareSnapshotsHelper_SelectDialogCaption(), true,
new Object[] {
panel.getOKButton(), DialogDescriptor.CANCEL_OPTION
}, DialogDescriptor.OK_OPTION, 0, HELP_CTX, null);
Object res = DialogDisplayer.getDefault().notify(desc);
return !res.equals(panel.getOKButton()) ? null :
new Result(panel.getSnapshot(), panel.computeRetained());
}
public void performAction() {
Node[] selected = ExplorerTopComponent.findInstance().getExplorerManager().getSelectedNodes();
if (selected.length == 1){
OpenSimObjectNode objectNode = (OpenSimObjectNode) selected[0];
NotifyDescriptor.InputLine dlg =
new NotifyDescriptor.InputLine("Model Name: ", "Rename ");
dlg.setInputText(objectNode.getOpenSimObject().getName());
if(DialogDisplayer.getDefault().notify(dlg)==NotifyDescriptor.OK_OPTION){
String newName = dlg.getInputText();
if (OpenSimDB.getInstance().validateName(newName, true)){
objectNode.getOpenSimObject().setName(newName);
objectNode.setName(newName); // Force navigator window update
// Create event to tell everyone else
Vector<OpenSimObject> objs = new Vector<OpenSimObject>(1);
objs.add(objectNode.getOpenSimObject());
ObjectsRenamedEvent evnt = new ObjectsRenamedEvent(this, null, objs);
OpenSimDB.getInstance().setChanged();
OpenSimDB.getInstance().notifyObservers(evnt);
// The following is specific to renaming a model since
// other windows may display currentModel's name
// A more generic scheme using events should be used.
if (objectNode instanceof OneModelNode) {
Model dModel = ((OneModelNode)objectNode).getModel();
if (dModel==OpenSimDB.getInstance().getCurrentModel())
OpenSimDB.getInstance().setCurrentModel(dModel); // Need to do this so that model dropdown updates
// Mark the model as dirty
SingleModelGuiElements guiElem = OpenSimDB.getInstance().getModelGuiElements(dModel);
guiElem.setUnsavedChangesFlag(true);
}
objectNode.refreshNode();
} else
DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message("Provided name "+newName+" is not valid"));
}
} else { // Should never happen
DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message("Rename of multiple objects is not supported."));
}
}
@Override
@Messages("TIT_PLUGIN_EXPRESSION=Add Plugin Expression Property")
public void actionPerformed(ActionEvent e) {
GoalsProvider provider = Lookup.getDefault().lookup(GoalsProvider.class);
if (provider != null) {
AddPropertyDialog panel = new AddPropertyDialog(project, goals.getText());
DialogDescriptor dd = new DialogDescriptor(panel, TIT_PLUGIN_EXPRESSION());
dd.setOptions(new Object[] {panel.getOkButton(), DialogDescriptor.CANCEL_OPTION});
dd.setClosingOptions(new Object[] {panel.getOkButton(), DialogDescriptor.CANCEL_OPTION});
DialogDisplayer.getDefault().notify(dd);
if (dd.getValue() == panel.getOkButton()) {
String expr = panel.getSelectedExpression();
if (expr != null) {
String props = area.getText();
String sep = "\n";//NOI18N
if (props.endsWith("\n") || props.trim().length() == 0) {//NOI18N
sep = "";//NOI18N
}
props = props + sep + expr + "="; //NOI18N
area.setText(props);
area.setSelectionStart(props.length() - (expr + "=").length()); //NOI18N
area.setSelectionEnd(props.length());
area.requestFocusInWindow();
}
}
}
}