Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #80 - Added parameterized default function and variable namesp…
…ace per xquery flavour type.
- Loading branch information
Showing
16 changed files
with
390 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* Copyright 2013-2014 Grzegorz Ligas <ligasgr@gmail.com> and other contributors | ||
* (see the CONTRIBUTORS file). | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.intellij.xquery; | ||
|
||
public enum XQueryFlavour { | ||
STANDARD_30("XQuery 3.0 Standard"), | ||
BASEX("BaseX"), | ||
EXIST("eXist"), | ||
MARKLOGIC("MarkLogic"), | ||
SAXON("Saxon"), | ||
SEDNA("Sedna"), | ||
ZORBA("Zorba"); | ||
|
||
private final String presentableName; | ||
|
||
XQueryFlavour(String presentableName) { | ||
this.presentableName = presentableName; | ||
} | ||
|
||
public String getPresentableName() { | ||
return presentableName; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
src/main/java/org/intellij/xquery/settings/OtherOptionsPanel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Copyright 2013-2014 Grzegorz Ligas <ligasgr@gmail.com> and other contributors | ||
* (see the CONTRIBUTORS file). | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.intellij.xquery.settings; | ||
|
||
import com.intellij.openapi.ui.LabeledComponent; | ||
import com.intellij.ui.ListCellRendererWrapper; | ||
import com.intellij.ui.SortedComboBoxModel; | ||
import net.miginfocom.swing.MigLayout; | ||
import org.intellij.xquery.XQueryFlavour; | ||
|
||
import javax.swing.*; | ||
import java.util.Comparator; | ||
|
||
public class OtherOptionsPanel extends SettingsPanel { | ||
|
||
private final LabeledComponent<JComboBox> xqueryFlavour; | ||
private final SortedComboBoxModel<Object> xqueryFlavourModel = comboBoxModel(); | ||
private final XQueryFlavour defaultFlavour; | ||
|
||
public OtherOptionsPanel(XQueryFlavour defaultFlavour) { | ||
this.defaultFlavour = defaultFlavour; | ||
setLayout(new MigLayout("ins 0, gap 5, fill, flowy")); | ||
xqueryFlavour = UIUtils.comboBox("&XQuery flavour", "xqueryFlavour", xqueryFlavourModel); | ||
xqueryFlavour.getComponent().setRenderer(new XQueryFlavourRenderer()); | ||
add(xqueryFlavour); | ||
setBorder(BorderFactory.createTitledBorder("Other options")); | ||
populateFlavourList(defaultFlavour); | ||
} | ||
|
||
private void populateFlavourList(XQueryFlavour defaultFlavour) { | ||
for (XQueryFlavour flavour : XQueryFlavour.values()) { | ||
xqueryFlavourModel.add(flavour); | ||
} | ||
xqueryFlavourModel.setSelectedItem(defaultFlavour); | ||
} | ||
|
||
@Override | ||
public XQuerySettings updateSettings(XQuerySettings settings) { | ||
settings.setFlavour((XQueryFlavour) xqueryFlavour.getComponent().getSelectedItem()); | ||
return settings; | ||
} | ||
|
||
@Override | ||
public void updatePanel(XQuerySettings settings) { | ||
if (settings.getFlavour() != null) { | ||
xqueryFlavour.getComponent().setSelectedItem(settings.getFlavour()); | ||
} else { | ||
xqueryFlavour.getComponent().setSelectedItem(defaultFlavour); | ||
} | ||
} | ||
|
||
private class XQueryFlavourRenderer extends ListCellRendererWrapper<XQueryFlavour> { | ||
|
||
@Override | ||
public void customize(JList list, XQueryFlavour value, int index, boolean selected, boolean hasFocus) { | ||
setText(value.getPresentableName()); | ||
} | ||
} | ||
|
||
private SortedComboBoxModel<Object> comboBoxModel() { | ||
return new SortedComboBoxModel<Object>(new Comparator<Object>() { | ||
@Override | ||
public int compare(Object o1, Object o2) { | ||
return ((XQueryFlavour) o1).getPresentableName().compareToIgnoreCase(((XQueryFlavour) o2).getPresentableName()); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright 2013-2014 Grzegorz Ligas <ligasgr@gmail.com> and other contributors | ||
* (see the CONTRIBUTORS file). | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.intellij.xquery.settings; | ||
|
||
import com.intellij.openapi.ui.LabeledComponent; | ||
import com.intellij.ui.SortedComboBoxModel; | ||
|
||
import javax.swing.*; | ||
import java.util.Comparator; | ||
|
||
public class UIUtils { | ||
static SortedComboBoxModel<Object> comboBoxModel() { | ||
return new SortedComboBoxModel<Object>(new Comparator<Object>() { | ||
@Override | ||
public int compare(Object o1, Object o2) { | ||
return ((String) o1).compareToIgnoreCase((String) o2); | ||
} | ||
}); | ||
} | ||
|
||
static LabeledComponent<JComboBox> comboBox(String text, String name, SortedComboBoxModel<Object> model) { | ||
LabeledComponent<JComboBox> comboBox = new LabeledComponent<JComboBox>(); | ||
comboBox.setText(text); | ||
comboBox.setLabelLocation("West"); | ||
comboBox.setComponent(new JComboBox()); | ||
comboBox.getComponent().setName(name); | ||
comboBox.getComponent().setModel(model); | ||
return comboBox; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.