Skip to content

Commit

Permalink
Added a new category "Bootstrap Containers" and two new items under
Browse files Browse the repository at this point in the history
it, Container palette and Panel palette
  • Loading branch information
tauquir authored and tauquir committed Aug 28, 2017
1 parent 800a3f3 commit 118dd49
Show file tree
Hide file tree
Showing 14 changed files with 968 additions and 3 deletions.
6 changes: 6 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## [<ins>1.2.0 (28-08-2017)</ins>](https://github.com/tauquirahmed93/palette4bootstrap/releases/tag/v1.2.0)
#### Added the following palette items
* **Bootstrap Containers** (NEW)
* Container
* Panel

## [<ins>1.1.0 (15-08-2017)</ins>](https://github.com/tauquirahmed93/palette4bootstrap/releases/tag/v1.1.0)
#### Added the following palette items
* **Bootstrap Typography**
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ This is a module for the [NetBeans IDE](http://netbeans.org/) which adds new pal
* Ionicons
* Carousel
* Google Maps
* **Bootstrap Containers**
* Container
* Panel

-And many more to come soon.

Expand Down
2 changes: 1 addition & 1 deletion manifest.mf
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ AutoUpdate-Show-In-Client: true
OpenIDE-Module: org.tauquir.palette4bootstrap
OpenIDE-Module-Layer: org/tauquir/palette4bootstrap/layer.xml
OpenIDE-Module-Localizing-Bundle: org/tauquir/palette4bootstrap/items/Bundle.properties
OpenIDE-Module-Specification-Version: 1.1.0
OpenIDE-Module-Specification-Version: 1.2.0

28 changes: 28 additions & 0 deletions src/org/tauquir/palette4bootstrap/items/Bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,28 @@ Create other typography related elements like &lt;small&gt;,<br>\
&lt;strong&gt;, &lt;em&gt;, &lt;mark&gt;, &lt;span&gt;, etc<br>\
</html>

# Strings for Container
CONTAINERS.CONTAINER.NAME=Container
CONTAINERS.CONTAINER.HINT=\
<html>\
Bootstrap requires a containing element to wrap site contents and house the grid system.<br>\
You may choose one of two containers to use in your projects<br>\
<ol>\
<li>Use <em>.container</em> for a responsive fixed width container.</li>\
<li>Use <em>.container-fluid</em> for a full width container, spanning the entire width of your viewport.</li>\
</ol><br>\
Note that, due to padding and more, neither container is nestable.<br>\
</html>

# Strings for Container
CONTAINERS.PANEL.NAME=Panel
CONTAINERS.PANEL.HINT=\
<html>\
This is the Bootstrap Panel Component<br>\
Use it to display content inside a customizable<br>\
box which may contain a heading, body and a footer\
</html>

# Strings for Image
MEDIA.IMAGE.NAME=Image
MEDIA.IMAGE.HINT=\
Expand Down Expand Up @@ -422,3 +444,9 @@ MapCustomizer.jLabel18.text=Type
MapCustomizer.jLabel17.text=Zoom
MapCustomizer.jLabel16.text=Coordinates
MapCustomizer.jLabel19.text=Coordinates
ContainerCustomizer.jLabel1.text=Container Type
ContainerCustomizer.jTextArea1.toolTipText=
PanelCustomizer.jLabel2.text=Panel Type
PanelCustomizer.showHeaderCheckBox.text=Show Heading
PanelCustomizer.showBodyCheckBox.text=Show Body
PanelCustomizer.showFooterCheckBox.text=Show Footer
43 changes: 43 additions & 0 deletions src/org/tauquir/palette4bootstrap/items/Container.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* palette4bootstrap - A netbeans palette plugin for the Bootstrap
* Copyright (c) 2017-2018 Tauquir Ahmed ([email protected])
* Licensed under the MIT License.
*/
package org.tauquir.palette4bootstrap.items;

import javax.swing.text.BadLocationException;
import javax.swing.text.JTextComponent;
import org.openide.text.ActiveEditorDrop;
import org.tauquir.palette4bootstrap.bsPaletteUtilities;

public class Container implements ActiveEditorDrop {
private boolean isFluid = false;

public String generateBody() {
StringBuilder sb = new StringBuilder();
sb.append("<div class=\"");
if (isFluid) sb.append("container-fluid");
else sb.append("container");
sb.append("\">\n</div>");
return sb.toString();
}

@Override
public boolean handleTransfer(JTextComponent jtc) {
ContainerCustomizer c = new ContainerCustomizer(this);
boolean accept = c.showDialog();
if (accept) {
String body = generateBody();
try {
bsPaletteUtilities.insert(body, jtc);
} catch (BadLocationException ble) {
accept = false;
}
}
return accept;
}

public void setIsFluid(boolean isFluid) {
this.isFluid = isFluid;
}
}
102 changes: 102 additions & 0 deletions src/org/tauquir/palette4bootstrap/items/ContainerCustomizer.form
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="UTF-8" ?>

<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>

<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane1" min="-2" pref="322" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jComboBox1" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jComboBox1" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jScrollPane1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JComboBox" name="jComboBox1">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="2">
<StringItem index="0" value=".container"/>
<StringItem index="1" value=".container-fluid"/>
</StringArray>
</Property>
</Properties>
<Events>
<EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="jComboBox1ItemStateChanged"/>
</Events>
<AuxValues>
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;String&gt;"/>
</AuxValues>
</Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/tauquir/palette4bootstrap/items/Bundle.properties" key="ContainerCustomizer.jLabel1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/tauquir/palette4bootstrap/items/Bundle.properties" key="Customizer.GeneratedCode" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>

<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTextArea" name="jTextArea1">
<Properties>
<Property name="columns" type="int" value="20"/>
<Property name="rows" type="int" value="5"/>
<Property name="text" type="java.lang.String" value="&lt;div class=&quot;container&quot;&gt;&#xa;&lt;/div&gt;" noResource="true"/>
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/tauquir/palette4bootstrap/items/Bundle.properties" key="ContainerCustomizer.jTextArea1.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>
127 changes: 127 additions & 0 deletions src/org/tauquir/palette4bootstrap/items/ContainerCustomizer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
/*
* palette4bootstrap - A netbeans palette plugin for the Bootstrap
* Copyright (c) 2017-2018 Tauquir Ahmed ([email protected])
* Licensed under the MIT License.
*/
package org.tauquir.palette4bootstrap.items;

import java.awt.Dialog;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import org.openide.DialogDescriptor;
import org.openide.DialogDisplayer;
import org.openide.util.NbBundle;

public class ContainerCustomizer extends javax.swing.JPanel {
private Dialog dialog = null;
private DialogDescriptor descriptor = null;
private boolean dialogOK = false;
private final Container container;
/**
* Creates new form ContainerCustomizer
*/
public ContainerCustomizer(Container container) {
this.container = container;
initComponents();
}

public boolean showDialog() {
dialogOK = false;
descriptor = new DialogDescriptor(this, NbBundle.getMessage(getClass(), "Customizer.InsertPrefix")
+ " " + NbBundle.getMessage(getClass(), "GRID.GRIDCLEARFIX.NAME"), true,
DialogDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION,
new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (descriptor.getValue().equals(DialogDescriptor.OK_OPTION)) {
dialogOK = true;
}
dialog.dispose();
}
});
dialog = DialogDisplayer.getDefault().createDialog(descriptor);
dialog.setResizable(false);
dialog.setVisible(true);
return dialogOK;
}

/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

jComboBox1 = new javax.swing.JComboBox<>();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();

jComboBox1.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { ".container", ".container-fluid" }));
jComboBox1.addItemListener(new java.awt.event.ItemListener() {
public void itemStateChanged(java.awt.event.ItemEvent evt) {
jComboBox1ItemStateChanged(evt);
}
});

org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(ContainerCustomizer.class, "ContainerCustomizer.jLabel1.text")); // NOI18N

org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(ContainerCustomizer.class, "Customizer.GeneratedCode")); // NOI18N

jTextArea1.setColumns(20);
jTextArea1.setRows(5);
jTextArea1.setText("<div class=\"container\">\n</div>"); // NOI18N
jTextArea1.setToolTipText(org.openide.util.NbBundle.getMessage(ContainerCustomizer.class, "ContainerCustomizer.jTextArea1.toolTipText")); // NOI18N
jScrollPane1.setViewportView(jTextArea1);

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 322, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jLabel2))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
}// </editor-fold>//GEN-END:initComponents

private void jComboBox1ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboBox1ItemStateChanged
if (evt.getStateChange() == java.awt.event.ItemEvent.SELECTED) { // Ignore ItemEvent.DESELECTED
if (jComboBox1.getSelectedItem().toString().equals(".container")) {
container.setIsFluid(false);
} else container.setIsFluid(true);
jTextArea1.setText(container.generateBody());
}
}//GEN-LAST:event_jComboBox1ItemStateChanged


// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JComboBox<String> jComboBox1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea jTextArea1;
// End of variables declaration//GEN-END:variables
}
Loading

0 comments on commit 118dd49

Please sign in to comment.