diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/CreateClassDialog.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/CreateClassDialog.java index 1dfae7e1bf14..203308cab9b8 100644 --- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/CreateClassDialog.java +++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/CreateClassDialog.java @@ -77,7 +77,7 @@ public class CreateClassDialog extends DialogWrapper { init(); if (!myClassNameEditable) { - setTitle(CodeInsightBundle.message("dialog.create.class.name", kind.getDescription(), targetClassName)); + setTitle(CodeInsightBundle.message("dialog.create.class.name", StringUtil.capitalize(kind.getDescription()), targetClassName)); } else { myInformationLabel.setText(CodeInsightBundle.message("dialog.create.class.label", kind.getDescription())); diff --git a/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java b/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java index 00ee4db4b203..966830d45be2 100644 --- a/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java +++ b/platform/lang-impl/src/com/intellij/execution/impl/ConsoleViewImpl.java @@ -192,7 +192,7 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo this.endOffset = endOffset; attributes = contentType.getAttributes(); } - + public int getLength() { return endOffset - startOffset; } @@ -256,7 +256,7 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo * Target offsets are anchored to the {@link #myDeferredOutput deferred buffer}. */ private final List myDeferredTokens = new ArrayList(); - + private final Hyperlinks myHyperlinks = new Hyperlinks(); private final TIntObjectHashMap myFolding = new TIntObjectHashMap(); @@ -529,13 +529,13 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo /** * IJ console works as follows - it receives managed process outputs from dedicated thread that serves that process and * pushes it to the {@link Document document} of editor used to represent process console. Important point here is that process - * output is received in a control flow of the thread over than EDT but push to the document is performed from EDT. Hence, we + * output is received in a control flow of the thread over than EDT but push to the document is performed from EDT. Hence, we * have a potential situation when particular process outputs a lot and EDT is busy or push to the document is performed slowly. *

* We don't want to keep too many information from the underlying process then and want to trim text buffer that holds text * to push to the document then. Current method serves exactly that purpose, i.e. it's expected to be called when new chunk of * text is received from the underlying process and trims existing text buffer if necessary. - * + * * @param numberOfNewSymbols number of symbols read from the managed process output * @return number of newly read symbols that should be accepted */ @@ -543,15 +543,15 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo if (!USE_CYCLIC_BUFFER || myDeferredOutput.length() <= 0 || myDeferredOutput.length() + numberOfNewSymbols <= CYCLIC_BUFFER_SIZE) { return numberOfNewSymbols; } - + final int numberOfSymbolsToRemove = myDeferredOutput.length() + numberOfNewSymbols - CYCLIC_BUFFER_SIZE; myDeferredTypes.clear(); - + int removedSymbolsNumber = 0; int endIndex = -1; for (int i = 0; i < myDeferredTokens.size(); i++) { TokenInfo tokenInfo = myDeferredTokens.get(i); - + if (removedSymbolsNumber < numberOfSymbolsToRemove) { int tokenLength = tokenInfo.getLength(); @@ -562,7 +562,7 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo removedSymbolsNumber += tokenLength; continue; } - + int remainingNumberOfSymbolsToRemove = numberOfSymbolsToRemove - removedSymbolsNumber; if (remainingNumberOfSymbolsToRemove >= tokenLength) { // We assume here that token construction is smart enough to extend end index in case of subsequent tokens of the same type, @@ -581,11 +581,11 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo removedSymbolsNumber = numberOfSymbolsToRemove; } } - + if (removedSymbolsNumber < numberOfSymbolsToRemove) { continue; } - + if (endIndex < 0) { endIndex = i; } @@ -594,7 +594,7 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo tokenInfo.endOffset -= numberOfSymbolsToRemove; myDeferredTypes.add(tokenInfo.contentType); } - + if (endIndex < 0) { myDeferredTokens.clear(); } @@ -622,7 +622,7 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo } return numberOfNewSymbols; } - + protected void beforeExternalAddContentToDocument(int length, ConsoleViewContentType contentType) { myContentSize+=length; addToken(length, null, contentType); @@ -1698,11 +1698,11 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo if (state && placeholder == null) { return; } - + final FoldingModel foldingModel = myEditor.getFoldingModel(); FoldRegion[] foldRegions = foldingModel.getAllFoldRegions(); Runnable foldTask = null; - + final int endFoldRegionOffset = myEditor.getDocument().getLineEndOffset(0); Runnable addCollapsedFoldRegionTask = new Runnable() { @Override @@ -1733,7 +1733,7 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo foldTask = addCollapsedFoldRegionTask; } } - + if (foldTask != null) { foldingModel.runBatchFoldingOperation(foldTask); } @@ -1957,6 +1957,10 @@ public class ConsoleViewImpl extends JPanel implements ConsoleView, ObservableCo return endOffset; } + public boolean isRunning() { + return myState.isRunning(); + } + /** * Command line used to launch application/test from idea is quite a big most of the time (it's likely that classpath definition * takes a lot of space). Hence, it takes many visual lines during representation if soft wraps are enabled. diff --git a/platform/lang-impl/src/com/intellij/facet/impl/pointers/FacetPointersManagerImpl.java b/platform/lang-impl/src/com/intellij/facet/impl/pointers/FacetPointersManagerImpl.java index 27a4d4fb3e2b..6adb9767a845 100644 --- a/platform/lang-impl/src/com/intellij/facet/impl/pointers/FacetPointersManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/facet/impl/pointers/FacetPointersManagerImpl.java @@ -92,6 +92,14 @@ public class FacetPointersManagerImpl extends FacetPointersManager implements Pr public void initComponent() { final FacetManagerListener facetListener = new FacetManagerAdapter() { + @Override + public void beforeFacetRenamed(@NotNull Facet facet) { + final FacetPointerImpl pointer = myPointers.get(constructId(facet)); + if (pointer != null) { + pointer.refresh(); + } + } + public void facetRenamed(@NotNull final Facet facet, @NotNull final String oldName) { refreshPointers(facet.getModule()); } diff --git a/platform/platform-api/src/com/intellij/ide/util/PropertiesComponent.java b/platform/platform-api/src/com/intellij/ide/util/PropertiesComponent.java index 20b65c0f86bb..52272fe91fef 100644 --- a/platform/platform-api/src/com/intellij/ide/util/PropertiesComponent.java +++ b/platform/platform-api/src/com/intellij/ide/util/PropertiesComponent.java @@ -20,6 +20,8 @@ import com.intellij.openapi.project.Project; import org.jetbrains.annotations.NonNls; public abstract class PropertiesComponent { + public abstract void unsetValue(String name); + public static PropertiesComponent getInstance(Project project) { return project.getComponent(PropertiesComponent.class); } diff --git a/platform/platform-impl/src/com/intellij/application/options/PathMacrosImpl.java b/platform/platform-impl/src/com/intellij/application/options/PathMacrosImpl.java index ff6d42bcfafb..9e0eca498ed2 100644 --- a/platform/platform-impl/src/com/intellij/application/options/PathMacrosImpl.java +++ b/platform/platform-impl/src/com/intellij/application/options/PathMacrosImpl.java @@ -110,6 +110,7 @@ public class PathMacrosImpl extends PathMacros implements ApplicationComponent, "ModuleName", "ModuleSourcePath", "OutputPath", + "PhpExecutable", "ProjectFileDir", "ProjectFilePath", "ProjectName", diff --git a/platform/platform-impl/src/com/intellij/ide/util/PropertiesComponentImpl.java b/platform/platform-impl/src/com/intellij/ide/util/PropertiesComponentImpl.java index 2ba64b19a7ad..cb7f05533797 100644 --- a/platform/platform-impl/src/com/intellij/ide/util/PropertiesComponentImpl.java +++ b/platform/platform-impl/src/com/intellij/ide/util/PropertiesComponentImpl.java @@ -22,8 +22,7 @@ import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; -public class PropertiesComponentImpl extends PropertiesComponent - implements PersistentStateComponent { +public class PropertiesComponentImpl extends PropertiesComponent implements PersistentStateComponent { private final HashMap myMap = new HashMap(); @NonNls private static final String ELEMENT_PROPERTY = "property"; @NonNls private static final String ATTRIBUTE_NAME = "name"; @@ -76,6 +75,11 @@ public class PropertiesComponentImpl extends PropertiesComponent myMap.put(name, value); } + @Override + public void unsetValue(String name) { + myMap.remove(name); + } + public boolean isValueSet(String name) { return myMap.containsKey(name); } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/actions/ScrollToTheEndToolbarAction.java b/platform/platform-impl/src/com/intellij/openapi/editor/actions/ScrollToTheEndToolbarAction.java index f0bec49f4da3..ba85adbe2524 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/actions/ScrollToTheEndToolbarAction.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/actions/ScrollToTheEndToolbarAction.java @@ -21,6 +21,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.ex.util.EditorUtil; import com.intellij.openapi.util.IconLoader; +import org.jetbrains.annotations.NotNull; /** * @author oleg @@ -28,7 +29,7 @@ import com.intellij.openapi.util.IconLoader; public class ScrollToTheEndToolbarAction extends AnAction { private final Editor myEditor; - public ScrollToTheEndToolbarAction(Editor editor) { + public ScrollToTheEndToolbarAction(@NotNull final Editor editor) { super(); myEditor = editor; final String message = ActionsBundle.message("action.EditorConsoleScrollToTheEnd.text"); diff --git a/platform/platform-impl/src/com/intellij/util/ui/ValidatingTableEditor.form b/platform/platform-impl/src/com/intellij/util/ui/ValidatingTableEditor.form index 91784e6483ab..f1fabb2b4f55 100644 --- a/platform/platform-impl/src/com/intellij/util/ui/ValidatingTableEditor.form +++ b/platform/platform-impl/src/com/intellij/util/ui/ValidatingTableEditor.form @@ -1,6 +1,6 @@

- + @@ -8,9 +8,9 @@ - + - + @@ -39,13 +39,13 @@ - + - + @@ -73,6 +73,14 @@ + + + + + + + +
diff --git a/platform/platform-impl/src/com/intellij/util/ui/ValidatingTableEditor.java b/platform/platform-impl/src/com/intellij/util/ui/ValidatingTableEditor.java index b71464a38513..8276664f01a6 100644 --- a/platform/platform-impl/src/com/intellij/util/ui/ValidatingTableEditor.java +++ b/platform/platform-impl/src/com/intellij/util/ui/ValidatingTableEditor.java @@ -91,6 +91,11 @@ public abstract class ValidatingTableEditor implements ComponentWithEmptyT public Class getColumnClass() { return myDelegate.getColumnClass(); } + + @Override + public TableCellRenderer getRenderer(Item item) { + return myDelegate.getRenderer(item); + } } private JPanel myContentPane; @@ -99,6 +104,7 @@ public abstract class ValidatingTableEditor implements ComponentWithEmptyT private JButton myRemoveButton; private JLabel myMessageLabel; private HoverHyperlinkLabel myFixLink; + private JButton myExtraButton; private final List myWarnings = new ArrayList(); private Fix myFixRunnable; @@ -211,6 +217,19 @@ public abstract class ValidatingTableEditor implements ComponentWithEmptyT removeSelected(); } }); + + myExtraButton.setVisible(false); + } + + protected ValidatingTableEditor(final ActionListener actionListener, String buttonText) { + this(); + myExtraButton.setVisible(true); + myExtraButton.setText(buttonText); + myExtraButton.addActionListener(actionListener); + } + + public List getSelectedItems() { + return myTable.getSelectedObjects(); } private void removeSelected() { @@ -379,5 +398,4 @@ public abstract class ValidatingTableEditor implements ComponentWithEmptyT header.setReorderingAllowed(value); } } - } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/AnnotationFieldGutter.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/AnnotationFieldGutter.java index cae5d4ec5582..f4ee40e12b0b 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/AnnotationFieldGutter.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/AnnotationFieldGutter.java @@ -34,13 +34,12 @@ import java.awt.*; import java.util.Collection; import java.util.List; import java.util.Map; -import java.util.regex.Pattern; /** * @author Irina Chernushina * @author Konstantin Bulenkov */ -class AnnotationFieldGutter implements ActiveAnnotationGutter { +public class AnnotationFieldGutter implements ActiveAnnotationGutter { protected final FileAnnotation myAnnotation; private final Editor myEditor; protected final LineAnnotationAspect myAspect; @@ -75,57 +74,39 @@ class AnnotationFieldGutter implements ActiveAnnotationGutter { public String getLineText(int line, Editor editor) { final String value = isAvailable() ? myAspect.getValue(line) : ""; if (myAspect.getId() == LineAnnotationAspect.AUTHOR && ShowShortenNames.isSet()) { - return shorten(value); + return shorten(value, ShowShortenNames.getType()); } return value; } @Nullable - private static String shorten(String value) { - if (value != null) { - // Vasya Pupkin - final int[] ind = {value.indexOf('<'), value.indexOf('@'), value.indexOf('>')}; + public static String shorten(String name, ShortNameType type) { + if (name != null) { + // Vasya Pupkin -> Vasya Pupkin + final int[] ind = {name.indexOf('<'), name.indexOf('@'), name.indexOf('>')}; if (0 < ind[0] && ind[0] < ind[1] && ind[1] < ind[2]) { - return shorten(value.substring(0, ind[0]).trim()); + return shorten(name.substring(0, ind[0]).trim(), type); } // vasya.pupkin@email.com --> vasya pupkin - if (isEmail(value)) { - final String firstPart = value.substring(0, value.indexOf('@')).replace('.', ' ').replace('_', ' ').replace('-', ' '); - if (firstPart.length() < value.length()) { - return shorten(firstPart); + if (!name.contains(" ") && name.contains("@")) { //simple e-mail check. john@localhost + final String firstPart = name.substring(0, name.indexOf('@')).replace('.', ' ').replace('_', ' ').replace('-', ' '); + if (firstPart.length() < name.length()) { + return shorten(firstPart, type); } else { return firstPart; } } - final List strings = StringUtil.split(value, " "); + final List strings = StringUtil.split(name.replace('.', ' ').replace('_', ' ').replace('-', ' '), " "); if (strings.size() > 1) { //Middle name check: Vasya S. Pupkin - return strings.get(1).length() < 3 && strings.size() > 2 && strings.get(2).length() > 1 ? strings.get(2) : strings.get(1); - } - if (value.contains(".")) { - strings.clear(); - strings.addAll(StringUtil.split(value, ".")); - // vasya.pupkin case - if (strings.size() > 1) { - //Middle name check: Vasya.S.Pupkin - return strings.get(1).length() == 1 && strings.size() > 2 && strings.get(2).length() > 1 ? strings.get(2) : strings.get(1); - } + return StringUtil.capitalize(type == ShortNameType.FIRSTNAME ? strings.get(0) : strings.get(strings.size() - 1)); } } - return value; + return name; } - private static final Pattern EMAIL = Pattern.compile("^[\\w\\.-]+@([\\w\\-]+\\.)+[a-z]{2,15}$"); - public static boolean isEmail(String s) { - if (!StringUtil.isEmpty(s)) { - return EMAIL.matcher(s).matches(); - } - return false; - } - - @Nullable public String getToolTip(final int line, final Editor editor) { return isAvailable() ? @@ -211,4 +192,14 @@ class AnnotationFieldGutter implements ActiveAnnotationGutter { public String getID() { return myAspect == null ? null : myAspect.getId(); } + + + public static void main(String[] args) { + assert shorten("Vasya Pavlovich Pupkin ", ShortNameType.FIRSTNAME).equals("Vasya"); + assert shorten("Vasya Pavlovich Pupkin ", ShortNameType.LASTNAME).equals("Pupkin"); + assert shorten("Vasya Pavlovich Pupkin", ShortNameType.FIRSTNAME).equals("Vasya"); + assert shorten("Vasya Pavlovich Pupkin", ShortNameType.LASTNAME).equals("Pupkin"); + assert shorten("vasya.pupkin@localhost.com", ShortNameType.LASTNAME).equals("Pupkin"); + assert shorten("vasya.pupkin@localhost.com", ShortNameType.FIRSTNAME).equals("Vasya"); + } } diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/ShortNameType.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/ShortNameType.java new file mode 100644 index 000000000000..a40935939f7a --- /dev/null +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/ShortNameType.java @@ -0,0 +1,52 @@ +/* + * Copyright 2000-2010 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.intellij.openapi.vcs.actions; + +import com.intellij.ide.util.PropertiesComponent; + +/** +* @author Konstantin Bulenkov +*/ +public enum ShortNameType { + LASTNAME("lastname", "Last Name"), + FIRSTNAME("firstname", "First Name"), + NONE("full", "Full name"); + + private static final String KEY = "annotate.short.names.type"; + private final String myId; + private final String myDescription; + + ShortNameType(String id, String description) { + myId = id; + myDescription = description; + } + + public String getDescription() { + return myDescription; + } + + boolean isSet() { + return myId.equals(PropertiesComponent.getInstance().getValue(KEY)); + } + + void set(boolean enable) { + if (enable) { + PropertiesComponent.getInstance().setValue(KEY, myId); + } else { + PropertiesComponent.getInstance().unsetValue(KEY); + } + } +} diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/ShowShortenNames.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/ShowShortenNames.java index 473d9c556b3b..8212c0bd664a 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/ShowShortenNames.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/ShowShortenNames.java @@ -16,34 +16,78 @@ package com.intellij.openapi.vcs.actions; import com.intellij.ide.util.PropertiesComponent; +import com.intellij.openapi.actionSystem.ActionGroup; +import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.ToggleAction; import com.intellij.openapi.editor.ex.EditorGutterComponentEx; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; /** * @author Konstantin Bulenkov */ -public class ShowShortenNames extends ToggleAction { +public class ShowShortenNames extends ActionGroup { public static final String KEY = "annotate.show.short.names"; - private final EditorGutterComponentEx myGutter; - public ShowShortenNames(EditorGutterComponentEx gutter) { - super("Short names"); - myGutter = gutter; + private final AnAction[] myChildren; + public ShowShortenNames(final EditorGutterComponentEx gutter) { + super("Names", true); + final ArrayList kids = new ArrayList(ShortNameType.values().length); + for (ShortNameType type : ShortNameType.values()) { + kids.add(new SetShortNameTypeAction(type, gutter)); + } + myChildren = kids.toArray(new AnAction[kids.size()]); } - + @NotNull @Override - public boolean isSelected(AnActionEvent e) { - return isSet(); - } - - @Override - public void setSelected(AnActionEvent e, boolean state) { - PropertiesComponent.getInstance().setValue(KEY, String.valueOf(state)); - myGutter.revalidateMarkup(); + public AnAction[] getChildren(@Nullable AnActionEvent e) { + return myChildren; } public static boolean isSet() { - return PropertiesComponent.getInstance().getBoolean(KEY, true); + return getType() != ShortNameType.NONE; + } + + public static ShortNameType getType() { + for (ShortNameType type : ShortNameType.values()) { + if (type.isSet()) { + return type; + } + } + return ShortNameType.LASTNAME; + } + + public static class SetShortNameTypeAction extends ToggleAction { + private final ShortNameType myType; + private final EditorGutterComponentEx myGutter; + + public SetShortNameTypeAction(ShortNameType type, EditorGutterComponentEx gutter) { + super(type.getDescription()); + myType = type; + myGutter = gutter; + } + + @Override + public boolean isSelected(AnActionEvent e) { + return myType == getType(); + } + + @Override + public void setSelected(AnActionEvent e, boolean enabled) { + PropertiesComponent.getInstance().unsetValue(KEY); + if (enabled) { + myType.set(enabled); + } else { + if (myType == ShortNameType.NONE) { + ShortNameType.LASTNAME.set(true); + } else { + ShortNameType.NONE.set(true); + } + } + myGutter.revalidateMarkup(); + } } }