public GenerateFromBuildFileSelectProjectViewOption(BlazeNewProjectBuilder builder) { this.builder = builder; this.userSettings = builder.getUserSettings(); this.buildFilePathField = new TextFieldWithStoredHistory(LAST_WORKSPACE_PATH); buildFilePathField.setName("build-file-path-field"); buildFilePathField.setHistorySize(BlazeNewProjectBuilder.HISTORY_SIZE); buildFilePathField.setText(userSettings.get(LAST_WORKSPACE_PATH, "")); JButton button = new JButton("..."); button.addActionListener(action -> chooseWorkspacePath()); int buttonSize = buildFilePathField.getPreferredSize().height; button.setPreferredSize(new Dimension(buttonSize, buttonSize)); JComponent box = UiUtil.createHorizontalBox( HORIZONTAL_LAYOUT_GAP, new JLabel("BUILD file:"), buildFilePathField, button); UiUtil.setPreferredWidth(box, PREFERRED_COMPONENT_WIDTH); this.component = box; }
public ImportFromWorkspaceProjectViewOption(BlazeNewProjectBuilder builder) { this.builder = builder; this.userSettings = builder.getUserSettings(); this.projectViewPathField = new TextFieldWithStoredHistory(LAST_WORKSPACE_PATH); projectViewPathField.setHistorySize(BlazeNewProjectBuilder.HISTORY_SIZE); projectViewPathField.setText(userSettings.get(LAST_WORKSPACE_PATH, "")); JButton button = new JButton("..."); button.addActionListener(action -> chooseWorkspacePath()); int buttonSize = projectViewPathField.getPreferredSize().height; button.setPreferredSize(new Dimension(buttonSize, buttonSize)); JComponent box = UiUtil.createHorizontalBox( HORIZONTAL_LAYOUT_GAP, new JLabel("Project view:"), projectViewPathField, button); UiUtil.setPreferredWidth(box, PREFERRED_COMPONENT_WIDTH); this.component = box; }
public CopyExternalProjectViewOption(BlazeNewProjectBuilder builder) { this.userSettings = builder.getUserSettings(); this.projectViewPathField = new TextFieldWithStoredHistory(LAST_WORKSPACE_PATH); projectViewPathField.setHistorySize(BlazeNewProjectBuilder.HISTORY_SIZE); projectViewPathField.setText(userSettings.get(LAST_WORKSPACE_PATH, "")); JButton button = new JButton("..."); button.addActionListener(action -> chooseWorkspacePath()); int buttonSize = projectViewPathField.getPreferredSize().height; button.setPreferredSize(new Dimension(buttonSize, buttonSize)); JComponent box = UiUtil.createHorizontalBox( HORIZONTAL_LAYOUT_GAP, new JLabel("Project view:"), projectViewPathField, button); UiUtil.setPreferredWidth(box, PREFERRED_COMPONENT_WIDTH); this.component = box; }
private void fixButton(final TextFieldWithStoredHistory historyField, ComponentWithBrowseButton<TextFieldWithStoredHistory> control) { FixedSizeButton button = control.getButton(); control.remove(button); BorderLayout borderLayout = new BorderLayout(); JPanel buttonPanel = new JPanel(borderLayout); buttonPanel.setBorder(IdeBorderFactory.createEmptyBorder(4, 0, 4, 0)); buttonPanel.add(button, BorderLayout.CENTER); control.add(buttonPanel, BorderLayout.EAST); button.setAttachedComponent(new JComponent() { public Dimension getPreferredSize() { Dimension size = historyField.getTextEditor().getPreferredSize(); return new Dimension(-1, size.height + 6); } }); }
@SuppressWarnings({"unchecked"}) private static TextFieldWithStoredHistory createHistoryTextField(@NotNull String name, @NotNull String... defaultValues) { TextFieldWithStoredHistory storedHistory = new TextFieldWithStoredHistoryBugFixed(name); storedHistory.reset(); List<String> list = storedHistory.getHistory(); list.removeAll(Arrays.asList(defaultValues)); if (list.isEmpty()) { // Default histories for (String defaultValue : defaultValues) { setTextWithHistory(storedHistory, defaultValue); } } else { storedHistory.setSelectedItem(list.get(list.size() - 1)); } return storedHistory; }
private static void setTextWithHistory(TextFieldWithStoredHistory component, String text) { if (StringUtil.isEmptyOrSpaces(text)) { component.setText(null); } else { component.setText(text); component.addCurrentTextToHistory(); } }
private FileSelectorWithStoredHistory(TextFieldWithStoredHistory textField, String title) { super(textField, null); addBrowseFolderListener( title, "", null, BrowseFilesListener.SINGLE_FILE_DESCRIPTOR, TextComponentAccessor.TEXT_FIELD_WITH_STORED_HISTORY_WHOLE_TEXT); }
private void createUIComponents() { enabledCompilationCheckBox = new StateRestoringCheckBox(JFLEX_ENABLED_COMPILATION_KEY, true); TextFieldWithStoredHistory jflexHomeHistory = createHistoryTextField(JFLEX_HOME_KEY, JFlexSettings.getDefaultJFlexHome()); jFlexHomeTextField = new ComponentWithBrowseButton<TextFieldWithStoredHistory>(jflexHomeHistory, null); fixButton(jflexHomeHistory, jFlexHomeTextField); TextFieldWithStoredHistory skeletonPathHistory = createHistoryTextField(JFLEX_SKELETON_KEY, JFlexSettings.getDefaultSkeletonPath(JFlexSettings.getDefaultJFlexHome())); skeletonPathTextField = new ComponentWithBrowseButton<TextFieldWithStoredHistory>(skeletonPathHistory, null); fixButton(skeletonPathHistory, skeletonPathTextField); commandLineOptionsTextField = createHistoryTextField(JFLEX_OPTIONS_KEY, JFlexSettings.DEFAULT_OPTIONS_CHARAT_NOBAK); enabledEmbedJavaCheckBox = new StateRestoringCheckBox(JFLEX_ENABLED_EMBED_JAVA_KEY, true); }
private void createUIComponents() { peopleTextField = new TextFieldWithStoredHistory("rb.people"); // peopleTextField.addKeyboardListener(new KeyAdapter() { // @Override // public void keyTyped(KeyEvent e) { // System.out.println(e); // if (e.getKeyCode() == KeyEvent.VK_DELETE) { // peopleTextField.setSelectedIndex(-1); //// peopleTextField // } // } // }); groupTextField = new TextFieldWithStoredHistory("rb.group"); }
@Override public String getText(TextFieldWithStoredHistory textField) { return textField.getText(); }
@Override public void setText(TextFieldWithStoredHistory textField, @NotNull String text) { textField.setText(text); }
public static FileSelectorWithStoredHistory create(String historyKey, String title) { TextFieldWithStoredHistory textField = new TextFieldWithStoredHistory(historyKey); return new FileSelectorWithStoredHistory(textField, title); }
public String getText(TextFieldWithStoredHistory component) { return component.getText().replace('\\', '/'); }
public void setText(TextFieldWithStoredHistory component, String text) { setTextWithHistory(component, text); }
public String getText(TextFieldWithStoredHistory textField) { return textField.getText(); }
public void setText(TextFieldWithStoredHistory textField, String text) { textField.setText(text); }