diff options
Diffstat (limited to 'java/idea-ui/src')
15 files changed, 84 insertions, 1326 deletions
diff --git a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryOptionsPanel.form b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryOptionsPanel.form index a738a96aa50e..9e5dd85f6936 100644 --- a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryOptionsPanel.form +++ b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryOptionsPanel.form @@ -139,7 +139,7 @@ <componentStyle value="SMALL"/> <enabled value="true"/> <fontColor value="BRIGHTER"/> - <text value="<html>{} jars will be downloaded into <b>lib</b> directory<br> Project level library <b>spring</b> will be created</html>"/> + <text value="<html>{} JARs will be downloaded into <b>lib</b> directory<br> Project level library <b>spring</b> will be created</html>"/> </properties> </component> <component id="84326" class="javax.swing.JLabel" binding="myHiddenLabel"> diff --git a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryOptionsPanel.java b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryOptionsPanel.java index 3bb96adb1141..a890bdad527d 100644 --- a/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryOptionsPanel.java +++ b/java/idea-ui/src/com/intellij/facet/impl/ui/libraries/LibraryOptionsPanel.java @@ -490,7 +490,7 @@ public class LibraryOptionsPanel implements Disposable { else { path = PathUtil.getFileName(downloadPath); } - return MessageFormat.format("{0} {0, choice, 1#jar|2#jars} will be downloaded into <b>{1}</b> directory<br>" + + return MessageFormat.format("{0} {0, choice, 1#JAR|2#JARs} will be downloaded into <b>{1}</b> directory<br>" + "{2} library <b>{3}</b> will be created", downloadSettings.getSelectedDownloads().size(), path, diff --git a/java/idea-ui/src/com/intellij/ide/RecentProjectsManager.java b/java/idea-ui/src/com/intellij/ide/RecentProjectsManager.java index 6ac07343357a..e2f93bf16771 100644 --- a/java/idea-ui/src/com/intellij/ide/RecentProjectsManager.java +++ b/java/idea-ui/src/com/intellij/ide/RecentProjectsManager.java @@ -16,31 +16,30 @@ package com.intellij.ide; import com.intellij.ide.impl.ProjectUtil; -import com.intellij.openapi.components.RoamingType; -import com.intellij.openapi.components.State; -import com.intellij.openapi.components.Storage; -import com.intellij.openapi.components.StoragePathMacros; +import com.intellij.openapi.components.*; import com.intellij.openapi.project.Project; import com.intellij.util.messages.MessageBus; import org.jetbrains.annotations.NotNull; @State( name = "RecentProjectsManager", - roamingType = RoamingType.DISABLED, storages = { - @Storage( - file = StoragePathMacros.APP_CONFIG + "/other.xml" - )} + @Storage(file = StoragePathMacros.APP_CONFIG + "/other.xml", roamingType = RoamingType.DISABLED), + @Storage(file = StoragePathMacros.APP_CONFIG + "/recentProjects.xml", roamingType = RoamingType.DISABLED) + }, + storageChooser = LastStorageChooserForWrite.class ) public class RecentProjectsManager extends RecentProjectsManagerBase { public RecentProjectsManager(MessageBus messageBus) { super(messageBus); } + @Override protected String getProjectPath(@NotNull Project project) { return project.getPresentableUrl(); } + @Override protected void doOpenProject(@NotNull String projectPath, Project projectToClose, boolean forceOpenInNewFrame) { ProjectUtil.openProject(projectPath, projectToClose, forceOpenInNewFrame); } diff --git a/java/idea-ui/src/com/intellij/ide/actions/ImportModuleAction.java b/java/idea-ui/src/com/intellij/ide/actions/ImportModuleAction.java index 3d497b829d50..3f087a998304 100644 --- a/java/idea-ui/src/com/intellij/ide/actions/ImportModuleAction.java +++ b/java/idea-ui/src/com/intellij/ide/actions/ImportModuleAction.java @@ -116,7 +116,7 @@ public class ImportModuleAction extends AnAction { if (lastLocation != null) { toSelect = LocalFileSystem.getInstance().refreshAndFindFileByPath(lastLocation); } - VirtualFile[] files = chooser.choose(toSelect, project); + VirtualFile[] files = chooser.choose(project, toSelect); if (files.length == 0) { return null; } diff --git a/java/idea-ui/src/com/intellij/ide/palette/impl/PaletteComponentList.java b/java/idea-ui/src/com/intellij/ide/palette/impl/PaletteComponentList.java deleted file mode 100644 index ea4f6de53401..000000000000 --- a/java/idea-ui/src/com/intellij/ide/palette/impl/PaletteComponentList.java +++ /dev/null @@ -1,401 +0,0 @@ -/* - * Copyright 2000-2012 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.ide.palette.impl; - -import com.intellij.ide.dnd.*; -import com.intellij.ide.palette.PaletteGroup; -import com.intellij.ide.palette.PaletteItem; -import com.intellij.openapi.actionSystem.ActionGroup; -import com.intellij.openapi.actionSystem.ActionManager; -import com.intellij.openapi.actionSystem.ActionPlaces; -import com.intellij.openapi.actionSystem.ActionPopupMenu; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.Pair; -import com.intellij.ui.ColoredListCellRenderer; -import com.intellij.ui.PopupHandler; -import com.intellij.ui.components.JBList; -import com.intellij.util.ui.PlatformColors; -import com.intellij.util.ui.UIUtil; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.Nullable; - -import javax.swing.*; -import javax.swing.plaf.basic.BasicListUI; -import java.awt.*; -import java.awt.event.*; - -/** - * @author yole - */ -public class PaletteComponentList extends JBList { - private final Project myProject; - private final PaletteGroup myGroup; - private int myHoverIndex = -1; - private int myBeforeClickSelectedRow = -1; - private int myDropTargetIndex = -1; - private boolean myNeedClearSelection = false; - - public PaletteComponentList(Project project, PaletteGroup group) { - myProject = project; - myGroup = group; - setModel(new AbstractListModel() { - public int getSize() { - return myGroup.getItems().length; - } - - public Object getElementAt(int index) { - return myGroup.getItems() [index]; - } - }); - - addMouseListener(new MouseAdapter() { - @Override public void mouseEntered(MouseEvent e) { - setHoverIndex(locationToIndex(e.getPoint())); - } - - @Override public void mouseExited(MouseEvent e) { - setHoverIndex(-1); - } - - @Override public void mousePressed(MouseEvent e) { - myNeedClearSelection = (SwingUtilities.isLeftMouseButton(e) && - myBeforeClickSelectedRow >= 0 && - locationToIndex(e.getPoint()) == myBeforeClickSelectedRow && - !UIUtil.isControlKeyDown(e) && !e.isShiftDown()); - } - - @Override public void mouseReleased(MouseEvent e) { - if (SwingUtilities.isLeftMouseButton(e) && - myBeforeClickSelectedRow >= 0 && - locationToIndex(e.getPoint()) == myBeforeClickSelectedRow && - !UIUtil.isControlKeyDown(e) && !e.isShiftDown() && myNeedClearSelection) { - clearSelection(); - } - } - }); - - addMouseListener(new PopupHandler() { - public void invokePopup(final Component comp, final int x, final int y) { - requestFocusInWindow(); - SwingUtilities.invokeLater(new Runnable() { - public void run() { - int index = locationToIndex(new Point(x, y)); - PaletteItem[] items = myGroup.getItems(); - if (index >= 0 && index < items.length) { - if (getSelectedIndex() != index) { - addSelectionInterval(index, index); - } - PaletteItem item = items [index]; - ActionGroup group = item.getPopupActionGroup(); - if (group != null) { - ActionPopupMenu popupMenu = ActionManager.getInstance().createActionPopupMenu(ActionPlaces.UNKNOWN, group); - popupMenu.getComponent().show(comp, x, y); - } - } - } - }); - } - }); - - addMouseMotionListener(new MouseMotionAdapter() { - public void mouseMoved(MouseEvent e) { - setHoverIndex(locationToIndex(e.getPoint())); - } - }); - - addKeyListener(new KeyListener() { - public void keyPressed(KeyEvent e) { - PaletteManager.getInstance(myProject).notifyKeyEvent(e); - } - - public void keyReleased(KeyEvent e) { - PaletteManager.getInstance(myProject).notifyKeyEvent(e); - } - - public void keyTyped(KeyEvent e) { - PaletteManager.getInstance(myProject).notifyKeyEvent(e); - } - }); - - setCellRenderer(new ComponentCellRenderer()); - - setVisibleRowCount(0); - setLayoutOrientation(HORIZONTAL_WRAP); - setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - - final DnDManager dndManager = DnDManager.getInstance(); - dndManager.registerSource(new MyDnDSource(), this); - dndManager.registerTarget(new MyDnDTarget(), this); - - initActions(); - } - - private void setHoverIndex(final int index) { - if (index != myHoverIndex) { - if (myHoverIndex >= 0) repaint(getCellBounds(myHoverIndex, myHoverIndex)); - myHoverIndex = index; - if (myHoverIndex >= 0) repaint(getCellBounds(myHoverIndex, myHoverIndex)); - } - } - - private void setDropTargetIndex(final int index) { - if (index != myDropTargetIndex) { - myDropTargetIndex = index; - repaint(); - } - } - - @Override public void updateUI() { - setUI(new ComponentListUI()); - invalidate(); - } - - private void initActions() { - @NonNls ActionMap map = getActionMap(); - map.put( "selectPreviousRow", new MoveFocusAction( map.get( "selectPreviousRow" ), false ) ); - map.put( "selectNextRow", new MoveFocusAction( map.get( "selectNextRow" ), true ) ); - map.put( "selectPreviousColumn", new MoveFocusAction( new ChangeColumnAction( map.get( "selectPreviousColumn" ), false ), false ) ); - map.put( "selectNextColumn", new MoveFocusAction( new ChangeColumnAction( map.get( "selectNextColumn" ), true ), true ) ); - } - - Integer myTempWidth; - - public int getWidth () { - return (myTempWidth == null) ? super.getWidth () : myTempWidth.intValue (); - } - - public int getPreferredHeight(final int width) { - myTempWidth = width; - try { - return getUI().getPreferredSize(this).height; - } - finally { - myTempWidth = null; - } - } - - public void takeFocusFrom(PaletteGroupHeader paletteGroup, int indexToSelect) { - if (indexToSelect == -1) { - //this is not 'our' CategoryButton so we'll assume it's the one below this category list - indexToSelect = getModel().getSize() - 1; - } - else if (getModel().getSize() == 0) { - indexToSelect = -1; - } - requestFocus(); - setSelectedIndex(indexToSelect); - if (indexToSelect >= 0) { - ensureIndexIsVisible(indexToSelect); - } - } - - @Override protected void paintComponent(Graphics g) { - super.paintComponent(g); - if (myDropTargetIndex >= 0) { - int dropLineY; - Rectangle rc; - if (myDropTargetIndex == myGroup.getItems().length) { - rc = getCellBounds(myDropTargetIndex-1, myDropTargetIndex-1); - dropLineY = (int)rc.getMaxY()-1; - } - else { - rc = getCellBounds(myDropTargetIndex, myDropTargetIndex); - dropLineY = rc.y; - } - Graphics2D g2d = (Graphics2D) g; - g2d.setColor(PlatformColors.BLUE); - g2d.setStroke(new BasicStroke(2.0f)); - g2d.drawLine(rc.x, dropLineY, rc.x+rc.width, dropLineY); - g2d.drawLine(rc.x, dropLineY-2, rc.x, dropLineY+2); - g2d.drawLine(rc.x+rc.width, dropLineY-2, rc.x+rc.width, dropLineY+2); - } - } - - class ComponentListUI extends BasicListUI { - private ComponentListListener myListener; - - @Override protected void updateLayoutState() { - super.updateLayoutState(); - - if (list.getLayoutOrientation() == JList.HORIZONTAL_WRAP) { - Insets insets = list.getInsets(); - int listWidth = list.getWidth() - (insets.left + insets.right); - if (listWidth >= cellWidth) { - int columnCount = listWidth / cellWidth; - cellWidth = (columnCount == 0) ? 1 : listWidth / columnCount; - } - } - } - - @Override protected void installListeners() { - myListener = new ComponentListListener(); - addMouseListener(myListener); - super.installListeners(); - } - - @Override - protected void uninstallListeners() { - if (myListener != null) { - removeMouseListener(myListener); - } - super.uninstallListeners(); - } - - private class ComponentListListener extends MouseAdapter { - @Override public void mousePressed(MouseEvent e) { - myBeforeClickSelectedRow = list.getSelectedIndex(); - } - } - } - - private static class ComponentCellRenderer extends ColoredListCellRenderer { - protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) { - PaletteItem paletteItem = (PaletteItem) value; - clear(); - paletteItem.customizeCellRenderer(this, selected, hasFocus); - } - } - - private class MoveFocusAction extends AbstractAction { - private final Action defaultAction; - private final boolean focusNext; - - public MoveFocusAction(Action defaultAction, boolean focusNext) { - this.defaultAction = defaultAction; - this.focusNext = focusNext; - } - - public void actionPerformed(ActionEvent e) { - int selIndexBefore = getSelectedIndex(); - defaultAction.actionPerformed(e); - int selIndexCurrent = getSelectedIndex(); - if (selIndexBefore != selIndexCurrent) return; - - if (focusNext && 0 == selIndexCurrent) return; - - KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager(); - Container container = kfm.getCurrentFocusCycleRoot(); - FocusTraversalPolicy policy = container.getFocusTraversalPolicy(); - if (null == policy) policy = kfm.getDefaultFocusTraversalPolicy(); - Component next = focusNext - ? policy.getComponentAfter(container, PaletteComponentList.this) - : policy.getComponentBefore(container, PaletteComponentList.this); - if (null != next && next instanceof PaletteGroupHeader) { - clearSelection(); - next.requestFocus(); - ((PaletteGroupHeader)next).scrollRectToVisible(next.getBounds()); - } - } - } - - private class ChangeColumnAction extends AbstractAction { - private final Action defaultAction; - private final boolean selectNext; - - public ChangeColumnAction(Action defaultAction, boolean selectNext) { - this.defaultAction = defaultAction; - this.selectNext = selectNext; - } - - public void actionPerformed(ActionEvent e) { - int selIndexBefore = getSelectedIndex(); - defaultAction.actionPerformed(e); - int selIndexCurrent = getSelectedIndex(); - if ((selectNext && selIndexBefore < selIndexCurrent) || (!selectNext && selIndexBefore > selIndexCurrent)) return; - - if (selectNext) { - if (selIndexCurrent == selIndexBefore + 1) selIndexCurrent++; - if (selIndexCurrent < getModel().getSize() - 1) { - setSelectedIndex(selIndexCurrent + 1); - scrollRectToVisible(getCellBounds(selIndexCurrent + 1, selIndexCurrent + 1)); - } - } - else { - if (selIndexCurrent > 0) { - setSelectedIndex(selIndexCurrent - 1); - scrollRectToVisible(getCellBounds(selIndexCurrent - 1, selIndexCurrent - 1)); - } - } - } - } - - private class MyDnDTarget implements DnDTarget { - - public boolean update(DnDEvent aEvent) { - setHoverIndex(-1); - if (aEvent.getAttachedObject() instanceof PaletteItem) { - setDropTargetIndex(locationToTargetIndex(aEvent.getPoint())); - aEvent.setDropPossible(true); - } - else { - setDropTargetIndex(-1); - aEvent.setDropPossible(false); - } - return false; - } - - public void drop(DnDEvent aEvent) { - setDropTargetIndex(-1); - if (aEvent.getAttachedObject() instanceof PaletteItem) { - int index = locationToTargetIndex(aEvent.getPoint()); - if (index >= 0) { - myGroup.handleDrop(myProject, (PaletteItem) aEvent.getAttachedObject(), index); - } - } - } - - public void cleanUpOnLeave() { - setDropTargetIndex(-1); - } - - private int locationToTargetIndex(Point location) { - int row = locationToIndex(location); - if (row < 0) { - return -1; - } - Rectangle rc = getCellBounds(row, row); - return location.y < rc.getCenterY() ? row : row + 1; - } - - public void updateDraggedImage(Image image, Point dropPoint, Point imageOffset) { - } - } - - private class MyDnDSource implements DnDSource { - public boolean canStartDragging(DnDAction action, Point dragOrigin) { - int index = locationToIndex(dragOrigin); - return index >= 0 && myGroup.getItems() [index].startDragging() != null; - } - - public DnDDragStartBean startDragging(DnDAction action, Point dragOrigin) { - int index = locationToIndex(dragOrigin); - if (index < 0) return null; - return myGroup.getItems() [index].startDragging(); - } - - @Nullable - public Pair<Image, Point> createDraggedImage(DnDAction action, Point dragOrigin) { - return null; - } - - public void dragDropEnd() { - } - - public void dropActionChanged(final int gestureModifiers) { - PaletteManager.getInstance(myProject).notifyDropActionChanged(gestureModifiers); - } - } -} diff --git a/java/idea-ui/src/com/intellij/ide/palette/impl/PaletteContentWindow.java b/java/idea-ui/src/com/intellij/ide/palette/impl/PaletteContentWindow.java deleted file mode 100644 index b5aaccad7b29..000000000000 --- a/java/idea-ui/src/com/intellij/ide/palette/impl/PaletteContentWindow.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright 2000-2009 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.ide.palette.impl; - -import org.jetbrains.annotations.Nullable; - -import javax.swing.*; -import java.awt.*; - -/** - * @author yole - */ -public class PaletteContentWindow extends JPanel implements Scrollable { - public PaletteContentWindow() { - setLayout(new PaletteLayoutManager()); - } - - public Dimension getPreferredScrollableViewportSize() { - return getPreferredSize(); - } - - public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) { - return 20; - } - - public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction) { - return 100; - } - - public boolean getScrollableTracksViewportWidth() { - return true; - } - - public boolean getScrollableTracksViewportHeight() { - return false; - } - - @Nullable PaletteGroupHeader getLastGroupHeader() { - PaletteGroupHeader result = null; - for(Component comp: getComponents()) { - if (comp instanceof PaletteGroupHeader) { - result = (PaletteGroupHeader) comp; - } - } - return result; - } - - private static class PaletteLayoutManager implements LayoutManager { - - public void addLayoutComponent(String name, Component comp) { - } - - public void layoutContainer(Container parent) { - int width = parent.getWidth(); - - int height = 0; - for(Component c: parent.getComponents()) { - if (c instanceof PaletteGroupHeader) { - PaletteGroupHeader groupHeader = (PaletteGroupHeader) c; - groupHeader.setLocation(0, height); - if (groupHeader.isVisible()) { - groupHeader.setSize(width, groupHeader.getPreferredSize().height); - height += groupHeader.getPreferredSize().height; - } - else { - groupHeader.setSize(0, 0); - } - if (groupHeader.isSelected() || !groupHeader.isVisible()) { - PaletteComponentList componentList = groupHeader.getComponentList(); - componentList.setSize(width, componentList.getPreferredSize().height); - componentList.setLocation(0, height); - height += componentList.getHeight(); - } - } - } - } - - public Dimension minimumLayoutSize(Container parent) { - return new Dimension(0, 0); - } - - public Dimension preferredLayoutSize(Container parent) { - int height = 0; - int width = parent.getWidth(); - for(Component c: parent.getComponents()) { - if (c instanceof PaletteGroupHeader) { - PaletteGroupHeader groupHeader = (PaletteGroupHeader) c; - height += groupHeader.getHeight(); - if (groupHeader.isSelected()) { - height += groupHeader.getComponentList().getPreferredHeight(width); - } - } - } - return new Dimension(10 /* not used - tracks viewports width*/, height); - } - - public void removeLayoutComponent(Component comp) { - } - } -} diff --git a/java/idea-ui/src/com/intellij/ide/palette/impl/PaletteGroupHeader.java b/java/idea-ui/src/com/intellij/ide/palette/impl/PaletteGroupHeader.java deleted file mode 100644 index c98caefa3f75..000000000000 --- a/java/idea-ui/src/com/intellij/ide/palette/impl/PaletteGroupHeader.java +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Copyright 2000-2013 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.ide.palette.impl; - -import com.intellij.ide.dnd.DnDEvent; -import com.intellij.ide.dnd.DnDManager; -import com.intellij.ide.dnd.DnDTarget; -import com.intellij.ide.palette.PaletteGroup; -import com.intellij.ide.palette.PaletteItem; -import com.intellij.openapi.actionSystem.*; -import com.intellij.openapi.project.Project; -import com.intellij.ui.PopupHandler; -import com.intellij.util.ui.UIUtil; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.Nullable; - -import javax.swing.*; -import javax.swing.border.CompoundBorder; -import java.awt.*; -import java.awt.event.*; - -/** - * @author yole - */ -public class PaletteGroupHeader extends JCheckBox implements DataProvider { - private final PaletteWindow myPaletteWindow; - private PaletteComponentList myComponentList; - private final PaletteGroup myGroup; - - public PaletteGroupHeader(PaletteWindow paletteWindow, PaletteGroup group) { - myPaletteWindow = paletteWindow; - myGroup = group; - if (group.getName() == null) { - setVisible(false); - } - else { - setText(group.getName()); - } - setSelected(true); - addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - if (myComponentList != null) { - myComponentList.setVisible(isSelected()); - } - } - }); - - addMouseListener(new PopupHandler() { - public void invokePopup(Component comp, int x, int y) { - myPaletteWindow.setLastFocusedGroup(PaletteGroupHeader.this); - showGroupPopupMenu(comp, x, y); - } - }); - - setIcon(UIUtil.getTreeCollapsedIcon()); - setSelectedIcon(UIUtil.getTreeExpandedIcon()); - setFont(getFont().deriveFont(Font.BOLD)); - setFocusPainted(false); - setMargin(new Insets(0, 3, 0, 3)); - setOpaque(true); - if (getBorder() instanceof CompoundBorder) { // from BasicLookAndFeel - Dimension pref = getPreferredSize(); - pref.height -= 3; - setPreferredSize(pref); - } - - DnDManager.getInstance().registerTarget(new DnDTarget() { - public boolean update(DnDEvent aEvent) { - setBorderPainted(true); - aEvent.setDropPossible(aEvent.getAttachedObject() instanceof PaletteItem); - return true; - } - - public void drop(DnDEvent aEvent) { - setBorderPainted(false); - if (aEvent.getAttachedObject() instanceof PaletteItem) { - myGroup.handleDrop(myPaletteWindow.getProject(), (PaletteItem) aEvent.getAttachedObject(), -1); - } - } - - public void cleanUpOnLeave() { - setBorderPainted(false); - } - - public void updateDraggedImage(Image image, Point dropPoint, Point imageOffset) { - } - }, this); - - addFocusListener(new FocusAdapter() { - @Override public void focusGained(FocusEvent e) { - myPaletteWindow.setLastFocusedGroup(PaletteGroupHeader.this); - } - }); - - initActions(); - } - - public void showGroupPopupMenu(final Component comp, final int x, final int y) { - ActionGroup group = myGroup.getPopupActionGroup(); - if (group != null) { - ActionPopupMenu popupMenu = ActionManager.getInstance().createActionPopupMenu(ActionPlaces.UNKNOWN, group); - popupMenu.getComponent().show(comp, x, y); - } - } - - private void initActions() { - @NonNls InputMap inputMap = getInputMap(WHEN_FOCUSED); - inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, 0, false), "moveFocusDown"); - inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_UP, 0, false), "moveFocusUp"); - inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0, false), "collapse"); - inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0, false), "expand"); - - @NonNls ActionMap actionMap = getActionMap(); - actionMap.put("moveFocusDown", new MoveFocusAction(true)); - actionMap.put("moveFocusUp", new MoveFocusAction(false)); - actionMap.put("collapse", new ExpandAction(false)); - actionMap.put("expand", new ExpandAction(true)); - } - - @Override public Color getBackground() { - if (isFocusOwner()) { - return UIUtil.getListSelectionBackground(); - } - return super.getBackground(); - } - - @Override public Color getForeground() { - if (isFocusOwner()) { - return UIUtil.getListSelectionForeground(); - } - return super.getForeground(); - } - - public void setComponentList(final PaletteComponentList componentList) { - myComponentList = componentList; - } - - public PaletteComponentList getComponentList() { - return myComponentList; - } - - public PaletteGroup getGroup() { - return myGroup; - } - - @Nullable public Object getData(String dataId) { - Object data = myPaletteWindow.getData(dataId); - if (data != null) return data; - Project project = CommonDataKeys.PROJECT.getData(myPaletteWindow); - return myGroup.getData(project, dataId); - } - - private class MoveFocusAction extends AbstractAction { - private final boolean moveDown; - - public MoveFocusAction(boolean moveDown) { - this.moveDown = moveDown; - } - - public void actionPerformed(ActionEvent e) { - KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager(); - Container container = kfm.getCurrentFocusCycleRoot(); - FocusTraversalPolicy policy = container.getFocusTraversalPolicy(); - if (null == policy) policy = kfm.getDefaultFocusTraversalPolicy(); - Component next = - moveDown ? policy.getComponentAfter(container, PaletteGroupHeader.this) : policy.getComponentBefore(container, PaletteGroupHeader.this); - if (null != next && next instanceof PaletteComponentList) { - final PaletteComponentList list = (PaletteComponentList)next; - if (list.getModel().getSize() != 0) { - list.takeFocusFrom(PaletteGroupHeader.this, list == myComponentList ? 0 : -1); - return; - } - else { - next = moveDown ? policy.getComponentAfter(container, next) : policy.getComponentBefore(container, next); - } - } - if (null != next && next instanceof PaletteGroupHeader) { - next.requestFocus(); - } - } - } - - private class ExpandAction extends AbstractAction { - private final boolean expand; - - public ExpandAction(boolean expand) { - this.expand = expand; - } - - public void actionPerformed(ActionEvent e) { - if (expand == isSelected()) return; - setSelected(expand); - if (myComponentList != null) { - myComponentList.setVisible(isSelected()); - } - } - } -} diff --git a/java/idea-ui/src/com/intellij/ide/palette/impl/PaletteManager.java b/java/idea-ui/src/com/intellij/ide/palette/impl/PaletteManager.java deleted file mode 100644 index 1ad6a1cd858d..000000000000 --- a/java/idea-ui/src/com/intellij/ide/palette/impl/PaletteManager.java +++ /dev/null @@ -1,229 +0,0 @@ -/* - * Copyright 2000-2014 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.ide.palette.impl; - -import com.intellij.icons.AllIcons; -import com.intellij.ide.IdeBundle; -import com.intellij.ide.palette.PaletteDragEventListener; -import com.intellij.ide.palette.PaletteItem; -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.components.ProjectComponent; -import com.intellij.openapi.fileEditor.FileEditorManager; -import com.intellij.openapi.fileEditor.FileEditorManagerEvent; -import com.intellij.openapi.fileEditor.FileEditorManagerListener; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.startup.StartupManager; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.openapi.wm.ToolWindow; -import com.intellij.openapi.wm.ToolWindowAnchor; -import com.intellij.openapi.wm.ToolWindowManager; -import com.intellij.util.containers.ContainerUtil; -import com.intellij.util.ui.update.MergingUpdateQueue; -import com.intellij.util.ui.update.Update; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; -import java.awt.event.KeyEvent; -import java.awt.event.KeyListener; -import java.util.List; - -/** - * @author yole - */ -public class PaletteManager implements ProjectComponent { - private final Project myProject; - private final FileEditorManager myFileEditorManager; - private PaletteWindow myPaletteWindow; - private ToolWindow myPaletteToolWindow; - private final List<KeyListener> myKeyListeners = ContainerUtil.createLockFreeCopyOnWriteList(); - private final List<PaletteDragEventListener> myDragEventListeners = ContainerUtil.createLockFreeCopyOnWriteList(); - private final List<ListSelectionListener> mySelectionListeners = ContainerUtil.createLockFreeCopyOnWriteList(); - - public PaletteManager(Project project, FileEditorManager fileEditorManager) { - myProject = project; - myFileEditorManager = fileEditorManager; - } - - @Override - public void projectOpened() { - if (!ApplicationManager.getApplication().isHeadlessEnvironment()) { - StartupManager.getInstance(myProject).registerPostStartupActivity(new Runnable() { - @Override - public void run() { - myPaletteWindow = new PaletteWindow(myProject); - myPaletteToolWindow = ToolWindowManager.getInstance(myProject). - registerToolWindow(IdeBundle.message("toolwindow.palette"), - myPaletteWindow, - ToolWindowAnchor.RIGHT, - myProject, - true); - myPaletteToolWindow.setIcon(AllIcons.Toolwindows.ToolWindowPalette); - setContent(); - final MyFileEditorManagerListener myListener = new MyFileEditorManagerListener(); - myFileEditorManager.addFileEditorManagerListener(myListener, myProject); - } - }); - } - } - - @Override - public void projectClosed() { - if (myPaletteWindow != null) { - myPaletteWindow.dispose(); - ToolWindowManager.getInstance(myProject).unregisterToolWindow(IdeBundle.message("toolwindow.palette")); - myPaletteWindow = null; - } - } - - @Override - @NotNull - public String getComponentName() { - return "PaletteManager"; - } - - @Override - public void initComponent() { - } - - @Override - public void disposeComponent() { - if (myPaletteWindow != null) { - myPaletteWindow.dispose(); - } - } - - public static PaletteManager getInstance(final Project project) { - return project.getComponent(PaletteManager.class); - } - - public void clearActiveItem() { - if (myPaletteWindow != null) { - myPaletteWindow.clearActiveItem(); - } - } - - @Nullable - public PaletteItem getActiveItem() { - if (myPaletteWindow != null) { - return myPaletteWindow.getActiveItem(); - } - return null; - } - - @Nullable - public <T extends PaletteItem> T getActiveItem(Class<T> cls) { - PaletteItem item = getActiveItem(); - if (item != null && item.getClass().isInstance(item)) { - //noinspection unchecked - return (T)item; - } - return null; - } - - public void addKeyListener(KeyListener l) { - myKeyListeners.add(l); - } - - public void removeKeyListener(KeyListener l) { - myKeyListeners.remove(l); - } - - public void addDragEventListener(PaletteDragEventListener l) { - myDragEventListeners.add(l); - } - - public void removeDragEventListener(PaletteDragEventListener l) { - myDragEventListeners.remove(l); - } - - public void addSelectionListener(ListSelectionListener l) { - mySelectionListeners.add(l); - } - - public void removeSelectionListener(ListSelectionListener l) { - mySelectionListeners.remove(l); - } - - private final MergingUpdateQueue myQueue = new MergingUpdateQueue("palette", 200, true, null); - - private void processFileEditorChange(@Nullable final VirtualFile selectedFile) { - myQueue.cancelAllUpdates(); - myQueue.queue(new Update("update") { - @Override - public void run() { - if (myPaletteWindow == null) return; - myPaletteWindow.refreshPaletteIfChanged(selectedFile); - setContent(); - } - }); - } - - private void setContent() { - if (myPaletteWindow.getActiveGroupCount() == 0) { - myPaletteToolWindow.setAvailable(false, null); - } - else { - myPaletteToolWindow.setAvailable(true, null); - myPaletteToolWindow.show(null); - } - } - - void notifyKeyEvent(final KeyEvent e) { - for (KeyListener l : myKeyListeners) { - if (e.getID() == KeyEvent.KEY_PRESSED) { - l.keyPressed(e); - } - else if (e.getID() == KeyEvent.KEY_RELEASED) { - l.keyReleased(e); - } - else if (e.getID() == KeyEvent.KEY_TYPED) { - l.keyTyped(e); - } - } - } - - void notifyDropActionChanged(int gestureModifiers) { - for (PaletteDragEventListener l : myDragEventListeners) { - l.dropActionChanged(gestureModifiers); - } - } - - void notifySelectionChanged(final ListSelectionEvent event) { - for (ListSelectionListener l : mySelectionListeners) { - l.valueChanged(event); - } - } - - private class MyFileEditorManagerListener implements FileEditorManagerListener { - @Override - public void fileOpened(@NotNull FileEditorManager source, @NotNull VirtualFile file) { - processFileEditorChange(file); - } - - @Override - public void fileClosed(@NotNull FileEditorManager source, @NotNull VirtualFile file) { - processFileEditorChange(null); - } - - @Override - public void selectionChanged(@NotNull FileEditorManagerEvent event) { - processFileEditorChange(event.getNewFile()); - } - } -} diff --git a/java/idea-ui/src/com/intellij/ide/palette/impl/PaletteWindow.java b/java/idea-ui/src/com/intellij/ide/palette/impl/PaletteWindow.java deleted file mode 100644 index 27f280386731..000000000000 --- a/java/idea-ui/src/com/intellij/ide/palette/impl/PaletteWindow.java +++ /dev/null @@ -1,314 +0,0 @@ -/* - * Copyright 2000-2009 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.ide.palette.impl; - -import com.intellij.ide.palette.PaletteGroup; -import com.intellij.ide.palette.PaletteItem; -import com.intellij.ide.palette.PaletteItemProvider; -import com.intellij.openapi.actionSystem.*; -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.extensions.Extensions; -import com.intellij.openapi.fileEditor.FileEditorManager; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.ui.PopupHandler; -import com.intellij.ui.ScrollPaneFactory; -import com.intellij.ui.components.JBTabbedPane; -import com.intellij.util.ArrayUtil; -import com.intellij.util.containers.HashSet; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.Nullable; - -import javax.swing.*; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; -import java.awt.*; -import java.awt.dnd.DragSource; -import java.awt.dnd.DragSourceAdapter; -import java.awt.dnd.DragSourceDropEvent; -import java.awt.dnd.DragSourceListener; -import java.awt.event.KeyEvent; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.util.*; - -/** - * @author yole - */ -public class PaletteWindow extends JPanel implements DataProvider { - private final Project myProject; - private final ArrayList<PaletteGroupHeader> myGroupHeaders = new ArrayList<PaletteGroupHeader>(); - private final PaletteItemProvider[] myProviders; - private final MyPropertyChangeListener myPropertyChangeListener = new MyPropertyChangeListener(); - private final Set<PaletteGroup> myGroups = new HashSet<PaletteGroup>(); - private final JTabbedPane myTabbedPane = new JBTabbedPane(); - private final JScrollPane myScrollPane = ScrollPaneFactory.createScrollPane(); - private final MyListSelectionListener myListSelectionListener = new MyListSelectionListener(); - private PaletteGroupHeader myLastFocusedGroup; - - @NonNls private static final String ourHelpID = "guiDesigner.uiTour.palette"; - private PaletteManager myPaletteManager; - - private final DragSourceListener myDragSourceListener = new DragSourceAdapter() { - @Override - public void dragDropEnd(DragSourceDropEvent event) { - Component component = event.getDragSourceContext().getComponent(); - if (!event.getDropSuccess() && - component instanceof PaletteComponentList && - getRootPane() == ((JComponent)component).getRootPane()) { - clearActiveItem(); - } - } - }; - - public PaletteWindow(Project project) { - myProject = project; - myPaletteManager = PaletteManager.getInstance(myProject); - myProviders = Extensions.getExtensions(PaletteItemProvider.EP_NAME, project); - for (PaletteItemProvider provider : myProviders) { - provider.addListener(myPropertyChangeListener); - } - - setLayout(new GridLayout(1, 1)); - myScrollPane.addMouseListener(new MyScrollPanePopupHandler()); - myScrollPane.setBorder(null); - KeyStroke escStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0); - new ClearActiveItemAction().registerCustomShortcutSet(new CustomShortcutSet(escStroke), myScrollPane); - refreshPalette(); - - if (!ApplicationManager.getApplication().isHeadlessEnvironment()) { - DragSource.getDefaultDragSource().addDragSourceListener(myDragSourceListener); - } - } - - public void dispose() { - if (!ApplicationManager.getApplication().isHeadlessEnvironment()) { - DragSource.getDefaultDragSource().removeDragSourceListener(myDragSourceListener); - } - } - - public void refreshPalette() { - refreshPalette(null); - } - - public void refreshPalette(@Nullable VirtualFile selectedFile) { - for (PaletteGroupHeader groupHeader : myGroupHeaders) { - groupHeader.getComponentList().removeListSelectionListener(myListSelectionListener); - } - String[] oldTabNames = collectTabNames(myGroups); - myTabbedPane.removeAll(); - myGroupHeaders.clear(); - myGroups.clear(); - - final ArrayList<PaletteGroup> currentGroups = collectCurrentGroups(selectedFile); - String[] tabNames = collectTabNames(currentGroups); - if (tabNames.length == 1) { - if (oldTabNames.length != 1) { - remove(myTabbedPane); - add(myScrollPane); - } - - PaletteContentWindow contentWindow = new PaletteContentWindow(); - myScrollPane.getViewport().setView(contentWindow); - - for (PaletteGroup group : currentGroups) { - addGroupToControl(group, contentWindow); - } - - final JComponent view = (JComponent)myScrollPane.getViewport().getView(); - if (view != null) { - view.revalidate(); - for (Component component : view.getComponents()) { - ((JComponent)component).revalidate(); - } - } - } - else { - if (oldTabNames.length <= 1) { - remove(myScrollPane); - add(myTabbedPane); - } - for (String tabName : tabNames) { - PaletteContentWindow contentWindow = new PaletteContentWindow(); - JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(contentWindow); - scrollPane.addMouseListener(new MyScrollPanePopupHandler()); - myTabbedPane.add(tabName, scrollPane); - for (PaletteGroup group : currentGroups) { - if (group.getTabName().equals(tabName)) { - addGroupToControl(group, contentWindow); - } - } - } - myTabbedPane.revalidate(); - } - } - - private void addGroupToControl(PaletteGroup group, JComponent control) { - PaletteGroupHeader groupHeader = new PaletteGroupHeader(this, group); - myGroupHeaders.add(groupHeader); - myGroups.add(group); - control.add(groupHeader); - PaletteComponentList componentList = new PaletteComponentList(myProject, group); - control.add(componentList); - groupHeader.setComponentList(componentList); - componentList.addListSelectionListener(myListSelectionListener); - } - - private static String[] collectTabNames(final Collection<PaletteGroup> groups) { - Set<String> result = new TreeSet<String>(); - for (PaletteGroup group : groups) { - result.add(group.getTabName()); - } - return ArrayUtil.toStringArray(result); - } - - private ArrayList<PaletteGroup> collectCurrentGroups(@Nullable VirtualFile selectedFile) { - ArrayList<PaletteGroup> result = new ArrayList<PaletteGroup>(); - if (selectedFile == null) { - VirtualFile[] editedFiles = FileEditorManager.getInstance(myProject).getSelectedFiles(); - if (editedFiles.length > 0) { - selectedFile = editedFiles[0]; - } - } - if (selectedFile != null) { - for (PaletteItemProvider provider : myProviders) { - PaletteGroup[] groups = provider.getActiveGroups(selectedFile); - Collections.addAll(result, groups); - } - } - return result; - } - - public void refreshPaletteIfChanged(VirtualFile selectedFile) { - Set<PaletteGroup> currentGroups = new HashSet<PaletteGroup>(collectCurrentGroups(selectedFile)); - if (!currentGroups.equals(myGroups)) { - refreshPalette(selectedFile); - } - } - - public int getActiveGroupCount() { - return myGroups.size(); - } - - public void clearActiveItem() { - if (getActiveItem() == null) return; - for (PaletteGroupHeader group : myGroupHeaders) { - group.getComponentList().clearSelection(); - } - ListSelectionEvent event = new ListSelectionEvent(this, -1, -1, false); - myPaletteManager.notifySelectionChanged(event); - } - - @Nullable - public PaletteItem getActiveItem() { - for (PaletteGroupHeader groupHeader : myGroupHeaders) { - if (groupHeader.isSelected() && groupHeader.getComponentList().getSelectedValue() != null) { - return (PaletteItem)groupHeader.getComponentList().getSelectedValue(); - } - } - return null; - } - - @Nullable - public Object getData(String dataId) { - if (PlatformDataKeys.HELP_ID.is(dataId)) { - return ourHelpID; - } - if (CommonDataKeys.PROJECT.is(dataId)) { - return myProject; - } - PaletteItem item = getActiveItem(); - if (item != null) { - Object data = item.getData(myProject, dataId); - if (data != null) return data; - } - for (PaletteGroupHeader groupHeader : myGroupHeaders) { - if ((groupHeader.isSelected() && groupHeader.getComponentList().getSelectedValue() != null) || groupHeader == myLastFocusedGroup) { - return groupHeader.getGroup().getData(myProject, dataId); - } - } - final int tabCount = collectTabNames(myGroups).length; - if (tabCount > 0) { - JScrollPane activeScrollPane; - if (tabCount == 1) { - activeScrollPane = myScrollPane; - } - else { - activeScrollPane = (JScrollPane)myTabbedPane.getSelectedComponent(); - } - PaletteContentWindow activeContentWindow = (PaletteContentWindow)activeScrollPane.getViewport().getView(); - PaletteGroupHeader groupHeader = activeContentWindow.getLastGroupHeader(); - if (groupHeader != null) { - return groupHeader.getGroup().getData(myProject, dataId); - } - } - return null; - } - - public Project getProject() { - return myProject; - } - - void setLastFocusedGroup(final PaletteGroupHeader focusedGroup) { - myLastFocusedGroup = focusedGroup; - for (PaletteGroupHeader group : myGroupHeaders) { - group.getComponentList().clearSelection(); - } - } - - private class MyListSelectionListener implements ListSelectionListener { - public void valueChanged(ListSelectionEvent e) { - PaletteComponentList sourceList = (PaletteComponentList)e.getSource(); - for (int i = e.getFirstIndex(); i <= e.getLastIndex(); i++) { - if (sourceList.isSelectedIndex(i)) { - // selection is being added - for (PaletteGroupHeader group : myGroupHeaders) { - if (group.getComponentList() != sourceList) { - group.getComponentList().clearSelection(); - } - } - break; - } - } - myPaletteManager.notifySelectionChanged(e); - } - } - - private class MyPropertyChangeListener implements PropertyChangeListener { - public void propertyChange(PropertyChangeEvent evt) { - refreshPalette(); - } - } - - private static class MyScrollPanePopupHandler extends PopupHandler { - public void invokePopup(Component comp, int x, int y) { - JScrollPane scrollPane = (JScrollPane)comp; - PaletteContentWindow contentWindow = (PaletteContentWindow)scrollPane.getViewport().getView(); - if (contentWindow != null) { - PaletteGroupHeader groupHeader = contentWindow.getLastGroupHeader(); - if (groupHeader != null) { - groupHeader.showGroupPopupMenu(comp, x, y); - } - } - } - } - - private class ClearActiveItemAction extends AnAction { - public void actionPerformed(AnActionEvent e) { - clearActiveItem(); - } - } -} diff --git a/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.form b/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.form index 7246f2cfb566..61333a8ed4ec 100644 --- a/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.form +++ b/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.form @@ -79,7 +79,14 @@ </constraints> <properties/> <border type="none"/> - <children/> + <children> + <component id="916d9" class="com.intellij.ui.components.JBLabel" binding="myFrameworksLabel"> + <constraints border-constraint="North"/> + <properties> + <text value="Additional Libraries and &Frameworks:"/> + </properties> + </component> + </children> </grid> </children> </grid> diff --git a/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.java b/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.java index 10e11f74077f..94e551250aed 100644 --- a/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.java +++ b/java/idea-ui/src/com/intellij/ide/projectWizard/ProjectTypeStep.java @@ -54,6 +54,7 @@ import com.intellij.ui.CollectionListModel; import com.intellij.ui.IdeBorderFactory; import com.intellij.ui.ListSpeedSearch; import com.intellij.ui.SingleSelectionModel; +import com.intellij.ui.components.JBLabel; import com.intellij.ui.components.JBList; import com.intellij.ui.popup.list.GroupedItemsListRenderer; import com.intellij.util.Function; @@ -81,10 +82,6 @@ import java.util.List; @SuppressWarnings("unchecked") public class ProjectTypeStep extends ModuleWizardStep implements SettingsStep, Disposable { - private static final String TEMPLATES_CARD = "templates card"; - private static final String FRAMEWORKS_CARD = "frameworks card"; - - private static final String PROJECT_WIZARD_GROUP = "project.wizard.group"; public static final Convertor<FrameworkSupportInModuleProvider,String> PROVIDER_STRING_CONVERTOR = new Convertor<FrameworkSupportInModuleProvider, String>() { @Override @@ -98,23 +95,14 @@ public class ProjectTypeStep extends ModuleWizardStep implements SettingsStep, D return node.getId(); } }; - - private JPanel myPanel; - private JPanel myOptionsPanel; - private JBList myProjectTypeList; - private ProjectTemplateList myTemplatesList; - private JPanel myFrameworksPanelPlaceholder; - private JPanel myHeaderPanel; - + private static final String TEMPLATES_CARD = "templates card"; + private static final String FRAMEWORKS_CARD = "frameworks card"; + private static final String PROJECT_WIZARD_GROUP = "project.wizard.group"; private final WizardContext myContext; private final NewProjectWizard myWizard; private final ModulesProvider myModulesProvider; private final AddSupportForFrameworksPanel myFrameworksPanel; private final ModuleBuilder.ModuleConfigurationUpdater myConfigurationUpdater; - @Nullable - private ModuleWizardStep mySettingsStep; - - @SuppressWarnings("MismatchedQueryAndUpdateOfCollection") private final FactoryMap<ProjectTemplate, ModuleBuilder> myBuilders = new FactoryMap<ProjectTemplate, ModuleBuilder>() { @Nullable @@ -125,6 +113,15 @@ public class ProjectTypeStep extends ModuleWizardStep implements SettingsStep, D }; private final Map<String, ModuleWizardStep> myCustomSteps = new HashMap<String, ModuleWizardStep>(); private final MultiMap<TemplatesGroup,ProjectTemplate> myTemplatesMap; + private JPanel myPanel; + private JPanel myOptionsPanel; + private JBList myProjectTypeList; + private ProjectTemplateList myTemplatesList; + private JPanel myFrameworksPanelPlaceholder; + private JPanel myHeaderPanel; + private JBLabel myFrameworksLabel; + @Nullable + private ModuleWizardStep mySettingsStep; private String myCurrentCard; private TemplatesGroup myLastSelectedGroup; @@ -206,6 +203,8 @@ public class ProjectTypeStep extends ModuleWizardStep implements SettingsStep, D myFrameworksPanel = new AddSupportForFrameworksPanel(Collections.<FrameworkSupportInModuleProvider>emptyList(), model, true, myHeaderPanel); Disposer.register(this, myFrameworksPanel); myFrameworksPanelPlaceholder.add(myFrameworksPanel.getMainPanel()); + myFrameworksLabel.setLabelFor(myFrameworksPanel.getFrameworksTree()); + myFrameworksLabel.setBorder(IdeBorderFactory.createEmptyBorder(3)); myConfigurationUpdater = new ModuleBuilder.ModuleConfigurationUpdater() { @Override @@ -258,6 +257,20 @@ public class ProjectTypeStep extends ModuleWizardStep implements SettingsStep, D myTemplatesList.restoreSelection(); } + private static ModuleType getModuleType(TemplatesGroup group) { + ModuleBuilder moduleBuilder = group.getModuleBuilder(); + return moduleBuilder == null ? null : moduleBuilder.getModuleType(); + } + + private static boolean matchFramework(ProjectCategory projectCategory, FrameworkSupportInModuleProvider framework) { + + FrameworkRole[] roles = framework.getRoles(); + if (roles.length == 0) return true; + + List<FrameworkRole> acceptable = Arrays.asList(projectCategory.getAcceptableFrameworkRoles()); + return ContainerUtil.intersects(Arrays.asList(roles), acceptable); + } + private boolean isFrameworksMode() { return FRAMEWORKS_CARD.equals(myCurrentCard) && getSelectedBuilder().equals(myContext.getProjectBuilder()); } @@ -356,11 +369,6 @@ public class ProjectTypeStep extends ModuleWizardStep implements SettingsStep, D return groups; } - private static ModuleType getModuleType(TemplatesGroup group) { - ModuleBuilder moduleBuilder = group.getModuleBuilder(); - return moduleBuilder == null ? null : moduleBuilder.getModuleType(); - } - // new TemplatesGroup selected public void projectTypeChanged() { TemplatesGroup group = getSelectedGroup(); @@ -438,15 +446,6 @@ public class ProjectTypeStep extends ModuleWizardStep implements SettingsStep, D showCard(TEMPLATES_CARD); } - private static boolean matchFramework(ProjectCategory projectCategory, FrameworkSupportInModuleProvider framework) { - - FrameworkRole[] roles = framework.getRoles(); - if (roles.length == 0) return true; - - List<FrameworkRole> acceptable = Arrays.asList(projectCategory.getAcceptableFrameworkRoles()); - return ContainerUtil.intersects(Arrays.asList(roles), acceptable); - } - private void setTemplatesList(TemplatesGroup group, Collection<ProjectTemplate> templates, boolean preserveSelection) { List<ProjectTemplate> list = new ArrayList<ProjectTemplate>(templates); ModuleBuilder moduleBuilder = group.getModuleBuilder(); diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/JavaResourceRootEditHandler.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/JavaResourceRootEditHandler.java index bf1efc89b0d5..0c7f20eb3313 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/JavaResourceRootEditHandler.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/JavaResourceRootEditHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 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. @@ -16,6 +16,7 @@ package com.intellij.openapi.roots.ui.configuration; import com.intellij.icons.AllIcons; +import com.intellij.ui.JBColor; import org.jetbrains.annotations.NotNull; import org.jetbrains.jps.model.java.JavaResourceRootType; @@ -51,7 +52,7 @@ public class JavaResourceRootEditHandler extends JavaResourceRootEditHandlerBase @NotNull @Override public Color getRootsGroupColor() { - return new Color(0x812DF3); + return new JBColor(new Color(0x812DF3), new Color(127, 96, 144)); } @NotNull diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ModuleEditor.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ModuleEditor.java index 10df2939f6e7..a10265607029 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ModuleEditor.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ModuleEditor.java @@ -206,7 +206,9 @@ public abstract class ModuleEditor implements Place.Navigator, Disposable { myEditors.add(new ModuleConfigurableWrapper(moduleConfigurable)); } for(ModuleConfigurableEP extension : myModule.getExtensions(MODULE_CONFIGURABLES)) { - myEditors.add(new ModuleConfigurableWrapper(extension.createConfigurable())); + if (extension.canCreateConfigurable()) { + myEditors.add(new ModuleConfigurableWrapper(extension.createConfigurable())); + } } } diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectStructureConfigurable.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectStructureConfigurable.java index a5867d66d176..12ab9b4c0de6 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectStructureConfigurable.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ProjectStructureConfigurable.java @@ -197,9 +197,9 @@ public class ProjectStructureConfigurable extends BaseConfigurable implements Se myToolbarComponent = toolbar.getComponent(); if (Registry.is("ide.new.project.settings")) { left.setBackground(UIUtil.getSidePanelColor()); - } else { - left.add(myToolbarComponent, BorderLayout.NORTH); + myToolbarComponent.setBackground(UIUtil.getSidePanelColor()); } + left.add(myToolbarComponent, BorderLayout.NORTH); left.add(mySidePanel, BorderLayout.CENTER); mySplitter.setFirstComponent(left); diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/DefaultLibraryRootsComponentDescriptor.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/DefaultLibraryRootsComponentDescriptor.java index eb87df2a47e7..5b3e9302a14b 100644 --- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/DefaultLibraryRootsComponentDescriptor.java +++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/libraryEditor/DefaultLibraryRootsComponentDescriptor.java @@ -17,6 +17,7 @@ package com.intellij.openapi.roots.ui.configuration.libraryEditor; import com.intellij.codeInsight.ExternalAnnotationsManager; import com.intellij.openapi.fileChooser.FileChooserDescriptor; +import com.intellij.openapi.fileChooser.FileElement; import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.module.Module; import com.intellij.openapi.progress.ProgressIndicator; @@ -29,7 +30,9 @@ import com.intellij.openapi.roots.OrderRootType; import com.intellij.openapi.roots.libraries.ui.*; import com.intellij.openapi.roots.ui.OrderRootTypeUIFactory; import com.intellij.openapi.roots.ui.configuration.PathUIUtils; +import com.intellij.openapi.util.Condition; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VfsUtilCore; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.VirtualFileVisitor; @@ -45,6 +48,14 @@ import java.util.*; * @author nik */ public class DefaultLibraryRootsComponentDescriptor extends LibraryRootsComponentDescriptor { + private static final Set<String> NATIVE_LIBRARY_EXTENSIONS = ContainerUtil.newTroveSet(FileUtil.PATH_HASHING_STRATEGY, "dll", "so", "dylib"); + public static final Condition<VirtualFile> LIBRARY_ROOT_CONDITION = new Condition<VirtualFile>() { + @Override + public boolean value(VirtualFile file) { + return FileElement.isArchive(file) || isNativeLibrary(file); + } + }; + @Override public OrderRootTypePresentation getRootTypePresentation(@NotNull OrderRootType type) { return getDefaultPresentation(type); @@ -67,10 +78,17 @@ public class DefaultLibraryRootsComponentDescriptor extends LibraryRootsComponen new AnnotationsRootFilter(), new NativeLibraryRootFilter()); } + private static boolean isNativeLibrary(VirtualFile file) { + String extension = file.getExtension(); + return extension != null && NATIVE_LIBRARY_EXTENSIONS.contains(extension); + } + @NotNull @Override public FileChooserDescriptor createAttachFilesChooserDescriptor(@Nullable String libraryName) { - FileChooserDescriptor descriptor = super.createAttachFilesChooserDescriptor(libraryName); + final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, true, true, false, true, true).withFileFilter(LIBRARY_ROOT_CONDITION); + descriptor.setTitle(StringUtil.isEmpty(libraryName) ? ProjectBundle.message("library.attach.files.action") + : ProjectBundle.message("library.attach.files.to.library.action", libraryName)); descriptor.setDescription(ProjectBundle.message("library.java.attach.files.description")); return descriptor; } @@ -119,24 +137,25 @@ public class DefaultLibraryRootsComponentDescriptor extends LibraryRootsComponen } } - private static class NativeLibraryRootFilter extends RootFilter { - private static final Set<String> NATIVE_LIBRARY_EXTENSIONS = ContainerUtil.newTroveSet(FileUtil.PATH_HASHING_STRATEGY, "dll", "so", "dylib"); - + private static class NativeLibraryRootFilter extends RootDetector { private NativeLibraryRootFilter() { - super(NativeLibraryOrderRootType.getInstance(), false, "external annotations"); + super(NativeLibraryOrderRootType.getInstance(), false, "native library location"); } + @NotNull @Override - public boolean isAccepted(@NotNull VirtualFile rootCandidate, @NotNull ProgressIndicator progressIndicator) { + public Collection<VirtualFile> detectRoots(@NotNull VirtualFile rootCandidate, @NotNull ProgressIndicator progressIndicator) { if (rootCandidate.isDirectory()) { for (VirtualFile file : rootCandidate.getChildren()) { - String extension = file.getExtension(); - if (extension != null && NATIVE_LIBRARY_EXTENSIONS.contains(extension)) { - return true; + if (isNativeLibrary(file)) { + return Collections.singleton(rootCandidate); } } } - return false; + else if (isNativeLibrary(rootCandidate)) { + return Collections.singleton(rootCandidate.getParent()); + } + return Collections.emptyList(); } } |