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

Adding a Project View to the Arduino IDE #11048

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
V1.0 Arduino IDE (Project View) - Icons and project touchbar Added + …
…Toggle button and shortcut
  • Loading branch information
samigamer1999 committed Dec 3, 2020
commit f369ef913d789f9de648a65b0d76bff2a26f04bd
62 changes: 56 additions & 6 deletions app/src/processing/app/Editor.java
Original file line number Diff line number Diff line change
@@ -185,6 +185,7 @@ public boolean test(SketchController controller) {
EditorProject project;

private JSplitPane splitPane;
private JSplitPane splitProject;

// currently opened program
SketchController sketchController;
@@ -312,16 +313,10 @@ public void windowDeactivated(WindowEvent e) {



project = new EditorProject(PreferencesData.get("sketchbook.path"), base, this);
middle.add(project);
codePanel = new JPanel(new BorderLayout());
editor_upper.add(codePanel);
middle.add(editor_upper);

JSplitPane splitProject = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, project, editor_upper);
splitProject.setContinuousLayout(true);
splitProject.setResizeWeight(0.25);
middle.add(splitProject);
upper.add(middle);
splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, upper, consolePanel);

@@ -376,6 +371,11 @@ public void windowDeactivated(WindowEvent e) {

// default the console output to the last opened editor
EditorConsole.setCurrentEditorConsole(console);

// Add Project View if True in the saved preferences

if(PreferencesData.getBoolean("project.view"))
handleAddProjectView();
}


@@ -722,6 +722,15 @@ private JMenu buildToolsMenu() {
item.addActionListener(e -> handlePlotter());
toolsMenu.add(item);

item = newJMenuItemShift(tr("Project View"), 'J');
item.addActionListener(e -> {
if (!PreferencesData.getBoolean("project.view")) {
handleAddProjectView();
}else{
handleRemoveProjectView();}
});
toolsMenu.add(item);

addTools(toolsMenu, BaseNoGui.getToolsFolder());
File sketchbookTools = new File(BaseNoGui.getSketchbookFolder(), "tools");
addTools(toolsMenu, sketchbookTools);
@@ -2595,4 +2604,45 @@ public void addCompilerProgressListener(CompilerProgressListener listener){
this.status.addCompilerProgressListener(listener);
}

public void handleAddProjectView(){

// Reset the panels and add the project view
middle.remove(editor_upper);
project = new EditorProject(PreferencesData.get("sketchbook.path"), base, this);
middle.add(project);
middle.add(editor_upper);

// Split the code and project View
splitProject = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, project, editor_upper);
splitProject.setContinuousLayout(true);
splitProject.setResizeWeight(0.25);
middle.add(splitProject);

// Pack the frame
pack();

// Print the status
statusNotice(tr("Added Project View"));

// Update preferences
PreferencesData.setBoolean("project.view", true);
}

public void handleRemoveProjectView(){
// Reset the panels and add only the code view
middle.remove(project);
middle.remove(editor_upper);
middle.remove(splitProject);
middle.add(editor_upper);

// Pack the frame
pack();

// Print the status
statusNotice(tr("Removed Project View"));

// Update preferences
PreferencesData.setBoolean("project.view", false);
}

}
80 changes: 18 additions & 62 deletions app/src/processing/app/EditorProject.java
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@
import static processing.app.I18n.tr;


public class EditorProject extends Panel implements ActionListener, MouseListener{
public class EditorProject extends JPanel {

private JExplorerPanel fileExplorerPanel;

@@ -25,25 +25,21 @@ public class EditorProject extends Panel implements ActionListener, MouseListene

private Editor editor;

private JPanel settingsbox;

private String path;

private JButton settings;

private JButton toggle;

private JFileChooser chooser;

private Label buttons_popup;
private ProjectToolbar projectToolbar;

public EditorProject(String path, Base base, Editor editor) throws IOException {

public EditorProject(String path, Base base, Editor editor){
this.setLayout(new BorderLayout());
fileRoot = new File(path);
this.base = base;
this.editor = editor;
fileExplorerPanel = new JExplorerPanel(fileRoot, editor);
buttons_popup = new Label("Toggle Project View");
projectToolbar = new ProjectToolbar(editor, this);
/*buttons_popup = new Label("Toggle Project View");
buttons_popup.setForeground(new Color(23, 161, 165));
buttons_popup.setBackground(new Color(23, 161, 165));
settingsbox = new JPanel();
@@ -73,7 +69,8 @@ public EditorProject(String path, Base base, Editor editor) throws IOException {
settingsbox.add(buttons_popup);
//settingsbox.add(Box.createHorizontalGlue());
//settingsbox.add(buttons_panel);
this.add(settingsbox, BorderLayout.NORTH);
this.add(settingsbox, BorderLayout.NORTH);*/
this.add(projectToolbar, BorderLayout.NORTH);
this.add(fileExplorerPanel);

}
@@ -85,66 +82,25 @@ public void resetProject(){

// Resetting the sketchbook path
PreferencesData.set("sketchbook.path", path);
editor.statusNotice(tr("Workspace moved to :")+path);
}


@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource() == settings){
chooser = new JFileChooser();
chooser.setCurrentDirectory(fileRoot);
chooser.setDialogTitle("Choose project directory : ");
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

if (chooser.showOpenDialog(fileExplorerPanel) == JFileChooser.APPROVE_OPTION) {
System.out.println("You moved your workspace to : " + chooser.getSelectedFile());
this.path = chooser.getSelectedFile().getAbsolutePath();
resetProject();
}
else {
System.out.println("No Selection ");
}
}

if(e.getSource() == toggle){
//TODO
}
}


@Override
public void mouseClicked(MouseEvent e) {

editor.statusNotice(tr("Navigated to :")+path);
}

@Override
public void mousePressed(MouseEvent e) {

}

@Override
public void mouseReleased(MouseEvent e) {
public void handleNavigate(){
chooser = new JFileChooser();
chooser.setCurrentDirectory(fileRoot);
chooser.setDialogTitle("Choose project directory : ");
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);

if (chooser.showOpenDialog(fileExplorerPanel) == JFileChooser.APPROVE_OPTION) {
this.path = chooser.getSelectedFile().getAbsolutePath();
resetProject();
}
}

@Override
public void mouseEntered(MouseEvent e) {
if(e.getSource() == settings){
buttons_popup.setForeground(Color.WHITE);
buttons_popup.setText("Change Workspace");
}

if(e.getSource() == toggle){
buttons_popup.setForeground(Color.WHITE);
buttons_popup.setText("Toggle Project View");
}
}

@Override
public void mouseExited(MouseEvent e) {
buttons_popup.setText("");
}
}


Loading
Oops, something went wrong.