use of com.intellij.ide.ui.UISettings 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 com.intellij.ide.ui.UISettings in project intellij-community by JetBrains.
the class ViewNavigationBarAction method setSelected.
@Override
public void setSelected(AnActionEvent e, boolean state) {
UISettings uiSettings = UISettings.getInstance();
uiSettings.setShowNavigationBar(state);
uiSettings.fireUISettingsChanged();
}
use of com.intellij.ide.ui.UISettings in project intellij-community by JetBrains.
the class EditorOptionsPanel method apply.
@Override
public void apply() throws ConfigurationException {
EditorSettingsExternalizable editorSettings = EditorSettingsExternalizable.getInstance();
CodeInsightSettings codeInsightSettings = CodeInsightSettings.getInstance();
UISettings uiSettings = UISettings.getInstance();
VcsApplicationSettings vcsSettings = VcsApplicationSettings.getInstance();
// Display
editorSettings.setSmoothScrolling(myCbSmoothScrolling.isSelected());
ComponentSettings.getInstance().setSmoothScrollingEnabled(myCbSmoothScrolling.isSelected());
// Brace Highlighting
codeInsightSettings.HIGHLIGHT_BRACES = myCbHighlightBraces.isSelected();
codeInsightSettings.HIGHLIGHT_SCOPE = myCbHighlightScope.isSelected();
codeInsightSettings.HIGHLIGHT_IDENTIFIER_UNDER_CARET = myCbHighlightIdentifierUnderCaret.isSelected();
clearAllIdentifierHighlighters();
// Virtual space
editorSettings.setUseSoftWraps(myCbUseSoftWrapsAtEditor.isSelected(), SoftWrapAppliancePlaces.MAIN_EDITOR);
editorSettings.setUseCustomSoftWrapIndent(myCbUseCustomSoftWrapIndent.isSelected());
editorSettings.setCustomSoftWrapIndent(getCustomSoftWrapIndent());
editorSettings.setAllSoftwrapsShown(!myCbShowSoftWrapsOnlyOnCaretLine.isSelected());
editorSettings.setVirtualSpace(myCbVirtualSpace.isSelected());
editorSettings.setCaretInsideTabs(myCbCaretInsideTabs.isSelected());
editorSettings.setAdditionalPageAtBottom(myCbVirtualPageAtBottom.isSelected());
// Limits
boolean uiSettingsChanged = false;
int maxClipboardContents = getMaxClipboardContents();
if (uiSettings.getMaxClipboardContents() != maxClipboardContents) {
uiSettings.setMaxClipboardContents(maxClipboardContents);
uiSettingsChanged = true;
}
if (uiSettingsChanged) {
uiSettings.fireUISettingsChanged();
}
if (STRIP_NONE.equals(myStripTrailingSpacesCombo.getSelectedItem())) {
editorSettings.setStripTrailingSpaces(EditorSettingsExternalizable.STRIP_TRAILING_SPACES_NONE);
} else if (STRIP_CHANGED.equals(myStripTrailingSpacesCombo.getSelectedItem())) {
editorSettings.setStripTrailingSpaces(EditorSettingsExternalizable.STRIP_TRAILING_SPACES_CHANGED);
} else {
editorSettings.setStripTrailingSpaces(EditorSettingsExternalizable.STRIP_TRAILING_SPACES_WHOLE);
}
editorSettings.setKeepTrailingSpacesOnCaretLine(myCbKeepTrailingSpacesOnCaretLine.isSelected());
editorSettings.setEnsureNewLineAtEOF(myCbEnsureBlankLineBeforeCheckBox.isSelected());
if (myCbShowQuickDocOnMouseMove.isSelected() ^ editorSettings.isShowQuickDocOnMouseOverElement()) {
boolean enabled = myCbShowQuickDocOnMouseMove.isSelected();
editorSettings.setShowQuickDocOnMouseOverElement(enabled);
ServiceManager.getService(QuickDocOnMouseOverManager.class).setEnabled(enabled);
}
int quickDocDelay = getQuickDocDelayFromGui();
if (quickDocDelay != -1) {
editorSettings.setQuickDocOnMouseOverElementDelayMillis(quickDocDelay);
}
editorSettings.setDndEnabled(myCbEnableDnD.isSelected());
editorSettings.setWheelFontChangeEnabled(myCbEnableWheelFontChange.isSelected());
editorSettings.setMouseClickSelectionHonorsCamelWords(myCbHonorCamelHumpsWhenSelectingByClicking.isSelected());
editorSettings.setRefrainFromScrolling(myRbPreferMovingCaret.isSelected());
editorSettings.setVariableInplaceRenameEnabled(myCbRenameLocalVariablesInplace.isSelected());
editorSettings.setPreselectRename(myPreselectCheckBox.isSelected());
editorSettings.setShowInlineLocalDialog(myShowInlineDialogForCheckBox.isSelected());
editorSettings.getOptions().SHOW_NOTIFICATION_AFTER_REFORMAT_CODE_ACTION = myShowNotificationAfterReformatCodeCheckBox.isSelected();
editorSettings.getOptions().SHOW_NOTIFICATION_AFTER_OPTIMIZE_IMPORTS_ACTION = myShowNotificationAfterOptimizeImportsCheckBox.isSelected();
boolean updateVcsSettings = false;
if (vcsSettings.SHOW_WHITESPACES_IN_LST != myShowWhitespacesModificationsInLSTGutterCheckBox.isSelected()) {
vcsSettings.SHOW_WHITESPACES_IN_LST = myShowWhitespacesModificationsInLSTGutterCheckBox.isSelected();
updateVcsSettings = true;
}
if (vcsSettings.SHOW_LST_GUTTER_MARKERS != myShowLSTInGutterCheckBox.isSelected()) {
vcsSettings.SHOW_LST_GUTTER_MARKERS = myShowLSTInGutterCheckBox.isSelected();
updateVcsSettings = true;
}
if (updateVcsSettings) {
ApplicationManager.getApplication().getMessageBus().syncPublisher(LineStatusTrackerSettingListener.TOPIC).settingsUpdated();
}
reinitAllEditors();
String temp = myRecentFilesLimitField.getText();
if (temp.trim().length() > 0) {
try {
int newRecentFilesLimit = Integer.parseInt(temp);
if (newRecentFilesLimit > 0 && uiSettings.getRecentFilesLimit() != newRecentFilesLimit) {
uiSettings.setRecentFilesLimit(newRecentFilesLimit);
uiSettingsChanged = true;
}
} catch (NumberFormatException ignored) {
}
}
if (uiSettingsChanged) {
uiSettings.fireUISettingsChanged();
}
myErrorHighlightingPanel.apply();
RichCopySettings settings = RichCopySettings.getInstance();
settings.setEnabled(myCbEnableRichCopyByDefault.isSelected());
Object item = myRichCopyColorSchemeComboBox.getSelectedItem();
if (item instanceof String) {
settings.setSchemeName(item.toString());
}
restartDaemons();
}
use of com.intellij.ide.ui.UISettings in project intellij-community by JetBrains.
the class EditorOptionsPanel method reset.
@Override
public void reset() {
EditorSettingsExternalizable editorSettings = EditorSettingsExternalizable.getInstance();
CodeInsightSettings codeInsightSettings = CodeInsightSettings.getInstance();
UISettings uiSettings = UISettings.getInstance();
VcsApplicationSettings vcsSettings = VcsApplicationSettings.getInstance();
// Display
myCbSmoothScrolling.setSelected(editorSettings.isSmoothScrolling());
// Brace highlighting
myCbHighlightBraces.setSelected(codeInsightSettings.HIGHLIGHT_BRACES);
myCbHighlightScope.setSelected(codeInsightSettings.HIGHLIGHT_SCOPE);
myCbHighlightIdentifierUnderCaret.setSelected(codeInsightSettings.HIGHLIGHT_IDENTIFIER_UNDER_CARET);
// Virtual space
myCbUseSoftWrapsAtEditor.setSelected(editorSettings.isUseSoftWraps(SoftWrapAppliancePlaces.MAIN_EDITOR));
myCbUseCustomSoftWrapIndent.setSelected(editorSettings.isUseCustomSoftWrapIndent());
myCustomSoftWrapIndent.setText(Integer.toString(editorSettings.getCustomSoftWrapIndent()));
myCbShowSoftWrapsOnlyOnCaretLine.setSelected(!editorSettings.isAllSoftWrapsShown());
updateSoftWrapSettingsRepresentation();
myCbVirtualSpace.setSelected(editorSettings.isVirtualSpace());
myCbCaretInsideTabs.setSelected(editorSettings.isCaretInsideTabs());
myCbVirtualPageAtBottom.setSelected(editorSettings.isAdditionalPageAtBottom());
// Limits
myClipboardContentLimitTextField.setText(Integer.toString(uiSettings.getMaxClipboardContents()));
// Strip trailing spaces on save
String stripTrailingSpaces = editorSettings.getStripTrailingSpaces();
if (EditorSettingsExternalizable.STRIP_TRAILING_SPACES_NONE.equals(stripTrailingSpaces)) {
myStripTrailingSpacesCombo.setSelectedItem(STRIP_NONE);
} else if (EditorSettingsExternalizable.STRIP_TRAILING_SPACES_CHANGED.equals(stripTrailingSpaces)) {
myStripTrailingSpacesCombo.setSelectedItem(STRIP_CHANGED);
} else if (EditorSettingsExternalizable.STRIP_TRAILING_SPACES_WHOLE.equals(stripTrailingSpaces)) {
myStripTrailingSpacesCombo.setSelectedItem(STRIP_ALL);
}
myCbKeepTrailingSpacesOnCaretLine.setSelected(editorSettings.isKeepTrailingSpacesOnCaretLine());
myCbEnsureBlankLineBeforeCheckBox.setSelected(editorSettings.isEnsureNewLineAtEOF());
myCbShowQuickDocOnMouseMove.setSelected(editorSettings.isShowQuickDocOnMouseOverElement());
myQuickDocDelayTextField.setText(Long.toString(editorSettings.getQuickDocOnMouseOverElementDelayMillis()));
myQuickDocDelayTextField.setEnabled(editorSettings.isShowQuickDocOnMouseOverElement());
myQuickDocDelayLabel.setEnabled(editorSettings.isShowQuickDocOnMouseOverElement());
// Advanced mouse
myCbEnableDnD.setSelected(editorSettings.isDndEnabled());
myCbEnableWheelFontChange.setSelected(editorSettings.isWheelFontChangeEnabled());
myCbHonorCamelHumpsWhenSelectingByClicking.setSelected(editorSettings.isMouseClickSelectionHonorsCamelWords());
myRbPreferMovingCaret.setSelected(editorSettings.isRefrainFromScrolling());
myRbPreferScrolling.setSelected(!editorSettings.isRefrainFromScrolling());
myRecentFilesLimitField.setText(Integer.toString(uiSettings.getRecentFilesLimit()));
myCbRenameLocalVariablesInplace.setSelected(editorSettings.isVariableInplaceRenameEnabled());
myPreselectCheckBox.setSelected(editorSettings.isPreselectRename());
myShowInlineDialogForCheckBox.setSelected(editorSettings.isShowInlineLocalDialog());
myShowNotificationAfterReformatCodeCheckBox.setSelected(editorSettings.getOptions().SHOW_NOTIFICATION_AFTER_REFORMAT_CODE_ACTION);
myShowNotificationAfterOptimizeImportsCheckBox.setSelected(editorSettings.getOptions().SHOW_NOTIFICATION_AFTER_OPTIMIZE_IMPORTS_ACTION);
myShowLSTInGutterCheckBox.setSelected(vcsSettings.SHOW_LST_GUTTER_MARKERS);
myShowWhitespacesModificationsInLSTGutterCheckBox.setSelected(vcsSettings.SHOW_WHITESPACES_IN_LST);
myShowWhitespacesModificationsInLSTGutterCheckBox.setEnabled(myShowLSTInGutterCheckBox.isSelected());
myErrorHighlightingPanel.reset();
RichCopySettings settings = RichCopySettings.getInstance();
myCbEnableRichCopyByDefault.setSelected(settings.isEnabled());
myRichCopyColorSchemeComboBox.removeAllItems();
EditorColorsScheme[] schemes = EditorColorsManager.getInstance().getAllSchemes();
myRichCopyColorSchemeComboBox.addItem(RichCopySettings.ACTIVE_GLOBAL_SCHEME_MARKER);
for (EditorColorsScheme scheme : schemes) {
myRichCopyColorSchemeComboBox.addItem(scheme.getName());
}
String toSelect = settings.getSchemeName();
if (!StringUtil.isEmpty(toSelect)) {
myRichCopyColorSchemeComboBox.setSelectedItem(toSelect);
}
}
use of com.intellij.ide.ui.UISettings in project intellij-community by JetBrains.
the class ConsoleConfigurable method isModified.
@Override
public boolean isModified() {
EditorSettingsExternalizable editorSettings = EditorSettingsExternalizable.getInstance();
boolean isModified = !ContainerUtil.newHashSet(myNegativePanel.getListItems()).equals(ContainerUtil.newHashSet(mySettings.getNegativePatterns()));
isModified |= !ContainerUtil.newHashSet(myPositivePanel.getListItems()).equals(ContainerUtil.newHashSet(mySettings.getPositivePatterns()));
isModified |= isModified(myCbUseSoftWrapsAtConsole, editorSettings.isUseSoftWraps(SoftWrapAppliancePlaces.CONSOLE));
UISettings uiSettings = UISettings.getInstance();
isModified |= isModified(myCommandsHistoryLimitField, uiSettings.getConsoleCommandHistoryLimit());
if (ConsoleBuffer.useCycleBuffer()) {
isModified |= isModified(myCbOverrideConsoleCycleBufferSize, uiSettings.getOverrideConsoleCycleBufferSize());
isModified |= isModified(myConsoleCycleBufferSizeField, uiSettings.getConsoleCycleBufferSizeKb());
}
return isModified;
}
Aggregations