private AppEngineSupportConfigurable(FrameworkSupportModel model) { super(AppEngineSupportProvider.this, model); mySdkEditor = new AppEngineSdkEditor(model.getProject()); mySdkPanel.add( LabeledComponent.create(mySdkEditor.getMainComponent(), "Google App Engine SDK:"), BorderLayout.CENTER); PersistenceApiComboboxUtil.setComboboxModel(myPersistenceApiComboBox, true); if (model.isFrameworkSelected(JPA_PROVIDER_ID)) { myPersistenceApiComboBox.setSelectedItem(PersistenceApi.JPA.getDisplayName()); } model.addFrameworkListener(this); myErrorLabel = new HyperlinkLabel(); myErrorLabel.setIcon(AllIcons.RunConfigurations.ConfigurationWarning); myErrorLabel.setVisible(false); myErrorLabel.setHyperlinkTarget(AppEngineSdkUtil.APP_ENGINE_DOWNLOAD_URL); myErrorPanel.add(BorderLayout.CENTER, myErrorLabel); final Component component = mySdkEditor.getComboBox().getEditor().getEditorComponent(); if (component instanceof JTextComponent) { ((JTextComponent) component) .getDocument() .addDocumentListener( new DocumentAdapter() { @Override protected void textChanged(DocumentEvent e) { checkSdk(); } }); } checkSdk(); }
public ConfigurableHandler( HyperlinkLabel label, final UnnamedConfigurable serverConfigurable, C serverConfiguration, ServerType<C> serverType) { myServerConfigurable = serverConfigurable; myServerConfiguration = serverConfiguration; myServerType = serverType; label.setHyperlinkText("Upload Public SSH Key"); label.addHyperlinkListener(this); myLabel = label; }
private void addErrorMessage(final FixableMessageInfo message, Icon icon) { if (message.myLinkText.length() > 0 || message.myAfterLinkText.length() > 0) { HyperlinkLabel warnLabel = new HyperlinkLabel(); warnLabel.setOpaque(false); warnLabel.setHyperlinkText( message.myBeforeLinkText, message.myLinkText, message.myAfterLinkText); warnLabel.setIcon(icon); if (message.myQuickFix != null) { warnLabel.addHyperlinkListener( new HyperlinkListener() { public void hyperlinkUpdate(final HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { message.myQuickFix.run(); } } }); } myErrorMessages.add(warnLabel); } else { JBLabel warnLabel = new JBLabel(); warnLabel.setOpaque(false); warnLabel.setText( "<html><body>" + message.myBeforeLinkText.replace("\n", "<br>") + "</body></html>"); warnLabel.setIcon(icon); myErrorMessages.add(warnLabel); } if (message.myAdditionalFixes != null && message.myAdditionalFixes.size() > 0) { JPanel fixesPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0)); fixesPanel.setBorder(IdeBorderFactory.createEmptyBorder(3, 0, 10, 0)); fixesPanel.setOpaque(false); fixesPanel.add(Box.createHorizontalStrut(icon.getIconWidth())); for (Pair<String, Runnable> pair : message.myAdditionalFixes) { HyperlinkLabel fixLabel = new HyperlinkLabel(); fixLabel.setOpaque(false); fixLabel.setHyperlinkText(pair.getFirst()); final Runnable fix = pair.getSecond(); fixLabel.addHyperlinkListener( new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { fix.run(); } } }); fixesPanel.add(fixLabel); } myErrorMessages.add(fixesPanel); } }
private void checkSdk() { final String path = mySdkEditor.getPath(); if (StringUtil.isEmptyOrSpaces(path)) { myErrorLabel.setVisible(true); myErrorLabel.setHyperlinkText("App Engine SDK path not specified. ", "Download", ""); myMainPanel.repaint(); return; } final ValidationResult result = AppEngineSdkUtil.checkPath(path); myErrorLabel.setVisible(!result.isOk()); if (!result.isOk()) { myErrorLabel.setText("App Engine SDK path is not correct"); } myMainPanel.repaint(); }
public HectorComponent(@NotNull PsiFile file) { super(new GridBagLayout()); setBorder(BorderFactory.createEmptyBorder(0, 0, 7, 0)); myFile = file; mySliders = new HashMap<Language, JSlider>(); final Project project = myFile.getProject(); final ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex(); final VirtualFile virtualFile = myFile.getContainingFile().getVirtualFile(); LOG.assertTrue(virtualFile != null); final boolean notInLibrary = !fileIndex.isInLibrarySource(virtualFile) && !fileIndex.isInLibraryClasses(virtualFile) || fileIndex.isInContent(virtualFile); final FileViewProvider viewProvider = myFile.getViewProvider(); List<Language> languages = new ArrayList<Language>(viewProvider.getLanguages()); Collections.sort(languages, PsiUtilBase.LANGUAGE_COMPARATOR); for (Language language : languages) { @SuppressWarnings("UseOfObsoleteCollectionType") final Hashtable<Integer, JLabel> sliderLabels = new Hashtable<Integer, JLabel>(); sliderLabels.put(1, new JLabel(EditorBundle.message("hector.none.slider.label"))); sliderLabels.put(2, new JLabel(EditorBundle.message("hector.syntax.slider.label"))); if (notInLibrary) { sliderLabels.put(3, new JLabel(EditorBundle.message("hector.inspections.slider.label"))); } final JSlider slider = new JSlider(SwingConstants.VERTICAL, 1, notInLibrary ? 3 : 2, 1); if (UIUtil.isUnderGTKLookAndFeel()) { // default GTK+ slider UI is way too ugly slider.putClientProperty("Slider.paintThumbArrowShape", true); slider.setUI(new BasicSliderUI(slider)); } slider.setLabelTable(sliderLabels); UIUtil.setSliderIsFilled(slider, true); slider.setPaintLabels(true); slider.setSnapToTicks(true); slider.addChangeListener( new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { int value = slider.getValue(); for (Enumeration<Integer> enumeration = sliderLabels.keys(); enumeration.hasMoreElements(); ) { Integer key = enumeration.nextElement(); sliderLabels .get(key) .setForeground( key.intValue() <= value ? UIUtil.getLabelForeground() : UIUtil.getLabelDisabledForeground()); } } }); final PsiFile psiRoot = viewProvider.getPsi(language); assert psiRoot != null : "No root in " + viewProvider + " for " + language; slider.setValue( getValue( HighlightLevelUtil.shouldHighlight(psiRoot), HighlightLevelUtil.shouldInspect(psiRoot))); mySliders.put(language, slider); } GridBagConstraints gc = new GridBagConstraints( 0, GridBagConstraints.RELATIVE, 1, 1, 0, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 5, 0, 0), 0, 0); JPanel panel = new JPanel(new GridBagLayout()); panel.setBorder(IdeBorderFactory.createTitledBorder(myTitle, false)); final boolean addLabel = mySliders.size() > 1; if (addLabel) { layoutVertical(panel); } else { layoutHorizontal(panel); } gc.gridx = 0; gc.gridy = 0; gc.weighty = 1.0; gc.fill = GridBagConstraints.BOTH; add(panel, gc); gc.gridy = GridBagConstraints.RELATIVE; gc.weighty = 0; final HyperlinkLabel configurator = new HyperlinkLabel("Configure inspections"); gc.insets.right = 5; gc.insets.bottom = 10; gc.weightx = 0; gc.fill = GridBagConstraints.NONE; gc.anchor = GridBagConstraints.EAST; add(configurator, gc); configurator.addHyperlinkListener( new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent e) { final JBPopup hector = getOldHector(); if (hector != null) { hector.cancel(); } if (!DaemonCodeAnalyzer.getInstance(myFile.getProject()) .isHighlightingAvailable(myFile)) return; final Project project = myFile.getProject(); final ErrorsConfigurable errorsConfigurable = ErrorsConfigurable.SERVICE.createConfigurable(project); assert errorsConfigurable != null; ShowSettingsUtil.getInstance().editConfigurable(project, errorsConfigurable); } }); gc.anchor = GridBagConstraints.WEST; gc.weightx = 1.0; gc.insets.right = 0; gc.fill = GridBagConstraints.HORIZONTAL; myAdditionalPanels = new ArrayList<HectorComponentPanel>(); for (HectorComponentPanelsProvider provider : Extensions.getExtensions(HectorComponentPanelsProvider.EP_NAME, project)) { final HectorComponentPanel componentPanel = provider.createConfigurable(file); if (componentPanel != null) { myAdditionalPanels.add(componentPanel); add(componentPanel.createComponent(), gc); componentPanel.reset(); } } }