Java Code Examples for javax.swing.JCheckBox#isSelected()

The following examples show how to use javax.swing.JCheckBox#isSelected() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExerciseCheckBoxService.java    From tmc-intellij with MIT License 6 votes vote down vote up
public static List<Exercise> filterDownloads(
        CustomCheckBoxList checkBoxes, List<Exercise> exercises) {
    logger.info("Filtering exercises. @ExerciseCheckBoxService");

    List<Exercise> downloadThese = new ArrayList<>();
    
    for (JCheckBox box : checkBoxes) {
        if (box.isSelected()) {
            for (Exercise ex : exercises) {
                if (box.getText().equals(ex.getName())) {
                    downloadThese.add(ex);
                }
            }
        }
    }
    return downloadThese;
}
 
Example 2
Source File: DefaultBandChoosingStrategy.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
private void checkSelectedBandsAndGrids() {
    final List<Band> bands = new ArrayList<>();
    final List<TiePointGrid> grids = new ArrayList<>();
    for (int i = 0; i < checkBoxes.length; i++) {
        JCheckBox checkBox = checkBoxes[i];
        if (checkBox.isSelected()) {
            if (allBands.length > i) {
                bands.add(allBands[i]);
            } else {
                grids.add(allTiePointGrids[i - allBands.length]);
            }
        }
    }
    selectedBands = bands.toArray(new Band[bands.size()]);
    selectedTiePointGrids = grids.toArray(new TiePointGrid[grids.size()]);
}
 
Example 3
Source File: JWTInterceptTabController.java    From JWT4B with GNU General Public License v3.0 6 votes vote down vote up
private void cveAttackChanged() {
	JCheckBox jcb = jwtST.getCVEAttackCheckBox();
	cveAttackMode = jcb.isSelected();
	jwtST.getNoneAttackComboBox().setEnabled(!cveAttackMode);
	jwtST.getRdbtnDontModify().setEnabled(!cveAttackMode);
	jwtST.getRdbtnOriginalSignature().setEnabled(!cveAttackMode);
	jwtST.getRdbtnRandomKey().setEnabled(!cveAttackMode);
	jwtST.getRdbtnRecalculateSignature().setEnabled(!cveAttackMode);
	jwtST.setKeyFieldState(!cveAttackMode);
	jwtST.getCVECopyBtn().setVisible(cveAttackMode);
	if (cveAttackMode) {
		jwtST.getRdbtnDontModify().setSelected(true);
		jwtST.getRdbtnOriginalSignature().setSelected(false);
		jwtST.getRdbtnRandomKey().setSelected(false);
		jwtST.getRdbtnRecalculateSignature().setSelected(false);
	} else {
		jwtST.setKeyFieldValue("");
		jwtST.setKeyFieldState(false);
	}
}
 
Example 4
Source File: MuleModulesCheckBoxList.java    From mule-intellij-plugins with Apache License 2.0 5 votes vote down vote up
public Module[] getSelectedModules(Project p) {
    List<Module> selectedModules = new ArrayList<>();
    DefaultListModel<JCheckBox> myModel = (DefaultListModel<JCheckBox>)getModel();
    Enumeration<JCheckBox> elements = myModel.elements();
    while (elements.hasMoreElements()) {
        JCheckBox nextElement = elements.nextElement();
        if (nextElement.isSelected()) {
            String name = nextElement.getText();
            Module m = ModuleManager.getInstance(p).findModuleByName(name);
            selectedModules.add(m);
        }
    }

    return selectedModules.toArray(new Module[] {});
}
 
Example 5
Source File: ListDemo.java    From beautyeye with Apache License 2.0 5 votes vote down vote up
public void actionPerformed(ActionEvent e) {
    JCheckBox cb = (JCheckBox) e.getSource();
    if(cb.isSelected()) {
	listModel.addSuffix(cb.getText());
    } else {
	listModel.removeSuffix(cb.getText());
    }
}
 
Example 6
Source File: UnitEditorDialog.java    From megamek with GNU General Public License v2.0 5 votes vote down vote up
public int getHits() {
    int hits = 0;
    for (JCheckBox check : checks) {
        if (check.isSelected()) {
            hits++;
        }
    }
    return hits;
}
 
Example 7
Source File: JCheckBoxBuilderTest.java    From triplea with GNU General Public License v3.0 5 votes vote down vote up
@Test
void boundToSettingReturningTrue() {
  final JCheckBox checkBox = givenBoxBoundToSetting(true);

  final boolean result = checkBox.isSelected();

  assertThat(result, is(true));
}
 
Example 8
Source File: MatchOptions.java    From AML-Project with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(ActionEvent e)
{
	Object o = e.getSource();
	if(o == cancel)
		this.dispose();
	else if(o == match)
	{
		if(aml.hasAlignment())
			aml.closeAlignment();
		setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
		aml.setThreshold((Double)threshold.getSelectedItem());
		Vector<MatchStep> selection = new Vector<MatchStep>();
		for(JCheckBox c : matchers)
			if(c.isSelected())
				selection.add(MatchStep.parseStep(c.getText()));
		aml.setMatchSteps(selection);
		//Then match the ontologies
		c = new Console();
		c.addWindowListener(this);
		console = new Thread(c);
		console.start();
		action = new Thread(this);
		action.start();
	}
	else if(o == detail)
	{
		new DetailedOptions();
	}
}
 
Example 9
Source File: CertificateTab.java    From SAMLRaider with MIT License 5 votes vote down vote up
public List<String> getKeyUsage() {
	List<String> keyUsage = new LinkedList<>();
	for (JCheckBox j : jbxKeyUsages) {
		if (j.isSelected()) {
			keyUsage.add(j.getText());
		}
	}
	return keyUsage;
}
 
Example 10
Source File: ContextView.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@NbBundle.Messages({
    "TTL_ContextView_showBigFile=Show Big File?",
    "# {0} - file name",
    "# {1} - file size in kilobytes",
    "MSG_ContextView_showBigFile=File {0} is quite big ({1} kB).\n"
    + "Showing it can cause memory and performance problems.\n"
    + "Do you want to show content of this file?",
    "LBL_ContextView_Show=Show",
    "LBL_ContextView_Skip=Do Not Show",
    "LBL_ContextView_ApplyAll=Apply to all big files"
})
private void approveFetchingOfBigFile(final MatchingObject mo,
        final int partIndex) {
    FileObject fo = mo.getFileObject();
    long fileSize = fo.getSize() / 1024;
    JButton showButton = new JButton(Bundle.LBL_ContextView_Show());
    JButton skipButton = new JButton(Bundle.LBL_ContextView_Skip());
    JCheckBox all = new JCheckBox(Bundle.LBL_ContextView_ApplyAll());
    all.setSelected(approveApplyToAllSelected);
    JPanel allPanel = new JPanel();
    allPanel.add(all); //Add to panel not to be handled as standard button.
    NotifyDescriptor nd = new NotifyDescriptor(
            Bundle.MSG_ContextView_showBigFile(
            fo.getNameExt(), fileSize),
            Bundle.TTL_ContextView_showBigFile(),
            NotifyDescriptor.YES_NO_OPTION,
            NotifyDescriptor.WARNING_MESSAGE,
            new Object[]{skipButton, showButton},
            lastApproveOption ? showButton : skipButton);
    nd.setAdditionalOptions(new Object[]{allPanel});
    DialogDisplayer.getDefault().notify(nd);
    boolean app = nd.getValue() == showButton;
    APPROVED_FILES.put(fo, app);
    if (all.isSelected()) {
        allApproved = app;
    }
    approveApplyToAllSelected = all.isSelected();
    lastApproveOption = app;
    displayFile(mo, partIndex);
}
 
Example 11
Source File: KubernetesConfigurable.java    From intellij-kubernetes with Apache License 2.0 5 votes vote down vote up
/**
 * Create an {@link ApiPackage} object from the "enable completion" and "version" UI elements.
 *
 * @param enableCompletion the enable completion check box.
 * @param versions the version combo box selector.
 * @return an {@code ApiPackage} configured from the UI.
 */
@NotNull
private static ApiPackage makeApiPackage(final JCheckBox enableCompletion, final JComboBox<String> versions) {
    final ApiPackage kubernetesPackage = new ApiPackage(enableCompletion.isSelected(), null);
    if (!Objects.equals(versions.getSelectedItem(), LATEST_API_VERSION_ITEM)) {
        kubernetesPackage.setVersion((String) versions.getSelectedItem());
    }
    return kubernetesPackage;
}
 
Example 12
Source File: IsLikeActionListener.java    From HBaseClient with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void stateChanged(ChangeEvent e)
{
    JCheckBox v_IsLike = (JCheckBox)e.getSource();
    
    if ( v_IsLike.isSelected() )
    {
        v_IsLike.setText("精确");
    }
    else
    {
        v_IsLike.setText("模糊");
    }
}
 
Example 13
Source File: IDEValidation.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** Test creation of java project. 
 * - open New Project wizard from main menu (File|New Project)
 * - select Java Application project from Standard category
 * - in the next panel type project name and project location in
 * - finish the wizard
 * - wait until project appears in projects view
 * - wait classpath scanning finished
 */
public void testNewProject() {
    NewProjectWizardOperator.invoke().cancel();
    NewProjectWizardOperator npwo = NewProjectWizardOperator.invoke();
    // "Standard"
    String standardLabel = Bundle.getStringTrimmed("org.netbeans.modules.java.j2seproject.ui.wizards.Bundle", "Templates/Project/Standard");
    npwo.selectCategory(standardLabel);
    // "Java Application"
    String javaApplicationLabel = Bundle.getStringTrimmed("org.netbeans.modules.java.j2seproject.ui.wizards.Bundle", "template_app");
    npwo.selectProject(javaApplicationLabel);
    npwo.next();
    NewJavaProjectNameLocationStepOperator npnlso = new NewJavaProjectNameLocationStepOperator();
    npnlso.txtProjectName().setText(SAMPLE_PROJECT_NAME);
    npnlso.txtProjectLocation().setText(System.getProperty("netbeans.user")); // NOI18N
    npnlso.btFinish().pushNoBlock();
    npnlso.getTimeouts().setTimeout("ComponentOperator.WaitStateTimeout", 120000);
    npnlso.waitClosed();
    // wait project appear in projects view
    new ProjectsTabOperator().getProjectRootNode(SAMPLE_PROJECT_NAME);

    //disable the compile on save:
    ProjectsTabOperator.invoke().getProjectRootNode(SAMPLE_PROJECT_NAME).properties();
    // "Project Properties"
    String projectPropertiesTitle = Bundle.getStringTrimmed("org.netbeans.modules.java.j2seproject.ui.customizer.Bundle", "LBL_Customizer_Title");
    NbDialogOperator propertiesDialogOper = new NbDialogOperator(projectPropertiesTitle);
    // select "Compile" category
    String buildCategoryTitle = Bundle.getStringTrimmed("org.netbeans.modules.java.j2seproject.ui.customizer.Bundle", "LBL_Config_BuildCategory");
    String compileCategoryTitle = Bundle.getStringTrimmed("org.netbeans.modules.java.j2seproject.ui.customizer.Bundle", "LBL_Config_Build");
    new Node(new Node(new JTreeOperator(propertiesDialogOper), buildCategoryTitle), compileCategoryTitle).select();
    // actually disable the quick run:
    String compileOnSaveLabel = Bundle.getStringTrimmed("org.netbeans.modules.java.j2seproject.ui.customizer.Bundle", "CustomizerCompile.CompileOnSave");
    JCheckBox cb = JCheckBoxOperator.waitJCheckBox((Container) propertiesDialogOper.getSource(), compileOnSaveLabel, true, true);
    if (cb.isSelected()) {
        cb.doClick();
    }
    // confirm properties dialog
    propertiesDialogOper.ok();

    // wait classpath scanning finished
    WatchProjects.waitScanFinished();
}
 
Example 14
Source File: FlowExtension.java    From burp-flow with MIT License 4 votes vote down vote up
private void flowFilterCaptureSourceOnly(JCheckBox which) {

        if (which != flowFilterCaptureSourceTargetOnly && flowFilterCaptureSourceTargetOnly.isSelected()) {
            flowFilterCaptureSourceTargetOnly.setSelected(false);
            flowFilterCaptureSourceTarget.setSelected(flowFilterCaptureSourceTargetOnlyOrig);
        }
        if (which != flowFilterCaptureSourceProxyOnly && flowFilterCaptureSourceProxyOnly.isSelected()) {
            flowFilterCaptureSourceProxyOnly.setSelected(false);
            flowFilterCaptureSourceProxy.setSelected(flowFilterCaptureSourceProxyOnlyOrig);
        }
        if (which != flowFilterCaptureSourceSpiderOnly && flowFilterCaptureSourceSpiderOnly.isSelected()) {
            flowFilterCaptureSourceSpiderOnly.setSelected(false);
            flowFilterCaptureSourceSpider.setSelected(flowFilterCaptureSourceSpiderOnlyOrig);
        }
        if (which != flowFilterCaptureSourceScannerOnly && flowFilterCaptureSourceScannerOnly.isSelected()) {
            flowFilterCaptureSourceScannerOnly.setSelected(false);
            flowFilterCaptureSourceScanner.setSelected(flowFilterCaptureSourceScannerOnlyOrig);
        }
        if (which != flowFilterCaptureSourceRepeaterOnly && flowFilterCaptureSourceRepeaterOnly.isSelected()) {
            flowFilterCaptureSourceRepeaterOnly.setSelected(false);
            flowFilterCaptureSourceRepeater.setSelected(flowFilterCaptureSourceRepeaterOnlyOrig);
        }
        if (which != flowFilterCaptureSourceIntruderOnly && flowFilterCaptureSourceIntruderOnly.isSelected()) {
            flowFilterCaptureSourceIntruderOnly.setSelected(false);
            flowFilterCaptureSourceIntruder.setSelected(flowFilterCaptureSourceIntruderOnlyOrig);
        }
        if (which != flowFilterCaptureSourceExtenderOnly && flowFilterCaptureSourceExtenderOnly.isSelected()) {
            flowFilterCaptureSourceExtenderOnly.setSelected(false);
            flowFilterCaptureSourceExtender.setSelected(flowFilterCaptureSourceExtenderOnlyOrig);
        }

        if (which == flowFilterCaptureSourceTargetOnly && !flowFilterCaptureSourceTargetOnly.isSelected()) {
            flowFilterCaptureSourceTarget.setSelected(flowFilterCaptureSourceTargetOnlyOrig);
        }
        if (which == flowFilterCaptureSourceProxyOnly && !flowFilterCaptureSourceProxyOnly.isSelected()) {
            flowFilterCaptureSourceProxy.setSelected(flowFilterCaptureSourceProxyOnlyOrig);
        }
        if (which == flowFilterCaptureSourceSpiderOnly && !flowFilterCaptureSourceSpiderOnly.isSelected()) {
            flowFilterCaptureSourceSpider.setSelected(flowFilterCaptureSourceSpiderOnlyOrig);
        }
        if (which == flowFilterCaptureSourceScannerOnly && !flowFilterCaptureSourceScannerOnly.isSelected()) {
            flowFilterCaptureSourceScanner.setSelected(flowFilterCaptureSourceScannerOnlyOrig);
        }
        if (which == flowFilterCaptureSourceRepeaterOnly && !flowFilterCaptureSourceRepeaterOnly.isSelected()) {
            flowFilterCaptureSourceRepeater.setSelected(flowFilterCaptureSourceRepeaterOnlyOrig);
        }
        if (which == flowFilterCaptureSourceIntruderOnly && !flowFilterCaptureSourceIntruderOnly.isSelected()) {
            flowFilterCaptureSourceIntruder.setSelected(flowFilterCaptureSourceIntruderOnlyOrig);
        }
        if (which == flowFilterCaptureSourceExtenderOnly && !flowFilterCaptureSourceExtenderOnly.isSelected()) {
            flowFilterCaptureSourceExtender.setSelected(flowFilterCaptureSourceExtenderOnlyOrig);
        }

        if (which.isSelected()) {
            flowFilterCaptureSourceTarget.setEnabled(false);
            flowFilterCaptureSourceTarget.setSelected(which == flowFilterCaptureSourceTargetOnly);
            flowFilterCaptureSourceProxy.setEnabled(false);
            flowFilterCaptureSourceProxy.setSelected(which == flowFilterCaptureSourceProxyOnly);
            flowFilterCaptureSourceSpider.setEnabled(false);
            flowFilterCaptureSourceSpider.setSelected(which == flowFilterCaptureSourceSpiderOnly);
            flowFilterCaptureSourceScanner.setEnabled(false);
            flowFilterCaptureSourceScanner.setSelected(which == flowFilterCaptureSourceScannerOnly);
            flowFilterCaptureSourceRepeater.setEnabled(false);
            flowFilterCaptureSourceRepeater.setSelected(which == flowFilterCaptureSourceRepeaterOnly);
            flowFilterCaptureSourceIntruder.setEnabled(false);
            flowFilterCaptureSourceIntruder.setSelected(which == flowFilterCaptureSourceIntruderOnly);
            flowFilterCaptureSourceExtender.setEnabled(false);
            flowFilterCaptureSourceExtender.setSelected(which == flowFilterCaptureSourceExtenderOnly);
        } else {
            flowFilterCaptureSourceTarget.setSelected(flowFilterCaptureSourceTargetOnlyOrig);
            flowFilterCaptureSourceTarget.setEnabled(true);
            flowFilterCaptureSourceProxy.setSelected(flowFilterCaptureSourceProxyOnlyOrig);
            flowFilterCaptureSourceProxy.setEnabled(true);
            flowFilterCaptureSourceSpider.setSelected(flowFilterCaptureSourceSpiderOnlyOrig);
            flowFilterCaptureSourceSpider.setEnabled(true);
            flowFilterCaptureSourceScanner.setSelected(flowFilterCaptureSourceScannerOnlyOrig);
            flowFilterCaptureSourceScanner.setEnabled(!burpFree);
            flowFilterCaptureSourceRepeater.setSelected(flowFilterCaptureSourceRepeaterOnlyOrig);
            flowFilterCaptureSourceRepeater.setEnabled(true);
            flowFilterCaptureSourceIntruder.setSelected(flowFilterCaptureSourceIntruderOnlyOrig);
            flowFilterCaptureSourceIntruder.setEnabled(true);
            flowFilterCaptureSourceExtender.setSelected(flowFilterCaptureSourceExtenderOnlyOrig);
            flowFilterCaptureSourceExtender.setEnabled(true);
        }

        flowFilterUpdateDescription(true);
    }
 
Example 15
Source File: VideoClip.java    From osp with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Creates a new object.
 *
 * @param control the XMLControl with the object data
 * @return the newly created object
 */
public Object createObject(XMLControl control) {
  // load the video and return a new clip
  boolean hasVideo = control.getPropertyNames().contains("video"); //$NON-NLS-1$
  if(!hasVideo) {
    return new VideoClip(null);
  }
  ResourceLoader.addSearchPath(control.getString("basepath")); //$NON-NLS-1$
  XMLControl child = control.getChildControl("video"); //$NON-NLS-1$
  String path = child.getString("path"); //$NON-NLS-1$
  Video video = VideoIO.getVideo(path, null);
  boolean engineChange = false;
  if (video==null && path!=null && !VideoIO.isCanceled()) {
  	if (ResourceLoader.getResource(path)!=null) { // resource exists but not loaded
     OSPLog.info("\""+path+"\" could not be opened");                                                  //$NON-NLS-1$ //$NON-NLS-2$
     // determine if other engines are available for the video extension
     ArrayList<VideoType> otherEngines = new ArrayList<VideoType>();
     String engine = VideoIO.getEngine();
     String ext = XML.getExtension(path);        
     if (!engine.equals(VideoIO.ENGINE_XUGGLE)) {
     	VideoType xuggleType = VideoIO.getVideoType("Xuggle", ext); //$NON-NLS-1$
     	if (xuggleType!=null) otherEngines.add(xuggleType);
     }
     if (otherEngines.isEmpty()) {
      JOptionPane.showMessageDialog(null, 
      		MediaRes.getString("VideoIO.Dialog.BadVideo.Message")+"\n\n"+path, //$NON-NLS-1$ //$NON-NLS-2$
      		MediaRes.getString("VideoClip.Dialog.BadVideo.Title"),                                          //$NON-NLS-1$
          JOptionPane.WARNING_MESSAGE); 
     }
     else {
   		// provide immediate way to open with other engines
 			JCheckBox changePreferredEngine = new JCheckBox(MediaRes.getString("VideoIO.Dialog.TryDifferentEngine.Checkbox")); //$NON-NLS-1$
     	video = VideoIO.getVideo(path, otherEngines, changePreferredEngine, null);
  		engineChange = changePreferredEngine.isSelected();
   	if (video!=null && changePreferredEngine.isSelected()) {
   		String typeName = video.getClass().getSimpleName();
   		String newEngine = typeName.indexOf("Xuggle")>-1? VideoIO.ENGINE_XUGGLE: //$NON-NLS-1$
   			VideoIO.ENGINE_NONE;
   		VideoIO.setEngine(newEngine);
   	}	        	
     }
  	}
  	else {
     int response = JOptionPane.showConfirmDialog(null, "\""+path+"\" "                                //$NON-NLS-1$ //$NON-NLS-2$
       +MediaRes.getString("VideoClip.Dialog.VideoNotFound.Message"),                                  //$NON-NLS-1$
         MediaRes.getString("VideoClip.Dialog.VideoNotFound.Title"),                                   //$NON-NLS-1$
           JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
     if(response==JOptionPane.YES_OPTION) {
     	VideoIO.getChooser().setAccessory(VideoIO.videoEnginePanel);
 	    VideoIO.videoEnginePanel.reset();
       VideoIO.getChooser().setSelectedFile(new File(path));
       java.io.File[] files = VideoIO.getChooserFiles("open video");                                         //$NON-NLS-1$
       if(files!=null && files.length>0) {
         VideoType selectedType = VideoIO.videoEnginePanel.getSelectedVideoType();
       	path = XML.getAbsolutePath(files[0]);
         video = VideoIO.getVideo(path, selectedType);
       }
     }
  	}
  }
  if (video!=null) {
    Collection<?> filters = (Collection<?>) child.getObject("filters"); //$NON-NLS-1$
    if(filters!=null) {
      video.getFilterStack().clear();
      Iterator<?> it = filters.iterator();
      while(it.hasNext()) {
        Filter filter = (Filter) it.next();
        video.getFilterStack().addFilter(filter);
      }
    }
    if (video instanceof ImageVideo) {
    	double dt = child.getDouble("delta_t"); //$NON-NLS-1$
    	if (!Double.isNaN(dt)) {
    		((ImageVideo)video).setFrameDuration(dt);
    	}
    }
    
  }
  VideoClip clip = new VideoClip(video);
  clip.changeEngine = engineChange;
  if (path!=null) {
  	if (!path.startsWith("/") && path.indexOf(":")==-1) { //$NON-NLS-1$ //$NON-NLS-2$
  		// convert path to absolute 
    	String base = control.getString("basepath"); //$NON-NLS-1$
  		path = XML.getResolvedPath(path, base);
  	}
  	clip.videoPath = path;
  }
  return clip;
}
 
Example 16
Source File: FmtOptions.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void storeData(JComponent jc, String optionID, Preferences node) {

            if (jc instanceof JTextField) {
                JTextField field = (JTextField) jc;

                String text = field.getText();

                // XXX test for numbers
                if (isInteger(optionID)) {
                    try {
                        Integer.parseInt(text);
                    } catch (NumberFormatException e) {
                        return;
                    }
                }

                // XXX: watch out, tabSize, spacesPerTab, indentSize and expandTabToSpaces
                // fall back on getGlopalXXX() values and not getDefaultAsXXX value,
                // which is why we must not remove them. Proper solution would be to
                // store formatting preferences to MimeLookup and not use NbPreferences.
                // The problem currently is that MimeLookup based Preferences do not support subnodes.
                if (!optionID.equals(TAB_SIZE)
                        && !optionID.equals(SPACES_PER_TAB) && !optionID.equals(INDENT_SIZE)
                        && getDefaultAsString(optionID).equals(text)) {
                    node.remove(optionID);
                } else {
                    node.put(optionID, text);
                }
            } else if (jc instanceof JCheckBox) {
                JCheckBox checkBox = (JCheckBox) jc;
                if (!optionID.equals(EXPAND_TAB_TO_SPACES) && getDefaultAsBoolean(optionID) == checkBox.isSelected()) {
                    node.remove(optionID);
                } else {
                    node.putBoolean(optionID, checkBox.isSelected());
                }
            } else if (jc instanceof JComboBox) {
                JComboBox cb = (JComboBox) jc;
                ComboItem comboItem = ((ComboItem) cb.getSelectedItem());
                String value = comboItem == null ? getDefaultAsString(optionID) : comboItem.value;

                if (getDefaultAsString(optionID).equals(value)) {
                    node.remove(optionID);
                } else {
                    node.put(optionID, value);
                }
            }
        }
 
Example 17
Source File: NextReports.java    From nextreports-designer with Apache License 2.0 4 votes vote down vote up
public static void showStartDialog(boolean test) {

        JPanel bottomPanel = new JPanel();
        bottomPanel.setLayout(new BoxLayout(bottomPanel, BoxLayout.X_AXIS));
        final JCheckBox chk = new JCheckBox(I18NSupport.getString("start.panel.show.startup"), true);
        bottomPanel.add(chk);
        bottomPanel.add(Box.createHorizontalGlue());
        String start = ReporterPreferencesManager.getInstance().loadParameter(ReporterPreferencesManager.SHOW_AT_STARTUP + "_" + ReleaseInfo.getVersion());
        if (test && "false".equals(start)) {
            return;
        }

        HelpMovieAction helpAction = new HelpMovieAction();
        VistaButton buttonHelp = new VistaButton(helpAction, I18NSupport.getString("start.panel.help"));
        ImportAction importAction = new ImportAction();
        VistaButton buttonImport = new VistaButton(importAction, I18NSupport.getString("start.panel.import"));
        AddDataSourceAction dataSourceAction = new AddDataSourceAction();
        VistaButton buttonDataSource = new VistaButton(dataSourceAction, I18NSupport.getString("start.panel.datasource"));
        WizardAction wizardAction = new WizardAction(Globals.getMainFrame().getQueryBuilderPanel().getTree());
        VistaButton buttonWizard = new VistaButton(wizardAction, I18NSupport.getString("start.panel.wizard"));

        List<VistaButton> list = new ArrayList<VistaButton>();
        list.add(buttonHelp);
        list.add(buttonImport);
        list.add(buttonDataSource);
        list.add(buttonWizard);

        VistaDialogContent content = new VistaDialogContent(list, I18NSupport.getString("start.panel.title"),
                I18NSupport.getString("start.panel.subtitle"));
        VistaDialog dialog = new VistaDialog(content, bottomPanel, Globals.getMainFrame(), true) {
        	
			private static final long serialVersionUID = 1L;

			@Override
            protected void beforeDispose() {
                String show = chk.isSelected() ? "true" : "false";
                ReporterPreferencesManager.getInstance().storeParameter(ReporterPreferencesManager.SHOW_AT_STARTUP + "_" + ReleaseInfo.getVersion(), show);
            }
            
        };
        dialog.setTitle(I18NSupport.getString("menu.startup"));
        dialog.selectButton(buttonHelp);

        dialog.setDispose(true);
        dialog.setEscapeOption(true);

        dialog.pack();
        dialog.setResizable(false);
        Show.centrateComponent(Globals.getMainFrame(), dialog);
        dialog.setVisible(true);
    }
 
Example 18
Source File: SettingsPage.java    From xdm with GNU General Public License v2.0 4 votes vote down vote up
private void saveQueue() {
	int index = qList.getSelectedIndex();
	if (index < 0)
		return;
	DownloadQueue q = queueModel.getElementAt(index);
	if (txtQueueName.getText().length() > 0) {
		q.setName(txtQueueName.getText());
	}
	if (chkQStart.isSelected()) {

		q.setStartTime(DateTimeUtils.getTimePart(spinnerDateModel1.getDate()));
		System.out.println(spinnerDateModel1.getDate());
		if (chkQStop.isSelected()) {
			q.setEndTime(DateTimeUtils.getTimePart(spinnerDateModel2.getDate()));
		} else {
			q.setEndTime(-1);
		}
		if (radOnetime.isSelected()) {
			q.setPeriodic(false);
			q.setExecDate(spinnerDateModel3.getDate());
			q.setDayMask(0);
		} else {
			q.setPeriodic(true);
			q.setExecDate(null);
			int dayMask = 0;
			int mask = 0x01;
			for (int i = 1; i <= 7; i++) {
				JCheckBox chk = chkDays[i - 1];
				if (chk.isSelected()) {
					dayMask |= mask;
				}
				mask = mask << 1;
			}
			q.setDayMask(dayMask);
		}
	} else {
		q.setStartTime(-1);
	}

	ArrayList<String> newOrder = new ArrayList<String>(queuedItemsModel.size());

	for (int i = 0; i < queuedItemsModel.size(); i++) {
		newOrder.add(queuedItemsModel.get(i));
	}

	q.reorderItems(newOrder);

	QueueManager.getInstance().saveQueues();
}
 
Example 19
Source File: Assistant.java    From Dayon with GNU General Public License v3.0 4 votes vote down vote up
private Action createComressionConfigurationAction() {
    final Action configure = new AbstractAction() {

        @Override
        public void actionPerformed(ActionEvent ev) {
            JFrame compressionFrame = (JFrame) SwingUtilities.getRoot((Component) ev.getSource());

            final JPanel pane = new JPanel();
            pane.setLayout(new GridLayout(4, 2, 10, 10));

            final JLabel methodLbl = new JLabel(Babylon.translate("compression.method"));
            // testing only: final JComboBox<CompressionMethod> methodCb = new JComboBox<>(CompressionMethod.values());
            final JComboBox<CompressionMethod> methodCb = new JComboBox<>(Stream.of(CompressionMethod.values()).filter(e -> !e.equals(CompressionMethod.NONE)).toArray(CompressionMethod[]::new));
            methodCb.setSelectedItem(compressorEngineConfiguration.getMethod());

            pane.add(methodLbl);
            pane.add(methodCb);

            final JLabel useCacheLbl = new JLabel(Babylon.translate("compression.cache.usage"));
            final JCheckBox useCacheCb = new JCheckBox();
            useCacheCb.setSelected(compressorEngineConfiguration.useCache());

            pane.add(useCacheLbl);
            pane.add(useCacheCb);

            final JLabel maxSizeLbl = new JLabel(Babylon.translate("compression.cache.max"));
            maxSizeLbl.setToolTipText(Babylon.translate("compression.cache.max.tooltip"));
            final JTextField maxSizeTf = new JTextField(String.valueOf(compressorEngineConfiguration.getCacheMaxSize()));

            pane.add(maxSizeLbl);
            pane.add(maxSizeTf);

            final JLabel purgeSizeLbl = new JLabel(Babylon.translate("compression.cache.purge"));
            purgeSizeLbl.setToolTipText(Babylon.translate("compression.cache.purge.tooltip"));
            final JTextField purgeSizeTf = new JTextField(String.valueOf(compressorEngineConfiguration.getCachePurgeSize()));

            pane.add(purgeSizeLbl);
            pane.add(purgeSizeTf);

            useCacheCb.addActionListener(ev1 -> {
                maxSizeLbl.setEnabled(useCacheCb.isSelected());
                maxSizeTf.setEnabled(useCacheCb.isSelected());
                purgeSizeLbl.setEnabled(useCacheCb.isSelected());
                purgeSizeTf.setEnabled(useCacheCb.isSelected());
            });

            maxSizeLbl.setEnabled(useCacheCb.isSelected());
            maxSizeTf.setEnabled(useCacheCb.isSelected());
            purgeSizeLbl.setEnabled(useCacheCb.isSelected());
            purgeSizeTf.setEnabled(useCacheCb.isSelected());

            final boolean ok = DialogFactory.showOkCancel(compressionFrame, Babylon.translate("compression.settings"), pane, () -> {
                final String max = maxSizeTf.getText();
                if (max.isEmpty()) {
                    return Babylon.translate("compression.cache.max.msg1");
                }

                final int maxValue;

                try {
                    maxValue = Integer.parseInt(max);
                } catch (NumberFormatException ex) {
                    return Babylon.translate("compression.cache.max.msg2");
                }

                if (maxValue <= 0) {
                    return Babylon.translate("compression.cache.max.msg3");
                }

                return validatePurgeValue(purgeSizeTf, maxValue);
            });

            if (ok) {
                final CompressorEngineConfiguration newCompressorEngineConfiguration = new CompressorEngineConfiguration((CompressionMethod) methodCb.getSelectedItem(),
                        useCacheCb.isSelected(), Integer.parseInt(maxSizeTf.getText()), Integer.parseInt(purgeSizeTf.getText()));

                if (!newCompressorEngineConfiguration.equals(compressorEngineConfiguration)) {
                    compressorEngineConfiguration = newCompressorEngineConfiguration;
                    compressorEngineConfiguration.persist();

                    sendCompressorConfiguration(compressorEngineConfiguration);
                }
            }
        }
    };

    configure.putValue(Action.NAME, "configureCompression");
    configure.putValue(Action.SHORT_DESCRIPTION, Babylon.translate("compression.settings.msg"));
    configure.putValue(Action.SMALL_ICON, ImageUtilities.getOrCreateIcon(ImageNames.COMPRESSION_SETTINGS));

    return configure;
}
 
Example 20
Source File: SVGImageExporter.java    From netbeans-mmd-plugin with Apache License 2.0 4 votes vote down vote up
@Nonnull
private String makeContent(@Nonnull final PluginContext context, @Nullable final JComponent options) throws IOException {
  if (options instanceof HasOptions) {
    final HasOptions opts = (HasOptions) options;
    this.flagExpandAllNodes = Boolean.parseBoolean(opts.getOption(Options.KEY_EXPAND_ALL));
    this.flagDrawBackground = Boolean.parseBoolean(opts.getOption(Options.KEY_DRAW_BACK));
  } else {
    for (final Component compo : Assertions.assertNotNull(options).getComponents()) {
      if (compo instanceof JCheckBox) {
        final JCheckBox cb = (JCheckBox) compo;
        if ("unfold".equalsIgnoreCase(cb.getActionCommand())) {
          this.flagExpandAllNodes = cb.isSelected();
        } else if ("back".equalsIgnoreCase(cb.getActionCommand())) {
          this.flagDrawBackground = cb.isSelected();
        }
      }
    }
  }

  final MindMap workMap = new MindMap(context.getPanel().getModel());
  workMap.resetPayload();

  if (this.flagExpandAllNodes) {
    MindMapUtils.removeCollapseAttr(workMap);
  }

  final MindMapPanelConfig newConfig = new MindMapPanelConfig(context.getPanelConfig(), false);
  final String[] mappedFont = LOCAL_FONT_MAP.get(newConfig.getFont().getFamily().toLowerCase(Locale.ENGLISH));
  if (mappedFont != null) {
    final Font adaptedFont = new Font(mappedFont[1], newConfig.getFont().getStyle(), newConfig.getFont().getSize());
    newConfig.setFont(adaptedFont);
  }

  newConfig.setDrawBackground(this.flagDrawBackground);
  newConfig.setScale(1.0f);

  final Dimension2D blockSize = calculateSizeOfMapInPixels(workMap, null, newConfig, flagExpandAllNodes, RenderQuality.DEFAULT);
  if (blockSize == null) {
    return SVG_HEADER + "</svg>";
  }

  final StringBuilder buffer = new StringBuilder(16384);
  buffer.append(String.format(SVG_HEADER, 100, 100, dbl2str(blockSize.getWidth()), dbl2str(blockSize.getHeight()))).append(NEXT_LINE);
  buffer.append(prepareStylePart(buffer, newConfig)).append(NEXT_LINE);

  final BufferedImage image = new BufferedImage(32, 32, BufferedImage.TYPE_INT_RGB);
  final Graphics2D g = image.createGraphics();
  final MMGraphics gfx = new SVGMMGraphics(buffer, g);

  gfx.setClip(0, 0, (int) Math.round(blockSize.getWidth()), (int) Math.round(blockSize.getHeight()));
  try {
    layoutFullDiagramWithCenteringToPaper(gfx, workMap, newConfig, blockSize);
    drawOnGraphicsForConfiguration(gfx, newConfig, workMap, false, null);
  } finally {
    gfx.dispose();
  }
  buffer.append("</svg>");

  return buffer.toString();
}