/// <summary> /// Creates a new form /// </summary> public ManagerForm() { InitializeComponent(); this.Closing += OnClosing; Constants.WindowIcon = this.Icon; //Ensure we upgrade settings if user has come from an older version of the application if (Settings.Default.UpgradeRequired) { Settings.Default.Upgrade(); Settings.Default.UpgradeRequired = false; Settings.Default.Save(); Settings.Default.Reload(); } //Enable UTF-8 BOM Output if relevant Options.UseBomForUtf8 = Settings.Default.UseUtf8Bom; //Ensure Configuration Loader has known required Object Factorires registered ConfigurationLoader.AddObjectFactory(new VirtuosoObjectFactory()); ConfigurationLoader.AddObjectFactory(new FullTextObjectFactory()); //Prepare Connection Definitions so users don't get a huge lag the first time they use these ConnectionDefinitionManager.GetDefinitions().Count(); //Check whether we have a Recent and Favourites Connections Graph this.LoadConnections(); }
private void mnuNewFromExisting_Click(object sender, EventArgs e) { if (this.ActiveMdiChild != null) { if (this.ActiveMdiChild is StoreManagerForm) { IStorageProvider manager = ((StoreManagerForm)this.ActiveMdiChild).Manager; IConnectionDefinition def = ConnectionDefinitionManager.GetDefinition(manager.GetType()); if (def != null) { if (manager is IConfigurationSerializable) { Graph g = new Graph(); ConfigurationSerializationContext ctx = new ConfigurationSerializationContext(g); INode n = g.CreateBlankNode(); ctx.NextSubject = n; ((IConfigurationSerializable)manager).SerializeConfiguration(ctx); def.PopulateFrom(g, n); EditConnectionForm editConn = new EditConnectionForm(def); if (editConn.ShowDialog() == DialogResult.OK) { StoreManagerForm managerForm = new StoreManagerForm(editConn.Connection); this.AddRecentConnection(editConn.Connection); managerForm.MdiParent = this; managerForm.Show(); } return; } } } } MessageBox.Show("The current connection is not editable", "New Connection from Current Error", MessageBoxButtons.OK, MessageBoxIcon.Information); }
public NewConnectionForm() { InitializeComponent(); this._definitions.AddRange(ConnectionDefinitionManager.GetDefinitions().OrderBy(d => d.StoreName)); this.lstStoreTypes.DataSource = this._definitions; this.lstStoreTypes.DisplayMember = "StoreName"; }
private void btnRescan_Click(object sender, EventArgs e) { this._assemblies.Clear(); this.lstPlugins.BeginUpdate(); this.lstPlugins.Items.Clear(); ConnectionDefinitionManager.ScanPlugins(); this.ShowDetectedAssemblies(); this.lstPlugins.EndUpdate(); }
private void EditConnection(ListBox lbox) { QuickConnect connect = lbox.SelectedItem as QuickConnect; if (connect == null) { return; } Type t = connect.Type; if (t != null) { IConnectionDefinition def = ConnectionDefinitionManager.GetDefinition(t); if (def != null) { def.PopulateFrom(connect.Graph, connect.ObjectNode); EditConnectionForm edit = new EditConnectionForm(def); if (edit.ShowDialog() == DialogResult.OK) { IStorageProvider manager = edit.Connection; StoreManagerForm storeManager = new StoreManagerForm(manager); storeManager.MdiParent = Program.MainForm; storeManager.Show(); //Add to Recent Connections Program.MainForm.AddRecentConnection(manager); this.Close(); } } else { MessageBox.Show("The selected connection is not editable", "Edit Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("The selected connection is not editable", "Edit Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void FillConnectionList(IGraph config, ListBox lbox) { SparqlParameterizedString query = new SparqlParameterizedString(); query.Namespaces.AddNamespace("rdfs", new Uri(NamespaceMapper.RDFS)); query.Namespaces.AddNamespace("dnr", new Uri(ConfigurationLoader.ConfigurationNamespace)); query.CommandText = "SELECT * WHERE { ?obj a @type . OPTIONAL { ?obj rdfs:label ?label } }"; query.CommandText += " ORDER BY DESC(?obj)"; query.SetParameter("type", config.CreateUriNode(UriFactory.Create(ConfigurationLoader.ClassStorageProvider))); SparqlResultSet results = config.ExecuteQuery(query) as SparqlResultSet; if (results != null) { foreach (SparqlResult r in results) { QuickConnect connect; if (r.HasValue("label") && r["label"] != null) { connect = new QuickConnect(config, r["obj"], r["label"].ToString()); } else { connect = new QuickConnect(config, r["obj"]); } lbox.Items.Add(connect); } } lbox.DoubleClick += new EventHandler((sender, args) => { QuickConnect connect = lbox.SelectedItem as QuickConnect; if (connect != null) { if (Properties.Settings.Default.AlwaysEdit) { IConnectionDefinition def = ConnectionDefinitionManager.GetDefinition(connect.Type); if (def != null) { def.PopulateFrom(connect.Graph, connect.ObjectNode); EditConnectionForm edit = new EditConnectionForm(def); if (edit.ShowDialog() == DialogResult.OK) { IStorageProvider manager = edit.Connection; StoreManagerForm storeManager = new StoreManagerForm(manager); storeManager.MdiParent = Program.MainForm; storeManager.Show(); //Add to Recent Connections Program.MainForm.AddRecentConnection(manager); this.Close(); } } else { MessageBox.Show("Selected Connection is not editable", "Connection Edit Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { try { IStorageProvider manager = connect.GetConnection(); StoreManagerForm storeManager = new StoreManagerForm(manager); storeManager.MdiParent = Program.MainForm; storeManager.Show(); try { //Add to Recent Connections Program.MainForm.AddRecentConnection(manager); } catch { // silently ignore this error? seems like if MaxRecentConnections is hit, there is a bug in removing old connections... } this.Close(); } catch (Exception ex) { MessageBox.Show("Error Opening Connection " + connect.ToString() + ":\n" + ex.Message, "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }); }
public ManagerForm() { InitializeComponent(); Constants.WindowIcon = this.Icon; //Ensure we upgrade settings if user has come from an older version of the application if (Properties.Settings.Default.UpgradeRequired) { Properties.Settings.Default.Upgrade(); Properties.Settings.Default.Save(); Properties.Settings.Default.Reload(); } //Enable UTF-8 BOM Output if relevant Options.UseBomForUtf8 = false; if (Properties.Settings.Default.UseUtf8Bom) { this.mnuUseUtf8Bom.Checked = true; Options.UseBomForUtf8 = true; } this.mnuShowStartPage.Checked = Properties.Settings.Default.ShowStartPage; //Check whether we have a Recent and Favourites Connections Graph try { String appDataDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); String sepChar = new String(new char[] { Path.DirectorySeparatorChar }); if (!appDataDir.EndsWith(sepChar)) { appDataDir += sepChar; } appDataDir = Path.Combine(appDataDir, "dotNetRDF" + sepChar); if (!Directory.Exists(appDataDir)) { Directory.CreateDirectory(appDataDir); } appDataDir = Path.Combine(appDataDir, "Store Manager" + sepChar); if (!Directory.Exists(appDataDir)) { Directory.CreateDirectory(appDataDir); } this._recentConnectionsFile = Path.Combine(appDataDir, "recent.ttl"); this._faveConnectionsFile = Path.Combine(appDataDir, "favourite.ttl"); if (File.Exists(this._recentConnectionsFile)) { //Load Recent Connections FileLoader.Load(this._recentConnections, this._recentConnectionsFile); this.FillConnectionsMenu(this.mnuRecentConnections, this._recentConnections, MaxRecentConnections); } if (File.Exists(this._faveConnectionsFile)) { //Load Favourite Connections FileLoader.Load(this._faveConnections, this._faveConnectionsFile); this.FillConnectionsMenu(this.mnuFavouriteConnections, this._faveConnections, 0, true, this._faveConnectionsFile); } } catch { //If errors occur then ignore Recent Connections } //Ensure Configuration Loader has any required Object Factorires registered ConfigurationLoader.AddObjectFactory(new VirtuosoObjectFactory()); ConfigurationLoader.AddObjectFactory(new FullTextObjectFactory()); //Prepare Connection Definitions so users don't get a huge lag the first time they use these ConnectionDefinitionManager.GetDefinitions().Count(); }
private void QuickEditClick(object sender, EventArgs e) { if (sender == null) { return; } Object tag = null; if (sender is Control) { tag = ((Control)sender).Tag; } else if (sender is ToolStripItem) { tag = ((ToolStripItem)sender).Tag; } else if (sender is Menu) { tag = ((Menu)sender).Tag; } if (tag != null) { if (tag is QuickConnect) { QuickConnect qc = (QuickConnect)tag; try { if (qc.Type != null) { IConnectionDefinition def = ConnectionDefinitionManager.GetDefinition(qc.Type); if (def != null) { def.PopulateFrom(qc.Graph, qc.ObjectNode); EditConnectionForm editConn = new EditConnectionForm(def); if (editConn.ShowDialog() == DialogResult.OK) { IStorageProvider manager = editConn.Connection; StoreManagerForm storeManager = new StoreManagerForm(manager); storeManager.MdiParent = Program.MainForm; storeManager.Show(); //Add to Recent Connections this.AddRecentConnection(manager); this.Close(); } } else { MessageBox.Show("This Connection is not ediatable", "Quick Edit Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("This Connection is not ediatable", "Quick Edit Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { MessageBox.Show("Unable to edit the Connection due to an error: " + ex.Message, "Quick Edit Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } }