Skip to content

Commit 00c3c04

Browse files
committed
Fix #2710
1 parent 8be0af1 commit 00c3c04

File tree

5 files changed

+121
-1
lines changed

5 files changed

+121
-1
lines changed

modules/DesktopProject/src/main/java/org/gephi/desktop/project/ProjectControllerUIImpl.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,21 @@ public void deleteWorkspace(Workspace workspace) {
612612
}
613613
}
614614

615+
public void deleteWorkspaces(List<Workspace> workspaces) {
616+
String message =
617+
NbBundle.getMessage(ProjectControllerUIImpl.class, "DeleteWorkspaces_confirm_message", workspaces.size());
618+
String title = NbBundle.getMessage(ProjectControllerUIImpl.class, "DeleteWorkspaces_confirm_title");
619+
NotifyDescriptor dd = new NotifyDescriptor(message, title,
620+
NotifyDescriptor.YES_NO_OPTION,
621+
NotifyDescriptor.QUESTION_MESSAGE, null, null);
622+
Object retType = DialogDisplayer.getDefault().notify(dd);
623+
if (retType == NotifyDescriptor.YES_OPTION) {
624+
for (Workspace workspace : workspaces) {
625+
controller.deleteWorkspace(workspace);
626+
}
627+
}
628+
}
629+
615630
public void renameWorkspace(String name) {
616631
controller.renameWorkspace(controller.getCurrentWorkspace(), name);
617632
}
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
/*
2+
Copyright 2008-2010 Gephi
3+
Authors : Mathieu Bastian <[email protected]>
4+
Website : http://www.gephi.org
5+
6+
This file is part of Gephi.
7+
8+
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
9+
10+
Copyright 2011 Gephi Consortium. All rights reserved.
11+
12+
The contents of this file are subject to the terms of either the GNU
13+
General Public License Version 3 only ("GPL") or the Common
14+
Development and Distribution License("CDDL") (collectively, the
15+
"License"). You may not use this file except in compliance with the
16+
License. You can obtain a copy of the License at
17+
http://gephi.org/about/legal/license-notice/
18+
or /cddl-1.0.txt and /gpl-3.0.txt. See the License for the
19+
specific language governing permissions and limitations under the
20+
License. When distributing the software, include this License Header
21+
Notice in each file and include the License files at
22+
/cddl-1.0.txt and /gpl-3.0.txt. If applicable, add the following below the
23+
License Header, with the fields enclosed by brackets [] replaced by
24+
your own identifying information:
25+
"Portions Copyrighted [year] [name of copyright owner]"
26+
27+
If you wish your version of this file to be governed by only the CDDL
28+
or only the GPL Version 3, indicate your decision by adding
29+
"[Contributor] elects to include this software in this distribution
30+
under the [CDDL or GPL Version 3] license." If you do not indicate a
31+
single choice of license, a recipient has the option to distribute
32+
your version of this file under either the CDDL, the GPL Version 3 or
33+
to extend the choice of license to its licensees as provided above.
34+
However, if you add GPL Version 3 code and therefore, elected the GPL
35+
Version 3 license, then the option applies only if the new code is
36+
made subject to such option by the copyright holder.
37+
38+
Contributor(s):
39+
40+
Portions Copyrighted 2011 Gephi Consortium.
41+
*/
42+
43+
package org.gephi.desktop.project.actions;
44+
45+
import java.awt.event.ActionEvent;
46+
import java.util.ArrayList;
47+
import java.util.List;
48+
import javax.swing.AbstractAction;
49+
import org.gephi.desktop.project.ProjectControllerUIImpl;
50+
import org.gephi.project.api.Workspace;
51+
import org.openide.awt.ActionID;
52+
import org.openide.awt.ActionReference;
53+
import org.openide.awt.ActionRegistration;
54+
import org.openide.util.ImageUtilities;
55+
import org.openide.util.Lookup;
56+
import org.openide.util.NbBundle;
57+
58+
@ActionID(id = "org.gephi.desktop.project.actions.DeleteOtherWorkspaces", category = "Workspace")
59+
@ActionRegistration(displayName = "#CTL_DeleteOtherWorkspaces", lazy = false)
60+
public final class DeleteOtherWorkspaces extends AbstractAction {
61+
62+
DeleteOtherWorkspaces() {
63+
super(NbBundle.getMessage(DeleteOtherWorkspaces.class, "CTL_DeleteOtherWorkspaces"));
64+
}
65+
66+
@Override
67+
public void actionPerformed(ActionEvent ev) {
68+
if (isEnabled()) {
69+
ProjectControllerUIImpl cui = Lookup.getDefault().lookup(ProjectControllerUIImpl.class);
70+
Workspace workspace;
71+
if (ev.getSource() != null && ev.getSource() instanceof Workspace) {
72+
workspace = (Workspace) ev.getSource();
73+
} else {
74+
workspace = cui.getCurrentProject().getCurrentWorkspace();
75+
}
76+
if (workspace != null) {
77+
List<Workspace> workspaces = new ArrayList<>(cui.getCurrentProject().getWorkspaces());
78+
workspaces.remove(workspace);
79+
if (!workspaces.isEmpty()) {
80+
cui.deleteWorkspaces(workspaces);
81+
}
82+
}
83+
}
84+
}
85+
86+
@Override
87+
public boolean isEnabled() {
88+
return Lookup.getDefault().lookup(ProjectControllerUIImpl.class).canDeleteWorkspace();
89+
}
90+
}

modules/DesktopProject/src/main/resources/org/gephi/desktop/project/Bundle.properties

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,7 @@ ProjectControllerUI.error.open=The project file couldn't be opened. Please check
2323
ProjectControllerUI.error.multipleGephi=Please select a unique .gephi project file
2424

2525
DeleteWorkspace_confirm_message=Are you sure do you want to delete this workspace ?
26-
DeleteWorkspace_confirm_title=Close workspace
26+
DeleteWorkspace_confirm_title=Close workspace
27+
28+
DeleteWorkspaces_confirm_message=Are you sure do you want to delete {0} workspaces ?
29+
DeleteWorkspaces_confirm_title=Close multiple workspaces

modules/DesktopProject/src/main/resources/org/gephi/desktop/project/actions/Bundle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ CTL_ProjectProperties=Properties...
88
CTL_NewWorkspace=New
99
CTL_DuplicateWorkspace=Duplicate
1010
CTL_DeleteWorkspace=Delete
11+
CTL_DeleteOtherWorkspaces=Delete Other Workspaces
1112
CTL_RenameWorkspace=Rename
1213
CTL_ManageProjects=Projects...
1314
CTL_WorkspaceProperties=Properties...

modules/DesktopWindow/src/main/java/org/gephi/desktop/banner/workspace/WorkspacePanel.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,16 @@ public void actionPerformed(ActionEvent e) {
116116
Actions.forID("Workspace", "org.gephi.desktop.project.actions.DeleteWorkspace").actionPerformed(
117117
new ActionEvent(tabData.getUserObject(), 0, null));
118118

119+
tabActionEvent.consume();
120+
} else if (tabActionEvent.getActionCommand().equals(TabbedContainer.COMMAND_CLOSE_ALL)) {
121+
Actions.forID("File", "org.gephi.desktop.project.actions.CloseProject").actionPerformed(null);
122+
tabActionEvent.consume();
123+
} else if (tabActionEvent.getActionCommand().equals(TabbedContainer.COMMAND_CLOSE_ALL_BUT_THIS)) {
124+
TabData tabData = tabDataModel.getTab(tabActionEvent.getTabIndex());
125+
126+
Actions.forID("Workspace", "org.gephi.desktop.project.actions.DeleteOtherWorkspaces").actionPerformed(
127+
new ActionEvent(tabData.getUserObject(), 0, null));
128+
119129
tabActionEvent.consume();
120130
} else if (tabActionEvent.getActionCommand().equals(TabbedContainer.COMMAND_SELECT)) {
121131
TabData tabData = tabDataModel.getTab(tabActionEvent.getTabIndex());
@@ -217,6 +227,7 @@ public void run() {
217227
if (tabbedContainer.getSelectionModel().getSelectedIndex() != i) {
218228
tabbedContainer.getSelectionModel().setSelectedIndex(i);
219229
}
230+
tabDataModel.setText(i, workspace.getName());
220231
workspace.getLookup().lookup(WorkspaceInformation.class).addChangeListener(WorkspacePanel.this);
221232
break;
222233
}

0 commit comments

Comments
 (0)