use of javax.swing.event.HyperlinkListener in project libgdx by libgdx.
the class GdxSetupUI method generate.
void generate() {
final String name = ui.form.nameText.getText().trim();
if (name.length() == 0) {
JOptionPane.showMessageDialog(this, "Please enter a project name.");
return;
}
final String pack = ui.form.packageText.getText().trim();
if (pack.length() == 0) {
JOptionPane.showMessageDialog(this, "Please enter a package name.");
return;
}
Pattern pattern = Pattern.compile("[a-z][a-z0-9_]*(\\.[a-z0-9_]+)+[0-9a-z_]");
Matcher matcher = pattern.matcher(pack);
boolean matches = matcher.matches();
if (!matches) {
JOptionPane.showMessageDialog(this, "Invalid package name");
return;
}
final String clazz = ui.form.gameClassText.getText().trim();
if (clazz.length() == 0) {
JOptionPane.showMessageDialog(this, "Please enter a game class name.");
return;
}
final String destination = ui.form.destinationText.getText().trim();
if (destination.length() == 0) {
JOptionPane.showMessageDialog(this, "Please enter a destination directory.");
return;
}
final String sdkLocation = ui.form.sdkLocationText.getText().trim();
if (sdkLocation.length() == 0 && modules.contains(ProjectType.ANDROID)) {
JOptionPane.showMessageDialog(this, "Please enter your Android SDK's path");
return;
}
if (!GdxSetup.isSdkLocationValid(sdkLocation) && modules.contains(ProjectType.ANDROID)) {
JOptionPane.showMessageDialog(this, "Your Android SDK path doesn't contain an SDK! Please install the Android SDK, including all platforms and build tools!");
return;
}
if (modules.contains(ProjectType.ANDROID)) {
if (!GdxSetup.isSdkUpToDate(sdkLocation)) {
File sdkLocationFile = new File(sdkLocation);
try {
//give them a poke in the right direction
if (System.getProperty("os.name").contains("Windows")) {
String replaced = sdkLocation.replace("\\", "\\\\");
Runtime.getRuntime().exec("\"" + replaced + "\\SDK Manager.exe\"");
} else {
File sdkManager = new File(sdkLocation, "tools/android");
Runtime.getRuntime().exec(new String[] { sdkManager.getAbsolutePath(), "sdk" });
}
} catch (IOException e) {
e.printStackTrace();
}
return;
}
}
if (!GdxSetup.isEmptyDirectory(destination)) {
int value = JOptionPane.showConfirmDialog(this, "The destination is not empty, do you want to overwrite?", "Warning!", JOptionPane.YES_NO_OPTION);
if (value != 0) {
return;
}
}
List<String> incompatList = builder.buildProject(modules, dependencies);
if (incompatList.size() == 0) {
try {
builder.build();
} catch (IOException e) {
e.printStackTrace();
}
} else {
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
for (String subIncompat : incompatList) {
JLabel label = new JLabel(subIncompat);
label.setAlignmentX(Component.CENTER_ALIGNMENT);
panel.add(label);
}
JLabel infoLabel = new JLabel("<html><br><br>The project can be generated, but you wont be able to use these extensions in the respective sub modules<br>Please see the link to learn about extensions</html>");
infoLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
panel.add(infoLabel);
JEditorPane pane = new JEditorPane("text/html", "<a href=\"https://github.com/libgdx/libgdx/wiki/Dependency-management-with-Gradle\">Dependency Management</a>");
pane.addHyperlinkListener(new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED))
try {
Desktop.getDesktop().browse(new URI(e.getURL().toString()));
} catch (IOException e1) {
e1.printStackTrace();
} catch (URISyntaxException e1) {
e1.printStackTrace();
}
}
});
pane.setEditable(false);
pane.setOpaque(false);
pane.setAlignmentX(Component.CENTER_ALIGNMENT);
panel.add(pane);
Object[] options = { "Yes, build it!", "No, I'll change my extensions" };
int value = JOptionPane.showOptionDialog(null, panel, "Extension Incompatibilities", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, null);
if (value != 0) {
return;
} else {
try {
builder.build();
} catch (IOException e) {
e.printStackTrace();
}
}
}
ui.generateButton.setEnabled(false);
new Thread() {
public void run() {
log("Generating app in " + destination);
new GdxSetup().build(builder, destination, name, pack, clazz, sdkLocation, new CharCallback() {
@Override
public void character(char c) {
log(c);
}
}, ui.settings.getGradleArgs());
log("Done!");
if (ui.settings.getGradleArgs().contains("eclipse") || ui.settings.getGradleArgs().contains("idea")) {
log("To import in Eclipse: File -> Import -> General -> Existing Projects into Workspace");
log("To import to Intellij IDEA: File -> Open -> YourProject.ipr");
} else {
log("To import in Eclipse: File -> Import -> Gradle -> Gradle Project");
log("To import to Intellij IDEA: File -> Open -> build.gradle");
log("To import to NetBeans: File -> Open Project...");
}
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
ui.generateButton.setEnabled(true);
}
});
}
}.start();
}
use of javax.swing.event.HyperlinkListener in project processing by processing.
the class DetailPanel method addPaneComponents.
/**
* Create the widgets for the header panel which is visible when the
* library panel is not clicked.
*/
private void addPaneComponents() {
setLayout(new BorderLayout());
descriptionPane = new JTextPane();
descriptionPane.setInheritsPopupMenu(true);
// why would this ever be true?
descriptionPane.setEditable(false);
Insets margin = descriptionPane.getMargin();
margin.bottom = 0;
descriptionPane.setMargin(margin);
descriptionPane.setContentType("text/html");
setTextStyle(descriptionPane, "0.95em");
descriptionPane.setOpaque(false);
if (UIManager.getLookAndFeel().getID().equals("Nimbus")) {
descriptionPane.setBackground(new Color(0, 0, 0, 0));
}
descriptionPane.setBorder(new EmptyBorder(4, 7, 7, 7));
descriptionPane.setHighlighter(null);
descriptionPane.addHyperlinkListener(new HyperlinkListener() {
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
// adding/removing the listener repeatedly
if (isSelected()) {
if (enableHyperlinks && e.getURL() != null) {
Platform.openURL(e.getURL().toString());
}
}
}
}
});
add(descriptionPane, BorderLayout.CENTER);
JPanel updateBox = new JPanel();
updateBox.setLayout(new BorderLayout());
notificationLabel = new JLabel();
notificationLabel.setInheritsPopupMenu(true);
notificationLabel.setVisible(false);
notificationLabel.setOpaque(false);
notificationLabel.setFont(ManagerFrame.SMALL_PLAIN);
{
updateButton = new JButton("Update");
updateButton.setInheritsPopupMenu(true);
Dimension dim = new Dimension(BUTTON_WIDTH, updateButton.getPreferredSize().height);
updateButton.setMinimumSize(dim);
updateButton.setPreferredSize(dim);
updateButton.setOpaque(false);
updateButton.setVisible(false);
updateButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
update();
}
});
}
updateBox.add(updateButton, BorderLayout.EAST);
updateBox.add(notificationLabel, BorderLayout.WEST);
updateBox.setBorder(new EmptyBorder(4, 7, 7, 7));
updateBox.setOpaque(false);
add(updateBox, BorderLayout.SOUTH);
JPanel rightPane = new JPanel();
rightPane.setInheritsPopupMenu(true);
rightPane.setOpaque(false);
rightPane.setLayout(new BoxLayout(rightPane, BoxLayout.Y_AXIS));
rightPane.setMinimumSize(new Dimension(BUTTON_WIDTH, 1));
add(rightPane, BorderLayout.EAST);
barButtonCardLayout = new CardLayout();
barButtonCardPane.setLayout(barButtonCardLayout);
barButtonCardPane.setInheritsPopupMenu(true);
barButtonCardPane.setOpaque(false);
barButtonCardPane.setMinimumSize(new Dimension(BUTTON_WIDTH, 1));
{
installProgressBar = new JProgressBar();
installProgressBar.setInheritsPopupMenu(true);
installProgressBar.setStringPainted(true);
resetInstallProgressBarState();
Dimension dim = new Dimension(BUTTON_WIDTH, installProgressBar.getPreferredSize().height);
installProgressBar.setPreferredSize(dim);
installProgressBar.setMaximumSize(dim);
installProgressBar.setMinimumSize(dim);
installProgressBar.setOpaque(false);
installProgressBar.setAlignmentX(CENTER_ALIGNMENT);
}
installRemoveButton = new JButton(" ");
installRemoveButton.setInheritsPopupMenu(true);
installRemoveButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
String mode = installRemoveButton.getText();
if (mode.equals(installText)) {
install();
} else if (mode.equals(removeText)) {
remove();
} else if (mode.equals(undoText)) {
undo();
}
}
});
Dimension installButtonDimensions = installRemoveButton.getPreferredSize();
installButtonDimensions.width = BUTTON_WIDTH;
installRemoveButton.setPreferredSize(installButtonDimensions);
installRemoveButton.setMaximumSize(installButtonDimensions);
installRemoveButton.setMinimumSize(installButtonDimensions);
installRemoveButton.setOpaque(false);
installRemoveButton.setAlignmentX(CENTER_ALIGNMENT);
JPanel barPane = new JPanel();
barPane.setOpaque(false);
JPanel buttonPane = new JPanel();
buttonPane.setOpaque(false);
buttonPane.add(installRemoveButton);
barButtonCardPane.add(buttonPane, BUTTON_CONSTRAINT);
barButtonCardPane.add(barPane, PROGRESS_BAR_CONSTRAINT);
barButtonCardLayout.show(barButtonCardPane, BUTTON_CONSTRAINT);
rightPane.add(barButtonCardPane);
// Set the minimum size of this pane to be the sum of the height of the
// progress bar and install button
Dimension dim = new Dimension(BUTTON_WIDTH, installRemoveButton.getPreferredSize().height);
rightPane.setMinimumSize(dim);
rightPane.setPreferredSize(dim);
}
use of javax.swing.event.HyperlinkListener in project azure-tools-for-java by Microsoft.
the class SparkSubmissionToolWindowProcessor method initialize.
public void initialize() {
ApplicationManager.getApplication().assertIsDispatchThread();
UISettings.getInstance().addUISettingsListener(new UISettingsListener() {
@Override
public void uiSettingsChanged(UISettings uiSettings) {
synchronized (this) {
for (IHtmlElement htmlElement : cachedInfo) {
htmlElement.ChangeTheme();
}
setToolWindowText(parserHtmlElementList(cachedInfo));
}
}
}, ApplicationManager.getApplication());
fontFace = jEditorPanel.getFont().getFamily();
JPanel jPanel = new JPanel();
jPanel.setLayout(new GridBagLayout());
jEditorPanel.setMargin(new Insets(0, 10, 0, 0));
JBScrollPane scrollPane = new JBScrollPane(jEditorPanel);
stopButton = new JButton(PluginUtil.getIcon(CommonConst.StopIconPath));
stopButton.setDisabledIcon(PluginUtil.getIcon(CommonConst.StopDisableIconPath));
stopButton.setEnabled(false);
stopButton.setToolTipText("stop execution of current application");
stopButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
DefaultLoader.getIdeHelper().executeOnPooledThread(new Runnable() {
@Override
public void run() {
if (clusterDetail != null) {
AppInsightsClient.create(HDInsightBundle.message("SparkSubmissionStopButtionClickEvent"), null);
try {
HttpResponse deleteResponse = SparkBatchSubmission.getInstance().killBatchJob(SparkSubmitHelper.getLivyConnectionURL(clusterDetail), batchId);
if (deleteResponse.getCode() == 201 || deleteResponse.getCode() == 200) {
jobStatusManager.setJobKilled();
setInfo("========================Stop application successfully=======================");
} else {
setError(String.format("Error : Failed to stop spark application. error code : %d, reason : %s.", deleteResponse.getCode(), deleteResponse.getContent()));
}
} catch (IOException exception) {
setError("Error : Failed to stop spark application. exception : " + exception.toString());
}
}
}
});
}
});
openSparkUIButton = new JButton(PluginUtil.getIcon(CommonConst.OpenSparkUIIconPath));
openSparkUIButton.setDisabledIcon(PluginUtil.getIcon(CommonConst.OpenSparkUIDisableIconPath));
openSparkUIButton.setEnabled(false);
openSparkUIButton.setToolTipText("open the corresponding Spark UI page");
openSparkUIButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (Desktop.isDesktopSupported()) {
try {
if (jobStatusManager.isApplicationGenerated()) {
String connectionURL = clusterDetail.getConnectionUrl();
String sparkApplicationUrl = clusterDetail.isEmulator() ? String.format(yarnRunningUIEmulatorUrlFormat, ((EmulatorClusterDetail) clusterDetail).getSparkHistoryEndpoint(), jobStatusManager.getApplicationId()) : String.format(yarnRunningUIUrlFormat, connectionURL, jobStatusManager.getApplicationId());
Desktop.getDesktop().browse(new URI(sparkApplicationUrl));
}
} catch (Exception browseException) {
DefaultLoader.getUIHelper().showError("Failed to browse spark application yarn url", "Spark Submission");
}
}
}
});
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.Y_AXIS));
buttonPanel.add(stopButton);
buttonPanel.add(openSparkUIButton);
GridBagConstraints c00 = new GridBagConstraints();
c00.fill = GridBagConstraints.VERTICAL;
c00.weighty = 1;
c00.gridx = 0;
c00.gridy = 0;
jPanel.add(buttonPanel, c00);
GridBagConstraints c10 = new GridBagConstraints();
c10.fill = GridBagConstraints.BOTH;
c10.weightx = 1;
c10.weighty = 1;
c10.gridx = 1;
c10.gridy = 0;
jPanel.add(scrollPane, c10);
toolWindow.getComponent().add(jPanel);
jEditorPanel.setEditable(false);
jEditorPanel.setOpaque(false);
jEditorPanel.setEditorKit(JEditorPane.createEditorKitForContentType("text/html"));
jEditorPanel.addHyperlinkListener(new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
if (Desktop.isDesktopSupported()) {
try {
String protocol = e.getURL().getProtocol();
if (protocol.equals("https") || protocol.equals("http")) {
Desktop.getDesktop().browse(e.getURL().toURI());
} else if (protocol.equals("file")) {
String path = e.getURL().getFile();
File localFile = new File(path);
File parentFile = localFile.getParentFile();
if (parentFile.exists() && parentFile.isDirectory()) {
Desktop.getDesktop().open(parentFile);
}
}
} catch (Exception exception) {
DefaultLoader.getUIHelper().showError(exception.getMessage(), "Open Local Folder Error");
}
}
}
}
});
PropertyChangeListener propertyChangeListener = new PropertyChangeListener() {
@Override
public void propertyChange(final PropertyChangeEvent evt) {
if (ApplicationManager.getApplication().isDispatchThread()) {
changeSupportHandler(evt);
} else {
try {
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
changeSupportHandler(evt);
}
});
} catch (InterruptedException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
}
private void changeSupportHandler(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals("toolWindowText")) {
jEditorPanel.setText(evt.getNewValue().toString());
} else if (evt.getPropertyName().equals("isStopButtonEnable")) {
stopButton.setEnabled(Boolean.parseBoolean(evt.getNewValue().toString()));
} else if (evt.getPropertyName().equals("isBrowserButtonEnable")) {
openSparkUIButton.setEnabled(Boolean.parseBoolean(evt.getNewValue().toString()));
}
}
};
jEditorPanel.addPropertyChangeListener(propertyChangeListener);
changeSupport = new PropertyChangeSupport(jEditorPanel);
changeSupport.addPropertyChangeListener(propertyChangeListener);
}
use of javax.swing.event.HyperlinkListener in project intellij-community by JetBrains.
the class FileInEditorProcessor method processCode.
public void processCode() {
if (myShouldOptimizeImports) {
myProcessor = new OptimizeImportsProcessor(myProject, myFile);
}
if (myProcessChangesTextOnly && !FormatChangedTextUtil.hasChanges(myFile)) {
myNoChangesDetected = true;
}
myProcessor = mixWithReformatProcessor(myProcessor);
if (myShouldRearrangeCode) {
myProcessor = mixWithRearrangeProcessor(myProcessor);
}
if (shouldNotify()) {
myProcessor.setCollectInfo(true);
myProcessor.setPostRunnable(() -> {
String message = prepareMessage();
if (!myEditor.isDisposed() && myEditor.getComponent().isShowing()) {
HyperlinkListener hyperlinkListener = new HyperlinkAdapter() {
@Override
protected void hyperlinkActivated(HyperlinkEvent e) {
AnAction action = ActionManager.getInstance().getAction("ShowReformatFileDialog");
DataManager manager = DataManager.getInstance();
if (manager != null) {
DataContext context = manager.getDataContext(myEditor.getContentComponent());
action.actionPerformed(AnActionEvent.createFromAnAction(action, null, "", context));
}
}
};
showHint(myEditor, message, hyperlinkListener);
}
});
}
myProcessor.run();
}
use of javax.swing.event.HyperlinkListener in project intellij-community by JetBrains.
the class IntentionDescriptionPanel method setupPoweredByPanel.
private void setupPoweredByPanel(final IntentionActionMetaData actionMetaData) {
PluginId pluginId = actionMetaData == null ? null : actionMetaData.getPluginId();
JComponent owner;
if (pluginId == null) {
@NonNls String label = XmlStringUtil.wrapInHtml("<b>" + ApplicationNamesInfo.getInstance().getFullProductName() + "</b>");
owner = new JLabel(label);
} else {
final IdeaPluginDescriptor pluginDescriptor = PluginManager.getPlugin(pluginId);
HyperlinkLabel label = new HyperlinkLabel(CodeInsightBundle.message("powered.by.plugin", pluginDescriptor.getName()));
label.addHyperlinkListener(new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
final ShowSettingsUtil util = ShowSettingsUtil.getInstance();
final PluginManagerConfigurable pluginConfigurable = new PluginManagerConfigurable(PluginManagerUISettings.getInstance());
final Project project = ProjectManager.getInstance().getDefaultProject();
util.editConfigurable(project, pluginConfigurable, () -> pluginConfigurable.select(pluginDescriptor));
}
});
owner = label;
}
//myPoweredByContainer.setVisible(true);
myPoweredByPanel.removeAll();
myPoweredByPanel.add(owner, BorderLayout.CENTER);
}
Aggregations