Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ProjectController.newProject() does not enable File/Save and Workspace menu items #837

Closed
jbliesener opened this issue Oct 6, 2013 · 3 comments
Assignees
Milestone

Comments

@jbliesener
Copy link
Contributor

The following code snippet CREATES a new project in a freshly started Gephi instance, but does not enable the File/Save action or the items in the Workspace menu. However, when closing Gephi, the prompt "Save changes before closing" appears.

I have documented the issue here: http://www.youtube.com/watch?v=6HGWLS04XII

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import org.gephi.project.api.ProjectController;
import org.openide.awt.ActionID;
import org.openide.awt.ActionReference;
import org.openide.awt.ActionRegistration;
import org.openide.util.Lookup;
import org.openide.util.NbBundle.Messages;

@ActionID(
        category = "Tools",
        id = "com.bliesener.test.SomeAction")
@ActionRegistration(
        displayName = "#CTL_SomeAction")
@ActionReference(path = "Menu/Tools", position = 100, separatorBefore = 50)
@Messages("CTL_SomeAction=New Project")
public final class SomeAction implements ActionListener {

    @Override
    public void actionPerformed(ActionEvent e) {
        ProjectController pc = Lookup.getDefault().lookup(ProjectController.class);
        pc.newProject();
    }
}
@jbliesener
Copy link
Contributor Author

Furthermore, if the user clicks on File/New Project AFTER having executing the mentioned code, Gephi generates the following exception:

I have documented the issue here: http://www.youtube.com/watch?v=6HGWLS04XII

java.lang.StringIndexOutOfBoundsException: String index out of range: -2
    at java.lang.String.substring(String.java:1911)
    at org.gephi.desktop.project.ProjectControllerUIImpl$5.run(ProjectControllerUIImpl.java:268)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:733)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:694)
    at java.awt.EventQueue$3.run(EventQueue.java:692)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:703)
    at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:158)
[catch] at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

@jbliesener
Copy link
Contributor Author

Problem found. The project must be created with an (undocumented) call to ProjectControllerUI.newProject().

This should be documented...

@jbliesener jbliesener reopened this Oct 8, 2013
@mbastian mbastian self-assigned this Sep 12, 2015
@mbastian mbastian added this to the 0.10.0 milestone Sep 24, 2022
@mbastian
Copy link
Member

mbastian commented Nov 9, 2022

Hi @jbliesener and thanks for the report. You are totally right and this wasn't the best design from our part. We actually fixed that in #2589. Starting from 0.10.0 we'll only need to interact with ProjectController. The UI is following changes behind the scene.

@mbastian mbastian closed this as completed Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants