reorganize some stuff, fix Undo/Redo command enabling, other minor aesthetic issues

This commit is contained in:
Michael Becker 2021-02-26 21:01:25 -05:00
parent 0185e4ab32
commit 847d98850e
No known key found for this signature in database
GPG Key ID: 98C333A81F18C22C
14 changed files with 370 additions and 9 deletions

View File

@ -1,6 +1,6 @@
<UniversalEditor Version="5.0">
<Editors>
<Editor ID="{2E873BD5-6F63-4ED8-9C33-C43A08919E29}" TypeName="UniversalEditor.Editors.Database.DatabaseEditor">
<Editor ID="{2E873BD5-6F63-4ED8-9C33-C43A08919E29}" TypeName="UniversalEditor.UserInterface.Editors.Database.DatabaseEditor">
<Commands>
<Command ID="DatabaseEditor_ContextMenu_Table_Script_Create_NewWindow" Title="New Query Editor _Window" />

View File

@ -0,0 +1,15 @@
<UniversalEditor Version="5.0">
<Editors>
<Editor ID="{2E873BD5-6F63-4ED8-9C33-C43A08919E29}" TypeName="UniversalEditor.UserInterface.Editors.Database.DatabaseEditor">
<Commands>
<Command ID="DatabaseEditor_ContextMenu_Columns" Title="Columns Context Menu">
<Items>
<CommandReference CommandID="DatabaseEditor_ContextMenu_Columns_Add" />
</Items>
</Command>
<Command ID="DatabaseEditor_ContextMenu_Columns_Add" Title="_Add Column" />
</Commands>
</Editor>
</Editors>
</UniversalEditor>

View File

@ -317,6 +317,7 @@
<Content Include="ProjectTypes\{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}.uexml" />
<Content Include="Editors\Blockchain\BlockchainEditor.glade" />
<Content Include="Panels\PropertyList\PropertyListPanel.glade" />
<Content Include="Editors\Database\ContextMenu_Columns.uexml" />
</ItemGroup>
<ItemGroup>
<Content Include="Configuration\Application.upl" />

View File

@ -64,6 +64,10 @@ namespace UniversalEditor.UserInterface
private void Selections_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
Application.Instance.Commands["EditCut"].Enabled = (Selections.Count > 0);
Application.Instance.Commands["EditCopy"].Enabled = (Selections.Count > 0);
Application.Instance.Commands["EditDelete"].Enabled = (Selections.Count > 0);
OnSelectionsChanged(e);
}
@ -583,6 +587,9 @@ namespace UniversalEditor.UserInterface
OnDocumentEdited(EventArgs.Empty);
mvarEditing--;
Application.Instance.Commands["EditUndo"].Enabled = undo.Count > 0;
Application.Instance.Commands["EditRedo"].Enabled = redo.Count > 0;
}
/// <summary>
@ -632,6 +639,9 @@ namespace UniversalEditor.UserInterface
redo.Push(newedi);
ProcessingUndoRedo = false;
Application.Instance.Commands["EditUndo"].Enabled = undo.Count > 0;
Application.Instance.Commands["EditRedo"].Enabled = redo.Count > 0;
}
/// <summary>
@ -675,6 +685,9 @@ namespace UniversalEditor.UserInterface
undo.Push(newedi);
ProcessingUndoRedo = false;
Application.Instance.Commands["EditUndo"].Enabled = undo.Count > 0;
Application.Instance.Commands["EditRedo"].Enabled = redo.Count > 0;
}
#endregion

View File

@ -26,10 +26,11 @@ using MBS.Framework.UserInterface;
using MBS.Framework.UserInterface.Controls;
using MBS.Framework.UserInterface.Dialogs;
using MBS.Framework.UserInterface.Layouts;
using UniversalEditor.UserInterface.Editors.Database.Dialogs;
using UniversalEditor.ObjectModels.Database;
using UniversalEditor.UserInterface;
namespace UniversalEditor.Editors.Database
namespace UniversalEditor.UserInterface.Editors.Database
{
/// <summary>
/// Provides a UWT-based <see cref="Editor" /> for manipulating database files.
@ -158,6 +159,15 @@ namespace UniversalEditor.Editors.Database
}
}
private void DatabaseEditor_ContextMenu_Columns_Add(object sender, EventArgs e)
{
ColumnPropertiesDialog dlg = new ColumnPropertiesDialog();
if (dlg.ShowDialog() == DialogResult.OK)
{
}
}
protected override void OnCreated(EventArgs e)
{
base.OnCreated(e);
@ -165,6 +175,8 @@ namespace UniversalEditor.Editors.Database
DocumentExplorer.BeforeContextMenu += DocumentExplorer_BeforeContextMenu;
OnObjectModelChanged(EventArgs.Empty);
Context.AttachCommandEventHandler("DatabaseEditor_ContextMenu_Columns_Add", DatabaseEditor_ContextMenu_Columns_Add);
Context.AttachCommandEventHandler("DatabaseEditor_ContextMenu_Table_NewTable", delegate (object sender, EventArgs ee)
{
DatabaseObjectModel db = (ObjectModel as DatabaseObjectModel);

View File

@ -0,0 +1,43 @@
//
// ColumnPropertiesDialog.cs
//
// Author:
// Michael Becker <alcexhim@gmail.com>
//
// Copyright (c) 2021 Mike Becker's Software
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
using MBS.Framework.UserInterface;
using MBS.Framework.UserInterface.Controls;
namespace UniversalEditor.UserInterface.Editors.Database.Dialogs
{
[ContainerLayout(typeof(ColumnPropertiesDialog), "UniversalEditor.UserInterface.Editors.Database.Dialogs.ColumnPropertiesDialog.glade")]
public class ColumnPropertiesDialog : CustomDialog
{
private Button cmdOK;
private Button cmdCancel;
private TextBox txtColumnName;
private ComboBox cboDataType;
private TextBox txtDescription;
private GroupBox fraDataTypeSpecificProperties;
protected override void OnCreated(EventArgs e)
{
base.OnCreated(e);
DefaultButton = cmdOK;
}
}
}

View File

@ -0,0 +1,246 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.2 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkListStore" id="tmDataType">
<columns>
<!-- column-name colDataTypeName -->
<column type="gchararray"/>
</columns>
</object>
<object class="GtkDialog">
<property name="width_request">500</property>
<property name="height_request">400</property>
<property name="can_focus">False</property>
<property name="title" translatable="yes">Column Properties</property>
<property name="type_hint">dialog</property>
<child type="titlebar">
<placeholder/>
</child>
<child internal-child="vbox">
<object class="GtkBox">
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="cmdOK">
<property name="label">gtk-ok</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
<style>
<class name="suggested-action"/>
</style>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="cmdCancel">
<property name="label">gtk-cancel</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">16</property>
<property name="margin_right">16</property>
<property name="margin_top">16</property>
<property name="margin_bottom">16</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="row_spacing">8</property>
<property name="column_spacing">8</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_Name</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="txtColumnName">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Data _type</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="cboDataType">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="model">tmDataType</property>
<child>
<object class="GtkCellRendererText"/>
<attributes>
<attribute name="text">0</attribute>
</attributes>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">start</property>
<property name="label" translatable="yes">_Description</property>
<property name="use_underline">True</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkTextView" id="txtDescription">
<property name="visible">True</property>
<property name="can_focus">True</property>
</object>
</child>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkFrame" id="fraDataTypeSpecificProperties">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_top">16</property>
<property name="label_xalign">0</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkAlignment">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="left_padding">12</property>
<child>
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">8</property>
<property name="margin_right">8</property>
<property name="margin_top">8</property>
<property name="margin_bottom">8</property>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">8</property>
<property name="margin_right">8</property>
<property name="margin_top">8</property>
<property name="margin_bottom">8</property>
<property name="label" translatable="yes">Data type specific properties</property>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
</interface>

View File

@ -19,7 +19,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
namespace UniversalEditor.Editors.Database
namespace UniversalEditor.UserInterface.Editors.Database
{
public enum ScriptTableMode
{

View File

@ -19,7 +19,7 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
using System;
namespace UniversalEditor.Editors.Database
namespace UniversalEditor.UserInterface.Editors.Database
{
public enum ScriptTableTo
{

View File

@ -24,7 +24,7 @@ using MBS.Framework.UserInterface.Controls;
using UniversalEditor.ObjectModels.Database;
using UniversalEditor.UserInterface;
namespace UniversalEditor.Editors.Database.Views
namespace UniversalEditor.UserInterface.Editors.Database.Views
{
[ContainerLayout("~/Editors/Database/Views/DesignView.glade")]
public class DesignView : View
@ -39,7 +39,7 @@ namespace UniversalEditor.Editors.Database.Views
private bool _InhibitEditing = false;
[EventHandler(nameof(txtName), "Changed")]
[EventHandler(nameof(txtName), nameof(TextBox.Changed))]
private void txtName_Changed(object sender, EventArgs e)
{
if (_InhibitEditing) return;
@ -52,6 +52,12 @@ namespace UniversalEditor.Editors.Database.Views
Editor.EndEdit();
}
[EventHandler(nameof(tvColumns), nameof(Control.BeforeContextMenu))]
private void tvColumns_BeforeContextMenu(object sender, EventArgs e)
{
tvColumns.ContextMenuCommandID = "DatabaseEditor_ContextMenu_Columns";
}
protected override void OnObjectModelChanged(EventArgs e)
{
base.OnObjectModelChanged(e);

View File

@ -28,7 +28,7 @@ using MBS.Framework.UserInterface.Dialogs;
using UniversalEditor.ObjectModels.Database;
using UniversalEditor.UserInterface;
namespace UniversalEditor.Editors.Database.Views
namespace UniversalEditor.UserInterface.Editors.Database.Views
{
[ContainerLayout("~/Editors/Database/Views/ScriptView.glade")]
public class ScriptView : View

View File

@ -111,6 +111,28 @@ namespace UniversalEditor.Editors.FileSystem
{
Application.Instance.Contexts.Remove(ctxTreeView);
}
[EventHandler(nameof(tv), nameof(ListViewControl.SelectionChanged))]
private void tv_SelectionChanged(object sender, EventArgs e)
{
Selections.Clear();
IFileSystemObject[] sels = GetSelectedItems();
if (sels.Length > 0)
{
Selections.Add(new FileSystemSelection(this, GetSelectedItems()));
}
}
private IFileSystemObject[] GetSelectedItems()
{
List<IFileSystemObject> list = new List<IFileSystemObject>();
for (int i = 0; i < tv.SelectedRows.Count; i++)
{
IFileSystemObject fso = tv.SelectedRows[i].GetExtraData<IFileSystemObject>("item");
list.Add(fso);
}
return list.ToArray();
}
/// <summary>
/// Navigates to the specified <see cref="IFileSystemObject" />.

View File

@ -105,8 +105,8 @@ namespace UniversalEditor.UserInterface.Pages
return true;
}
private EditorReference DefaultBinaryEditor = new EditorReference(typeof(Editors.Binary.BinaryEditor));
private EditorReference DefaultTextEditor = new EditorReference(typeof(Editors.Text.Plain.PlainTextEditor));
private EditorReference DefaultBinaryEditor = new EditorReference(typeof(UniversalEditor.Editors.Binary.BinaryEditor));
private EditorReference DefaultTextEditor = new EditorReference(typeof(UniversalEditor.Editors.Text.Plain.PlainTextEditor));
private Document mvarDocument = null;
public Document Document

View File

@ -135,6 +135,7 @@
<Compile Include="EditorApplication.cs" />
<Compile Include="IHostApplication.cs" />
<Compile Include="Controls\PrintDialogOptionsTabPage.cs" />
<Compile Include="Editors\Database\Dialogs\ColumnPropertiesDialog.cs" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
@ -193,12 +194,14 @@
<Folder Include="Editors\Database\Views\" />
<Folder Include="PrintHandlers\" />
<Folder Include="SettingsProviders\" />
<Folder Include="Editors\Database\Dialogs\" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="SettingsProviders\DefaultSettingsProvider.xml" />
<EmbeddedResource Include="Editors\FileSystem\FileSystemEditorSettingsProvider.xml" />
<EmbeddedResource Include="Editors\Text\Plain\PlainTextEditorSettingsProvider.xml" />
<EmbeddedResource Include="Controls\PrintDialogOptionsTabPage.glade" />
<EmbeddedResource Include="Editors\Database\Dialogs\ColumnPropertiesDialog.glade" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.