Skip to content

Commit

Permalink
1)fixed icons for refactoring language (move to folder with robot icons)
Browse files Browse the repository at this point in the history
2)fixed palette for refactoring language
3)added change element type by refactoring
4)added possibility to ignore autosaving by repoApi
5)fixed crach with search group of elements, one element, etc
search of group of elements still work incorrectly
  • Loading branch information
terrwwww committed Oct 29, 2012
1 parent ab15c8e commit 2cc0271
Show file tree
Hide file tree
Showing 16 changed files with 216 additions and 71 deletions.
8 changes: 8 additions & 0 deletions plugins/refactoring/editor/editor.pro
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,11 @@ QREAL_EDITOR_PATH = refactoring/editor
ROOT = ../../..

include (../../editorsSdk/editorsCommon.pri)

win32 {
QMAKE_POST_LINK = "xcopy images ..\\..\\..\\bin\\images /s /e /q /y /i"
}
else {
QMAKE_POST_LINK = "mkdir ../../../bin/images/; cp -r images/* ../../../bin/images/"
}

6 changes: 4 additions & 2 deletions plugins/refactoring/editor/refactoringEditor.pro
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ ROOT = ../../..
include (../../editorsSdk/editorsCommon.pri)

win32 {
QMAKE_POST_LINK = "xcopy ..\\images ..\\..\\..\\..\\bin\\images /s /e /q /y /i"
QMAKE_POST_LINK = "xcopy images ..\\..\\..\\bin\\images /s /e /q /y /i"
}
else {
QMAKE_POST_LINK = "mkdir ../../../../bin/images/; cp -r ../images/* ../../../../bin/images/"
QMAKE_POST_LINK = "mkdir ../../../bin/images/; cp -r images/* ../../../bin/images/"
}



10 changes: 5 additions & 5 deletions plugins/refactoring/editor/refactoringEditor.xml
Original file line number Diff line number Diff line change
Expand Up @@ -208,15 +208,15 @@
</graphicTypes>
<palette>
<group name="Refactoring Rule Elements">
<element name="Refactoring Diagram"/>
<element name="From Before To After"/>
<element name="After Block"/>
<element name="Before Block"/>
<element name="RefactoringDiagramNode"/>
<element name="FromBeforeToAter"/>
<element name="AfterBlock"/>
<element name="BeforeBlock"/>
</group>
<group name="Basic Elements">
<element name="Element"/>
<element name="Link"/>
<element name="Selected segment"/>
<element name="SelectedSegment"/>
</group>
</palette>
</diagram>
Expand Down
28 changes: 26 additions & 2 deletions plugins/refactoring/refactoringSupport/refactoringApplier.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
#include "refactoringApplier.h"
#include <QtCore/QDebug>

using namespace qReal;

QSet<QString> const defaultProperties = (QSet<QString>()
<< "from" << "incomingConnections" << "incomingUsages" << "links"
<< "name" << "outgoingConnections" << "outgoingUsages" << "to");
QSet<QString> const refactoringElements = (QSet<QString>()
<< "Element" << "Link" << "BeforeBlock" << "AfterBlock");

RefactoringApplier::RefactoringApplier(
LogicalModelAssistInterface &logicalModelApi
Expand Down Expand Up @@ -226,8 +229,29 @@ void RefactoringApplier::changePropertiesInModel(Id const &changeFromId, Id cons

void RefactoringApplier::changeElementInModel(const Id &changeFromId, const Id &changeToId)
{
Q_UNUSED(changeFromId);
Q_UNUSED(changeToId);
if (mLogicalModelApi.isLogicalId(changeFromId)) {
return;
}
if (!refactoringElements.contains(changeToId.element())) {
IdList const inLinks = mGraphicalModelApi.mutableGraphicalRepoApi().incomingLinks(changeFromId);
IdList const outLinks = mGraphicalModelApi.mutableGraphicalRepoApi().outgoingLinks(changeFromId);
Id const parentId = mGraphicalModelApi.mutableGraphicalRepoApi().parent(changeFromId);
QVariant const position = mGraphicalModelApi.mutableGraphicalRepoApi().position(changeFromId);
bool const isFromLogicalModel = false;
QString const refactoringsMetamodel = "RefactoringsMetamodel";
QString newEditor = changeToId.editor();
newEditor.chop(refactoringsMetamodel.length());
Id const newId = Id(newEditor, changeToId.diagram(), changeToId.element(), QUuid::createUuid().toString());
Id const newElementId = mGraphicalModelApi.createElement(parentId, newId, isFromLogicalModel, "ololo", position.toPointF());
foreach (Id idLink, inLinks) {
mGraphicalModelApi.mutableGraphicalRepoApi().setTo(idLink, newElementId);
}
foreach (Id idLink, outLinks) {
mGraphicalModelApi.mutableGraphicalRepoApi().setFrom(idLink, newElementId);
}
mGraphicalModelApi.mutableGraphicalRepoApi().removeChild(parentId, changeFromId);
mGraphicalModelApi.mutableGraphicalRepoApi().removeElement(changeFromId);
}
}

void RefactoringApplier::setProperty(Id const &id, QString const &propertyName
Expand Down
59 changes: 41 additions & 18 deletions plugins/refactoring/refactoringSupport/refactoringPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void RefactoringPlugin::init(PluginConfigurator const &configurator)
mRefactoringWindow = new RefactoringWindow(mMainWindowIFace->windowWidget());
connect(mRefactoringWindow, SIGNAL(rejected()), this, SLOT(discardRefactoring()));

mRefactoringRepoApi = new qrRepo::RepoApi(mQRealSourceFilesPath + "/plugins/refactoring/refactoringExamples");
mRefactoringRepoApi = new qrRepo::RepoApi(mQRealSourceFilesPath + "/plugins/refactoring/refactoringExamples", true);
mRefactoringFinder = new RefactoringFinder(configurator.logicalModelApi()
, configurator.graphicalModelApi()
, configurator.mainWindowInterpretersInterface()
Expand Down Expand Up @@ -130,7 +130,6 @@ void RefactoringPlugin::generateRefactoringMetamodel()
}

QDomDocument metamodel = mMetamodelGeneratorSupport->loadMetamodelFromFile(editorMetamodelFilePath);

QDomElement diagram = mMetamodelGeneratorSupport->diagramElement(metamodel);
QDomElement graphics = metamodel.elementsByTagName("graphicTypes").at(0).toElement();
QString const diagramName = diagram.attribute("name").replace(" ", "_");
Expand All @@ -147,9 +146,11 @@ void RefactoringPlugin::generateRefactoringMetamodel()
addRefactoringLanguageElements(diagramName, metamodel, graphics
, mQRealSourceFilesPath + "/plugins/refactoring/editor/refactoringEditor.xml");
mEditorElementNames.clear();

QString metamodelName = diagramName + "RefactoringsMetamodel";
QString relativeEditorPath = diagramName + "RefactoringsEditor";
QString sourceEditorName = editorMetamodelFilePath.split("/", QString::SkipEmptyParts).last();
sourceEditorName.chop(4);
qDebug() << sourceEditorName;
QString metamodelName = sourceEditorName + "RefactoringsMetamodel";
QString relativeEditorPath = sourceEditorName + "RefactoringsEditor";
QString editorPath = mQRealSourceFilesPath + "/plugins/" + relativeEditorPath;

mMetamodelGeneratorSupport->generateProFile(metamodel
Expand All @@ -162,8 +163,7 @@ void RefactoringPlugin::generateRefactoringMetamodel()
, SettingsManager::value("pathToQmake", "").toString()
, SettingsManager::value("pathToMake", "").toString()
, SettingsManager::value("pluginExtension", "").toString()
, SettingsManager::value("prefix", "").toString()
);
, SettingsManager::value("prefix", "").toString());
}

void RefactoringPlugin::insertRefactoringID(QDomDocument metamodel, QDomNodeList const &list, bool isNode)
Expand Down Expand Up @@ -260,10 +260,10 @@ void RefactoringPlugin::saveRefactoring()
}

QDomElement RefactoringPlugin::createPaletteElement(QString const &elementType
, QDomDocument metamodel, QString const &displayedName)
, QDomDocument metamodel, QString const &name)
{
QDomElement element = metamodel.createElement(elementType);
element.setAttribute("name", displayedName);
element.setAttribute("name", name);
return element;
}

Expand All @@ -281,24 +281,38 @@ void RefactoringPlugin::addElementsToMetamodelGroup(QDomDocument metamodel
{
for (int i = 0; i < list.size(); ++i) {
QDomElement element = list.at(i).toElement();
QString const displayedName = element.attribute("displayedName", "");
QDomElement paletteElement = createPaletteElement("element", metamodel, displayedName);
QString name = nameForPaletteGroup(element.attribute("name", ""));
QDomElement paletteElement = createPaletteElement("element", metamodel, name);
metamodelGroup.appendChild(paletteElement);
}
}

QString const RefactoringPlugin::nameForPaletteGroup(QString const &name)
{
QString nameForPaletteGroup = name;
if (nameForPaletteGroup.length() > 0) {
if (nameForPaletteGroup.length() > 1) {
nameForPaletteGroup = nameForPaletteGroup.at(0).toUpper() + nameForPaletteGroup.mid(1);
}
else {
nameForPaletteGroup = nameForPaletteGroup.at(0).toUpper();
}
}
return nameForPaletteGroup;
}

void RefactoringPlugin::addPalette(QDomDocument metamodel, QDomElement diagram
, QDomElement const &metamodelPaletteGroup)
{
QStringList patternGroupNamesList;
patternGroupNamesList << "Refactoring Diagram"
<< "From Before To After"
<< "After Block"
<< "Before Block";
patternGroupNamesList << "RefactoringDiagramNode"
<< "FromBeforeToAter"
<< "AfterBlock"
<< "BeforeBlock";
QStringList basicGroupNamesList;
basicGroupNamesList << "Element"
<< "Link"
<< "Selected segment";
<< "SelectedSegment";
QDomElement palette = metamodel.createElement("palette");
addPaletteGroup(metamodel, palette, "Refactoring Rule Elements", patternGroupNamesList);
addPaletteGroup(metamodel, palette, "Basic Elements", basicGroupNamesList);
Expand All @@ -323,7 +337,7 @@ void RefactoringPlugin::arrangeElements(const QString &algorithm)
mErrorReporter->addCritical(tr("Path to dot is not specified"));
return;
}

mMainWindowIFace->arrangeElementsByDotRunner(algorithm, mQRealSourceFilesPath + "/bin");
}

Expand Down Expand Up @@ -365,7 +379,16 @@ void RefactoringPlugin::findRefactoring(const QString &refactoringName)
}
mCurrentMatch = mMatches.takeFirst();
foreach (Id const &id, mCurrentMatch.keys()) {
mMainWindowIFace->highlight(mCurrentMatch.value(id), false);
Id valueId = mCurrentMatch.value(id);
if (mLogicalModelApi->isLogicalId(valueId)) {
mMainWindowIFace->errorReporter()->addInformation(tr("No graphical elements match"));
mRefactoringWindow->discard();
return;
}
}
foreach (Id const &id, mCurrentMatch.keys()) {
Id valueId = mCurrentMatch.value(id);
mMainWindowIFace->highlight(valueId, false);
}
}
else {
Expand Down
6 changes: 3 additions & 3 deletions plugins/refactoring/refactoringSupport/refactoringPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class RefactoringPlugin : public QObject, public qReal::ToolPluginInterface
virtual void init(qReal::PluginConfigurator const &configurator);
virtual QList<qReal::ActionInfo> actions();

virtual QPair<QString, PreferencesPage *> preferencesPage();
virtual QPair<QString, PreferencesPage *> preferencesPage();

private slots:
/// generate and plugged refactoring metamodel, integrated with chosen metamodel (by user)
Expand Down Expand Up @@ -101,7 +101,7 @@ private slots:


QDomElement createPaletteElement(QString const &elementType
, QDomDocument metamodel, const QString &displayedName);
, QDomDocument metamodel, const QString &name);
QDomElement metamodelPaletteGroup(QDomDocument metamodel
, const QDomNodeList &nodeList, const QDomNodeList &edgeList);

Expand All @@ -111,7 +111,7 @@ private slots:
, QString const &groupName, QStringList const &elementNameList);
void addElementsToMetamodelGroup(QDomDocument metamodel, const QDomNodeList &list
, QDomElement &metamodelGroup);

const QString nameForPaletteGroup(const QString &name);
void arrangeElements(QString const &algorithm);
QList<QPair<Id, QPair<Id, bool> > > findOutsideSelectionLinks();
void removeUnnecessaryLinksFromSelected();
Expand Down
9 changes: 5 additions & 4 deletions qrgui/dotFiles/graph1.dot
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
digraph G {
rankdir=LR;
edeedfcgaaffehggaeeigcbcideceadf -> idecfchdbjgeeadfbfcjdgbfdhegaahc;
cgfdegfdcebdejfcjbjihdbdbdfifafj -> idecfchdbjgeeadfbfcjdgbfdhegaahc;
cgfdegfdcebdejfcjbjihdbdbdfifafj -> jebehfbijhjfehfaaifbfggbbhfiagbd;
jebehfbijhjfehfaaifbfggbbhfiagbd -> bejbjhficadbegabibbgbeabbcjcdcda;
jhdbjfbafifgejbdjdebfeccbfbhfdgd -> fdeacfjhegececaebigfjcehfhdchiaj;
fdeacfjhegececaebigfjcehfhdchiaj -> jbcgefdbffffeicgjdfcehbehdabhadb;
fdeacfjhegececaebigfjcehfhdchiaj -> adbdbcgdceafeifejhchecccadhceefi;
jbcgefdbffffeicgjdfcehbehdabhadb -> jfccfhdbaceeedchjhajafededaebggd;
adbdbcgdceafeifejhchecccadhceefi -> cadjdhdbchheefbabdcfbcfdacbfjfcg;
}
2 changes: 1 addition & 1 deletion qrgui/mainwindow/mainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void MainWindow::connectActions()
connect(mUi->actionNew_Diagram, SIGNAL(triggered()), mProjectManager, SLOT(suggestToCreateDiagram()));
connect(mUi->actionNewProject, SIGNAL(triggered()), mProjectManager, SLOT(openNewWithDiagram()));

connect(mUi->actionImport, SIGNAL(triggered()), mProjectManager, SLOT(suggestToimport()));
connect(mUi->actionImport, SIGNAL(triggered()), mProjectManager, SLOT(suggestToImport()));
connect(mUi->actionDeleteFromDiagram, SIGNAL(triggered()), this, SLOT(deleteFromDiagram()));
connect(mUi->actionCopyElementsOnDiagram, SIGNAL(triggered()), this, SLOT(copyElementsOnDiagram()));
connect(mUi->actionPasteOnDiagram, SIGNAL(triggered()), this, SLOT(pasteOnDiagram()));
Expand Down
3 changes: 2 additions & 1 deletion qrgui/mainwindow/projectManager/projectManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ void ProjectManager::save()
{
// Do not change the method to saveAll - in the current implementation, an empty project in the repository is
// created to initialize the file name with an empty string, which allows the internal state of the file
// name = "" Attempt to save the project in this case result in trash
// name = "" Attempt to save the project in this case result in
// qDebug() << "start save";
mMainWindow->models()->repoControlApi().saveTo(mSaveFilePath);
refreshApplicationStateAfterSave();
}
Expand Down
3 changes: 2 additions & 1 deletion qrrepo/private/classes/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ Object::Object(const Id &id, const Id &parent, const qReal::Id &logicalId)
setParent(parent);
}

Object::Object(const Id &id) : mId(id)
Object::Object(const Id &id)
: mId(id)
{
}

Expand Down
9 changes: 6 additions & 3 deletions qrrepo/private/repoApi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ using namespace qrRepo;
using namespace qrRepo::details;
using namespace qReal;

RepoApi::RepoApi(QString const &workingDirectory)
RepoApi::RepoApi(QString const &workingDirectory, bool ignoreAutosave)
: mClient(workingDirectory)
, mIgnoreAutosave(ignoreAutosave)
{
}

Expand Down Expand Up @@ -403,8 +404,10 @@ void RepoApi::saveAll() const

void RepoApi::saveTo(QString const &workingFile)
{
mClient.setWorkingFile(workingFile);
mClient.saveAll();
if (!mIgnoreAutosave) {
mClient.setWorkingFile(workingFile);
mClient.saveAll();
}
}

void RepoApi::saveDiagramsById(QHash<QString, IdList> const &diagramIds)
Expand Down
5 changes: 3 additions & 2 deletions qrrepo/private/serializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ void Serializer::setWorkingFile(QString const &workingFile)
void Serializer::saveToDisk(QList<Object*> const &objects) const
{
Q_ASSERT_X(!mWorkingFile.isEmpty()
, "Serializer::saveToDisk(...)"
, "may be Client of RepoApi (see Models constructor also) has been initialised with empty filename?");
, "Serializer::saveToDisk(...)"
, "may be Client of RepoApi (see Models constructor also) has been initialised with empty filename?");

foreach (Object *object, objects) {

QString filePath = createDirectory(object->id(), object->logicalId());

QDomDocument doc;
Expand Down
3 changes: 2 additions & 1 deletion qrrepo/repoApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace qrRepo {
class QRREPO_EXPORT RepoApi : public GraphicalRepoApi, public LogicalRepoApi, public RepoControlInterface
{
public:
explicit RepoApi(QString const &workingDirectory);
explicit RepoApi(QString const &workingDirectory, bool ignoreAutosave = false);
// Default destructor ok.

/// replacing property values that contains input value with new value
Expand Down Expand Up @@ -151,6 +151,7 @@ namespace qrRepo {
void removeLinkEnds(QString const &endName, qReal::Id const &id);

details::Client mClient;
bool mIgnoreAutosave;
};

}
2 changes: 1 addition & 1 deletion qrtest/unitTests/unittestDeclaration.cfg
Original file line number Diff line number Diff line change
@@ -1 +1 @@
UNIT_TEST = FALSE
UNIT_TEST = TRUE
Loading

0 comments on commit 2cc0271

Please sign in to comment.