/* * Copyright 2015 Sudipto Chandra. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.sandsoft.cymric.model; import org.sandsoft.cymric.Cymric; import org.sandsoft.cymric.view.SidePane; import org.sandsoft.cymric.view.components.StatusBar; import org.sandsoft.cymric.util.AppSettings; import org.sandsoft.cymric.view.EditorLayout; import org.sandsoft.cymric.view.NotesLayout; import org.sandsoft.cymric.view.ProjectLayout; import org.sandsoft.cymric.view.RootLayout; import org.sandsoft.cymric.view.SettingsLayout; import org.sandsoft.cymric.view.SnippetLayout; import org.sandsoft.cymric.view.SoftwareLayout; import org.sandsoft.cymric.view.ToolsLayout; import javafx.scene.Parent; import javafx.stage.Stage; /** * For interaction between controls of different levels. * * @author Sudipto Chandra */ public final class CymricCore { /** * Creates a new Cymric core * * @param stage the primary stage. */ public CymricCore(Stage stage) { mPrimaryStage = stage; mAppSettings = new AppSettings(); } // core objects private final Stage mPrimaryStage; private final AppSettings mAppSettings; //should initialize at startup private RootLayout mRootLayout; //others private StatusBar mStatusBar; private SidePane mSidePane; private SnippetLayout mSnippet; private EditorLayout mEditor; private NotesLayout mNotes; private ProjectLayout mProject; private SoftwareLayout mSoftware; private SettingsLayout mSettings; private ToolsLayout mTools; /** * Sets the root node to the scene * * @param parent New parent to set * @param resizeable True if the stage should be re-sizeable. */ public void attachRootNode(Parent parent, boolean resizeable) { mPrimaryStage.setResizable(resizeable); mPrimaryStage.getScene().setRoot(parent); if (!mPrimaryStage.isMaximized()) { mPrimaryStage.setWidth(parent.prefWidth(Cymric.DEFAULT_WIDTH)); mPrimaryStage.setHeight(parent.prefHeight(Cymric.DEFAULT_HEIGHT)); mPrimaryStage.centerOnScreen(); mPrimaryStage.show(); } } //<editor-fold defaultstate="collapsed" desc="Normal getter and setter"> /** * Gets the primary stage. * * @return the primary stage. */ public final Stage getPrimaryStage() { return mPrimaryStage; } /** * Gets the root layout. * * @return the root layout. */ public final RootLayout getRootLayout() { return mRootLayout; } /** * Sets the root layout. * * @param root the root layout */ public void setRootLayout(RootLayout root) { mRootLayout = root; } /** * Gets an instance of the application settings. * * @return An instance of the AppSettings class. */ public final AppSettings getAppSettings() { return mAppSettings; } /** * Gets the side pane control. * * @return the side pane control. */ public final SidePane getSidePane() { return mSidePane; } /** * Sets the side pane control. * * @param pane the side pane control. */ public void setSidePane(SidePane pane) { mSidePane = pane; } /** * Gets the status bar control. * * @return the status bar control. */ public final StatusBar getStatusBar() { return mStatusBar; } /** * Sets the SnippetLayout. * * @param layout the SnippetLayout. */ public void setSnippetLayout(SnippetLayout layout) { mSnippet = layout; } /** * Gets the SnippetLayout. * * @return the SnippetLayout. */ public final SnippetLayout getSnippetLayout() { return mSnippet; } /** * Sets the EditorLayout. * * @param layout the EditorLayout. */ public void setEditorLayout(EditorLayout layout) { mEditor = layout; } /** * Gets the EditorLayout. * * @return the EditorLayout. */ public final EditorLayout getEditorLayout() { return mEditor; } /** * Sets the NotesLayout. * * @param layout the NotesLayout. */ public final void setNotesLayout(NotesLayout layout) { mNotes = layout; } /** * Gets the NotesLayout. * * @return the NotesLayout. */ public final NotesLayout getNotesLayout() { return mNotes; } /** * Sets the ProjectLayout. * * @param layout the ProjectLayout. */ public void setProjectLayout(ProjectLayout layout) { mProject = layout; } /** * Gets the ProjectLayout. * * @return the ProjectLayout. */ public final ProjectLayout getProjectLayout() { return mProject; } /** * Sets the SoftwareLayout. * * @param layout the SoftwareLayout. */ public void setSoftwareLayout(SoftwareLayout layout) { mSoftware = layout; } /** * Gets the SoftwareLayout. * * @return the SoftwareLayout. */ public final SoftwareLayout getSoftwareLayout() { return mSoftware; } /** * Sets the SettingsLayout. * * @param layout the SettingsLayout. */ public void setSettingsLayout(SettingsLayout layout) { mSettings = layout; } /** * Gets the SettingsLayout. * * @return the SettingsLayout. */ public final SettingsLayout getSettingsLayout() { return mSettings; } /** * Sets the ToolsLayout. * * @param layout the ToolsLayout. */ public void setToolsLayout(ToolsLayout layout) { mTools = layout; } /** * Gets the ToolsLayout. * * @return the ToolsLayout. */ public final ToolsLayout getToolsLayout() { return mTools; } //</editor-fold> //<editor-fold defaultstate="collapsed" desc="Specialized getter and setter"> /** * Sets the status bar control. * * @param statusbar the status bar control. */ public void setStatusBar(StatusBar statusbar) { mStatusBar = statusbar; } /** * Sets the status text and progress. * * @param text Text to display as status. (null if none) */ public void setStatus(String text) { if (text != null) { mStatusBar.setStatus(text); } } /** * Sets the current value of progress. * * @param progress Current value of progress. */ public void setProgress(double progress) { mStatusBar.setProgress(progress); } /** * Sets the current value of progress. * * @param progress Current value of progress. * @param maximum Maximum value of progress. */ public void setProgress(double progress, double maximum) { mStatusBar.setProgress(progress, maximum); } //</editor-fold> }