This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 202853
Collapse All | Expand All

(-)a/cnd.remote/src/org/netbeans/modules/remote/ui/OpenTerminalAction.java (-24 / +36 lines)
Lines 43-51 Link Here
43
package org.netbeans.modules.remote.ui;
43
package org.netbeans.modules.remote.ui;
44
44
45
import java.awt.Frame;
45
import java.awt.Frame;
46
import java.io.File;
46
import java.io.IOException;
47
import java.io.IOException;
47
import java.util.HashMap;
48
import java.util.Map;
49
import javax.swing.JFileChooser;
48
import javax.swing.JFileChooser;
50
import javax.swing.JMenu;
49
import javax.swing.JMenu;
51
import javax.swing.JMenuItem;
50
import javax.swing.JMenuItem;
Lines 66-71 Link Here
66
import org.openide.awt.ActionRegistration;
65
import org.openide.awt.ActionRegistration;
67
import org.openide.awt.StatusDisplayer;
66
import org.openide.awt.StatusDisplayer;
68
import org.openide.filesystems.FileObject;
67
import org.openide.filesystems.FileObject;
68
import org.openide.filesystems.FileUtil;
69
import org.openide.nodes.Node;
69
import org.openide.nodes.Node;
70
import org.openide.util.Exceptions;
70
import org.openide.util.Exceptions;
71
import org.openide.util.NbBundle;
71
import org.openide.util.NbBundle;
Lines 82-88 Link Here
82
@ActionReference(path = "Remote/Host/Actions", name = "OpenTerminalAction", position = 700)
82
@ActionReference(path = "Remote/Host/Actions", name = "OpenTerminalAction", position = 700)
83
public class OpenTerminalAction extends SingleHostAction {
83
public class OpenTerminalAction extends SingleHostAction {
84
    private JMenu remotePopupMenu;
84
    private JMenu remotePopupMenu;
85
    private JMenu localPopupMenu;
85
    private JMenuItem localPopupMenu;
86
86
87
    @Override
87
    @Override
88
    public String getName() {
88
    public String getName() {
Lines 91-96 Link Here
91
91
92
    @Override
92
    @Override
93
    protected void performAction(final ExecutionEnvironment env, Node node) {
93
    protected void performAction(final ExecutionEnvironment env, Node node) {
94
        Node[] activatedNodes = getActivatedNodes();
95
        if (activatedNodes != null && activatedNodes.length == 1 && !isRemote(activatedNodes[0])) {
96
            SystemAction.get(AddHome.class).performAction(env, node);
97
        }        
94
    }
98
    }
95
99
96
    @Override
100
    @Override
Lines 113-129 Link Here
113
        if (remotePopupMenu == null) {
117
        if (remotePopupMenu == null) {
114
            remotePopupMenu = new JMenu(getName());
118
            remotePopupMenu = new JMenu(getName());
115
            remotePopupMenu.add(SystemAction.get(AddHome.class).getPopupPresenter());
119
            remotePopupMenu.add(SystemAction.get(AddHome.class).getPopupPresenter());
116
//            popupMenu.add(new AddProjects().getPopupPresenter());
117
            remotePopupMenu.add(SystemAction.get(AddMirror.class).getPopupPresenter());
120
            remotePopupMenu.add(SystemAction.get(AddMirror.class).getPopupPresenter());
118
            remotePopupMenu.add(SystemAction.get(AddRoot.class).getPopupPresenter());
121
//            remotePopupMenu.add(SystemAction.get(AddRoot.class).getPopupPresenter());
119
            remotePopupMenu.add(SystemAction.get(AddOther.class).getPopupPresenter());
122
//            remotePopupMenu.add(SystemAction.get(AddOther.class).getPopupPresenter());
120
        }
123
        }
121
        if (localPopupMenu == null) {
124
        if (localPopupMenu == null) {
122
            localPopupMenu = new JMenu(getName());
125
            localPopupMenu = super.getPopupPresenter();
123
            localPopupMenu.add(SystemAction.get(AddHome.class).getPopupPresenter());
124
//            popupMenu.add(new AddProjects().getPopupPresenter());
125
            localPopupMenu.add(SystemAction.get(AddRoot.class).getPopupPresenter());
126
            localPopupMenu.add(SystemAction.get(AddOther.class).getPopupPresenter());
127
        }
126
        }
128
    }
127
    }
129
128
Lines 172-185 Link Here
172
                    }
171
                    }
173
                    final String path = getPath(env);
172
                    final String path = getPath(env);
174
                    if (path != null && path.length() > 0) {
173
                    if (path != null && path.length() > 0) {
175
                        Runnable openFavorites = new Runnable() {
174
                        Runnable openTask = new Runnable() {
176
175
177
                            @Override
176
                            @Override
178
                            public void run() {
177
                            public void run() {
179
                                TerminalSupport.openTerminal(env.getDisplayName(), env, path);
178
                                TerminalSupport.openTerminal(env.getDisplayName(), env, path);
180
                            }
179
                            }
181
                        };
180
                        };
182
                        SwingUtilities.invokeLater(openFavorites);
181
                        SwingUtilities.invokeLater(openTask);
183
                    } else {
182
                    } else {
184
                        if (path != null) {
183
                        if (path != null) {
185
                            String msg;
184
                            String msg;
Lines 231-237 Link Here
231
        try {
230
        try {
232
            HostInfo hostInfo = HostInfoUtils.getHostInfo(env);
231
            HostInfo hostInfo = HostInfoUtils.getHostInfo(env);
233
            if (hostInfo != null) {
232
            if (hostInfo != null) {
234
                String userDir = hostInfo.getUserDir();
233
                String userDir;
234
                if (env.isLocal()) {
235
                    userDir = hostInfo.getUserDirFile().getAbsolutePath();
236
                } else {
237
                    userDir = hostInfo.getUserDir();
238
                }
235
                return userDir;
239
                return userDir;
236
            }
240
            }
237
        } catch (IOException ex) {
241
        } catch (IOException ex) {
Lines 267-273 Link Here
267
        }
271
        }
268
    }
272
    }
269
    
273
    
270
    private static Map<ExecutionEnvironment, String> lastUsedDirs = new HashMap<ExecutionEnvironment, String>();
271
    private static final class AddOther extends AddPlace {
274
    private static final class AddOther extends AddPlace {
272
        private final Frame mainWindow;
275
        private final Frame mainWindow;
273
        
276
        
Lines 286-309 Link Here
286
    }
289
    }
287
290
288
    /**/ static FileObject getRemoteFileObject(ExecutionEnvironment env, String title, String btn, Frame mainWindow) {
291
    /**/ static FileObject getRemoteFileObject(ExecutionEnvironment env, String title, String btn, Frame mainWindow) {
289
        String homeDir = lastUsedDirs.get(env);
292
        String curDir = RemoteFileUtil.getCurrentChooserFile(env);
290
        if (homeDir == null) {
293
        if (curDir == null) {
291
            homeDir = getHomeDir(env);
294
            curDir = getHomeDir(env);
292
        }
295
        }
293
        JFileChooserEx fileChooser = (JFileChooserEx) RemoteFileUtil.createFileChooser(
296
        JFileChooser fileChooser =  RemoteFileUtil.createFileChooser(
294
                env,
297
                env,
295
                title,
298
                title,
296
                btn,
299
                btn,
297
                JFileChooser.DIRECTORIES_ONLY, null, homeDir, true);
300
                JFileChooser.DIRECTORIES_ONLY, null, curDir, true);
298
        int ret = fileChooser.showOpenDialog(mainWindow);
301
        int ret = fileChooser.showOpenDialog(mainWindow);
299
        if (ret == JFileChooser.CANCEL_OPTION) {
302
        if (ret == JFileChooser.CANCEL_OPTION) {
300
            return null;
303
            return null;
301
        }
304
        }
302
        FileObject remoteProjectFO = fileChooser.getSelectedFileObject();
305
        FileObject fo = null;
303
        lastUsedDirs.put(env, remoteProjectFO.getParent().getPath());
306
        if (fileChooser instanceof JFileChooserEx) {
304
        if (remoteProjectFO == null || !remoteProjectFO.isFolder()) {
307
            fo = ((JFileChooserEx)fileChooser).getSelectedFileObject();
308
        } else {
309
            File selectedFile = fileChooser.getSelectedFile();
310
            if (selectedFile != null) {
311
                fo = FileUtil.toFileObject(selectedFile);
312
            }
313
        }
314
        if (fo == null || !fo.isFolder()) {
305
            return null;
315
            return null;
306
        }
316
        }
307
        return remoteProjectFO;
317
        String lastPath = fo.getParent() == null ? fo.getPath() : fo.getParent().getPath();
318
        RemoteFileUtil.setCurrentChooserFile(lastPath, env);
319
        return fo;
308
    }    
320
    }    
309
}
321
}

Return to bug 202853