Untitled
unknown
plain_text
2 years ago
11 kB
6
Indexable
package com.swift.view.load; import com.swift.model.cache.TaskCache; import com.swift.controller.operations.task.TaskList; import com.swift.controller.util.PowershellDependency; import com.swift.model.modules.SystemInformation; import com.swift.view.Application; import com.swift.view.form.*; import java.awt.Color; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseMotionAdapter; import javax.swing.JFrame; public class LoadingScreen extends JFrame{ private int x; private int y; private Form_Dashboard dashboard; private Form_Operations operations; private Form_Templates template; private Form_Vitals vitals; private Form_Backstage backstage; private Form_Calendar calendar; private PowershellDependency dependency; private TaskCache cache; private TaskList taskList; public LoadingScreen(){ initComponents(); initMoving(); setBackground(new Color(0,0,0,0)); setVisible(true); } public void load(){ waitForCredentials(); cache(); dependency(); taskList(); dashboard(); operations(); template(); vitals(); backstage(); calendar(); progressLabel(); progressBar(); initInfo(); launch(); dispose(); } private void waitForCredentials(){ while(!loginPanel1.getStart()){ try { Thread.sleep(10); } catch (InterruptedException e) { throw new RuntimeException(e); } } } private void cache(){ new Thread(() -> { this.cache = new TaskCache(); }).start(); } private void dependency(){ new Thread(() -> { this.dependency = new PowershellDependency(); }).start(); } private void dashboard(){ new Thread (() -> { this.dashboard = new Form_Dashboard(); }).start(); } private void operations(){ new Thread (() -> { this.operations = new Form_Operations(); }).start(); } private void template(){ new Thread (() -> { this.template = new Form_Templates(); }).start(); } private void vitals(){ new Thread (() -> { this.vitals = new Form_Vitals(); }).start(); } private void backstage(){ new Thread (() -> { this.backstage = new Form_Backstage(); }).start(); } private void calendar(){ new Thread (() -> { this.calendar = new Form_Calendar(); }).start(); } private void initInfo(){ SystemInformation.setPassword(loginPanel1.getPassword()); } private void taskList(){ new Thread(() -> { this.taskList = new TaskList(); }).start(); } private void progressLabel(){ new Thread(() -> { boolean start = true; while(start){ for(LoadingLabel label : LoadingLabel.values()){ loadingLabel.setText(label.getLabel()); try { Thread.sleep(100); } catch (InterruptedException ignored) {} } } }).start(); } private void progressBar(){ int i = 0; while(i<=100){ jProgressBar1.setValue(i); try{ Thread.sleep(50); }catch (InterruptedException e){ e.printStackTrace(); } i++; } } private void launch(){ new Thread(() -> { Application application = new Application(dashboard,operations,template,vitals,backstage,calendar,this); application.setVisible(true); }).start(); } public Form_Dashboard getDashboard() { return dashboard; } public void setDashboard(Form_Dashboard dashboard) { this.dashboard = dashboard; } public Form_Operations getOperations() { return operations; } public void setOperations(Form_Operations operations) { this.operations = operations; } public Form_Templates getTemplate() { return template; } public void setTemplate(Form_Templates template) { this.template = template; } public Form_Vitals getVitals() { return vitals; } public void setVitals(Form_Vitals vitals) { this.vitals = vitals; } public Form_Backstage getBackstage() { return backstage; } public void setBackstage(Form_Backstage backstage) { this.backstage = backstage; } public Form_Calendar getCalendar() { return calendar; } public void setCalendar(Form_Calendar calendar) { this.calendar = calendar; } public PowershellDependency getDependency() { return dependency; } public void setDependency(PowershellDependency dependency) { this.dependency = dependency; } public TaskCache getCache() { return cache; } public void setCache(TaskCache cache) { this.cache = cache; } public TaskList getTaskList() { return taskList; } public void setTaskList(TaskList taskList) { this.taskList = taskList; } @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { panelBorder1 = new com.swift.view.component.BackgroundPanel(); jProgressBar1 = new javax.swing.JProgressBar(); loadingLabel = new javax.swing.JLabel(); loginPanel1 = new com.swift.view.load.loginPanel(); jLabel1 = new javax.swing.JLabel(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setUndecorated(true); jProgressBar1.setBackground(new java.awt.Color(51, 51, 51)); jProgressBar1.setForeground(new java.awt.Color(153, 0, 255)); loadingLabel.setFont(new java.awt.Font("Yu Gothic Medium", 0, 14)); // NOI18N loadingLabel.setForeground(new java.awt.Color(255, 255, 255)); loadingLabel.setToolTipText(""); loginPanel1.setColor1(new java.awt.Color(0, 102, 204)); loginPanel1.setColor2(new java.awt.Color(195, 52, 230)); jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icon/loadDragon.png"))); // NOI18N javax.swing.GroupLayout panelBorder1Layout = new javax.swing.GroupLayout(panelBorder1); panelBorder1.setLayout(panelBorder1Layout); panelBorder1Layout.setHorizontalGroup( panelBorder1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(panelBorder1Layout.createSequentialGroup() .addComponent(loginPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(panelBorder1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(panelBorder1Layout.createSequentialGroup() .addGap(17, 17, 17) .addGroup(panelBorder1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(jProgressBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 676, Short.MAX_VALUE) .addComponent(loadingLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addGroup(panelBorder1Layout.createSequentialGroup() .addGap(222, 222, 222) .addComponent(jLabel1))) .addContainerGap(17, Short.MAX_VALUE)) ); panelBorder1Layout.setVerticalGroup( panelBorder1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelBorder1Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel1) .addGap(63, 63, 63) .addComponent(loadingLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(16, 16, 16)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelBorder1Layout.createSequentialGroup() .addComponent(loginPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(0, 0, Short.MAX_VALUE)) ); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(panelBorder1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(panelBorder1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); pack(); setLocationRelativeTo(null); }// </editor-fold>//GEN-END:initComponents public void initMoving() { addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent me) { x = me.getX(); y = me.getY(); } }); addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseDragged(MouseEvent me) { setLocation(me.getXOnScreen() - x, me.getYOnScreen() - y); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JLabel jLabel1; private javax.swing.JProgressBar jProgressBar1; private javax.swing.JLabel loadingLabel; private com.swift.view.load.loginPanel loginPanel1; private com.swift.view.component.BackgroundPanel panelBorder1; // End of variables declaration//GEN-END:variables }