-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a new category "Bootstrap Containers" and two new items under
it, Container palette and Panel palette
- Loading branch information
tauquir
authored and
tauquir
committed
Aug 28, 2017
1 parent
800a3f3
commit 118dd49
Showing
14 changed files
with
968 additions
and
3 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
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
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,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
102
src/org/tauquir/palette4bootstrap/items/ContainerCustomizer.form
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,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="<String>"/> | ||
</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, "{key}")"/> | ||
</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, "{key}")"/> | ||
</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="<div class="container">
</div>" 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, "{key}")"/> | ||
</Property> | ||
</Properties> | ||
</Component> | ||
</SubComponents> | ||
</Container> | ||
</SubComponents> | ||
</Form> |
127 changes: 127 additions & 0 deletions
127
src/org/tauquir/palette4bootstrap/items/ContainerCustomizer.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,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 | ||
} |
Oops, something went wrong.