#36512: adapting to new winsys: various adjustments, cleanup, etc. BLD200311181900
authortpavek@netbeans.org
Tue, 18 Nov 2003 10:09:31 +0000
changeset 3684e00865b9a4f4
parent 3683 9d08160ff228
child 3685 29cfe102f766
#36512: adapting to new winsys: various adjustments, cleanup, etc.
vcs.profiles.cvsprofiles/src/org/netbeans/modules/vcs/profiles/cvsprofiles/visualizers/Bundle.properties
vcs.profiles.cvsprofiles/src/org/netbeans/modules/vcs/profiles/cvsprofiles/visualizers/OutputVisualizer.java
vcs.profiles.cvsprofiles/src/org/netbeans/modules/vcs/profiles/cvsprofiles/visualizers/annotate/CvsAnnotateVisualizer.java
vcscore/src/org/netbeans/modules/vcscore/commands/Bundle.properties
vcscore/src/org/netbeans/modules/vcscore/commands/CommandOutputVisualizer.java
vcscore/src/org/netbeans/modules/vcscore/grouping/VcsGroupMenuAction.java
vcscore/src/org/netbeans/modules/vcscore/versioning/impl/VersioningExplorer.java
     1.1 --- a/vcs.profiles.cvsprofiles/src/org/netbeans/modules/vcs/profiles/cvsprofiles/visualizers/Bundle.properties	Mon Nov 17 18:36:43 2003 +0000
     1.2 +++ b/vcs.profiles.cvsprofiles/src/org/netbeans/modules/vcs/profiles/cvsprofiles/visualizers/Bundle.properties	Tue Nov 18 10:09:31 2003 +0000
     1.3 @@ -83,4 +83,10 @@
     1.4  
     1.5  CommandOutputVisualizer.name={0}
     1.6  
     1.7 -CommandOutputVisualizer.modeName=Output of VCS Commands
     1.8 +# {0} = file name
     1.9 +# {1} = command name
    1.10 +CommandOutputVisualizer.title_one={0} [CVS {1}]
    1.11 +
    1.12 +# {0} = number of files
    1.13 +# {1} = command name
    1.14 +CommandOutputVisualizer.title_many={0} Objects [CVS {1}]
     2.1 --- a/vcs.profiles.cvsprofiles/src/org/netbeans/modules/vcs/profiles/cvsprofiles/visualizers/OutputVisualizer.java	Mon Nov 17 18:36:43 2003 +0000
     2.2 +++ b/vcs.profiles.cvsprofiles/src/org/netbeans/modules/vcs/profiles/cvsprofiles/visualizers/OutputVisualizer.java	Tue Nov 18 10:09:31 2003 +0000
     2.3 @@ -24,7 +24,6 @@
     2.4  import javax.swing.SwingUtilities;
     2.5  
     2.6  import org.openide.windows.Workspace;
     2.7 -import org.openide.windows.Mode;
     2.8  import org.openide.NotifyDescriptor;
     2.9  import org.openide.util.RequestProcessor;
    2.10  import org.openide.util.NbBundle;
    2.11 @@ -41,7 +40,6 @@
    2.12  import org.netbeans.spi.vcs.VcsCommandsProvider;
    2.13  import org.openide.DialogDisplayer;
    2.14  import org.openide.awt.Actions;
    2.15 -import org.openide.windows.WindowManager;
    2.16  
    2.17  /**
    2.18   * The default visualizer of command output.
    2.19 @@ -49,8 +47,6 @@
    2.20   */
    2.21  public abstract class OutputVisualizer extends VcsCommandVisualizer {
    2.22      
    2.23 -    public static final String MODE_NAME = "GUI VCS Command Output";
    2.24 -     
    2.25      //private static RequestProcessor outputDisplayRequestProcessor;        
    2.26      private JComponent outputPanel;
    2.27      private ArrayList closeListeners = new ArrayList();
    2.28 @@ -69,7 +65,6 @@
    2.29      public OutputVisualizer() {
    2.30          setIcon(org.openide.util.Utilities.loadImage("org/netbeans/modules/vcscore/commands/commandOutputWindow.gif"));
    2.31          putClientProperty("PersistenceType", "Never");
    2.32 -        putClientProperty("TabPolicy", "HideWhenAlone");
    2.33          initAccessibility();
    2.34      }
    2.35      
    2.36 @@ -100,9 +95,22 @@
    2.37          Hashtable vars = vce.getVariables();        
    2.38          this.rootDir = new File((String)vars.get("ROOTDIR"));
    2.39          //actFilePath = ""+vars.get("WORKDIR")+vars.get("FILE");
    2.40 -        //actFilePath = Variables.expand(vars, actFilePath, false);                                
    2.41 -        setName(java.text.MessageFormat.format(NbBundle.getBundle(OutputVisualizer.class).getString("CommandOutputVisualizer.name"),
    2.42 -        new Object[] { findDisplayName(this.task) }));
    2.43 +        //actFilePath = Variables.expand(vars, actFilePath, false);
    2.44 +        String commandName = findDisplayName(this.task);
    2.45 +        String title;
    2.46 +        if (files.size() == 1) {
    2.47 +            String filePath = (String) files.iterator().next();
    2.48 +            File file = new File(filePath);
    2.49 +            title = java.text.MessageFormat.format(
    2.50 +                NbBundle.getBundle(OutputVisualizer.class).getString("CommandOutputVisualizer.title_one"), // NOI18N
    2.51 +                new Object[] { file.getName(), commandName });
    2.52 +        }
    2.53 +        else title = java.text.MessageFormat.format(
    2.54 +            NbBundle.getBundle(OutputVisualizer.class).getString("CommandOutputVisualizer.title_many"), // NOI18N
    2.55 +            new Object[] { Integer.toString(files.size()), commandName });
    2.56 +
    2.57 +        setName(commandName);
    2.58 +        setDisplayName(title);
    2.59      }
    2.60      
    2.61      /**
    2.62 @@ -136,17 +144,10 @@
    2.63       * Open the component on the given workspace.
    2.64       */
    2.65      public void open(Workspace workspace) {
    2.66 -        if(exit != 0)
    2.67 +        if (exit != 0)
    2.68              return;
    2.69 -        if (workspace == null) workspace = WindowManager.getDefault().getCurrentWorkspace();
    2.70 -        if(outputPanel == null)
    2.71 +        if (outputPanel == null)
    2.72              this.initComponents();
    2.73 -        Mode myMode = workspace.findMode(this);        
    2.74 -        if (myMode == null) {            
    2.75 -            String modeName = org.openide.util.NbBundle.getBundle(OutputVisualizer.class).getString("CommandOutputVisualizer.modeName");
    2.76 -            myMode = workspace.createMode(MODE_NAME, modeName, null); //NOI18N
    2.77 -            myMode.dockInto(this);
    2.78 -        }        
    2.79          super.open(workspace);
    2.80          requestFocus();
    2.81      }
     3.1 --- a/vcs.profiles.cvsprofiles/src/org/netbeans/modules/vcs/profiles/cvsprofiles/visualizers/annotate/CvsAnnotateVisualizer.java	Mon Nov 17 18:36:43 2003 +0000
     3.2 +++ b/vcs.profiles.cvsprofiles/src/org/netbeans/modules/vcs/profiles/cvsprofiles/visualizers/annotate/CvsAnnotateVisualizer.java	Tue Nov 18 10:09:31 2003 +0000
     3.3 @@ -53,7 +53,6 @@
     3.4      private String filePath;
     3.5      private ArrayList resultList;
     3.6      private HashMap file_infoMap;
     3.7 -    private JTabbedPane contentPane = null;
     3.8      
     3.9      /** Creates new CvsAnnotateVisualizer */
    3.10      public CvsAnnotateVisualizer() {
    3.11 @@ -61,21 +60,26 @@
    3.12          annotationLines = new ArrayList();
    3.13          resultList = new ArrayList();
    3.14      }
    3.15 -    
    3.16 +
    3.17      public javax.swing.JComponent getOutputPanel() {
    3.18          debug("getOutputPanel");
    3.19 -        contentPane = new JTabbedPane();
    3.20 -        contentPane.setTabPlacement(JTabbedPane.BOTTOM);
    3.21 +        JTabbedPane contentPane = null;
    3.22 +        if (files.size() != 1) {
    3.23 +            contentPane = new JTabbedPane();
    3.24 +            contentPane.setTabPlacement(JTabbedPane.BOTTOM);
    3.25 +        }
    3.26          Iterator it = files.iterator();
    3.27 -        while(it.hasNext()){            
    3.28 +        while(it.hasNext()) {            
    3.29              String fileName = (String)it.next();
    3.30 -            filePath=rootDir+File.separator+fileName;
    3.31 +            filePath = rootDir+File.separator+fileName;
    3.32              debug("filePath:"+filePath);
    3.33              File file = new File(filePath);
    3.34 -            contentPane.addTab(file.getName(),showAnnotations(file));
    3.35 +            if (contentPane != null)
    3.36 +                contentPane.addTab(file.getName(), showAnnotations(file));
    3.37 +            else
    3.38 +                return showAnnotations(file);
    3.39          }
    3.40          return contentPane;
    3.41 -        
    3.42      }
    3.43      
    3.44      private javax.swing.JComponent showAnnotations(File file) {
     4.1 --- a/vcscore/src/org/netbeans/modules/vcscore/commands/Bundle.properties	Mon Nov 17 18:36:43 2003 +0000
     4.2 +++ b/vcscore/src/org/netbeans/modules/vcscore/commands/Bundle.properties	Tue Nov 18 10:09:31 2003 +0000
     4.3 @@ -40,6 +40,12 @@
     4.4  
     4.5  # {0} is the name of the command
     4.6  CommandOutputVisualizer.name={0}
     4.7 +# {0} = file name
     4.8 +# {1} = command name
     4.9 +CommandOutputVisualizer.title_one={0} [VCS {1}]
    4.10 +# {0} = number of files
    4.11 +# {1} = command name
    4.12 +CommandOutputVisualizer.title_many={0} Objects [VCS {1}]
    4.13  CommandOutputVisualizer.modeName=Output of VCS Commands
    4.14  CommandOutputPanel.execStringLabel.text=Execution String:
    4.15  CommandOutputPanel.execStringLabel.mnemonic=E
     5.1 --- a/vcscore/src/org/netbeans/modules/vcscore/commands/CommandOutputVisualizer.java	Mon Nov 17 18:36:43 2003 +0000
     5.2 +++ b/vcscore/src/org/netbeans/modules/vcscore/commands/CommandOutputVisualizer.java	Tue Nov 18 10:09:31 2003 +0000
     5.3 @@ -19,7 +19,6 @@
     5.4  import javax.swing.SwingUtilities;
     5.5  
     5.6  import org.openide.windows.Workspace;
     5.7 -import org.openide.windows.Mode;
     5.8  import org.openide.NotifyDescriptor;
     5.9  import org.openide.util.RequestProcessor;
    5.10  import org.openide.util.NbBundle;
    5.11 @@ -37,8 +36,6 @@
    5.12   */
    5.13  public class CommandOutputVisualizer extends VcsCommandVisualizer {
    5.14  
    5.15 -    public static final String MODE_NAME = "Default VCS Command Output";
    5.16 -    
    5.17      //private static final int MAX_NUM_LINES_TO_KEEP = 1000;
    5.18      /** Maximum number of characters to keep in the buffer */
    5.19      private static final int MAX_BUFFER_SIZE = 3000*80;
    5.20 @@ -65,11 +62,6 @@
    5.21          setIcon(org.openide.util.Utilities.loadImage("org/netbeans/modules/vcscore/commands/commandOutputWindow.gif"));
    5.22          putClientProperty("PersistenceType", "Never");
    5.23  
    5.24 -        // http://www.netbeans.org/issues/show_bug.cgi?id=24199
    5.25 -        // the TabPolicy property's value makes sure that the tab is not shown 
    5.26 -        // for the topcomponent when it is alone in the mode.
    5.27 -        putClientProperty("TabPolicy", "HideWhenAlone");
    5.28 -        
    5.29          initComponents();
    5.30          synchronized (CommandOutputVisualizer.class) {
    5.31              if (outputDisplayRequestProcessor == null) {
    5.32 @@ -111,10 +103,29 @@
    5.33          killListener = new CommandKillListener();
    5.34          outputPanel.addKillActionListener(killListener);
    5.35          outputPanel.setExec(vce.getExec());
    5.36 -        String name = vce.getCommand().getDisplayName();
    5.37 -        if (name == null || name.length() == 0) name = vce.getCommand().getName();
    5.38 -        setName(java.text.MessageFormat.format(NbBundle.getBundle(CommandOutputVisualizer.class).getString("CommandOutputVisualizer.name"),
    5.39 -                new Object[] { name }));
    5.40 +        String title;
    5.41 +        String commandName = vce.getCommand().getDisplayName();
    5.42 +        if (commandName == null || commandName.length() == 0)
    5.43 +            commandName = vce.getCommand().getName();
    5.44 +        setName(commandName);
    5.45 +        java.util.Collection files = vce.getFiles();
    5.46 +        if (files.size() == 1) {
    5.47 +            String filePath = (String) files.iterator().next();
    5.48 +            java.io.File file = new java.io.File(filePath);
    5.49 +            title = java.text.MessageFormat.format(
    5.50 +                NbBundle.getBundle(CommandOutputVisualizer.class).getString("CommandOutputVisualizer.title_one"), // NOI18N
    5.51 +                new Object[] { file.getName(), commandName });
    5.52 +        }
    5.53 +        else if (files.size() > 1) {
    5.54 +            title = java.text.MessageFormat.format(
    5.55 +                NbBundle.getBundle(CommandOutputVisualizer.class).getString("CommandOutputVisualizer.title_many"), // NOI18N
    5.56 +                new Object[] { Integer.toString(files.size()), commandName }); 
    5.57 +        }
    5.58 +        else title = java.text.MessageFormat.format(
    5.59 +            NbBundle.getBundle(CommandOutputVisualizer.class).getString("CommandOutputVisualizer.name"), // NOI18N
    5.60 +            new Object[] { commandName });
    5.61 +
    5.62 +        setDisplayName(title);
    5.63      }
    5.64      
    5.65      /*
    5.66 @@ -128,19 +139,11 @@
    5.67      public boolean openAfterCommandFinish() {
    5.68          return false;
    5.69      }
    5.70 -    
    5.71 +
    5.72      /**
    5.73       * Open the component on the given workspace.
    5.74       */
    5.75      public void open(Workspace workspace) {
    5.76 -        if (workspace == null) workspace = WindowManager.getDefault().getCurrentWorkspace();
    5.77 -        Mode myMode = workspace.findMode(this);
    5.78 -        if (myMode == null) {
    5.79 -            // create new mode for CI and set the bounds properly
    5.80 -            String modeName = org.openide.util.NbBundle.getBundle(CommandOutputVisualizer.class).getString("CommandOutputVisualizer.modeName");
    5.81 -            myMode = workspace.createMode(MODE_NAME, modeName, null); //NOI18N
    5.82 -            myMode.dockInto(this);
    5.83 -        }
    5.84          super.open(workspace);
    5.85          requestFocus();
    5.86      }
     6.1 --- a/vcscore/src/org/netbeans/modules/vcscore/grouping/VcsGroupMenuAction.java	Mon Nov 17 18:36:43 2003 +0000
     6.2 +++ b/vcscore/src/org/netbeans/modules/vcscore/grouping/VcsGroupMenuAction.java	Tue Nov 18 10:09:31 2003 +0000
     6.3 @@ -46,8 +46,7 @@
     6.4  * @author Milos Kleint
     6.5  */
     6.6  public class VcsGroupMenuAction extends CallableSystemAction  {
     6.7 -    private transient String MODE_NAME = "VcsGroupsMode";//NOI18N
     6.8 -        
     6.9 +
    6.10      private static final long serialVersionUID = 38657723580032415L;
    6.11      
    6.12      /** Creates new CvsMenuAction */
    6.13 @@ -122,31 +121,15 @@
    6.14          
    6.15          if (panel == null) {
    6.16              panel = new GroupExplorerPanel();
    6.17 -//            Workspace workspace = WindowManager.getDefault().getCurrentWorkspace();
    6.18 -//            String modeName = org.openide.util.NbBundle.getMessage(VcsGroupMenuAction.class, "LBL_MODE.title");//NOI18N
    6.19 -//            Mode myMode = workspace.findMode(MODE_NAME);
    6.20 -//            
    6.21 -//            if (myMode == null) {
    6.22 -//                // create new mode for CI and set the bounds properly
    6.23 -//                myMode = workspace.createMode(MODE_NAME, modeName, null); //NOI18N
    6.24 -//                /*
    6.25 -//                Rectangle workingSpace = workspace.getBounds();
    6.26 -//                myMode.setBounds(new Rectangle(workingSpace.x +(workingSpace.width * 3 / 10), workingSpace.y,
    6.27 -//                                               workingSpace.width * 2 / 10, workingSpace.height / 2));
    6.28 -//                 */
    6.29 -//            }
    6.30 -//            myMode.dockInto(panel);
    6.31 -            Mode myMode = WindowManager.getDefault().findMode("explorer"); // NOI18N
    6.32 -            if(myMode != null) {
    6.33 -                myMode.dockInto(panel);
    6.34 -            }
    6.35 +            Mode mode = WindowManager.getDefault().findMode("explorer"); // NOI18N
    6.36 +            if(mode != null)
    6.37 +                mode.dockInto(panel);
    6.38          }
    6.39          panel.getAccessibleContext().setAccessibleDescription(
    6.40              org.openide.util.NbBundle.getMessage(VcsGroupMenuAction.class, "ACSD_AddVcsGroupAction.dialog"));
    6.41          panel.setIcon(org.openide.util.Utilities.loadImage("org/netbeans/modules/vcscore/grouping/MainVcsGroupNodeIcon.gif"));
    6.42 -        panel.open(WindowManager.getDefault().getCurrentWorkspace());
    6.43 +        panel.open();
    6.44          panel.requestFocus();
    6.45 -        
    6.46      }
    6.47      
    6.48  
    6.49 @@ -154,14 +137,6 @@
    6.50          
    6.51          private static final long serialVersionUID = 7160066451512137154L;
    6.52          
    6.53 -        public GroupExplorerPanel() {
    6.54 -            super();
    6.55 -            // http://www.netbeans.org/issues/show_bug.cgi?id=24199
    6.56 -            // the TabPolicy property's value makes sure that the tab is not shown 
    6.57 -            // for the topcomponent when it is alone in the mode.
    6.58 -            putClientProperty("TabPolicy", "HideWhenAlone");        
    6.59 -        }
    6.60 -        
    6.61          public void open() {
    6.62              if (!isOpened()) {
    6.63                  Node root = null;
     7.1 --- a/vcscore/src/org/netbeans/modules/vcscore/versioning/impl/VersioningExplorer.java	Mon Nov 17 18:36:43 2003 +0000
     7.2 +++ b/vcscore/src/org/netbeans/modules/vcscore/versioning/impl/VersioningExplorer.java	Tue Nov 18 10:09:31 2003 +0000
     7.3 @@ -35,13 +35,10 @@
     7.4   */
     7.5  public class VersioningExplorer {
     7.6  
     7.7 -    private static final String MODE_NAME = "VersioningExplorer";
     7.8 -    
     7.9      /**
    7.10 -     * Map of workspaces as keys and map of explorer panels, that belongs to
    7.11 -     * these workspaces for individual nodes as values.
    7.12 +     * Map of explorer panels for individual nodes.
    7.13       */
    7.14 -    private static Map explorersInWorkspaces = new WeakHashMap();
    7.15 +    private static Map explorersForNodes = new WeakHashMap();
    7.16  
    7.17      private Panel panel;
    7.18      private Node root = null;
    7.19 @@ -65,23 +62,17 @@
    7.20       * Get the Revision Explorer for that node.
    7.21       */
    7.22      private static VersioningExplorer.Panel getRevisionExplorer(final Node node) {
    7.23 -        Workspace curr = WindowManager.getDefault().getCurrentWorkspace();
    7.24 -        synchronized (explorersInWorkspaces) {
    7.25 -            Map explorersForNodes = (Map) explorersInWorkspaces.get(curr);
    7.26 +        synchronized (explorersForNodes) {
    7.27              VersioningExplorer explorer;
    7.28 -            if (explorersForNodes != null) {
    7.29 -                explorer = (VersioningExplorer) explorersForNodes.get(node);
    7.30 -                if (explorer != null) return explorer.panel;
    7.31 -            } else {
    7.32 -                explorersForNodes = new WeakHashMap();
    7.33 -                explorersInWorkspaces.put(curr, explorersForNodes);
    7.34 +            explorer = (VersioningExplorer) explorersForNodes.get(node);
    7.35 +            if (explorer == null) {
    7.36 +                explorer = new VersioningExplorer(node);
    7.37 +                explorersForNodes.put(node, explorer);
    7.38              }
    7.39 -            explorer = new VersioningExplorer(node);
    7.40 -            explorersForNodes.put(node, explorer);
    7.41              return explorer.panel;
    7.42          }
    7.43      }
    7.44 -    
    7.45 +
    7.46      private void initComponentsSplitted() {
    7.47          PropertySheetView propertySheetView = new PropertySheetView();
    7.48          try {
    7.49 @@ -115,32 +106,17 @@
    7.50          private transient ArrayList closeListeners = new ArrayList();
    7.51      
    7.52          static final long serialVersionUID =-264310566346550916L;
    7.53 -        Panel() {
    7.54 -            // http://www.netbeans.org/issues/show_bug.cgi?id=24199
    7.55 -            // the TabPolicy property's value makes sure that the tab is not shown 
    7.56 -            // for the topcomponent when it is alone in the mode.
    7.57 -            putClientProperty("TabPolicy", "HideWhenAlone");            
    7.58 -        }
    7.59  
    7.60          public void open(Workspace workspace) {
    7.61 -            Mode myMode = workspace.findMode(this);
    7.62 -            if (myMode == null) {
    7.63 -                // create new mode for CI and set the bounds properly
    7.64 -//                myMode = workspace.createMode(MODE_NAME, getName(), null); //NOI18N // TEMP
    7.65 -                /*
    7.66 -                Rectangle workingSpace = workspace.getBounds();
    7.67 -                myMode.setBounds(new Rectangle(workingSpace.x +(workingSpace.width * 3 / 10), workingSpace.y,
    7.68 -                                               workingSpace.width * 2 / 10, workingSpace.height / 2));
    7.69 -                 */
    7.70 -                
    7.71 -                myMode = WindowManager.getDefault().findMode("explorer"); // NOI18N
    7.72 -                if(myMode != null) {
    7.73 -                    myMode.dockInto(this);
    7.74 -                }
    7.75 +            Mode mode = WindowManager.getDefault().findMode(this);
    7.76 +            if (mode == null) {
    7.77 +                mode = WindowManager.getDefault().findMode("explorer"); // NOI18N
    7.78 +                if (mode != null)
    7.79 +                    mode.dockInto(this);
    7.80              }
    7.81              super.open(workspace);
    7.82          }
    7.83 -        
    7.84 +
    7.85          /*
    7.86           * Override for clean up reasons.
    7.87           * Will be moved to the appropriate method when will be made.