public MainWindow() {
		this.eventHandler = new MainEventHandler();

		// TODO don't do this, create a real package
		PackageManager.getInstance().registerCommand(
				SafeResourceLoader.getString("COMMAND_SHUTDOWN",
						"com.ikalagaming.omega.core.resources.PackageManager",
						"shutdown"), Editor.getInstance());

		this.resources =
				ResourceBundle.getBundle(
						"com.ikalagaming.omega.gui.resources.gui",
						Localization.getLocale());

		try {
			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
		}
		catch (final UnsupportedLookAndFeelException e) {
			e.printStackTrace();
		}
		catch (final ClassNotFoundException e) {
			e.printStackTrace();
		}
		catch (final InstantiationException e) {
			e.printStackTrace();
		}
		catch (final IllegalAccessException e) {
			e.printStackTrace();
		}

		// this.setExtendedState(Frame.MAXIMIZED_BOTH);// full screen
		this.setTitle(SafeResourceLoader.getString("MainWindow.title",
				this.resources, "MAIN_WINDOW_TITLE"));
		this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
		this.addWindowListener(new WindowAdapter() {
			@Override
			public void windowClosing(final WindowEvent event) {
				EventManager
						.getInstance()
						.fireEvent(
								new PackageEvent(
										Editor.getInstance().getName(),
										"editor",
										SafeResourceLoader
												.getString(
														"COMMAND_SHUTDOWN",
														"com.ikalagaming.omega.core.resources.PackageManager",
														"shutdown")));
			}
		});
		this.setBounds(100, 100, 562, 487);
		this.contentPane = new JPanel();
		this.contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		this.contentPane.setLayout(new BorderLayout(0, 0));
		this.setContentPane(this.contentPane);

		final JPanel menuPanel = new JPanel();
		this.contentPane.add(menuPanel, BorderLayout.NORTH);
		menuPanel.setLayout(new BorderLayout(0, 0));

		final JPanel panel_1 = new JPanel();
		menuPanel.add(panel_1, BorderLayout.NORTH);
		panel_1.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5));

		final JMenuBar menuBar = new JMenuBar();
		panel_1.add(menuBar);

		final Menu menu_file =
				new Menu(SafeResourceLoader.getString(
						"MainWindow.menubar.file", this.resources, "FILE"));
		final MenuItem menuitem_file_new =
				new MenuItem(SafeResourceLoader.getString(
						"MainWindow.menubar.file.new", this.resources, "NEW"));
		final MenuItem menuitem_file_open =
				new MenuItem(SafeResourceLoader.getString(
						"MainWindow.menubar.file.open", this.resources, "OPEN"));
		final MenuItem menuitem_file_save =
				new MenuItem(SafeResourceLoader.getString(
						"MainWindow.menubar.file.save", this.resources, "SAVE"));
		final MenuItem menuitem_file_saveas =
				new MenuItem(SafeResourceLoader.getString(
						"MainWindow.menubar.file.saveas", this.resources,
						"SAVE_AS"));
		final MenuItem menuitem_file_exit =
				new MenuItem(SafeResourceLoader.getString(
						"MainWindow.menubar.file.exit", this.resources, "EXIT"));
		menu_file.addActionListener(this.eventHandler);
		menuitem_file_new.addActionListener(this.eventHandler);
		menuitem_file_open.addActionListener(this.eventHandler);
		menuitem_file_save.addActionListener(this.eventHandler);
		menuitem_file_saveas.addActionListener(this.eventHandler);
		menuitem_file_exit.addActionListener(this.eventHandler);
		menu_file.setID(ScriptRegistry.register(menu_file, "file"));
		menuitem_file_new.setID(ScriptRegistry.register(menuitem_file_new,
				"file.new"));
		menuitem_file_open.setID(ScriptRegistry.register(menuitem_file_open,
				"file.open"));
		menuitem_file_save.setID(ScriptRegistry.register(menuitem_file_save,
				"file.save"));
		menuitem_file_saveas.setID(ScriptRegistry.register(
				menuitem_file_saveas, "file.saveas"));
		menuitem_file_exit.setID(ScriptRegistry.register(menuitem_file_exit,
				"file.exit"));
		menu_file.add(menuitem_file_new);
		menu_file.add(menuitem_file_open);
		menu_file.add(menuitem_file_save);
		menu_file.add(menuitem_file_saveas);
		menu_file.add(new JSeparator());// divides the sections
		menu_file.add(menuitem_file_exit);

		// edit menu
		final Menu menu_edit =
				new Menu(SafeResourceLoader.getString(
						"MainWindow.menubar.edit", this.resources, "EDIT"));
		final MenuItem menuitem_edit_undo =
				new MenuItem(SafeResourceLoader.getString(
						"MainWindow.menubar.edit.undo", this.resources, "UNDO"));
		final MenuItem menuitem_edit_redo =
				new MenuItem(SafeResourceLoader.getString(
						"MainWindow.menubar.edit.redo", this.resources, "REDO"));
		final MenuItem menuitem_edit_cut =
				new MenuItem(SafeResourceLoader.getString(
						"MainWindow.menubar.edit.cut", this.resources, "CUT"));
		final MenuItem menuitem_edit_copy =
				new MenuItem(SafeResourceLoader.getString(
						"MainWindow.menubar.edit.copy", this.resources, "COPY"));
		final MenuItem menuitem_edit_paste =
				new MenuItem(SafeResourceLoader.getString(
						"MainWindow.menubar.edit.paste", this.resources,
						"PASTE"));
		final MenuItem menuitem_edit_delete =
				new MenuItem(SafeResourceLoader.getString(
						"MainWindow.menubar.edit.delete", this.resources,
						"PASTE"));
		final MenuItem menuitem_edit_find =
				new MenuItem(SafeResourceLoader.getString(
						"MainWindow.menubar.edit.find", this.resources, "FIND"));
		final MenuItem menuitem_edit_findnext =
				new MenuItem(SafeResourceLoader.getString(
						"MainWindow.menubar.edit.findnext", this.resources,
						"FIND_NEXT"));
		final MenuItem menuitem_edit_replace =
				new MenuItem(SafeResourceLoader.getString(
						"MainWindow.menubar.edit.replace", this.resources,
						"REPLACE"));
		final MenuItem menuitem_edit_selectall =
				new MenuItem(SafeResourceLoader.getString(
						"MainWindow.menubar.edit.selectall", this.resources,
						"SELECT_ALL"));
		menu_edit.addActionListener(this.eventHandler);
		menuitem_edit_undo.addActionListener(this.eventHandler);
		menuitem_edit_redo.addActionListener(this.eventHandler);
		menuitem_edit_cut.addActionListener(this.eventHandler);
		menuitem_edit_copy.addActionListener(this.eventHandler);
		menuitem_edit_paste.addActionListener(this.eventHandler);
		menuitem_edit_delete.addActionListener(this.eventHandler);
		menuitem_edit_find.addActionListener(this.eventHandler);
		menuitem_edit_findnext.addActionListener(this.eventHandler);
		menuitem_edit_replace.addActionListener(this.eventHandler);
		menuitem_edit_selectall.addActionListener(this.eventHandler);
		menu_edit.setID(ScriptRegistry.register(menu_edit, "edit"));
		menuitem_edit_undo.setID(ScriptRegistry.register(menuitem_edit_undo,
				"edit.undo"));
		menuitem_edit_redo.setID(ScriptRegistry.register(menuitem_edit_redo,
				"edit.redo"));
		menuitem_edit_cut.setID(ScriptRegistry.register(menuitem_edit_cut,
				"edit.cut"));
		menuitem_edit_copy.setID(ScriptRegistry.register(menuitem_edit_copy,
				"edit.copy"));
		menuitem_edit_paste.setID(ScriptRegistry.register(menuitem_edit_paste,
				"edit.paste"));
		menuitem_edit_delete.setID(ScriptRegistry.register(
				menuitem_edit_delete, "edit.delete"));
		menuitem_edit_find.setID(ScriptRegistry.register(menuitem_edit_find,
				"edit.find"));
		menuitem_edit_findnext.setID(ScriptRegistry.register(
				menuitem_edit_findnext, "edit.findnext"));
		menuitem_edit_replace.setID(ScriptRegistry.register(
				menuitem_edit_replace, "edit.replace"));
		menuitem_edit_selectall.setID(ScriptRegistry.register(
				menuitem_edit_selectall, "edit.selectall"));
		menu_edit.add(menuitem_edit_undo);
		menu_edit.add(menuitem_edit_redo);
		menu_edit.add(new JSeparator());
		menu_edit.add(menuitem_edit_cut);
		menu_edit.add(menuitem_edit_copy);
		menu_edit.add(menuitem_edit_paste);
		menu_edit.add(menuitem_edit_delete);
		menu_edit.add(new JSeparator());
		menu_edit.add(menuitem_edit_find);
		menu_edit.add(menuitem_edit_findnext);
		menu_edit.add(menuitem_edit_replace);
		menu_edit.add(menuitem_edit_selectall);

		menuBar.add(menu_file);
		menuBar.add(menu_edit);

		final JPanel panel_2 = new JPanel();
		final FlowLayout flowLayout = (FlowLayout) panel_2.getLayout();
		flowLayout.setAlignment(FlowLayout.LEFT);
		menuPanel.add(panel_2, BorderLayout.SOUTH);

		final JToolBar fileToolbar = new JToolBar();
		panel_2.add(fileToolbar);

		final Button btnNew =
				new Button(SafeResourceLoader.getString(
						"MainWindow.toolbar.new", this.resources, "NEW"));
		btnNew.setID(ScriptRegistry.register(btnNew, "new"));
		btnNew.addActionListener(this.eventHandler);
		fileToolbar.add(btnNew);

		final Button btnOpen =
				new Button(SafeResourceLoader.getString(
						"MainWindow.toolbar.open", this.resources, "OPEN"));
		btnOpen.setID(ScriptRegistry.register(btnOpen, "open"));
		btnOpen.addActionListener(this.eventHandler);
		fileToolbar.add(btnOpen);

		final Button btnSave =
				new Button(SafeResourceLoader.getString(
						"MainWindow.toolbar.save", this.resources, "SAVE"));
		fileToolbar.add(btnSave);
		btnSave.addActionListener(this.eventHandler);
		btnSave.setID(ScriptRegistry.register(btnSave, "save"));

		final Button btnSaveas =
				new Button(SafeResourceLoader.getString(
						"MainWindow.toolbar.saveas", this.resources, "SAVE_AS"));
		fileToolbar.add(btnSaveas);
		btnSaveas.addActionListener(this.eventHandler);
		btnSaveas.setID(ScriptRegistry.register(btnSaveas, "saveas"));

		final Button btnSaveall =
				new Button(SafeResourceLoader.getString(
						"MainWindow.toolbar.saveall", this.resources,
						"SAVE_ALL"));
		fileToolbar.add(btnSaveall);
		btnSaveall.addActionListener(this.eventHandler);
		btnSaveall.setID(ScriptRegistry.register(btnSaveall, "saveall"));

		final JToolBar editAsToolbar = new JToolBar();
		panel_2.add(editAsToolbar);

		final JLabel lblEditAs =
				new JLabel(SafeResourceLoader.getString(
						"MainWindow.toolbar.editas", this.resources, "EDIT_AS"));
		editAsToolbar.add(lblEditAs);

		final EditorTypeComboBox<EditorType> comboBox =
				new EditorTypeComboBox<>();
		comboBox.setModel(new DefaultComboBoxModel<Object>(EditorType.values()));
		editAsToolbar.add(comboBox);
		comboBox.addActionListener(this.eventHandler);

		final JPanel infoBar = new JPanel();
		this.contentPane.add(infoBar, BorderLayout.SOUTH);

		final JLabel lblWords =
				new JLabel(SafeResourceLoader.getString(
						"MainWindow.infobar.line", this.resources, "CUR_LINE"));
		infoBar.add(lblWords);

		final JLabel lblLnnum = new JLabel("line");
		infoBar.add(lblLnnum);

		final JLabel lblColumn =
				new JLabel(SafeResourceLoader.getString(
						"MainWindow.infobar.column", this.resources,
						"CUR_COLUMN"));
		infoBar.add(lblColumn);

		final JLabel lblColnum = new JLabel("colnum");
		infoBar.add(lblColnum);

		this.tabbedPane = new JTabbedPane(SwingConstants.TOP);
		this.contentPane.add(this.tabbedPane, BorderLayout.CENTER);

		this.setID(ScriptRegistry.register(this, "main"));

		try {
			EventManager.getInstance().registerEventListeners(this);
		}
		catch (final Exception e) {
			e.printStackTrace();
		}
	}