mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-08-25 14:22:54 -06:00
MoveTopic
git-svn-id: svn://ultimatepp.org/upp/trunk@550 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
2a04343458
commit
6238a20707
5 changed files with 57 additions and 33 deletions
|
|
@ -12,12 +12,29 @@ public:
|
|||
|
||||
void MoveTopicDlg::Package()
|
||||
{
|
||||
|
||||
String g = ~group;
|
||||
group.Clear();
|
||||
group.Add("src", "Reference (src)");
|
||||
group.Add("srcdoc", "Documents (srcdoc)");
|
||||
group.Add("srcimp", "Implementation (srcimp)");
|
||||
FindFile ff(SourcePath(~package, "*.tpp"));
|
||||
while(ff) {
|
||||
if(ff.IsFolder()) {
|
||||
String h = GetFileTitle(ff.GetName());
|
||||
if(h != "src" && h != "srcdoc" && h != "srcimp")
|
||||
group.Add(h);
|
||||
}
|
||||
ff.Next();
|
||||
}
|
||||
if(group.HasKey(g))
|
||||
group <<= g;
|
||||
else
|
||||
group.GoBegin();
|
||||
}
|
||||
|
||||
MoveTopicDlg::MoveTopicDlg()
|
||||
{
|
||||
CtrlLayoutOKCancel(*this, "");
|
||||
CtrlLayoutOKCancel(*this, "Move topic");
|
||||
|
||||
topic.NotNull();
|
||||
topic.MaxLen(30);
|
||||
|
|
@ -27,35 +44,41 @@ MoveTopicDlg::MoveTopicDlg()
|
|||
const Workspace& w = GetIdeWorkspace();
|
||||
for(int i = 0; i < w.GetCount(); i++)
|
||||
package.Add(w[i]);
|
||||
package.GoBegin();
|
||||
Package();
|
||||
}
|
||||
|
||||
void TopicEditor::MoveTopic()
|
||||
{
|
||||
if(!topic.IsCursor())
|
||||
return;
|
||||
|
||||
TopicDlg<WithMoveTopicLayout<TopWindow> > d("Move topic");
|
||||
MoveTopicDlg dlg;
|
||||
String p = GetCurrentTopicPath();
|
||||
TopicLink tl = ParseTopicFilePath(p);
|
||||
dlg.package <<= tl.package;
|
||||
dlg.Package();
|
||||
dlg.group <<= tl.group;
|
||||
String tn;
|
||||
int lng;
|
||||
ParseTopicFileName(p, tn, lng);
|
||||
d.topic <<= tn;
|
||||
d.lang <<= lng;
|
||||
if(d.Run() != IDOK)
|
||||
dlg.topic <<= tn;
|
||||
dlg.lang <<= lng;
|
||||
if(dlg.Run() != IDOK)
|
||||
return;
|
||||
String np = AppendFileName(grouppath, d.GetName());
|
||||
String np = AppendFileName(SourcePath(~dlg.package, (String)~dlg.group + ".tpp"),
|
||||
(String)~dlg.topic + "$" + ToLower(LNGAsText(~dlg.lang)) + ".tpp");
|
||||
if(FindFile(np)) {
|
||||
Exclamation("Target file aready exists!");
|
||||
return;
|
||||
if(!PromptYesNo("Target file aready exists!&Do you want to overwrite it?"))
|
||||
return;
|
||||
FileDelete(np);
|
||||
}
|
||||
Flush();
|
||||
FileMove(p, np);
|
||||
RealizeDirectory(GetFileFolder(np));
|
||||
if(!SaveFile(np, LoadFile(p))) {
|
||||
Exclamation("Operation failed!");
|
||||
return;
|
||||
}
|
||||
serial++;
|
||||
FileDelete(p);
|
||||
InvalidateTopicInfoPath(p);
|
||||
InvalidateTopicInfoPath(np);
|
||||
Open(grouppath);
|
||||
Load(np);
|
||||
SaveInc();
|
||||
topic.FindSetCursor(GetFileTitle(np));
|
||||
editor.SetFocus();
|
||||
serial++;
|
||||
TheIde()->IdeOpenTopicFile(np);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,17 +8,17 @@ LAYOUT(NewTopicLayout, 268, 92)
|
|||
ITEM(Button, cancel, SetLabel(t_("Cancel")).LeftPosZ(196, 64).TopPosZ(60, 24))
|
||||
END_LAYOUT
|
||||
|
||||
LAYOUT(MoveTopicLayout, 184, 136)
|
||||
LAYOUT(MoveTopicLayout, 220, 136)
|
||||
ITEM(Label, dv___0, SetLabel(t_("Package")).LeftPosZ(8, 48).TopPosZ(4, 19))
|
||||
ITEM(DropList, package, LeftPosZ(68, 108).TopPosZ(4, 19))
|
||||
ITEM(DropList, package, LeftPosZ(68, 144).TopPosZ(4, 19))
|
||||
ITEM(Label, dv___2, SetLabel(t_("Group")).LeftPosZ(8, 48).TopPosZ(28, 19))
|
||||
ITEM(DropList, group, LeftPosZ(68, 108).TopPosZ(28, 19))
|
||||
ITEM(DropList, group, LeftPosZ(68, 144).TopPosZ(28, 19))
|
||||
ITEM(Label, dv___4, SetLabel(t_("Name")).LeftPosZ(8, 60).TopPosZ(52, 19))
|
||||
ITEM(EditString, topic, LeftPosZ(68, 108).TopPosZ(52, 19))
|
||||
ITEM(EditString, topic, LeftPosZ(68, 144).TopPosZ(52, 19))
|
||||
ITEM(Label, dv___6, SetLabel(t_("Language")).LeftPosZ(8, 60).TopPosZ(76, 19))
|
||||
ITEM(LNGCtrl, lang, LeftPosZ(68, 108).TopPosZ(76, 19))
|
||||
ITEM(Button, ok, SetLabel(t_("OK")).LeftPosZ(44, 64).TopPosZ(104, 24))
|
||||
ITEM(Button, cancel, SetLabel(t_("Cancel")).LeftPosZ(112, 64).TopPosZ(104, 24))
|
||||
ITEM(Button, ok, SetLabel(t_("OK")).LeftPosZ(80, 64).TopPosZ(104, 24))
|
||||
ITEM(Button, cancel, SetLabel(t_("Cancel")).LeftPosZ(148, 64).TopPosZ(104, 24))
|
||||
END_LAYOUT
|
||||
|
||||
LAYOUT(TemplateListLayout, 236, 376)
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ public:
|
|||
virtual bool IdeIsDebugLock() const = 0;
|
||||
virtual void IdeSetBar() = 0;
|
||||
virtual void IdeGotoCodeRef(String link) = 0;
|
||||
virtual void IdeMoveTopic(const String& from, const String& to) = 0;
|
||||
virtual void IdeOpenTopicFile(const String& file) = 0;
|
||||
|
||||
virtual ~IdeContext() {}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -524,7 +524,7 @@ public:
|
|||
|
||||
virtual void IdeSetBar();
|
||||
virtual void IdeGotoCodeRef(String coderef);
|
||||
virtual void IdeMoveTopic(const String& from, const String& to);
|
||||
virtual void IdeOpenTopicFile(const String& file);
|
||||
|
||||
enum {
|
||||
EDITING, BUILDING, RUNNING, DEBUGGING,
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ void Ide::OpenTopic(const char *topic)
|
|||
if(designer) {
|
||||
TopicEditor *te = dynamic_cast<TopicEditor *>(&designer->DesignerCtrl());
|
||||
if(te)
|
||||
te->GoTo(tl.topic, doc.GetCurrentLabel());
|
||||
te->GoTo(tl.topic, tl.label);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -97,13 +97,14 @@ void Ide::OpenATopic()
|
|||
OpenTopic(t);
|
||||
}
|
||||
|
||||
void Ide::IdeMoveTopic(const String& from, const String& to)
|
||||
void Ide::IdeOpenTopicFile(const String& file)
|
||||
{
|
||||
if(to != from) {
|
||||
Upp::SaveFile(to, LoadFile(from));
|
||||
FileDelete(from);
|
||||
EditFile(GetFileFolder(file));
|
||||
if(designer) {
|
||||
TopicEditor *te = dynamic_cast<TopicEditor *>(&designer->DesignerCtrl());
|
||||
if(te)
|
||||
te->GoTo(GetFileName(file), "");
|
||||
}
|
||||
OpenTopic(to);
|
||||
}
|
||||
|
||||
void Ide::InsertColor()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue